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