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

Commit 668a5070 authored by Makoto Onuki's avatar Makoto Onuki Committed by Android Git Automerger
Browse files

am d7a35611: Merge "READ_SMS allows getLine1Number() [3/3]" into mnc-dev

* commit 'd7a35611':
  READ_SMS allows getLine1Number() [3/3]
parents 98c899e1 d7a35611
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;
        }
    }
}