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

Commit 0d8879ad authored by Robin Lee's avatar Robin Lee
Browse files

Badge Wi-Fi installer apps

Consistent, and more importantly useful to know which version of an app
was responsible for installing a network.

Change-Id: I37e326f419e03b020e17daa7d65c713d1ea6ddc8
parent 0702e87e
Loading
Loading
Loading
Loading
+20 −7
Original line number Diff line number Diff line
@@ -15,12 +15,16 @@
 */
package com.android.settings.wifi;

import android.app.AppGlobals;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.net.wifi.WifiConfiguration;
import android.os.RemoteException;
import android.os.UserHandle;
import android.preference.Preference;
import android.view.View;
import android.widget.TextView;
@@ -71,15 +75,24 @@ public class AccessPointPreference extends Preference {
        Drawable drawable = pm.getDefaultActivityIcon();
        if (mConfig == null) {
            drawable.setAlpha(0);
        } else if (mConfig.creatorName.equals(systemName)) {
            drawable = getContext().getApplicationInfo().loadIcon(pm);
        } else {
            int userId = UserHandle.getUserId(mConfig.creatorUid);
            ApplicationInfo appInfo = null;
            if (mConfig.creatorName.equals(systemName)) {
                appInfo = getContext().getApplicationInfo();
            } else {
                try {
                drawable = pm.getApplicationIcon(mConfig.creatorName);
            } catch (NameNotFoundException nnfe) {
                    IPackageManager ipm = AppGlobals.getPackageManager();
                    appInfo = ipm.getApplicationInfo(mConfig.creatorName, 0 /* flags */, userId);
                } catch (RemoteException rex) {
                    // use default app icon
                }
            }
            if (appInfo != null) {
                drawable = appInfo.loadIcon(pm);
                drawable = pm.getUserBadgedIcon(drawable, new UserHandle(userId));
            }
        }

        setIcon(drawable);
    }