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

Commit 810e1f90 authored by Patrik Torstensson's avatar Patrik Torstensson
Browse files

Add default permissions for GLOBAL_SEARCH

Adding default permissions for packages which respond to
android.search.action.GLOBAL_SEARCH on low RAM devices.

This change is specifically for the Android Go platform where devices
will return true for ActivityManager.isLowRamDevice().

Test: gts & test on gobo device
Bug: 64997899
Change-Id: I8ba27ec2150c5747a9accd1853b117c11578507e
parent c1235a1f
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.pm;

import android.Manifest;
import android.annotation.NonNull;
import android.app.ActivityManager;
import android.app.DownloadManager;
import android.app.admin.DevicePolicyManager;
import android.companion.CompanionDeviceManager;
@@ -582,6 +583,21 @@ final class DefaultPermissionGrantPolicy {
                }
            }

            if (ActivityManager.isLowRamDeviceStatic()) {
                // Allow voice search on low-ram devices
                Intent globalSearchIntent = new Intent("android.search.action.GLOBAL_SEARCH");
                PackageParser.Package globalSearchPickerPackage =
                    getDefaultSystemHandlerActivityPackageLPr(globalSearchIntent, userId);

                if (globalSearchPickerPackage != null
                        && doesPackageSupportRuntimePermissions(globalSearchPickerPackage)) {
                    grantRuntimePermissionsLPw(globalSearchPickerPackage,
                        MICROPHONE_PERMISSIONS, true, userId);
                    grantRuntimePermissionsLPw(globalSearchPickerPackage,
                        LOCATION_PERMISSIONS, true, userId);
                }
            }

            // Voice recognition
            Intent voiceRecoIntent = new Intent("android.speech.RecognitionService");
            voiceRecoIntent.addCategory(Intent.CATEGORY_DEFAULT);