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

Commit fba3e88e authored by Joanne Chung's avatar Joanne Chung
Browse files

Grant permissions to ContentCapture and remove permission for TC.

1. Grant default permissions to ContentCapture app.
2. Remove unnecessary permissions for TC.
3. Made getContentCaptureServicePackageName() available for testing.

Bug: 139523153
Test: Manual. Use dumpsys pm to check the runtime permissions are grant.
Change-Id: If0d1669ac7d99785002c25cc783f1cf40ed7f13b
parent 447cc7c9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -744,6 +744,7 @@ package android.content.pm {
  public abstract class PackageManager {
    method @RequiresPermission("android.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS") public abstract void addOnPermissionsChangeListener(@NonNull android.content.pm.PackageManager.OnPermissionsChangedListener);
    method public abstract boolean arePermissionsIndividuallyControlled();
    method @Nullable public String getContentCaptureServicePackageName();
    method @Nullable @RequiresPermission("android.permission.INTERACT_ACROSS_USERS_FULL") public abstract String getDefaultBrowserPackageNameAsUser(int);
    method @Nullable public String getIncidentReportApproverPackageName();
    method public abstract int getInstallReason(@NonNull String, @NonNull android.os.UserHandle);
+9 −0
Original line number Diff line number Diff line
@@ -3195,6 +3195,15 @@ public class ApplicationPackageManager extends PackageManager {
        }
    }

    @Override
    public String getContentCaptureServicePackageName() {
        try {
            return mPM.getContentCaptureServicePackageName();
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
    }

    @Override
    public boolean isPackageStateProtected(String packageName, int userId) {
        try {
+2 −0
Original line number Diff line number Diff line
@@ -692,6 +692,8 @@ interface IPackageManager {

    String getIncidentReportApproverPackageName();

    String getContentCaptureServicePackageName();

    boolean isPackageStateProtected(String packageName, int userId);

    void sendDeviceCustomizationReadyBroadcast();
+12 −0
Original line number Diff line number Diff line
@@ -7457,6 +7457,18 @@ public abstract class PackageManager {
                "getSetupWizardPackageName not implemented in subclass");
    }

    /**
     * @return the system defined content capture package name, or null if there's none.
     *
     * @hide
     */
    @TestApi
    @Nullable
    public String getContentCaptureServicePackageName() {
        throw new UnsupportedOperationException(
                "getContentCaptureServicePackageName not implemented in subclass");
    }

    /**
     * @return the incident report approver app package name, or null if it's not defined
     * by the OEM.
+17 −0
Original line number Diff line number Diff line
@@ -19750,6 +19750,23 @@ public class PackageManagerService extends IPackageManager.Stub
        return telephonyPackageNames;
    }
    @Override
    public String getContentCaptureServicePackageName() {
        final String flattenedContentCaptureService =
                mContext.getString(R.string.config_defaultContentCaptureService);
        if (TextUtils.isEmpty(flattenedContentCaptureService)) {
            return null;
        }
        final ComponentName contentCaptureServiceComponentName =
                ComponentName.unflattenFromString(flattenedContentCaptureService);
        if (contentCaptureServiceComponentName == null) {
            return null;
        }
        return contentCaptureServiceComponentName.getPackageName();
    }
    @Override
    public void setApplicationEnabledSetting(String appPackageName,
            int newState, int flags, int userId, String callingPackage) {
Loading