Fix the flashing list on Opening link page

The bottom list flashes because it takes some time to create a
DomainAppPreference, where each perference takes around 6ms to load an
icon. When there are, that say, 30 apps installed, then it will take
around 180ms to be ready, which introduces the flashing issue.

In order to tackle icon loading, this CL applies the icon cache
mechanism to speed up the loading time.

Fixes: 222981986
Test: robotest
Change-Id: Ia8f7cbf5af5ea9f694c352ea40ccca47bedb175c
This commit is contained in:
Yi-Ling Chuang
2022-04-29 19:29:02 +08:00
parent 3438e20da1
commit 93f945d516
4 changed files with 43 additions and 17 deletions

View File

@@ -29,7 +29,6 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.verify.domain.DomainVerificationManager;
import android.content.pm.verify.domain.DomainVerificationUserState;
import android.util.IconDrawableFactory;
import com.android.settings.R;
import com.android.settingslib.applications.ApplicationsState;
@@ -49,18 +48,14 @@ public class DomainAppPreferenceControllerTest {
private ApplicationsState.AppEntry mAppEntry;
private Context mContext;
private IconDrawableFactory mIconDrawableFactory;
@Mock
private DomainVerificationManager mDomainVerificationManager;
@Mock
private DomainVerificationUserState mDomainVerificationUserState;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
mIconDrawableFactory = IconDrawableFactory.newInstance(mContext);
mAppEntry = new ApplicationsState.AppEntry(
mContext, createApplicationInfo(mContext.getPackageName()), 0);
when(mContext.getSystemService(DomainVerificationManager.class)).thenReturn(
@@ -75,8 +70,7 @@ public class DomainAppPreferenceControllerTest {
doReturn(domainVerificationUserState).when(
mDomainVerificationManager).getDomainVerificationUserState(anyString());
doReturn(true).when(domainVerificationUserState).isLinkHandlingAllowed();
final DomainAppPreference pref = new DomainAppPreference(
mContext, mIconDrawableFactory, mAppEntry);
final DomainAppPreference pref = new DomainAppPreference(mContext, mAppEntry);
assertThat(pref.getLayoutResource()).isEqualTo(R.layout.preference_app);
}