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