Fixing Launcher crases due to methods being called on Ui Threads.

This CL fixes the following two issues:
1. Launcher crashing while calling `addPrivateSpaceSettingsButton` from
   BaseAllAppsAdapter as the thread is UI
2. Decorator is not removed from Private Space Header during reset to
   paused state. https://screenshot.googleplex.com/BZdLqaZQwdDApfV

Flag: ACONFIG com.android.launcher3.Flags.enable_private_space DEVELOPMENT
Bug: 311337961, 311342946
Test: Ran Launcher3 tests
Change-Id: I2763338ebf0f5468ad38f61a781e8a8334194c5c
This commit is contained in:
Himanshu Gupta
2023-11-16 17:24:37 +00:00
parent 172eb5896b
commit 2b5620b295
4 changed files with 31 additions and 10 deletions

View File

@@ -22,6 +22,7 @@ import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_PRIVATE_PRO
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.spy;
@@ -29,6 +30,8 @@ import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
@@ -75,6 +78,8 @@ public class PrivateProfileManagerTest {
private Context mContext;
@Mock
private AllAppsStore mAllAppsStore;
@Mock
private PackageManager mPackageManager;
@Before
public void setUp() {
@@ -85,6 +90,8 @@ public class PrivateProfileManagerTest {
when(mUserCache.getUserInfo(PRIVATE_HANDLE)).thenReturn(PRIVATE_ICON_INFO);
when(mActivityAllAppsContainerView.getContext()).thenReturn(mContext);
when(mActivityAllAppsContainerView.getAppsStore()).thenReturn(mAllAppsStore);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
when(mPackageManager.resolveActivity(any(), any())).thenReturn(new ResolveInfo());
mPrivateProfileManager = new PrivateProfileManager(mUserManager,
mActivityAllAppsContainerView, mStatsLogManager, mUserCache);
}