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

Commit e9ffc868 authored by Ye Wen's avatar Ye Wen Committed by android-build-merger
Browse files

Merge "Assign WRITE_SMS to UID 1001" into nyc-dev

am: d5d54d19

* commit 'd5d54d19':
  Assign WRITE_SMS to UID 1001

Change-Id: If383e630a00f680059db100b14952bd4c367a19b
parents ad57f63e d5d54d19
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.content.res.Resources;
import android.net.Uri;
import android.os.Binder;
import android.os.Debug;
import android.os.Process;
import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Telephony;
@@ -469,6 +470,11 @@ public final class SmsApplication {
                        MMS_SERVICE_PACKAGE_NAME);
                assignWriteSmsPermissionToSystemApp(context, packageManager, appOps,
                        TELEPHONY_PROVIDER_PACKAGE_NAME);
                // Give WRITE_SMS AppOps permission to UID 1001 which contains multiple
                // apps, all of them should be able to write to telephony provider.
                // This is to allow the proxy package permission check in telephony provider
                // to pass.
                assignWriteSmsPermissionToSystemUid(appOps, Process.PHONE_UID);
            }
        }
        if (DEBUG_MULTIUSER) {
@@ -555,6 +561,11 @@ public final class SmsApplication {
                    MMS_SERVICE_PACKAGE_NAME);
            assignWriteSmsPermissionToSystemApp(context, packageManager, appOps,
                    TELEPHONY_PROVIDER_PACKAGE_NAME);
            // Give WRITE_SMS AppOps permission to UID 1001 which contains multiple
            // apps, all of them should be able to write to telephony provider.
            // This is to allow the proxy package permission check in telephony provider
            // to pass.
            assignWriteSmsPermissionToSystemUid(appOps, Process.PHONE_UID);

            if (DEBUG_MULTIUSER) {
                Log.i(LOG_TAG, "setDefaultApplicationInternal oldAppData=" + oldAppData);
@@ -629,6 +640,10 @@ public final class SmsApplication {

    }

    private static void assignWriteSmsPermissionToSystemUid(AppOpsManager appOps, int uid) {
        appOps.setUidMode(AppOpsManager.OP_WRITE_SMS, uid, AppOpsManager.MODE_ALLOWED);
    }

    /**
     * Tracks package changes and ensures that the default SMS app is always configured to be the
     * preferred activity for SENDTO sms/mms intents.