diff options
author | Koushik Dutta <koushd@gmail.com> | 2013-06-21 16:34:44 -0700 |
---|---|---|
committer | Koushik Dutta <koushd@gmail.com> | 2013-06-29 21:31:18 -0700 |
commit | e49288d5b13f33172eadd068d1ef1eb89295f78f (patch) | |
tree | a3e4551b91438e5ea36975ebadc1f6fe8265581c /services | |
parent | 9929e6bc78030aa92bfe14094ea3c3696818915a (diff) | |
download | frameworks_base-e49288d5b13f33172eadd068d1ef1eb89295f78f.zip frameworks_base-e49288d5b13f33172eadd068d1ef1eb89295f78f.tar.gz frameworks_base-e49288d5b13f33172eadd068d1ef1eb89295f78f.tar.bz2 |
Add SMS Middleware layer.
Add fix so ordered broadcasts are delivered to system
apps first in the event of a tie. This works around
the issue where terrible apps steal SMS notifications
from the broadcast queue to simply prevent notifications
that could otherwise be removed by a toggle.
Change-Id: I4fff0c584f8fce9c5f2f4fe86a82fe6480c307c7
Diffstat (limited to 'services')
3 files changed, 17 insertions, 3 deletions
diff --git a/services/java/com/android/server/IntentResolver.java b/services/java/com/android/server/IntentResolver.java index 9b19008..8f703f0 100644 --- a/services/java/com/android/server/IntentResolver.java +++ b/services/java/com/android/server/IntentResolver.java @@ -609,7 +609,7 @@ public abstract class IntentResolver<F extends IntentFilter, R extends Object> { public int compare(Object o1, Object o2) { final int q1 = ((IntentFilter) o1).getPriority(); final int q2 = ((IntentFilter) o2).getPriority(); - return (q1 > q2) ? -1 : ((q1 < q2) ? 1 : 0); + return (q1 > q2) ? -1 : ((q1 < q2) ? 1 : ((IntentFilter) o1).onCompareTie((IntentFilter) o2)); } }; diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 618f02c..d7f9eb4 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -11522,7 +11522,7 @@ public final class ActivityManagerService extends ActivityManagerNative + " was previously registered for user " + rl.userId); } BroadcastFilter bf = new BroadcastFilter(filter, rl, callerPackage, - permission, callingUid, userId); + permission, callingUid, userId, (callerApp.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0); rl.add(bf); if (!bf.debugCheck()) { Slog.w(TAG, "==> For Dynamic broadast"); diff --git a/services/java/com/android/server/am/BroadcastFilter.java b/services/java/com/android/server/am/BroadcastFilter.java index c631b6e..1d983c7 100644 --- a/services/java/com/android/server/am/BroadcastFilter.java +++ b/services/java/com/android/server/am/BroadcastFilter.java @@ -29,15 +29,17 @@ class BroadcastFilter extends IntentFilter { final String requiredPermission; final int owningUid; final int owningUserId; + final boolean isSystem; BroadcastFilter(IntentFilter _filter, ReceiverList _receiverList, - String _packageName, String _requiredPermission, int _owningUid, int _userId) { + String _packageName, String _requiredPermission, int _owningUid, int _userId, boolean _isSystem) { super(_filter); receiverList = _receiverList; packageName = _packageName; requiredPermission = _requiredPermission; owningUid = _owningUid; owningUserId = _userId; + isSystem = _isSystem; } public void dump(PrintWriter pw, String prefix) { @@ -71,4 +73,16 @@ class BroadcastFilter extends IntentFilter { sb.append('}'); return sb.toString(); } + + @Override + public int onCompareTie(IntentFilter other) { + // in case of a tie when sorting ordered broadcasts, + // favor system apps. + BroadcastFilter bf = (BroadcastFilter)other; + if (isSystem) + return -1; + if (bf.isSystem) + return 1; + return 0; + } } |