Move PreInstalled App List to UserCache.

Bug: 333543006
Test: atest PrivateSpaceHeaderViewTest, AlphabeticalAppsListTest
Flag: NA
Change-Id: I84233c5a6406325d9e641b72ea8455911b46f65f
This commit is contained in:
Himanshu Gupta committed 2024-04-23 15:28:01 +01:00
1 parent 568e0bff90
commit ae4631e6a3
5 files changed
+50 -28

No files matched your search

@@ -71,6 +71,7 @@ import org.mockito.MockitoAnnotations;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
@SmallTest
@RunWith(AndroidJUnit4.class)
@@ -279,10 +280,8 @@ public class PrivateSpaceHeaderViewTest {
when(mAllAppsStore.getApps()).thenReturn(createAppInfoList());
PrivateProfileManager privateProfileManager = spy(mPrivateProfileManager);
when(privateProfileManager.getCurrentState()).thenReturn(STATE_ENABLED);
when(privateProfileManager.splitIntoUserInstalledAndSystemApps())
.thenReturn(iteminfo -> iteminfo.componentName == null
|| !iteminfo.componentName.getPackageName()
.equals(CAMERA_PACKAGE_NAME));
doReturn(splitIntoUserInstalledAndSystemApps()).when(privateProfileManager)
.splitIntoUserInstalledAndSystemApps(any());
doReturn(0).when(privateProfileManager).addPrivateSpaceHeader(any());
doAnswer(answer(this::addPrivateSpaceHeader)).when(privateProfileManager)
.addPrivateSpaceHeader(any());
@@ -316,10 +315,8 @@ public class PrivateSpaceHeaderViewTest {
when(mAllAppsStore.getApps()).thenReturn(createAppInfoList());
PrivateProfileManager privateProfileManager = spy(mPrivateProfileManager);
when(privateProfileManager.getCurrentState()).thenReturn(STATE_ENABLED);
when(privateProfileManager.splitIntoUserInstalledAndSystemApps())
.thenReturn(iteminfo -> iteminfo.componentName == null
|| !iteminfo.componentName.getPackageName()
.equals(CAMERA_PACKAGE_NAME));
doReturn(splitIntoUserInstalledAndSystemApps()).when(privateProfileManager)
.splitIntoUserInstalledAndSystemApps(any());
doReturn(0).when(privateProfileManager).addPrivateSpaceHeader(any());
doAnswer(answer(this::addPrivateSpaceHeader)).when(privateProfileManager)
.addPrivateSpaceHeader(any());
@@ -353,10 +350,8 @@ public class PrivateSpaceHeaderViewTest {
when(mAllAppsStore.getApps()).thenReturn(createAppInfoList());
PrivateProfileManager privateProfileManager = spy(mPrivateProfileManager);
when(privateProfileManager.getCurrentState()).thenReturn(STATE_ENABLED);
when(privateProfileManager.splitIntoUserInstalledAndSystemApps())
.thenReturn(iteminfo -> iteminfo.componentName == null
|| !iteminfo.componentName.getPackageName()
.equals(CAMERA_PACKAGE_NAME));
doReturn(splitIntoUserInstalledAndSystemApps()).when(privateProfileManager)
.splitIntoUserInstalledAndSystemApps(any());
doReturn(0).when(privateProfileManager).addPrivateSpaceHeader(any());
doAnswer(answer(this::addPrivateSpaceHeader)).when(privateProfileManager)
.addPrivateSpaceHeader(any());
@@ -390,10 +385,8 @@ public class PrivateSpaceHeaderViewTest {
when(mAllAppsStore.getApps()).thenReturn(createAppInfoList());
PrivateProfileManager privateProfileManager = spy(mPrivateProfileManager);
when(privateProfileManager.getCurrentState()).thenReturn(STATE_ENABLED);
when(privateProfileManager.splitIntoUserInstalledAndSystemApps())
.thenReturn(iteminfo -> iteminfo.componentName == null
|| !iteminfo.componentName.getPackageName()
.equals(CAMERA_PACKAGE_NAME));
doReturn(splitIntoUserInstalledAndSystemApps()).when(privateProfileManager)
.splitIntoUserInstalledAndSystemApps(any());
doReturn(0).when(privateProfileManager).addPrivateSpaceHeader(any());
doNothing().when(privateProfileManager).addPrivateSpaceInstallAppButton(any());
doReturn(0).when(privateProfileManager).addSystemAppsDivider(any());
@@ -465,4 +458,10 @@ public class PrivateSpaceHeaderViewTest {
}
return appInfos.toArray(AppInfo[]::new);
}
private Predicate<AppInfo> splitIntoUserInstalledAndSystemApps() {
return iteminfo -> iteminfo.componentName == null
|| !iteminfo.componentName.getPackageName()
.equals(CAMERA_PACKAGE_NAME);
}
}