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

Commit 01dd2285 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6664334 from d63c0f64 to rvc-release

Change-Id: I7987b7bdb0473b910d9e560cb7abb280b9ff679c
parents c1c8da6e d63c0f64
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -756,7 +756,8 @@ public class GrantPermissionsActivity extends Activity
                                || groupState.mGroup.getName().equals(
                                Manifest.permission_group.MICROPHONE)) {
                            mButtonVisibilities[ALLOW_BUTTON] = false;
                            if (mCouldHaveFgCapabilities) {
                            if (mCouldHaveFgCapabilities
                                    || Utils.isEmergencyApp(this, mCallingPackage)) {
                                mButtonVisibilities[ALLOW_ALWAYS_BUTTON] = true;
                                mButtonVisibilities[ALLOW_ONE_TIME_BUTTON] = false;
                            } else {
@@ -832,7 +833,8 @@ public class GrantPermissionsActivity extends Activity
                                || groupState.mGroup.getName().equals(
                                        Manifest.permission_group.MICROPHONE)) {
                            mButtonVisibilities[ALLOW_BUTTON] = false;
                            if (mCouldHaveFgCapabilities) {
                            if (mCouldHaveFgCapabilities
                                    || Utils.isEmergencyApp(this, mCallingPackage)) {
                                mButtonVisibilities[ALLOW_ALWAYS_BUTTON] = true;
                                mButtonVisibilities[ALLOW_ONE_TIME_BUTTON] = false;
                            } else {
+11 −3
Original line number Diff line number Diff line
@@ -278,9 +278,11 @@ class AppPermissionViewModel(

                    if (detailId == 0) {
                        detailId = getForegroundCapableDetailResId(foregroundCapableType)
                        if (detailId != 0) {
                            detailResIdLiveData.value = detailId to null
                        }
                    }
                }
            } else {
                // Allow / Deny case
                allowedState.isShown = true
@@ -308,7 +310,8 @@ class AppPermissionViewModel(
                    allowedState.isShown = false
                    allowedForegroundState.isChecked = allowedState.isChecked
                    allowedForegroundState.isEnabled = allowedState.isEnabled
                    if (couldPackageHaveFgCapabilities) {
                    if (couldPackageHaveFgCapabilities || (Utils.isEmergencyApp(app, packageName) &&
                                    isMicrophone(permGroupName))) {
                        allowedAlwaysState.isShown = true
                        allowedAlwaysState.isChecked = allowedForegroundState.isChecked
                        allowedAlwaysState.isEnabled = allowedForegroundState.isEnabled
@@ -319,11 +322,13 @@ class AppPermissionViewModel(

                        if (detailId == 0) {
                            detailId = getForegroundCapableDetailResId(foregroundCapableType)
                            if (detailId != 0) {
                                detailResIdLiveData.value = detailId to null
                            }
                        }
                    }
                }
            }
            if (group.packageInfo.targetSdkVersion < Build.VERSION_CODES.M) {
                // Pre-M app's can't ask for runtime permissions
                askState.isShown = false
@@ -367,6 +372,9 @@ class AppPermissionViewModel(
        return permissionGroupName.equals(Manifest.permission_group.CAMERA) ||
                permissionGroupName.equals(Manifest.permission_group.MICROPHONE)
    }
    private fun isMicrophone(permissionGroupName: String): Boolean {
        return permissionGroupName.equals(Manifest.permission_group.MICROPHONE)
    }

    /**
     * Modifies the radio buttons to reflect the current policy fixing state
+14 −0
Original line number Diff line number Diff line
@@ -1127,4 +1127,18 @@ public final class Utils {
                || (userManager.isManagedProfile(user.getIdentifier())
                && !DeviceUtils.isTelevision(app));
    }

    /**
     * @return Whether a package is an emergency app.
     */
    public static boolean isEmergencyApp(@NonNull Context context,  @NonNull String packageName) {
        try {
            return context.getSystemService(RoleManager.class)
                    .getRoleHolders(RoleManager.ROLE_EMERGENCY).contains(packageName);
        } catch (Throwable t) {
            // Avoid crashing for any reason, this isn't very well tested
            Log.e(LOG_TAG, "Unable to check if " + packageName + " is an emergency app.", t);
            return false;
        }
    }
}