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

Commit 6d50dcc8 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Moved URI grants code out of ActivityManagerService to its own service (13/n)

Allows for other services like window manager to call uri grants without
holding AM service lock.

Bug: 80414790
Test: Existing tests pass.
Change-Id: Ie5b4ddb19a2cedff09332dbeb56bcd9292fd18ac
parent 4ec6b125
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ java_library {
        "core/java/android/app/IUidObserver.aidl",
        "core/java/android/app/IUiAutomationConnection.aidl",
        "core/java/android/app/IUiModeManager.aidl",
        "core/java/android/app/IUriGrantsManager.aidl",
        "core/java/android/app/IUserSwitchObserver.aidl",
        "core/java/android/app/IWallpaperManager.aidl",
        "core/java/android/app/IWallpaperManagerCallback.aidl",
+8 −15
Original line number Diff line number Diff line
@@ -2559,7 +2559,6 @@ public class ActivityManager {
        return clearApplicationUserData(mContext.getPackageName(), null);
    }


    /**
     * Permits an application to get the persistent URI permissions granted to another.
     *
@@ -2571,17 +2570,13 @@ public class ActivityManager {
     * @return list of granted URI permissions
     *
     * @hide
     * @deprecated use {@link UriGrantsManager#getGrantedUriPermissions(String)} instead.
     */
    @Deprecated
    public ParceledListSlice<GrantedUriPermission> getGrantedUriPermissions(
            @Nullable String packageName) {
        try {
            @SuppressWarnings("unchecked")
            final ParceledListSlice<GrantedUriPermission> castedList = getService()
                    .getGrantedUriPermissions(packageName, mContext.getUserId());
            return castedList;
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
        return ((UriGrantsManager) mContext.getSystemService(Context.URI_GRANTS_SERVICE))
                .getGrantedUriPermissions(packageName);
    }

    /**
@@ -2592,14 +2587,12 @@ public class ActivityManager {
     * @param packageName application to clear its granted permissions
     *
     * @hide
     * @deprecated use {@link UriGrantsManager#clearGrantedUriPermissions(String)} instead.
     */
    @Deprecated
    public void clearGrantedUriPermissions(String packageName) {
        try {
            getService().clearGrantedUriPermissions(packageName,
                    mContext.getUserId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
        ((UriGrantsManager) mContext.getSystemService(Context.URI_GRANTS_SERVICE))
                .clearGrantedUriPermissions(packageName);
    }

    /**
+0 −7
Original line number Diff line number Diff line
@@ -49,13 +49,6 @@ public abstract class ActivityManagerInternal {
    public static final int ALLOW_NON_FULL_IN_PROFILE = 1;
    public static final int ALLOW_FULL_ONLY = 2;

    /**
     * Grant Uri permissions from one app to another. This method only extends
     * permission grants if {@code callingUid} has permission to them.
     */
    public abstract void grantUriPermissionFromIntent(int callingUid, String targetPkg,
            Intent intent, int targetUserId);

    /**
     * Verify that calling app has access to the given provider.
     */
+0 −15
Original line number Diff line number Diff line
@@ -243,12 +243,6 @@ interface IActivityManager {
    boolean isTopActivityImmersive();
    void crashApplication(int uid, int initialPid, in String packageName, int userId, in String message);
    String getProviderMimeType(in Uri uri, int userId);
    IBinder newUriPermissionOwner(in String name);
    void grantUriPermissionFromOwner(in IBinder owner, int fromUid, in String targetPkg,
            in Uri uri, int mode, int sourceUserId, int targetUserId);
    void revokeUriPermissionFromOwner(in IBinder owner, in Uri uri, int mode, int userId);
    int checkGrantUriPermission(int callingUid, in String targetPkg, in Uri uri,
            int modeFlags, int userId);
    // Cause the specified process to dump the specified heap.
    boolean dumpHeap(in String process, int userId, boolean managed, boolean mallocInfo,
            boolean runGc, in String path, in ParcelFileDescriptor fd,
@@ -363,9 +357,6 @@ interface IActivityManager {
    ActivityManager.StackInfo getFocusedStackInfo();
    void restart();
    void performIdleMaintenance();
    void takePersistableUriPermission(in Uri uri, int modeFlags, String toPackage, int userId);
    void releasePersistableUriPermission(in Uri uri, int modeFlags, String toPackage, int userId);
    ParceledListSlice getPersistedUriPermissions(in String packageName, boolean incoming);
    void appNotRespondingViaProvider(in IBinder connection);
    Rect getTaskBounds(int taskId);
    boolean setProcessMemoryTrimLevel(in String process, int uid, int level);
@@ -441,12 +432,6 @@ interface IActivityManager {
    void resizeDockedStack(in Rect dockedBounds, in Rect tempDockedTaskBounds,
            in Rect tempDockedTaskInsetBounds,
            in Rect tempOtherTaskBounds, in Rect tempOtherTaskInsetBounds);
    // Gets the URI permissions granted to an arbitrary package (or all packages if null)
    // NOTE: this is different from getPersistedUriPermissions(), which returns the URIs the package
    // granted to another packages (instead of those granted to it).
    ParceledListSlice getGrantedUriPermissions(in String packageName, int userId);
    // Clears the URI permissions granted to an arbitrary package.
    void clearGrantedUriPermissions(in String packageName, int userId);
    boolean isAppForeground(int uid);
    void removeStack(int stackId);
    void makePackageIdle(String packageName, int userId);
+41 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.app;

import android.content.pm.ParceledListSlice;
import android.net.Uri;
import android.os.IBinder;

/**
 * Interface for managing an app's permission to access a particular URI.
 * {@hide}
 */
interface IUriGrantsManager {
    void takePersistableUriPermission(in Uri uri, int modeFlags, String toPackage, int userId);
    void releasePersistableUriPermission(in Uri uri, int modeFlags, String toPackage, int userId);
    void grantUriPermissionFromOwner(in IBinder owner, int fromUid, in String targetPkg,
            in Uri uri, int mode, int sourceUserId, int targetUserId);
    /**
     * Gets the URI permissions granted to an arbitrary package (or all packages if null)
     * NOTE: this is different from getPersistedUriPermissions(), which returns the URIs the package
     * granted to another packages (instead of those granted to it).
     */
    ParceledListSlice getGrantedUriPermissions(in String packageName, int userId);
    /** Clears the URI permissions granted to an arbitrary package. */
    void clearGrantedUriPermissions(in String packageName, int userId);
    ParceledListSlice getPersistedUriPermissions(in String packageName, boolean incoming);
}
Loading