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

Commit 4591f801 authored by Sudheer Shanka's avatar Sudheer Shanka Committed by Automerger Merge Worker
Browse files

Merge "Handle uid state changes on the handler thread." into udc-qpr-dev am:...

Merge "Handle uid state changes on the handler thread." into udc-qpr-dev am: ae3fcf13 am: 4afb1946

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24030082



Change-Id: I8e4073971ad98752c0a9e6027fb8a29379d78ece
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 3a1bdd03 4afb1946
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -249,6 +249,7 @@ class BroadcastQueueModernImpl extends BroadcastQueue {
    private static final int MSG_CHECK_HEALTH = 5;
    private static final int MSG_CHECK_PENDING_COLD_START_VALIDITY = 6;
    private static final int MSG_PROCESS_FREEZABLE_CHANGED = 7;
    private static final int MSG_UID_STATE_CHANGED = 8;

    private void enqueueUpdateRunningList() {
        mLocalHandler.removeMessages(MSG_UPDATE_RUNNING_LIST);
@@ -295,6 +296,19 @@ class BroadcastQueueModernImpl extends BroadcastQueue {
                }
                return true;
            }
            case MSG_UID_STATE_CHANGED: {
                final int uid = (int) msg.obj;
                final int procState = msg.arg1;
                synchronized (mService) {
                    if (procState == ActivityManager.PROCESS_STATE_TOP) {
                        mUidForeground.put(uid, true);
                    } else {
                        mUidForeground.delete(uid);
                    }
                    refreshProcessQueuesLocked(uid);
                }
                return true;
            }
        }
        return false;
    };
@@ -672,7 +686,7 @@ class BroadcastQueueModernImpl extends BroadcastQueue {
    @Override
    public void onProcessFreezableChangedLocked(@NonNull ProcessRecord app) {
        mLocalHandler.removeMessages(MSG_PROCESS_FREEZABLE_CHANGED, app);
        mLocalHandler.sendMessage(mHandler.obtainMessage(MSG_PROCESS_FREEZABLE_CHANGED, app));
        mLocalHandler.obtainMessage(MSG_PROCESS_FREEZABLE_CHANGED, app).sendToTarget();
    }

    @Override
@@ -1601,14 +1615,9 @@ class BroadcastQueueModernImpl extends BroadcastQueue {
            @Override
            public void onUidStateChanged(int uid, int procState, long procStateSeq,
                    int capability) {
                synchronized (mService) {
                    if (procState == ActivityManager.PROCESS_STATE_TOP) {
                        mUidForeground.put(uid, true);
                    } else {
                        mUidForeground.delete(uid);
                    }
                    refreshProcessQueuesLocked(uid);
                }
                mLocalHandler.removeMessages(MSG_UID_STATE_CHANGED, uid);
                mLocalHandler.obtainMessage(MSG_UID_STATE_CHANGED, procState, 0, uid)
                        .sendToTarget();
            }
        }, ActivityManager.UID_OBSERVER_PROCSTATE,
                ActivityManager.PROCESS_STATE_TOP, "android");
+6 −0
Original line number Diff line number Diff line
@@ -125,6 +125,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.UnaryOperator;
@@ -707,6 +708,9 @@ public class BroadcastQueueTest {
    private void waitForIdle() throws Exception {
        mLooper.release();
        mQueue.waitForIdle(LOG_WRITER_INFO);
        final CountDownLatch latch = new CountDownLatch(1);
        mHandlerThread.getThreadHandler().post(latch::countDown);
        latch.await();
        mLooper = Objects.requireNonNull(InstrumentationRegistry.getInstrumentation()
                .acquireLooperManager(mHandlerThread.getLooper()));
    }
@@ -2342,6 +2346,7 @@ public class BroadcastQueueTest {

        mUidObserver.onUidStateChanged(receiverGreenApp.info.uid,
                ActivityManager.PROCESS_STATE_TOP, 0, ActivityManager.PROCESS_CAPABILITY_NONE);
        waitForIdle();

        final Intent airplane = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
        final Intent timeTick = new Intent(Intent.ACTION_TIME_TICK);
@@ -2375,6 +2380,7 @@ public class BroadcastQueueTest {

        mUidObserver.onUidStateChanged(receiverGreenApp.info.uid,
                ActivityManager.PROCESS_STATE_TOP, 0, ActivityManager.PROCESS_CAPABILITY_NONE);
        waitForIdle();

        final Intent timeTick = new Intent(Intent.ACTION_TIME_TICK);