Fix links to notification settings activities.

Additionally, we now show the user a list of "app-like"
things (packages with launchable activities) instead of only
non-system things. This way you can make (some) changes to
system package notifications while not having to page
through reams of random non-app packages.

Bug: 17277023
Change-Id: I920d6b941070efb75a816e6ad38b798b09a83d08
This commit is contained in:
Dan Sandler
2014-09-02 18:31:49 +02:00
parent 963ce47525
commit b58b512704
3 changed files with 83 additions and 47 deletions

View File

@@ -30,9 +30,11 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.pm.Signature;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
@@ -839,4 +841,34 @@ public final class Utils {
return tm.getSimCount() > 0;
}
/**
* Determine whether a package is a "system package", in which case certain things (like
* disabling notifications or disabling the package altogether) should be disallowed.
*/
public static boolean isSystemPackage(PackageManager pm, PackageInfo pkg) {
if (sSystemSignature == null) {
sSystemSignature = new Signature[]{ getSystemSignature(pm) };
}
return sSystemSignature[0] != null && sSystemSignature[0].equals(getFirstSignature(pkg));
}
private static Signature[] sSystemSignature;
private static Signature getFirstSignature(PackageInfo pkg) {
if (pkg != null && pkg.signatures != null && pkg.signatures.length > 0) {
return pkg.signatures[0];
}
return null;
}
private static Signature getSystemSignature(PackageManager pm) {
try {
final PackageInfo sys = pm.getPackageInfo("android", PackageManager.GET_SIGNATURES);
return getFirstSignature(sys);
} catch (NameNotFoundException e) {
}
return null;
}
}