diff options
author | Christopher Tate <ctate@google.com> | 2013-10-29 17:42:26 -0700 |
---|---|---|
committer | Christopher Tate <ctate@google.com> | 2013-10-29 17:42:26 -0700 |
commit | e202cad1abd3ef63f6226c9164b74cc4368df135 (patch) | |
tree | 00b7894a216b6648986e3793b3ffccf7bdfbb62e /services | |
parent | e5c1208ef9ef7d10b5bae6c82b9eb5a92da1244e (diff) | |
download | frameworks_base-e202cad1abd3ef63f6226c9164b74cc4368df135.zip frameworks_base-e202cad1abd3ef63f6226c9164b74cc4368df135.tar.gz frameworks_base-e202cad1abd3ef63f6226c9164b74cc4368df135.tar.bz2 |
Don't crash when preferred activity settings are malformed
We also now ignore attempts to set preferred resolutions with
intent filters for which no actions are defined.
Bug 11392870
Change-Id: If0d0b37bf01b59463985441edfc2bddd070bfc2a
Diffstat (limited to 'services')
-rwxr-xr-x | services/java/com/android/server/pm/PackageManagerService.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java index a781d5f..3d6b3c9 100755 --- a/services/java/com/android/server/pm/PackageManagerService.java +++ b/services/java/com/android/server/pm/PackageManagerService.java @@ -9965,6 +9965,10 @@ public class PackageManagerService extends IPackageManager.Stub { // writer int callingUid = Binder.getCallingUid(); enforceCrossUserPermission(callingUid, userId, true, "add preferred activity"); + if (filter.countActions() == 0) { + Slog.w(TAG, "Cannot set a preferred activity with no filter actions"); + return; + } synchronized (mPackages) { if (mContext.checkCallingOrSelfPermission( android.Manifest.permission.SET_PREFERRED_APPLICATIONS) @@ -10024,7 +10028,9 @@ public class PackageManagerService extends IPackageManager.Stub { String category = filter.getCategory(0); while (it.hasNext()) { PreferredActivity pa = it.next(); - if (pa.getAction(0).equals(action) && pa.getCategory(0).equals(category)) { + if ((pa.countActions() == 0) || (pa.countCategories() == 0) + || (pa.getAction(0).equals(action) + && pa.getCategory(0).equals(category))) { if (removed == null) { removed = new ArrayList<PreferredActivity>(); } |