Fix ANR in installed app details.
InstalledAppDetails tries to refreshUi whenever something about a package changes. It does not need to refresh when the changing package is different from what's being displayed. Change-Id: Ib45289c39ee402cf8974bf52c881f44d225b8be5 Fix: 37424866 Test: make RunSettingsRoboTests
This commit is contained in:
@@ -454,6 +454,10 @@ public class InstalledAppDetails extends AppInfoBase
|
||||
|
||||
@Override
|
||||
public void onPackageSizeChanged(String packageName) {
|
||||
if (!TextUtils.equals(packageName, mPackageName)) {
|
||||
Log.d(LOG_TAG, "Package change irrelevant, skipping");
|
||||
return;
|
||||
}
|
||||
refreshUi();
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,6 @@ package com.android.settings.applications;
|
||||
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
@@ -69,6 +68,9 @@ import org.robolectric.util.ReflectionHelpers;
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public final class InstalledAppDetailsTest {
|
||||
|
||||
private static final String PACKAGE_NAME = "test_package_name";
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
@Mock
|
||||
@@ -181,6 +183,24 @@ public final class InstalledAppDetailsTest {
|
||||
verify(mActivity, never()).finishAndRemoveTask();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void packageSizeChange_isOtherPackage_shouldNotRefreshUi() {
|
||||
ReflectionHelpers.setField(mAppDetail, "mPackageName", PACKAGE_NAME);
|
||||
mAppDetail.onPackageSizeChanged("Not_" + PACKAGE_NAME);
|
||||
|
||||
verify(mAppDetail, never()).refreshUi();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void packageSizeChange_isOwnPackage_shouldRefreshUi() {
|
||||
doReturn(Boolean.TRUE).when(mAppDetail).refreshUi();
|
||||
ReflectionHelpers.setField(mAppDetail, "mPackageName", PACKAGE_NAME);
|
||||
|
||||
mAppDetail.onPackageSizeChanged(PACKAGE_NAME);
|
||||
|
||||
verify(mAppDetail).refreshUi();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void launchPowerUsageDetailFragment_shouldNotCrash() {
|
||||
mAppDetail.mBatteryPreference = mBatteryPreference;
|
||||
|
Reference in New Issue
Block a user