From 9df879dd029954f3fa203e5a9b000c2fc10da64b Mon Sep 17 00:00:00 2001 From: Ned Burns Date: Thu, 17 Oct 2019 11:42:57 -0400 Subject: [PATCH] Make FeatureFlags a singleton Also fix up some comments related to reboot systemui. Test: atest Change-Id: Ida865d7b80a16333d66249b02dfe55c0d154b5a2 --- .../systemui/statusbar/FeatureFlags.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/FeatureFlags.java b/packages/SystemUI/src/com/android/systemui/statusbar/FeatureFlags.java index f91341f8f4ea8..0679595cef23d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/FeatureFlags.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/FeatureFlags.java @@ -16,16 +16,19 @@ package com.android.systemui.statusbar; +import static com.android.systemui.Dependency.BG_HANDLER_NAME; + import android.annotation.NonNull; import android.os.Handler; import android.os.HandlerExecutor; -import android.os.Looper; import android.provider.DeviceConfig; import android.util.ArrayMap; import java.util.Map; import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; /** * Class to manage simple DeviceConfig-based feature flags. @@ -36,16 +39,22 @@ import javax.inject.Inject; * $ adb shell device_config put systemui * } * - * You will probably need to @{$ adb reboot} afterwards in order for the code to pick up the change. + * You will probably need to restart systemui for the changes to be picked up: + * + * {@code + * $ adb shell am crash com.android.systemui + * } */ +@Singleton public class FeatureFlags { private final Map mCachedDeviceConfigFlags = new ArrayMap<>(); @Inject - public FeatureFlags() { + public FeatureFlags( + @Named(BG_HANDLER_NAME) Handler bgHandler) { DeviceConfig.addOnPropertiesChangedListener( "systemui", - new HandlerExecutor(new Handler(Looper.getMainLooper())), + new HandlerExecutor(bgHandler), this::onPropertiesChanged); }