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

Commit 15dc9d7d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Internal Framework changes needed by DocumentUI's ScopedAccessProvider:"

parents 54573c59 23a0c7a0
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.annotation.TestApi;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.UriPermission;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.ConfigurationInfo;
@@ -2686,17 +2685,22 @@ public class ActivityManager {
    /**
     * Permits an application to get the persistent URI permissions granted to another.
     *
     * <p>Typically called by Settings.
     * <p>Typically called by Settings or DocumentsUI, requires
     * {@code GET_APP_GRANTED_URI_PERMISSIONS}.
     *
     * @param packageName application to look for the granted permissions
     * @param packageName application to look for the granted permissions, or {@code null} to get
     * granted permissions for all applications
     * @return list of granted URI permissions
     *
     * @hide
     */
    public ParceledListSlice<UriPermission> getGrantedUriPermissions(String packageName) {
    public ParceledListSlice<GrantedUriPermission> getGrantedUriPermissions(
            @Nullable String packageName) {
        try {
            return getService().getGrantedUriPermissions(packageName,
                    UserHandle.myUserId());
            @SuppressWarnings("unchecked")
            final ParceledListSlice<GrantedUriPermission> castedList = getService()
                    .getGrantedUriPermissions(packageName, UserHandle.myUserId());
            return castedList;
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -2705,7 +2709,7 @@ public class ActivityManager {
    /**
     * Permits an application to clear the persistent URI permissions granted to another.
     *
     * <p>Typically called by Settings.
     * <p>Typically called by Settings, requires {@code CLEAR_APP_GRANTED_URI_PERMISSIONS}.
     *
     * @param packageName application to clear its granted permissions
     *
+20 −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;

/** @hide */
parcelable GrantedUriPermission;
 No newline at end of file
+74 −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.annotation.NonNull;
import android.annotation.Nullable;
import android.content.UriPermission;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * Represents an {@link UriPermission} granted to a package.
 *
 * {@hide}
 */
public class GrantedUriPermission implements Parcelable {

    public final Uri uri;
    public final String packageName;

    public GrantedUriPermission(@NonNull Uri uri, @Nullable String packageName) {
        this.uri = uri;
        this.packageName = packageName;
    }

    @Override
    public String toString() {
        return packageName + ":" + uri;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeParcelable(uri, flags);
        out.writeString(packageName);
    }

    public static final Parcelable.Creator<GrantedUriPermission> CREATOR =
            new Parcelable.Creator<GrantedUriPermission>() {
                @Override
                public GrantedUriPermission createFromParcel(Parcel in) {
                    return new GrantedUriPermission(in);
                }

                @Override
                public GrantedUriPermission[] newArray(int size) {
                    return new GrantedUriPermission[size];
                }
            };

    private GrantedUriPermission(Parcel in) {
        uri = in.readParcelable(null);
        packageName = in.readString();
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.app;
import android.app.ActivityManager;
import android.app.ApplicationErrorReport;
import android.app.ContentProviderHolder;
import android.app.GrantedUriPermission;
import android.app.IApplicationThread;
import android.app.IActivityController;
import android.app.IAppTask;
@@ -569,7 +570,7 @@ interface IActivityManager {
            in Rect tempDockedTaskInsetBounds,
            in Rect tempOtherTaskBounds, in Rect tempOtherTaskInsetBounds);
    int setVrMode(in IBinder token, boolean enabled, in ComponentName packageName);
    // Gets the URI permissions granted to an arbitrary package.
    // 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);
+3 −1
Original line number Diff line number Diff line
@@ -738,7 +738,9 @@ public final class DocumentsContract {
    private static final String PATH_DOCUMENT = "document";
    private static final String PATH_CHILDREN = "children";
    private static final String PATH_SEARCH = "search";
    private static final String PATH_TREE = "tree";
    // TODO(b/72055774): make private again once ScopedAccessProvider is refactored
    /** {@hide} */
    public static final String PATH_TREE = "tree";

    private static final String PARAM_QUERY = "query";
    private static final String PARAM_MANAGE = "manage";
Loading