Merge "Fix disabled WebView packages being shown as enabled in Dev Setting."
This commit is contained in:
committed by
Android (Google) Code Review
commit
9a8bae0838
@@ -35,8 +35,6 @@ public class DefaultAppInfo {
|
||||
public final ComponentName componentName;
|
||||
public final PackageItemInfo packageItemInfo;
|
||||
public final String summary;
|
||||
// Description for why this item is disabled, if null, the item is enabled.
|
||||
public final String disabledDescription;
|
||||
public final boolean enabled;
|
||||
|
||||
public DefaultAppInfo(int uid, ComponentName cn) {
|
||||
@@ -52,21 +50,19 @@ public class DefaultAppInfo {
|
||||
userId = uid;
|
||||
componentName = cn;
|
||||
this.summary = summary;
|
||||
this.disabledDescription = null;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public DefaultAppInfo(PackageItemInfo info, String description) {
|
||||
public DefaultAppInfo(PackageItemInfo info, String summary, boolean enabled) {
|
||||
userId = UserHandle.myUserId();
|
||||
packageItemInfo = info;
|
||||
componentName = null;
|
||||
summary = null;
|
||||
this.disabledDescription = description;
|
||||
enabled = true;
|
||||
this.summary = summary;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public DefaultAppInfo(PackageItemInfo info) {
|
||||
this(info, null);
|
||||
this(info, null /* summary */, true /* enabled */);
|
||||
}
|
||||
|
||||
public CharSequence loadLabel(PackageManager pm) {
|
||||
|
||||
@@ -116,26 +116,9 @@ public abstract class DefaultAppPickerFragment extends InstrumentedPreferenceFra
|
||||
screen.addPreference(nonePref);
|
||||
}
|
||||
for (Map.Entry<String, DefaultAppInfo> app : mCandidates.entrySet()) {
|
||||
final RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
|
||||
final String appKey = app.getKey();
|
||||
final DefaultAppInfo info = app.getValue();
|
||||
pref.setTitle(info.loadLabel(mPm.getPackageManager()));
|
||||
pref.setIcon(info.loadIcon(mPm.getPackageManager()));
|
||||
pref.setKey(appKey);
|
||||
if (TextUtils.equals(defaultAppKey, appKey)) {
|
||||
pref.setChecked(true);
|
||||
}
|
||||
if (TextUtils.equals(systemDefaultAppKey, appKey)) {
|
||||
pref.setSummary(R.string.system_app);
|
||||
} else if (!TextUtils.isEmpty(info.summary)) {
|
||||
pref.setSummary(info.summary);
|
||||
}
|
||||
if (!TextUtils.isEmpty(app.getValue().disabledDescription)) {
|
||||
pref.setEnabled(false);
|
||||
pref.setSummary(app.getValue().disabledDescription);
|
||||
}
|
||||
pref.setEnabled(info.enabled);
|
||||
pref.setOnClickListener(this);
|
||||
RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
|
||||
configurePreferenceFromAppInfo(
|
||||
pref, app.getKey(), app.getValue(), defaultAppKey, systemDefaultAppKey);
|
||||
screen.addPreference(pref);
|
||||
}
|
||||
mayCheckOnlyRadioButton();
|
||||
@@ -259,4 +242,22 @@ public abstract class DefaultAppPickerFragment extends InstrumentedPreferenceFra
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public RadioButtonPreference configurePreferenceFromAppInfo(RadioButtonPreference pref,
|
||||
String appKey, DefaultAppInfo info, String defaultAppKey, String systemDefaultAppKey) {
|
||||
pref.setTitle(info.loadLabel(mPm.getPackageManager()));
|
||||
pref.setIcon(info.loadIcon(mPm.getPackageManager()));
|
||||
pref.setKey(appKey);
|
||||
if (TextUtils.equals(defaultAppKey, appKey)) {
|
||||
pref.setChecked(true);
|
||||
}
|
||||
if (TextUtils.equals(systemDefaultAppKey, appKey)) {
|
||||
pref.setSummary(R.string.system_app);
|
||||
} else if (!TextUtils.isEmpty(info.summary)) {
|
||||
pref.setSummary(info.summary);
|
||||
}
|
||||
pref.setEnabled(info.enabled);
|
||||
pref.setOnClickListener(this);
|
||||
return pref;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user