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

Commit beb3011c authored by Makoto Onuki's avatar Makoto Onuki
Browse files

READ_SMS allows getLine1Number() [3/3]

Bug 22862050

Change-Id: I0cb90152b64508a173f51dd2b6dbaa79f4df8849
parent 7a384469
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -386,9 +386,18 @@ public class PhoneSubInfo {
     * Besides READ_PHONE_STATE, WRITE_SMS also allows apps to get phone numbers.
     */
    private boolean checkReadPhoneNumber(String callingPackage, String message) {
        // Note checkReadPhoneState() may throw, so we need to do the appops check first.
        return (mAppOps.noteOp(AppOpsManager.OP_WRITE_SMS,
                        Binder.getCallingUid(), callingPackage) == AppOpsManager.MODE_ALLOWED)
                || checkReadPhoneState(callingPackage, message);
        // Default SMS app can always read it.
        if (mAppOps.noteOp(AppOpsManager.OP_WRITE_SMS,
                Binder.getCallingUid(), callingPackage) == AppOpsManager.MODE_ALLOWED) {
            return true;
        }
        try {
            return checkReadPhoneState(callingPackage, message);
        } catch (SecurityException e) {
            // Can be read with READ_SMS too.
            mContext.enforceCallingOrSelfPermission(android.Manifest.permission.READ_SMS, message);
            return mAppOps.noteOp(AppOpsManager.OP_READ_SMS,
                    Binder.getCallingUid(), callingPackage) == AppOpsManager.MODE_ALLOWED;
        }
    }
}