NekoSMS icon indicating copy to clipboard operation
NekoSMS copied to clipboard

Android O support

Open apsun opened this issue 8 years ago • 9 comments

  • [x] Xposed module compatibility (duh!)
  • [x] Adaptive icons (launcher, app shortcuts)
  • [x] Fix double-notification bug

apsun avatar Jul 29 '17 19:07 apsun

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:

  1. Use getCallingPackage() to limit the callers to just com.android.phone. Also an ugly hack, but it should work.

  2. 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.

  3. 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.

apsun avatar Feb 28 '18 14:02 apsun

(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.

apsun avatar Feb 28 '18 19:02 apsun

Method (1) implemented in 6888eb7b8ea4a9cd735617eacd89c3e6d87c925e

apsun avatar Feb 28 '18 19:02 apsun

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).

apsun avatar Feb 28 '18 20:02 apsun

NekoSMS works fine on my Oneplus3T

LineageOS 15.1 + xposed 90beta3

lixingcong avatar Apr 19 '18 03:04 lixingcong

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.

tdram avatar Apr 20 '18 09:04 tdram

Upgraded to 8.1 Oreo and it works fine.

tdram avatar Apr 23 '18 11:04 tdram

Suspected call framework irregular crash on Oreo. Trying to get logs.

HankAviator avatar Jul 04 '18 11:07 HankAviator

above probably was a miscall.

HankAviator avatar Aug 07 '18 05:08 HankAviator