Loading services/java/com/android/server/am/ActivityManagerService.java +7 −4 Original line number Original line Diff line number Diff line Loading @@ -2388,7 +2388,7 @@ public final class ActivityManagerService extends ActivityManagerNative intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setComponent(new ComponentName( intent.setComponent(new ComponentName( ri.activityInfo.packageName, ri.activityInfo.name)); ri.activityInfo.packageName, ri.activityInfo.name)); getMainStack().startActivityLocked(null, intent, null, ri.activityInfo, mStackSupervisor.startActivityLocked(null, intent, null, ri.activityInfo, null, null, 0, 0, 0, null, 0, null, false, null); null, null, 0, 0, 0, null, 0, null, false, null); } } } } Loading Loading @@ -2700,7 +2700,7 @@ public final class ActivityManagerService extends ActivityManagerNative } } final long origId = Binder.clearCallingIdentity(); final long origId = Binder.clearCallingIdentity(); int res = r.task.stack.startActivityLocked(r.app.thread, intent, int res = mStackSupervisor.startActivityLocked(r.app.thread, intent, r.resolvedType, aInfo, resultTo != null ? resultTo.appToken : null, r.resolvedType, aInfo, resultTo != null ? resultTo.appToken : null, resultWho, requestCode, -1, r.launchedFromUid, r.launchedFromPackage, 0, resultWho, requestCode, -1, r.launchedFromUid, r.launchedFromPackage, 0, options, false, null); options, false, null); Loading Loading @@ -3767,7 +3767,8 @@ public final class ActivityManagerService extends ActivityManagerNative return infos; return infos; } } public long[] getProcessPss(int[] pids) throws RemoteException { @Override public long[] getProcessPss(int[] pids) { enforceNotIsolatedCaller("getProcessPss"); enforceNotIsolatedCaller("getProcessPss"); long[] pss = new long[pids.length]; long[] pss = new long[pids.length]; for (int i=pids.length-1; i>=0; i--) { for (int i=pids.length-1; i>=0; i--) { Loading @@ -3776,6 +3777,7 @@ public final class ActivityManagerService extends ActivityManagerNative return pss; return pss; } } @Override public void killApplicationProcess(String processName, int uid) { public void killApplicationProcess(String processName, int uid) { if (processName == null) { if (processName == null) { return; return; Loading Loading @@ -4214,7 +4216,7 @@ public final class ActivityManagerService extends ActivityManagerNative mHandler.removeMessages(PROC_START_TIMEOUT_MSG, app); mHandler.removeMessages(PROC_START_TIMEOUT_MSG, app); boolean normalMode = mProcessesReady || isAllowedWhileBooting(app.info); boolean normalMode = mProcessesReady || isAllowedWhileBooting(app.info); List providers = normalMode ? generateApplicationProvidersLocked(app) : null; List<ProviderInfo> providers = normalMode ? generateApplicationProvidersLocked(app) : null; if (!normalMode) { if (!normalMode) { Slog.i(TAG, "Launching preboot mode app: " + app); Slog.i(TAG, "Launching preboot mode app: " + app); Loading Loading @@ -4360,6 +4362,7 @@ public final class ActivityManagerService extends ActivityManagerNative return true; return true; } } @Override public final void attachApplication(IApplicationThread thread) { public final void attachApplication(IApplicationThread thread) { synchronized (this) { synchronized (this) { int callingPid = Binder.getCallingPid(); int callingPid = Binder.getCallingPid(); Loading services/java/com/android/server/am/ActivityStack.java +1 −184 Original line number Original line Diff line number Diff line Loading @@ -2157,189 +2157,6 @@ final class ActivityStack { newTop.frontOfTask = true; newTop.frontOfTask = true; } } final int startActivityLocked(IApplicationThread caller, Intent intent, String resolvedType, ActivityInfo aInfo, IBinder resultTo, String resultWho, int requestCode, int callingPid, int callingUid, String callingPackage, int startFlags, Bundle options, boolean componentSpecified, ActivityRecord[] outActivity) { int err = ActivityManager.START_SUCCESS; ProcessRecord callerApp = null; if (caller != null) { callerApp = mService.getRecordForAppLocked(caller); if (callerApp != null) { callingPid = callerApp.pid; callingUid = callerApp.info.uid; } else { Slog.w(TAG, "Unable to find app for caller " + caller + " (pid=" + callingPid + ") when starting: " + intent.toString()); err = ActivityManager.START_PERMISSION_DENIED; } } if (err == ActivityManager.START_SUCCESS) { final int userId = aInfo != null ? UserHandle.getUserId(aInfo.applicationInfo.uid) : 0; Slog.i(TAG, "START u" + userId + " {" + intent.toShortString(true, true, true, false) + "} from pid " + (callerApp != null ? callerApp.pid : callingPid)); } ActivityRecord sourceRecord = null; ActivityRecord resultRecord = null; if (resultTo != null) { sourceRecord = isInStackLocked(resultTo); if (DEBUG_RESULTS) Slog.v( TAG, "Will send result to " + resultTo + " " + sourceRecord); if (sourceRecord != null) { if (requestCode >= 0 && !sourceRecord.finishing) { resultRecord = sourceRecord; } } } int launchFlags = intent.getFlags(); if ((launchFlags&Intent.FLAG_ACTIVITY_FORWARD_RESULT) != 0 && sourceRecord != null) { // Transfer the result target from the source activity to the new // one being started, including any failures. if (requestCode >= 0) { ActivityOptions.abort(options); return ActivityManager.START_FORWARD_AND_REQUEST_CONFLICT; } resultRecord = sourceRecord.resultTo; resultWho = sourceRecord.resultWho; requestCode = sourceRecord.requestCode; sourceRecord.resultTo = null; if (resultRecord != null) { resultRecord.removeResultsLocked( sourceRecord, resultWho, requestCode); } } if (err == ActivityManager.START_SUCCESS && intent.getComponent() == null) { // We couldn't find a class that can handle the given Intent. // That's the end of that! err = ActivityManager.START_INTENT_NOT_RESOLVED; } if (err == ActivityManager.START_SUCCESS && aInfo == null) { // We couldn't find the specific class specified in the Intent. // Also the end of the line. err = ActivityManager.START_CLASS_NOT_FOUND; } if (err != ActivityManager.START_SUCCESS) { if (resultRecord != null) { sendActivityResultLocked(-1, resultRecord, resultWho, requestCode, Activity.RESULT_CANCELED, null); } mStackSupervisor.setDismissKeyguard(false); ActivityOptions.abort(options); return err; } final int startAnyPerm = mService.checkPermission( START_ANY_ACTIVITY, callingPid, callingUid); final int componentPerm = mService.checkComponentPermission(aInfo.permission, callingPid, callingUid, aInfo.applicationInfo.uid, aInfo.exported); if (startAnyPerm != PERMISSION_GRANTED && componentPerm != PERMISSION_GRANTED) { if (resultRecord != null) { sendActivityResultLocked(-1, resultRecord, resultWho, requestCode, Activity.RESULT_CANCELED, null); } mStackSupervisor.setDismissKeyguard(false); String msg; if (!aInfo.exported) { msg = "Permission Denial: starting " + intent.toString() + " from " + callerApp + " (pid=" + callingPid + ", uid=" + callingUid + ")" + " not exported from uid " + aInfo.applicationInfo.uid; } else { msg = "Permission Denial: starting " + intent.toString() + " from " + callerApp + " (pid=" + callingPid + ", uid=" + callingUid + ")" + " requires " + aInfo.permission; } Slog.w(TAG, msg); throw new SecurityException(msg); } if (mStackSupervisor.isMainStack(this)) { if (mService.mController != null) { boolean abort = false; try { // The Intent we give to the watcher has the extra data // stripped off, since it can contain private information. Intent watchIntent = intent.cloneFilter(); abort = !mService.mController.activityStarting(watchIntent, aInfo.applicationInfo.packageName); } catch (RemoteException e) { mService.mController = null; } if (abort) { if (resultRecord != null) { sendActivityResultLocked(-1, resultRecord, resultWho, requestCode, Activity.RESULT_CANCELED, null); } // We pretend to the caller that it was really started, but // they will just get a cancel result. mStackSupervisor.setDismissKeyguard(false); ActivityOptions.abort(options); return ActivityManager.START_SUCCESS; } } } ActivityRecord r = new ActivityRecord(mService, callerApp, callingUid, callingPackage, intent, resolvedType, aInfo, mService.mConfiguration, resultRecord, resultWho, requestCode, componentSpecified); if (outActivity != null) { outActivity[0] = r; } if (mStackSupervisor.isMainStack(this)) { if (mResumedActivity == null || mResumedActivity.info.applicationInfo.uid != callingUid) { if (!mService.checkAppSwitchAllowedLocked(callingPid, callingUid, "Activity start")) { PendingActivityLaunch pal = new PendingActivityLaunch(r, sourceRecord, startFlags, this); mService.mPendingActivityLaunches.add(pal); mStackSupervisor.setDismissKeyguard(false); ActivityOptions.abort(options); return ActivityManager.START_SWITCHES_CANCELED; } } if (mService.mDidAppSwitch) { // This is the second allowed switch since we stopped switches, // so now just generally allow switches. Use case: user presses // home (switches disabled, switch to home, mDidAppSwitch now true); // user taps a home icon (coming from home so allowed, we hit here // and now allow anyone to switch again). mService.mAppSwitchesAllowedTime = 0; } else { mService.mDidAppSwitch = true; } } mService.doPendingActivityLaunchesLocked(false); err = startActivityUncheckedLocked(r, sourceRecord, startFlags, true, options); if (mPausingActivity == null) { // Someone asked to have the keyguard dismissed on the next // activity start, but we are not actually doing an activity // switch... just dismiss the keyguard now, because we // probably want to see whatever is behind it. mStackSupervisor.dismissKeyguard(); } return err; } final void moveHomeToFrontFromLaunchLocked(int launchFlags) { final void moveHomeToFrontFromLaunchLocked(int launchFlags) { if ((launchFlags & if ((launchFlags & (Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_TASK_ON_HOME)) (Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_TASK_ON_HOME)) Loading Loading @@ -3369,7 +3186,7 @@ final class ActivityStack { try { try { ActivityInfo aInfo = AppGlobals.getPackageManager().getActivityInfo( ActivityInfo aInfo = AppGlobals.getPackageManager().getActivityInfo( destIntent.getComponent(), 0, srec.userId); destIntent.getComponent(), 0, srec.userId); int res = startActivityLocked(srec.app.thread, destIntent, int res = mStackSupervisor.startActivityLocked(srec.app.thread, destIntent, null, aInfo, parent.appToken, null, null, aInfo, parent.appToken, null, 0, -1, parent.launchedFromUid, parent.launchedFromPackage, 0, -1, parent.launchedFromUid, parent.launchedFromPackage, 0, null, true, null); 0, null, true, null); Loading services/java/com/android/server/am/ActivityStackSupervisor.java +198 −3 Original line number Original line Diff line number Diff line Loading @@ -16,8 +16,11 @@ package com.android.server.am; package com.android.server.am; import static android.Manifest.permission.START_ANY_ACTIVITY; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static com.android.server.am.ActivityManagerService.localLOGV; import static com.android.server.am.ActivityManagerService.localLOGV; import static com.android.server.am.ActivityManagerService.DEBUG_CONFIGURATION; import static com.android.server.am.ActivityManagerService.DEBUG_CONFIGURATION; import static com.android.server.am.ActivityManagerService.DEBUG_RESULTS; import static com.android.server.am.ActivityManagerService.DEBUG_SWITCH; import static com.android.server.am.ActivityManagerService.DEBUG_SWITCH; import static com.android.server.am.ActivityManagerService.TAG; import static com.android.server.am.ActivityManagerService.TAG; Loading Loading @@ -49,10 +52,12 @@ import android.os.Message; import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.RemoteException; import android.os.SystemClock; import android.os.SystemClock; import android.os.UserHandle; import android.util.EventLog; import android.util.EventLog; import android.util.Slog; import android.util.Slog; import com.android.internal.app.HeavyWeightSwitcherActivity; import com.android.internal.app.HeavyWeightSwitcherActivity; import com.android.server.am.ActivityManagerService.PendingActivityLaunch; import com.android.server.am.ActivityStack.ActivityState; import com.android.server.am.ActivityStack.ActivityState; import java.io.FileDescriptor; import java.io.FileDescriptor; Loading Loading @@ -146,6 +151,16 @@ public class ActivityStackSupervisor { return null; return null; } } ActivityRecord isInAnyStackLocked(IBinder token) { for (int stackNdx = mStacks.size() - 1; stackNdx >= 0; --stackNdx) { final ActivityRecord r = mStacks.get(stackNdx).isInStackLocked(token); if (r != null) { return r; } } return null; } int getNextTaskId() { int getNextTaskId() { do { do { mCurTaskId++; mCurTaskId++; Loading Loading @@ -258,7 +273,7 @@ public class ActivityStackSupervisor { } } void startHomeActivity(Intent intent, ActivityInfo aInfo) { void startHomeActivity(Intent intent, ActivityInfo aInfo) { mHomeStack.startActivityLocked(null, intent, null, aInfo, null, null, 0, 0, 0, null, 0, startActivityLocked(null, intent, null, aInfo, null, null, 0, 0, 0, null, 0, null, false, null); null, false, null); } } Loading Loading @@ -368,7 +383,7 @@ public class ActivityStackSupervisor { } } } } int res = mMainStack.startActivityLocked(caller, intent, resolvedType, int res = startActivityLocked(caller, intent, resolvedType, aInfo, resultTo, resultWho, requestCode, callingPid, callingUid, aInfo, resultTo, resultWho, requestCode, callingPid, callingUid, callingPackage, startFlags, options, componentSpecified, null); callingPackage, startFlags, options, componentSpecified, null); Loading Loading @@ -484,7 +499,7 @@ public class ActivityStackSupervisor { } else { } else { theseOptions = null; theseOptions = null; } } int res = mMainStack.startActivityLocked(caller, intent, resolvedTypes[i], int res = startActivityLocked(caller, intent, resolvedTypes[i], aInfo, resultTo, null, -1, callingPid, callingUid, callingPackage, aInfo, resultTo, null, -1, callingPid, callingUid, callingPackage, 0, theseOptions, componentSpecified, outActivity); 0, theseOptions, componentSpecified, outActivity); if (res < 0) { if (res < 0) { Loading Loading @@ -695,6 +710,186 @@ public class ActivityStackSupervisor { "activity", r.intent.getComponent(), false, false); "activity", r.intent.getComponent(), false, false); } } final int startActivityLocked(IApplicationThread caller, Intent intent, String resolvedType, ActivityInfo aInfo, IBinder resultTo, String resultWho, int requestCode, int callingPid, int callingUid, String callingPackage, int startFlags, Bundle options, boolean componentSpecified, ActivityRecord[] outActivity) { int err = ActivityManager.START_SUCCESS; ProcessRecord callerApp = null; if (caller != null) { callerApp = mService.getRecordForAppLocked(caller); if (callerApp != null) { callingPid = callerApp.pid; callingUid = callerApp.info.uid; } else { Slog.w(TAG, "Unable to find app for caller " + caller + " (pid=" + callingPid + ") when starting: " + intent.toString()); err = ActivityManager.START_PERMISSION_DENIED; } } if (err == ActivityManager.START_SUCCESS) { final int userId = aInfo != null ? UserHandle.getUserId(aInfo.applicationInfo.uid) : 0; Slog.i(TAG, "START u" + userId + " {" + intent.toShortString(true, true, true, false) + "} from pid " + (callerApp != null ? callerApp.pid : callingPid)); } ActivityRecord sourceRecord = null; ActivityRecord resultRecord = null; if (resultTo != null) { sourceRecord = isInAnyStackLocked(resultTo); if (DEBUG_RESULTS) Slog.v( TAG, "Will send result to " + resultTo + " " + sourceRecord); if (sourceRecord != null) { if (requestCode >= 0 && !sourceRecord.finishing) { resultRecord = sourceRecord; } } } ActivityStack resultStack = resultRecord == null ? null : resultRecord.task.stack; int launchFlags = intent.getFlags(); if ((launchFlags&Intent.FLAG_ACTIVITY_FORWARD_RESULT) != 0 && sourceRecord != null) { // Transfer the result target from the source activity to the new // one being started, including any failures. if (requestCode >= 0) { ActivityOptions.abort(options); return ActivityManager.START_FORWARD_AND_REQUEST_CONFLICT; } resultRecord = sourceRecord.resultTo; resultWho = sourceRecord.resultWho; requestCode = sourceRecord.requestCode; sourceRecord.resultTo = null; if (resultRecord != null) { resultRecord.removeResultsLocked( sourceRecord, resultWho, requestCode); } } if (err == ActivityManager.START_SUCCESS && intent.getComponent() == null) { // We couldn't find a class that can handle the given Intent. // That's the end of that! err = ActivityManager.START_INTENT_NOT_RESOLVED; } if (err == ActivityManager.START_SUCCESS && aInfo == null) { // We couldn't find the specific class specified in the Intent. // Also the end of the line. err = ActivityManager.START_CLASS_NOT_FOUND; } if (err != ActivityManager.START_SUCCESS) { if (resultRecord != null) { resultStack.sendActivityResultLocked(-1, resultRecord, resultWho, requestCode, Activity.RESULT_CANCELED, null); } setDismissKeyguard(false); ActivityOptions.abort(options); return err; } final int startAnyPerm = mService.checkPermission( START_ANY_ACTIVITY, callingPid, callingUid); final int componentPerm = mService.checkComponentPermission(aInfo.permission, callingPid, callingUid, aInfo.applicationInfo.uid, aInfo.exported); if (startAnyPerm != PERMISSION_GRANTED && componentPerm != PERMISSION_GRANTED) { if (resultRecord != null) { resultStack.sendActivityResultLocked(-1, resultRecord, resultWho, requestCode, Activity.RESULT_CANCELED, null); } setDismissKeyguard(false); String msg; if (!aInfo.exported) { msg = "Permission Denial: starting " + intent.toString() + " from " + callerApp + " (pid=" + callingPid + ", uid=" + callingUid + ")" + " not exported from uid " + aInfo.applicationInfo.uid; } else { msg = "Permission Denial: starting " + intent.toString() + " from " + callerApp + " (pid=" + callingPid + ", uid=" + callingUid + ")" + " requires " + aInfo.permission; } Slog.w(TAG, msg); throw new SecurityException(msg); } if (mService.mController != null) { boolean abort = false; try { // The Intent we give to the watcher has the extra data // stripped off, since it can contain private information. Intent watchIntent = intent.cloneFilter(); abort = !mService.mController.activityStarting(watchIntent, aInfo.applicationInfo.packageName); } catch (RemoteException e) { mService.mController = null; } if (abort) { if (resultRecord != null) { resultStack.sendActivityResultLocked(-1, resultRecord, resultWho, requestCode, Activity.RESULT_CANCELED, null); } // We pretend to the caller that it was really started, but // they will just get a cancel result. setDismissKeyguard(false); ActivityOptions.abort(options); return ActivityManager.START_SUCCESS; } } ActivityRecord r = new ActivityRecord(mService, callerApp, callingUid, callingPackage, intent, resolvedType, aInfo, mService.mConfiguration, resultRecord, resultWho, requestCode, componentSpecified); if (outActivity != null) { outActivity[0] = r; } if (mMainStack.mResumedActivity == null || mMainStack.mResumedActivity.info.applicationInfo.uid != callingUid) { if (!mService.checkAppSwitchAllowedLocked(callingPid, callingUid, "Activity start")) { PendingActivityLaunch pal = new PendingActivityLaunch(r, sourceRecord, startFlags, mMainStack); mService.mPendingActivityLaunches.add(pal); setDismissKeyguard(false); ActivityOptions.abort(options); return ActivityManager.START_SWITCHES_CANCELED; } } if (mService.mDidAppSwitch) { // This is the second allowed switch since we stopped switches, // so now just generally allow switches. Use case: user presses // home (switches disabled, switch to home, mDidAppSwitch now true); // user taps a home icon (coming from home so allowed, we hit here // and now allow anyone to switch again). mService.mAppSwitchesAllowedTime = 0; } else { mService.mDidAppSwitch = true; } mService.doPendingActivityLaunchesLocked(false); err = mMainStack.startActivityUncheckedLocked(r, sourceRecord, startFlags, true, options); if (mMainStack.mPausingActivity == null) { // Someone asked to have the keyguard dismissed on the next // activity start, but we are not actually doing an activity // switch... just dismiss the keyguard now, because we // probably want to see whatever is behind it. dismissKeyguard(); } return err; } void handleAppDiedLocked(ProcessRecord app, boolean restarting) { void handleAppDiedLocked(ProcessRecord app, boolean restarting) { // Just in case. // Just in case. final int numStacks = mStacks.size(); final int numStacks = mStacks.size(); Loading services/java/com/android/server/am/TaskRecord.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -133,6 +133,7 @@ class TaskRecord extends ThumbnailHolder { } } void addActivityToTop(ActivityRecord r) { void addActivityToTop(ActivityRecord r) { // Remove r first, and if it wasn't already in the list and it's fullscreen, count it. if (!mActivities.remove(r) && r.fullscreen) { if (!mActivities.remove(r) && r.fullscreen) { // Was not previously in list. // Was not previously in list. numFullscreen++; numFullscreen++; Loading Loading
services/java/com/android/server/am/ActivityManagerService.java +7 −4 Original line number Original line Diff line number Diff line Loading @@ -2388,7 +2388,7 @@ public final class ActivityManagerService extends ActivityManagerNative intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setComponent(new ComponentName( intent.setComponent(new ComponentName( ri.activityInfo.packageName, ri.activityInfo.name)); ri.activityInfo.packageName, ri.activityInfo.name)); getMainStack().startActivityLocked(null, intent, null, ri.activityInfo, mStackSupervisor.startActivityLocked(null, intent, null, ri.activityInfo, null, null, 0, 0, 0, null, 0, null, false, null); null, null, 0, 0, 0, null, 0, null, false, null); } } } } Loading Loading @@ -2700,7 +2700,7 @@ public final class ActivityManagerService extends ActivityManagerNative } } final long origId = Binder.clearCallingIdentity(); final long origId = Binder.clearCallingIdentity(); int res = r.task.stack.startActivityLocked(r.app.thread, intent, int res = mStackSupervisor.startActivityLocked(r.app.thread, intent, r.resolvedType, aInfo, resultTo != null ? resultTo.appToken : null, r.resolvedType, aInfo, resultTo != null ? resultTo.appToken : null, resultWho, requestCode, -1, r.launchedFromUid, r.launchedFromPackage, 0, resultWho, requestCode, -1, r.launchedFromUid, r.launchedFromPackage, 0, options, false, null); options, false, null); Loading Loading @@ -3767,7 +3767,8 @@ public final class ActivityManagerService extends ActivityManagerNative return infos; return infos; } } public long[] getProcessPss(int[] pids) throws RemoteException { @Override public long[] getProcessPss(int[] pids) { enforceNotIsolatedCaller("getProcessPss"); enforceNotIsolatedCaller("getProcessPss"); long[] pss = new long[pids.length]; long[] pss = new long[pids.length]; for (int i=pids.length-1; i>=0; i--) { for (int i=pids.length-1; i>=0; i--) { Loading @@ -3776,6 +3777,7 @@ public final class ActivityManagerService extends ActivityManagerNative return pss; return pss; } } @Override public void killApplicationProcess(String processName, int uid) { public void killApplicationProcess(String processName, int uid) { if (processName == null) { if (processName == null) { return; return; Loading Loading @@ -4214,7 +4216,7 @@ public final class ActivityManagerService extends ActivityManagerNative mHandler.removeMessages(PROC_START_TIMEOUT_MSG, app); mHandler.removeMessages(PROC_START_TIMEOUT_MSG, app); boolean normalMode = mProcessesReady || isAllowedWhileBooting(app.info); boolean normalMode = mProcessesReady || isAllowedWhileBooting(app.info); List providers = normalMode ? generateApplicationProvidersLocked(app) : null; List<ProviderInfo> providers = normalMode ? generateApplicationProvidersLocked(app) : null; if (!normalMode) { if (!normalMode) { Slog.i(TAG, "Launching preboot mode app: " + app); Slog.i(TAG, "Launching preboot mode app: " + app); Loading Loading @@ -4360,6 +4362,7 @@ public final class ActivityManagerService extends ActivityManagerNative return true; return true; } } @Override public final void attachApplication(IApplicationThread thread) { public final void attachApplication(IApplicationThread thread) { synchronized (this) { synchronized (this) { int callingPid = Binder.getCallingPid(); int callingPid = Binder.getCallingPid(); Loading
services/java/com/android/server/am/ActivityStack.java +1 −184 Original line number Original line Diff line number Diff line Loading @@ -2157,189 +2157,6 @@ final class ActivityStack { newTop.frontOfTask = true; newTop.frontOfTask = true; } } final int startActivityLocked(IApplicationThread caller, Intent intent, String resolvedType, ActivityInfo aInfo, IBinder resultTo, String resultWho, int requestCode, int callingPid, int callingUid, String callingPackage, int startFlags, Bundle options, boolean componentSpecified, ActivityRecord[] outActivity) { int err = ActivityManager.START_SUCCESS; ProcessRecord callerApp = null; if (caller != null) { callerApp = mService.getRecordForAppLocked(caller); if (callerApp != null) { callingPid = callerApp.pid; callingUid = callerApp.info.uid; } else { Slog.w(TAG, "Unable to find app for caller " + caller + " (pid=" + callingPid + ") when starting: " + intent.toString()); err = ActivityManager.START_PERMISSION_DENIED; } } if (err == ActivityManager.START_SUCCESS) { final int userId = aInfo != null ? UserHandle.getUserId(aInfo.applicationInfo.uid) : 0; Slog.i(TAG, "START u" + userId + " {" + intent.toShortString(true, true, true, false) + "} from pid " + (callerApp != null ? callerApp.pid : callingPid)); } ActivityRecord sourceRecord = null; ActivityRecord resultRecord = null; if (resultTo != null) { sourceRecord = isInStackLocked(resultTo); if (DEBUG_RESULTS) Slog.v( TAG, "Will send result to " + resultTo + " " + sourceRecord); if (sourceRecord != null) { if (requestCode >= 0 && !sourceRecord.finishing) { resultRecord = sourceRecord; } } } int launchFlags = intent.getFlags(); if ((launchFlags&Intent.FLAG_ACTIVITY_FORWARD_RESULT) != 0 && sourceRecord != null) { // Transfer the result target from the source activity to the new // one being started, including any failures. if (requestCode >= 0) { ActivityOptions.abort(options); return ActivityManager.START_FORWARD_AND_REQUEST_CONFLICT; } resultRecord = sourceRecord.resultTo; resultWho = sourceRecord.resultWho; requestCode = sourceRecord.requestCode; sourceRecord.resultTo = null; if (resultRecord != null) { resultRecord.removeResultsLocked( sourceRecord, resultWho, requestCode); } } if (err == ActivityManager.START_SUCCESS && intent.getComponent() == null) { // We couldn't find a class that can handle the given Intent. // That's the end of that! err = ActivityManager.START_INTENT_NOT_RESOLVED; } if (err == ActivityManager.START_SUCCESS && aInfo == null) { // We couldn't find the specific class specified in the Intent. // Also the end of the line. err = ActivityManager.START_CLASS_NOT_FOUND; } if (err != ActivityManager.START_SUCCESS) { if (resultRecord != null) { sendActivityResultLocked(-1, resultRecord, resultWho, requestCode, Activity.RESULT_CANCELED, null); } mStackSupervisor.setDismissKeyguard(false); ActivityOptions.abort(options); return err; } final int startAnyPerm = mService.checkPermission( START_ANY_ACTIVITY, callingPid, callingUid); final int componentPerm = mService.checkComponentPermission(aInfo.permission, callingPid, callingUid, aInfo.applicationInfo.uid, aInfo.exported); if (startAnyPerm != PERMISSION_GRANTED && componentPerm != PERMISSION_GRANTED) { if (resultRecord != null) { sendActivityResultLocked(-1, resultRecord, resultWho, requestCode, Activity.RESULT_CANCELED, null); } mStackSupervisor.setDismissKeyguard(false); String msg; if (!aInfo.exported) { msg = "Permission Denial: starting " + intent.toString() + " from " + callerApp + " (pid=" + callingPid + ", uid=" + callingUid + ")" + " not exported from uid " + aInfo.applicationInfo.uid; } else { msg = "Permission Denial: starting " + intent.toString() + " from " + callerApp + " (pid=" + callingPid + ", uid=" + callingUid + ")" + " requires " + aInfo.permission; } Slog.w(TAG, msg); throw new SecurityException(msg); } if (mStackSupervisor.isMainStack(this)) { if (mService.mController != null) { boolean abort = false; try { // The Intent we give to the watcher has the extra data // stripped off, since it can contain private information. Intent watchIntent = intent.cloneFilter(); abort = !mService.mController.activityStarting(watchIntent, aInfo.applicationInfo.packageName); } catch (RemoteException e) { mService.mController = null; } if (abort) { if (resultRecord != null) { sendActivityResultLocked(-1, resultRecord, resultWho, requestCode, Activity.RESULT_CANCELED, null); } // We pretend to the caller that it was really started, but // they will just get a cancel result. mStackSupervisor.setDismissKeyguard(false); ActivityOptions.abort(options); return ActivityManager.START_SUCCESS; } } } ActivityRecord r = new ActivityRecord(mService, callerApp, callingUid, callingPackage, intent, resolvedType, aInfo, mService.mConfiguration, resultRecord, resultWho, requestCode, componentSpecified); if (outActivity != null) { outActivity[0] = r; } if (mStackSupervisor.isMainStack(this)) { if (mResumedActivity == null || mResumedActivity.info.applicationInfo.uid != callingUid) { if (!mService.checkAppSwitchAllowedLocked(callingPid, callingUid, "Activity start")) { PendingActivityLaunch pal = new PendingActivityLaunch(r, sourceRecord, startFlags, this); mService.mPendingActivityLaunches.add(pal); mStackSupervisor.setDismissKeyguard(false); ActivityOptions.abort(options); return ActivityManager.START_SWITCHES_CANCELED; } } if (mService.mDidAppSwitch) { // This is the second allowed switch since we stopped switches, // so now just generally allow switches. Use case: user presses // home (switches disabled, switch to home, mDidAppSwitch now true); // user taps a home icon (coming from home so allowed, we hit here // and now allow anyone to switch again). mService.mAppSwitchesAllowedTime = 0; } else { mService.mDidAppSwitch = true; } } mService.doPendingActivityLaunchesLocked(false); err = startActivityUncheckedLocked(r, sourceRecord, startFlags, true, options); if (mPausingActivity == null) { // Someone asked to have the keyguard dismissed on the next // activity start, but we are not actually doing an activity // switch... just dismiss the keyguard now, because we // probably want to see whatever is behind it. mStackSupervisor.dismissKeyguard(); } return err; } final void moveHomeToFrontFromLaunchLocked(int launchFlags) { final void moveHomeToFrontFromLaunchLocked(int launchFlags) { if ((launchFlags & if ((launchFlags & (Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_TASK_ON_HOME)) (Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_TASK_ON_HOME)) Loading Loading @@ -3369,7 +3186,7 @@ final class ActivityStack { try { try { ActivityInfo aInfo = AppGlobals.getPackageManager().getActivityInfo( ActivityInfo aInfo = AppGlobals.getPackageManager().getActivityInfo( destIntent.getComponent(), 0, srec.userId); destIntent.getComponent(), 0, srec.userId); int res = startActivityLocked(srec.app.thread, destIntent, int res = mStackSupervisor.startActivityLocked(srec.app.thread, destIntent, null, aInfo, parent.appToken, null, null, aInfo, parent.appToken, null, 0, -1, parent.launchedFromUid, parent.launchedFromPackage, 0, -1, parent.launchedFromUid, parent.launchedFromPackage, 0, null, true, null); 0, null, true, null); Loading
services/java/com/android/server/am/ActivityStackSupervisor.java +198 −3 Original line number Original line Diff line number Diff line Loading @@ -16,8 +16,11 @@ package com.android.server.am; package com.android.server.am; import static android.Manifest.permission.START_ANY_ACTIVITY; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static com.android.server.am.ActivityManagerService.localLOGV; import static com.android.server.am.ActivityManagerService.localLOGV; import static com.android.server.am.ActivityManagerService.DEBUG_CONFIGURATION; import static com.android.server.am.ActivityManagerService.DEBUG_CONFIGURATION; import static com.android.server.am.ActivityManagerService.DEBUG_RESULTS; import static com.android.server.am.ActivityManagerService.DEBUG_SWITCH; import static com.android.server.am.ActivityManagerService.DEBUG_SWITCH; import static com.android.server.am.ActivityManagerService.TAG; import static com.android.server.am.ActivityManagerService.TAG; Loading Loading @@ -49,10 +52,12 @@ import android.os.Message; import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.RemoteException; import android.os.SystemClock; import android.os.SystemClock; import android.os.UserHandle; import android.util.EventLog; import android.util.EventLog; import android.util.Slog; import android.util.Slog; import com.android.internal.app.HeavyWeightSwitcherActivity; import com.android.internal.app.HeavyWeightSwitcherActivity; import com.android.server.am.ActivityManagerService.PendingActivityLaunch; import com.android.server.am.ActivityStack.ActivityState; import com.android.server.am.ActivityStack.ActivityState; import java.io.FileDescriptor; import java.io.FileDescriptor; Loading Loading @@ -146,6 +151,16 @@ public class ActivityStackSupervisor { return null; return null; } } ActivityRecord isInAnyStackLocked(IBinder token) { for (int stackNdx = mStacks.size() - 1; stackNdx >= 0; --stackNdx) { final ActivityRecord r = mStacks.get(stackNdx).isInStackLocked(token); if (r != null) { return r; } } return null; } int getNextTaskId() { int getNextTaskId() { do { do { mCurTaskId++; mCurTaskId++; Loading Loading @@ -258,7 +273,7 @@ public class ActivityStackSupervisor { } } void startHomeActivity(Intent intent, ActivityInfo aInfo) { void startHomeActivity(Intent intent, ActivityInfo aInfo) { mHomeStack.startActivityLocked(null, intent, null, aInfo, null, null, 0, 0, 0, null, 0, startActivityLocked(null, intent, null, aInfo, null, null, 0, 0, 0, null, 0, null, false, null); null, false, null); } } Loading Loading @@ -368,7 +383,7 @@ public class ActivityStackSupervisor { } } } } int res = mMainStack.startActivityLocked(caller, intent, resolvedType, int res = startActivityLocked(caller, intent, resolvedType, aInfo, resultTo, resultWho, requestCode, callingPid, callingUid, aInfo, resultTo, resultWho, requestCode, callingPid, callingUid, callingPackage, startFlags, options, componentSpecified, null); callingPackage, startFlags, options, componentSpecified, null); Loading Loading @@ -484,7 +499,7 @@ public class ActivityStackSupervisor { } else { } else { theseOptions = null; theseOptions = null; } } int res = mMainStack.startActivityLocked(caller, intent, resolvedTypes[i], int res = startActivityLocked(caller, intent, resolvedTypes[i], aInfo, resultTo, null, -1, callingPid, callingUid, callingPackage, aInfo, resultTo, null, -1, callingPid, callingUid, callingPackage, 0, theseOptions, componentSpecified, outActivity); 0, theseOptions, componentSpecified, outActivity); if (res < 0) { if (res < 0) { Loading Loading @@ -695,6 +710,186 @@ public class ActivityStackSupervisor { "activity", r.intent.getComponent(), false, false); "activity", r.intent.getComponent(), false, false); } } final int startActivityLocked(IApplicationThread caller, Intent intent, String resolvedType, ActivityInfo aInfo, IBinder resultTo, String resultWho, int requestCode, int callingPid, int callingUid, String callingPackage, int startFlags, Bundle options, boolean componentSpecified, ActivityRecord[] outActivity) { int err = ActivityManager.START_SUCCESS; ProcessRecord callerApp = null; if (caller != null) { callerApp = mService.getRecordForAppLocked(caller); if (callerApp != null) { callingPid = callerApp.pid; callingUid = callerApp.info.uid; } else { Slog.w(TAG, "Unable to find app for caller " + caller + " (pid=" + callingPid + ") when starting: " + intent.toString()); err = ActivityManager.START_PERMISSION_DENIED; } } if (err == ActivityManager.START_SUCCESS) { final int userId = aInfo != null ? UserHandle.getUserId(aInfo.applicationInfo.uid) : 0; Slog.i(TAG, "START u" + userId + " {" + intent.toShortString(true, true, true, false) + "} from pid " + (callerApp != null ? callerApp.pid : callingPid)); } ActivityRecord sourceRecord = null; ActivityRecord resultRecord = null; if (resultTo != null) { sourceRecord = isInAnyStackLocked(resultTo); if (DEBUG_RESULTS) Slog.v( TAG, "Will send result to " + resultTo + " " + sourceRecord); if (sourceRecord != null) { if (requestCode >= 0 && !sourceRecord.finishing) { resultRecord = sourceRecord; } } } ActivityStack resultStack = resultRecord == null ? null : resultRecord.task.stack; int launchFlags = intent.getFlags(); if ((launchFlags&Intent.FLAG_ACTIVITY_FORWARD_RESULT) != 0 && sourceRecord != null) { // Transfer the result target from the source activity to the new // one being started, including any failures. if (requestCode >= 0) { ActivityOptions.abort(options); return ActivityManager.START_FORWARD_AND_REQUEST_CONFLICT; } resultRecord = sourceRecord.resultTo; resultWho = sourceRecord.resultWho; requestCode = sourceRecord.requestCode; sourceRecord.resultTo = null; if (resultRecord != null) { resultRecord.removeResultsLocked( sourceRecord, resultWho, requestCode); } } if (err == ActivityManager.START_SUCCESS && intent.getComponent() == null) { // We couldn't find a class that can handle the given Intent. // That's the end of that! err = ActivityManager.START_INTENT_NOT_RESOLVED; } if (err == ActivityManager.START_SUCCESS && aInfo == null) { // We couldn't find the specific class specified in the Intent. // Also the end of the line. err = ActivityManager.START_CLASS_NOT_FOUND; } if (err != ActivityManager.START_SUCCESS) { if (resultRecord != null) { resultStack.sendActivityResultLocked(-1, resultRecord, resultWho, requestCode, Activity.RESULT_CANCELED, null); } setDismissKeyguard(false); ActivityOptions.abort(options); return err; } final int startAnyPerm = mService.checkPermission( START_ANY_ACTIVITY, callingPid, callingUid); final int componentPerm = mService.checkComponentPermission(aInfo.permission, callingPid, callingUid, aInfo.applicationInfo.uid, aInfo.exported); if (startAnyPerm != PERMISSION_GRANTED && componentPerm != PERMISSION_GRANTED) { if (resultRecord != null) { resultStack.sendActivityResultLocked(-1, resultRecord, resultWho, requestCode, Activity.RESULT_CANCELED, null); } setDismissKeyguard(false); String msg; if (!aInfo.exported) { msg = "Permission Denial: starting " + intent.toString() + " from " + callerApp + " (pid=" + callingPid + ", uid=" + callingUid + ")" + " not exported from uid " + aInfo.applicationInfo.uid; } else { msg = "Permission Denial: starting " + intent.toString() + " from " + callerApp + " (pid=" + callingPid + ", uid=" + callingUid + ")" + " requires " + aInfo.permission; } Slog.w(TAG, msg); throw new SecurityException(msg); } if (mService.mController != null) { boolean abort = false; try { // The Intent we give to the watcher has the extra data // stripped off, since it can contain private information. Intent watchIntent = intent.cloneFilter(); abort = !mService.mController.activityStarting(watchIntent, aInfo.applicationInfo.packageName); } catch (RemoteException e) { mService.mController = null; } if (abort) { if (resultRecord != null) { resultStack.sendActivityResultLocked(-1, resultRecord, resultWho, requestCode, Activity.RESULT_CANCELED, null); } // We pretend to the caller that it was really started, but // they will just get a cancel result. setDismissKeyguard(false); ActivityOptions.abort(options); return ActivityManager.START_SUCCESS; } } ActivityRecord r = new ActivityRecord(mService, callerApp, callingUid, callingPackage, intent, resolvedType, aInfo, mService.mConfiguration, resultRecord, resultWho, requestCode, componentSpecified); if (outActivity != null) { outActivity[0] = r; } if (mMainStack.mResumedActivity == null || mMainStack.mResumedActivity.info.applicationInfo.uid != callingUid) { if (!mService.checkAppSwitchAllowedLocked(callingPid, callingUid, "Activity start")) { PendingActivityLaunch pal = new PendingActivityLaunch(r, sourceRecord, startFlags, mMainStack); mService.mPendingActivityLaunches.add(pal); setDismissKeyguard(false); ActivityOptions.abort(options); return ActivityManager.START_SWITCHES_CANCELED; } } if (mService.mDidAppSwitch) { // This is the second allowed switch since we stopped switches, // so now just generally allow switches. Use case: user presses // home (switches disabled, switch to home, mDidAppSwitch now true); // user taps a home icon (coming from home so allowed, we hit here // and now allow anyone to switch again). mService.mAppSwitchesAllowedTime = 0; } else { mService.mDidAppSwitch = true; } mService.doPendingActivityLaunchesLocked(false); err = mMainStack.startActivityUncheckedLocked(r, sourceRecord, startFlags, true, options); if (mMainStack.mPausingActivity == null) { // Someone asked to have the keyguard dismissed on the next // activity start, but we are not actually doing an activity // switch... just dismiss the keyguard now, because we // probably want to see whatever is behind it. dismissKeyguard(); } return err; } void handleAppDiedLocked(ProcessRecord app, boolean restarting) { void handleAppDiedLocked(ProcessRecord app, boolean restarting) { // Just in case. // Just in case. final int numStacks = mStacks.size(); final int numStacks = mStacks.size(); Loading
services/java/com/android/server/am/TaskRecord.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -133,6 +133,7 @@ class TaskRecord extends ThumbnailHolder { } } void addActivityToTop(ActivityRecord r) { void addActivityToTop(ActivityRecord r) { // Remove r first, and if it wasn't already in the list and it's fullscreen, count it. if (!mActivities.remove(r) && r.fullscreen) { if (!mActivities.remove(r) && r.fullscreen) { // Was not previously in list. // Was not previously in list. numFullscreen++; numFullscreen++; Loading