diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 93f4d34dd682b..d5b6813ba12ca 100755 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -6333,7 +6333,7 @@ public final class ActivityManagerService extends ActivityManagerNative startProcessLocked(procs.get(ip), "on-hold", null); } } - + if (mFactoryTest != FactoryTest.FACTORY_TEST_LOW_LEVEL) { // Start looking for apps that are abusing wake locks. Message nmsg = mHandler.obtainMessage(CHECK_EXCESSIVE_WAKE_LOCKS_MSG); @@ -6573,7 +6573,7 @@ public final class ActivityManagerService extends ActivityManagerNative throw new IllegalArgumentException("File descriptors passed in options"); } } - + synchronized(this) { int callingUid = Binder.getCallingUid(); int origUserId = userId; @@ -6603,7 +6603,7 @@ public final class ActivityManagerService extends ActivityManagerNative return getIntentSenderLocked(type, packageName, callingUid, userId, token, resultWho, requestCode, intents, resolvedTypes, flags, options); - + } catch (RemoteException e) { throw new SecurityException(e); } @@ -6861,7 +6861,7 @@ public final class ActivityManagerService extends ActivityManagerNative "setProcessForeground()"); synchronized(this) { boolean changed = false; - + synchronized (mPidsSelfLocked) { ProcessRecord pr = mPidsSelfLocked.get(pid); if (pr == null && isForeground) { @@ -6897,13 +6897,13 @@ public final class ActivityManagerService extends ActivityManagerNative } } } - + if (changed) { updateOomAdjLocked(); } } } - + // ========================================================= // PERMISSIONS // ========================================================= @@ -6965,7 +6965,7 @@ public final class ActivityManagerService extends ActivityManagerNative * permission is automatically denied. (Internally a null permission * string is used when calling {@link #checkComponentPermission} in cases * when only uid-based security is needed.) - * + * * This can be called with or without the global lock held. */ @Override @@ -7222,12 +7222,12 @@ public final class ActivityManagerService extends ActivityManagerNative if (DEBUG_URI_PERMISSION) Slog.v(TAG, "Checking grant " + targetPkg + " permission to " + grantUri); } - + final IPackageManager pm = AppGlobals.getPackageManager(); // If this is not a content: uri, we can't do anything with it. if (!ContentResolver.SCHEME_CONTENT.equals(grantUri.uri.getScheme())) { - if (DEBUG_URI_PERMISSION) Slog.v(TAG, + if (DEBUG_URI_PERMISSION) Slog.v(TAG, "Can't grant URI permission for non-content URI: " + grantUri); return -1; } @@ -7355,7 +7355,7 @@ public final class ActivityManagerService extends ActivityManagerNative // to the uri, and the target doesn't. Let's now give this to // the target. - if (DEBUG_URI_PERMISSION) Slog.v(TAG, + if (DEBUG_URI_PERMISSION) Slog.v(TAG, "Granting " + targetPkg + "/" + targetUid + " permission to " + grantUri); final String authority = grantUri.uri.getAuthority(); @@ -7557,7 +7557,7 @@ public final class ActivityManagerService extends ActivityManagerNative final ArrayMap perms = mGrantedUriPermissions.get( perm.targetUid); if (perms != null) { - if (DEBUG_URI_PERMISSION) Slog.v(TAG, + if (DEBUG_URI_PERMISSION) Slog.v(TAG, "Removing " + perm.targetUid + " permission to " + perm.uri); perms.remove(perm.uri); @@ -8126,7 +8126,7 @@ public final class ActivityManagerService extends ActivityManagerNative outInfo.foregroundAppThreshold = mProcessList.getMemLevel( ProcessList.FOREGROUND_APP_ADJ); } - + // ========================================================= // TASK MANAGEMENT // ========================================================= @@ -8528,7 +8528,7 @@ public final class ActivityManagerService extends ActivityManagerNative } } } - + /** * TODO: Add mController hook */ @@ -8604,7 +8604,7 @@ public final class ActivityManagerService extends ActivityManagerNative /** * Moves an activity, and all of the other activities within the same task, to the bottom * of the history stack. The activity's order within the task is unchanged. - * + * * @param token A reference to the activity we wish to move * @param nonRoot If false then this only works if the activity is the root * of a task; if true it will work for any activity in a task. @@ -9025,7 +9025,7 @@ public final class ActivityManagerService extends ActivityManagerNative == PackageManager.PERMISSION_GRANTED) { return null; } - + PathPermission[] pps = cpi.pathPermissions; if (pps != null) { int i = pps.length; @@ -9609,7 +9609,7 @@ public final class ActivityManagerService extends ActivityManagerNative } } } - + public final void publishContentProviders(IApplicationThread caller, List providers) { if (providers == null) { @@ -10087,7 +10087,7 @@ public final class ActivityManagerService extends ActivityManagerNative return timedout; } - + public final void activitySlept(IBinder token) { if (localLOGV) Slog.v(TAG, "Activity slept: token=" + token); @@ -10162,7 +10162,7 @@ public final class ActivityManagerService extends ActivityManagerNative throw new SecurityException("Requires permission " + android.Manifest.permission.STOP_APP_SWITCHES); } - + synchronized(this) { mAppSwitchesAllowedTime = SystemClock.uptimeMillis() + APP_SWITCH_DELAY_TIME; @@ -10172,14 +10172,14 @@ public final class ActivityManagerService extends ActivityManagerNative mHandler.sendMessageDelayed(msg, APP_SWITCH_DELAY_TIME); } } - + public void resumeAppSwitches() { if (checkCallingPermission(android.Manifest.permission.STOP_APP_SWITCHES) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires permission " + android.Manifest.permission.STOP_APP_SWITCHES); } - + synchronized(this) { // Note that we don't execute any pending app switches... we will // let those wait until either the timeout, or the next start @@ -10187,7 +10187,7 @@ public final class ActivityManagerService extends ActivityManagerNative mAppSwitchesAllowedTime = 0; } } - + boolean checkAppSwitchAllowedLocked(int sourcePid, int sourceUid, int callingPid, int callingUid, String name) { if (mAppSwitchesAllowedTime < SystemClock.uptimeMillis()) { @@ -10215,7 +10215,7 @@ public final class ActivityManagerService extends ActivityManagerNative Slog.w(TAG, name + " request from " + sourceUid + " stopped"); return false; } - + public void setDebugApp(String packageName, boolean waitForDebugger, boolean persistent) { enforceCallingPermission(android.Manifest.permission.SET_DEBUG_APP, @@ -11189,7 +11189,7 @@ public final class ActivityManagerService extends ActivityManagerNative } } } - + synchronized(this) { if (procsToKill != null) { for (int i=procsToKill.size()-1; i>=0; i--) { @@ -11198,20 +11198,20 @@ public final class ActivityManagerService extends ActivityManagerNative removeProcessLocked(proc, true, false, "system update done"); } } - + // Now that we have cleaned up any update processes, we // are ready to start launching real processes and know that // we won't trample on them any more. mProcessesReady = true; } - + Slog.i(TAG, "System now ready"); EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_AMS_READY, SystemClock.uptimeMillis()); synchronized(this) { // Make sure we have no pre-ready processes sitting around. - + if (mFactoryTest == FactoryTest.FACTORY_TEST_LOW_LEVEL) { ResolveInfo ri = mContext.getPackageManager() .resolveActivity(new Intent(Intent.ACTION_FACTORY_TEST), @@ -11346,12 +11346,12 @@ public final class ActivityManagerService extends ActivityManagerNative startAppProblemLocked(app); app.stopFreezingAllLocked(); } - + /** * Generate a process error record, suitable for attachment to a ProcessRecord. - * + * * @param app The ProcessRecord in which the error occurred. - * @param condition Crashing, Application Not Responding, etc. Values are defined in + * @param condition Crashing, Application Not Responding, etc. Values are defined in * ActivityManager.AppErrorStateInfo * @param activity The activity associated with the crash, if known. * @param shortMsg Short message describing the crash. @@ -11360,7 +11360,7 @@ public final class ActivityManagerService extends ActivityManagerNative * * @return Returns a fully-formed AppErrorStateInfo record. */ - private ActivityManager.ProcessErrorStateInfo generateProcessError(ProcessRecord app, + private ActivityManager.ProcessErrorStateInfo generateProcessError(ProcessRecord app, int condition, String activity, String shortMsg, String longMsg, String stackTrace) { ActivityManager.ProcessErrorStateInfo report = new ActivityManager.ProcessErrorStateInfo(); @@ -12117,14 +12117,14 @@ public final class ActivityManagerService extends ActivityManagerNative } else if (app.notResponding) { report = app.notRespondingReport; } - + if (report != null) { if (errList == null) { errList = new ArrayList(1); } errList.add(report); } else { - Slog.w(TAG, "Missing app error report, app = " + app.processName + + Slog.w(TAG, "Missing app error report, app = " + app.processName + " crashing = " + app.crashing + " notResponding = " + app.notResponding); } @@ -12183,7 +12183,7 @@ public final class ActivityManagerService extends ActivityManagerNative } if ((app.thread != null) && (!app.crashing && !app.notResponding)) { // Generate process state info for running application - ActivityManager.RunningAppProcessInfo currApp = + ActivityManager.RunningAppProcessInfo currApp = new ActivityManager.RunningAppProcessInfo(app.processName, app.pid, app.getPackageList()); fillInProcMemInfo(app, currApp); @@ -12265,7 +12265,7 @@ public final class ActivityManagerService extends ActivityManagerNative boolean dumpAll = false; boolean dumpClient = false; String dumpPackage = null; - + int opti = 0; while (opti < args.length) { String opt = args[opti]; @@ -12638,12 +12638,12 @@ public final class ActivityManagerService extends ActivityManagerNative } } } - + if (mForegroundProcesses.size() > 0) { synchronized (mPidsSelfLocked) { boolean printed = false; for (int i=0; i 0) { if (needSep) pw.println(); needSep = true; @@ -12679,7 +12679,7 @@ public final class ActivityManagerService extends ActivityManagerNative dumpProcessList(pw, this, mRemovedProcesses, " ", "Removed Norm", "Removed PERS", dumpPackage); } - + if (mProcessesOnHold.size() > 0) { if (needSep) pw.println(); needSep = true; @@ -12690,7 +12690,7 @@ public final class ActivityManagerService extends ActivityManagerNative } needSep = dumpProcessesToGc(fd, pw, args, opti, needSep, dumpAll, dumpPackage); - + if (mProcessCrashTimes.getMap().size() > 0) { boolean printed = false; long now = SystemClock.uptimeMillis(); @@ -13062,7 +13062,7 @@ public final class ActivityManagerService extends ActivityManagerNative ArrayList strings; ArrayList objects; boolean all; - + ItemMatcher() { all = true; } @@ -13147,7 +13147,7 @@ public final class ActivityManagerService extends ActivityManagerNative protected boolean dumpActivity(FileDescriptor fd, PrintWriter pw, String name, String[] args, int opti, boolean dumpAll) { ArrayList activities; - + synchronized (this) { activities = mStackSupervisor.getDumpActivitiesLocked(name); } @@ -13270,7 +13270,7 @@ public final class ActivityManagerService extends ActivityManagerNative } needSep = true; - + if (!onlyHistory && mStickyBroadcasts != null && dumpPackage == null) { for (int user=0; user= 0 ; i--) { ProcessRecord r = procs.get(i); if (r.thread != null) { @@ -13847,7 +13847,7 @@ public final class ActivityManagerService extends ActivityManagerNative boolean oomOnly = false; boolean isCompact = false; boolean localOnly = false; - + int opti = 0; while (opti < args.length) { String opt = args[opti]; @@ -13881,7 +13881,7 @@ public final class ActivityManagerService extends ActivityManagerNative pw.println("Unknown argument: " + opt + "; use -h for help"); } } - + final boolean isCheckinRequest = scanArgs(args, "--checkin"); long uptime = SystemClock.uptimeMillis(); long realtime = SystemClock.elapsedRealtime(); @@ -14566,7 +14566,7 @@ public final class ActivityManagerService extends ActivityManagerNative } return restart; } - + // ========================================================= // SERVICES // ========================================================= @@ -14648,7 +14648,7 @@ public final class ActivityManagerService extends ActivityManagerNative return mServices.peekServiceLocked(service, resolvedType); } } - + @Override public boolean stopServiceToken(ComponentName className, IBinder token, int startId) { @@ -14870,11 +14870,11 @@ public final class ActivityManagerService extends ActivityManagerNative mServices.serviceDoneExecutingLocked((ServiceRecord)token, type, startId, res); } } - + // ========================================================= // BACKUP AND RESTORE // ========================================================= - + // Cause the target app to be launched if necessary and its backup agent // instantiated. The backup agent will invoke backupAgentCreated() on the // activity manager to announce its creation. @@ -14937,7 +14937,7 @@ public final class ActivityManagerService extends ActivityManagerNative // mBackupAppName describe the app, so that when it binds back to the AM we // know that it's scheduled for a backup-agent operation. } - + return true; } @@ -15240,7 +15240,7 @@ public final class ActivityManagerService extends ActivityManagerNative mReceiverResolver.removeFilter(rl.get(i)); } } - + private final void sendPackageBroadcastLocked(int cmd, String[] packages, int userId) { for (int i = mLruProcesses.size() - 1 ; i >= 0 ; i--) { ProcessRecord r = mLruProcesses.get(i); @@ -15646,10 +15646,10 @@ public final class ActivityManagerService extends ActivityManagerNative final boolean replacePending = (intent.getFlags()&Intent.FLAG_RECEIVER_REPLACE_PENDING) != 0; - + if (DEBUG_BROADCAST) Slog.v(TAG, "Enqueing broadcast: " + intent.getAction() + " replacePending=" + replacePending); - + int NR = registeredReceivers != null ? registeredReceivers.size() : 0; if (!ordered && NR > 0) { // If we are not serializing this broadcast, then send the @@ -15757,7 +15757,7 @@ public final class ActivityManagerService extends ActivityManagerNative int seq = r.intent.getIntExtra("seq", -1); Slog.i(TAG, "Enqueueing broadcast " + r.intent.getAction() + " seq=" + seq); } - boolean replaced = replacePending && queue.replaceOrderedBroadcastLocked(r); + boolean replaced = replacePending && queue.replaceOrderedBroadcastLocked(r); if (!replaced) { queue.enqueueOrderedBroadcastLocked(r); queue.scheduleBroadcastsLocked(); @@ -15923,7 +15923,7 @@ public final class ActivityManagerService extends ActivityManagerNative Binder.restoreCallingIdentity(origId); } } - + // ========================================================= // INSTRUMENTATION // ========================================================= @@ -15993,17 +15993,17 @@ public final class ActivityManagerService extends ActivityManagerNative return true; } - + /** - * Report errors that occur while attempting to start Instrumentation. Always writes the + * Report errors that occur while attempting to start Instrumentation. Always writes the * error to the logs, but if somebody is watching, send the report there too. This enables * the "am" command to report errors with more information. - * + * * @param watcher The IInstrumentationWatcher. Null if there isn't one. * @param cn The component name of the instrumentation. * @param report The error report. */ - private void reportStartInstrumentationFailure(IInstrumentationWatcher watcher, + private void reportStartInstrumentationFailure(IInstrumentationWatcher watcher, ComponentName cn, String report) { Slog.w(TAG, report); try { @@ -16073,7 +16073,7 @@ public final class ActivityManagerService extends ActivityManagerNative // ========================================================= // CONFIGURATION // ========================================================= - + public ConfigurationInfo getDeviceConfigurationInfo() { ConfigurationInfo config = new ConfigurationInfo(); synchronized (this) { @@ -16163,11 +16163,11 @@ public final class ActivityManagerService extends ActivityManagerNative if (DEBUG_SWITCH || DEBUG_CONFIGURATION) { Slog.i(TAG, "Updating configuration to: " + values); } - + EventLog.writeEvent(EventLogTags.CONFIGURATION_CHANGED, changes); if (values.locale != null && !initLocale) { - saveLocaleLocked(values.locale, + saveLocaleLocked(values.locale, !values.locale.equals(mConfiguration.locale), values.userSetLocale); } @@ -16183,7 +16183,7 @@ public final class ActivityManagerService extends ActivityManagerNative //mUsageStatsService.noteStartConfig(newConfig); final Configuration configCopy = new Configuration(mConfiguration); - + // TODO: If our config changes, should we auto dismiss any currently // showing dialogs? mShowDialogs = shouldShowDialogs(newConfig); @@ -16282,7 +16282,7 @@ public final class ActivityManagerService extends ActivityManagerNative if(isDiff) { SystemProperties.set("user.language", l.getLanguage()); SystemProperties.set("user.region", l.getCountry()); - } + } if(isPersist) { SystemProperties.set("persist.sys.language", l.getLanguage()); @@ -16970,7 +16970,7 @@ public final class ActivityManagerService extends ActivityManagerNative } app.curRawAdj = adj; - + //Slog.i(TAG, "OOM ADJ " + app + ": pid=" + app.pid + // " adj=" + adj + " curAdj=" + app.curAdj + " maxAdj=" + app.maxAdj); if (adj > app.maxAdj) { @@ -17053,7 +17053,7 @@ public final class ActivityManagerService extends ActivityManagerNative // whatever. } } - + /** * Returns true if things are idle enough to perform GCs. */ @@ -17067,7 +17067,7 @@ public final class ActivityManagerService extends ActivityManagerNative return !processingBroadcasts && (isSleeping() || mStackSupervisor.allResumedActivitiesIdle()); } - + /** * Perform GCs on all processes that are waiting for it, but only * if things are idle. @@ -17096,11 +17096,11 @@ public final class ActivityManagerService extends ActivityManagerNative } } } - + scheduleAppGcsLocked(); } } - + /** * If all looks good, perform GCs on all processes waiting for them. */ @@ -17118,12 +17118,12 @@ public final class ActivityManagerService extends ActivityManagerNative */ final void scheduleAppGcsLocked() { mHandler.removeMessages(GC_BACKGROUND_PROCESSES_MSG); - + if (mProcessesToGc.size() > 0) { // Schedule a GC for the time to the next process. ProcessRecord proc = mProcessesToGc.get(0); Message msg = mHandler.obtainMessage(GC_BACKGROUND_PROCESSES_MSG); - + long when = proc.lastRequestedGc + GC_MIN_INTERVAL; long now = SystemClock.uptimeMillis(); if (when < (now+GC_TIMEOUT)) { @@ -17132,7 +17132,7 @@ public final class ActivityManagerService extends ActivityManagerNative mHandler.sendMessageAtTime(msg, when); } } - + /** * Add a process to the array of processes waiting to be GCed. Keeps the * list in sorted order by the last GC time. The process can't already be @@ -17152,7 +17152,7 @@ public final class ActivityManagerService extends ActivityManagerNative mProcessesToGc.add(0, proc); } } - + /** * Set up to ask a process to GC itself. This will either do it * immediately, or put it on the list of processes to gc the next