Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7be09b68 authored by Jing Ji's avatar Jing Ji Committed by Android (Google) Code Review
Browse files

Merge "Move the mStrictModeCallbacks to be self-locked" into main

parents 8984924e 3e79e0fb
Loading
Loading
Loading
Loading
+17 −15
Original line number Diff line number Diff line
@@ -730,7 +730,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    /** Whether some specified important processes are allowed to use FIFO priority. */
    boolean mAllowSpecifiedFifoScheduling = true;
    @GuardedBy("this")
    @GuardedBy("mStrictModeCallbacks")
    private final SparseArray<IUnsafeIntentStrictModeCallback>
            mStrictModeCallbacks = new SparseArray<>();
@@ -9535,13 +9535,14 @@ public class ActivityManagerService extends IActivityManager.Stub
     * @param callback The binder used to communicate the violations.
     */
    @Override
    public synchronized void registerStrictModeCallback(IBinder callback) {
        int callingPid = Binder.getCallingPid();
    public void registerStrictModeCallback(IBinder callback) {
        final int callingPid = Binder.getCallingPid();
        synchronized (mStrictModeCallbacks) {
            mStrictModeCallbacks.put(callingPid,
                    IUnsafeIntentStrictModeCallback.Stub.asInterface(callback));
            try {
                callback.linkToDeath(() -> {
                synchronized (ActivityManagerService.this) {
                    synchronized (mStrictModeCallbacks) {
                        mStrictModeCallbacks.remove(callingPid);
                    }
                }, 0);
@@ -9549,6 +9550,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                mStrictModeCallbacks.remove(callingPid);
            }
        }
    }
    // Depending on the policy in effect, there could be a bunch of
    // these in quick succession so we try to batch these together to
@@ -19907,7 +19909,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        public void triggerUnsafeIntentStrictMode(int callingPid, int type, Intent intent) {
            final IUnsafeIntentStrictModeCallback callback;
            final Intent i = intent.cloneFilter();
            synchronized (ActivityManagerService.this) {
            synchronized (mStrictModeCallbacks) {
                callback = mStrictModeCallbacks.get(callingPid);
            }
            if (callback != null) {
@@ -19915,7 +19917,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                    try {
                        callback.onUnsafeIntent(type, i);
                    } catch (RemoteException e) {
                        synchronized (ActivityManagerService.this) {
                        synchronized (mStrictModeCallbacks) {
                            mStrictModeCallbacks.remove(callingPid);
                        }
                    }