diff --git a/res/values/strings.xml b/res/values/strings.xml
index 77c4e412eeb..f8198a9e1a9 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -10683,13 +10683,11 @@
- @string/game_driver_app_preference_default
- @string/game_driver_app_preference_game_driver
- - @string/game_driver_app_preference_prerelease_driver
- @string/game_driver_app_preference_default
- @string/game_driver_app_preference_game_driver
- - @string/game_driver_app_preference_prerelease_driver
- @string/game_driver_app_preference_system
diff --git a/src/com/android/settings/applications/appinfo/AppStoragePreferenceController.java b/src/com/android/settings/applications/appinfo/AppStoragePreferenceController.java
index d887634a540..b0d49390cd0 100644
--- a/src/com/android/settings/applications/appinfo/AppStoragePreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/AppStoragePreferenceController.java
@@ -31,6 +31,7 @@ import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.applications.AppStorageSettings;
import com.android.settings.applications.FetchPackageStorageAsyncLoader;
+import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.applications.StorageStatsSource;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnPause;
@@ -48,9 +49,12 @@ public class AppStoragePreferenceController extends AppInfoPreferenceControllerB
@Override
public void updateState(Preference preference) {
- final boolean isExternal =
- (mParent.getAppEntry().info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
- preference.setSummary(getStorageSummary(mLastResult, isExternal));
+ final ApplicationsState.AppEntry entry = mParent.getAppEntry();
+ if (entry != null && entry.info != null) {
+ final boolean isExternal =
+ (entry.info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
+ preference.setSummary(getStorageSummary(mLastResult, isExternal));
+ }
}
@Override
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppStoragePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppStoragePreferenceControllerTest.java
index 809d2cfefd1..065544b2f68 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppStoragePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppStoragePreferenceControllerTest.java
@@ -21,6 +21,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -99,6 +100,16 @@ public class AppStoragePreferenceControllerTest {
verify(preference).setSummary(any());
}
+ @Test
+ public void updateState_entryIsNull_shouldNotUpdatePreferenceSummary() {
+ when(mFragment.getAppEntry()).thenReturn(null);
+ Preference preference = mock(Preference.class);
+
+ mController.updateState(preference);
+
+ verify(preference, never()).setSummary(any());
+ }
+
@Test
public void getStorageSummary_shouldWorkForExternal() {
final StorageStatsSource.AppStorageStats stats =
diff --git a/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceControllerTest.java
index f007ce257a2..dd5af2b6045 100644
--- a/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceControllerTest.java
@@ -56,8 +56,7 @@ public class GameDriverAppPreferenceControllerTest {
private static final int DEFAULT = 0;
private static final int GAME_DRIVER = 1;
- private static final int PRERELEASE_DRIVER = 2;
- private static final int SYSTEM = 3;
+ private static final int SYSTEM = 2;
private static final String TEST_APP_NAME = "testApp";
private static final String TEST_PKG_NAME = "testPkg";
@@ -80,6 +79,7 @@ public class GameDriverAppPreferenceControllerTest {
private GameDriverAppPreferenceController mController;
private CharSequence[] mValueList;
private String mDialogTitle;
+ private String mPreferencePrereleaseDriver;
@Before
public void setUp() {
@@ -89,6 +89,8 @@ public class GameDriverAppPreferenceControllerTest {
mValueList =
mContext.getResources().getStringArray(R.array.game_driver_app_preference_values);
mDialogTitle = mContext.getResources().getString(R.string.game_driver_app_preference_title);
+ mPreferencePrereleaseDriver =
+ mContext.getResources().getString(R.string.game_driver_app_preference_prerelease_driver);
}
@Test
@@ -207,9 +209,7 @@ public class GameDriverAppPreferenceControllerTest {
assertThat(preference.getDialogTitle()).isEqualTo(mDialogTitle);
assertThat(preference.getEntries()).isEqualTo(mValueList);
assertThat(preference.getEntryValues()).isEqualTo(mValueList);
- assertThat(preference.getEntry()).isEqualTo(mValueList[PRERELEASE_DRIVER]);
- assertThat(preference.getValue()).isEqualTo(mValueList[PRERELEASE_DRIVER]);
- assertThat(preference.getSummary()).isEqualTo(mValueList[PRERELEASE_DRIVER]);
+ assertThat(preference.getSummary()).isEqualTo(mPreferencePrereleaseDriver);
}
@Test