Loading services/java/com/android/server/am/ActiveServices.java +6 −2 Original line number Diff line number Diff line Loading @@ -1551,8 +1551,12 @@ public class ActiveServices { } } } else { HashMap<ComponentName, ServiceRecord> items = mServiceMap.mServicesByNamePerUser.get(userId); if (items != null) { didSomething = collectForceStopServicesLocked(name, userId, evenPersistent, doit, mServiceMap.mServicesByNamePerUser.get(userId), services); doit, items, services); } } int N = services.size(); Loading services/java/com/android/server/am/ActivityManagerService.java +13 −11 Original line number Diff line number Diff line Loading @@ -546,7 +546,7 @@ public final class ActivityManagerService extends ActivityManagerNative */ final ArrayList mCancelledThumbnails = new ArrayList(); final ProviderMap mProviderMap = new ProviderMap(); final ProviderMap mProviderMap; /** * List of content providers who have clients waiting for them. The Loading Loading @@ -1511,6 +1511,7 @@ public final class ActivityManagerService extends ActivityManagerNative mBroadcastQueues[1] = mBgBroadcastQueue; mServices = new ActiveServices(this); mProviderMap = new ProviderMap(this); File dataDir = Environment.getDataDirectory(); File systemDir = new File(dataDir, "system"); Loading Loading @@ -2680,7 +2681,7 @@ public final class ActivityManagerService extends ActivityManagerNative } final long origId = Binder.clearCallingIdentity(); boolean res = mMainStack.requestFinishActivityLocked(token, resultCode, resultData, "app-request"); resultData, "app-request", true); Binder.restoreCallingIdentity(origId); return res; } Loading Loading @@ -2710,7 +2711,7 @@ public final class ActivityManagerService extends ActivityManagerNative int index = mMainStack.indexOfTokenLocked(r.appToken); if (index >= 0) { mMainStack.finishActivityLocked(r, index, Activity.RESULT_CANCELED, null, "finish-heavy"); null, "finish-heavy", true); } } } Loading Loading @@ -3627,7 +3628,7 @@ public final class ActivityManagerService extends ActivityManagerNative ActivityRecord r = (ActivityRecord)mMainStack.mHistory.get(i); if ((r.info.flags&ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS) != 0) { r.stack.finishActivityLocked(r, i, Activity.RESULT_CANCELED, null, "close-sys"); Activity.RESULT_CANCELED, null, "close-sys", true); } } Loading Loading @@ -6972,7 +6973,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (count > 1) { final long origId = Binder.clearCallingIdentity(); mMainStack.finishActivityLocked((ActivityRecord)mMainStack.mHistory.get(count-1), count-1, Activity.RESULT_CANCELED, null, "unhandled-back"); count-1, Activity.RESULT_CANCELED, null, "unhandled-back", true); Binder.restoreCallingIdentity(origId); } } Loading Loading @@ -7891,7 +7892,8 @@ public final class ActivityManagerService extends ActivityManagerNative if (r.app == app) { Slog.w(TAG, " Force finishing activity " + r.intent.getComponent().flattenToShortString()); r.stack.finishActivityLocked(r, i, Activity.RESULT_CANCELED, null, "crashed"); r.stack.finishActivityLocked(r, i, Activity.RESULT_CANCELED, null, "crashed", false); } } if (!app.persistent) { Loading Loading @@ -7926,7 +7928,7 @@ public final class ActivityManagerService extends ActivityManagerNative + r.intent.getComponent().flattenToShortString()); int index = mMainStack.indexOfActivityLocked(r); r.stack.finishActivityLocked(r, index, Activity.RESULT_CANCELED, null, "crashed"); Activity.RESULT_CANCELED, null, "crashed", false); // Also terminate any activities below it that aren't yet // stopped, to avoid a situation where one will get // re-start our crashing activity once it gets resumed again. Loading @@ -7940,7 +7942,7 @@ public final class ActivityManagerService extends ActivityManagerNative Slog.w(TAG, " Force finishing activity " + r.intent.getComponent().flattenToShortString()); r.stack.finishActivityLocked(r, index, Activity.RESULT_CANCELED, null, "crashed"); Activity.RESULT_CANCELED, null, "crashed", false); } } } Loading Loading @@ -12305,7 +12307,7 @@ public final class ActivityManagerService extends ActivityManagerNative for (int i = start; i > finishTo; i--) { ActivityRecord r = history.get(i); mMainStack.requestFinishActivityLocked(r.appToken, resultCode, resultData, "navigate-up"); "navigate-up", true); // Only return the supplied result for the first activity finished resultCode = Activity.RESULT_CANCELED; resultData = null; Loading @@ -12331,7 +12333,7 @@ public final class ActivityManagerService extends ActivityManagerNative foundParentInTask = false; } mMainStack.requestFinishActivityLocked(parent.appToken, resultCode, resultData, "navigate-up"); resultData, "navigate-up", true); } } Binder.restoreCallingIdentity(origId); Loading services/java/com/android/server/am/ActivityRecord.java +5 −1 Original line number Diff line number Diff line Loading @@ -333,7 +333,6 @@ final class ActivityRecord { state = ActivityState.INITIALIZING; frontOfTask = false; launchFailed = false; haveState = false; stopped = false; delayedResume = false; finishing = false; Loading @@ -347,6 +346,11 @@ final class ActivityRecord { idle = false; hasBeenLaunched = false; // This starts out true, since the initial state of an activity // is that we have everything, and we shouldn't never consider it // lacking in state to be removed if it dies. haveState = true; if (aInfo != null) { if (aInfo.targetActivity == null || aInfo.launchMode == ActivityInfo.LAUNCH_MULTIPLE Loading services/java/com/android/server/am/ActivityStack.java +35 −30 Original line number Diff line number Diff line Loading @@ -725,7 +725,7 @@ final class ActivityStack { + ", giving up", e); mService.appDiedLocked(app, app.pid, app.thread); requestFinishActivityLocked(r.appToken, Activity.RESULT_CANCELED, null, "2nd-crash"); "2nd-crash", false); return false; } Loading Loading @@ -1092,7 +1092,7 @@ final class ActivityStack { if (prev != null) { if (prev.finishing) { if (DEBUG_PAUSE) Slog.v(TAG, "Executing finish of activity: " + prev); prev = finishCurrentActivityLocked(prev, FINISH_AFTER_VISIBLE); prev = finishCurrentActivityLocked(prev, FINISH_AFTER_VISIBLE, false); } else if (prev.app != null) { if (DEBUG_PAUSE) Slog.v(TAG, "Enqueueing pending stop: " + prev); if (prev.waitingVisible) { Loading Loading @@ -1504,7 +1504,7 @@ final class ActivityStack { Slog.d(TAG, "no-history finish of " + last + " on new resume"); } requestFinishActivityLocked(last.appToken, Activity.RESULT_CANCELED, null, "no-history"); "no-history", false); } } Loading Loading @@ -1726,7 +1726,7 @@ final class ActivityStack { // activity and try the next one. Slog.w(TAG, "Exception thrown during resume of " + next, e); requestFinishActivityLocked(next.appToken, Activity.RESULT_CANCELED, null, "resume-exception"); "resume-exception", true); return true; } Loading Loading @@ -2080,7 +2080,7 @@ final class ActivityStack { continue; } if (finishActivityLocked(p, srcPos, Activity.RESULT_CANCELED, null, "reset")) { Activity.RESULT_CANCELED, null, "reset", false)) { replyChainEnd--; srcPos--; } Loading Loading @@ -2143,7 +2143,7 @@ final class ActivityStack { continue; } if (finishActivityLocked(p, srcPos, Activity.RESULT_CANCELED, null, "reset")) { Activity.RESULT_CANCELED, null, "reset", false)) { taskTopI--; lastReparentPos--; replyChainEnd--; Loading Loading @@ -2200,7 +2200,7 @@ final class ActivityStack { } if (p.intent.getComponent().equals(target.intent.getComponent())) { if (finishActivityLocked(p, j, Activity.RESULT_CANCELED, null, "replace")) { Activity.RESULT_CANCELED, null, "replace", false)) { taskTopI--; lastReparentPos--; } Loading Loading @@ -2270,7 +2270,7 @@ final class ActivityStack { continue; } if (finishActivityLocked(r, i, Activity.RESULT_CANCELED, null, "clear")) { null, "clear", false)) { i--; } } Loading @@ -2284,7 +2284,7 @@ final class ActivityStack { int index = indexOfTokenLocked(ret.appToken); if (index >= 0) { finishActivityLocked(ret, index, Activity.RESULT_CANCELED, null, "clear"); null, "clear", false); } return null; } Loading Loading @@ -2313,7 +2313,7 @@ final class ActivityStack { continue; } if (!finishActivityLocked(r, i, Activity.RESULT_CANCELED, null, "clear")) { null, "clear", false)) { i++; } } Loading Loading @@ -2579,6 +2579,7 @@ final class ActivityStack { mDismissKeyguardOnNextActivity = false; mService.mWindowManager.dismissKeyguard(); } Slog.i(TAG, "DONE STARTING!"); return err; } Loading Loading @@ -3319,7 +3320,7 @@ final class ActivityStack { Slog.d(TAG, "no-history finish of " + r); } requestFinishActivityLocked(r.appToken, Activity.RESULT_CANCELED, null, "no-history"); "no-history", false); } else { if (DEBUG_STATES) Slog.d(TAG, "Not finishing noHistory " + r + " on stop because we're just sleeping"); Loading Loading @@ -3531,7 +3532,7 @@ final class ActivityStack { ActivityRecord r = (ActivityRecord)stops.get(i); synchronized (mService) { if (r.finishing) { finishCurrentActivityLocked(r, FINISH_IMMEDIATELY); finishCurrentActivityLocked(r, FINISH_IMMEDIATELY, false); } else { stopActivityLocked(r); } Loading Loading @@ -3585,7 +3586,7 @@ final class ActivityStack { * some reason it is being left as-is. */ final boolean requestFinishActivityLocked(IBinder token, int resultCode, Intent resultData, String reason) { Intent resultData, String reason, boolean oomAdj) { int index = indexOfTokenLocked(token); if (DEBUG_RESULTS || DEBUG_STATES) Slog.v( TAG, "Finishing activity @" + index + ": token=" + token Loading @@ -3596,7 +3597,7 @@ final class ActivityStack { } ActivityRecord r = mHistory.get(index); finishActivityLocked(r, index, resultCode, resultData, reason); finishActivityLocked(r, index, resultCode, resultData, reason, oomAdj); return true; } Loading @@ -3613,10 +3614,11 @@ final class ActivityStack { if ((r.resultWho == null && resultWho == null) || (r.resultWho != null && r.resultWho.equals(resultWho))) { finishActivityLocked(r, i, Activity.RESULT_CANCELED, null, "request-sub"); Activity.RESULT_CANCELED, null, "request-sub", false); } } } mService.updateOomAdjLocked(); } final boolean finishActivityAffinityLocked(IBinder token) { Loading @@ -3639,7 +3641,8 @@ final class ActivityStack { if (cur.taskAffinity != null && !cur.taskAffinity.equals(r.taskAffinity)) { break; } finishActivityLocked(cur, index, Activity.RESULT_CANCELED, null, "request-affinity"); finishActivityLocked(cur, index, Activity.RESULT_CANCELED, null, "request-affinity", true); index--; } return true; Loading Loading @@ -3677,16 +3680,16 @@ final class ActivityStack { * list, or false if it is still in the list and will be removed later. */ final boolean finishActivityLocked(ActivityRecord r, int index, int resultCode, Intent resultData, String reason) { return finishActivityLocked(r, index, resultCode, resultData, reason, false); int resultCode, Intent resultData, String reason, boolean oomAdj) { return finishActivityLocked(r, index, resultCode, resultData, reason, false, oomAdj); } /** * @return Returns true if this activity has been removed from the history * list, or false if it is still in the list and will be removed later. */ final boolean finishActivityLocked(ActivityRecord r, int index, int resultCode, Intent resultData, String reason, boolean immediate) { final boolean finishActivityLocked(ActivityRecord r, int index, int resultCode, Intent resultData, String reason, boolean immediate, boolean oomAdj) { if (r.finishing) { Slog.w(TAG, "Duplicate finish request for " + r); return false; Loading Loading @@ -3730,7 +3733,7 @@ final class ActivityStack { if (immediate) { return finishCurrentActivityLocked(r, index, FINISH_IMMEDIATELY) == null; FINISH_IMMEDIATELY, oomAdj) == null; } else if (mResumedActivity == r) { boolean endTask = index <= 0 || (mHistory.get(index-1)).task != r.task; Loading @@ -3754,7 +3757,7 @@ final class ActivityStack { // it is done pausing; else we can just directly finish it here. if (DEBUG_PAUSE) Slog.v(TAG, "Finish not pausing: " + r); return finishCurrentActivityLocked(r, index, FINISH_AFTER_PAUSE) == null; FINISH_AFTER_PAUSE, oomAdj) == null; } else { if (DEBUG_PAUSE) Slog.v(TAG, "Finish waiting for pause of: " + r); } Loading @@ -3767,17 +3770,17 @@ final class ActivityStack { private static final int FINISH_AFTER_VISIBLE = 2; private final ActivityRecord finishCurrentActivityLocked(ActivityRecord r, int mode) { int mode, boolean oomAdj) { final int index = indexOfActivityLocked(r); if (index < 0) { return null; } return finishCurrentActivityLocked(r, index, mode); return finishCurrentActivityLocked(r, index, mode, oomAdj); } private final ActivityRecord finishCurrentActivityLocked(ActivityRecord r, int index, int mode) { int index, int mode, boolean oomAdj) { // First things first: if this activity is currently visible, // and the resumed activity is not yet visible, then hold off on // finishing until the resumed one becomes visible. Loading @@ -3796,7 +3799,9 @@ final class ActivityStack { if (DEBUG_STATES) Slog.v(TAG, "Moving to STOPPING: " + r + " (finish requested)"); r.state = ActivityState.STOPPING; if (oomAdj) { mService.updateOomAdjLocked(); } return r; } Loading @@ -3816,7 +3821,8 @@ final class ActivityStack { || prevState == ActivityState.INITIALIZING) { // If this activity is already stopped, we can just finish // it right now. boolean activityRemoved = destroyActivityLocked(r, true, true, "finish-imm"); boolean activityRemoved = destroyActivityLocked(r, true, oomAdj, "finish-imm"); if (activityRemoved) { resumeTopActivityLocked(null); } Loading Loading @@ -4008,9 +4014,8 @@ final class ActivityStack { ActivityManagerService.CANCEL_HEAVY_NOTIFICATION_MSG); } if (r.app.activities.size() == 0) { // No longer have activities, so update location in // LRU list. mService.updateLruProcessLocked(r.app, oomAdj, false); // No longer have activities, so update oom adj. mService.updateOomAdjLocked(); } } Loading services/java/com/android/server/am/ProviderMap.java +35 −25 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.server.am; import android.content.ComponentName; import android.os.Binder; import android.os.Process; import android.os.RemoteException; import android.os.UserHandle; import android.util.Slog; Loading @@ -31,8 +30,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Set; /** * Keeps track of content providers by authority (name) and class. It separates the mapping by Loading @@ -44,6 +41,8 @@ public class ProviderMap { private static final boolean DBG = false; private final ActivityManagerService mAm; private final HashMap<String, ContentProviderRecord> mSingletonByName = new HashMap<String, ContentProviderRecord>(); private final HashMap<ComponentName, ContentProviderRecord> mSingletonByClass Loading @@ -54,6 +53,10 @@ public class ProviderMap { private final SparseArray<HashMap<ComponentName, ContentProviderRecord>> mProvidersByClassPerUser = new SparseArray<HashMap<ComponentName, ContentProviderRecord>>(); ProviderMap(ActivityManagerService am) { mAm = am; } ContentProviderRecord getProviderByName(String name) { return getProviderByName(name, -1); } Loading Loading @@ -217,8 +220,12 @@ public class ProviderMap { } } } else { didSomething |= collectForceStopProvidersLocked(name, appId, doit, evenPersistent, userId, getProvidersByClass(userId), result); HashMap<ComponentName, ContentProviderRecord> items = getProvidersByClass(userId); if (items != null) { didSomething |= collectForceStopProvidersLocked(name, appId, doit, evenPersistent, userId, items, result); } } return didSomething; } Loading Loading @@ -279,14 +286,17 @@ public class ProviderMap { protected boolean dumpProvider(FileDescriptor fd, PrintWriter pw, String name, String[] args, int opti, boolean dumpAll) { ArrayList<ContentProviderRecord> allProviders = new ArrayList<ContentProviderRecord>(); ArrayList<ContentProviderRecord> providers = new ArrayList<ContentProviderRecord>(); if ("all".equals(name)) { synchronized (this) { for (ContentProviderRecord r1 : getProvidersByClass(-1).values()) { providers.add(r1); } synchronized (mAm) { allProviders.addAll(mSingletonByClass.values()); for (int i=0; i<mProvidersByClassPerUser.size(); i++) { allProviders.addAll(mProvidersByClassPerUser.valueAt(i).values()); } if ("all".equals(name)) { providers.addAll(allProviders); } else { ComponentName componentName = name != null ? ComponentName.unflattenFromString(name) : null; Loading @@ -301,8 +311,8 @@ public class ProviderMap { } } synchronized (this) { for (ContentProviderRecord r1 : getProvidersByClass(-1).values()) { for (int i=0; i<allProviders.size(); i++) { ContentProviderRecord r1 = allProviders.get(i); if (componentName != null) { if (r1.name.equals(componentName)) { providers.add(r1); Loading Loading @@ -340,7 +350,7 @@ public class ProviderMap { private void dumpProvider(String prefix, FileDescriptor fd, PrintWriter pw, final ContentProviderRecord r, String[] args, boolean dumpAll) { String innerPrefix = prefix + " "; synchronized (this) { synchronized (mAm) { pw.print(prefix); pw.print("PROVIDER "); pw.print(r); pw.print(" pid="); Loading Loading
services/java/com/android/server/am/ActiveServices.java +6 −2 Original line number Diff line number Diff line Loading @@ -1551,8 +1551,12 @@ public class ActiveServices { } } } else { HashMap<ComponentName, ServiceRecord> items = mServiceMap.mServicesByNamePerUser.get(userId); if (items != null) { didSomething = collectForceStopServicesLocked(name, userId, evenPersistent, doit, mServiceMap.mServicesByNamePerUser.get(userId), services); doit, items, services); } } int N = services.size(); Loading
services/java/com/android/server/am/ActivityManagerService.java +13 −11 Original line number Diff line number Diff line Loading @@ -546,7 +546,7 @@ public final class ActivityManagerService extends ActivityManagerNative */ final ArrayList mCancelledThumbnails = new ArrayList(); final ProviderMap mProviderMap = new ProviderMap(); final ProviderMap mProviderMap; /** * List of content providers who have clients waiting for them. The Loading Loading @@ -1511,6 +1511,7 @@ public final class ActivityManagerService extends ActivityManagerNative mBroadcastQueues[1] = mBgBroadcastQueue; mServices = new ActiveServices(this); mProviderMap = new ProviderMap(this); File dataDir = Environment.getDataDirectory(); File systemDir = new File(dataDir, "system"); Loading Loading @@ -2680,7 +2681,7 @@ public final class ActivityManagerService extends ActivityManagerNative } final long origId = Binder.clearCallingIdentity(); boolean res = mMainStack.requestFinishActivityLocked(token, resultCode, resultData, "app-request"); resultData, "app-request", true); Binder.restoreCallingIdentity(origId); return res; } Loading Loading @@ -2710,7 +2711,7 @@ public final class ActivityManagerService extends ActivityManagerNative int index = mMainStack.indexOfTokenLocked(r.appToken); if (index >= 0) { mMainStack.finishActivityLocked(r, index, Activity.RESULT_CANCELED, null, "finish-heavy"); null, "finish-heavy", true); } } } Loading Loading @@ -3627,7 +3628,7 @@ public final class ActivityManagerService extends ActivityManagerNative ActivityRecord r = (ActivityRecord)mMainStack.mHistory.get(i); if ((r.info.flags&ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS) != 0) { r.stack.finishActivityLocked(r, i, Activity.RESULT_CANCELED, null, "close-sys"); Activity.RESULT_CANCELED, null, "close-sys", true); } } Loading Loading @@ -6972,7 +6973,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (count > 1) { final long origId = Binder.clearCallingIdentity(); mMainStack.finishActivityLocked((ActivityRecord)mMainStack.mHistory.get(count-1), count-1, Activity.RESULT_CANCELED, null, "unhandled-back"); count-1, Activity.RESULT_CANCELED, null, "unhandled-back", true); Binder.restoreCallingIdentity(origId); } } Loading Loading @@ -7891,7 +7892,8 @@ public final class ActivityManagerService extends ActivityManagerNative if (r.app == app) { Slog.w(TAG, " Force finishing activity " + r.intent.getComponent().flattenToShortString()); r.stack.finishActivityLocked(r, i, Activity.RESULT_CANCELED, null, "crashed"); r.stack.finishActivityLocked(r, i, Activity.RESULT_CANCELED, null, "crashed", false); } } if (!app.persistent) { Loading Loading @@ -7926,7 +7928,7 @@ public final class ActivityManagerService extends ActivityManagerNative + r.intent.getComponent().flattenToShortString()); int index = mMainStack.indexOfActivityLocked(r); r.stack.finishActivityLocked(r, index, Activity.RESULT_CANCELED, null, "crashed"); Activity.RESULT_CANCELED, null, "crashed", false); // Also terminate any activities below it that aren't yet // stopped, to avoid a situation where one will get // re-start our crashing activity once it gets resumed again. Loading @@ -7940,7 +7942,7 @@ public final class ActivityManagerService extends ActivityManagerNative Slog.w(TAG, " Force finishing activity " + r.intent.getComponent().flattenToShortString()); r.stack.finishActivityLocked(r, index, Activity.RESULT_CANCELED, null, "crashed"); Activity.RESULT_CANCELED, null, "crashed", false); } } } Loading Loading @@ -12305,7 +12307,7 @@ public final class ActivityManagerService extends ActivityManagerNative for (int i = start; i > finishTo; i--) { ActivityRecord r = history.get(i); mMainStack.requestFinishActivityLocked(r.appToken, resultCode, resultData, "navigate-up"); "navigate-up", true); // Only return the supplied result for the first activity finished resultCode = Activity.RESULT_CANCELED; resultData = null; Loading @@ -12331,7 +12333,7 @@ public final class ActivityManagerService extends ActivityManagerNative foundParentInTask = false; } mMainStack.requestFinishActivityLocked(parent.appToken, resultCode, resultData, "navigate-up"); resultData, "navigate-up", true); } } Binder.restoreCallingIdentity(origId); Loading
services/java/com/android/server/am/ActivityRecord.java +5 −1 Original line number Diff line number Diff line Loading @@ -333,7 +333,6 @@ final class ActivityRecord { state = ActivityState.INITIALIZING; frontOfTask = false; launchFailed = false; haveState = false; stopped = false; delayedResume = false; finishing = false; Loading @@ -347,6 +346,11 @@ final class ActivityRecord { idle = false; hasBeenLaunched = false; // This starts out true, since the initial state of an activity // is that we have everything, and we shouldn't never consider it // lacking in state to be removed if it dies. haveState = true; if (aInfo != null) { if (aInfo.targetActivity == null || aInfo.launchMode == ActivityInfo.LAUNCH_MULTIPLE Loading
services/java/com/android/server/am/ActivityStack.java +35 −30 Original line number Diff line number Diff line Loading @@ -725,7 +725,7 @@ final class ActivityStack { + ", giving up", e); mService.appDiedLocked(app, app.pid, app.thread); requestFinishActivityLocked(r.appToken, Activity.RESULT_CANCELED, null, "2nd-crash"); "2nd-crash", false); return false; } Loading Loading @@ -1092,7 +1092,7 @@ final class ActivityStack { if (prev != null) { if (prev.finishing) { if (DEBUG_PAUSE) Slog.v(TAG, "Executing finish of activity: " + prev); prev = finishCurrentActivityLocked(prev, FINISH_AFTER_VISIBLE); prev = finishCurrentActivityLocked(prev, FINISH_AFTER_VISIBLE, false); } else if (prev.app != null) { if (DEBUG_PAUSE) Slog.v(TAG, "Enqueueing pending stop: " + prev); if (prev.waitingVisible) { Loading Loading @@ -1504,7 +1504,7 @@ final class ActivityStack { Slog.d(TAG, "no-history finish of " + last + " on new resume"); } requestFinishActivityLocked(last.appToken, Activity.RESULT_CANCELED, null, "no-history"); "no-history", false); } } Loading Loading @@ -1726,7 +1726,7 @@ final class ActivityStack { // activity and try the next one. Slog.w(TAG, "Exception thrown during resume of " + next, e); requestFinishActivityLocked(next.appToken, Activity.RESULT_CANCELED, null, "resume-exception"); "resume-exception", true); return true; } Loading Loading @@ -2080,7 +2080,7 @@ final class ActivityStack { continue; } if (finishActivityLocked(p, srcPos, Activity.RESULT_CANCELED, null, "reset")) { Activity.RESULT_CANCELED, null, "reset", false)) { replyChainEnd--; srcPos--; } Loading Loading @@ -2143,7 +2143,7 @@ final class ActivityStack { continue; } if (finishActivityLocked(p, srcPos, Activity.RESULT_CANCELED, null, "reset")) { Activity.RESULT_CANCELED, null, "reset", false)) { taskTopI--; lastReparentPos--; replyChainEnd--; Loading Loading @@ -2200,7 +2200,7 @@ final class ActivityStack { } if (p.intent.getComponent().equals(target.intent.getComponent())) { if (finishActivityLocked(p, j, Activity.RESULT_CANCELED, null, "replace")) { Activity.RESULT_CANCELED, null, "replace", false)) { taskTopI--; lastReparentPos--; } Loading Loading @@ -2270,7 +2270,7 @@ final class ActivityStack { continue; } if (finishActivityLocked(r, i, Activity.RESULT_CANCELED, null, "clear")) { null, "clear", false)) { i--; } } Loading @@ -2284,7 +2284,7 @@ final class ActivityStack { int index = indexOfTokenLocked(ret.appToken); if (index >= 0) { finishActivityLocked(ret, index, Activity.RESULT_CANCELED, null, "clear"); null, "clear", false); } return null; } Loading Loading @@ -2313,7 +2313,7 @@ final class ActivityStack { continue; } if (!finishActivityLocked(r, i, Activity.RESULT_CANCELED, null, "clear")) { null, "clear", false)) { i++; } } Loading Loading @@ -2579,6 +2579,7 @@ final class ActivityStack { mDismissKeyguardOnNextActivity = false; mService.mWindowManager.dismissKeyguard(); } Slog.i(TAG, "DONE STARTING!"); return err; } Loading Loading @@ -3319,7 +3320,7 @@ final class ActivityStack { Slog.d(TAG, "no-history finish of " + r); } requestFinishActivityLocked(r.appToken, Activity.RESULT_CANCELED, null, "no-history"); "no-history", false); } else { if (DEBUG_STATES) Slog.d(TAG, "Not finishing noHistory " + r + " on stop because we're just sleeping"); Loading Loading @@ -3531,7 +3532,7 @@ final class ActivityStack { ActivityRecord r = (ActivityRecord)stops.get(i); synchronized (mService) { if (r.finishing) { finishCurrentActivityLocked(r, FINISH_IMMEDIATELY); finishCurrentActivityLocked(r, FINISH_IMMEDIATELY, false); } else { stopActivityLocked(r); } Loading Loading @@ -3585,7 +3586,7 @@ final class ActivityStack { * some reason it is being left as-is. */ final boolean requestFinishActivityLocked(IBinder token, int resultCode, Intent resultData, String reason) { Intent resultData, String reason, boolean oomAdj) { int index = indexOfTokenLocked(token); if (DEBUG_RESULTS || DEBUG_STATES) Slog.v( TAG, "Finishing activity @" + index + ": token=" + token Loading @@ -3596,7 +3597,7 @@ final class ActivityStack { } ActivityRecord r = mHistory.get(index); finishActivityLocked(r, index, resultCode, resultData, reason); finishActivityLocked(r, index, resultCode, resultData, reason, oomAdj); return true; } Loading @@ -3613,10 +3614,11 @@ final class ActivityStack { if ((r.resultWho == null && resultWho == null) || (r.resultWho != null && r.resultWho.equals(resultWho))) { finishActivityLocked(r, i, Activity.RESULT_CANCELED, null, "request-sub"); Activity.RESULT_CANCELED, null, "request-sub", false); } } } mService.updateOomAdjLocked(); } final boolean finishActivityAffinityLocked(IBinder token) { Loading @@ -3639,7 +3641,8 @@ final class ActivityStack { if (cur.taskAffinity != null && !cur.taskAffinity.equals(r.taskAffinity)) { break; } finishActivityLocked(cur, index, Activity.RESULT_CANCELED, null, "request-affinity"); finishActivityLocked(cur, index, Activity.RESULT_CANCELED, null, "request-affinity", true); index--; } return true; Loading Loading @@ -3677,16 +3680,16 @@ final class ActivityStack { * list, or false if it is still in the list and will be removed later. */ final boolean finishActivityLocked(ActivityRecord r, int index, int resultCode, Intent resultData, String reason) { return finishActivityLocked(r, index, resultCode, resultData, reason, false); int resultCode, Intent resultData, String reason, boolean oomAdj) { return finishActivityLocked(r, index, resultCode, resultData, reason, false, oomAdj); } /** * @return Returns true if this activity has been removed from the history * list, or false if it is still in the list and will be removed later. */ final boolean finishActivityLocked(ActivityRecord r, int index, int resultCode, Intent resultData, String reason, boolean immediate) { final boolean finishActivityLocked(ActivityRecord r, int index, int resultCode, Intent resultData, String reason, boolean immediate, boolean oomAdj) { if (r.finishing) { Slog.w(TAG, "Duplicate finish request for " + r); return false; Loading Loading @@ -3730,7 +3733,7 @@ final class ActivityStack { if (immediate) { return finishCurrentActivityLocked(r, index, FINISH_IMMEDIATELY) == null; FINISH_IMMEDIATELY, oomAdj) == null; } else if (mResumedActivity == r) { boolean endTask = index <= 0 || (mHistory.get(index-1)).task != r.task; Loading @@ -3754,7 +3757,7 @@ final class ActivityStack { // it is done pausing; else we can just directly finish it here. if (DEBUG_PAUSE) Slog.v(TAG, "Finish not pausing: " + r); return finishCurrentActivityLocked(r, index, FINISH_AFTER_PAUSE) == null; FINISH_AFTER_PAUSE, oomAdj) == null; } else { if (DEBUG_PAUSE) Slog.v(TAG, "Finish waiting for pause of: " + r); } Loading @@ -3767,17 +3770,17 @@ final class ActivityStack { private static final int FINISH_AFTER_VISIBLE = 2; private final ActivityRecord finishCurrentActivityLocked(ActivityRecord r, int mode) { int mode, boolean oomAdj) { final int index = indexOfActivityLocked(r); if (index < 0) { return null; } return finishCurrentActivityLocked(r, index, mode); return finishCurrentActivityLocked(r, index, mode, oomAdj); } private final ActivityRecord finishCurrentActivityLocked(ActivityRecord r, int index, int mode) { int index, int mode, boolean oomAdj) { // First things first: if this activity is currently visible, // and the resumed activity is not yet visible, then hold off on // finishing until the resumed one becomes visible. Loading @@ -3796,7 +3799,9 @@ final class ActivityStack { if (DEBUG_STATES) Slog.v(TAG, "Moving to STOPPING: " + r + " (finish requested)"); r.state = ActivityState.STOPPING; if (oomAdj) { mService.updateOomAdjLocked(); } return r; } Loading @@ -3816,7 +3821,8 @@ final class ActivityStack { || prevState == ActivityState.INITIALIZING) { // If this activity is already stopped, we can just finish // it right now. boolean activityRemoved = destroyActivityLocked(r, true, true, "finish-imm"); boolean activityRemoved = destroyActivityLocked(r, true, oomAdj, "finish-imm"); if (activityRemoved) { resumeTopActivityLocked(null); } Loading Loading @@ -4008,9 +4014,8 @@ final class ActivityStack { ActivityManagerService.CANCEL_HEAVY_NOTIFICATION_MSG); } if (r.app.activities.size() == 0) { // No longer have activities, so update location in // LRU list. mService.updateLruProcessLocked(r.app, oomAdj, false); // No longer have activities, so update oom adj. mService.updateOomAdjLocked(); } } Loading
services/java/com/android/server/am/ProviderMap.java +35 −25 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.server.am; import android.content.ComponentName; import android.os.Binder; import android.os.Process; import android.os.RemoteException; import android.os.UserHandle; import android.util.Slog; Loading @@ -31,8 +30,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Set; /** * Keeps track of content providers by authority (name) and class. It separates the mapping by Loading @@ -44,6 +41,8 @@ public class ProviderMap { private static final boolean DBG = false; private final ActivityManagerService mAm; private final HashMap<String, ContentProviderRecord> mSingletonByName = new HashMap<String, ContentProviderRecord>(); private final HashMap<ComponentName, ContentProviderRecord> mSingletonByClass Loading @@ -54,6 +53,10 @@ public class ProviderMap { private final SparseArray<HashMap<ComponentName, ContentProviderRecord>> mProvidersByClassPerUser = new SparseArray<HashMap<ComponentName, ContentProviderRecord>>(); ProviderMap(ActivityManagerService am) { mAm = am; } ContentProviderRecord getProviderByName(String name) { return getProviderByName(name, -1); } Loading Loading @@ -217,8 +220,12 @@ public class ProviderMap { } } } else { didSomething |= collectForceStopProvidersLocked(name, appId, doit, evenPersistent, userId, getProvidersByClass(userId), result); HashMap<ComponentName, ContentProviderRecord> items = getProvidersByClass(userId); if (items != null) { didSomething |= collectForceStopProvidersLocked(name, appId, doit, evenPersistent, userId, items, result); } } return didSomething; } Loading Loading @@ -279,14 +286,17 @@ public class ProviderMap { protected boolean dumpProvider(FileDescriptor fd, PrintWriter pw, String name, String[] args, int opti, boolean dumpAll) { ArrayList<ContentProviderRecord> allProviders = new ArrayList<ContentProviderRecord>(); ArrayList<ContentProviderRecord> providers = new ArrayList<ContentProviderRecord>(); if ("all".equals(name)) { synchronized (this) { for (ContentProviderRecord r1 : getProvidersByClass(-1).values()) { providers.add(r1); } synchronized (mAm) { allProviders.addAll(mSingletonByClass.values()); for (int i=0; i<mProvidersByClassPerUser.size(); i++) { allProviders.addAll(mProvidersByClassPerUser.valueAt(i).values()); } if ("all".equals(name)) { providers.addAll(allProviders); } else { ComponentName componentName = name != null ? ComponentName.unflattenFromString(name) : null; Loading @@ -301,8 +311,8 @@ public class ProviderMap { } } synchronized (this) { for (ContentProviderRecord r1 : getProvidersByClass(-1).values()) { for (int i=0; i<allProviders.size(); i++) { ContentProviderRecord r1 = allProviders.get(i); if (componentName != null) { if (r1.name.equals(componentName)) { providers.add(r1); Loading Loading @@ -340,7 +350,7 @@ public class ProviderMap { private void dumpProvider(String prefix, FileDescriptor fd, PrintWriter pw, final ContentProviderRecord r, String[] args, boolean dumpAll) { String innerPrefix = prefix + " "; synchronized (this) { synchronized (mAm) { pw.print(prefix); pw.print("PROVIDER "); pw.print(r); pw.print(" pid="); Loading