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

Commit db9165ba authored by Austin Borger's avatar Austin Borger
Browse files

Add new onUidProcAdjChanged callback to be consumed by the camera

service.

The camera service needs to know when individual process oom adj scores
are changed in order to address bug #124224342. When two separate
processes are displayed in split screen and focus is switched between
them, both proc states will remain the same while their oom scores
change. This is a problem if both have access to the camera - we want
only one owner of the camera stream at any given time and for the app
in focus to be the one to own it.

This patch adds a new IUidObserver registration level for individual
process oom score changes. In addition a new callback has been added to
IUidObserver to track these changes.

Change-Id: I68d964f474d20f819f54b614a4e314ce00aac8fb
Bug: 124224342
Test: -- ActivityManagerServiceTest
      -- ActivityManagerProcessStateTest
      -- ActivityManagerFgsBgStartTest
      -- UidObserverControllerTest
      -- NetworkPolicyManagerServiceTest
      -- ShortcutManagerTest2
      -- HintManagerServiceTest
      -- VibrationSettingsTest
      -- CameraEvictionTest#testCamera2AccessCallbackInSplitMode (x100)
parent 177d5bb1
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -767,6 +767,10 @@ public class AppStateTrackerImpl implements AppStateTracker {
        @Override
        public void onUidCachedChanged(int uid, boolean cached) {
        }

        @Override
        public void onUidProcAdjChanged(int uid) {
        }
    }

    private final class AppOpsWatcher extends IAppOpsCallback.Stub {
+3 −0
Original line number Diff line number Diff line
@@ -1009,6 +1009,9 @@ public class JobSchedulerService extends com.android.server.SystemService

        @Override public void onUidCachedChanged(int uid, boolean cached) {
        }

        @Override public void onUidProcAdjChanged(int uid) {
        }
    };

    public Context getTestableContext() {
+4 −0
Original line number Diff line number Diff line
@@ -404,6 +404,10 @@ public final class QuotaController extends StateController {
        @Override
        public void onUidCachedChanged(int uid, boolean cached) {
        }

        @Override
        public void onUidProcAdjChanged(int uid) {
        }
    }

    /**
+4 −0
Original line number Diff line number Diff line
@@ -97,6 +97,10 @@ class ProcessStateModifier extends Modifier {
        @Override
        public void onUidCachedChanged(int uid, boolean cached) {
        }

        @Override
        public void onUidProcAdjChanged(int uid) {
        }
    };

    ProcessStateModifier(@NonNull InternalResourceService irs) {
+6 −0
Original line number Diff line number Diff line
@@ -222,6 +222,9 @@ public class ActivityManager {

        @Override public void onUidCachedChanged(int uid, boolean cached) {
        }

        @Override public void onUidProcAdjChanged(int uid) {
        }
    }

    final ArrayMap<OnUidImportanceListener, UidObserver> mImportanceListeners = new ArrayMap<>();
@@ -825,6 +828,9 @@ public class ActivityManager {
    /** @hide Flag for registerUidObserver: report uid capability has changed. */
    public static final int UID_OBSERVER_CAPABILITY = 1<<5;

    /** @hide Flag for registerUidObserver: report pid oom adj has changed. */
    public static final int UID_OBSERVER_PROC_OOM_ADJ = 1 << 6;

    /** @hide Mode for {@link IActivityManager#isAppStartModeDisabled}: normal free-to-run operation. */
    public static final int APP_START_MODE_NORMAL = 0;

Loading