Merge "Fix a NPE where developer options page crash sometimes." into pi-dev am: d940a680a5
am: aee1191c72
Change-Id: Iac0d2a8551d9c1ba230890dadb1bdf2b6edb12b9
This commit is contained in:
committed by
android-build-merger
commit
d3ff522a0b
@@ -133,6 +133,9 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
@Override
|
||||
public void bindPreferenceToTile(Activity activity, int sourceMetricsCategory, Preference pref,
|
||||
Tile tile, String key, int baseOrder) {
|
||||
if (pref == null) {
|
||||
return;
|
||||
}
|
||||
pref.setTitle(tile.title);
|
||||
if (!TextUtils.isEmpty(key)) {
|
||||
pref.setKey(key);
|
||||
@@ -239,7 +242,7 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
if (tile.icon != null) {
|
||||
preference.setIcon(tile.icon.loadDrawable(preference.getContext()));
|
||||
} else if (tile.metaData != null
|
||||
&& tile.metaData.containsKey(META_DATA_PREFERENCE_ICON_URI))
|
||||
&& tile.metaData.containsKey(META_DATA_PREFERENCE_ICON_URI)) {
|
||||
ThreadUtils.postOnBackgroundThread(() -> {
|
||||
String packageName = null;
|
||||
if (tile.intent != null) {
|
||||
@@ -259,12 +262,12 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
return;
|
||||
}
|
||||
final Icon icon = Icon.createWithResource(iconInfo.first, iconInfo.second);
|
||||
ThreadUtils.postOnMainThread(() -> {
|
||||
preference.setIcon(icon.loadDrawable(preference.getContext()));
|
||||
}
|
||||
ThreadUtils.postOnMainThread(() ->
|
||||
preference.setIcon(icon.loadDrawable(preference.getContext()))
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void launchIntentOrSelectProfile(Activity activity, Tile tile, Intent intent,
|
||||
int sourceMetricCategory) {
|
||||
|
@@ -24,6 +24,7 @@ import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.robolectric.Shadows.shadowOf;
|
||||
|
||||
@@ -214,6 +215,15 @@ public class DashboardFeatureProviderImplTest {
|
||||
.startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindPreference_nullPreference_shouldIgnore() {
|
||||
final Tile tile = mock(Tile.class);
|
||||
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
|
||||
null, tile, "123", Preference.DEFAULT_ORDER);
|
||||
|
||||
verifyZeroInteractions(tile);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindPreference_withNullKeyNullPriority_shouldGenerateKeyAndPriority() {
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
|
Reference in New Issue
Block a user