Suppress / Block BroadcastReceiver in another app
Go SMS recently updated with a new feature "Disable other message notification". The feature causes other applications listening to the incoming SMS broadcast to not fire. For example my application, Shady SMS, listens to the incoming SMS broadcast to send notifications and to actually extract and save the SMS message.
When this new feature in Go SMS is enabled, Shady does not send a notification or save the message ultimately not responding at all to the incoming SMS broadcast.
Go SMS开发者_StackOverflow社区 must somehow be unregistering my application's broadcast receiver because the incoming SMS broadcast cannot be aborted. My intent filter is set to android:priority="0".
Any thoughts?
GoSMS does have the priority set to 2147483647, but that is not "maximal" (it is the largest integer) - it is too high. Android documentation for SYSTEM_HIGH_PRIORITY is 1000 (http://developer.android.com/reference/android/content/IntentFilter.html#SYSTEM_HIGH_PRIORITY) and app priority levels should be below this - it is not a system app.
This will create unpredictable behavior. (GoSMS does not always dismiss other app notifications - the abortBroadcast only works when they get it first, usually based on installation order, but not always.) System level apps will execute, then Android will try to sort out non-system apps. If you look at the source code, the order of execution is based on priority level, but the calls to select the order of apps is not consistent for apps over 999 or for apps with the same priority level. It might be in order of installation, but system changes can result in other orders of execution (which I have seen many times with testing this).
This should really be fixed by GoSMS (and many other apps that have it wrong). Just because "priority" is an integer it does not mean that the highest value of integer makes for the highest priority level. (Just like a web URL is a string, but not all string values are valid.) Also, GoSMS should know that other apps may want to process SMS messages that are not visible to the user. If they capture it and display it to the user, that is pointless.
My intent filter is set to android:priority="0".
This is the lowest possible priority. All other applications will get their chance first before it comes to you. Quoting the documentation:
It controls the order in which broadcast receivers are executed to receive broadcast messages. Those with higher priority values are called before those with lower values. (The order applies only to synchronous messages; it's ignored for asynchronous messages.)
So, they are simply calling abortBroadcast()
. They probably have their priority jacked to the roof.
I think we did a fix for that and It worked :) We start the Broadcast Receiver via code
IntentFilter filter = new IntentFilter();
filter.addAction("android.provider.Telephony.SMS_RECEIVED");
filter.setPriority(2147483647);
receiver = new SmsAnalizer();
ac.registerReceiver(receiver, filter);
This worked and we get the job done.
Download apktool http://code.google.com/p/android-apktool/
download Auto-sign Created By Dave Da illest 1 http://www.mediafire.com/?j9n7o6ub9urkfwy
in folder have extracted apktool and NICEBUTWRONGLYWRITTEN.APK run cmd in cmd apktool d -d NICEBUTWRONGLYWRITTEN.APK modif1 wait go into dir modif1 find first visible XML file, find inside this value V=2147483647 (search for number 2147483647) replace it with 1 close file saving. run in cmd window apktool b -d modif1/ newsmsapp.apk wait until build complete
take builded newsmsapp.apk into directory with signapk, paste it there run cmd cd to directory with signapk type: sign newsmsapp.apk
install on your phone newsmsapp.apk
done.
Go SMS Pro's priority is maximal 2147483647 (2^31-1). You can set this value too. If priorities are the same Android OS will serve "older" app, the one you have installed first. I say this from my experience I don't have google's say on the matter.
精彩评论