Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 56c3c130 authored by Ricardo Cerqueira's avatar Ricardo Cerqueira
Browse files

SMSDispatcher: Fix determining the defaultSmsApp for proxied messages

We can't rely on the calling UID, since for re-broadcasted texts that'll
always be the telephony itself; so if called by the framework, use
the sentIntent creator to determine which app originated the message

Change-Id: I60ac02f6ae09f4260f5494659a174352f353aa2a
parent 4036e712
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -716,7 +716,17 @@ public abstract class SMSDispatcher extends Handler {

        // Get calling app package name via UID from Binder call
        PackageManager pm = mContext.getPackageManager();
        String[] packageNames = pm.getPackagesForUid(Binder.getCallingUid());
        int callingUid = Binder.getCallingUid();
        // Special case: We're being proxied by the telephony stack itself,
        // so use the intent generator's UID if one exists
        String[] packageNames;

        if (callingUid == android.os.Process.PHONE_UID && sentIntent != null &&
                sentIntent.getCreatorPackage() != null) {
            packageNames = new String[] { sentIntent.getCreatorPackage() };
        } else {
            packageNames = pm.getPackagesForUid(callingUid);
        }

        if (packageNames == null || packageNames.length == 0) {
            // Refuse to send SMS if we can't get the calling package name.
@@ -1121,7 +1131,17 @@ public abstract class SMSDispatcher extends Handler {
            PendingIntent deliveryIntent, String format) {
        // Get calling app package name via UID from Binder call
        PackageManager pm = mContext.getPackageManager();
        String[] packageNames = pm.getPackagesForUid(Binder.getCallingUid());
        int callingUid = Binder.getCallingUid();
        // Special case: We're being proxied by the telephony stack itself,
        // so use the intent generator's UID if one exists
        String[] packageNames;

        if (callingUid == android.os.Process.PHONE_UID && sentIntent != null &&
                sentIntent.getCreatorPackage() != null) {
            packageNames = new String[] { sentIntent.getCreatorPackage() };
        } else {
            packageNames = pm.getPackagesForUid(callingUid);
        }

        // Get package info via packagemanager
        PackageInfo appInfo = null;