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

Commit e85c2681 authored by Ahaan Ugale's avatar Ahaan Ugale Committed by Automerger Merge Worker
Browse files

Merge "Hotword: Treat preflight soft denial as granted." into sc-dev am: a13d8032

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15421452

Change-Id: Ie906a0f8ec6d88bf9b7e942f69382322016cbdd5
parents 02dc7196 a13d8032
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import android.media.permission.Identity;
import android.media.permission.PermissionUtil;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceSpecificException;
import android.text.TextUtils;
import android.util.Slog;

@@ -117,8 +116,8 @@ final class SoundTriggerSessionPermissionsDecorator implements

    /**
     * Throws a {@link SecurityException} if originator permanently doesn't have the given
     * permission, or a {@link ServiceSpecificException} with a {@link
     * #TEMPORARY_PERMISSION_DENIED} if caller originator doesn't have the given permission.
     * permission.
     * Soft (temporary) denials are considered OK for preflight purposes.
     *
     * @param context    A {@link Context}, used for permission checks.
     * @param identity   The identity to check.
@@ -130,15 +129,12 @@ final class SoundTriggerSessionPermissionsDecorator implements
                permission);
        switch (status) {
            case PermissionChecker.PERMISSION_GRANTED:
            case PermissionChecker.PERMISSION_SOFT_DENIED:
                return;
            case PermissionChecker.PERMISSION_HARD_DENIED:
                throw new SecurityException(
                        TextUtils.formatSimple("Failed to obtain permission %s for identity %s",
                                permission, toString(identity)));
            case PermissionChecker.PERMISSION_SOFT_DENIED:
                throw new ServiceSpecificException(TEMPORARY_PERMISSION_DENIED,
                        TextUtils.formatSimple("Failed to obtain permission %s for identity %s",
                                permission, toString(identity)));
            default:
                throw new RuntimeException("Unexpected permission check result.");
        }