Merge "Hide the app details preference for mainline module apps" into rvc-dev am: cf33b4bc5e
Change-Id: I421103706198203fb7e25aff4a380c0b0ede8df7
diff --git a/src/com/android/settings/applications/appinfo/AppInstallerInfoPreferenceController.java b/src/com/android/settings/applications/appinfo/AppInstallerInfoPreferenceController.java
index bf85676..2e11953 100644
--- a/src/com/android/settings/applications/appinfo/AppInstallerInfoPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/AppInstallerInfoPreferenceController.java
@@ -42,6 +42,11 @@
if (UserManager.get(mContext).isManagedProfile()) {
return DISABLED_FOR_USER;
}
+
+ if (AppUtils.isMainlineModule(mContext, mPackageName)) {
+ return DISABLED_FOR_USER;
+ }
+
return mInstallerLabel != null ? AVAILABLE : DISABLED_FOR_USER;
}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppInstallerInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppInstallerInfoPreferenceControllerTest.java
index 1f85477..00bd5f8 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppInstallerInfoPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppInstallerInfoPreferenceControllerTest.java
@@ -32,6 +32,7 @@
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
+import android.content.pm.ModuleInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
@@ -148,4 +149,16 @@
verify(mPreference, never()).setEnabled(false);
verify(mPreference).setIntent(any(Intent.class));
}
+
+ @Test
+ public void getAvailabilityStatus_isMainlineModule_shouldReturnDisabled()
+ throws PackageManager.NameNotFoundException {
+ when(mUserManager.isManagedProfile()).thenReturn(false);
+ when(mAppInfo.loadLabel(mPackageManager)).thenReturn("Label");
+ mController.setPackageName("Package");
+ when(mPackageManager.getModuleInfo("Package", 0 /* flags */)).thenReturn(new ModuleInfo());
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(
+ BasePreferenceController.DISABLED_FOR_USER);
+ }
}