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

Commit b7f831e2 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Replace screen broadcast receivers with binder cb" into tm-qpr-dev am:...

Merge "Replace screen broadcast receivers with binder cb" into tm-qpr-dev am: 17976479 am: 2d04b1f8

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



Change-Id: If4c5f29e357474f61291a2389cea32d86c74968b
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 5359b460 2d04b1f8
Loading
Loading
Loading
Loading
+30 −17
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.DisplayId;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.model.SysUiState;
import com.android.systemui.navigationbar.NavigationBarComponent.NavigationBarScope;
import com.android.systemui.navigationbar.NavigationModeController.ModeChangedListener;
@@ -211,6 +212,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
    private final NotificationShadeDepthController mNotificationShadeDepthController;
    private final OnComputeInternalInsetsListener mOnComputeInternalInsetsListener;
    private final UserContextProvider mUserContextProvider;
    private final WakefulnessLifecycle mWakefulnessLifecycle;
    private final RegionSamplingHelper mRegionSamplingHelper;
    private final int mNavColorSampleMargin;
    private NavigationBarFrame mFrame;
@@ -451,6 +453,28 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
                }
            };

    private final WakefulnessLifecycle.Observer mWakefulnessObserver =
            new WakefulnessLifecycle.Observer() {
                private void notifyScreenStateChanged(boolean isScreenOn) {
                    notifyNavigationBarScreenOn();
                    mView.onScreenStateChanged(isScreenOn);
                }

                @Override
                public void onStartedWakingUp() {
                    notifyScreenStateChanged(true);
                    if (isGesturalModeOnDefaultDisplay(getContext(), mNavBarMode)) {
                        mRegionSamplingHelper.start(mSamplingBounds);
                    }
                }

                @Override
                public void onFinishedGoingToSleep() {
                    notifyScreenStateChanged(false);
                    mRegionSamplingHelper.stop();
                }
            };

    @Inject
    NavigationBar(
            NavigationBarView navigationBarView,
@@ -491,7 +515,8 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
            NavigationBarTransitions navigationBarTransitions,
            EdgeBackGestureHandler edgeBackGestureHandler,
            Optional<BackAnimation> backAnimation,
            UserContextProvider userContextProvider) {
            UserContextProvider userContextProvider,
            WakefulnessLifecycle wakefulnessLifecycle) {
        super(navigationBarView);
        mFrame = navigationBarFrame;
        mContext = context;
@@ -529,6 +554,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
        mTelecomManagerOptional = telecomManagerOptional;
        mInputMethodManager = inputMethodManager;
        mUserContextProvider = userContextProvider;
        mWakefulnessLifecycle = wakefulnessLifecycle;

        mNavColorSampleMargin = getResources()
                .getDimensionPixelSize(R.dimen.navigation_handle_sample_horizontal_margin);
@@ -682,11 +708,10 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
        prepareNavigationBarView();
        checkNavBarModes();

        IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
        filter.addAction(Intent.ACTION_SCREEN_ON);
        filter.addAction(Intent.ACTION_USER_SWITCHED);
        IntentFilter filter = new IntentFilter(Intent.ACTION_USER_SWITCHED);
        mBroadcastDispatcher.registerReceiverWithHandler(mBroadcastReceiver, filter,
                Handler.getMain(), UserHandle.ALL);
        mWakefulnessLifecycle.addObserver(mWakefulnessObserver);
        notifyNavigationBarScreenOn();

        mOverviewProxyService.addCallback(mOverviewProxyListener);
@@ -737,6 +762,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
        getBarTransitions().destroy();
        mOverviewProxyService.removeCallback(mOverviewProxyListener);
        mBroadcastDispatcher.unregisterReceiver(mBroadcastReceiver);
        mWakefulnessLifecycle.removeObserver(mWakefulnessObserver);
        if (mOrientationHandle != null) {
            resetSecondaryHandle();
            getBarTransitions().removeDarkIntensityListener(mOrientationHandleIntensityListener);
@@ -1619,19 +1645,6 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
                return;
            }
            String action = intent.getAction();
            if (Intent.ACTION_SCREEN_OFF.equals(action)
                    || Intent.ACTION_SCREEN_ON.equals(action)) {
                notifyNavigationBarScreenOn();
                boolean isScreenOn = Intent.ACTION_SCREEN_ON.equals(action);
                mView.onScreenStateChanged(isScreenOn);
                if (isScreenOn) {
                    if (isGesturalModeOnDefaultDisplay(getContext(), mNavBarMode)) {
                        mRegionSamplingHelper.start(mSamplingBounds);
                    }
                } else {
                    mRegionSamplingHelper.stop();
                }
            }
            if (Intent.ACTION_USER_SWITCHED.equals(action)) {
                // The accessibility settings may be different for the new user
                updateAccessibilityStateFlags();
+17 −6
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import com.android.systemui.CoreStartable;
import com.android.systemui.R;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.phone.CentralSurfaces;

@@ -78,6 +79,7 @@ public class PowerUI implements CoreStartable, CommandQueue.Callbacks {

    private final PowerManager mPowerManager;
    private final WarningsUI mWarnings;
    private final WakefulnessLifecycle mWakefulnessLifecycle;
    private InattentiveSleepWarningView mOverlayView;
    private final Configuration mLastConfiguration = new Configuration();
    private int mPlugType = 0;
@@ -107,11 +109,24 @@ public class PowerUI implements CoreStartable, CommandQueue.Callbacks {
    private final BroadcastDispatcher mBroadcastDispatcher;
    private final CommandQueue mCommandQueue;
    private final Lazy<Optional<CentralSurfaces>> mCentralSurfacesOptionalLazy;
    private final WakefulnessLifecycle.Observer mWakefulnessObserver =
            new WakefulnessLifecycle.Observer() {
                @Override
                public void onStartedWakingUp() {
                    mScreenOffTime = -1;
                }

                @Override
                public void onFinishedGoingToSleep() {
                    mScreenOffTime = SystemClock.elapsedRealtime();
                }
            };

    @Inject
    public PowerUI(Context context, BroadcastDispatcher broadcastDispatcher,
            CommandQueue commandQueue, Lazy<Optional<CentralSurfaces>> centralSurfacesOptionalLazy,
            WarningsUI warningsUI, EnhancedEstimates enhancedEstimates,
            WakefulnessLifecycle wakefulnessLifecycle,
            PowerManager powerManager) {
        mContext = context;
        mBroadcastDispatcher = broadcastDispatcher;
@@ -120,6 +135,7 @@ public class PowerUI implements CoreStartable, CommandQueue.Callbacks {
        mWarnings = warningsUI;
        mEnhancedEstimates = enhancedEstimates;
        mPowerManager = powerManager;
        mWakefulnessLifecycle = wakefulnessLifecycle;
    }

    public void start() {
@@ -138,6 +154,7 @@ public class PowerUI implements CoreStartable, CommandQueue.Callbacks {
                false, obs, UserHandle.USER_ALL);
        updateBatteryWarningLevels();
        mReceiver.init();
        mWakefulnessLifecycle.addObserver(mWakefulnessObserver);

        // Check to see if we need to let the user know that the phone previously shut down due
        // to the temperature being too high.
@@ -233,8 +250,6 @@ public class PowerUI implements CoreStartable, CommandQueue.Callbacks {
            IntentFilter filter = new IntentFilter();
            filter.addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
            filter.addAction(Intent.ACTION_BATTERY_CHANGED);
            filter.addAction(Intent.ACTION_SCREEN_OFF);
            filter.addAction(Intent.ACTION_SCREEN_ON);
            filter.addAction(Intent.ACTION_USER_SWITCHED);
            mBroadcastDispatcher.registerReceiverWithHandler(this, filter, mHandler);
            // Force get initial values. Relying on Sticky behavior until API for getting info.
@@ -317,10 +332,6 @@ public class PowerUI implements CoreStartable, CommandQueue.Callbacks {
                            plugged, bucket);
                });

            } else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
                mScreenOffTime = SystemClock.elapsedRealtime();
            } else if (Intent.ACTION_SCREEN_ON.equals(action)) {
                mScreenOffTime = -1;
            } else if (Intent.ACTION_USER_SWITCHED.equals(action)) {
                mWarnings.userSwitched();
            } else {
+5 −1
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ import com.android.systemui.accessibility.SystemActions;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.model.SysUiState;
import com.android.systemui.navigationbar.buttons.ButtonDispatcher;
import com.android.systemui.navigationbar.buttons.DeadZone;
@@ -197,6 +198,8 @@ public class NavigationBarTest extends SysuiTestCase {
    @Mock
    private UserContextProvider mUserContextProvider;
    @Mock
    private WakefulnessLifecycle mWakefulnessLifecycle;
    @Mock
    private Resources mResources;
    private FakeExecutor mFakeExecutor = new FakeExecutor(new FakeSystemClock());
    private DeviceConfigProxyFake mDeviceConfigProxyFake = new DeviceConfigProxyFake();
@@ -474,7 +477,8 @@ public class NavigationBarTest extends SysuiTestCase {
                mNavigationBarTransitions,
                mEdgeBackGestureHandler,
                Optional.of(mock(BackAnimation.class)),
                mUserContextProvider));
                mUserContextProvider,
                mWakefulnessLifecycle));
    }

    private void processAllMessages() {
+3 −1
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import com.android.settingslib.fuelgauge.Estimate;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.power.PowerUI.WarningsUI;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.phone.CentralSurfaces;
@@ -84,6 +85,7 @@ public class PowerUITest extends SysuiTestCase {
    private PowerUI mPowerUI;
    @Mock private EnhancedEstimates mEnhancedEstimates;
    @Mock private PowerManager mPowerManager;
    @Mock private WakefulnessLifecycle mWakefulnessLifecycle;
    @Mock private IThermalService mThermalServiceMock;
    private IThermalEventListener mUsbThermalEventListener;
    private IThermalEventListener mSkinThermalEventListener;
@@ -680,7 +682,7 @@ public class PowerUITest extends SysuiTestCase {
    private void createPowerUi() {
        mPowerUI = new PowerUI(
                mContext, mBroadcastDispatcher, mCommandQueue, mCentralSurfacesOptionalLazy,
                mMockWarnings, mEnhancedEstimates, mPowerManager);
                mMockWarnings, mEnhancedEstimates, mWakefulnessLifecycle, mPowerManager);
        mPowerUI.mThermalService = mThermalServiceMock;
    }