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

Commit efcc8a58 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove flag powerhint_thread_cleanup & cpu_headroom_affinity_check" into main

parents 036e0e50 581376e1
Loading
Loading
Loading
Loading
+22 −36
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import static com.android.internal.util.FrameworkStatsLog.GPU_HEADROOM_REPORTED_
import static com.android.internal.util.FrameworkStatsLog.GPU_HEADROOM_REPORTED__TYPE__AVERAGE;
import static com.android.internal.util.FrameworkStatsLog.GPU_HEADROOM_REPORTED__TYPE__UNKNOWN_CALCULATION_TYPE;
import static com.android.server.power.hint.Flags.adpfSessionTag;
import static com.android.server.power.hint.Flags.powerhintThreadCleanup;
import static com.android.server.power.hint.Flags.resetOnForkEnabled;

import android.Manifest;
@@ -316,13 +315,8 @@ public final class HintManagerService extends SystemService {
    HintManagerService(Context context, Injector injector) {
        super(context);
        mContext = context;
        if (powerhintThreadCleanup()) {
        mCleanUpHandler = new CleanUpHandler(createCleanUpThread().getLooper());
        mNonIsolatedTids = new HashMap<>();
        } else {
            mCleanUpHandler = null;
            mNonIsolatedTids = null;
        }
        if (adpfSessionTag()) {
            mPackageManager = mContext.getPackageManager();
        } else {
@@ -992,7 +986,7 @@ public final class HintManagerService extends SystemService {
            FgThread.getHandler().post(() -> {
                synchronized (mLock) {
                    boolean shouldCleanup = false;
                    if (mPowerHalVersion >= 4 && powerhintThreadCleanup()) {
                    if (mPowerHalVersion >= 4) {
                        int prevProcState = mProcStatesCache.get(uid, Integer.MAX_VALUE);
                        shouldCleanup =
                                prevProcState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND
@@ -1005,7 +999,7 @@ public final class HintManagerService extends SystemService {
                    if (tokenMap == null) {
                        return;
                    }
                    if (shouldCleanup && powerhintThreadCleanup()) {
                    if (shouldCleanup) {
                        final Message msg = mCleanUpHandler.obtainMessage(EVENT_CLEAN_UP_UID,
                                uid);
                        mCleanUpHandler.sendMessageDelayed(msg, CLEAN_UP_UID_DELAY_MILLIS);
@@ -1431,8 +1425,7 @@ public final class HintManagerService extends SystemService {
            }

            try {
                final IntArray nonIsolated = powerhintThreadCleanup() ? new IntArray(tids.length)
                        : null;
                final IntArray nonIsolated = new IntArray(tids.length);
                final Integer invalidTid = checkTidValid(callingUid, callingTgid, tids,
                        nonIsolated);
                if (invalidTid != null) {
@@ -1503,15 +1496,12 @@ public final class HintManagerService extends SystemService {
                            "createHintSession failed: " + e.getMessage());
                    }
                }

                if (powerhintThreadCleanup()) {
                synchronized (mNonIsolatedTidsLock) {
                    for (int i = nonIsolated.size() - 1; i >= 0; i--) {
                        mNonIsolatedTids.putIfAbsent(nonIsolated.get(i), new ArraySet<>());
                        mNonIsolatedTids.get(nonIsolated.get(i)).add(halSessionPtr);
                    }
                }
                }
                AppHintSession hs = null;
                synchronized (mLock) {
                    Integer configId = null;
@@ -2336,7 +2326,6 @@ public final class HintManagerService extends SystemService {
                    }
                }
            }
            if (powerhintThreadCleanup()) {
            synchronized (mNonIsolatedTidsLock) {
                final int[] tids = getTidsInternal();
                for (int tid : tids) {
@@ -2349,7 +2338,6 @@ public final class HintManagerService extends SystemService {
                }
            }
        }
        }

        @Override
        public void sendHint(@PerformanceHintManager.Session.Hint int hint) {
@@ -2409,7 +2397,7 @@ public final class HintManagerService extends SystemService {
                }
                if (checkTid) {
                    final int callingTgid = Process.getThreadGroupLeader(Binder.getCallingPid());
                    final IntArray nonIsolated = powerhintThreadCleanup() ? new IntArray() : null;
                    final IntArray nonIsolated = new IntArray();
                    final long identity = Binder.clearCallingIdentity();
                    try {
                        final Integer invalidTid = checkTidValid(callingUid, callingTgid, tids,
@@ -2439,7 +2427,6 @@ public final class HintManagerService extends SystemService {
                                        + Arrays.toString(tids), e);
                            }
                        }
                        if (powerhintThreadCleanup()) {
                        synchronized (mNonIsolatedTidsLock) {
                            for (int i = nonIsolated.size() - 1; i >= 0; i--) {
                                mNonIsolatedTids.putIfAbsent(nonIsolated.get(i),
@@ -2447,7 +2434,6 @@ public final class HintManagerService extends SystemService {
                                mNonIsolatedTids.get(nonIsolated.get(i)).add(mHalSessionPtr);
                            }
                        }
                        }
                    } finally {
                        Binder.restoreCallingIdentity(identity);
                    }
+0 −14
Original line number Diff line number Diff line
package: "com.android.server.power.hint"
container: "system"

flag {
    name: "powerhint_thread_cleanup"
    namespace: "game"
    description: "Feature flag for auto PowerHintSession dead thread cleanup"
    bug: "296160319"
}

flag {
    name: "adpf_session_tag"
    namespace: "game"
@@ -21,10 +14,3 @@ flag {
    description: "Set reset_on_fork flag."
    bug: "370988407"
}

flag {
    name: "cpu_headroom_affinity_check"
    namespace: "game"
    description: "Check affinity on CPU headroom."
    bug: "346604998"
}
+0 −3
Original line number Diff line number Diff line
@@ -70,7 +70,6 @@ import android.os.PerformanceHintManager;
import android.os.Process;
import android.os.RemoteException;
import android.os.SessionCreationConfig;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.platform.test.flag.junit.SetFlagsRule;
@@ -692,7 +691,6 @@ public class HintManagerServiceTest {
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_POWERHINT_THREAD_CLEANUP)
    public void testNoCleanupDeadThreadsForPrevPowerHalVersion() throws Exception {
        reset(mIPowerMock);
        when(mIPowerMock.getInterfaceVersion()).thenReturn(3);
@@ -730,7 +728,6 @@ public class HintManagerServiceTest {


    @Test
    @RequiresFlagsEnabled(Flags.FLAG_POWERHINT_THREAD_CLEANUP)
    public void testCleanupDeadThreads() throws Exception {
        HintManagerService service = createService();
        IBinder token = new Binder();