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

Commit 31f18be4 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove call to getComponent(StatusBar) from PowerUI."

parents 281fe469 9a22a2f8
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -55,7 +55,11 @@ import java.util.Arrays;
import java.util.concurrent.Future;

import javax.inject.Inject;
import javax.inject.Singleton;

import dagger.Lazy;

@Singleton
public class PowerUI extends SystemUI {

    static final String TAG = "PowerUI";
@@ -101,11 +105,14 @@ public class PowerUI extends SystemUI {
    private IThermalEventListener mSkinThermalEventListener;
    private IThermalEventListener mUsbThermalEventListener;
    private final BroadcastDispatcher mBroadcastDispatcher;
    private final Lazy<StatusBar> mStatusBarLazy;

    @Inject
    public PowerUI(Context context, BroadcastDispatcher broadcastDispatcher) {
    public PowerUI(Context context, BroadcastDispatcher broadcastDispatcher,
            Lazy<StatusBar> statusBarLazy) {
        super(context);
        mBroadcastDispatcher = broadcastDispatcher;
        mStatusBarLazy = statusBarLazy;
    }

    public void start() {
@@ -663,8 +670,7 @@ public class PowerUI extends SystemUI {
            int status = temp.getStatus();

            if (status >= Temperature.THROTTLING_EMERGENCY) {
                StatusBar statusBar = getComponent(StatusBar.class);
                if (statusBar != null && !statusBar.isDeviceInVrMode()) {
                if (!mStatusBarLazy.get().isDeviceInVrMode()) {
                    mWarnings.showHighTemperatureWarning();
                    Slog.d(TAG, "SkinThermalEventListener: notifyThrottling was called "
                            + ", current skin status = " + status
+7 −3
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -60,6 +59,8 @@ import org.mockito.MockitoAnnotations;
import java.time.Duration;
import java.util.concurrent.TimeUnit;

import dagger.Lazy;

@RunWith(AndroidTestingRunner.class)
@RunWithLooper
@SmallTest
@@ -86,6 +87,8 @@ public class PowerUITest extends SysuiTestCase {
    private IThermalEventListener mUsbThermalEventListener;
    private IThermalEventListener mSkinThermalEventListener;
    @Mock private BroadcastDispatcher mBroadcastDispatcher;
    @Mock private Lazy<StatusBar> mStatusBarLazy;
    @Mock private StatusBar mStatusBar;

    @Before
    public void setup() {
@@ -93,7 +96,8 @@ public class PowerUITest extends SysuiTestCase {
        mMockWarnings = mDependency.injectMockDependency(WarningsUI.class);
        mEnhancedEstimates = mDependency.injectMockDependency(EnhancedEstimates.class);

        mContext.putComponent(StatusBar.class, mock(StatusBar.class));
        when(mStatusBarLazy.get()).thenReturn(mStatusBar);

        mContext.addMockSystemService(Context.POWER_SERVICE, mPowerManager);

        createPowerUi();
@@ -682,7 +686,7 @@ public class PowerUITest extends SysuiTestCase {
    }

    private void createPowerUi() {
        mPowerUI = new PowerUI(mContext, mBroadcastDispatcher);
        mPowerUI = new PowerUI(mContext, mBroadcastDispatcher, mStatusBarLazy);
        mPowerUI.mComponents = mContext.getComponents();
        mPowerUI.mThermalService = mThermalServiceMock;
    }