diff options
author | 2017-01-31 01:55:54 +0000 | |
---|---|---|
committer | 2017-01-31 01:55:58 +0000 | |
commit | a09a31f99f9d65e1100f8295c2b9db485fe68b07 (patch) | |
tree | 6663daafa55baf9de83d719531e7d970ee381c5b | |
parent | 02f3a5f0e76a54e73f29bf93d88c079beec297cc (diff) | |
parent | ee9e85f12e1bf4864435a1fe395cf31499f90b0a (diff) |
Merge "Remove some unused code around process state reporting."
-rw-r--r-- | core/java/android/app/AppImportanceMonitor.java | 148 | ||||
-rw-r--r-- | core/java/android/app/IProcessObserver.aidl | 3 | ||||
-rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 10 |
3 files changed, 0 insertions, 161 deletions
diff --git a/core/java/android/app/AppImportanceMonitor.java b/core/java/android/app/AppImportanceMonitor.java deleted file mode 100644 index b5cbeeb0d729..000000000000 --- a/core/java/android/app/AppImportanceMonitor.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.app; - -import android.content.Context; -import android.os.Handler; -import android.os.Looper; -import android.os.Message; -import android.os.RemoteException; -import android.util.SparseArray; -import java.util.List; - -/** - * Helper for monitoring the current importance of applications. - * @hide - */ -public class AppImportanceMonitor { - final Context mContext; - - final SparseArray<AppEntry> mApps = new SparseArray<>(); - - static class AppEntry { - final int uid; - final SparseArray<Integer> procs = new SparseArray<>(1); - int importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE; - - AppEntry(int _uid) { - uid = _uid; - } - } - - final IProcessObserver mProcessObserver = new IProcessObserver.Stub() { - @Override - public void onForegroundActivitiesChanged(int pid, int uid, boolean foregroundActivities) { - } - - @Override - public void onProcessStateChanged(int pid, int uid, int procState) { - synchronized (mApps) { - updateImportanceLocked(pid, uid, - ActivityManager.RunningAppProcessInfo.procStateToImportance(procState), - true); - } - } - - @Override - public void onProcessDied(int pid, int uid) { - synchronized (mApps) { - updateImportanceLocked(pid, uid, - ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE, true); - } - } - }; - - static final int MSG_UPDATE = 1; - - final Handler mHandler; - - public AppImportanceMonitor(Context context, Looper looper) { - mContext = context; - mHandler = new Handler(looper) { - @Override - public void handleMessage(Message msg) { - switch (msg.what) { - case MSG_UPDATE: - onImportanceChanged(msg.arg1, msg.arg2&0xffff, msg.arg2>>16); - break; - default: - super.handleMessage(msg); - } - } - }; - ActivityManager am = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE); - try { - ActivityManager.getService().registerProcessObserver(mProcessObserver); - } catch (RemoteException e) { - } - List<ActivityManager.RunningAppProcessInfo> apps = am.getRunningAppProcesses(); - if (apps != null) { - for (int i=0; i<apps.size(); i++) { - ActivityManager.RunningAppProcessInfo app = apps.get(i); - updateImportanceLocked(app.uid, app.pid, app.importance, false); - } - } - } - - public int getImportance(int uid) { - AppEntry ent = mApps.get(uid); - if (ent == null) { - return ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE; - } - return ent.importance; - } - - /** - * Report when an app's importance changed. Called on looper given to constructor. - */ - public void onImportanceChanged(int uid, int importance, int oldImportance) { - } - - void updateImportanceLocked(int uid, int pid, int importance, boolean repChange) { - AppEntry ent = mApps.get(uid); - if (ent == null) { - ent = new AppEntry(uid); - mApps.put(uid, ent); - } - if (importance >= ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE) { - ent.procs.remove(pid); - } else { - ent.procs.put(pid, importance); - } - updateImportanceLocked(ent, repChange); - } - - void updateImportanceLocked(AppEntry ent, boolean repChange) { - int appImp = ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE; - for (int i=0; i<ent.procs.size(); i++) { - int procImp = ent.procs.valueAt(i); - if (procImp < appImp) { - appImp = procImp; - } - } - if (appImp != ent.importance) { - int impCode = appImp | (ent.importance<<16); - ent.importance = appImp; - if (appImp >= ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE) { - mApps.remove(ent.uid); - } - if (repChange) { - mHandler.obtainMessage(MSG_UPDATE, ent.uid, impCode).sendToTarget(); - } - } - } -} diff --git a/core/java/android/app/IProcessObserver.aidl b/core/java/android/app/IProcessObserver.aidl index ecf2c73c32b7..b436aa2bcd0f 100644 --- a/core/java/android/app/IProcessObserver.aidl +++ b/core/java/android/app/IProcessObserver.aidl @@ -18,9 +18,6 @@ package android.app; /** {@hide} */ oneway interface IProcessObserver { - void onForegroundActivitiesChanged(int pid, int uid, boolean foregroundActivities); - void onProcessStateChanged(int pid, int uid, int procState); void onProcessDied(int pid, int uid); - } diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index c08bcefed51e..1b4c87784179 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -1438,7 +1438,6 @@ public class ActivityManagerService extends IActivityManager.Stub static final class ProcessChangeItem { static final int CHANGE_ACTIVITIES = 1<<0; - static final int CHANGE_PROCESS_STATE = 1<<1; int changes; int uid; int pid; @@ -4165,12 +4164,6 @@ public class ActivityManagerService extends IActivityManager.Stub observer.onForegroundActivitiesChanged(item.pid, item.uid, item.foregroundActivities); } - if ((item.changes&ProcessChangeItem.CHANGE_PROCESS_STATE) != 0) { - if (DEBUG_PROCESS_OBSERVERS) Slog.i(TAG_PROCESS_OBSERVERS, - "PROCSTATE CHANGED pid=" + item.pid + " uid=" + item.uid - + ": " + item.processState); - observer.onProcessStateChanged(item.pid, item.uid, item.processState); - } } } catch (RemoteException e) { } @@ -21018,7 +21011,6 @@ public class ActivityManagerService extends IActivityManager.Stub } if (app.repProcState != app.curProcState) { app.repProcState = app.curProcState; - changes |= ProcessChangeItem.CHANGE_PROCESS_STATE; if (app.thread != null) { try { if (false) { @@ -21139,12 +21131,10 @@ public class ActivityManagerService extends IActivityManager.Stub mPendingProcessChanges.add(item); } item.changes |= changes; - item.processState = app.repProcState; item.foregroundActivities = app.repForegroundActivities; if (DEBUG_PROCESS_OBSERVERS) Slog.i(TAG_PROCESS_OBSERVERS, "Item " + Integer.toHexString(System.identityHashCode(item)) + " " + app.toShortString() + ": changes=" + item.changes - + " procState=" + item.processState + " foreground=" + item.foregroundActivities + " type=" + app.adjType + " source=" + app.adjSource + " target=" + app.adjTarget); |