The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 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.am; |
| 18 | |
Wale Ogunwale | 4cea0f5 | 2015-12-25 06:30:31 -0800 | [diff] [blame] | 19 | import static android.app.ActivityManager.StackId; |
Wale Ogunwale | 826c706 | 2016-09-13 08:25:54 -0700 | [diff] [blame] | 20 | import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; |
Filip Gruszczynski | 3d02671 | 2015-12-16 13:46:38 -0800 | [diff] [blame] | 21 | import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; |
Wale Ogunwale | 22e2526 | 2016-02-01 10:32:02 -0800 | [diff] [blame] | 22 | import static android.app.ActivityManager.StackId.PINNED_STACK_ID; |
Wale Ogunwale | 513346d | 2016-01-27 10:55:01 -0800 | [diff] [blame] | 23 | import static android.content.pm.ActivityInfo.RESIZE_MODE_CROP_WINDOWS; |
Wale Ogunwale | 6cae765 | 2015-12-26 07:36:26 -0800 | [diff] [blame] | 24 | import static android.content.pm.ActivityInfo.FLAG_ALWAYS_FOCUSABLE; |
Jorim Jaggi | cd13d33 | 2016-04-27 15:40:20 -0700 | [diff] [blame] | 25 | import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE; |
Wale Ogunwale | d26176f | 2016-01-25 20:04:04 -0800 | [diff] [blame] | 26 | import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE_AND_PIPABLE; |
Filip Gruszczynski | 3d02671 | 2015-12-16 13:46:38 -0800 | [diff] [blame] | 27 | import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_CONFIGURATION; |
Filip Gruszczynski | 3d02671 | 2015-12-16 13:46:38 -0800 | [diff] [blame] | 28 | import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_SWITCH; |
| 29 | import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_THUMBNAILS; |
| 30 | import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_STATES; |
| 31 | import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_SWITCH; |
| 32 | import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_THUMBNAILS; |
| 33 | import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM; |
| 34 | import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME; |
Wale Ogunwale | 18795a2 | 2014-12-03 11:38:33 -0800 | [diff] [blame] | 35 | import static com.android.server.am.TaskRecord.INVALID_TASK_ID; |
| 36 | |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 37 | import android.app.ActivityManager.TaskDescription; |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 38 | import android.app.ActivityOptions; |
Filip Gruszczynski | 3d02671 | 2015-12-16 13:46:38 -0800 | [diff] [blame] | 39 | import android.app.PendingIntent; |
Craig Mautner | 05d6272ba | 2013-02-11 09:39:27 -0800 | [diff] [blame] | 40 | import android.app.ResultInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | import android.content.ComponentName; |
| 42 | import android.content.Intent; |
| 43 | import android.content.pm.ActivityInfo; |
| 44 | import android.content.pm.ApplicationInfo; |
Dianne Hackborn | 8ea5e1d | 2011-05-27 16:45:31 -0700 | [diff] [blame] | 45 | import android.content.res.CompatibilityInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | import android.content.res.Configuration; |
| 47 | import android.graphics.Bitmap; |
Dianne Hackborn | d367ca8 | 2012-05-07 15:49:39 -0700 | [diff] [blame] | 48 | import android.graphics.Rect; |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 49 | import android.os.Build; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 50 | import android.os.Bundle; |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 51 | import android.os.IBinder; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | import android.os.Message; |
Filip Gruszczynski | 3d02671 | 2015-12-16 13:46:38 -0800 | [diff] [blame] | 53 | import android.os.PersistableBundle; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | import android.os.Process; |
Dianne Hackborn | 39792d2 | 2010-08-19 18:01:52 -0700 | [diff] [blame] | 55 | import android.os.RemoteException; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 56 | import android.os.SystemClock; |
Filip Gruszczynski | 3d02671 | 2015-12-16 13:46:38 -0800 | [diff] [blame] | 57 | import android.os.Trace; |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 58 | import android.os.UserHandle; |
Amith Yamasani | 0af6fa7 | 2016-01-17 15:36:19 -0800 | [diff] [blame] | 59 | import android.service.voice.IVoiceInteractionSession; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | import android.util.EventLog; |
| 61 | import android.util.Log; |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 62 | import android.util.Slog; |
Dianne Hackborn | 0dad364 | 2010-09-09 21:25:35 -0700 | [diff] [blame] | 63 | import android.util.TimeUtils; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 64 | import android.view.AppTransitionAnimationSpec; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 65 | import android.view.IApplicationToken; |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 66 | import android.view.WindowManager; |
Jeff Sharkey | 8a4c972 | 2014-06-16 13:48:42 -0700 | [diff] [blame] | 67 | |
Filip Gruszczynski | 3d02671 | 2015-12-16 13:46:38 -0800 | [diff] [blame] | 68 | import com.android.internal.app.ResolverActivity; |
| 69 | import com.android.internal.content.ReferrerIntent; |
| 70 | import com.android.internal.util.XmlUtils; |
| 71 | import com.android.server.AttributeCache; |
| 72 | import com.android.server.am.ActivityStack.ActivityState; |
| 73 | import com.android.server.am.ActivityStackSupervisor.ActivityContainer; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | |
Suprabh Shukla | 2359314 | 2015-11-03 17:31:15 -0800 | [diff] [blame] | 75 | import java.io.File; |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 76 | import java.io.IOException; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 77 | import java.io.PrintWriter; |
| 78 | import java.lang.ref.WeakReference; |
| 79 | import java.util.ArrayList; |
Todd Kennedy | 39bfee5 | 2016-02-24 10:28:21 -0800 | [diff] [blame] | 80 | import java.util.Arrays; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 81 | import java.util.HashSet; |
Jeff Sharkey | 8a4c972 | 2014-06-16 13:48:42 -0700 | [diff] [blame] | 82 | import java.util.Objects; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 83 | |
Filip Gruszczynski | 3d02671 | 2015-12-16 13:46:38 -0800 | [diff] [blame] | 84 | import org.xmlpull.v1.XmlPullParser; |
| 85 | import org.xmlpull.v1.XmlPullParserException; |
| 86 | import org.xmlpull.v1.XmlSerializer; |
| 87 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 88 | /** |
| 89 | * An entry in the history stack, representing an activity. |
| 90 | */ |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 91 | final class ActivityRecord { |
Wale Ogunwale | e23149f | 2015-03-06 15:39:44 -0800 | [diff] [blame] | 92 | private static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityRecord" : TAG_AM; |
Wale Ogunwale | 0fc365c | 2015-05-25 19:35:42 -0700 | [diff] [blame] | 93 | private static final String TAG_STATES = TAG + POSTFIX_STATES; |
Wale Ogunwale | ee006da | 2015-03-30 14:49:25 -0700 | [diff] [blame] | 94 | private static final String TAG_SWITCH = TAG + POSTFIX_SWITCH; |
| 95 | private static final String TAG_THUMBNAILS = TAG + POSTFIX_THUMBNAILS; |
Wale Ogunwale | e23149f | 2015-03-06 15:39:44 -0800 | [diff] [blame] | 96 | |
Wale Ogunwale | 3ab9a27 | 2015-03-16 09:55:45 -0700 | [diff] [blame] | 97 | private static final boolean SHOW_ACTIVITY_START_TIME = true; |
Winson Chung | 740c3ac | 2014-11-12 16:14:38 -0800 | [diff] [blame] | 98 | final public static String RECENTS_PACKAGE_NAME = "com.android.systemui.recents"; |
Craig Mautner | b59dcfd | 2013-05-06 13:12:58 -0700 | [diff] [blame] | 99 | |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 100 | private static final String ATTR_ID = "id"; |
| 101 | private static final String TAG_INTENT = "intent"; |
| 102 | private static final String ATTR_USERID = "user_id"; |
| 103 | private static final String TAG_PERSISTABLEBUNDLE = "persistable_bundle"; |
| 104 | private static final String ATTR_LAUNCHEDFROMUID = "launched_from_uid"; |
Stefan Kuhne | e88d1e5 | 2015-05-18 10:33:45 -0700 | [diff] [blame] | 105 | private static final String ATTR_LAUNCHEDFROMPACKAGE = "launched_from_package"; |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 106 | private static final String ATTR_RESOLVEDTYPE = "resolved_type"; |
| 107 | private static final String ATTR_COMPONENTSPECIFIED = "component_specified"; |
Dianne Hackborn | 337abb3 | 2014-09-24 12:44:29 -0700 | [diff] [blame] | 108 | static final String ACTIVITY_ICON_SUFFIX = "_activity_icon_"; |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 109 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 110 | final ActivityManagerService service; // owner |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 111 | final IApplicationToken.Stub appToken; // window manager token |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 112 | final ActivityInfo info; // all about me |
Jeff Sharkey | 8a4c972 | 2014-06-16 13:48:42 -0700 | [diff] [blame] | 113 | final ApplicationInfo appInfo; // information about activity's app |
Stefan Kuhne | e88d1e5 | 2015-05-18 10:33:45 -0700 | [diff] [blame] | 114 | final int launchedFromUid; // always the uid who started the activity. |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 115 | final String launchedFromPackage; // always the package who started the activity. |
Amith Yamasani | 742a671 | 2011-05-04 14:49:28 -0700 | [diff] [blame] | 116 | final int userId; // Which user is this running for? |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 117 | final Intent intent; // the original intent that generated us |
| 118 | final ComponentName realActivity; // the intent component, or target of an alias. |
| 119 | final String shortComponentName; // the short component name of the intent |
| 120 | final String resolvedType; // as per original caller; |
| 121 | final String packageName; // the package implementing intent's component |
| 122 | final String processName; // process where this component wants to run |
| 123 | final String taskAffinity; // as per ActivityInfo.taskAffinity |
| 124 | final boolean stateNotNeeded; // As per ActivityInfo.flags |
Craig Mautner | 4addfc5 | 2013-06-25 08:05:45 -0700 | [diff] [blame] | 125 | boolean fullscreen; // covers the full screen? |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 126 | final boolean noDisplay; // activity is not displayed? |
Ruben Brunk | e24b9a6 | 2016-02-16 21:38:24 -0800 | [diff] [blame] | 127 | final boolean componentSpecified; // did caller specify an explicit component? |
Dianne Hackborn | fb81d09 | 2015-08-03 17:14:46 -0700 | [diff] [blame] | 128 | final boolean rootVoiceInteraction; // was this the root activity of a voice interaction? |
Craig Mautner | 86d67a4 | 2013-05-14 10:34:38 -0700 | [diff] [blame] | 129 | |
| 130 | static final int APPLICATION_ACTIVITY_TYPE = 0; |
| 131 | static final int HOME_ACTIVITY_TYPE = 1; |
| 132 | static final int RECENTS_ACTIVITY_TYPE = 2; |
Craig Mautner | 2c1faed | 2013-07-23 12:56:02 -0700 | [diff] [blame] | 133 | int mActivityType; |
Craig Mautner | 86d67a4 | 2013-05-14 10:34:38 -0700 | [diff] [blame] | 134 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 135 | CharSequence nonLocalizedLabel; // the label information from the package mgr. |
| 136 | int labelRes; // the label information from the package mgr. |
| 137 | int icon; // resource identifier of activity's icon. |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 138 | int logo; // resource identifier of activity's logo. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 139 | int theme; // resource identifier of activity's theme. |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 140 | int realTheme; // actual theme resource we will use, never 0. |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 141 | int windowFlags; // custom window flags for preview window. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 142 | TaskRecord task; // the task this is in. |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 143 | long createTime = System.currentTimeMillis(); |
Dianne Hackborn | 2286cdc | 2013-07-01 19:10:06 -0700 | [diff] [blame] | 144 | long displayStartTime; // when we started launching this activity |
| 145 | long fullyDrawnStartTime; // when we started launching this activity |
Dianne Hackborn | 0dad364 | 2010-09-09 21:25:35 -0700 | [diff] [blame] | 146 | long startTime; // last time this activity was started |
Dianne Hackborn | 5068560 | 2011-12-01 12:23:37 -0800 | [diff] [blame] | 147 | long lastVisibleTime; // last time this activity became visible |
Amith Yamasani | eaeb663 | 2009-06-03 15:16:10 -0700 | [diff] [blame] | 148 | long cpuTimeAtResume; // the cpu time of host process at the time of resuming activity |
Dianne Hackborn | 2a29b3a | 2012-03-15 15:48:38 -0700 | [diff] [blame] | 149 | long pauseTime; // last time we started pausing the activity |
| 150 | long launchTickTime; // base time for launch tick messages |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 151 | Configuration configuration; // configuration activity was last running in |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 152 | // Overridden configuration by the activity task |
| 153 | // WARNING: Reference points to {@link TaskRecord#mOverrideConfig}, so its internal state |
Wale Ogunwale | 60454db | 2015-01-23 16:05:07 -0800 | [diff] [blame] | 154 | // should never be altered directly. |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 155 | Configuration taskConfigOverride; |
Dianne Hackborn | 8ea5e1d | 2011-05-27 16:45:31 -0700 | [diff] [blame] | 156 | CompatibilityInfo compat;// last used compatibility mode |
Dianne Hackborn | 01e4cfc | 2010-06-24 15:07:24 -0700 | [diff] [blame] | 157 | ActivityRecord resultTo; // who started this entry, so will get our reply |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 158 | final String resultWho; // additional identifier for use by resultTo. |
| 159 | final int requestCode; // code given by requester (resultTo) |
Craig Mautner | 05d6272ba | 2013-02-11 09:39:27 -0800 | [diff] [blame] | 160 | ArrayList<ResultInfo> results; // pending ActivityResult objs we have received |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 161 | HashSet<WeakReference<PendingIntentRecord>> pendingResults; // all pending intents for this act |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 162 | ArrayList<ReferrerIntent> newIntents; // any pending new intents for single-top mode |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 163 | ActivityOptions pendingOptions; // most recently given options |
George Mount | 6ba042b | 2014-07-28 11:12:28 -0700 | [diff] [blame] | 164 | ActivityOptions returningOptions; // options that are coming back via convertToTranslucent |
Dianne Hackborn | b5a380d | 2015-05-20 18:18:46 -0700 | [diff] [blame] | 165 | AppTimeTracker appTimeTracker; // set if we are tracking the time in this app/task/activity |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 166 | HashSet<ConnectionRecord> connections; // All ConnectionRecord we hold |
Dianne Hackborn | 7e26964 | 2010-08-25 19:50:20 -0700 | [diff] [blame] | 167 | UriPermissionOwner uriPermissions; // current special URI access perms. |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 168 | ProcessRecord app; // if non-null, hosting application |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 169 | ActivityState state; // current state we are in |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 170 | Bundle icicle; // last saved activity state |
Craig Mautner | a002604 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 171 | PersistableBundle persistentState; // last persistently saved activity state |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 172 | boolean frontOfTask; // is this the root activity of its task? |
| 173 | boolean launchFailed; // set if a launched failed, to abort on 2nd try |
| 174 | boolean haveState; // have we gotten the last activity state? |
| 175 | boolean stopped; // is activity pause finished? |
Dianne Hackborn | 95fc68f | 2009-05-19 18:37:45 -0700 | [diff] [blame] | 176 | boolean delayedResume; // not yet resumed because of stopped app switches? |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 177 | boolean finishing; // activity in pending finish list? |
Wale Ogunwale | f81c1d1 | 2016-01-12 12:20:18 -0800 | [diff] [blame] | 178 | boolean deferRelaunchUntilPaused; // relaunch of activity is being deferred until pause is |
| 179 | // completed |
| 180 | boolean preserveWindowOnDeferredRelaunch; // activity windows are preserved on deferred relaunch |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 181 | int configChangeFlags; // which config values have changed |
| 182 | boolean keysPaused; // has key dispatching been paused for it? |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 183 | int launchMode; // the launch mode activity attribute. |
| 184 | boolean visible; // does this activity's window need to be shown? |
Dianne Hackborn | 4eba96b | 2011-01-21 13:34:36 -0800 | [diff] [blame] | 185 | boolean sleeping; // have we told the activity to sleep? |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 186 | boolean nowVisible; // is this activity's window visible? |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 187 | boolean idle; // has the activity gone idle? |
| 188 | boolean hasBeenLaunched;// has this activity ever been launched? |
| 189 | boolean frozenBeforeDestroy;// has been frozen but not yet destroyed. |
Daniel Sandler | 69a4817 | 2010-06-23 16:29:36 -0400 | [diff] [blame] | 190 | boolean immersive; // immersive mode (don't interrupt if possible) |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 191 | boolean forceNewConfig; // force re-create with new config next time |
Dianne Hackborn | 0798149 | 2013-01-28 11:36:23 -0800 | [diff] [blame] | 192 | int launchCount; // count of launches since last state |
Wale Ogunwale | f81c1d1 | 2016-01-12 12:20:18 -0800 | [diff] [blame] | 193 | long lastLaunchTime; // time of last launch of this activity |
Ruben Brunk | e24b9a6 | 2016-02-16 21:38:24 -0800 | [diff] [blame] | 194 | ComponentName requestedVrComponent; // the requested component for handling VR mode. |
Wale Ogunwale | f81c1d1 | 2016-01-12 12:20:18 -0800 | [diff] [blame] | 195 | ArrayList<ActivityContainer> mChildContainers = new ArrayList<>(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 196 | |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 197 | String stringName; // for caching of toString(). |
Craig Mautner | de4ef02 | 2013-04-07 19:01:33 -0700 | [diff] [blame] | 198 | |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 199 | private boolean inHistory; // are we in the history stack? |
Craig Mautner | de4ef02 | 2013-04-07 19:01:33 -0700 | [diff] [blame] | 200 | final ActivityStackSupervisor mStackSupervisor; |
Wale Ogunwale | f40c11b | 2016-02-26 08:16:02 -0800 | [diff] [blame] | 201 | |
| 202 | static final int STARTING_WINDOW_NOT_SHOWN = 0; |
| 203 | static final int STARTING_WINDOW_SHOWN = 1; |
| 204 | static final int STARTING_WINDOW_REMOVED = 2; |
| 205 | int mStartingWindowState = STARTING_WINDOW_NOT_SHOWN; |
Wale Ogunwale | 3b23239 | 2016-05-13 15:37:13 -0700 | [diff] [blame] | 206 | boolean mTaskOverlay = false; // Task is always on-top of other activities in the task. |
Wale Ogunwale | f40c11b | 2016-02-26 08:16:02 -0800 | [diff] [blame] | 207 | |
Jorim Jaggi | c2f262b | 2015-12-07 16:59:10 -0800 | [diff] [blame] | 208 | boolean mUpdateTaskThumbnailWhenHidden; |
Craig Mautner | e0a3884 | 2013-12-16 16:14:02 -0800 | [diff] [blame] | 209 | ActivityContainer mInitialActivityContainer; |
Craig Mautner | de4ef02 | 2013-04-07 19:01:33 -0700 | [diff] [blame] | 210 | |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 211 | TaskDescription taskDescription; // the recents information for this activity |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 212 | boolean mLaunchTaskBehind; // this activity is actively being launched with |
| 213 | // ActivityOptions.setLaunchTaskBehind, will be cleared once launch is completed. |
Craig Mautner | 2fbd754 | 2014-03-21 09:34:07 -0700 | [diff] [blame] | 214 | |
Filip Gruszczynski | 2349332 | 2015-07-29 17:02:59 -0700 | [diff] [blame] | 215 | // These configurations are collected from application's resources based on size-sensitive |
| 216 | // qualifiers. For example, layout-w800dp will be added to mHorizontalSizeConfigurations as 800 |
| 217 | // and drawable-sw400dp will be added to both as 400. |
| 218 | private int[] mVerticalSizeConfigurations; |
| 219 | private int[] mHorizontalSizeConfigurations; |
Filip Gruszczynski | 20aa0ae | 2015-10-30 10:08:27 -0700 | [diff] [blame] | 220 | private int[] mSmallestSizeConfigurations; |
Filip Gruszczynski | 2349332 | 2015-07-29 17:02:59 -0700 | [diff] [blame] | 221 | |
Amith Yamasani | 0af6fa7 | 2016-01-17 15:36:19 -0800 | [diff] [blame] | 222 | boolean pendingVoiceInteractionStart; // Waiting for activity-invoked voice session |
| 223 | IVoiceInteractionSession voiceSession; // Voice interaction session for this activity |
| 224 | |
Robert Carr | d226512 | 2016-08-05 10:25:21 -0700 | [diff] [blame] | 225 | // A hint to override the window specified rotation animation, or -1 |
| 226 | // to use the window specified value. We use this so that |
| 227 | // we can select the right animation in the cases of starting |
| 228 | // windows, where the app hasn't had time to set a value |
| 229 | // on the window. |
| 230 | int mRotationAnimationHint = -1; |
Robert Carr | fd10cd1 | 2016-06-29 16:41:50 -0700 | [diff] [blame] | 231 | |
Wale Ogunwale | f40c11b | 2016-02-26 08:16:02 -0800 | [diff] [blame] | 232 | private static String startingWindowStateToString(int state) { |
| 233 | switch (state) { |
| 234 | case STARTING_WINDOW_NOT_SHOWN: |
| 235 | return "STARTING_WINDOW_NOT_SHOWN"; |
| 236 | case STARTING_WINDOW_SHOWN: |
| 237 | return "STARTING_WINDOW_SHOWN"; |
| 238 | case STARTING_WINDOW_REMOVED: |
| 239 | return "STARTING_WINDOW_REMOVED"; |
| 240 | default: |
| 241 | return "unknown state=" + state; |
| 242 | } |
| 243 | } |
| 244 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 245 | void dump(PrintWriter pw, String prefix) { |
Dianne Hackborn | f530ac3 | 2012-06-21 14:17:48 -0700 | [diff] [blame] | 246 | final long now = SystemClock.uptimeMillis(); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 247 | pw.print(prefix); pw.print("packageName="); pw.print(packageName); |
| 248 | pw.print(" processName="); pw.println(processName); |
| 249 | pw.print(prefix); pw.print("launchedFromUid="); pw.print(launchedFromUid); |
Craig Mautner | e11f2b7 | 2013-04-01 12:37:17 -0700 | [diff] [blame] | 250 | pw.print(" launchedFromPackage="); pw.print(launchedFromPackage); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 251 | pw.print(" userId="); pw.println(userId); |
| 252 | pw.print(prefix); pw.print("app="); pw.println(app); |
| 253 | pw.print(prefix); pw.println(intent.toInsecureStringWithClip()); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 254 | pw.print(prefix); pw.print("frontOfTask="); pw.print(frontOfTask); |
| 255 | pw.print(" task="); pw.println(task); |
| 256 | pw.print(prefix); pw.print("taskAffinity="); pw.println(taskAffinity); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 257 | pw.print(prefix); pw.print("realActivity="); |
| 258 | pw.println(realActivity.flattenToShortString()); |
Jeff Sharkey | 8a4c972 | 2014-06-16 13:48:42 -0700 | [diff] [blame] | 259 | if (appInfo != null) { |
| 260 | pw.print(prefix); pw.print("baseDir="); pw.println(appInfo.sourceDir); |
| 261 | if (!Objects.equals(appInfo.sourceDir, appInfo.publicSourceDir)) { |
| 262 | pw.print(prefix); pw.print("resDir="); pw.println(appInfo.publicSourceDir); |
| 263 | } |
| 264 | pw.print(prefix); pw.print("dataDir="); pw.println(appInfo.dataDir); |
Todd Kennedy | 39bfee5 | 2016-02-24 10:28:21 -0800 | [diff] [blame] | 265 | if (appInfo.splitSourceDirs != null) { |
| 266 | pw.print(prefix); pw.print("splitDir="); |
| 267 | pw.println(Arrays.toString(appInfo.splitSourceDirs)); |
| 268 | } |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 269 | } |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 270 | pw.print(prefix); pw.print("stateNotNeeded="); pw.print(stateNotNeeded); |
| 271 | pw.print(" componentSpecified="); pw.print(componentSpecified); |
Craig Mautner | 86d67a4 | 2013-05-14 10:34:38 -0700 | [diff] [blame] | 272 | pw.print(" mActivityType="); pw.println(mActivityType); |
Dianne Hackborn | fb81d09 | 2015-08-03 17:14:46 -0700 | [diff] [blame] | 273 | if (rootVoiceInteraction) { |
| 274 | pw.print(prefix); pw.print("rootVoiceInteraction="); pw.println(rootVoiceInteraction); |
| 275 | } |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 276 | pw.print(prefix); pw.print("compat="); pw.print(compat); |
| 277 | pw.print(" labelRes=0x"); pw.print(Integer.toHexString(labelRes)); |
| 278 | pw.print(" icon=0x"); pw.print(Integer.toHexString(icon)); |
| 279 | pw.print(" theme=0x"); pw.println(Integer.toHexString(theme)); |
Dianne Hackborn | e17aeb3 | 2011-04-07 15:11:57 -0700 | [diff] [blame] | 280 | pw.print(prefix); pw.print("config="); pw.println(configuration); |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 281 | pw.print(prefix); pw.print("taskConfigOverride="); pw.println(taskConfigOverride); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 282 | if (resultTo != null || resultWho != null) { |
| 283 | pw.print(prefix); pw.print("resultTo="); pw.print(resultTo); |
| 284 | pw.print(" resultWho="); pw.print(resultWho); |
| 285 | pw.print(" resultCode="); pw.println(requestCode); |
| 286 | } |
Craig Mautner | 29c58ca | 2014-10-14 16:17:06 -0700 | [diff] [blame] | 287 | if (taskDescription != null) { |
| 288 | final String iconFilename = taskDescription.getIconFilename(); |
| 289 | if (iconFilename != null || taskDescription.getLabel() != null || |
| 290 | taskDescription.getPrimaryColor() != 0) { |
| 291 | pw.print(prefix); pw.print("taskDescription:"); |
| 292 | pw.print(" iconFilename="); pw.print(taskDescription.getIconFilename()); |
| 293 | pw.print(" label=\""); pw.print(taskDescription.getLabel()); |
| 294 | pw.print("\""); |
| 295 | pw.print(" color="); |
| 296 | pw.println(Integer.toHexString(taskDescription.getPrimaryColor())); |
| 297 | } |
| 298 | if (iconFilename == null && taskDescription.getIcon() != null) { |
| 299 | pw.print(prefix); pw.println("taskDescription contains Bitmap"); |
| 300 | } |
Craig Mautner | 648f69b | 2014-09-18 14:16:26 -0700 | [diff] [blame] | 301 | } |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 302 | if (results != null) { |
| 303 | pw.print(prefix); pw.print("results="); pw.println(results); |
| 304 | } |
Dianne Hackborn | f530ac3 | 2012-06-21 14:17:48 -0700 | [diff] [blame] | 305 | if (pendingResults != null && pendingResults.size() > 0) { |
| 306 | pw.print(prefix); pw.println("Pending Results:"); |
| 307 | for (WeakReference<PendingIntentRecord> wpir : pendingResults) { |
| 308 | PendingIntentRecord pir = wpir != null ? wpir.get() : null; |
| 309 | pw.print(prefix); pw.print(" - "); |
| 310 | if (pir == null) { |
| 311 | pw.println("null"); |
| 312 | } else { |
| 313 | pw.println(pir); |
| 314 | pir.dump(pw, prefix + " "); |
| 315 | } |
| 316 | } |
| 317 | } |
| 318 | if (newIntents != null && newIntents.size() > 0) { |
| 319 | pw.print(prefix); pw.println("Pending New Intents:"); |
| 320 | for (int i=0; i<newIntents.size(); i++) { |
Craig Mautner | d232895 | 2013-03-05 12:46:26 -0800 | [diff] [blame] | 321 | Intent intent = newIntents.get(i); |
Dianne Hackborn | f530ac3 | 2012-06-21 14:17:48 -0700 | [diff] [blame] | 322 | pw.print(prefix); pw.print(" - "); |
| 323 | if (intent == null) { |
| 324 | pw.println("null"); |
| 325 | } else { |
| 326 | pw.println(intent.toShortString(false, true, false, true)); |
| 327 | } |
| 328 | } |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 329 | } |
Dianne Hackborn | 6e3d6da | 2012-06-15 12:05:27 -0700 | [diff] [blame] | 330 | if (pendingOptions != null) { |
| 331 | pw.print(prefix); pw.print("pendingOptions="); pw.println(pendingOptions); |
| 332 | } |
Dianne Hackborn | b5a380d | 2015-05-20 18:18:46 -0700 | [diff] [blame] | 333 | if (appTimeTracker != null) { |
| 334 | appTimeTracker.dumpWithHeader(pw, prefix, false); |
| 335 | } |
Dianne Hackborn | 7e26964 | 2010-08-25 19:50:20 -0700 | [diff] [blame] | 336 | if (uriPermissions != null) { |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 337 | uriPermissions.dump(pw, prefix); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 338 | } |
| 339 | pw.print(prefix); pw.print("launchFailed="); pw.print(launchFailed); |
Dianne Hackborn | 0798149 | 2013-01-28 11:36:23 -0800 | [diff] [blame] | 340 | pw.print(" launchCount="); pw.print(launchCount); |
| 341 | pw.print(" lastLaunchTime="); |
| 342 | if (lastLaunchTime == 0) pw.print("0"); |
| 343 | else TimeUtils.formatDuration(lastLaunchTime, now, pw); |
| 344 | pw.println(); |
Dianne Hackborn | cfc837f | 2013-06-27 18:32:07 -0700 | [diff] [blame] | 345 | pw.print(prefix); pw.print("haveState="); pw.print(haveState); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 346 | pw.print(" icicle="); pw.println(icicle); |
| 347 | pw.print(prefix); pw.print("state="); pw.print(state); |
| 348 | pw.print(" stopped="); pw.print(stopped); |
Dianne Hackborn | 95fc68f | 2009-05-19 18:37:45 -0700 | [diff] [blame] | 349 | pw.print(" delayedResume="); pw.print(delayedResume); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 350 | pw.print(" finishing="); pw.println(finishing); |
| 351 | pw.print(prefix); pw.print("keysPaused="); pw.print(keysPaused); |
| 352 | pw.print(" inHistory="); pw.print(inHistory); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 353 | pw.print(" visible="); pw.print(visible); |
Dianne Hackborn | 4eba96b | 2011-01-21 13:34:36 -0800 | [diff] [blame] | 354 | pw.print(" sleeping="); pw.print(sleeping); |
Wale Ogunwale | f40c11b | 2016-02-26 08:16:02 -0800 | [diff] [blame] | 355 | pw.print(" idle="); pw.print(idle); |
| 356 | pw.print(" mStartingWindowState="); |
| 357 | pw.println(startingWindowStateToString(mStartingWindowState)); |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 358 | pw.print(prefix); pw.print("fullscreen="); pw.print(fullscreen); |
| 359 | pw.print(" noDisplay="); pw.print(noDisplay); |
| 360 | pw.print(" immersive="); pw.print(immersive); |
| 361 | pw.print(" launchMode="); pw.println(launchMode); |
Dianne Hackborn | 4eba96b | 2011-01-21 13:34:36 -0800 | [diff] [blame] | 362 | pw.print(prefix); pw.print("frozenBeforeDestroy="); pw.print(frozenBeforeDestroy); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 363 | pw.print(" forceNewConfig="); pw.println(forceNewConfig); |
Craig Mautner | ae7ecab | 2013-09-18 11:48:14 -0700 | [diff] [blame] | 364 | pw.print(prefix); pw.print("mActivityType="); |
| 365 | pw.println(activityTypeToString(mActivityType)); |
Ruben Brunk | e24b9a6 | 2016-02-16 21:38:24 -0800 | [diff] [blame] | 366 | if (requestedVrComponent != null) { |
| 367 | pw.print(prefix); |
| 368 | pw.print("requestedVrComponent="); |
| 369 | pw.println(requestedVrComponent); |
| 370 | } |
Dianne Hackborn | 2286cdc | 2013-07-01 19:10:06 -0700 | [diff] [blame] | 371 | if (displayStartTime != 0 || startTime != 0) { |
| 372 | pw.print(prefix); pw.print("displayStartTime="); |
| 373 | if (displayStartTime == 0) pw.print("0"); |
| 374 | else TimeUtils.formatDuration(displayStartTime, now, pw); |
Dianne Hackborn | f530ac3 | 2012-06-21 14:17:48 -0700 | [diff] [blame] | 375 | pw.print(" startTime="); |
| 376 | if (startTime == 0) pw.print("0"); |
| 377 | else TimeUtils.formatDuration(startTime, now, pw); |
| 378 | pw.println(); |
Dianne Hackborn | 0dad364 | 2010-09-09 21:25:35 -0700 | [diff] [blame] | 379 | } |
Craig Mautner | 8c14c15 | 2015-01-15 17:32:07 -0800 | [diff] [blame] | 380 | final boolean waitingVisible = mStackSupervisor.mWaitingVisibleActivities.contains(this); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 381 | if (lastVisibleTime != 0 || waitingVisible || nowVisible) { |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 382 | pw.print(prefix); pw.print("waitingVisible="); pw.print(waitingVisible); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 383 | pw.print(" nowVisible="); pw.print(nowVisible); |
Dianne Hackborn | 6e3d6da | 2012-06-15 12:05:27 -0700 | [diff] [blame] | 384 | pw.print(" lastVisibleTime="); |
Dianne Hackborn | f530ac3 | 2012-06-21 14:17:48 -0700 | [diff] [blame] | 385 | if (lastVisibleTime == 0) pw.print("0"); |
| 386 | else TimeUtils.formatDuration(lastVisibleTime, now, pw); |
| 387 | pw.println(); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 388 | } |
Wale Ogunwale | f81c1d1 | 2016-01-12 12:20:18 -0800 | [diff] [blame] | 389 | if (deferRelaunchUntilPaused || configChangeFlags != 0) { |
| 390 | pw.print(prefix); pw.print("deferRelaunchUntilPaused="); pw.print(deferRelaunchUntilPaused); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 391 | pw.print(" configChangeFlags="); |
| 392 | pw.println(Integer.toHexString(configChangeFlags)); |
| 393 | } |
| 394 | if (connections != null) { |
| 395 | pw.print(prefix); pw.print("connections="); pw.println(connections); |
| 396 | } |
Wale Ogunwale | d26176f | 2016-01-25 20:04:04 -0800 | [diff] [blame] | 397 | if (info != null) { |
| 398 | pw.println(prefix + "resizeMode=" + ActivityInfo.resizeModeToString(info.resizeMode)); |
| 399 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 400 | } |
| 401 | |
Filip Gruszczynski | 2349332 | 2015-07-29 17:02:59 -0700 | [diff] [blame] | 402 | public boolean crossesHorizontalSizeThreshold(int firstDp, int secondDp) { |
| 403 | return crossesSizeThreshold(mHorizontalSizeConfigurations, firstDp, secondDp); |
| 404 | } |
| 405 | |
| 406 | public boolean crossesVerticalSizeThreshold(int firstDp, int secondDp) { |
| 407 | return crossesSizeThreshold(mVerticalSizeConfigurations, firstDp, secondDp); |
| 408 | } |
| 409 | |
Filip Gruszczynski | 20aa0ae | 2015-10-30 10:08:27 -0700 | [diff] [blame] | 410 | public boolean crossesSmallestSizeThreshold(int firstDp, int secondDp) { |
| 411 | return crossesSizeThreshold(mSmallestSizeConfigurations, firstDp, secondDp); |
| 412 | } |
| 413 | |
Filip Gruszczynski | 2349332 | 2015-07-29 17:02:59 -0700 | [diff] [blame] | 414 | /** |
| 415 | * The purpose of this method is to decide whether the activity needs to be relaunched upon |
| 416 | * changing its size. In most cases the activities don't need to be relaunched, if the resize |
| 417 | * is small, all the activity content has to do is relayout itself within new bounds. There are |
| 418 | * cases however, where the activity's content would be completely changed in the new size and |
| 419 | * the full relaunch is required. |
| 420 | * |
| 421 | * The activity will report to us vertical and horizontal thresholds after which a relaunch is |
| 422 | * required. These thresholds are collected from the application resource qualifiers. For |
| 423 | * example, if application has layout-w600dp resource directory, then it needs a relaunch when |
| 424 | * we resize from width of 650dp to 550dp, as it crosses the 600dp threshold. However, if |
| 425 | * it resizes width from 620dp to 700dp, it won't be relaunched as it stays on the same side |
| 426 | * of the threshold. |
| 427 | */ |
| 428 | private static boolean crossesSizeThreshold(int[] thresholds, int firstDp, |
| 429 | int secondDp) { |
| 430 | if (thresholds == null) { |
| 431 | return false; |
| 432 | } |
| 433 | for (int i = thresholds.length - 1; i >= 0; i--) { |
| 434 | final int threshold = thresholds[i]; |
| 435 | if ((firstDp < threshold && secondDp >= threshold) |
| 436 | || (firstDp >= threshold && secondDp < threshold)) { |
| 437 | return true; |
| 438 | } |
| 439 | } |
| 440 | return false; |
| 441 | } |
| 442 | |
| 443 | public void setSizeConfigurations(int[] horizontalSizeConfiguration, |
Filip Gruszczynski | 20aa0ae | 2015-10-30 10:08:27 -0700 | [diff] [blame] | 444 | int[] verticalSizeConfigurations, int[] smallestSizeConfigurations) { |
Filip Gruszczynski | 2349332 | 2015-07-29 17:02:59 -0700 | [diff] [blame] | 445 | mHorizontalSizeConfigurations = horizontalSizeConfiguration; |
| 446 | mVerticalSizeConfigurations = verticalSizeConfigurations; |
Filip Gruszczynski | 20aa0ae | 2015-10-30 10:08:27 -0700 | [diff] [blame] | 447 | mSmallestSizeConfigurations = smallestSizeConfigurations; |
Filip Gruszczynski | 2349332 | 2015-07-29 17:02:59 -0700 | [diff] [blame] | 448 | } |
| 449 | |
Filip Gruszczynski | ca66481 | 2015-12-04 12:43:36 -0800 | [diff] [blame] | 450 | void scheduleConfigurationChanged(Configuration config, boolean reportToActivity) { |
Wale Ogunwale | 22e2526 | 2016-02-01 10:32:02 -0800 | [diff] [blame] | 451 | if (app == null || app.thread == null) { |
| 452 | return; |
| 453 | } |
| 454 | try { |
Chong Zhang | 6be533e | 2016-06-17 16:24:21 -0700 | [diff] [blame] | 455 | // Make sure fontScale is always equal to global. For fullscreen apps, config is |
| 456 | // the shared EMPTY config, which has default fontScale of 1.0. We don't want it |
| 457 | // to be applied as an override config. |
| 458 | Configuration overrideConfig = new Configuration(config); |
| 459 | overrideConfig.fontScale = service.mConfiguration.fontScale; |
| 460 | |
Wale Ogunwale | 22e2526 | 2016-02-01 10:32:02 -0800 | [diff] [blame] | 461 | if (DEBUG_CONFIGURATION) Slog.v(TAG, "Sending new config to " + this + " " + |
Chong Zhang | 6be533e | 2016-06-17 16:24:21 -0700 | [diff] [blame] | 462 | "reportToActivity=" + reportToActivity + " and config: " + overrideConfig); |
| 463 | |
Wale Ogunwale | 22e2526 | 2016-02-01 10:32:02 -0800 | [diff] [blame] | 464 | app.thread.scheduleActivityConfigurationChanged( |
Chong Zhang | 6be533e | 2016-06-17 16:24:21 -0700 | [diff] [blame] | 465 | appToken, overrideConfig, reportToActivity); |
Wale Ogunwale | 22e2526 | 2016-02-01 10:32:02 -0800 | [diff] [blame] | 466 | } catch (RemoteException e) { |
| 467 | // If process died, whatever. |
| 468 | } |
| 469 | } |
| 470 | |
Andrii Kulian | 933076d | 2016-03-29 17:04:42 -0700 | [diff] [blame] | 471 | void scheduleMultiWindowModeChanged() { |
Wale Ogunwale | 22e2526 | 2016-02-01 10:32:02 -0800 | [diff] [blame] | 472 | if (task == null || task.stack == null || app == null || app.thread == null) { |
| 473 | return; |
| 474 | } |
| 475 | try { |
| 476 | // An activity is considered to be in multi-window mode if its task isn't fullscreen. |
Andrii Kulian | 933076d | 2016-03-29 17:04:42 -0700 | [diff] [blame] | 477 | app.thread.scheduleMultiWindowModeChanged(appToken, !task.mFullscreen); |
Wale Ogunwale | 22e2526 | 2016-02-01 10:32:02 -0800 | [diff] [blame] | 478 | } catch (Exception e) { |
| 479 | // If process died, I don't care. |
| 480 | } |
| 481 | } |
| 482 | |
Andrii Kulian | 933076d | 2016-03-29 17:04:42 -0700 | [diff] [blame] | 483 | void schedulePictureInPictureModeChanged() { |
Wale Ogunwale | 22e2526 | 2016-02-01 10:32:02 -0800 | [diff] [blame] | 484 | if (task == null || task.stack == null || app == null || app.thread == null) { |
| 485 | return; |
| 486 | } |
| 487 | try { |
Andrii Kulian | 933076d | 2016-03-29 17:04:42 -0700 | [diff] [blame] | 488 | app.thread.schedulePictureInPictureModeChanged( |
Wale Ogunwale | 22e2526 | 2016-02-01 10:32:02 -0800 | [diff] [blame] | 489 | appToken, task.stack.mStackId == PINNED_STACK_ID); |
| 490 | } catch (Exception e) { |
| 491 | // If process died, no one cares. |
Filip Gruszczynski | ca66481 | 2015-12-04 12:43:36 -0800 | [diff] [blame] | 492 | } |
| 493 | } |
| 494 | |
Filip Gruszczynski | 3d02671 | 2015-12-16 13:46:38 -0800 | [diff] [blame] | 495 | boolean isFreeform() { |
| 496 | return task != null && task.stack != null |
| 497 | && task.stack.mStackId == FREEFORM_WORKSPACE_STACK_ID; |
| 498 | } |
| 499 | |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 500 | static class Token extends IApplicationToken.Stub { |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 501 | private final WeakReference<ActivityRecord> weakActivity; |
| 502 | private final ActivityManagerService mService; |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 503 | |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 504 | Token(ActivityRecord activity, ActivityManagerService service) { |
Wale Ogunwale | e23149f | 2015-03-06 15:39:44 -0800 | [diff] [blame] | 505 | weakActivity = new WeakReference<>(activity); |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 506 | mService = service; |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 507 | } |
| 508 | |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 509 | @Override |
| 510 | public void windowsDrawn() { |
| 511 | synchronized (mService) { |
| 512 | ActivityRecord r = tokenToActivityRecordLocked(this); |
| 513 | if (r != null) { |
| 514 | r.windowsDrawnLocked(); |
| 515 | } |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 516 | } |
| 517 | } |
| 518 | |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 519 | @Override |
| 520 | public void windowsVisible() { |
| 521 | synchronized (mService) { |
| 522 | ActivityRecord r = tokenToActivityRecordLocked(this); |
| 523 | if (r != null) { |
| 524 | r.windowsVisibleLocked(); |
| 525 | } |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 526 | } |
| 527 | } |
| 528 | |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 529 | @Override |
| 530 | public void windowsGone() { |
| 531 | synchronized (mService) { |
| 532 | ActivityRecord r = tokenToActivityRecordLocked(this); |
| 533 | if (r != null) { |
Wale Ogunwale | ee006da | 2015-03-30 14:49:25 -0700 | [diff] [blame] | 534 | if (DEBUG_SWITCH) Log.v(TAG_SWITCH, "windowsGone(): " + r); |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 535 | r.nowVisible = false; |
| 536 | return; |
| 537 | } |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 538 | } |
| 539 | } |
| 540 | |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 541 | @Override |
| 542 | public boolean keyDispatchingTimedOut(String reason) { |
| 543 | ActivityRecord r; |
| 544 | ActivityRecord anrActivity; |
| 545 | ProcessRecord anrApp; |
| 546 | synchronized (mService) { |
| 547 | r = tokenToActivityRecordLocked(this); |
| 548 | if (r == null) { |
| 549 | return false; |
| 550 | } |
| 551 | anrActivity = r.getWaitingHistoryRecordLocked(); |
| 552 | anrApp = r != null ? r.app : null; |
| 553 | } |
| 554 | return mService.inputDispatchingTimedOut(anrApp, anrActivity, r, false, reason); |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 555 | } |
| 556 | |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 557 | @Override |
| 558 | public long getKeyDispatchingTimeout() { |
| 559 | synchronized (mService) { |
| 560 | ActivityRecord r = tokenToActivityRecordLocked(this); |
| 561 | if (r == null) { |
| 562 | return 0; |
| 563 | } |
| 564 | r = r.getWaitingHistoryRecordLocked(); |
| 565 | return ActivityManagerService.getInputDispatchingTimeoutLocked(r); |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 566 | } |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | private static final ActivityRecord tokenToActivityRecordLocked(Token token) { |
| 570 | if (token == null) { |
| 571 | return null; |
| 572 | } |
| 573 | ActivityRecord r = token.weakActivity.get(); |
| 574 | if (r == null || r.task == null || r.task.stack == null) { |
| 575 | return null; |
| 576 | } |
| 577 | return r; |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 578 | } |
| 579 | |
Craig Mautner | de4ef02 | 2013-04-07 19:01:33 -0700 | [diff] [blame] | 580 | @Override |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 581 | public String toString() { |
| 582 | StringBuilder sb = new StringBuilder(128); |
| 583 | sb.append("Token{"); |
| 584 | sb.append(Integer.toHexString(System.identityHashCode(this))); |
| 585 | sb.append(' '); |
| 586 | sb.append(weakActivity.get()); |
| 587 | sb.append('}'); |
| 588 | return sb.toString(); |
| 589 | } |
| 590 | } |
| 591 | |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 592 | static ActivityRecord forTokenLocked(IBinder token) { |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 593 | try { |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 594 | return Token.tokenToActivityRecordLocked((Token)token); |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 595 | } catch (ClassCastException e) { |
Wale Ogunwale | e23149f | 2015-03-06 15:39:44 -0800 | [diff] [blame] | 596 | Slog.w(TAG, "Bad activity token: " + token, e); |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 597 | return null; |
| 598 | } |
| 599 | } |
| 600 | |
Chong Zhang | 85ee654 | 2015-10-02 13:36:38 -0700 | [diff] [blame] | 601 | boolean isResolverActivity() { |
| 602 | return ResolverActivity.class.getName().equals(realActivity.getClassName()); |
Craig Mautner | ac6f843 | 2013-07-17 13:24:59 -0700 | [diff] [blame] | 603 | } |
| 604 | |
Craig Mautner | d232895 | 2013-03-05 12:46:26 -0800 | [diff] [blame] | 605 | ActivityRecord(ActivityManagerService _service, ProcessRecord _caller, |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 606 | int _launchedFromUid, String _launchedFromPackage, Intent _intent, String _resolvedType, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 607 | ActivityInfo aInfo, Configuration _configuration, |
Dianne Hackborn | 01e4cfc | 2010-06-24 15:07:24 -0700 | [diff] [blame] | 608 | ActivityRecord _resultTo, String _resultWho, int _reqCode, |
Dianne Hackborn | fb81d09 | 2015-08-03 17:14:46 -0700 | [diff] [blame] | 609 | boolean _componentSpecified, boolean _rootVoiceInteraction, |
| 610 | ActivityStackSupervisor supervisor, |
Wale Ogunwale | 1affbbc | 2016-05-01 09:03:52 -0700 | [diff] [blame] | 611 | ActivityContainer container, ActivityOptions options, ActivityRecord sourceRecord) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 612 | service = _service; |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 613 | appToken = new Token(this, service); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 614 | info = aInfo; |
| 615 | launchedFromUid = _launchedFromUid; |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 616 | launchedFromPackage = _launchedFromPackage; |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 617 | userId = UserHandle.getUserId(aInfo.applicationInfo.uid); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 618 | intent = _intent; |
| 619 | shortComponentName = _intent.getComponent().flattenToShortString(); |
| 620 | resolvedType = _resolvedType; |
The Android Open Source Project | 4df2423 | 2009-03-05 14:34:35 -0800 | [diff] [blame] | 621 | componentSpecified = _componentSpecified; |
Dianne Hackborn | fb81d09 | 2015-08-03 17:14:46 -0700 | [diff] [blame] | 622 | rootVoiceInteraction = _rootVoiceInteraction; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 623 | configuration = _configuration; |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 624 | taskConfigOverride = Configuration.EMPTY; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 625 | resultTo = _resultTo; |
| 626 | resultWho = _resultWho; |
| 627 | requestCode = _reqCode; |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 628 | state = ActivityState.INITIALIZING; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 629 | frontOfTask = false; |
| 630 | launchFailed = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 631 | stopped = false; |
Dianne Hackborn | 95fc68f | 2009-05-19 18:37:45 -0700 | [diff] [blame] | 632 | delayedResume = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 633 | finishing = false; |
Wale Ogunwale | f81c1d1 | 2016-01-12 12:20:18 -0800 | [diff] [blame] | 634 | deferRelaunchUntilPaused = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 635 | keysPaused = false; |
| 636 | inHistory = false; |
Chong Zhang | a48ef66 | 2015-08-18 19:21:47 -0700 | [diff] [blame] | 637 | visible = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 638 | nowVisible = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 639 | idle = false; |
| 640 | hasBeenLaunched = false; |
Craig Mautner | de4ef02 | 2013-04-07 19:01:33 -0700 | [diff] [blame] | 641 | mStackSupervisor = supervisor; |
Craig Mautner | e0a3884 | 2013-12-16 16:14:02 -0800 | [diff] [blame] | 642 | mInitialActivityContainer = container; |
Craig Mautner | 233ceee | 2014-05-09 17:05:11 -0700 | [diff] [blame] | 643 | if (options != null) { |
Chong Zhang | 280d332 | 2015-11-03 17:27:26 -0800 | [diff] [blame] | 644 | pendingOptions = options; |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 645 | mLaunchTaskBehind = pendingOptions.getLaunchTaskBehind(); |
Robert Carr | fd10cd1 | 2016-06-29 16:41:50 -0700 | [diff] [blame] | 646 | mRotationAnimationHint = pendingOptions.getRotationAnimationHint(); |
Dianne Hackborn | b5a380d | 2015-05-20 18:18:46 -0700 | [diff] [blame] | 647 | PendingIntent usageReport = pendingOptions.getUsageTimeReport(); |
| 648 | if (usageReport != null) { |
| 649 | appTimeTracker = new AppTimeTracker(usageReport); |
| 650 | } |
Craig Mautner | 233ceee | 2014-05-09 17:05:11 -0700 | [diff] [blame] | 651 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 652 | |
Dianne Hackborn | 2d1b378 | 2012-09-09 17:49:39 -0700 | [diff] [blame] | 653 | // This starts out true, since the initial state of an activity |
| 654 | // is that we have everything, and we shouldn't never consider it |
| 655 | // lacking in state to be removed if it dies. |
| 656 | haveState = true; |
| 657 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 658 | if (aInfo != null) { |
Chong Zhang | 6bdc7e1 | 2016-02-01 14:33:53 -0800 | [diff] [blame] | 659 | // If the class name in the intent doesn't match that of the target, this is |
| 660 | // probably an alias. We have to create a new ComponentName object to keep track |
| 661 | // of the real activity name, so that FLAG_ACTIVITY_CLEAR_TOP is handled properly. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 662 | if (aInfo.targetActivity == null |
Chong Zhang | 6bdc7e1 | 2016-02-01 14:33:53 -0800 | [diff] [blame] | 663 | || (aInfo.targetActivity.equals(_intent.getComponent().getClassName()) |
| 664 | && (aInfo.launchMode == ActivityInfo.LAUNCH_MULTIPLE |
| 665 | || aInfo.launchMode == ActivityInfo.LAUNCH_SINGLE_TOP))) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 666 | realActivity = _intent.getComponent(); |
| 667 | } else { |
Chong Zhang | 6bdc7e1 | 2016-02-01 14:33:53 -0800 | [diff] [blame] | 668 | realActivity = new ComponentName(aInfo.packageName, aInfo.targetActivity); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 669 | } |
| 670 | taskAffinity = aInfo.taskAffinity; |
| 671 | stateNotNeeded = (aInfo.flags& |
| 672 | ActivityInfo.FLAG_STATE_NOT_NEEDED) != 0; |
Jeff Sharkey | 8a4c972 | 2014-06-16 13:48:42 -0700 | [diff] [blame] | 673 | appInfo = aInfo.applicationInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 674 | nonLocalizedLabel = aInfo.nonLocalizedLabel; |
| 675 | labelRes = aInfo.labelRes; |
| 676 | if (nonLocalizedLabel == null && labelRes == 0) { |
| 677 | ApplicationInfo app = aInfo.applicationInfo; |
| 678 | nonLocalizedLabel = app.nonLocalizedLabel; |
| 679 | labelRes = app.labelRes; |
| 680 | } |
| 681 | icon = aInfo.getIconResource(); |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 682 | logo = aInfo.getLogoResource(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 683 | theme = aInfo.getThemeResource(); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 684 | realTheme = theme; |
| 685 | if (realTheme == 0) { |
| 686 | realTheme = aInfo.applicationInfo.targetSdkVersion |
| 687 | < Build.VERSION_CODES.HONEYCOMB |
| 688 | ? android.R.style.Theme |
| 689 | : android.R.style.Theme_Holo; |
| 690 | } |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 691 | if ((aInfo.flags&ActivityInfo.FLAG_HARDWARE_ACCELERATED) != 0) { |
| 692 | windowFlags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 693 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 694 | if ((aInfo.flags&ActivityInfo.FLAG_MULTIPROCESS) != 0 |
| 695 | && _caller != null |
| 696 | && (aInfo.applicationInfo.uid == Process.SYSTEM_UID |
| 697 | || aInfo.applicationInfo.uid == _caller.info.uid)) { |
| 698 | processName = _caller.processName; |
| 699 | } else { |
| 700 | processName = aInfo.processName; |
| 701 | } |
| 702 | |
| 703 | if (intent != null && (aInfo.flags & ActivityInfo.FLAG_EXCLUDE_FROM_RECENTS) != 0) { |
| 704 | intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); |
| 705 | } |
Craig Mautner | b59dcfd | 2013-05-06 13:12:58 -0700 | [diff] [blame] | 706 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 707 | packageName = aInfo.applicationInfo.packageName; |
| 708 | launchMode = aInfo.launchMode; |
Craig Mautner | b59dcfd | 2013-05-06 13:12:58 -0700 | [diff] [blame] | 709 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 710 | AttributeCache.Entry ent = AttributeCache.instance().get(packageName, |
Amith Yamasani | 4befbec | 2013-07-10 16:18:01 -0700 | [diff] [blame] | 711 | realTheme, com.android.internal.R.styleable.Window, userId); |
Dianne Hackborn | b795d7c | 2015-07-28 17:40:06 -0700 | [diff] [blame] | 712 | final boolean translucent = ent != null && (ent.array.getBoolean( |
Ned Burns | d7a313f | 2016-12-06 15:52:01 -0500 | [diff] [blame] | 713 | com.android.internal.R.styleable.Window_windowIsTranslucent, false)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 714 | fullscreen = ent != null && !ent.array.getBoolean( |
| 715 | com.android.internal.R.styleable.Window_windowIsFloating, false) |
Filip Gruszczynski | 23958c6 | 2015-02-23 18:05:27 -0800 | [diff] [blame] | 716 | && !translucent; |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 717 | noDisplay = ent != null && ent.array.getBoolean( |
| 718 | com.android.internal.R.styleable.Window_windowNoDisplay, false); |
Craig Mautner | b59dcfd | 2013-05-06 13:12:58 -0700 | [diff] [blame] | 719 | |
Wale Ogunwale | 1affbbc | 2016-05-01 09:03:52 -0700 | [diff] [blame] | 720 | setActivityType(_componentSpecified, _launchedFromUid, _intent, sourceRecord); |
Daniel Sandler | 69a4817 | 2010-06-23 16:29:36 -0400 | [diff] [blame] | 721 | |
| 722 | immersive = (aInfo.flags & ActivityInfo.FLAG_IMMERSIVE) != 0; |
Ruben Brunk | f56c9f4 | 2016-04-22 18:20:55 -0700 | [diff] [blame] | 723 | |
| 724 | requestedVrComponent = (aInfo.requestedVrComponent == null) ? |
| 725 | null : ComponentName.unflattenFromString(aInfo.requestedVrComponent); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 726 | } else { |
| 727 | realActivity = null; |
| 728 | taskAffinity = null; |
| 729 | stateNotNeeded = false; |
Jeff Sharkey | 8a4c972 | 2014-06-16 13:48:42 -0700 | [diff] [blame] | 730 | appInfo = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 731 | processName = null; |
| 732 | packageName = null; |
| 733 | fullscreen = true; |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 734 | noDisplay = false; |
Craig Mautner | 86d67a4 | 2013-05-14 10:34:38 -0700 | [diff] [blame] | 735 | mActivityType = APPLICATION_ACTIVITY_TYPE; |
Daniel Sandler | 69a4817 | 2010-06-23 16:29:36 -0400 | [diff] [blame] | 736 | immersive = false; |
Ruben Brunk | f56c9f4 | 2016-04-22 18:20:55 -0700 | [diff] [blame] | 737 | requestedVrComponent = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 738 | } |
| 739 | } |
| 740 | |
Wale Ogunwale | 1affbbc | 2016-05-01 09:03:52 -0700 | [diff] [blame] | 741 | private boolean isHomeIntent(Intent intent) { |
| 742 | return Intent.ACTION_MAIN.equals(intent.getAction()) |
| 743 | && intent.hasCategory(Intent.CATEGORY_HOME) |
| 744 | && intent.getCategories().size() == 1 |
| 745 | && intent.getData() == null |
| 746 | && intent.getType() == null; |
| 747 | } |
| 748 | |
Chong Zhang | 813be13 | 2016-08-25 12:12:33 -0700 | [diff] [blame] | 749 | static boolean isMainIntent(Intent intent) { |
| 750 | return Intent.ACTION_MAIN.equals(intent.getAction()) |
| 751 | && intent.hasCategory(Intent.CATEGORY_LAUNCHER) |
| 752 | && intent.getCategories().size() == 1 |
| 753 | && intent.getData() == null |
| 754 | && intent.getType() == null; |
| 755 | } |
| 756 | |
Wale Ogunwale | 1affbbc | 2016-05-01 09:03:52 -0700 | [diff] [blame] | 757 | private boolean canLaunchHomeActivity(int uid, ActivityRecord sourceRecord) { |
| 758 | if (uid == Process.myUid() || uid == 0) { |
| 759 | // System process can launch home activity. |
| 760 | return true; |
| 761 | } |
| 762 | // Resolver activity can launch home activity. |
| 763 | return sourceRecord != null && sourceRecord.isResolverActivity(); |
| 764 | } |
| 765 | |
| 766 | private void setActivityType(boolean componentSpecified, |
| 767 | int launchedFromUid, Intent intent, ActivityRecord sourceRecord) { |
| 768 | if ((!componentSpecified || canLaunchHomeActivity(launchedFromUid, sourceRecord)) |
| 769 | && isHomeIntent(intent) && !isResolverActivity()) { |
| 770 | // This sure looks like a home activity! |
| 771 | mActivityType = HOME_ACTIVITY_TYPE; |
| 772 | } else if (realActivity.getClassName().contains(RECENTS_PACKAGE_NAME)) { |
| 773 | mActivityType = RECENTS_ACTIVITY_TYPE; |
| 774 | } else { |
| 775 | mActivityType = APPLICATION_ACTIVITY_TYPE; |
| 776 | } |
| 777 | } |
| 778 | |
Craig Mautner | a228ae9 | 2014-07-09 05:44:55 -0700 | [diff] [blame] | 779 | void setTask(TaskRecord newTask, TaskRecord taskToAffiliateWith) { |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 780 | if (task != null && task.removeActivity(this) && task != newTask && task.stack != null) { |
| 781 | task.stack.removeTask(task, "setTask"); |
Craig Mautner | de4ef02 | 2013-04-07 19:01:33 -0700 | [diff] [blame] | 782 | } |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 783 | task = newTask; |
Craig Mautner | a228ae9 | 2014-07-09 05:44:55 -0700 | [diff] [blame] | 784 | setTaskToAffiliateWith(taskToAffiliateWith); |
| 785 | } |
| 786 | |
| 787 | void setTaskToAffiliateWith(TaskRecord taskToAffiliateWith) { |
| 788 | if (taskToAffiliateWith != null && |
| 789 | launchMode != ActivityInfo.LAUNCH_SINGLE_INSTANCE && |
| 790 | launchMode != ActivityInfo.LAUNCH_SINGLE_TASK) { |
| 791 | task.setTaskToAffiliateWith(taskToAffiliateWith); |
| 792 | } |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 793 | } |
| 794 | |
Craig Mautner | 5eda9b3 | 2013-07-02 11:58:16 -0700 | [diff] [blame] | 795 | boolean changeWindowTranslucency(boolean toOpaque) { |
| 796 | if (fullscreen == toOpaque) { |
| 797 | return false; |
| 798 | } |
Craig Mautner | 4addfc5 | 2013-06-25 08:05:45 -0700 | [diff] [blame] | 799 | |
Craig Mautner | 5eda9b3 | 2013-07-02 11:58:16 -0700 | [diff] [blame] | 800 | // Keep track of the number of fullscreen activities in this task. |
| 801 | task.numFullscreen += toOpaque ? +1 : -1; |
| 802 | |
| 803 | fullscreen = toOpaque; |
| 804 | return true; |
Craig Mautner | 4addfc5 | 2013-06-25 08:05:45 -0700 | [diff] [blame] | 805 | } |
| 806 | |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 807 | void putInHistory() { |
| 808 | if (!inHistory) { |
| 809 | inHistory = true; |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 810 | } |
| 811 | } |
| 812 | |
| 813 | void takeFromHistory() { |
| 814 | if (inHistory) { |
| 815 | inHistory = false; |
| 816 | if (task != null && !finishing) { |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 817 | task = null; |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 818 | } |
Dianne Hackborn | 6e3d6da | 2012-06-15 12:05:27 -0700 | [diff] [blame] | 819 | clearOptionsLocked(); |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 820 | } |
| 821 | } |
| 822 | |
| 823 | boolean isInHistory() { |
| 824 | return inHistory; |
| 825 | } |
| 826 | |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 827 | boolean isInStackLocked() { |
| 828 | return task != null && task.stack != null && task.stack.isInStackLocked(this) != null; |
| 829 | } |
| 830 | |
Craig Mautner | 86d67a4 | 2013-05-14 10:34:38 -0700 | [diff] [blame] | 831 | boolean isHomeActivity() { |
| 832 | return mActivityType == HOME_ACTIVITY_TYPE; |
| 833 | } |
| 834 | |
| 835 | boolean isRecentsActivity() { |
| 836 | return mActivityType == RECENTS_ACTIVITY_TYPE; |
| 837 | } |
| 838 | |
| 839 | boolean isApplicationActivity() { |
| 840 | return mActivityType == APPLICATION_ACTIVITY_TYPE; |
| 841 | } |
| 842 | |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 843 | boolean isPersistable() { |
Craig Mautner | 43e52ed | 2014-06-16 17:18:52 -0700 | [diff] [blame] | 844 | return (info.persistableMode == ActivityInfo.PERSIST_ROOT_ONLY || |
| 845 | info.persistableMode == ActivityInfo.PERSIST_ACROSS_REBOOTS) && |
| 846 | (intent == null || |
| 847 | (intent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == 0); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 848 | } |
| 849 | |
Wale Ogunwale | 4cea0f5 | 2015-12-25 06:30:31 -0800 | [diff] [blame] | 850 | boolean isFocusable() { |
Wale Ogunwale | 6cae765 | 2015-12-26 07:36:26 -0800 | [diff] [blame] | 851 | return StackId.canReceiveKeys(task.stack.mStackId) || isAlwaysFocusable(); |
| 852 | } |
| 853 | |
| 854 | boolean isResizeable() { |
Wale Ogunwale | b1faf60 | 2016-01-27 09:12:31 -0800 | [diff] [blame] | 855 | return !isHomeActivity() && ActivityInfo.isResizeableMode(info.resizeMode); |
Wale Ogunwale | 6cae765 | 2015-12-26 07:36:26 -0800 | [diff] [blame] | 856 | } |
| 857 | |
Wale Ogunwale | 513346d | 2016-01-27 10:55:01 -0800 | [diff] [blame] | 858 | boolean isResizeableOrForced() { |
| 859 | return !isHomeActivity() && (isResizeable() || service.mForceResizableActivities); |
| 860 | } |
| 861 | |
Jorim Jaggi | cd13d33 | 2016-04-27 15:40:20 -0700 | [diff] [blame] | 862 | boolean isNonResizableOrForced() { |
| 863 | return !isHomeActivity() && info.resizeMode != RESIZE_MODE_RESIZEABLE |
| 864 | && info.resizeMode != RESIZE_MODE_RESIZEABLE_AND_PIPABLE; |
| 865 | } |
| 866 | |
Wale Ogunwale | 6cae765 | 2015-12-26 07:36:26 -0800 | [diff] [blame] | 867 | boolean supportsPictureInPicture() { |
Wale Ogunwale | d26176f | 2016-01-25 20:04:04 -0800 | [diff] [blame] | 868 | return !isHomeActivity() && info.resizeMode == RESIZE_MODE_RESIZEABLE_AND_PIPABLE; |
| 869 | } |
| 870 | |
Wale Ogunwale | 513346d | 2016-01-27 10:55:01 -0800 | [diff] [blame] | 871 | boolean canGoInDockedStack() { |
| 872 | return !isHomeActivity() |
| 873 | && (isResizeableOrForced() || info.resizeMode == RESIZE_MODE_CROP_WINDOWS); |
| 874 | } |
| 875 | |
Wale Ogunwale | 6cae765 | 2015-12-26 07:36:26 -0800 | [diff] [blame] | 876 | boolean isAlwaysFocusable() { |
| 877 | return (info.flags & FLAG_ALWAYS_FOCUSABLE) != 0; |
Wale Ogunwale | 4cea0f5 | 2015-12-25 06:30:31 -0800 | [diff] [blame] | 878 | } |
| 879 | |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 880 | void makeFinishingLocked() { |
Dianne Hackborn | 94cb2eb | 2011-01-13 21:09:44 -0800 | [diff] [blame] | 881 | if (!finishing) { |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 882 | if (task != null && task.stack != null |
| 883 | && this == task.stack.getVisibleBehindActivity()) { |
Jose Lima | 34ff492 | 2014-08-18 15:19:41 -0700 | [diff] [blame] | 884 | // A finishing activity should not remain as visible in the background |
| 885 | mStackSupervisor.requestVisibleBehindLocked(this, false); |
| 886 | } |
Dianne Hackborn | 94cb2eb | 2011-01-13 21:09:44 -0800 | [diff] [blame] | 887 | finishing = true; |
Dianne Hackborn | 6e3d6da | 2012-06-15 12:05:27 -0700 | [diff] [blame] | 888 | if (stopped) { |
| 889 | clearOptionsLocked(); |
| 890 | } |
Dianne Hackborn | 94cb2eb | 2011-01-13 21:09:44 -0800 | [diff] [blame] | 891 | } |
| 892 | } |
| 893 | |
Dianne Hackborn | 7e26964 | 2010-08-25 19:50:20 -0700 | [diff] [blame] | 894 | UriPermissionOwner getUriPermissionsLocked() { |
| 895 | if (uriPermissions == null) { |
| 896 | uriPermissions = new UriPermissionOwner(service, this); |
| 897 | } |
| 898 | return uriPermissions; |
| 899 | } |
| 900 | |
Dianne Hackborn | 01e4cfc | 2010-06-24 15:07:24 -0700 | [diff] [blame] | 901 | void addResultLocked(ActivityRecord from, String resultWho, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 902 | int requestCode, int resultCode, |
| 903 | Intent resultData) { |
| 904 | ActivityResult r = new ActivityResult(from, resultWho, |
John Spurlock | 8a985d2 | 2014-02-25 09:40:05 -0500 | [diff] [blame] | 905 | requestCode, resultCode, resultData); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 906 | if (results == null) { |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 907 | results = new ArrayList<ResultInfo>(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 908 | } |
| 909 | results.add(r); |
| 910 | } |
| 911 | |
Dianne Hackborn | 01e4cfc | 2010-06-24 15:07:24 -0700 | [diff] [blame] | 912 | void removeResultsLocked(ActivityRecord from, String resultWho, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 913 | int requestCode) { |
| 914 | if (results != null) { |
| 915 | for (int i=results.size()-1; i>=0; i--) { |
| 916 | ActivityResult r = (ActivityResult)results.get(i); |
| 917 | if (r.mFrom != from) continue; |
| 918 | if (r.mResultWho == null) { |
| 919 | if (resultWho != null) continue; |
| 920 | } else { |
| 921 | if (!r.mResultWho.equals(resultWho)) continue; |
| 922 | } |
| 923 | if (r.mRequestCode != requestCode) continue; |
| 924 | |
| 925 | results.remove(i); |
| 926 | } |
| 927 | } |
| 928 | } |
| 929 | |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 930 | void addNewIntentLocked(ReferrerIntent intent) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 931 | if (newIntents == null) { |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 932 | newIntents = new ArrayList<>(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 933 | } |
| 934 | newIntents.add(intent); |
| 935 | } |
Craig Mautner | b59dcfd | 2013-05-06 13:12:58 -0700 | [diff] [blame] | 936 | |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 937 | /** |
| 938 | * Deliver a new Intent to an existing activity, so that its onNewIntent() |
| 939 | * method will be called at the proper time. |
| 940 | */ |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 941 | final void deliverNewIntentLocked(int callingUid, Intent intent, String referrer) { |
Dianne Hackborn | 514074f | 2013-02-11 10:52:46 -0800 | [diff] [blame] | 942 | // The activity now gets access to the data associated with this Intent. |
| 943 | service.grantUriPermissionFromIntentLocked(callingUid, packageName, |
Nicolas Prevot | c6cf95c | 2014-05-29 11:30:36 +0100 | [diff] [blame] | 944 | intent, getUriPermissionsLocked(), userId); |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 945 | final ReferrerIntent rintent = new ReferrerIntent(intent, referrer); |
Craig Mautner | 86d67a4 | 2013-05-14 10:34:38 -0700 | [diff] [blame] | 946 | boolean unsent = true; |
Wale Ogunwale | 826c706 | 2016-09-13 08:25:54 -0700 | [diff] [blame] | 947 | final ActivityStack stack = task.stack; |
| 948 | final boolean isTopActivityInStack = |
| 949 | stack != null && stack.topRunningActivityLocked() == this; |
| 950 | final boolean isTopActivityWhileSleeping = |
| 951 | service.isSleepingLocked() && isTopActivityInStack; |
Wale Ogunwale | 826c706 | 2016-09-13 08:25:54 -0700 | [diff] [blame] | 952 | |
| 953 | // We want to immediately deliver the intent to the activity if: |
Wale Ogunwale | 03f7e9e | 2016-09-22 09:04:09 -0700 | [diff] [blame] | 954 | // - It is currently resumed or paused. i.e. it is currently visible to the user and we want |
| 955 | // the user to see the visual effects caused by the intent delivery now. |
Wale Ogunwale | 826c706 | 2016-09-13 08:25:54 -0700 | [diff] [blame] | 956 | // - The device is sleeping and it is the top activity behind the lock screen (b/6700897). |
Wale Ogunwale | 03f7e9e | 2016-09-22 09:04:09 -0700 | [diff] [blame] | 957 | if ((state == ActivityState.RESUMED || state == ActivityState.PAUSED |
| 958 | || isTopActivityWhileSleeping) && app != null && app.thread != null) { |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 959 | try { |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 960 | ArrayList<ReferrerIntent> ar = new ArrayList<>(1); |
| 961 | ar.add(rintent); |
Wale Ogunwale | 826c706 | 2016-09-13 08:25:54 -0700 | [diff] [blame] | 962 | app.thread.scheduleNewIntent( |
Wale Ogunwale | 03f7e9e | 2016-09-22 09:04:09 -0700 | [diff] [blame] | 963 | ar, appToken, state == ActivityState.PAUSED /* andPause */); |
Craig Mautner | 86d67a4 | 2013-05-14 10:34:38 -0700 | [diff] [blame] | 964 | unsent = false; |
Dianne Hackborn | 39792d2 | 2010-08-19 18:01:52 -0700 | [diff] [blame] | 965 | } catch (RemoteException e) { |
Wale Ogunwale | e23149f | 2015-03-06 15:39:44 -0800 | [diff] [blame] | 966 | Slog.w(TAG, "Exception thrown sending new intent to " + this, e); |
Dianne Hackborn | 39792d2 | 2010-08-19 18:01:52 -0700 | [diff] [blame] | 967 | } catch (NullPointerException e) { |
Wale Ogunwale | e23149f | 2015-03-06 15:39:44 -0800 | [diff] [blame] | 968 | Slog.w(TAG, "Exception thrown sending new intent to " + this, e); |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 969 | } |
| 970 | } |
Craig Mautner | 86d67a4 | 2013-05-14 10:34:38 -0700 | [diff] [blame] | 971 | if (unsent) { |
Dianne Hackborn | 85d558c | 2014-11-04 10:31:54 -0800 | [diff] [blame] | 972 | addNewIntentLocked(rintent); |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 973 | } |
| 974 | } |
| 975 | |
Dianne Hackborn | 9622ca4 | 2012-10-23 18:56:33 -0700 | [diff] [blame] | 976 | void updateOptionsLocked(ActivityOptions options) { |
| 977 | if (options != null) { |
| 978 | if (pendingOptions != null) { |
| 979 | pendingOptions.abort(); |
| 980 | } |
| 981 | pendingOptions = options; |
| 982 | } |
| 983 | } |
| 984 | |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 985 | void applyOptionsLocked() { |
George Mount | 2c92c97 | 2014-03-20 09:38:23 -0700 | [diff] [blame] | 986 | if (pendingOptions != null |
| 987 | && pendingOptions.getAnimationType() != ActivityOptions.ANIM_SCENE_TRANSITION) { |
Michael Jurka | 21385cd | 2012-05-03 10:57:31 -0700 | [diff] [blame] | 988 | final int animationType = pendingOptions.getAnimationType(); |
| 989 | switch (animationType) { |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 990 | case ActivityOptions.ANIM_CUSTOM: |
| 991 | service.mWindowManager.overridePendingAppTransition( |
| 992 | pendingOptions.getPackageName(), |
| 993 | pendingOptions.getCustomEnterResId(), |
Dianne Hackborn | 8437587 | 2012-06-01 19:03:50 -0700 | [diff] [blame] | 994 | pendingOptions.getCustomExitResId(), |
| 995 | pendingOptions.getOnAnimationStartListener()); |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 996 | break; |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 997 | case ActivityOptions.ANIM_CLIP_REVEAL: |
| 998 | service.mWindowManager.overridePendingAppTransitionClipReveal( |
| 999 | pendingOptions.getStartX(), pendingOptions.getStartY(), |
| 1000 | pendingOptions.getWidth(), pendingOptions.getHeight()); |
| 1001 | if (intent.getSourceBounds() == null) { |
| 1002 | intent.setSourceBounds(new Rect(pendingOptions.getStartX(), |
| 1003 | pendingOptions.getStartY(), |
| 1004 | pendingOptions.getStartX()+pendingOptions.getWidth(), |
| 1005 | pendingOptions.getStartY()+pendingOptions.getHeight())); |
| 1006 | } |
| 1007 | break; |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 1008 | case ActivityOptions.ANIM_SCALE_UP: |
| 1009 | service.mWindowManager.overridePendingAppTransitionScaleUp( |
| 1010 | pendingOptions.getStartX(), pendingOptions.getStartY(), |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 1011 | pendingOptions.getWidth(), pendingOptions.getHeight()); |
Dianne Hackborn | d367ca8 | 2012-05-07 15:49:39 -0700 | [diff] [blame] | 1012 | if (intent.getSourceBounds() == null) { |
| 1013 | intent.setSourceBounds(new Rect(pendingOptions.getStartX(), |
| 1014 | pendingOptions.getStartY(), |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 1015 | pendingOptions.getStartX()+pendingOptions.getWidth(), |
| 1016 | pendingOptions.getStartY()+pendingOptions.getHeight())); |
Dianne Hackborn | d367ca8 | 2012-05-07 15:49:39 -0700 | [diff] [blame] | 1017 | } |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 1018 | break; |
Michael Jurka | 832cb22 | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 1019 | case ActivityOptions.ANIM_THUMBNAIL_SCALE_UP: |
| 1020 | case ActivityOptions.ANIM_THUMBNAIL_SCALE_DOWN: |
| 1021 | boolean scaleUp = (animationType == ActivityOptions.ANIM_THUMBNAIL_SCALE_UP); |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 1022 | service.mWindowManager.overridePendingAppTransitionThumb( |
| 1023 | pendingOptions.getThumbnail(), |
| 1024 | pendingOptions.getStartX(), pendingOptions.getStartY(), |
Michael Jurka | 21385cd | 2012-05-03 10:57:31 -0700 | [diff] [blame] | 1025 | pendingOptions.getOnAnimationStartListener(), |
Michael Jurka | 832cb22 | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 1026 | scaleUp); |
Dianne Hackborn | d367ca8 | 2012-05-07 15:49:39 -0700 | [diff] [blame] | 1027 | if (intent.getSourceBounds() == null) { |
| 1028 | intent.setSourceBounds(new Rect(pendingOptions.getStartX(), |
| 1029 | pendingOptions.getStartY(), |
| 1030 | pendingOptions.getStartX() |
| 1031 | + pendingOptions.getThumbnail().getWidth(), |
| 1032 | pendingOptions.getStartY() |
| 1033 | + pendingOptions.getThumbnail().getHeight())); |
| 1034 | } |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 1035 | break; |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1036 | case ActivityOptions.ANIM_THUMBNAIL_ASPECT_SCALE_UP: |
| 1037 | case ActivityOptions.ANIM_THUMBNAIL_ASPECT_SCALE_DOWN: |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1038 | final AppTransitionAnimationSpec[] specs = pendingOptions.getAnimSpecs(); |
| 1039 | if (animationType == ActivityOptions.ANIM_THUMBNAIL_ASPECT_SCALE_DOWN |
| 1040 | && specs != null) { |
| 1041 | service.mWindowManager.overridePendingAppTransitionMultiThumb( |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 1042 | specs, pendingOptions.getOnAnimationStartListener(), |
| 1043 | pendingOptions.getAnimationFinishedListener(), false); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1044 | } else { |
| 1045 | service.mWindowManager.overridePendingAppTransitionAspectScaledThumb( |
| 1046 | pendingOptions.getThumbnail(), |
| 1047 | pendingOptions.getStartX(), pendingOptions.getStartY(), |
| 1048 | pendingOptions.getWidth(), pendingOptions.getHeight(), |
| 1049 | pendingOptions.getOnAnimationStartListener(), |
| 1050 | (animationType == ActivityOptions.ANIM_THUMBNAIL_ASPECT_SCALE_UP)); |
| 1051 | if (intent.getSourceBounds() == null) { |
| 1052 | intent.setSourceBounds(new Rect(pendingOptions.getStartX(), |
| 1053 | pendingOptions.getStartY(), |
| 1054 | pendingOptions.getStartX() + pendingOptions.getWidth(), |
| 1055 | pendingOptions.getStartY() + pendingOptions.getHeight())); |
| 1056 | } |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1057 | } |
| 1058 | break; |
Craig Mautner | 233ceee | 2014-05-09 17:05:11 -0700 | [diff] [blame] | 1059 | default: |
| 1060 | Slog.e(TAG, "applyOptionsLocked: Unknown animationType=" + animationType); |
| 1061 | break; |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1062 | } |
| 1063 | pendingOptions = null; |
| 1064 | } |
| 1065 | } |
| 1066 | |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 1067 | ActivityOptions getOptionsForTargetActivityLocked() { |
| 1068 | return pendingOptions != null ? pendingOptions.forTargetActivity() : null; |
| 1069 | } |
| 1070 | |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1071 | void clearOptionsLocked() { |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 1072 | if (pendingOptions != null) { |
| 1073 | pendingOptions.abort(); |
| 1074 | pendingOptions = null; |
| 1075 | } |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1076 | } |
| 1077 | |
Dianne Hackborn | 9622ca4 | 2012-10-23 18:56:33 -0700 | [diff] [blame] | 1078 | ActivityOptions takeOptionsLocked() { |
| 1079 | ActivityOptions opts = pendingOptions; |
| 1080 | pendingOptions = null; |
| 1081 | return opts; |
| 1082 | } |
| 1083 | |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 1084 | void removeUriPermissionsLocked() { |
Dianne Hackborn | 7e26964 | 2010-08-25 19:50:20 -0700 | [diff] [blame] | 1085 | if (uriPermissions != null) { |
| 1086 | uriPermissions.removeUriPermissionsLocked(); |
| 1087 | uriPermissions = null; |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 1088 | } |
| 1089 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1090 | |
| 1091 | void pauseKeyDispatchingLocked() { |
| 1092 | if (!keysPaused) { |
| 1093 | keysPaused = true; |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 1094 | service.mWindowManager.pauseKeyDispatching(appToken); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1095 | } |
| 1096 | } |
| 1097 | |
| 1098 | void resumeKeyDispatchingLocked() { |
| 1099 | if (keysPaused) { |
| 1100 | keysPaused = false; |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 1101 | service.mWindowManager.resumeKeyDispatching(appToken); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1102 | } |
| 1103 | } |
| 1104 | |
Winson Chung | 740c3ac | 2014-11-12 16:14:38 -0800 | [diff] [blame] | 1105 | void updateThumbnailLocked(Bitmap newThumbnail, CharSequence description) { |
Craig Mautner | c0ffce5 | 2014-07-01 12:38:52 -0700 | [diff] [blame] | 1106 | if (newThumbnail != null) { |
Wale Ogunwale | ee006da | 2015-03-30 14:49:25 -0700 | [diff] [blame] | 1107 | if (DEBUG_THUMBNAILS) Slog.i(TAG_THUMBNAILS, |
Craig Mautner | c0ffce5 | 2014-07-01 12:38:52 -0700 | [diff] [blame] | 1108 | "Setting thumbnail of " + this + " to " + newThumbnail); |
Winson | c809cbb | 2015-11-02 12:06:15 -0800 | [diff] [blame] | 1109 | boolean thumbnailUpdated = task.setLastThumbnailLocked(newThumbnail); |
Winson Chung | 096f36b | 2014-08-20 15:39:01 -0700 | [diff] [blame] | 1110 | if (thumbnailUpdated && isPersistable()) { |
Craig Mautner | c0ffce5 | 2014-07-01 12:38:52 -0700 | [diff] [blame] | 1111 | mStackSupervisor.mService.notifyTaskPersisterLocked(task, false); |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 1112 | } |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 1113 | } |
Craig Mautner | c0ffce5 | 2014-07-01 12:38:52 -0700 | [diff] [blame] | 1114 | task.lastDescription = description; |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 1115 | } |
| 1116 | |
Dianne Hackborn | 2a29b3a | 2012-03-15 15:48:38 -0700 | [diff] [blame] | 1117 | void startLaunchTickingLocked() { |
| 1118 | if (ActivityManagerService.IS_USER_BUILD) { |
| 1119 | return; |
| 1120 | } |
| 1121 | if (launchTickTime == 0) { |
| 1122 | launchTickTime = SystemClock.uptimeMillis(); |
| 1123 | continueLaunchTickingLocked(); |
| 1124 | } |
| 1125 | } |
| 1126 | |
| 1127 | boolean continueLaunchTickingLocked() { |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 1128 | if (launchTickTime == 0) { |
| 1129 | return false; |
Dianne Hackborn | 2a29b3a | 2012-03-15 15:48:38 -0700 | [diff] [blame] | 1130 | } |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 1131 | |
| 1132 | final ActivityStack stack = task.stack; |
| 1133 | if (stack == null) { |
| 1134 | return false; |
| 1135 | } |
| 1136 | |
| 1137 | Message msg = stack.mHandler.obtainMessage(ActivityStack.LAUNCH_TICK_MSG, this); |
| 1138 | stack.mHandler.removeMessages(ActivityStack.LAUNCH_TICK_MSG); |
| 1139 | stack.mHandler.sendMessageDelayed(msg, ActivityStack.LAUNCH_TICK); |
| 1140 | return true; |
Dianne Hackborn | 2a29b3a | 2012-03-15 15:48:38 -0700 | [diff] [blame] | 1141 | } |
| 1142 | |
| 1143 | void finishLaunchTickingLocked() { |
| 1144 | launchTickTime = 0; |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 1145 | final ActivityStack stack = task.stack; |
| 1146 | if (stack != null) { |
| 1147 | stack.mHandler.removeMessages(ActivityStack.LAUNCH_TICK_MSG); |
| 1148 | } |
Dianne Hackborn | 2a29b3a | 2012-03-15 15:48:38 -0700 | [diff] [blame] | 1149 | } |
| 1150 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1151 | // IApplicationToken |
| 1152 | |
| 1153 | public boolean mayFreezeScreenLocked(ProcessRecord app) { |
| 1154 | // Only freeze the screen if this activity is currently attached to |
| 1155 | // an application, and that application is not blocked or unresponding. |
| 1156 | // In any other case, we can't count on getting the screen unfrozen, |
| 1157 | // so it is best to leave as-is. |
Dianne Hackborn | 5f4d643 | 2010-12-21 20:40:11 -0800 | [diff] [blame] | 1158 | return app != null && !app.crashing && !app.notResponding; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1159 | } |
Craig Mautner | b59dcfd | 2013-05-06 13:12:58 -0700 | [diff] [blame] | 1160 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1161 | public void startFreezingScreenLocked(ProcessRecord app, int configChanges) { |
| 1162 | if (mayFreezeScreenLocked(app)) { |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 1163 | service.mWindowManager.startAppFreezingScreen(appToken, configChanges); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1164 | } |
| 1165 | } |
Craig Mautner | b59dcfd | 2013-05-06 13:12:58 -0700 | [diff] [blame] | 1166 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1167 | public void stopFreezingScreenLocked(boolean force) { |
| 1168 | if (force || frozenBeforeDestroy) { |
| 1169 | frozenBeforeDestroy = false; |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 1170 | service.mWindowManager.stopAppFreezingScreen(appToken, force); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1171 | } |
| 1172 | } |
Craig Mautner | b59dcfd | 2013-05-06 13:12:58 -0700 | [diff] [blame] | 1173 | |
Dianne Hackborn | 2286cdc | 2013-07-01 19:10:06 -0700 | [diff] [blame] | 1174 | public void reportFullyDrawnLocked() { |
| 1175 | final long curTime = SystemClock.uptimeMillis(); |
| 1176 | if (displayStartTime != 0) { |
| 1177 | reportLaunchTimeLocked(curTime); |
| 1178 | } |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 1179 | final ActivityStack stack = task.stack; |
| 1180 | if (fullyDrawnStartTime != 0 && stack != null) { |
Dianne Hackborn | 2286cdc | 2013-07-01 19:10:06 -0700 | [diff] [blame] | 1181 | final long thisTime = curTime - fullyDrawnStartTime; |
| 1182 | final long totalTime = stack.mFullyDrawnStartTime != 0 |
| 1183 | ? (curTime - stack.mFullyDrawnStartTime) : thisTime; |
Wale Ogunwale | 3ab9a27 | 2015-03-16 09:55:45 -0700 | [diff] [blame] | 1184 | if (SHOW_ACTIVITY_START_TIME) { |
Dianne Hackborn | cee04b5 | 2013-07-03 17:01:28 -0700 | [diff] [blame] | 1185 | Trace.asyncTraceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER, "drawing", 0); |
Dianne Hackborn | 2286cdc | 2013-07-01 19:10:06 -0700 | [diff] [blame] | 1186 | EventLog.writeEvent(EventLogTags.AM_ACTIVITY_FULLY_DRAWN_TIME, |
| 1187 | userId, System.identityHashCode(this), shortComponentName, |
| 1188 | thisTime, totalTime); |
| 1189 | StringBuilder sb = service.mStringBuilder; |
| 1190 | sb.setLength(0); |
| 1191 | sb.append("Fully drawn "); |
| 1192 | sb.append(shortComponentName); |
| 1193 | sb.append(": "); |
| 1194 | TimeUtils.formatDuration(thisTime, sb); |
| 1195 | if (thisTime != totalTime) { |
| 1196 | sb.append(" (total "); |
| 1197 | TimeUtils.formatDuration(totalTime, sb); |
| 1198 | sb.append(")"); |
| 1199 | } |
Wale Ogunwale | e23149f | 2015-03-06 15:39:44 -0800 | [diff] [blame] | 1200 | Log.i(TAG, sb.toString()); |
Dianne Hackborn | 2286cdc | 2013-07-01 19:10:06 -0700 | [diff] [blame] | 1201 | } |
| 1202 | if (totalTime > 0) { |
Adam Lesinski | 0debc9a | 2014-07-16 19:09:13 -0700 | [diff] [blame] | 1203 | //service.mUsageStatsService.noteFullyDrawnTime(realActivity, (int) totalTime); |
Dianne Hackborn | 2286cdc | 2013-07-01 19:10:06 -0700 | [diff] [blame] | 1204 | } |
Dianne Hackborn | 2286cdc | 2013-07-01 19:10:06 -0700 | [diff] [blame] | 1205 | stack.mFullyDrawnStartTime = 0; |
| 1206 | } |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 1207 | fullyDrawnStartTime = 0; |
Dianne Hackborn | 2286cdc | 2013-07-01 19:10:06 -0700 | [diff] [blame] | 1208 | } |
| 1209 | |
| 1210 | private void reportLaunchTimeLocked(final long curTime) { |
| 1211 | final ActivityStack stack = task.stack; |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 1212 | if (stack == null) { |
| 1213 | return; |
| 1214 | } |
Dianne Hackborn | 2286cdc | 2013-07-01 19:10:06 -0700 | [diff] [blame] | 1215 | final long thisTime = curTime - displayStartTime; |
| 1216 | final long totalTime = stack.mLaunchStartTime != 0 |
| 1217 | ? (curTime - stack.mLaunchStartTime) : thisTime; |
Wale Ogunwale | 3ab9a27 | 2015-03-16 09:55:45 -0700 | [diff] [blame] | 1218 | if (SHOW_ACTIVITY_START_TIME) { |
Narayan Kamath | 7829c81 | 2015-06-08 17:39:43 +0100 | [diff] [blame] | 1219 | Trace.asyncTraceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER, "launching: " + packageName, 0); |
Dianne Hackborn | 2286cdc | 2013-07-01 19:10:06 -0700 | [diff] [blame] | 1220 | EventLog.writeEvent(EventLogTags.AM_ACTIVITY_LAUNCH_TIME, |
| 1221 | userId, System.identityHashCode(this), shortComponentName, |
| 1222 | thisTime, totalTime); |
| 1223 | StringBuilder sb = service.mStringBuilder; |
| 1224 | sb.setLength(0); |
| 1225 | sb.append("Displayed "); |
| 1226 | sb.append(shortComponentName); |
| 1227 | sb.append(": "); |
| 1228 | TimeUtils.formatDuration(thisTime, sb); |
| 1229 | if (thisTime != totalTime) { |
| 1230 | sb.append(" (total "); |
| 1231 | TimeUtils.formatDuration(totalTime, sb); |
| 1232 | sb.append(")"); |
| 1233 | } |
Wale Ogunwale | e23149f | 2015-03-06 15:39:44 -0800 | [diff] [blame] | 1234 | Log.i(TAG, sb.toString()); |
Dianne Hackborn | 2286cdc | 2013-07-01 19:10:06 -0700 | [diff] [blame] | 1235 | } |
| 1236 | mStackSupervisor.reportActivityLaunchedLocked(false, this, thisTime, totalTime); |
| 1237 | if (totalTime > 0) { |
Adam Lesinski | 0debc9a | 2014-07-16 19:09:13 -0700 | [diff] [blame] | 1238 | //service.mUsageStatsService.noteLaunchTime(realActivity, (int)totalTime); |
Dianne Hackborn | 2286cdc | 2013-07-01 19:10:06 -0700 | [diff] [blame] | 1239 | } |
| 1240 | displayStartTime = 0; |
| 1241 | stack.mLaunchStartTime = 0; |
| 1242 | } |
| 1243 | |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 1244 | void windowsDrawnLocked() { |
Jorim Jaggi | 275561a | 2016-02-23 10:11:02 -0500 | [diff] [blame] | 1245 | mStackSupervisor.mActivityMetricsLogger.notifyWindowsDrawn(); |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 1246 | if (displayStartTime != 0) { |
Chong Zhang | 5022da3 | 2016-06-21 16:31:37 -0700 | [diff] [blame] | 1247 | reportLaunchTimeLocked(SystemClock.uptimeMillis()); |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 1248 | } |
| 1249 | mStackSupervisor.sendWaitingVisibleReportLocked(this); |
| 1250 | startTime = 0; |
| 1251 | finishLaunchTickingLocked(); |
| 1252 | if (task != null) { |
| 1253 | task.hasBeenVisible = true; |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 1254 | } |
| 1255 | } |
| 1256 | |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 1257 | void windowsVisibleLocked() { |
| 1258 | mStackSupervisor.reportActivityVisibleLocked(this); |
Wale Ogunwale | ee006da | 2015-03-30 14:49:25 -0700 | [diff] [blame] | 1259 | if (DEBUG_SWITCH) Log.v(TAG_SWITCH, "windowsVisibleLocked(): " + this); |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 1260 | if (!nowVisible) { |
| 1261 | nowVisible = true; |
| 1262 | lastVisibleTime = SystemClock.uptimeMillis(); |
| 1263 | if (!idle) { |
| 1264 | // Instead of doing the full stop routine here, let's just hide any activities |
| 1265 | // we now can, and let them stop when the normal idle happens. |
| 1266 | mStackSupervisor.processStoppingActivitiesLocked(false); |
| 1267 | } else { |
| 1268 | // If this activity was already idle, then we now need to make sure we perform |
| 1269 | // the full stop of any activities that are waiting to do so. This is because |
| 1270 | // we won't do that while they are still waiting for this one to become visible. |
| 1271 | final int size = mStackSupervisor.mWaitingVisibleActivities.size(); |
| 1272 | if (size > 0) { |
| 1273 | for (int i = 0; i < size; i++) { |
| 1274 | ActivityRecord r = mStackSupervisor.mWaitingVisibleActivities.get(i); |
Wale Ogunwale | ee006da | 2015-03-30 14:49:25 -0700 | [diff] [blame] | 1275 | if (DEBUG_SWITCH) Log.v(TAG_SWITCH, "Was waiting for visible: " + r); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1276 | } |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 1277 | mStackSupervisor.mWaitingVisibleActivities.clear(); |
| 1278 | mStackSupervisor.scheduleIdleLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1279 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1280 | } |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 1281 | service.scheduleAppGcsLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1282 | } |
| 1283 | } |
| 1284 | |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 1285 | ActivityRecord getWaitingHistoryRecordLocked() { |
riddle_hsu | db46d6b | 2015-04-01 18:58:07 +0800 | [diff] [blame] | 1286 | // First find the real culprit... if this activity is waiting for |
| 1287 | // another activity to start or has stopped, then the key dispatching |
| 1288 | // timeout should not be caused by this. |
Wale Ogunwale | 16a6279 | 2015-04-01 11:50:31 -0700 | [diff] [blame] | 1289 | if (mStackSupervisor.mWaitingVisibleActivities.contains(this) || stopped) { |
Craig Mautner | 8f2adcb | 2014-04-07 22:21:33 +0000 | [diff] [blame] | 1290 | final ActivityStack stack = mStackSupervisor.getFocusedStack(); |
riddle_hsu | db46d6b | 2015-04-01 18:58:07 +0800 | [diff] [blame] | 1291 | // Try to use the one which is closest to top. |
| 1292 | ActivityRecord r = stack.mResumedActivity; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1293 | if (r == null) { |
Dianne Hackborn | 621e2fe | 2012-02-16 17:07:33 -0800 | [diff] [blame] | 1294 | r = stack.mPausingActivity; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1295 | } |
riddle_hsu | db46d6b | 2015-04-01 18:58:07 +0800 | [diff] [blame] | 1296 | if (r != null) { |
| 1297 | return r; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1298 | } |
| 1299 | } |
riddle_hsu | db46d6b | 2015-04-01 18:58:07 +0800 | [diff] [blame] | 1300 | return this; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1301 | } |
| 1302 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1303 | /** |
| 1304 | * This method will return true if the activity is either visible, is becoming visible, is |
| 1305 | * currently pausing, or is resumed. |
| 1306 | */ |
| 1307 | public boolean isInterestingToUserLocked() { |
Craig Mautner | b59dcfd | 2013-05-06 13:12:58 -0700 | [diff] [blame] | 1308 | return visible || nowVisible || state == ActivityState.PAUSING || |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1309 | state == ActivityState.RESUMED; |
Dianne Hackborn | 4eba96b | 2011-01-21 13:34:36 -0800 | [diff] [blame] | 1310 | } |
| 1311 | |
Wale Ogunwale | 3e99736 | 2016-09-06 10:37:56 -0700 | [diff] [blame] | 1312 | void setSleeping(boolean _sleeping) { |
| 1313 | setSleeping(_sleeping, false); |
| 1314 | } |
| 1315 | |
| 1316 | void setSleeping(boolean _sleeping, boolean force) { |
| 1317 | if (!force && sleeping == _sleeping) { |
Dianne Hackborn | 4eba96b | 2011-01-21 13:34:36 -0800 | [diff] [blame] | 1318 | return; |
| 1319 | } |
| 1320 | if (app != null && app.thread != null) { |
| 1321 | try { |
Dianne Hackborn | be70785 | 2011-11-11 14:32:10 -0800 | [diff] [blame] | 1322 | app.thread.scheduleSleeping(appToken, _sleeping); |
Craig Mautner | 0eea92c | 2013-05-16 13:35:39 -0700 | [diff] [blame] | 1323 | if (_sleeping && !mStackSupervisor.mGoingToSleepActivities.contains(this)) { |
| 1324 | mStackSupervisor.mGoingToSleepActivities.add(this); |
Dianne Hackborn | 4eba96b | 2011-01-21 13:34:36 -0800 | [diff] [blame] | 1325 | } |
| 1326 | sleeping = _sleeping; |
| 1327 | } catch (RemoteException e) { |
Craig Mautner | 0eea92c | 2013-05-16 13:35:39 -0700 | [diff] [blame] | 1328 | Slog.w(TAG, "Exception thrown when sleeping: " + intent.getComponent(), e); |
Dianne Hackborn | 4eba96b | 2011-01-21 13:34:36 -0800 | [diff] [blame] | 1329 | } |
| 1330 | } |
| 1331 | } |
Craig Mautner | f81b9087 | 2013-02-26 13:02:43 -0800 | [diff] [blame] | 1332 | |
Craig Mautner | d232895 | 2013-03-05 12:46:26 -0800 | [diff] [blame] | 1333 | static int getTaskForActivityLocked(IBinder token, boolean onlyRoot) { |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 1334 | final ActivityRecord r = ActivityRecord.forTokenLocked(token); |
Craig Mautner | d232895 | 2013-03-05 12:46:26 -0800 | [diff] [blame] | 1335 | if (r == null) { |
Wale Ogunwale | 18795a2 | 2014-12-03 11:38:33 -0800 | [diff] [blame] | 1336 | return INVALID_TASK_ID; |
Craig Mautner | d232895 | 2013-03-05 12:46:26 -0800 | [diff] [blame] | 1337 | } |
| 1338 | final TaskRecord task = r.task; |
Craig Mautner | 9d4e9bc | 2014-06-18 18:34:56 -0700 | [diff] [blame] | 1339 | final int activityNdx = task.mActivities.indexOf(r); |
| 1340 | if (activityNdx < 0 || (onlyRoot && activityNdx > task.findEffectiveRootIndex())) { |
Wale Ogunwale | 18795a2 | 2014-12-03 11:38:33 -0800 | [diff] [blame] | 1341 | return INVALID_TASK_ID; |
Craig Mautner | d232895 | 2013-03-05 12:46:26 -0800 | [diff] [blame] | 1342 | } |
Craig Mautner | 9d4e9bc | 2014-06-18 18:34:56 -0700 | [diff] [blame] | 1343 | return task.taskId; |
Craig Mautner | d232895 | 2013-03-05 12:46:26 -0800 | [diff] [blame] | 1344 | } |
| 1345 | |
| 1346 | static ActivityRecord isInStackLocked(IBinder token) { |
Wale Ogunwale | 7d70117 | 2015-03-11 15:36:30 -0700 | [diff] [blame] | 1347 | final ActivityRecord r = ActivityRecord.forTokenLocked(token); |
Wale Ogunwale | 60454db | 2015-01-23 16:05:07 -0800 | [diff] [blame] | 1348 | return (r != null) ? r.task.stack.isInStackLocked(r) : null; |
Craig Mautner | d232895 | 2013-03-05 12:46:26 -0800 | [diff] [blame] | 1349 | } |
| 1350 | |
Craig Mautner | b59dcfd | 2013-05-06 13:12:58 -0700 | [diff] [blame] | 1351 | static ActivityStack getStackLocked(IBinder token) { |
Craig Mautner | d232895 | 2013-03-05 12:46:26 -0800 | [diff] [blame] | 1352 | final ActivityRecord r = ActivityRecord.isInStackLocked(token); |
| 1353 | if (r != null) { |
| 1354 | return r.task.stack; |
| 1355 | } |
| 1356 | return null; |
| 1357 | } |
| 1358 | |
Dianne Hackborn | 89ad456 | 2014-08-24 16:45:38 -0700 | [diff] [blame] | 1359 | final boolean isDestroyable() { |
| 1360 | if (finishing || app == null || state == ActivityState.DESTROYING |
| 1361 | || state == ActivityState.DESTROYED) { |
| 1362 | // This would be redundant. |
| 1363 | return false; |
| 1364 | } |
| 1365 | if (task == null || task.stack == null || this == task.stack.mResumedActivity |
| 1366 | || this == task.stack.mPausingActivity || !haveState || !stopped) { |
| 1367 | // We're not ready for this kind of thing. |
| 1368 | return false; |
| 1369 | } |
| 1370 | if (visible) { |
| 1371 | // The user would notice this! |
| 1372 | return false; |
| 1373 | } |
| 1374 | return true; |
| 1375 | } |
| 1376 | |
Winson Chung | 3bad5cc0 | 2014-08-19 17:44:32 -0700 | [diff] [blame] | 1377 | private static String createImageFilename(long createTime, int taskId) { |
| 1378 | return String.valueOf(taskId) + ACTIVITY_ICON_SUFFIX + createTime + |
Craig Mautner | c0ffce5 | 2014-07-01 12:38:52 -0700 | [diff] [blame] | 1379 | TaskPersister.IMAGE_EXTENSION; |
| 1380 | } |
| 1381 | |
Craig Mautner | 648f69b | 2014-09-18 14:16:26 -0700 | [diff] [blame] | 1382 | void setTaskDescription(TaskDescription _taskDescription) { |
| 1383 | Bitmap icon; |
| 1384 | if (_taskDescription.getIconFilename() == null && |
| 1385 | (icon = _taskDescription.getIcon()) != null) { |
| 1386 | final String iconFilename = createImageFilename(createTime, task.taskId); |
Suprabh Shukla | 2359314 | 2015-11-03 17:31:15 -0800 | [diff] [blame] | 1387 | final File iconFile = new File(TaskPersister.getUserImagesDir(userId), iconFilename); |
| 1388 | final String iconFilePath = iconFile.getAbsolutePath(); |
Suprabh Shukla | 09a88f5 | 2015-12-02 14:36:31 -0800 | [diff] [blame] | 1389 | service.mRecentTasks.saveImage(icon, iconFilePath); |
Suprabh Shukla | 2359314 | 2015-11-03 17:31:15 -0800 | [diff] [blame] | 1390 | _taskDescription.setIconFilename(iconFilePath); |
Craig Mautner | 648f69b | 2014-09-18 14:16:26 -0700 | [diff] [blame] | 1391 | } |
| 1392 | taskDescription = _taskDescription; |
| 1393 | } |
| 1394 | |
Amith Yamasani | 0af6fa7 | 2016-01-17 15:36:19 -0800 | [diff] [blame] | 1395 | void setVoiceSessionLocked(IVoiceInteractionSession session) { |
| 1396 | voiceSession = session; |
| 1397 | pendingVoiceInteractionStart = false; |
| 1398 | } |
| 1399 | |
| 1400 | void clearVoiceSessionLocked() { |
| 1401 | voiceSession = null; |
| 1402 | pendingVoiceInteractionStart = false; |
| 1403 | } |
| 1404 | |
Wale Ogunwale | 3b23239 | 2016-05-13 15:37:13 -0700 | [diff] [blame] | 1405 | void showStartingWindow(ActivityRecord prev, boolean createIfNeeded) { |
| 1406 | final CompatibilityInfo compatInfo = |
| 1407 | service.compatibilityInfoForPackageLocked(info.applicationInfo); |
| 1408 | final boolean shown = service.mWindowManager.setAppStartingWindow( |
| 1409 | appToken, packageName, theme, compatInfo, nonLocalizedLabel, labelRes, icon, |
| 1410 | logo, windowFlags, prev != null ? prev.appToken : null, createIfNeeded); |
| 1411 | if (shown) { |
| 1412 | mStartingWindowState = STARTING_WINDOW_SHOWN; |
| 1413 | } |
| 1414 | } |
| 1415 | |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 1416 | void saveToXml(XmlSerializer out) throws IOException, XmlPullParserException { |
| 1417 | out.attribute(null, ATTR_ID, String.valueOf(createTime)); |
| 1418 | out.attribute(null, ATTR_LAUNCHEDFROMUID, String.valueOf(launchedFromUid)); |
| 1419 | if (launchedFromPackage != null) { |
| 1420 | out.attribute(null, ATTR_LAUNCHEDFROMPACKAGE, launchedFromPackage); |
| 1421 | } |
| 1422 | if (resolvedType != null) { |
| 1423 | out.attribute(null, ATTR_RESOLVEDTYPE, resolvedType); |
| 1424 | } |
| 1425 | out.attribute(null, ATTR_COMPONENTSPECIFIED, String.valueOf(componentSpecified)); |
| 1426 | out.attribute(null, ATTR_USERID, String.valueOf(userId)); |
Winson Chung | 2cb86c7 | 2014-06-25 12:03:30 -0700 | [diff] [blame] | 1427 | |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 1428 | if (taskDescription != null) { |
Craig Mautner | 648f69b | 2014-09-18 14:16:26 -0700 | [diff] [blame] | 1429 | taskDescription.saveToXml(out); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 1430 | } |
| 1431 | |
| 1432 | out.startTag(null, TAG_INTENT); |
| 1433 | intent.saveToXml(out); |
| 1434 | out.endTag(null, TAG_INTENT); |
| 1435 | |
| 1436 | if (isPersistable() && persistentState != null) { |
| 1437 | out.startTag(null, TAG_PERSISTABLEBUNDLE); |
| 1438 | persistentState.saveToXml(out); |
| 1439 | out.endTag(null, TAG_PERSISTABLEBUNDLE); |
| 1440 | } |
| 1441 | } |
| 1442 | |
Stefan Kuhne | e88d1e5 | 2015-05-18 10:33:45 -0700 | [diff] [blame] | 1443 | static ActivityRecord restoreFromXml(XmlPullParser in, |
| 1444 | ActivityStackSupervisor stackSupervisor) throws IOException, XmlPullParserException { |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 1445 | Intent intent = null; |
| 1446 | PersistableBundle persistentState = null; |
| 1447 | int launchedFromUid = 0; |
| 1448 | String launchedFromPackage = null; |
| 1449 | String resolvedType = null; |
| 1450 | boolean componentSpecified = false; |
| 1451 | int userId = 0; |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 1452 | long createTime = -1; |
| 1453 | final int outerDepth = in.getDepth(); |
Winson Chung | 2cb86c7 | 2014-06-25 12:03:30 -0700 | [diff] [blame] | 1454 | TaskDescription taskDescription = new TaskDescription(); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 1455 | |
| 1456 | for (int attrNdx = in.getAttributeCount() - 1; attrNdx >= 0; --attrNdx) { |
| 1457 | final String attrName = in.getAttributeName(attrNdx); |
| 1458 | final String attrValue = in.getAttributeValue(attrNdx); |
Stefan Kuhne | e88d1e5 | 2015-05-18 10:33:45 -0700 | [diff] [blame] | 1459 | if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG, |
Wale Ogunwale | 18795a2 | 2014-12-03 11:38:33 -0800 | [diff] [blame] | 1460 | "ActivityRecord: attribute name=" + attrName + " value=" + attrValue); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 1461 | if (ATTR_ID.equals(attrName)) { |
Tobias Thierer | 28532d0 | 2016-04-21 14:52:10 +0100 | [diff] [blame] | 1462 | createTime = Long.parseLong(attrValue); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 1463 | } else if (ATTR_LAUNCHEDFROMUID.equals(attrName)) { |
Narayan Kamath | a09b4d2 | 2016-04-15 18:32:45 +0100 | [diff] [blame] | 1464 | launchedFromUid = Integer.parseInt(attrValue); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 1465 | } else if (ATTR_LAUNCHEDFROMPACKAGE.equals(attrName)) { |
| 1466 | launchedFromPackage = attrValue; |
| 1467 | } else if (ATTR_RESOLVEDTYPE.equals(attrName)) { |
| 1468 | resolvedType = attrValue; |
| 1469 | } else if (ATTR_COMPONENTSPECIFIED.equals(attrName)) { |
Tobias Thierer | b0800dc | 2016-04-21 17:51:41 +0100 | [diff] [blame] | 1470 | componentSpecified = Boolean.parseBoolean(attrValue); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 1471 | } else if (ATTR_USERID.equals(attrName)) { |
Narayan Kamath | a09b4d2 | 2016-04-15 18:32:45 +0100 | [diff] [blame] | 1472 | userId = Integer.parseInt(attrValue); |
Craig Mautner | 648f69b | 2014-09-18 14:16:26 -0700 | [diff] [blame] | 1473 | } else if (attrName.startsWith(TaskDescription.ATTR_TASKDESCRIPTION_PREFIX)) { |
| 1474 | taskDescription.restoreFromXml(attrName, attrValue); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 1475 | } else { |
| 1476 | Log.d(TAG, "Unknown ActivityRecord attribute=" + attrName); |
| 1477 | } |
| 1478 | } |
| 1479 | |
| 1480 | int event; |
| 1481 | while (((event = in.next()) != XmlPullParser.END_DOCUMENT) && |
Ben Kwa | 8814cf4 | 2015-07-08 10:54:56 -0700 | [diff] [blame] | 1482 | (event != XmlPullParser.END_TAG || in.getDepth() >= outerDepth)) { |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 1483 | if (event == XmlPullParser.START_TAG) { |
| 1484 | final String name = in.getName(); |
Stefan Kuhne | e88d1e5 | 2015-05-18 10:33:45 -0700 | [diff] [blame] | 1485 | if (TaskPersister.DEBUG) |
Wale Ogunwale | 18795a2 | 2014-12-03 11:38:33 -0800 | [diff] [blame] | 1486 | Slog.d(TaskPersister.TAG, "ActivityRecord: START_TAG name=" + name); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 1487 | if (TAG_INTENT.equals(name)) { |
| 1488 | intent = Intent.restoreFromXml(in); |
Stefan Kuhne | e88d1e5 | 2015-05-18 10:33:45 -0700 | [diff] [blame] | 1489 | if (TaskPersister.DEBUG) |
Wale Ogunwale | 18795a2 | 2014-12-03 11:38:33 -0800 | [diff] [blame] | 1490 | Slog.d(TaskPersister.TAG, "ActivityRecord: intent=" + intent); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 1491 | } else if (TAG_PERSISTABLEBUNDLE.equals(name)) { |
| 1492 | persistentState = PersistableBundle.restoreFromXml(in); |
Stefan Kuhne | e88d1e5 | 2015-05-18 10:33:45 -0700 | [diff] [blame] | 1493 | if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG, |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 1494 | "ActivityRecord: persistentState=" + persistentState); |
| 1495 | } else { |
| 1496 | Slog.w(TAG, "restoreActivity: unexpected name=" + name); |
| 1497 | XmlUtils.skipCurrentTag(in); |
| 1498 | } |
| 1499 | } |
| 1500 | } |
| 1501 | |
| 1502 | if (intent == null) { |
Craig Mautner | e0129b3 | 2014-05-25 16:41:09 -0700 | [diff] [blame] | 1503 | throw new XmlPullParserException("restoreActivity error intent=" + intent); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 1504 | } |
| 1505 | |
| 1506 | final ActivityManagerService service = stackSupervisor.mService; |
| 1507 | final ActivityInfo aInfo = stackSupervisor.resolveActivity(intent, resolvedType, 0, null, |
Jeff Hao | 1b012d3 | 2014-08-20 10:35:34 -0700 | [diff] [blame] | 1508 | userId); |
Craig Mautner | e0129b3 | 2014-05-25 16:41:09 -0700 | [diff] [blame] | 1509 | if (aInfo == null) { |
Craig Mautner | 77b0426 | 2014-06-27 15:22:12 -0700 | [diff] [blame] | 1510 | throw new XmlPullParserException("restoreActivity resolver error. Intent=" + intent + |
| 1511 | " resolvedType=" + resolvedType); |
Craig Mautner | e0129b3 | 2014-05-25 16:41:09 -0700 | [diff] [blame] | 1512 | } |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 1513 | final ActivityRecord r = new ActivityRecord(service, /*caller*/null, launchedFromUid, |
| 1514 | launchedFromPackage, intent, resolvedType, aInfo, service.getConfiguration(), |
Wale Ogunwale | 1affbbc | 2016-05-01 09:03:52 -0700 | [diff] [blame] | 1515 | null, null, 0, componentSpecified, false, stackSupervisor, null, null, null); |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 1516 | |
| 1517 | r.persistentState = persistentState; |
Winson Chung | 2cb86c7 | 2014-06-25 12:03:30 -0700 | [diff] [blame] | 1518 | r.taskDescription = taskDescription; |
Craig Mautner | 21d24a2 | 2014-04-23 11:45:37 -0700 | [diff] [blame] | 1519 | r.createTime = createTime; |
| 1520 | |
| 1521 | return r; |
| 1522 | } |
| 1523 | |
| 1524 | private static String activityTypeToString(int type) { |
Craig Mautner | ae7ecab | 2013-09-18 11:48:14 -0700 | [diff] [blame] | 1525 | switch (type) { |
| 1526 | case APPLICATION_ACTIVITY_TYPE: return "APPLICATION_ACTIVITY_TYPE"; |
| 1527 | case HOME_ACTIVITY_TYPE: return "HOME_ACTIVITY_TYPE"; |
| 1528 | case RECENTS_ACTIVITY_TYPE: return "RECENTS_ACTIVITY_TYPE"; |
| 1529 | default: return Integer.toString(type); |
| 1530 | } |
| 1531 | } |
| 1532 | |
Craig Mautner | f81b9087 | 2013-02-26 13:02:43 -0800 | [diff] [blame] | 1533 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1534 | public String toString() { |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 1535 | if (stringName != null) { |
Wale Ogunwale | 18795a2 | 2014-12-03 11:38:33 -0800 | [diff] [blame] | 1536 | return stringName + " t" + (task == null ? INVALID_TASK_ID : task.taskId) + |
Craig Mautner | f333327 | 2013-04-22 10:55:53 -0700 | [diff] [blame] | 1537 | (finishing ? " f}" : "}"); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 1538 | } |
| 1539 | StringBuilder sb = new StringBuilder(128); |
Dianne Hackborn | 30d7189 | 2010-12-11 10:37:55 -0800 | [diff] [blame] | 1540 | sb.append("ActivityRecord{"); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 1541 | sb.append(Integer.toHexString(System.identityHashCode(this))); |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 1542 | sb.append(" u"); |
| 1543 | sb.append(userId); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 1544 | sb.append(' '); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1545 | sb.append(intent.getComponent().flattenToShortString()); |
Craig Mautner | f81b9087 | 2013-02-26 13:02:43 -0800 | [diff] [blame] | 1546 | stringName = sb.toString(); |
| 1547 | return toString(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1548 | } |
| 1549 | } |