Merge "Connect to hvac in background thread, post status icons init" into rvc-dev
This commit is contained in:
@@ -32,7 +32,6 @@ import android.os.Binder;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.view.Display;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
@@ -47,6 +46,7 @@ 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.shared.system.ActivityManagerWrapper;
|
||||
import com.android.systemui.statusbar.AutoHideUiElement;
|
||||
@@ -76,6 +76,8 @@ 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 IStatusBarService mBarService;
|
||||
private final Lazy<KeyguardStateController> mKeyguardStateControllerLazy;
|
||||
private final ButtonSelectionStateController mButtonSelectionStateController;
|
||||
private final PhoneStatusBarPolicy mIconPolicy;
|
||||
@@ -84,7 +86,6 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
private final int mDisplayId;
|
||||
|
||||
private StatusBarSignalPolicy mSignalPolicy;
|
||||
private IStatusBarService mBarService;
|
||||
private ActivityManagerWrapper mActivityManagerWrapper;
|
||||
|
||||
// If the nav bar should be hidden when the soft keyboard is visible.
|
||||
@@ -121,6 +122,8 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
AutoHideController autoHideController,
|
||||
ButtonSelectionStateListener buttonSelectionStateListener,
|
||||
@Main Handler mainHandler,
|
||||
@Background Handler bgHandler,
|
||||
IStatusBarService barService,
|
||||
Lazy<KeyguardStateController> keyguardStateControllerLazy,
|
||||
ButtonSelectionStateController buttonSelectionStateController,
|
||||
PhoneStatusBarPolicy iconPolicy,
|
||||
@@ -135,6 +138,8 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
mAutoHideController = autoHideController;
|
||||
mButtonSelectionStateListener = buttonSelectionStateListener;
|
||||
mMainHandler = mainHandler;
|
||||
mBgHandler = bgHandler;
|
||||
mBarService = barService;
|
||||
mKeyguardStateControllerLazy = keyguardStateControllerLazy;
|
||||
mButtonSelectionStateController = buttonSelectionStateController;
|
||||
mIconPolicy = iconPolicy;
|
||||
@@ -150,10 +155,6 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
com.android.internal.R.bool.config_automotiveHideNavBarForKeyboard);
|
||||
mBottomNavBarVisible = false;
|
||||
|
||||
// Get bar service.
|
||||
mBarService = IStatusBarService.Stub.asInterface(
|
||||
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
|
||||
|
||||
// Connect into the status bar manager service
|
||||
mCommandQueue.addCallback(this);
|
||||
|
||||
@@ -233,11 +234,15 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
|
||||
mActivityManagerWrapper = ActivityManagerWrapper.getInstance();
|
||||
mActivityManagerWrapper.registerTaskStackListener(mButtonSelectionStateListener);
|
||||
|
||||
mCarNavigationBarController.connectToHvac();
|
||||
mBgHandler.post(() -> mCarNavigationBarController.connectToHvac());
|
||||
|
||||
// Lastly, call to the icon policy to install/update all the icons.
|
||||
mIconPolicy.init();
|
||||
mSignalPolicy = new StatusBarSignalPolicy(mContext, mIconController);
|
||||
// Must be called on the main thread due to the use of observeForever() in
|
||||
// mIconPolicy.init().
|
||||
mMainHandler.post(() -> {
|
||||
mIconPolicy.init();
|
||||
mSignalPolicy = new StatusBarSignalPolicy(mContext, mIconController);
|
||||
});
|
||||
}
|
||||
|
||||
private void restartNavBarsIfNecessary() {
|
||||
|
||||
@@ -33,6 +33,7 @@ import android.view.WindowManager;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.internal.statusbar.IStatusBarService;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.car.CarDeviceProvisionedController;
|
||||
@@ -57,6 +58,7 @@ public class CarNavigationBarTest extends SysuiTestCase {
|
||||
private CarNavigationBar mCarNavigationBar;
|
||||
private TestableResources mTestableResources;
|
||||
private Handler mHandler;
|
||||
private Handler mBackgroundHandler;
|
||||
|
||||
@Mock
|
||||
private CarNavigationBarController mCarNavigationBarController;
|
||||
@@ -69,6 +71,8 @@ public class CarNavigationBarTest extends SysuiTestCase {
|
||||
@Mock
|
||||
private ButtonSelectionStateListener mButtonSelectionStateListener;
|
||||
@Mock
|
||||
private IStatusBarService mBarService;
|
||||
@Mock
|
||||
private KeyguardStateController mKeyguardStateController;
|
||||
@Mock
|
||||
private ButtonSelectionStateController mButtonSelectionStateController;
|
||||
@@ -82,11 +86,12 @@ public class CarNavigationBarTest extends SysuiTestCase {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mTestableResources = mContext.getOrCreateTestableResources();
|
||||
mHandler = Handler.getMain();
|
||||
mBackgroundHandler = Handler.createAsync(TestableLooper.get(this).getLooper());
|
||||
mCarNavigationBar = new CarNavigationBar(mContext, mTestableResources.getResources(),
|
||||
mCarNavigationBarController, mWindowManager, mDeviceProvisionedController,
|
||||
new CommandQueue(mContext), mAutoHideController, mButtonSelectionStateListener,
|
||||
mHandler, () -> mKeyguardStateController, mButtonSelectionStateController,
|
||||
mIconPolicy, mIconController);
|
||||
mHandler, mBackgroundHandler, mBarService, () -> mKeyguardStateController,
|
||||
mButtonSelectionStateController, mIconPolicy, mIconController);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -103,7 +108,7 @@ public class CarNavigationBarTest extends SysuiTestCase {
|
||||
verify(mDeviceProvisionedController).addCallback(deviceProvisionedCallbackCaptor.capture());
|
||||
|
||||
deviceProvisionedCallbackCaptor.getValue().onUserSwitched();
|
||||
waitForIdleSync(mHandler);
|
||||
waitForIdleSync(mBackgroundHandler);
|
||||
|
||||
verify(mButtonSelectionStateListener).onTaskStackChanged();
|
||||
}
|
||||
@@ -123,7 +128,7 @@ public class CarNavigationBarTest extends SysuiTestCase {
|
||||
verify(mDeviceProvisionedController).addCallback(deviceProvisionedCallbackCaptor.capture());
|
||||
|
||||
deviceProvisionedCallbackCaptor.getValue().onUserSwitched();
|
||||
waitForIdleSync(mHandler);
|
||||
waitForIdleSync(mBackgroundHandler);
|
||||
|
||||
verify(mCarNavigationBarController).showAllKeyguardButtons(false);
|
||||
}
|
||||
@@ -142,12 +147,12 @@ public class CarNavigationBarTest extends SysuiTestCase {
|
||||
when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(false);
|
||||
verify(mDeviceProvisionedController).addCallback(deviceProvisionedCallbackCaptor.capture());
|
||||
deviceProvisionedCallbackCaptor.getValue().onUserSwitched();
|
||||
waitForIdleSync(mHandler);
|
||||
waitForIdleSync(mBackgroundHandler);
|
||||
when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true);
|
||||
when(mKeyguardStateController.isShowing()).thenReturn(false);
|
||||
|
||||
deviceProvisionedCallbackCaptor.getValue().onUserSetupChanged();
|
||||
waitForIdleSync(mHandler);
|
||||
waitForIdleSync(mBackgroundHandler);
|
||||
|
||||
verify(mCarNavigationBarController).hideAllKeyguardButtons(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user