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 | |
| 19 | import com.android.server.AttributeCache; |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 20 | import com.android.server.am.ActivityStack.ActivityState; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | |
| 22 | import android.app.Activity; |
| 23 | import android.content.ComponentName; |
| 24 | import android.content.Intent; |
| 25 | import android.content.pm.ActivityInfo; |
| 26 | import android.content.pm.ApplicationInfo; |
| 27 | import android.content.res.Configuration; |
| 28 | import android.graphics.Bitmap; |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 29 | import android.os.Build; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | import android.os.Bundle; |
| 31 | import android.os.Message; |
| 32 | import android.os.Process; |
Dianne Hackborn | 39792d2 | 2010-08-19 18:01:52 -0700 | [diff] [blame] | 33 | import android.os.RemoteException; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | import android.os.SystemClock; |
| 35 | import android.util.EventLog; |
| 36 | import android.util.Log; |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 37 | import android.util.Slog; |
Dianne Hackborn | 0dad364 | 2010-09-09 21:25:35 -0700 | [diff] [blame] | 38 | import android.util.TimeUtils; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | import android.view.IApplicationToken; |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 40 | import android.view.WindowManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | |
| 42 | import java.io.PrintWriter; |
| 43 | import java.lang.ref.WeakReference; |
| 44 | import java.util.ArrayList; |
| 45 | import java.util.HashSet; |
| 46 | |
| 47 | /** |
| 48 | * An entry in the history stack, representing an activity. |
| 49 | */ |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 50 | final class ActivityRecord extends IApplicationToken.Stub { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | final ActivityManagerService service; // owner |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 52 | final ActivityStack stack; // owner |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | final ActivityInfo info; // all about me |
| 54 | final int launchedFromUid; // always the uid who started the activity. |
| 55 | final Intent intent; // the original intent that generated us |
| 56 | final ComponentName realActivity; // the intent component, or target of an alias. |
| 57 | final String shortComponentName; // the short component name of the intent |
| 58 | final String resolvedType; // as per original caller; |
| 59 | final String packageName; // the package implementing intent's component |
| 60 | final String processName; // process where this component wants to run |
| 61 | final String taskAffinity; // as per ActivityInfo.taskAffinity |
| 62 | final boolean stateNotNeeded; // As per ActivityInfo.flags |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 63 | final boolean fullscreen; // covers the full screen? |
| 64 | final boolean noDisplay; // activity is not displayed? |
The Android Open Source Project | 4df2423 | 2009-03-05 14:34:35 -0800 | [diff] [blame] | 65 | final boolean componentSpecified; // did caller specifiy an explicit component? |
| 66 | final boolean isHomeActivity; // do we consider this to be a home activity? |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | final String baseDir; // where activity source (resources etc) located |
| 68 | final String resDir; // where public activity source (public resources etc) located |
| 69 | final String dataDir; // where activity data should go |
| 70 | CharSequence nonLocalizedLabel; // the label information from the package mgr. |
| 71 | int labelRes; // the label information from the package mgr. |
| 72 | int icon; // resource identifier of activity's icon. |
| 73 | int theme; // resource identifier of activity's theme. |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 74 | int realTheme; // actual theme resource we will use, never 0. |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 75 | int windowFlags; // custom window flags for preview window. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 76 | TaskRecord task; // the task this is in. |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 77 | ThumbnailHolder thumbHolder; // where our thumbnails should go. |
Dianne Hackborn | 0dad364 | 2010-09-09 21:25:35 -0700 | [diff] [blame] | 78 | long launchTime; // when we starting launching this activity |
| 79 | long startTime; // last time this activity was started |
Amith Yamasani | eaeb663 | 2009-06-03 15:16:10 -0700 | [diff] [blame] | 80 | long cpuTimeAtResume; // the cpu time of host process at the time of resuming activity |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 81 | Configuration configuration; // configuration activity was last running in |
Dianne Hackborn | 01e4cfc | 2010-06-24 15:07:24 -0700 | [diff] [blame] | 82 | 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] | 83 | final String resultWho; // additional identifier for use by resultTo. |
| 84 | final int requestCode; // code given by requester (resultTo) |
| 85 | ArrayList results; // pending ActivityResult objs we have received |
| 86 | HashSet<WeakReference<PendingIntentRecord>> pendingResults; // all pending intents for this act |
| 87 | ArrayList newIntents; // any pending new intents for single-top mode |
| 88 | HashSet<ConnectionRecord> connections; // All ConnectionRecord we hold |
Dianne Hackborn | 7e26964 | 2010-08-25 19:50:20 -0700 | [diff] [blame] | 89 | UriPermissionOwner uriPermissions; // current special URI access perms. |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 90 | ProcessRecord app; // if non-null, hosting application |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 91 | ActivityState state; // current state we are in |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 92 | Bundle icicle; // last saved activity state |
| 93 | boolean frontOfTask; // is this the root activity of its task? |
| 94 | boolean launchFailed; // set if a launched failed, to abort on 2nd try |
| 95 | boolean haveState; // have we gotten the last activity state? |
| 96 | boolean stopped; // is activity pause finished? |
Dianne Hackborn | 95fc68f | 2009-05-19 18:37:45 -0700 | [diff] [blame] | 97 | 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] | 98 | boolean finishing; // activity in pending finish list? |
| 99 | boolean configDestroy; // need to destroy due to config change? |
| 100 | int configChangeFlags; // which config values have changed |
| 101 | boolean keysPaused; // has key dispatching been paused for it? |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 102 | int launchMode; // the launch mode activity attribute. |
| 103 | boolean visible; // does this activity's window need to be shown? |
Dianne Hackborn | 4eba96b | 2011-01-21 13:34:36 -0800 | [diff] [blame] | 104 | boolean sleeping; // have we told the activity to sleep? |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | boolean waitingVisible; // true if waiting for a new act to become vis |
| 106 | boolean nowVisible; // is this activity's window visible? |
| 107 | boolean thumbnailNeeded;// has someone requested a thumbnail? |
| 108 | boolean idle; // has the activity gone idle? |
| 109 | boolean hasBeenLaunched;// has this activity ever been launched? |
| 110 | boolean frozenBeforeDestroy;// has been frozen but not yet destroyed. |
Daniel Sandler | 69a4817 | 2010-06-23 16:29:36 -0400 | [diff] [blame] | 111 | boolean immersive; // immersive mode (don't interrupt if possible) |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 112 | boolean forceNewConfig; // force re-create with new config next time |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 113 | |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 114 | String stringName; // for caching of toString(). |
| 115 | |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 116 | private boolean inHistory; // are we in the history stack? |
| 117 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 118 | void dump(PrintWriter pw, String prefix) { |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 119 | pw.print(prefix); pw.print("packageName="); pw.print(packageName); |
| 120 | pw.print(" processName="); pw.println(processName); |
| 121 | pw.print(prefix); pw.print("launchedFromUid="); pw.print(launchedFromUid); |
| 122 | pw.print(" app="); pw.println(app); |
| 123 | pw.print(prefix); pw.println(intent); |
| 124 | pw.print(prefix); pw.print("frontOfTask="); pw.print(frontOfTask); |
| 125 | pw.print(" task="); pw.println(task); |
| 126 | pw.print(prefix); pw.print("taskAffinity="); pw.println(taskAffinity); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 127 | pw.print(prefix); pw.print("realActivity="); |
| 128 | pw.println(realActivity.flattenToShortString()); |
| 129 | pw.print(prefix); pw.print("base="); pw.print(baseDir); |
| 130 | if (!resDir.equals(baseDir)) pw.print(" res="); pw.print(resDir); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 131 | pw.print(" data="); pw.println(dataDir); |
| 132 | pw.print(prefix); pw.print("labelRes=0x"); |
| 133 | pw.print(Integer.toHexString(labelRes)); |
| 134 | pw.print(" icon=0x"); pw.print(Integer.toHexString(icon)); |
| 135 | pw.print(" theme=0x"); pw.println(Integer.toHexString(theme)); |
| 136 | pw.print(prefix); pw.print("stateNotNeeded="); pw.print(stateNotNeeded); |
| 137 | pw.print(" componentSpecified="); pw.print(componentSpecified); |
| 138 | pw.print(" isHomeActivity="); pw.println(isHomeActivity); |
Dianne Hackborn | e17aeb3 | 2011-04-07 15:11:57 -0700 | [diff] [blame] | 139 | pw.print(prefix); pw.print("config="); pw.println(configuration); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 140 | if (resultTo != null || resultWho != null) { |
| 141 | pw.print(prefix); pw.print("resultTo="); pw.print(resultTo); |
| 142 | pw.print(" resultWho="); pw.print(resultWho); |
| 143 | pw.print(" resultCode="); pw.println(requestCode); |
| 144 | } |
| 145 | if (results != null) { |
| 146 | pw.print(prefix); pw.print("results="); pw.println(results); |
| 147 | } |
| 148 | if (pendingResults != null) { |
| 149 | pw.print(prefix); pw.print("pendingResults="); pw.println(pendingResults); |
| 150 | } |
Dianne Hackborn | 7e26964 | 2010-08-25 19:50:20 -0700 | [diff] [blame] | 151 | if (uriPermissions != null) { |
| 152 | if (uriPermissions.readUriPermissions != null) { |
| 153 | pw.print(prefix); pw.print("readUriPermissions="); |
| 154 | pw.println(uriPermissions.readUriPermissions); |
| 155 | } |
| 156 | if (uriPermissions.writeUriPermissions != null) { |
| 157 | pw.print(prefix); pw.print("writeUriPermissions="); |
| 158 | pw.println(uriPermissions.writeUriPermissions); |
| 159 | } |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 160 | } |
| 161 | pw.print(prefix); pw.print("launchFailed="); pw.print(launchFailed); |
| 162 | pw.print(" haveState="); pw.print(haveState); |
| 163 | pw.print(" icicle="); pw.println(icicle); |
| 164 | pw.print(prefix); pw.print("state="); pw.print(state); |
| 165 | pw.print(" stopped="); pw.print(stopped); |
Dianne Hackborn | 95fc68f | 2009-05-19 18:37:45 -0700 | [diff] [blame] | 166 | pw.print(" delayedResume="); pw.print(delayedResume); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 167 | pw.print(" finishing="); pw.println(finishing); |
| 168 | pw.print(prefix); pw.print("keysPaused="); pw.print(keysPaused); |
| 169 | pw.print(" inHistory="); pw.print(inHistory); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 170 | pw.print(" visible="); pw.print(visible); |
Dianne Hackborn | 4eba96b | 2011-01-21 13:34:36 -0800 | [diff] [blame] | 171 | pw.print(" sleeping="); pw.print(sleeping); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 172 | pw.print(" idle="); pw.println(idle); |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 173 | pw.print(prefix); pw.print("fullscreen="); pw.print(fullscreen); |
| 174 | pw.print(" noDisplay="); pw.print(noDisplay); |
| 175 | pw.print(" immersive="); pw.print(immersive); |
| 176 | pw.print(" launchMode="); pw.println(launchMode); |
Dianne Hackborn | 4eba96b | 2011-01-21 13:34:36 -0800 | [diff] [blame] | 177 | pw.print(prefix); pw.print("frozenBeforeDestroy="); pw.print(frozenBeforeDestroy); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 178 | pw.print(" thumbnailNeeded="); pw.print(thumbnailNeeded); |
| 179 | pw.print(" forceNewConfig="); pw.println(forceNewConfig); |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 180 | pw.print(prefix); pw.print("thumbHolder="); pw.println(thumbHolder); |
Dianne Hackborn | 0dad364 | 2010-09-09 21:25:35 -0700 | [diff] [blame] | 181 | if (launchTime != 0 || startTime != 0) { |
| 182 | pw.print(prefix); pw.print("launchTime="); |
| 183 | TimeUtils.formatDuration(launchTime, pw); pw.print(" startTime="); |
| 184 | TimeUtils.formatDuration(startTime, pw); pw.println(""); |
| 185 | } |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 186 | if (waitingVisible || nowVisible) { |
| 187 | pw.print(prefix); pw.print("waitingVisible="); pw.print(waitingVisible); |
| 188 | pw.print(" nowVisible="); pw.println(nowVisible); |
| 189 | } |
| 190 | if (configDestroy || configChangeFlags != 0) { |
| 191 | pw.print(prefix); pw.print("configDestroy="); pw.print(configDestroy); |
| 192 | pw.print(" configChangeFlags="); |
| 193 | pw.println(Integer.toHexString(configChangeFlags)); |
| 194 | } |
| 195 | if (connections != null) { |
| 196 | pw.print(prefix); pw.print("connections="); pw.println(connections); |
| 197 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 198 | } |
| 199 | |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 200 | ActivityRecord(ActivityManagerService _service, ActivityStack _stack, ProcessRecord _caller, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 201 | int _launchedFromUid, Intent _intent, String _resolvedType, |
| 202 | ActivityInfo aInfo, Configuration _configuration, |
Dianne Hackborn | 01e4cfc | 2010-06-24 15:07:24 -0700 | [diff] [blame] | 203 | ActivityRecord _resultTo, String _resultWho, int _reqCode, |
The Android Open Source Project | 4df2423 | 2009-03-05 14:34:35 -0800 | [diff] [blame] | 204 | boolean _componentSpecified) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 205 | service = _service; |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 206 | stack = _stack; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 207 | info = aInfo; |
| 208 | launchedFromUid = _launchedFromUid; |
| 209 | intent = _intent; |
| 210 | shortComponentName = _intent.getComponent().flattenToShortString(); |
| 211 | resolvedType = _resolvedType; |
The Android Open Source Project | 4df2423 | 2009-03-05 14:34:35 -0800 | [diff] [blame] | 212 | componentSpecified = _componentSpecified; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 213 | configuration = _configuration; |
| 214 | resultTo = _resultTo; |
| 215 | resultWho = _resultWho; |
| 216 | requestCode = _reqCode; |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 217 | state = ActivityState.INITIALIZING; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 218 | frontOfTask = false; |
| 219 | launchFailed = false; |
| 220 | haveState = false; |
| 221 | stopped = false; |
Dianne Hackborn | 95fc68f | 2009-05-19 18:37:45 -0700 | [diff] [blame] | 222 | delayedResume = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 223 | finishing = false; |
| 224 | configDestroy = false; |
| 225 | keysPaused = false; |
| 226 | inHistory = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 227 | visible = true; |
| 228 | waitingVisible = false; |
| 229 | nowVisible = false; |
| 230 | thumbnailNeeded = false; |
| 231 | idle = false; |
| 232 | hasBeenLaunched = false; |
| 233 | |
| 234 | if (aInfo != null) { |
| 235 | if (aInfo.targetActivity == null |
| 236 | || aInfo.launchMode == ActivityInfo.LAUNCH_MULTIPLE |
| 237 | || aInfo.launchMode == ActivityInfo.LAUNCH_SINGLE_TOP) { |
| 238 | realActivity = _intent.getComponent(); |
| 239 | } else { |
| 240 | realActivity = new ComponentName(aInfo.packageName, |
| 241 | aInfo.targetActivity); |
| 242 | } |
| 243 | taskAffinity = aInfo.taskAffinity; |
| 244 | stateNotNeeded = (aInfo.flags& |
| 245 | ActivityInfo.FLAG_STATE_NOT_NEEDED) != 0; |
| 246 | baseDir = aInfo.applicationInfo.sourceDir; |
| 247 | resDir = aInfo.applicationInfo.publicSourceDir; |
| 248 | dataDir = aInfo.applicationInfo.dataDir; |
| 249 | nonLocalizedLabel = aInfo.nonLocalizedLabel; |
| 250 | labelRes = aInfo.labelRes; |
| 251 | if (nonLocalizedLabel == null && labelRes == 0) { |
| 252 | ApplicationInfo app = aInfo.applicationInfo; |
| 253 | nonLocalizedLabel = app.nonLocalizedLabel; |
| 254 | labelRes = app.labelRes; |
| 255 | } |
| 256 | icon = aInfo.getIconResource(); |
| 257 | theme = aInfo.getThemeResource(); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 258 | realTheme = theme; |
| 259 | if (realTheme == 0) { |
| 260 | realTheme = aInfo.applicationInfo.targetSdkVersion |
| 261 | < Build.VERSION_CODES.HONEYCOMB |
| 262 | ? android.R.style.Theme |
| 263 | : android.R.style.Theme_Holo; |
| 264 | } |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 265 | if ((aInfo.flags&ActivityInfo.FLAG_HARDWARE_ACCELERATED) != 0) { |
| 266 | windowFlags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 267 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 268 | if ((aInfo.flags&ActivityInfo.FLAG_MULTIPROCESS) != 0 |
| 269 | && _caller != null |
| 270 | && (aInfo.applicationInfo.uid == Process.SYSTEM_UID |
| 271 | || aInfo.applicationInfo.uid == _caller.info.uid)) { |
| 272 | processName = _caller.processName; |
| 273 | } else { |
| 274 | processName = aInfo.processName; |
| 275 | } |
| 276 | |
| 277 | if (intent != null && (aInfo.flags & ActivityInfo.FLAG_EXCLUDE_FROM_RECENTS) != 0) { |
| 278 | intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); |
| 279 | } |
| 280 | |
| 281 | packageName = aInfo.applicationInfo.packageName; |
| 282 | launchMode = aInfo.launchMode; |
| 283 | |
| 284 | AttributeCache.Entry ent = AttributeCache.instance().get(packageName, |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 285 | realTheme, com.android.internal.R.styleable.Window); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 286 | fullscreen = ent != null && !ent.array.getBoolean( |
| 287 | com.android.internal.R.styleable.Window_windowIsFloating, false) |
| 288 | && !ent.array.getBoolean( |
| 289 | com.android.internal.R.styleable.Window_windowIsTranslucent, false); |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 290 | noDisplay = ent != null && ent.array.getBoolean( |
| 291 | com.android.internal.R.styleable.Window_windowNoDisplay, false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 292 | |
The Android Open Source Project | 4df2423 | 2009-03-05 14:34:35 -0800 | [diff] [blame] | 293 | if (!_componentSpecified || _launchedFromUid == Process.myUid() |
| 294 | || _launchedFromUid == 0) { |
| 295 | // If we know the system has determined the component, then |
| 296 | // we can consider this to be a home activity... |
| 297 | if (Intent.ACTION_MAIN.equals(_intent.getAction()) && |
| 298 | _intent.hasCategory(Intent.CATEGORY_HOME) && |
| 299 | _intent.getCategories().size() == 1 && |
| 300 | _intent.getData() == null && |
| 301 | _intent.getType() == null && |
| 302 | (intent.getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) != 0 && |
| 303 | !"android".equals(realActivity.getClassName())) { |
| 304 | // This sure looks like a home activity! |
| 305 | // Note the last check is so we don't count the resolver |
| 306 | // activity as being home... really, we don't care about |
| 307 | // doing anything special with something that comes from |
| 308 | // the core framework package. |
| 309 | isHomeActivity = true; |
| 310 | } else { |
| 311 | isHomeActivity = false; |
| 312 | } |
| 313 | } else { |
| 314 | isHomeActivity = false; |
| 315 | } |
Daniel Sandler | 69a4817 | 2010-06-23 16:29:36 -0400 | [diff] [blame] | 316 | |
| 317 | immersive = (aInfo.flags & ActivityInfo.FLAG_IMMERSIVE) != 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 318 | } else { |
| 319 | realActivity = null; |
| 320 | taskAffinity = null; |
| 321 | stateNotNeeded = false; |
| 322 | baseDir = null; |
| 323 | resDir = null; |
| 324 | dataDir = null; |
| 325 | processName = null; |
| 326 | packageName = null; |
| 327 | fullscreen = true; |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 328 | noDisplay = false; |
The Android Open Source Project | 4df2423 | 2009-03-05 14:34:35 -0800 | [diff] [blame] | 329 | isHomeActivity = false; |
Daniel Sandler | 69a4817 | 2010-06-23 16:29:36 -0400 | [diff] [blame] | 330 | immersive = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 331 | } |
| 332 | } |
| 333 | |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 334 | void setTask(TaskRecord newTask, ThumbnailHolder newThumbHolder, boolean isRoot) { |
| 335 | if (inHistory && !finishing) { |
| 336 | if (task != null) { |
| 337 | task.numActivities--; |
| 338 | } |
| 339 | if (newTask != null) { |
| 340 | newTask.numActivities++; |
| 341 | } |
| 342 | } |
| 343 | if (newThumbHolder == null) { |
| 344 | newThumbHolder = newTask; |
| 345 | } |
| 346 | task = newTask; |
| 347 | if (!isRoot && (intent.getFlags()&Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) != 0) { |
| 348 | // This is the start of a new sub-task. |
| 349 | if (thumbHolder == null) { |
| 350 | thumbHolder = new ThumbnailHolder(); |
| 351 | } |
| 352 | } else { |
| 353 | thumbHolder = newThumbHolder; |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | void putInHistory() { |
| 358 | if (!inHistory) { |
| 359 | inHistory = true; |
| 360 | if (task != null && !finishing) { |
| 361 | task.numActivities++; |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | void takeFromHistory() { |
| 367 | if (inHistory) { |
| 368 | inHistory = false; |
| 369 | if (task != null && !finishing) { |
| 370 | task.numActivities--; |
| 371 | } |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | boolean isInHistory() { |
| 376 | return inHistory; |
| 377 | } |
| 378 | |
Dianne Hackborn | 94cb2eb | 2011-01-13 21:09:44 -0800 | [diff] [blame] | 379 | void makeFinishing() { |
| 380 | if (!finishing) { |
| 381 | finishing = true; |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 382 | if (task != null && inHistory) { |
Dianne Hackborn | 94cb2eb | 2011-01-13 21:09:44 -0800 | [diff] [blame] | 383 | task.numActivities--; |
| 384 | } |
| 385 | } |
| 386 | } |
| 387 | |
Dianne Hackborn | 7e26964 | 2010-08-25 19:50:20 -0700 | [diff] [blame] | 388 | UriPermissionOwner getUriPermissionsLocked() { |
| 389 | if (uriPermissions == null) { |
| 390 | uriPermissions = new UriPermissionOwner(service, this); |
| 391 | } |
| 392 | return uriPermissions; |
| 393 | } |
| 394 | |
Dianne Hackborn | 01e4cfc | 2010-06-24 15:07:24 -0700 | [diff] [blame] | 395 | void addResultLocked(ActivityRecord from, String resultWho, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 396 | int requestCode, int resultCode, |
| 397 | Intent resultData) { |
| 398 | ActivityResult r = new ActivityResult(from, resultWho, |
| 399 | requestCode, resultCode, resultData); |
| 400 | if (results == null) { |
| 401 | results = new ArrayList(); |
| 402 | } |
| 403 | results.add(r); |
| 404 | } |
| 405 | |
Dianne Hackborn | 01e4cfc | 2010-06-24 15:07:24 -0700 | [diff] [blame] | 406 | void removeResultsLocked(ActivityRecord from, String resultWho, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 407 | int requestCode) { |
| 408 | if (results != null) { |
| 409 | for (int i=results.size()-1; i>=0; i--) { |
| 410 | ActivityResult r = (ActivityResult)results.get(i); |
| 411 | if (r.mFrom != from) continue; |
| 412 | if (r.mResultWho == null) { |
| 413 | if (resultWho != null) continue; |
| 414 | } else { |
| 415 | if (!r.mResultWho.equals(resultWho)) continue; |
| 416 | } |
| 417 | if (r.mRequestCode != requestCode) continue; |
| 418 | |
| 419 | results.remove(i); |
| 420 | } |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | void addNewIntentLocked(Intent intent) { |
| 425 | if (newIntents == null) { |
| 426 | newIntents = new ArrayList(); |
| 427 | } |
| 428 | newIntents.add(intent); |
| 429 | } |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 430 | |
| 431 | /** |
| 432 | * Deliver a new Intent to an existing activity, so that its onNewIntent() |
| 433 | * method will be called at the proper time. |
| 434 | */ |
Dianne Hackborn | 39792d2 | 2010-08-19 18:01:52 -0700 | [diff] [blame] | 435 | final void deliverNewIntentLocked(int callingUid, Intent intent) { |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 436 | boolean sent = false; |
| 437 | if (state == ActivityState.RESUMED |
| 438 | && app != null && app.thread != null) { |
| 439 | try { |
| 440 | ArrayList<Intent> ar = new ArrayList<Intent>(); |
Dianne Hackborn | 39792d2 | 2010-08-19 18:01:52 -0700 | [diff] [blame] | 441 | intent = new Intent(intent); |
| 442 | ar.add(intent); |
| 443 | service.grantUriPermissionFromIntentLocked(callingUid, packageName, |
Dianne Hackborn | 7e26964 | 2010-08-25 19:50:20 -0700 | [diff] [blame] | 444 | intent, getUriPermissionsLocked()); |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 445 | app.thread.scheduleNewIntent(ar, this); |
| 446 | sent = true; |
Dianne Hackborn | 39792d2 | 2010-08-19 18:01:52 -0700 | [diff] [blame] | 447 | } catch (RemoteException e) { |
| 448 | Slog.w(ActivityManagerService.TAG, |
| 449 | "Exception thrown sending new intent to " + this, e); |
| 450 | } catch (NullPointerException e) { |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 451 | Slog.w(ActivityManagerService.TAG, |
| 452 | "Exception thrown sending new intent to " + this, e); |
| 453 | } |
| 454 | } |
| 455 | if (!sent) { |
| 456 | addNewIntentLocked(new Intent(intent)); |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | void removeUriPermissionsLocked() { |
Dianne Hackborn | 7e26964 | 2010-08-25 19:50:20 -0700 | [diff] [blame] | 461 | if (uriPermissions != null) { |
| 462 | uriPermissions.removeUriPermissionsLocked(); |
| 463 | uriPermissions = null; |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 464 | } |
| 465 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 466 | |
| 467 | void pauseKeyDispatchingLocked() { |
| 468 | if (!keysPaused) { |
| 469 | keysPaused = true; |
| 470 | service.mWindowManager.pauseKeyDispatching(this); |
| 471 | } |
| 472 | } |
| 473 | |
| 474 | void resumeKeyDispatchingLocked() { |
| 475 | if (keysPaused) { |
| 476 | keysPaused = false; |
| 477 | service.mWindowManager.resumeKeyDispatching(this); |
| 478 | } |
| 479 | } |
| 480 | |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 481 | void updateThumbnail(Bitmap newThumbnail, CharSequence description) { |
| 482 | if ((intent.getFlags()&Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) != 0) { |
| 483 | // This is a logical break in the task; it repre |
| 484 | } |
| 485 | if (thumbHolder != null) { |
| 486 | if (newThumbnail != null) { |
| 487 | thumbHolder.lastThumbnail = newThumbnail; |
| 488 | } |
| 489 | thumbHolder.lastDescription = description; |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | void clearThumbnail() { |
| 494 | if (thumbHolder != null) { |
| 495 | thumbHolder.lastThumbnail = null; |
| 496 | thumbHolder.lastDescription = null; |
| 497 | } |
| 498 | } |
| 499 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 500 | // IApplicationToken |
| 501 | |
| 502 | public boolean mayFreezeScreenLocked(ProcessRecord app) { |
| 503 | // Only freeze the screen if this activity is currently attached to |
| 504 | // an application, and that application is not blocked or unresponding. |
| 505 | // In any other case, we can't count on getting the screen unfrozen, |
| 506 | // so it is best to leave as-is. |
Dianne Hackborn | 5f4d643 | 2010-12-21 20:40:11 -0800 | [diff] [blame] | 507 | return app != null && !app.crashing && !app.notResponding; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | public void startFreezingScreenLocked(ProcessRecord app, int configChanges) { |
| 511 | if (mayFreezeScreenLocked(app)) { |
| 512 | service.mWindowManager.startAppFreezingScreen(this, configChanges); |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | public void stopFreezingScreenLocked(boolean force) { |
| 517 | if (force || frozenBeforeDestroy) { |
| 518 | frozenBeforeDestroy = false; |
| 519 | service.mWindowManager.stopAppFreezingScreen(this, force); |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | public void windowsVisible() { |
| 524 | synchronized(service) { |
Dianne Hackborn | 0dad364 | 2010-09-09 21:25:35 -0700 | [diff] [blame] | 525 | if (launchTime != 0) { |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 526 | final long curTime = SystemClock.uptimeMillis(); |
Dianne Hackborn | 0dad364 | 2010-09-09 21:25:35 -0700 | [diff] [blame] | 527 | final long thisTime = curTime - launchTime; |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 528 | final long totalTime = stack.mInitialStartTime != 0 |
| 529 | ? (curTime - stack.mInitialStartTime) : thisTime; |
Dianne Hackborn | 6447ca3 | 2009-04-07 19:50:08 -0700 | [diff] [blame] | 530 | if (ActivityManagerService.SHOW_ACTIVITY_START_TIME) { |
Doug Zongker | 2bec3d4 | 2009-12-04 12:52:44 -0800 | [diff] [blame] | 531 | EventLog.writeEvent(EventLogTags.ACTIVITY_LAUNCH_TIME, |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 532 | System.identityHashCode(this), shortComponentName, |
| 533 | thisTime, totalTime); |
| 534 | StringBuilder sb = service.mStringBuilder; |
| 535 | sb.setLength(0); |
Dianne Hackborn | 0dad364 | 2010-09-09 21:25:35 -0700 | [diff] [blame] | 536 | sb.append("Displayed "); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 537 | sb.append(shortComponentName); |
| 538 | sb.append(": "); |
Dianne Hackborn | 0dad364 | 2010-09-09 21:25:35 -0700 | [diff] [blame] | 539 | TimeUtils.formatDuration(thisTime, sb); |
Dianne Hackborn | cef65ee | 2010-09-30 18:27:22 -0700 | [diff] [blame] | 540 | if (thisTime != totalTime) { |
| 541 | sb.append(" (total "); |
| 542 | TimeUtils.formatDuration(totalTime, sb); |
| 543 | sb.append(")"); |
| 544 | } |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 545 | Log.i(ActivityManagerService.TAG, sb.toString()); |
Dianne Hackborn | 6447ca3 | 2009-04-07 19:50:08 -0700 | [diff] [blame] | 546 | } |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 547 | stack.reportActivityLaunchedLocked(false, this, thisTime, totalTime); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 548 | if (totalTime > 0) { |
| 549 | service.mUsageStatsService.noteLaunchTime(realActivity, (int)totalTime); |
Dianne Hackborn | 6447ca3 | 2009-04-07 19:50:08 -0700 | [diff] [blame] | 550 | } |
Dianne Hackborn | 0dad364 | 2010-09-09 21:25:35 -0700 | [diff] [blame] | 551 | launchTime = 0; |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 552 | stack.mInitialStartTime = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 553 | } |
Dianne Hackborn | 0dad364 | 2010-09-09 21:25:35 -0700 | [diff] [blame] | 554 | startTime = 0; |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 555 | stack.reportActivityVisibleLocked(this); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 556 | if (ActivityManagerService.DEBUG_SWITCH) Log.v( |
| 557 | ActivityManagerService.TAG, "windowsVisible(): " + this); |
| 558 | if (!nowVisible) { |
| 559 | nowVisible = true; |
| 560 | if (!idle) { |
| 561 | // Instead of doing the full stop routine here, let's just |
| 562 | // hide any activities we now can, and let them stop when |
| 563 | // the normal idle happens. |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 564 | stack.processStoppingActivitiesLocked(false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 565 | } else { |
| 566 | // If this activity was already idle, then we now need to |
| 567 | // make sure we perform the full stop of any activities |
| 568 | // that are waiting to do so. This is because we won't |
| 569 | // do that while they are still waiting for this one to |
| 570 | // become visible. |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 571 | final int N = stack.mWaitingVisibleActivities.size(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 572 | if (N > 0) { |
| 573 | for (int i=0; i<N; i++) { |
Dianne Hackborn | 01e4cfc | 2010-06-24 15:07:24 -0700 | [diff] [blame] | 574 | ActivityRecord r = (ActivityRecord) |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 575 | stack.mWaitingVisibleActivities.get(i); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 576 | r.waitingVisible = false; |
| 577 | if (ActivityManagerService.DEBUG_SWITCH) Log.v( |
| 578 | ActivityManagerService.TAG, |
| 579 | "Was waiting for visible: " + r); |
| 580 | } |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 581 | stack.mWaitingVisibleActivities.clear(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 582 | Message msg = Message.obtain(); |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 583 | msg.what = ActivityStack.IDLE_NOW_MSG; |
| 584 | stack.mHandler.sendMessage(msg); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 585 | } |
| 586 | } |
| 587 | service.scheduleAppGcsLocked(); |
| 588 | } |
| 589 | } |
| 590 | } |
| 591 | |
| 592 | public void windowsGone() { |
| 593 | if (ActivityManagerService.DEBUG_SWITCH) Log.v( |
| 594 | ActivityManagerService.TAG, "windowsGone(): " + this); |
| 595 | nowVisible = false; |
| 596 | } |
| 597 | |
Dianne Hackborn | 01e4cfc | 2010-06-24 15:07:24 -0700 | [diff] [blame] | 598 | private ActivityRecord getWaitingHistoryRecordLocked() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 599 | // First find the real culprit... if we are waiting |
| 600 | // for another app to start, then we have paused dispatching |
| 601 | // for this activity. |
Dianne Hackborn | 01e4cfc | 2010-06-24 15:07:24 -0700 | [diff] [blame] | 602 | ActivityRecord r = this; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 603 | if (r.waitingVisible) { |
| 604 | // Hmmm, who might we be waiting for? |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 605 | r = stack.mResumedActivity; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 606 | if (r == null) { |
Dianne Hackborn | 50dc3bc | 2010-06-25 10:05:59 -0700 | [diff] [blame] | 607 | r = stack.mPausingActivity; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 608 | } |
| 609 | // Both of those null? Fall back to 'this' again |
| 610 | if (r == null) { |
| 611 | r = this; |
| 612 | } |
| 613 | } |
| 614 | |
| 615 | return r; |
| 616 | } |
| 617 | |
| 618 | public boolean keyDispatchingTimedOut() { |
Dianne Hackborn | 01e4cfc | 2010-06-24 15:07:24 -0700 | [diff] [blame] | 619 | ActivityRecord r; |
Dianne Hackborn | ad5499d | 2010-03-29 18:08:45 -0700 | [diff] [blame] | 620 | ProcessRecord anrApp = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 621 | synchronized(service) { |
Dianne Hackborn | ad5499d | 2010-03-29 18:08:45 -0700 | [diff] [blame] | 622 | r = getWaitingHistoryRecordLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 623 | if (r != null && r.app != null) { |
| 624 | if (r.app.debugging) { |
| 625 | return false; |
| 626 | } |
| 627 | |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 628 | if (service.mDidDexOpt) { |
| 629 | // Give more time since we were dexopting. |
| 630 | service.mDidDexOpt = false; |
| 631 | return false; |
| 632 | } |
| 633 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 634 | if (r.app.instrumentationClass == null) { |
Dianne Hackborn | ad5499d | 2010-03-29 18:08:45 -0700 | [diff] [blame] | 635 | anrApp = r.app; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 636 | } else { |
| 637 | Bundle info = new Bundle(); |
| 638 | info.putString("shortMsg", "keyDispatchingTimedOut"); |
| 639 | info.putString("longMsg", "Timed out while dispatching key event"); |
| 640 | service.finishInstrumentationLocked( |
| 641 | r.app, Activity.RESULT_CANCELED, info); |
| 642 | } |
| 643 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 644 | } |
Dianne Hackborn | ad5499d | 2010-03-29 18:08:45 -0700 | [diff] [blame] | 645 | |
| 646 | if (anrApp != null) { |
| 647 | service.appNotResponding(anrApp, r, this, |
| 648 | "keyDispatchingTimedOut"); |
| 649 | } |
| 650 | |
| 651 | return true; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 652 | } |
| 653 | |
| 654 | /** Returns the key dispatching timeout for this application token. */ |
| 655 | public long getKeyDispatchingTimeout() { |
| 656 | synchronized(service) { |
Dianne Hackborn | 01e4cfc | 2010-06-24 15:07:24 -0700 | [diff] [blame] | 657 | ActivityRecord r = getWaitingHistoryRecordLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 658 | if (r == null || r.app == null |
| 659 | || r.app.instrumentationClass == null) { |
| 660 | return ActivityManagerService.KEY_DISPATCHING_TIMEOUT; |
| 661 | } |
| 662 | |
| 663 | return ActivityManagerService.INSTRUMENTATION_KEY_DISPATCHING_TIMEOUT; |
| 664 | } |
| 665 | } |
| 666 | |
| 667 | /** |
| 668 | * This method will return true if the activity is either visible, is becoming visible, is |
| 669 | * currently pausing, or is resumed. |
| 670 | */ |
| 671 | public boolean isInterestingToUserLocked() { |
| 672 | return visible || nowVisible || state == ActivityState.PAUSING || |
| 673 | state == ActivityState.RESUMED; |
Dianne Hackborn | 4eba96b | 2011-01-21 13:34:36 -0800 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | public void setSleeping(boolean _sleeping) { |
| 677 | if (sleeping == _sleeping) { |
| 678 | return; |
| 679 | } |
| 680 | if (app != null && app.thread != null) { |
| 681 | try { |
| 682 | app.thread.scheduleSleeping(this, _sleeping); |
| 683 | if (sleeping && !stack.mGoingToSleepActivities.contains(this)) { |
| 684 | stack.mGoingToSleepActivities.add(this); |
| 685 | } |
| 686 | sleeping = _sleeping; |
| 687 | } catch (RemoteException e) { |
| 688 | Slog.w(ActivityStack.TAG, "Exception thrown when sleeping: " |
| 689 | + intent.getComponent(), e); |
| 690 | } |
| 691 | } |
| 692 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 693 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 694 | public String toString() { |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 695 | if (stringName != null) { |
| 696 | return stringName; |
| 697 | } |
| 698 | StringBuilder sb = new StringBuilder(128); |
Dianne Hackborn | 30d7189 | 2010-12-11 10:37:55 -0800 | [diff] [blame] | 699 | sb.append("ActivityRecord{"); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 700 | sb.append(Integer.toHexString(System.identityHashCode(this))); |
| 701 | sb.append(' '); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 702 | sb.append(intent.getComponent().flattenToShortString()); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 703 | sb.append('}'); |
| 704 | return stringName = sb.toString(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 705 | } |
| 706 | } |