Android O support
- [x] Xposed module compatibility (duh!)
- [x] Adaptive icons (launcher, app shortcuts)
- [x] Fix double-notification bug
As it turns out, Android O seems to have removed the *_SMS permissions from com.android.phone, which means we can no longer protect our blocked messages/filters database using that permission. Using any other permission seems like an ugly hack, so here are the alternatives:
-
Use
getCallingPackage()to limit the callers to justcom.android.phone. Also an ugly hack, but it should work. -
Refactor the blocking logic out of the module and into a service that runs under the NekoSMS app. Blocking can be done by sending a broadcast, just like it did on Android 4.3 and below. I would prefer this option, but it would be a significant change and I will have difficulty testing it across the various supported Android versions. Another benefit is that it allows us to decouple the module from the rest of the app, so if someone wants to write a custom blocker, they can just listen for the NekoSMS broadcast w/o needing their own Xposed module.
-
Just let the module grant the phone package the *_SMS permissions, just like what we did with the NekoSMS package. Seems like the easiest way out, but I have no idea if it works.
Overall (2) is the best long-term solution, but (1) and (3) are suitable quick workarounds for a quick patch.
(2) also has the added benefit of removing a lot of ugly complexity in the app. We can finally implement verbose logging in a reasonable way (global singleton, anyone?), and get rid of the BroadcastListener in SmsFilterLoader. Oh, and we won't need RemotePreferences anymore. Also, I think it should bypass the stupid app autostart blocker modules everyone is using.
Ideally I would also like to get rid of the grantWriteSmsPermissions portion of the Xposed module, since that's just waiting to get broken by a future Android update. Don't know of a suitable alternative at the time, though.
Method (1) implemented in 6888eb7b8ea4a9cd735617eacd89c3e6d87c925e
For method (2), I believe replacing the dispatchIntent hook with something like this should work:
Intent originalIntent = new Intent(intent);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
mContext.sendOrderedBroadcast(intent,
"com.crossbowffs.nekosms.permission.BLOCK_SMS",
new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (getResultCode() == Activity.RESULT_CANCELED) {
// discard SMS and clean up database
} else {
// re-call dispatchIntent with originalIntent (avoiding this hook somehow)
}
}
},
(Handler)XposedHelpers.callMethod(param.thisObject, "getHandler"),
Activity.RESULT_OK, null, null);
Anyone who wants to block the SMS can just install a BroadcastReceiver and use setResultCode(Activity.RESULT_CANCELED).
NekoSMS works fine on my Oneplus3T
LineageOS 15.1 + xposed 90beta3
Thank you lixingcong. This is the only module that made me to wait and not to switch to Oreo. I will try upgrade to Oreo soon and will let you know.
Upgraded to 8.1 Oreo and it works fine.
Suspected call framework irregular crash on Oreo. Trying to get logs.
above probably was a miscall.