Adding key to individual entries in ManagedServiceSettings so that it can
be linked using an intent. Also updating the icon loading logic so that it handles AdaptiveIcons properly. Test: Manually tested on device Bug: 63418030 Change-Id: I3059e3a562a593bc425d4e778be052ac014a7002
This commit is contained in:
@@ -37,6 +37,7 @@ import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.util.IconDrawableFactory;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
@@ -58,6 +59,7 @@ public abstract class ManagedServiceSettings extends EmptyTextSettings {
|
||||
private DevicePolicyManager mDpm;
|
||||
protected ServiceListing mServiceListing;
|
||||
protected NotificationManager mNm;
|
||||
private IconDrawableFactory mIconDrawableFactory;
|
||||
|
||||
abstract protected Config getConfig();
|
||||
|
||||
@@ -73,6 +75,7 @@ public abstract class ManagedServiceSettings extends EmptyTextSettings {
|
||||
mPm = mContext.getPackageManager();
|
||||
mDpm = (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||
mNm = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mIconDrawableFactory = IconDrawableFactory.newInstance(mContext);
|
||||
mServiceListing = new ServiceListing(mContext, mConfig);
|
||||
mServiceListing.addCallback(new ServiceListing.Callback() {
|
||||
@Override
|
||||
@@ -126,13 +129,15 @@ public abstract class ManagedServiceSettings extends EmptyTextSettings {
|
||||
final String summary = service.loadLabel(mPm).toString();
|
||||
final SwitchPreference pref = new SwitchPreference(getPrefContext());
|
||||
pref.setPersistent(false);
|
||||
pref.setIcon(service.loadIcon(mPm));
|
||||
pref.setIcon(mIconDrawableFactory.getBadgedIcon(service, service.applicationInfo,
|
||||
UserHandle.getUserId(service.applicationInfo.uid)));
|
||||
if (title != null && !title.equals(summary)) {
|
||||
pref.setTitle(title);
|
||||
pref.setSummary(summary);
|
||||
} else {
|
||||
pref.setTitle(summary);
|
||||
}
|
||||
pref.setKey(cn.flattenToString());
|
||||
pref.setChecked(isServiceEnabled(cn));
|
||||
if (managedProfileId != UserHandle.USER_NULL
|
||||
&& !mDpm.isNotificationListenerServicePermitted(
|
||||
|
Reference in New Issue
Block a user