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

Unverified Commit 0fff85dc authored by Roman Birg's avatar Roman Birg Committed by Michael Bestas
Browse files

Telephony: handle 3rd party sms apps + 'always ask'



3rd party SMS apps may not be able to handle our always ask behavior, so
they may get stuck in a bad state. An example of this is Hangouts, which
just ends up never sending messages when always ask is selected.

TIcket: CYNGNOS-3068

Change-Id: I8a0f1f6bf7a5010438e40eb0be9aa178d2141f3c
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent 02efbec1
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.provider.Telephony.Sms.Intents;
import android.telephony.Rlog;
import android.telephony.SmsManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;

import com.android.internal.content.PackageMonitor;
@@ -62,6 +63,7 @@ public final class SmsApplication {
    private static final String BLUETOOTH_PACKAGE_NAME = "com.android.bluetooth";
    private static final String MMS_SERVICE_PACKAGE_NAME = "com.android.mms.service";
    private static final String TELEPHONY_PROVIDER_PACKAGE_NAME = "com.android.providers.telephony";
    private static final String DEFAULT_SYSTEM_MMS_PACKAGE_NAME = "com.android.messaging";

    private static final String SCHEME_SMS = "sms";
    private static final String SCHEME_SMSTO = "smsto";
@@ -914,6 +916,16 @@ public final class SmsApplication {
        return false;
    }

    /**
     * @hide
     */
    public static boolean canSmsAppHandleAlwaysAsk(Context context) {
        final ComponentName defaultMmsApplication = SmsApplication.getDefaultMmsApplication(context,
                false);
        return TextUtils.equals(DEFAULT_SYSTEM_MMS_PACKAGE_NAME,
                defaultMmsApplication.getPackageName());
    }

    private static String getDefaultSmsApplicationPackageName(Context context) {
        final ComponentName component = getDefaultSmsApplication(context, false);
        if (component != null) {
+9 −1
Original line number Diff line number Diff line
@@ -292,6 +292,14 @@ public class UiccSmsController extends ISms.Stub {
    @Override
    public boolean isSmsSimPickActivityNeeded(int subId) {
        final Context context = ActivityThread.currentApplication().getApplicationContext();

        boolean canCurrentAppHandleAlwaysAsk = SmsApplication.canSmsAppHandleAlwaysAsk(context);
        if (!isSMSPromptEnabled() && canCurrentAppHandleAlwaysAsk) {
            Rlog.d(LOG_TAG, "isSmsSimPickActivityNeeded: false, sms prompt disabled.");
            // user knows best
            return false;
        }

        TelephonyManager telephonyManager =
                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        List<SubscriptionInfo> subInfoList;
@@ -319,7 +327,7 @@ public class UiccSmsController extends ISms.Stub {
            }
        }

        return false;
        return !canCurrentAppHandleAlwaysAsk;
    }

    @Override