summaryrefslogtreecommitdiffstats
path: root/services/java/com/android/server/am/ActivityManagerService.java
diff options
context:
space:
mode:
Diffstat (limited to 'services/java/com/android/server/am/ActivityManagerService.java')
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java84
1 files changed, 59 insertions, 25 deletions
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 856ae42..25991f2 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -32,6 +32,7 @@ import android.app.ActivityThread;
import android.app.AlertDialog;
import android.app.ApplicationErrorReport;
import android.app.Dialog;
+import android.app.IActivityController;
import android.app.IActivityWatcher;
import android.app.IApplicationThread;
import android.app.IInstrumentationWatcher;
@@ -76,6 +77,7 @@ import android.os.Parcel;
import android.os.ParcelFileDescriptor;
import android.os.PowerManager;
import android.os.Process;
+import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
@@ -831,8 +833,11 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
String mOrigDebugApp = null;
boolean mOrigWaitForDebugger = false;
boolean mAlwaysFinishActivities = false;
- IActivityWatcher mWatcher = null;
+ IActivityController mController = null;
+ final RemoteCallbackList<IActivityWatcher> mWatchers
+ = new RemoteCallbackList<IActivityWatcher>();
+
/**
* Callback of last caller to {@link #requestPss}.
*/
@@ -1629,7 +1634,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
/**
* This is a simplified version of topRunningActivityLocked that provides a number of
- * optional skip-over modes. It is intended for use with the ActivityWatcher hook only.
+ * optional skip-over modes. It is intended for use with the ActivityController hook only.
*
* @param token If non-null, any history records matching this token will be skipped.
* @param taskId If non-zero, we'll attempt to skip over records with the same task ID.
@@ -1734,10 +1739,9 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
}
ensurePackageDexOpt(r.intent.getComponent().getPackageName());
app.thread.scheduleLaunchActivity(new Intent(r.intent), r,
+ System.identityHashCode(r),
r.info, r.icicle, results, newIntents, !andResume,
isNextTransitionForward());
- // Update usage stats for launched activity
- updateUsageStats(r, true);
} catch (RemoteException e) {
if (r.launchFailed) {
// This is the second time we failed -- finish activity
@@ -2190,6 +2194,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
mHandler.sendMessage(msg);
}
+ reportResumedActivity(next);
+
next.thumbnail = null;
setFocusedActivityLocked(next);
next.resumeKeyDispatchingLocked();
@@ -2460,6 +2466,26 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
}
}
+ private void reportResumedActivity(HistoryRecord r) {
+ //Log.i(TAG, "**** REPORT RESUME: " + r);
+
+ final int identHash = System.identityHashCode(r);
+ updateUsageStats(r, true);
+
+ int i = mWatchers.beginBroadcast();
+ while (i > 0) {
+ i--;
+ IActivityWatcher w = mWatchers.getBroadcastItem(i);
+ if (w != null) {
+ try {
+ w.activityResuming(identHash);
+ } catch (RemoteException e) {
+ }
+ }
+ }
+ mWatchers.finishBroadcast();
+ }
+
/**
* Ensure that the top activity in the stack is resumed.
*
@@ -2648,10 +2674,10 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
EventLog.writeEvent(LOG_AM_RESUME_ACTIVITY,
System.identityHashCode(next),
next.task.taskId, next.shortComponentName);
- updateUsageStats(next, true);
next.app.thread.scheduleResumeActivity(next,
isNextTransitionForward());
+
pauseIfSleepingLocked();
} catch (Exception e) {
@@ -3068,16 +3094,16 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
throw new SecurityException(msg);
}
- if (mWatcher != null) {
+ if (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 = !mWatcher.activityStarting(watchIntent,
+ abort = !mController.activityStarting(watchIntent,
aInfo.applicationInfo.packageName);
} catch (RemoteException e) {
- mWatcher = null;
+ mController = null;
}
if (abort) {
@@ -3974,16 +4000,16 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
}
synchronized(this) {
- if (mWatcher != null) {
+ if (mController != null) {
// Find the first activity that is not finishing.
HistoryRecord next = topRunningActivityLocked(token, 0);
if (next != null) {
// ask watcher if this is allowed
boolean resumeOK = true;
try {
- resumeOK = mWatcher.activityResuming(next.packageName);
+ resumeOK = mController.activityResuming(next.packageName);
} catch (RemoteException e) {
- mWatcher = null;
+ mController = null;
}
if (!resumeOK) {
@@ -4475,9 +4501,9 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
}
}
- if (mWatcher != null) {
+ if (mController != null) {
try {
- int res = mWatcher.appNotResponding(app.processName,
+ int res = mController.appNotResponding(app.processName,
app.pid, info.toString());
if (res != 0) {
if (res < 0) {
@@ -4493,7 +4519,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
}
}
} catch (RemoteException e) {
- mWatcher = null;
+ mController = null;
}
}
@@ -6618,7 +6644,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
}
/**
- * TODO: Add mWatcher hook
+ * TODO: Add mController hook
*/
public void moveTaskToFront(int task) {
enforceCallingPermission(android.Manifest.permission.REORDER_TASKS,
@@ -6763,7 +6789,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
// If we have a watcher, preflight the move before committing to it. First check
// for *other* available tasks, but if none are available, then try again allowing the
// current task to be selected.
- if (mWatcher != null) {
+ if (mController != null) {
HistoryRecord next = topRunningActivityLocked(null, task);
if (next == null) {
next = topRunningActivityLocked(null, 0);
@@ -6772,9 +6798,9 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
// ask watcher if this is allowed
boolean moveOK = true;
try {
- moveOK = mWatcher.activityResuming(next.packageName);
+ moveOK = mController.activityResuming(next.packageName);
} catch (RemoteException e) {
- mWatcher = null;
+ mController = null;
}
if (!moveOK) {
return false;
@@ -7685,14 +7711,22 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
}
}
- public void setActivityWatcher(IActivityWatcher watcher) {
+ public void setActivityController(IActivityController controller) {
enforceCallingPermission(android.Manifest.permission.SET_ACTIVITY_WATCHER,
- "setActivityWatcher()");
+ "setActivityController()");
synchronized (this) {
- mWatcher = watcher;
+ mController = controller;
}
}
+ public void registerActivityWatcher(IActivityWatcher watcher) {
+ mWatchers.register(watcher);
+ }
+
+ public void unregisterActivityWatcher(IActivityWatcher watcher) {
+ mWatchers.unregister(watcher);
+ }
+
public final void enterSafeMode() {
synchronized(this) {
// It only makes sense to do this before the system is ready
@@ -8288,11 +8322,11 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
//Process.sendSignal(MY_PID, Process.SIGNAL_QUIT);
}
- if (mWatcher != null) {
+ if (mController != null) {
try {
String name = r != null ? r.processName : null;
int pid = r != null ? r.pid : Binder.getCallingPid();
- if (!mWatcher.appCrashed(name, pid,
+ if (!mController.appCrashed(name, pid,
shortMsg, longMsg, crashData)) {
Log.w(TAG, "Force-killing crashed app " + name
+ " at watcher's request");
@@ -8300,7 +8334,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
return 0;
}
} catch (RemoteException e) {
- mWatcher = null;
+ mController = null;
}
}
@@ -8727,7 +8761,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
+ " mDebugTransient=" + mDebugTransient
+ " mOrigWaitForDebugger=" + mOrigWaitForDebugger);
pw.println(" mAlwaysFinishActivities=" + mAlwaysFinishActivities
- + " mWatcher=" + mWatcher);
+ + " mController=" + mController);
}
}