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

Commit d00b1581 authored by Xin Guan's avatar Xin Guan Committed by Android (Google) Code Review
Browse files

Merge "UsageStats: Remove FLAG_USE_DEDICATED_HANDLER_THREAD" into main

parents 262d119c e61a245f
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -17,14 +17,6 @@ flag {
    bug: "296056771"
}

flag {
    name: "use_dedicated_handler_thread"
    namespace: "backstage_power"
    description: "Flag to use a dedicated thread for usage event process"
    is_fixed_read_only: true
    bug: "299336442"
}

flag {
    name: "filter_based_event_query_api"
    is_exported: true
+4 −15
Original line number Diff line number Diff line
@@ -106,7 +106,6 @@ import android.util.SparseSetArray;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.content.PackageMonitor;
import com.android.internal.os.BackgroundThread;
import com.android.internal.util.CollectionUtils;
import com.android.internal.util.DumpUtils;
import com.android.internal.util.FrameworkStatsLog;
@@ -154,10 +153,6 @@ public class UsageStatsService extends SystemService implements
    public static final boolean ENABLE_TIME_CHANGE_CORRECTION
            = SystemProperties.getBoolean("persist.debug.time_correction", true);

    private static final boolean USE_DEDICATED_HANDLER_THREAD =
            SystemProperties.getBoolean("persist.debug.use_dedicated_handler_thread",
            Flags.useDedicatedHandlerThread());

    static final boolean DEBUG = false; // Never submit with true
    static final boolean DEBUG_RESPONSE_STATS = DEBUG || Log.isLoggable(TAG, Log.DEBUG);
    static final boolean COMPRESS_TIME = false;
@@ -406,18 +401,16 @@ public class UsageStatsService extends SystemService implements

        mAppStandby.addListener(mStandbyChangeListener);

        mPackageMonitor.register(getContext(),
                /* thread= */ USE_DEDICATED_HANDLER_THREAD ? mHandler.getLooper() : null,
        mPackageMonitor.register(getContext(), /* thread= */ mHandler.getLooper(),
                UserHandle.ALL, true);

        IntentFilter filter = new IntentFilter(Intent.ACTION_USER_REMOVED);
        filter.addAction(Intent.ACTION_USER_STARTED);
        getContext().registerReceiverAsUser(new UserActionsReceiver(), UserHandle.ALL, filter,
                null, /* scheduler= */ USE_DEDICATED_HANDLER_THREAD ? mHandler : null);
                null, /* scheduler= */ mHandler);

        getContext().registerReceiverAsUser(new UidRemovedReceiver(), UserHandle.ALL,
                new IntentFilter(ACTION_UID_REMOVED), null,
                /* scheduler= */ USE_DEDICATED_HANDLER_THREAD ? mHandler : null);
                new IntentFilter(ACTION_UID_REMOVED), null, /* scheduler= */ mHandler);

        mRealTimeSnapshot = SystemClock.elapsedRealtime();
        mSystemTimeSnapshot = System.currentTimeMillis();
@@ -509,11 +502,7 @@ public class UsageStatsService extends SystemService implements
    }

    private Handler getUsageEventProcessingHandler() {
        if (USE_DEDICATED_HANDLER_THREAD) {
        return new H(UsageStatsHandlerThread.get().getLooper());
        } else {
            return new H(BackgroundThread.get().getLooper());
        }
    }

    private void onUserUnlocked(int userId) {