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

Commit 1a1f5a21 authored by Nadav Bar's avatar Nadav Bar
Browse files

Grant record audio permission to SystemCaptionsService instead of ContentCaptureService

Now that we have a definition for a SystemCaptionsService we should move to use it instead
of piggybacking on ContentCaptureService.
This is also required to ensure that T2C will be granted audio recording permission in case it will
be shipped in a different APK for OEMs.

Test: Manual and DefaultPermissionGrantPolicyTest.
Bug: 128622041.
Change-Id: Ic0b5b21b05ff1ad200472bfc1c4eaa3c588324df
parent d3d14432
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -3055,9 +3055,9 @@ public class ApplicationPackageManager extends PackageManager {
    }

    @Override
    public String getContentCaptureServicePackageName() {
    public String getSystemCaptionsServicePackageName() {
        try {
            return mPM.getContentCaptureServicePackageName();
            return mPM.getSystemCaptionsServicePackageName();
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
+1 −1
Original line number Diff line number Diff line
@@ -742,7 +742,7 @@ interface IPackageManager {

    String getAppPredictionServicePackageName();

    String getContentCaptureServicePackageName();
    String getSystemCaptionsServicePackageName();

    String getIncidentReportApproverPackageName();

+2 −2
Original line number Diff line number Diff line
@@ -6860,9 +6860,9 @@ public abstract class PackageManager {
     *
     * @hide
     */
    public String getContentCaptureServicePackageName() {
    public String getSystemCaptionsServicePackageName() {
        throw new UnsupportedOperationException(
                "getContentCaptureServicePackageName not implemented in subclass");
                "getSystemCaptionsServicePackageName not implemented in subclass");
    }

    /**
+9 −10
Original line number Diff line number Diff line
@@ -160,9 +160,9 @@ import android.content.pm.InstantAppInfo;
import android.content.pm.InstantAppRequest;
import android.content.pm.InstrumentationInfo;
import android.content.pm.IntentFilterVerificationInfo;
import android.content.pm.PackageBackwardCompatibility;
import android.content.pm.KeySet;
import android.content.pm.ModuleInfo;
import android.content.pm.PackageBackwardCompatibility;
import android.content.pm.PackageInfo;
import android.content.pm.PackageInfoLite;
import android.content.pm.PackageInstaller;
@@ -20124,21 +20124,20 @@ public class PackageManagerService extends IPackageManager.Stub
    }
    @Override
    public String getContentCaptureServicePackageName() {
        String contentCaptureServiceName =
                mContext.getString(R.string.config_defaultContentCaptureService);
    public String getSystemCaptionsServicePackageName() {
        String flattenedSystemCaptionsServiceComponentName =
                mContext.getString(R.string.config_defaultSystemCaptionsService);
        if (TextUtils.isEmpty(contentCaptureServiceName)) {
        if (TextUtils.isEmpty(flattenedSystemCaptionsServiceComponentName)) {
            return null;
        }
        int separatorIndex = contentCaptureServiceName.indexOf("/");
        if (separatorIndex < 0) {
        ComponentName systemCaptionsServiceComponentName =
                ComponentName.unflattenFromString(flattenedSystemCaptionsServiceComponentName);
        if (systemCaptionsServiceComponentName == null) {
            return null;
        }
        return contentCaptureServiceName.substring(0, separatorIndex);
        return systemCaptionsServiceComponentName.getPackageName();
    }
    public String getIncidentReportApproverPackageName() {
+5 −5
Original line number Diff line number Diff line
@@ -742,11 +742,11 @@ public final class DefaultPermissionGrantPolicy {
        grantSystemFixedPermissionsToSystemPackage("com.android.sharedstoragebackup", userId,
                STORAGE_PERMISSIONS);

        // Content Capture Service
        String contentCaptureServicePackageName =
                mContext.getPackageManager().getContentCaptureServicePackageName();
        if (!TextUtils.isEmpty(contentCaptureServicePackageName)) {
            grantPermissionsToSystemPackage(contentCaptureServicePackageName, userId,
        // System Captions Service
        String systemCaptionsServicePackageName =
                mContext.getPackageManager().getSystemCaptionsServicePackageName();
        if (!TextUtils.isEmpty(systemCaptionsServicePackageName)) {
            grantPermissionsToSystemPackage(systemCaptionsServicePackageName, userId,
                    MICROPHONE_PERMISSIONS);
        }

Loading