Loading packages/SettingsLib/src/com/android/settingslib/applications/AppUtils.java +15 −2 Original line number Diff line number Diff line Loading @@ -286,6 +286,19 @@ public class AppUtils { } } /** * Returns a boolean indicating whether this app is installed or not. * * @param appEntry AppEntry of ApplicationsState. * @return true if the app is in installed state. */ public static boolean isAppInstalled(ApplicationsState.AppEntry appEntry) { if (appEntry == null || appEntry.info == null) { return false; } return (appEntry.info.flags & ApplicationInfo.FLAG_INSTALLED) != 0; } private static void setAppEntryMounted(ApplicationsState.AppEntry appEntry, boolean mounted) { if (appEntry.mounted != mounted) { synchronized (appEntry) { Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/AppUtilsTest.java +22 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,28 @@ public class AppUtilsTest { assertThat(mAppIconCacheManager.get(APP_PACKAGE_NAME, APP_UID)).isNotNull(); } @Test public void isAppInstalled_noAppEntry_shouldReturnFalse() { assertThat(AppUtils.isAppInstalled(null)).isFalse(); } @Test public void isAppInstalled_hasAppEntryWithInstalledFlag_shouldReturnTrue() { final ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class); appEntry.info = new ApplicationInfo(); appEntry.info.flags = ApplicationInfo.FLAG_INSTALLED; assertThat(AppUtils.isAppInstalled(appEntry)).isTrue(); } @Test public void isAppInstalled_hasAppEntryWithoutInstalledFlag_shouldReturnFalse() { final ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class); appEntry.info = new ApplicationInfo(); assertThat(AppUtils.isAppInstalled(appEntry)).isFalse(); } private ApplicationsState.AppEntry createAppEntry(ApplicationInfo appInfo, int id) { ApplicationsState.AppEntry appEntry = new ApplicationsState.AppEntry(mContext, appInfo, id); appEntry.label = "label"; Loading Loading
packages/SettingsLib/src/com/android/settingslib/applications/AppUtils.java +15 −2 Original line number Diff line number Diff line Loading @@ -286,6 +286,19 @@ public class AppUtils { } } /** * Returns a boolean indicating whether this app is installed or not. * * @param appEntry AppEntry of ApplicationsState. * @return true if the app is in installed state. */ public static boolean isAppInstalled(ApplicationsState.AppEntry appEntry) { if (appEntry == null || appEntry.info == null) { return false; } return (appEntry.info.flags & ApplicationInfo.FLAG_INSTALLED) != 0; } private static void setAppEntryMounted(ApplicationsState.AppEntry appEntry, boolean mounted) { if (appEntry.mounted != mounted) { synchronized (appEntry) { Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/AppUtilsTest.java +22 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,28 @@ public class AppUtilsTest { assertThat(mAppIconCacheManager.get(APP_PACKAGE_NAME, APP_UID)).isNotNull(); } @Test public void isAppInstalled_noAppEntry_shouldReturnFalse() { assertThat(AppUtils.isAppInstalled(null)).isFalse(); } @Test public void isAppInstalled_hasAppEntryWithInstalledFlag_shouldReturnTrue() { final ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class); appEntry.info = new ApplicationInfo(); appEntry.info.flags = ApplicationInfo.FLAG_INSTALLED; assertThat(AppUtils.isAppInstalled(appEntry)).isTrue(); } @Test public void isAppInstalled_hasAppEntryWithoutInstalledFlag_shouldReturnFalse() { final ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class); appEntry.info = new ApplicationInfo(); assertThat(AppUtils.isAppInstalled(appEntry)).isFalse(); } private ApplicationsState.AppEntry createAppEntry(ApplicationInfo appInfo, int id) { ApplicationsState.AppEntry appEntry = new ApplicationsState.AppEntry(mContext, appInfo, id); appEntry.label = "label"; Loading