1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.server.wm; 17 18 import android.annotation.SystemApi; 19 import android.annotation.UserIdInt; 20 import android.content.Intent; 21 import android.content.pm.ActivityInfo; 22 23 /** 24 * A wrapper over {@link com.android.server.wm.ActivityInterceptorCallback.ActivityInterceptorInfo}. 25 * 26 * @hide 27 */ 28 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 29 public final class ActivityInterceptorInfoWrapper { 30 private final ActivityInterceptorCallback.ActivityInterceptorInfo mActivityInterceptorInfo; 31 ActivityInterceptorInfoWrapper( ActivityInterceptorCallback.ActivityInterceptorInfo interceptorInfo)32 private ActivityInterceptorInfoWrapper( 33 ActivityInterceptorCallback.ActivityInterceptorInfo interceptorInfo) { 34 mActivityInterceptorInfo = interceptorInfo; 35 } 36 37 /** 38 * Creates an instance of {@link ActivityInterceptorInfoWrapper}. 39 * 40 * @param interceptorInfo the original interceptorInfo that needs to be wrapped. 41 * @hide 42 */ create( ActivityInterceptorCallback.ActivityInterceptorInfo interceptorInfo)43 public static ActivityInterceptorInfoWrapper create( 44 ActivityInterceptorCallback.ActivityInterceptorInfo interceptorInfo) { 45 return new ActivityInterceptorInfoWrapper(interceptorInfo); 46 } 47 getIntent()48 public Intent getIntent() { 49 return mActivityInterceptorInfo.getIntent(); 50 } 51 getActivityInfo()52 public ActivityInfo getActivityInfo() { 53 return mActivityInterceptorInfo.getActivityInfo(); 54 } 55 getCheckedOptions()56 public ActivityOptionsWrapper getCheckedOptions() { 57 return ActivityOptionsWrapper.create(mActivityInterceptorInfo.getCheckedOptions()); 58 59 } 60 getCallingPackage()61 public String getCallingPackage() { 62 return mActivityInterceptorInfo.getCallingPackage(); 63 } 64 65 @UserIdInt getUserId()66 public int getUserId() { 67 return mActivityInterceptorInfo.getUserId(); 68 } 69 getCallingUid()70 public int getCallingUid() { 71 int callingUid = mActivityInterceptorInfo.getCallingUid() != -1 72 ? mActivityInterceptorInfo.getCallingUid() 73 : mActivityInterceptorInfo.getRealCallingUid(); 74 return callingUid; 75 } 76 getCallingPid()77 public int getCallingPid() { 78 int callingPid = mActivityInterceptorInfo.getCallingPid() != -1 79 ? mActivityInterceptorInfo.getCallingPid() 80 : mActivityInterceptorInfo.getRealCallingPid(); 81 return callingPid; 82 } 83 } 84