Add callback to DozeParameters on alwaysOn change
Previously, the tuner callback would be called on the StatusBar before DozeParameters, so the StatusBar would update with stale information. Instead of relying on the ordering of the tuner, directly register a callback to DozeParameters when the ALWAYS_ON setting is updated. Test: manual, atest SystemUITests Fixes: 186376450 Change-Id: Id3523ea33b451a2f565806cac636dfb59a125b30
This commit is contained in:
@@ -39,6 +39,8 @@ import com.android.systemui.tuner.TunerService;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -62,6 +64,8 @@ public class DozeParameters implements TunerService.Tunable,
|
||||
private final BatteryController mBatteryController;
|
||||
private final FeatureFlags mFeatureFlags;
|
||||
|
||||
private final Set<Callback> mCallbacks = new HashSet<>();
|
||||
|
||||
private boolean mDozeAlwaysOn;
|
||||
private boolean mControlScreenOffAnimation;
|
||||
|
||||
@@ -250,9 +254,26 @@ public class DozeParameters implements TunerService.Tunable,
|
||||
return mResources.getBoolean(R.bool.doze_long_press_uses_prox);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to listen for DozeParameter changes.
|
||||
*/
|
||||
public void addCallback(Callback callback) {
|
||||
mCallbacks.add(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove callback that listens for DozeParameter changes.
|
||||
*/
|
||||
public void removeCallback(Callback callback) {
|
||||
mCallbacks.remove(callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTuningChanged(String key, String newValue) {
|
||||
mDozeAlwaysOn = mAmbientDisplayConfiguration.alwaysOnEnabled(UserHandle.USER_CURRENT);
|
||||
for (Callback callback : mCallbacks) {
|
||||
callback.onAlwaysOnChange();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -270,4 +291,11 @@ public class DozeParameters implements TunerService.Tunable,
|
||||
pw.print("getSelectivelyRegisterSensorsUsingProx(): ");
|
||||
pw.println(getSelectivelyRegisterSensorsUsingProx());
|
||||
}
|
||||
|
||||
interface Callback {
|
||||
/**
|
||||
* Invoked when the value of getAlwaysOn may have changed.
|
||||
*/
|
||||
void onAlwaysOnChange();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,7 +241,6 @@ import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
|
||||
import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler;
|
||||
import com.android.systemui.statusbar.policy.UserInfoControllerImpl;
|
||||
import com.android.systemui.statusbar.policy.UserSwitcherController;
|
||||
import com.android.systemui.tuner.TunerService;
|
||||
import com.android.systemui.volume.VolumeComponent;
|
||||
import com.android.systemui.wmshell.BubblesManager;
|
||||
import com.android.wm.shell.bubbles.Bubbles;
|
||||
@@ -800,7 +799,6 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
OngoingCallController ongoingCallController,
|
||||
SystemStatusAnimationScheduler animationScheduler,
|
||||
PrivacyDotViewController dotViewController,
|
||||
TunerService tunerService,
|
||||
FeatureFlags featureFlags,
|
||||
KeyguardUnlockAnimationController keyguardUnlockAnimationController) {
|
||||
super(context);
|
||||
@@ -886,15 +884,6 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
mDotViewController = dotViewController;
|
||||
mFeatureFlags = featureFlags;
|
||||
|
||||
tunerService.addTunable(
|
||||
(key, newValue) -> {
|
||||
if (key.equals(Settings.Secure.DOZE_ALWAYS_ON)) {
|
||||
updateLightRevealScrimVisibility();
|
||||
}
|
||||
},
|
||||
Settings.Secure.DOZE_ALWAYS_ON
|
||||
);
|
||||
|
||||
mExpansionChangedListeners = new ArrayList<>();
|
||||
|
||||
mBubbleExpandListener =
|
||||
@@ -1038,6 +1027,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
mNotificationShadeWindowViewController,
|
||||
mNotificationPanelViewController,
|
||||
mAmbientIndicationContainer);
|
||||
mDozeParameters.addCallback(this::updateLightRevealScrimVisibility);
|
||||
|
||||
mConfigurationController.addCallback(this);
|
||||
|
||||
|
||||
@@ -103,7 +103,6 @@ import com.android.systemui.statusbar.policy.NetworkController;
|
||||
import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler;
|
||||
import com.android.systemui.statusbar.policy.UserInfoControllerImpl;
|
||||
import com.android.systemui.statusbar.policy.UserSwitcherController;
|
||||
import com.android.systemui.tuner.TunerService;
|
||||
import com.android.systemui.volume.VolumeComponent;
|
||||
import com.android.systemui.wmshell.BubblesManager;
|
||||
import com.android.wm.shell.bubbles.Bubbles;
|
||||
@@ -214,7 +213,6 @@ public interface StatusBarPhoneModule {
|
||||
OngoingCallController ongoingCallController,
|
||||
SystemStatusAnimationScheduler animationScheduler,
|
||||
PrivacyDotViewController dotViewController,
|
||||
TunerService tunerService,
|
||||
FeatureFlags featureFlags,
|
||||
KeyguardUnlockAnimationController keyguardUnlockAnimationController) {
|
||||
return new StatusBar(
|
||||
@@ -301,7 +299,6 @@ public interface StatusBarPhoneModule {
|
||||
ongoingCallController,
|
||||
animationScheduler,
|
||||
dotViewController,
|
||||
tunerService,
|
||||
featureFlags,
|
||||
keyguardUnlockAnimationController);
|
||||
}
|
||||
|
||||
@@ -146,7 +146,6 @@ import com.android.systemui.statusbar.policy.NetworkController;
|
||||
import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler;
|
||||
import com.android.systemui.statusbar.policy.UserInfoControllerImpl;
|
||||
import com.android.systemui.statusbar.policy.UserSwitcherController;
|
||||
import com.android.systemui.tuner.TunerService;
|
||||
import com.android.systemui.util.concurrency.FakeExecutor;
|
||||
import com.android.systemui.util.time.FakeSystemClock;
|
||||
import com.android.systemui.volume.VolumeComponent;
|
||||
@@ -269,7 +268,6 @@ public class StatusBarTest extends SysuiTestCase {
|
||||
@Mock private OngoingCallController mOngoingCallController;
|
||||
@Mock private SystemStatusAnimationScheduler mAnimationScheduler;
|
||||
@Mock private PrivacyDotViewController mDotViewController;
|
||||
@Mock private TunerService mTunerService;
|
||||
@Mock private FeatureFlags mFeatureFlags;
|
||||
@Mock private IWallpaperManager mWallpaperManager;
|
||||
@Mock private KeyguardUnlockAnimationController mKeyguardUnlockAnimationController;
|
||||
@@ -440,7 +438,6 @@ public class StatusBarTest extends SysuiTestCase {
|
||||
mOngoingCallController,
|
||||
mAnimationScheduler,
|
||||
mDotViewController,
|
||||
mTunerService,
|
||||
mFeatureFlags,
|
||||
mKeyguardUnlockAnimationController);
|
||||
when(mKeyguardViewMediator.registerStatusBar(any(StatusBar.class), any(ViewGroup.class),
|
||||
|
||||
Reference in New Issue
Block a user