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

Commit 294af233 authored by Will Harmon's avatar Will Harmon Committed by Jason Monk
Browse files

Allow system apps to have disabled QS tiles.

Otherwise the tile can get removed on bootup if the tile is disabled by
default.

Fixes: 29509725

Change-Id: Icc6b63b6cf9b9cdca367c79c3175896c87041e05
parent 157c6811
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -82,8 +82,11 @@ public class CustomTile extends QSTile<QSTile.State> implements TileChangeListen
    private void setTileIcon() {
        try {
            PackageManager pm = mContext.getPackageManager();
            ServiceInfo info = pm.getServiceInfo(mComponent,
                    PackageManager.MATCH_ENCRYPTION_AWARE_AND_UNAWARE);
            int flags = PackageManager.MATCH_ENCRYPTION_AWARE_AND_UNAWARE;
            if (isSystemApp(pm)) {
                flags |= PackageManager.MATCH_DISABLED_COMPONENTS;
            }
            ServiceInfo info = pm.getServiceInfo(mComponent, flags);
            int icon = info.icon != 0 ? info.icon
                    : info.applicationInfo.icon;
            // Update the icon if its not set or is the default icon.
@@ -103,6 +106,10 @@ public class CustomTile extends QSTile<QSTile.State> implements TileChangeListen
        }
    }

    private boolean isSystemApp(PackageManager pm) throws PackageManager.NameNotFoundException {
        return pm.getApplicationInfo(mComponent.getPackageName(), 0).isSystemApp();
    }

    /**
     * Compare two icons, only works for resources.
     */