diff options
| author | Tyler Gunn <tgunn@google.com> | 2021-02-18 20:07:37 -0800 |
|---|---|---|
| committer | Tyler Gunn <tgunn@google.com> | 2021-02-22 23:55:13 +0000 |
| commit | e52128f5dbf46f74410d68649f2356e4bcfd347a (patch) | |
| tree | ee59569201b6ac9d94e462b51a6955b96d3588d3 /tests/src/com | |
| parent | e32724767efce35abd97047fb5bc37005c43007f (diff) | |
| download | platform_packages_services_Telecomm-e52128f5dbf46f74410d68649f2356e4bcfd347a.tar.gz platform_packages_services_Telecomm-e52128f5dbf46f74410d68649f2356e4bcfd347a.tar.bz2 platform_packages_services_Telecomm-e52128f5dbf46f74410d68649f2356e4bcfd347a.zip | |
Fix issue with rebind to dialer on uninstall of app.
Fixed issue where uninstall of a random app while not in car mode would
cause the dialer to disconnect and rebind.
Test: Manually tested by uninstalling an unrelated app and seeing
the problem manifest itself. Applied fix and verified it no longer causes
a problem.
Test: Manually uninstalled active car mode app and ensured fallback to
dialer UX.
Test: Added two new unit tests for this.
Fixes: 174697155
Change-Id: Icd325615dd13ca622c0004d88c2c4b7c57b4152f
(cherry picked from commit 2c1e608b7a6cf5b1c111c63118404f52303d4dd5)
Diffstat (limited to 'tests/src/com')
| -rw-r--r-- | tests/src/com/android/server/telecom/tests/InCallControllerTests.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/src/com/android/server/telecom/tests/InCallControllerTests.java b/tests/src/com/android/server/telecom/tests/InCallControllerTests.java index c15a04fae..8ae823e86 100644 --- a/tests/src/com/android/server/telecom/tests/InCallControllerTests.java +++ b/tests/src/com/android/server/telecom/tests/InCallControllerTests.java @@ -254,6 +254,27 @@ public class InCallControllerTests extends TelecomTestCase { assertFalse(mCarModeTracker.isInCarMode()); } + /** + * Ensure that if we remove a random unrelated app we don't exit car mode. + */ + @SmallTest + @Test + public void testRandomAppRemovalInCarMode() { + setupMockPackageManager(true /* default */, true /* system */, true /* external calls */); + when(mMockCallsManager.getCurrentUserHandle()).thenReturn(mUserHandle); + when(mMockContext.getPackageManager()).thenReturn(mMockPackageManager); + + when(mMockSystemStateHelper.isCarModeOrProjectionActive()).thenReturn(true); + + mSystemStateListener.onCarModeChanged(666, CAR_PKG, true); + verify(mCarModeTracker).handleEnterCarMode(666, CAR_PKG); + assertTrue(mCarModeTracker.isInCarMode()); + + mSystemStateListener.onPackageUninstalled("com.foo.test"); + verify(mCarModeTracker, never()).forceRemove(CAR_PKG); + assertTrue(mCarModeTracker.isInCarMode()); + } + @SmallTest @Test public void testAutomotiveProjectionAppRemoval() { @@ -969,6 +990,31 @@ public class InCallControllerTests extends TelecomTestCase { */ @MediumTest @Test + public void testRandomAppRemovalWhenNotInCarMode() throws Exception { + setupMocks(true /* isExternalCall */); + setupMockPackageManager(true /* default */, true /* system */, true /* external calls */); + // Bind to default dialer. + mInCallController.bindToServices(mMockCall); + + // Uninstall an unrelated app. + mSystemStateListener.onPackageUninstalled("com.joe.stuff"); + + // Bind InCallServices, just once; we should not re-bind to the same app. + ArgumentCaptor<Intent> bindIntentCaptor = ArgumentCaptor.forClass(Intent.class); + verify(mMockContext).bindServiceAsUser( + bindIntentCaptor.capture(), + any(ServiceConnection.class), + eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE + | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS), + eq(UserHandle.CURRENT)); + } + + /** + * Ensures that the {@link InCallController} will bind to a higher priority car mode service + * when one becomes available. + */ + @MediumTest + @Test public void testCarmodeRebindHigherPriority() throws Exception { setupMocks(true /* isExternalCall */); setupMockPackageManager(true /* default */, true /* system */, true /* external calls */); |
