Fix Settings crash after disabling Settings Suggestion

- Settings Suggestion App is responsible for searching, we can not
prevent user disable it. Hide search feature if user disable it.

Fixes: 118805907
Fixes: 117921464
Test: manual
Change-Id: I61c47c52265a6efd79ef2fa60272bf6513e678b1
This commit is contained in:
Raff Tsai
2018-11-05 16:10:19 +08:00
parent 7d704c8798
commit 2928cd4c72
8 changed files with 69 additions and 3 deletions

View File

@@ -93,6 +93,7 @@ public class UtilsTest {
when(mContext.getSystemService(WifiManager.class)).thenReturn(wifiManager);
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
.thenReturn(connectivityManager);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
}
@Test
@@ -200,4 +201,27 @@ public class UtilsTest {
verify(mPackageManager).getApplicationInfoAsUser(eq(PACKAGE_NAME), anyInt(), eq(USER_ID));
verify(mIconDrawableFactory).getBadgedIcon(mApplicationInfo, USER_ID);
}
@Test
public void isPackageEnabled_appEnabled_returnTrue()
throws PackageManager.NameNotFoundException{
mApplicationInfo.enabled = true;
when(mPackageManager.getApplicationInfo(PACKAGE_NAME, 0)).thenReturn(mApplicationInfo);
assertThat(Utils.isPackageEnabled(mContext, PACKAGE_NAME)).isTrue();
}
@Test
public void isPackageEnabled_appDisabled_returnTrue()
throws PackageManager.NameNotFoundException{
mApplicationInfo.enabled = false;
when(mPackageManager.getApplicationInfo(PACKAGE_NAME, 0)).thenReturn(mApplicationInfo);
assertThat(Utils.isPackageEnabled(mContext, PACKAGE_NAME)).isFalse();
}
@Test
public void isPackageEnabled_noApp_returnFalse() {
assertThat(Utils.isPackageEnabled(mContext, PACKAGE_NAME)).isFalse();
}
}