Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 48191f73 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

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
parent d2d524d9
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -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(