blob: 48d5b8cc126ba1f54ce40aa86da6629859e78fca [file] [log] [blame]
Felipe Leme23a0c7a2018-01-24 08:43:34 -08001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.app;
18
19import android.annotation.NonNull;
20import android.annotation.Nullable;
21import android.content.UriPermission;
22import android.net.Uri;
23import android.os.Parcel;
24import android.os.Parcelable;
25
26/**
27 * Represents an {@link UriPermission} granted to a package.
28 *
29 * {@hide}
30 */
31public class GrantedUriPermission implements Parcelable {
32
33 public final Uri uri;
34 public final String packageName;
35
36 public GrantedUriPermission(@NonNull Uri uri, @Nullable String packageName) {
37 this.uri = uri;
38 this.packageName = packageName;
39 }
40
41 @Override
42 public String toString() {
43 return packageName + ":" + uri;
44 }
45
46 @Override
47 public int describeContents() {
48 return 0;
49 }
50
51 @Override
52 public void writeToParcel(Parcel out, int flags) {
53 out.writeParcelable(uri, flags);
54 out.writeString(packageName);
55 }
56
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -070057 public static final @android.annotation.NonNull Parcelable.Creator<GrantedUriPermission> CREATOR =
Felipe Leme23a0c7a2018-01-24 08:43:34 -080058 new Parcelable.Creator<GrantedUriPermission>() {
59 @Override
60 public GrantedUriPermission createFromParcel(Parcel in) {
61 return new GrantedUriPermission(in);
62 }
63
64 @Override
65 public GrantedUriPermission[] newArray(int size) {
66 return new GrantedUriPermission[size];
67 }
68 };
69
70 private GrantedUriPermission(Parcel in) {
71 uri = in.readParcelable(null);
72 packageName = in.readString();
73 }
74}