• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 
17 package com.android.server.wm;
18 
19 import android.annotation.Nullable;
20 import android.annotation.SystemApi;
21 import android.car.builtin.annotation.PlatformVersion;
22 import android.content.ComponentName;
23 import android.content.pm.ActivityInfo;
24 
25 import com.android.annotation.AddedIn;
26 
27 /**
28  * Wrapper of {@link ActivityRecord}.
29  * @hide
30  */
31 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
32 public final class ActivityRecordWrapper {
33     private final ActivityRecord mActivityRecord;
34 
ActivityRecordWrapper(ActivityRecord activityRecord)35     private ActivityRecordWrapper(ActivityRecord activityRecord) {
36         mActivityRecord = activityRecord;
37     }
38 
39     /** @hide */
40     @AddedIn(PlatformVersion.TIRAMISU_0)
create(@ullable ActivityRecord activityRecord)41     public static ActivityRecordWrapper create(@Nullable ActivityRecord activityRecord) {
42         if (activityRecord == null) return null;
43         return new ActivityRecordWrapper(activityRecord);
44     }
45 
46     /** @hide */
47     @AddedIn(PlatformVersion.TIRAMISU_0)
getActivityRecord()48     public ActivityRecord getActivityRecord() {
49         return mActivityRecord;
50     }
51 
52     /**
53      * Gets which user this Activity is running for.
54      */
55     @AddedIn(PlatformVersion.TIRAMISU_0)
getUserId()56     public int getUserId() {
57         return mActivityRecord.mUserId;
58     }
59 
60     /**
61      * Gets the actual {@link ComponentName} of this Activity.
62      */
63     @AddedIn(PlatformVersion.TIRAMISU_0)
getComponentName()64     public ComponentName getComponentName() {
65         if (mActivityRecord.info == null) return null;
66         return mActivityRecord.info.getComponentName();
67     }
68 
69     /**
70      * Gets the {@link TaskDisplayAreaWrapper} where this is located.
71      */
72     @AddedIn(PlatformVersion.TIRAMISU_0)
getDisplayArea()73     public TaskDisplayAreaWrapper getDisplayArea() {
74         return TaskDisplayAreaWrapper.create(mActivityRecord.getDisplayArea());
75     }
76 
77     /**
78      * Returns whether this Activity is not displayed.
79      */
80     @AddedIn(PlatformVersion.TIRAMISU_0)
isNoDisplay()81     public boolean isNoDisplay() {
82         return mActivityRecord.noDisplay;
83     }
84 
85     /**
86      * Gets {@link TaskDisplayAreaWrapper} where the handover Activity is supposed to launch
87      */
88     @AddedIn(PlatformVersion.TIRAMISU_0)
getHandoverTaskDisplayArea()89     public TaskDisplayAreaWrapper getHandoverTaskDisplayArea() {
90         return TaskDisplayAreaWrapper.create(mActivityRecord.mHandoverTaskDisplayArea);
91     }
92 
93     /**
94      * Gets {@code displayId} where the handover Activity is supposed to launch
95      */
96     @AddedIn(PlatformVersion.TIRAMISU_0)
getHandoverLaunchDisplayId()97     public int getHandoverLaunchDisplayId() {
98         return mActivityRecord.mHandoverLaunchDisplayId;
99     }
100 
101     /**
102      * Returns whether this Activity allows to be embedded in the other Activity.
103      */
104     @AddedIn(PlatformVersion.TIRAMISU_0)
allowingEmbedded()105     public boolean allowingEmbedded() {
106         if (mActivityRecord.info == null) return false;
107         return (mActivityRecord.info.flags & ActivityInfo.FLAG_ALLOW_EMBEDDED) != 0;
108     }
109 
110     /**
111      * Returns whether the display where this Activity is located is trusted.
112      */
113     @AddedIn(PlatformVersion.TIRAMISU_0)
isDisplayTrusted()114     public boolean isDisplayTrusted() {
115         return mActivityRecord.getDisplayContent().isTrusted();
116     }
117 
118     @Override
119     @AddedIn(PlatformVersion.TIRAMISU_0)
toString()120     public String toString() {
121         return mActivityRecord.toString();
122     }
123 }
124