Move adding views logic to privateProfileManager
- Have the animation happen according to the state of private space. - Have the transition happen only once by setting the current transition to null at the end of transition and by ensuring where the transitions are allowed. - Removing controller class. - The onClick controls the enablement of the profile. On reset (when getting the transition) is what controls the animation during expand. tldr- In the collapse case: execute() is called -> animation happens -> addPsHeader tldr- Expand case: post() is called -> addPsHeader -> animation happens. Collapse: onClick() -> AACV.onAppsUpdated() that resets & apply/RUNS runnable because EXECUTE -> AAList.onAppsUpdated() (which is called at the same time animating happens which we should cancel and do at end callback) -> AAList.onAppsUpdated() gets called again Expand: onCLick() -> AACV.onAppsUpdated() that resets & apply runnable -> AAList.onAppsUpdated() (no animation running) -> AAList.onAppsUpdated() (no animation running) -> addPrivateSpaceHeader -> then unlockAction() runnable because its posted at this point bug: 326206132 bug: 330444548 bug: 299294792 Test: manually locally and presubmit: https://screenshot.googleplex.com/9wavvwKQ8hY6oUw & https://screenshot.googleplex.com/BiqmidLFjPwS28j video: https://drive.google.com/file/d/1XGhmTncdUFtJj188_l7alGyyNz_fhXNw/view?usp=sharing Scrolling fix before: https://drive.google.com/file/d/1XykDm4UELoCvcwZdj8ZlJ6TszptB8W0W/view?usp=sharing scrolling fix after when not a lot of apps: https://drive.google.com/file/d/1Y4VY1eX7WE8ShSLXRrT56ieBdAuJo_zn/view?usp=sharing scrolling fix after with a lot of apps: https://drive.google.com/file/d/1Y58c-Z9xnU1GILp0Ih-oLORXYkMB-jWn/view?usp=sharing Flag: ACONFIG com.android.launcher3.Flags.private_space_animation Change-Id: I8d03ae60e2c9fe0ec145c4b0a2e9604b9e6e9017
This commit is contained in:
1 parent
75216f9108
commit
136f9d6f8a
9 files changed
+567
-463
No files matched your search
@@ -26,7 +26,7 @@ import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
@@ -80,7 +80,7 @@ public class PrivateProfileManagerTest {
|
||||
|
||||
private PrivateProfileManager mPrivateProfileManager;
|
||||
@Mock
|
||||
private ActivityAllAppsContainerView mActivityAllAppsContainerView;
|
||||
private ActivityAllAppsContainerView mAllApps;
|
||||
@Mock
|
||||
private StatsLogManager mStatsLogManager;
|
||||
@Mock
|
||||
@@ -90,13 +90,13 @@ public class PrivateProfileManagerTest {
|
||||
@Mock
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private AllAppsStore mAllAppsStore;
|
||||
private AllAppsStore<?> mAllAppsStore;
|
||||
@Mock
|
||||
private PackageManager mPackageManager;
|
||||
@Mock
|
||||
private LauncherApps mLauncherApps;
|
||||
|
||||
private boolean mRunnableCalled = false;
|
||||
@Mock
|
||||
private AllAppsRecyclerView mAllAppsRecyclerView;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -105,8 +105,9 @@ public class PrivateProfileManagerTest {
|
||||
.thenReturn(Arrays.asList(MAIN_HANDLE, PRIVATE_HANDLE));
|
||||
when(mUserCache.getUserInfo(Process.myUserHandle())).thenReturn(MAIN_ICON_INFO);
|
||||
when(mUserCache.getUserInfo(PRIVATE_HANDLE)).thenReturn(PRIVATE_ICON_INFO);
|
||||
when(mActivityAllAppsContainerView.getContext()).thenReturn(mContext);
|
||||
when(mActivityAllAppsContainerView.getAppsStore()).thenReturn(mAllAppsStore);
|
||||
when(mAllApps.getContext()).thenReturn(mContext);
|
||||
when(mAllApps.getAppsStore()).thenReturn(mAllAppsStore);
|
||||
when(mAllApps.getActiveRecyclerView()).thenReturn(mAllAppsRecyclerView);
|
||||
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
||||
when(mPackageManager.resolveActivity(any(), any())).thenReturn(new ResolveInfo());
|
||||
when(mContext.getSystemService(LauncherApps.class)).thenReturn(mLauncherApps);
|
||||
@@ -117,7 +118,7 @@ public class PrivateProfileManagerTest {
|
||||
.thenReturn("com.android.launcher3.tests.privateProfileManager");
|
||||
when(mLauncherApps.getPreInstalledSystemPackages(any())).thenReturn(new ArrayList<>());
|
||||
mPrivateProfileManager = new PrivateProfileManager(mUserManager,
|
||||
mActivityAllAppsContainerView, mStatsLogManager, mUserCache);
|
||||
mAllApps, mStatsLogManager, mUserCache);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -134,7 +135,7 @@ public class PrivateProfileManagerTest {
|
||||
public void unlockPrivateProfile_requestsQuietModeAsFalse() throws Exception {
|
||||
when(mAllAppsStore.hasModelFlag(FLAG_PRIVATE_PROFILE_QUIET_MODE_ENABLED)).thenReturn(true);
|
||||
|
||||
mPrivateProfileManager.unlockPrivateProfile(() -> {});
|
||||
mPrivateProfileManager.unlockPrivateProfile();
|
||||
|
||||
awaitTasksCompleted();
|
||||
Mockito.verify(mUserManager).requestQuietModeEnabled(false, PRIVATE_HANDLE);
|
||||
@@ -160,20 +161,36 @@ public class PrivateProfileManagerTest {
|
||||
|
||||
@Test
|
||||
@TestStabilityRule.Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT) // b/320703862
|
||||
public void transitioningToUnlocked_resetCallsPendingRunnable() throws Exception {
|
||||
public void transitioningToUnlocked_resetCallsPostUnlock() throws Exception {
|
||||
PrivateProfileManager privateProfileManager = spy(mPrivateProfileManager);
|
||||
doNothing().when(privateProfileManager).resetPrivateSpaceDecorator(anyInt());
|
||||
when(mAllAppsStore.hasModelFlag(FLAG_PRIVATE_PROFILE_QUIET_MODE_ENABLED))
|
||||
.thenReturn(false);
|
||||
doNothing().when(privateProfileManager).expandPrivateSpace();
|
||||
when(privateProfileManager.getCurrentState()).thenReturn(STATE_DISABLED);
|
||||
mRunnableCalled = false;
|
||||
|
||||
privateProfileManager.unlockPrivateProfile(this::testRunnable);
|
||||
privateProfileManager.unlockPrivateProfile();
|
||||
privateProfileManager.reset();
|
||||
|
||||
awaitTasksCompleted();
|
||||
Mockito.verify(privateProfileManager).applyUnlockRunnable();
|
||||
assertTrue("Unlock Runnable not Invoked", mRunnableCalled);
|
||||
Mockito.verify(privateProfileManager).postUnlock();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestStabilityRule.Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT)
|
||||
public void transitioningToLocked_resetCallsExecuteLock() throws Exception {
|
||||
PrivateProfileManager privateProfileManager = spy(mPrivateProfileManager);
|
||||
doNothing().when(privateProfileManager).resetPrivateSpaceDecorator(anyInt());
|
||||
when(mAllAppsStore.hasModelFlag(FLAG_PRIVATE_PROFILE_QUIET_MODE_ENABLED))
|
||||
.thenReturn(true);
|
||||
doNothing().when(privateProfileManager).expandPrivateSpace();
|
||||
when(privateProfileManager.getCurrentState()).thenReturn(STATE_ENABLED);
|
||||
|
||||
privateProfileManager.lockPrivateProfile();
|
||||
privateProfileManager.reset();
|
||||
|
||||
awaitTasksCompleted();
|
||||
Mockito.verify(privateProfileManager).executeLock();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -191,8 +208,4 @@ public class PrivateProfileManagerTest {
|
||||
private static void awaitTasksCompleted() throws Exception {
|
||||
UI_HELPER_EXECUTOR.submit(() -> null).get();
|
||||
}
|
||||
|
||||
private void testRunnable() {
|
||||
mRunnableCalled = true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user