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

Commit f240272a authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 7699297 from ad28fe0e to sc-qpr1-release

Change-Id: I4dab8b1c6bd14b58660357c264012d5b39ddcc87
parents 358f5589 ad28fe0e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -739,6 +739,16 @@ public class RemoteViews implements Parcelable, Filter {
            return mContextForResources.getPackageName();
        }

        @Override
        public UserHandle getUser() {
            return mContextForResources.getUser();
        }

        @Override
        public int getUserId() {
            return mContextForResources.getUserId();
        }

        @Override
        public boolean isRestricted() {
            // Override isRestricted and direct to resource's implementation. The isRestricted is
+1 −2
Original line number Diff line number Diff line
@@ -84,8 +84,7 @@ public class MDNSFilterPlugin implements PrintServicePlugin {
     */
    public MDNSFilterPlugin(@NonNull Context context, @NonNull String name,
            @NonNull CharSequence packageName, @NonNull List<String> mDNSNames) {
        mName = context.getResources().getIdentifier(name, null,
                "com.android.printservice.recommendation");
        mName = context.getResources().getIdentifier(name, null, context.getPackageName());
        mPackageName = packageName;
        mMDNSFilteredDiscovery = new MDNSFilteredDiscovery(context, PRINTER_SERVICE_TYPES,
                new VendorNameFilter(new HashSet<>(mDNSNames)));
+1 −2
Original line number Diff line number Diff line
@@ -486,8 +486,7 @@ public class InternetDialog extends SystemUIDialog implements
    }

    private void showTurnOffMobileDialog() {
        CharSequence carrierName =
                mSubscriptionManager.getDefaultDataSubscriptionInfo().getCarrierName();
        CharSequence carrierName = getMobileNetworkTitle();
        boolean isInService = mInternetDialogController.isVoiceStateInService();
        if (TextUtils.isEmpty(carrierName) || !isInService) {
            carrierName = mContext.getString(R.string.mobile_data_disable_message_default_carrier);
+2 −1
Original line number Diff line number Diff line
@@ -2479,7 +2479,8 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
        try {
            foregroundUser = ActivityManager.getCurrentUser();
            valid = (callingUser == foregroundUser) || parentUser == foregroundUser
                    || callingAppId == Process.NFC_UID || callingAppId == mSystemUiUid;
                    || callingAppId == Process.NFC_UID || callingAppId == mSystemUiUid
                    || callingAppId == Process.SHELL_UID;
            if (DBG && !valid) {
                Slog.d(TAG, "checkIfCallerIsForegroundUser: valid=" + valid + " callingUser="
                        + callingUser + " parentUser=" + parentUser + " foregroundUser="
+32 −8
Original line number Diff line number Diff line
@@ -2823,8 +2823,8 @@ public class AudioService extends IAudioService.Stub
        if (uid == android.os.Process.SYSTEM_UID) {
            uid = UserHandle.getUid(getCurrentUserId(), UserHandle.getAppId(uid));
        }
        if (mAppOps.noteOp(STREAM_VOLUME_OPS[streamTypeAlias], uid, callingPackage)
                != AppOpsManager.MODE_ALLOWED) {
        // validate calling package and app op
        if (!checkNoteAppOp(STREAM_VOLUME_OPS[streamTypeAlias], uid, callingPackage)) {
            return;
        }

@@ -3547,8 +3547,7 @@ public class AudioService extends IAudioService.Stub
        if (uid == android.os.Process.SYSTEM_UID) {
            uid = UserHandle.getUid(getCurrentUserId(), UserHandle.getAppId(uid));
        }
        if (mAppOps.noteOp(STREAM_VOLUME_OPS[streamTypeAlias], uid, callingPackage)
                != AppOpsManager.MODE_ALLOWED) {
        if (!checkNoteAppOp(STREAM_VOLUME_OPS[streamTypeAlias], uid, callingPackage)) {
            return;
        }

@@ -3983,8 +3982,7 @@ public class AudioService extends IAudioService.Stub
            uid = UserHandle.getUid(userId, UserHandle.getAppId(uid));
        }
        // If OP_AUDIO_MASTER_VOLUME is set, disallow unmuting.
        if (!mute && mAppOps.noteOp(AppOpsManager.OP_AUDIO_MASTER_VOLUME, uid, callingPackage)
                != AppOpsManager.MODE_ALLOWED) {
        if (!mute && !checkNoteAppOp(AppOpsManager.OP_AUDIO_MASTER_VOLUME, uid, callingPackage)) {
            return;
        }
        if (userId != UserHandle.getCallingUserId() &&
@@ -4115,8 +4113,7 @@ public class AudioService extends IAudioService.Stub
                        ? MediaMetrics.Value.MUTE : MediaMetrics.Value.UNMUTE);

        // If OP_MUTE_MICROPHONE is set, disallow unmuting.
        if (!on && mAppOps.noteOp(AppOpsManager.OP_MUTE_MICROPHONE, uid, callingPackage)
                != AppOpsManager.MODE_ALLOWED) {
        if (!on && !checkNoteAppOp(AppOpsManager.OP_MUTE_MICROPHONE, uid, callingPackage)) {
            mmi.set(MediaMetrics.Property.EARLY_RETURN, "disallow unmuting").record();
            return;
        }
@@ -10534,4 +10531,31 @@ public class AudioService extends IAudioService.Stub
        }
        mFullVolumeDevices.remove(audioSystemDeviceOut);
    }

    //====================
    // Helper functions for app ops
    //====================
    /**
     * Validates, and notes an app op for a given uid and package name.
     * Validation comes from exception catching: a security exception indicates the package
     * doesn't exist, an IAE indicates the uid and package don't match. The code only checks
     * if exception was thrown for robustness to code changes in op validation
     * @param op the app op to check
     * @param uid the uid of the caller
     * @param packageName the package to check
     * @return true if the origin of the call is valid (no uid / package mismatch) and the caller
     *      is allowed to perform the operation
     */
    private boolean checkNoteAppOp(int op, int uid, String packageName) {
        try {
            if (mAppOps.noteOp(op, uid, packageName) != AppOpsManager.MODE_ALLOWED) {
                return false;
            }
        } catch (Exception e) {
            Log.e(TAG, "Error noting op:" + op + " on uid:" + uid + " for package:"
                    + packageName, e);
            return false;
        }
        return true;
    }
}
Loading