Merge "ActivityManager: Use the default UidObserver implementation." into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
8b1d231b76
@@ -211,7 +211,7 @@ android.app.ActivityManager$RunningTaskInfo$1
|
||||
android.app.ActivityManager$RunningTaskInfo
|
||||
android.app.ActivityManager$TaskDescription$1
|
||||
android.app.ActivityManager$TaskDescription
|
||||
android.app.ActivityManager$UidObserver
|
||||
android.app.ActivityManager$MyUidObserver
|
||||
android.app.ActivityManager
|
||||
android.app.ActivityManagerInternal
|
||||
android.app.ActivityOptions$1
|
||||
|
||||
@@ -211,7 +211,7 @@ android.app.ActivityManager$RunningTaskInfo$1
|
||||
android.app.ActivityManager$RunningTaskInfo
|
||||
android.app.ActivityManager$TaskDescription$1
|
||||
android.app.ActivityManager$TaskDescription
|
||||
android.app.ActivityManager$UidObserver
|
||||
android.app.ActivityManager$MyUidObserver
|
||||
android.app.ActivityManager
|
||||
android.app.ActivityManagerInternal
|
||||
android.app.ActivityOptions$1
|
||||
|
||||
@@ -193,11 +193,11 @@ public class ActivityManager {
|
||||
*/
|
||||
public static final int INSTR_FLAG_INSTRUMENT_SDK_SANDBOX = 1 << 5;
|
||||
|
||||
static final class UidObserver extends IUidObserver.Stub {
|
||||
static final class MyUidObserver extends UidObserver {
|
||||
final OnUidImportanceListener mListener;
|
||||
final Context mContext;
|
||||
|
||||
UidObserver(OnUidImportanceListener listener, Context clientContext) {
|
||||
MyUidObserver(OnUidImportanceListener listener, Context clientContext) {
|
||||
mListener = listener;
|
||||
mContext = clientContext;
|
||||
}
|
||||
@@ -212,23 +212,9 @@ public class ActivityManager {
|
||||
public void onUidGone(int uid, boolean disabled) {
|
||||
mListener.onUidImportance(uid, RunningAppProcessInfo.IMPORTANCE_GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUidActive(int uid) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUidIdle(int uid, boolean disabled) {
|
||||
}
|
||||
|
||||
@Override public void onUidCachedChanged(int uid, boolean cached) {
|
||||
}
|
||||
|
||||
@Override public void onUidProcAdjChanged(int uid) {
|
||||
}
|
||||
}
|
||||
|
||||
final ArrayMap<OnUidImportanceListener, UidObserver> mImportanceListeners = new ArrayMap<>();
|
||||
final ArrayMap<OnUidImportanceListener, MyUidObserver> mImportanceListeners = new ArrayMap<>();
|
||||
|
||||
/**
|
||||
* Map of callbacks that have registered for {@link UidFrozenStateChanged} events.
|
||||
@@ -4273,7 +4259,7 @@ public class ActivityManager {
|
||||
throw new IllegalArgumentException("Listener already registered: " + listener);
|
||||
}
|
||||
// TODO: implement the cut point in the system process to avoid IPCs.
|
||||
UidObserver observer = new UidObserver(listener, mContext);
|
||||
MyUidObserver observer = new MyUidObserver(listener, mContext);
|
||||
try {
|
||||
getService().registerUidObserver(observer,
|
||||
UID_OBSERVER_PROCSTATE | UID_OBSERVER_GONE,
|
||||
@@ -4297,7 +4283,7 @@ public class ActivityManager {
|
||||
@RequiresPermission(Manifest.permission.PACKAGE_USAGE_STATS)
|
||||
public void removeOnUidImportanceListener(OnUidImportanceListener listener) {
|
||||
synchronized (this) {
|
||||
UidObserver observer = mImportanceListeners.remove(listener);
|
||||
MyUidObserver observer = mImportanceListeners.remove(listener);
|
||||
if (observer == null) {
|
||||
throw new IllegalArgumentException("Listener not registered: " + listener);
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ import android.app.IUidObserver;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.UidObserver;
|
||||
import android.app.role.OnRoleHoldersChangedListener;
|
||||
import android.app.role.RoleManager;
|
||||
import android.app.usage.AppStandbyInfo;
|
||||
@@ -1439,7 +1440,7 @@ public final class AppRestrictionController {
|
||||
};
|
||||
|
||||
private final IUidObserver mUidObserver =
|
||||
new IUidObserver.Stub() {
|
||||
new UidObserver() {
|
||||
@Override
|
||||
public void onUidStateChanged(int uid, int procState, long procStateSeq,
|
||||
int capability) {
|
||||
@@ -1463,14 +1464,6 @@ public final class AppRestrictionController {
|
||||
public void onUidActive(int uid) {
|
||||
mBgHandler.obtainMessage(BgHandler.MSG_UID_ACTIVE, uid, 0).sendToTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUidCachedChanged(int uid, boolean cached) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUidProcAdjChanged(int uid) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -70,7 +70,7 @@ import android.app.ApplicationExitInfo.Reason;
|
||||
import android.app.ApplicationExitInfo.SubReason;
|
||||
import android.app.IApplicationThread;
|
||||
import android.app.IProcessObserver;
|
||||
import android.app.IUidObserver;
|
||||
import android.app.UidObserver;
|
||||
import android.compat.annotation.ChangeId;
|
||||
import android.compat.annotation.EnabledAfter;
|
||||
import android.content.BroadcastReceiver;
|
||||
@@ -5281,7 +5281,7 @@ public final class ProcessList {
|
||||
return new Pair<>(numForegroundServices, procs);
|
||||
}
|
||||
|
||||
private final class ImperceptibleKillRunner extends IUidObserver.Stub {
|
||||
private final class ImperceptibleKillRunner extends UidObserver {
|
||||
private static final String EXTRA_PID = "pid";
|
||||
private static final String EXTRA_UID = "uid";
|
||||
private static final String EXTRA_TIMESTAMP = "timestamp";
|
||||
@@ -5536,25 +5536,9 @@ public final class ProcessList {
|
||||
mHandler.obtainMessage(H.MSG_UID_GONE, uid, 0).sendToTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUidActive(int uid) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUidIdle(int uid, boolean disabled) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUidStateChanged(int uid, int procState, long procStateSeq, int capability) {
|
||||
mHandler.obtainMessage(H.MSG_UID_STATE_CHANGED, uid, procState).sendToTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUidCachedChanged(int uid, boolean cached) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUidProcAdjChanged(int uid) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user