Merge "Use UiBgExecutor instead of background handler" into rvc-dev
This commit is contained in:
@@ -49,6 +49,7 @@ import javax.inject.Singleton;
|
||||
@Singleton
|
||||
public class HvacController {
|
||||
public static final String TAG = "HvacController";
|
||||
private static final boolean DEBUG = true;
|
||||
|
||||
private final CarServiceProvider mCarServiceProvider;
|
||||
private final Set<TemperatureView> mRegisteredViews = new HashSet<>();
|
||||
@@ -70,6 +71,9 @@ public class HvacController {
|
||||
new HvacKey(propertyId, areaId));
|
||||
if (temperatureViews != null && !temperatureViews.isEmpty()) {
|
||||
float value = (float) val.getValue();
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "onChangeEvent: " + areaId + ":" + propertyId + ":" + value);
|
||||
}
|
||||
for (TemperatureView tempView : temperatureViews) {
|
||||
tempView.setTemp(value);
|
||||
}
|
||||
@@ -145,6 +149,9 @@ public class HvacController {
|
||||
private void initComponent(TemperatureView view) {
|
||||
int id = view.getPropertyId();
|
||||
int zone = view.getAreaId();
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "initComponent: " + zone + ":" + id);
|
||||
}
|
||||
|
||||
try {
|
||||
if (mHvacManager != null
|
||||
|
||||
@@ -44,8 +44,8 @@ import com.android.systemui.R;
|
||||
import com.android.systemui.SystemUI;
|
||||
import com.android.systemui.car.CarDeviceProvisionedController;
|
||||
import com.android.systemui.car.CarDeviceProvisionedListener;
|
||||
import com.android.systemui.dagger.qualifiers.Background;
|
||||
import com.android.systemui.dagger.qualifiers.Main;
|
||||
import com.android.systemui.dagger.qualifiers.UiBackground;
|
||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||
import com.android.systemui.statusbar.AutoHideUiElement;
|
||||
import com.android.systemui.statusbar.CommandQueue;
|
||||
@@ -58,6 +58,7 @@ import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -74,7 +75,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
private final AutoHideController mAutoHideController;
|
||||
private final ButtonSelectionStateListener mButtonSelectionStateListener;
|
||||
private final Handler mMainHandler;
|
||||
private final Handler mBgHandler;
|
||||
private final Executor mUiBgExecutor;
|
||||
private final IStatusBarService mBarService;
|
||||
private final Lazy<KeyguardStateController> mKeyguardStateControllerLazy;
|
||||
private final ButtonSelectionStateController mButtonSelectionStateController;
|
||||
@@ -105,8 +106,10 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
private boolean mDeviceIsSetUpForUser = true;
|
||||
private boolean mIsUserSetupInProgress = false;
|
||||
|
||||
private @BarTransitions.TransitionMode int mStatusBarMode;
|
||||
private @BarTransitions.TransitionMode int mNavigationBarMode;
|
||||
@BarTransitions.TransitionMode
|
||||
private int mStatusBarMode;
|
||||
@BarTransitions.TransitionMode
|
||||
private int mNavigationBarMode;
|
||||
private boolean mStatusBarTransientShown;
|
||||
private boolean mNavBarTransientShown;
|
||||
|
||||
@@ -120,7 +123,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
AutoHideController autoHideController,
|
||||
ButtonSelectionStateListener buttonSelectionStateListener,
|
||||
@Main Handler mainHandler,
|
||||
@Background Handler bgHandler,
|
||||
@UiBackground Executor uiBgExecutor,
|
||||
IStatusBarService barService,
|
||||
Lazy<KeyguardStateController> keyguardStateControllerLazy,
|
||||
ButtonSelectionStateController buttonSelectionStateController,
|
||||
@@ -136,7 +139,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
mAutoHideController = autoHideController;
|
||||
mButtonSelectionStateListener = buttonSelectionStateListener;
|
||||
mMainHandler = mainHandler;
|
||||
mBgHandler = bgHandler;
|
||||
mUiBgExecutor = uiBgExecutor;
|
||||
mBarService = barService;
|
||||
mKeyguardStateControllerLazy = keyguardStateControllerLazy;
|
||||
mButtonSelectionStateController = buttonSelectionStateController;
|
||||
@@ -232,7 +235,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
mActivityManagerWrapper = ActivityManagerWrapper.getInstance();
|
||||
mActivityManagerWrapper.registerTaskStackListener(mButtonSelectionStateListener);
|
||||
|
||||
mBgHandler.post(() -> mCarNavigationBarController.connectToHvac());
|
||||
mUiBgExecutor.execute(mCarNavigationBarController::connectToHvac);
|
||||
|
||||
// Lastly, call to the icon policy to install/update all the icons.
|
||||
// Must be called on the main thread due to the use of observeForever() in
|
||||
|
||||
@@ -21,19 +21,24 @@ import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.RemoteException;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
import android.testing.TestableLooper;
|
||||
import android.testing.TestableResources;
|
||||
import android.util.ArrayMap;
|
||||
import android.view.Display;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.internal.statusbar.IStatusBarService;
|
||||
import com.android.internal.statusbar.RegisterStatusBarResult;
|
||||
import com.android.internal.view.AppearanceRegion;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.car.CarDeviceProvisionedController;
|
||||
@@ -42,6 +47,8 @@ import com.android.systemui.statusbar.phone.AutoHideController;
|
||||
import com.android.systemui.statusbar.phone.PhoneStatusBarPolicy;
|
||||
import com.android.systemui.statusbar.phone.StatusBarIconController;
|
||||
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||
import com.android.systemui.util.concurrency.FakeExecutor;
|
||||
import com.android.systemui.util.time.FakeSystemClock;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -58,7 +65,6 @@ public class CarNavigationBarTest extends SysuiTestCase {
|
||||
private CarNavigationBar mCarNavigationBar;
|
||||
private TestableResources mTestableResources;
|
||||
private Handler mHandler;
|
||||
private Handler mBackgroundHandler;
|
||||
|
||||
@Mock
|
||||
private CarNavigationBarController mCarNavigationBarController;
|
||||
@@ -81,16 +87,38 @@ public class CarNavigationBarTest extends SysuiTestCase {
|
||||
@Mock
|
||||
private StatusBarIconController mIconController;
|
||||
|
||||
private RegisterStatusBarResult mBarResult;
|
||||
private FakeExecutor mUiBgExecutor;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mTestableResources = mContext.getOrCreateTestableResources();
|
||||
mHandler = Handler.getMain();
|
||||
mBackgroundHandler = Handler.createAsync(TestableLooper.get(this).getLooper());
|
||||
mUiBgExecutor = new FakeExecutor(new FakeSystemClock());
|
||||
mBarResult = new RegisterStatusBarResult(
|
||||
/* icons= */ new ArrayMap<>(),
|
||||
/* disabledFlags1= */ 0,
|
||||
/* appearance= */ 0,
|
||||
/* appearanceRegions= */ new AppearanceRegion[]{},
|
||||
/* imeWindowVis= */ 0,
|
||||
/* imeBackDisposition= */ 0,
|
||||
/* showImeSwitcher= */ false,
|
||||
/* disabledFlags2= */ 0,
|
||||
/* imeToken= */ null,
|
||||
/* navbarColorMangedByIme= */ false,
|
||||
/* appFullscreen= */ false,
|
||||
/* appImmersive= */ false,
|
||||
/* transientBarTypes= */ new int[]{});
|
||||
try {
|
||||
when(mBarService.registerStatusBar(any())).thenReturn(mBarResult);
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mCarNavigationBar = new CarNavigationBar(mContext, mTestableResources.getResources(),
|
||||
mCarNavigationBarController, mWindowManager, mDeviceProvisionedController,
|
||||
new CommandQueue(mContext), mAutoHideController, mButtonSelectionStateListener,
|
||||
mHandler, mBackgroundHandler, mBarService, () -> mKeyguardStateController,
|
||||
mHandler, mUiBgExecutor, mBarService, () -> mKeyguardStateController,
|
||||
mButtonSelectionStateController, () -> mIconPolicy, () -> mIconController);
|
||||
}
|
||||
|
||||
@@ -108,7 +136,7 @@ public class CarNavigationBarTest extends SysuiTestCase {
|
||||
verify(mDeviceProvisionedController).addCallback(deviceProvisionedCallbackCaptor.capture());
|
||||
|
||||
deviceProvisionedCallbackCaptor.getValue().onUserSwitched();
|
||||
waitForIdleSync(mBackgroundHandler);
|
||||
waitForIdleSync(mHandler);
|
||||
|
||||
verify(mButtonSelectionStateListener).onTaskStackChanged();
|
||||
}
|
||||
@@ -128,7 +156,7 @@ public class CarNavigationBarTest extends SysuiTestCase {
|
||||
verify(mDeviceProvisionedController).addCallback(deviceProvisionedCallbackCaptor.capture());
|
||||
|
||||
deviceProvisionedCallbackCaptor.getValue().onUserSwitched();
|
||||
waitForIdleSync(mBackgroundHandler);
|
||||
waitForIdleSync(mHandler);
|
||||
|
||||
verify(mCarNavigationBarController).showAllKeyguardButtons(false);
|
||||
}
|
||||
@@ -147,12 +175,12 @@ public class CarNavigationBarTest extends SysuiTestCase {
|
||||
when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(false);
|
||||
verify(mDeviceProvisionedController).addCallback(deviceProvisionedCallbackCaptor.capture());
|
||||
deviceProvisionedCallbackCaptor.getValue().onUserSwitched();
|
||||
waitForIdleSync(mBackgroundHandler);
|
||||
waitForIdleSync(mHandler);
|
||||
when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true);
|
||||
when(mKeyguardStateController.isShowing()).thenReturn(false);
|
||||
|
||||
deviceProvisionedCallbackCaptor.getValue().onUserSetupChanged();
|
||||
waitForIdleSync(mBackgroundHandler);
|
||||
waitForIdleSync(mHandler);
|
||||
|
||||
verify(mCarNavigationBarController).hideAllKeyguardButtons(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user