1 /* 2 * Copyright (C) 2020 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 17 package com.android.permission.persistence; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.annotation.SystemApi; 22 import android.annotation.SystemApi.Client; 23 import android.os.UserHandle; 24 25 /** 26 * Persistence for runtime permissions. 27 * 28 * TODO(b/147914847): Remove @hide when it becomes the default. 29 * @hide 30 */ 31 @SystemApi(client = Client.SYSTEM_SERVER) 32 public interface RuntimePermissionsPersistence { 33 34 /** 35 * Read the runtime permissions from persistence. 36 * 37 * This will perform I/O operations synchronously. 38 * 39 * @param user the user to read for 40 * @return the runtime permissions read 41 */ 42 @Nullable readForUser(@onNull UserHandle user)43 RuntimePermissionsState readForUser(@NonNull UserHandle user); 44 45 /** 46 * Write the runtime permissions to persistence. 47 * 48 * This will perform I/O operations synchronously. 49 * 50 * @param runtimePermissions the runtime permissions to write 51 * @param user the user to write for 52 */ writeForUser(@onNull RuntimePermissionsState runtimePermissions, @NonNull UserHandle user)53 void writeForUser(@NonNull RuntimePermissionsState runtimePermissions, 54 @NonNull UserHandle user); 55 56 /** 57 * Delete the runtime permissions from persistence. 58 * 59 * This will perform I/O operations synchronously. 60 * 61 * @param user the user to delete for 62 */ deleteForUser(@onNull UserHandle user)63 void deleteForUser(@NonNull UserHandle user); 64 65 /** 66 * Create a new instance of {@link RuntimePermissionsPersistence} implementation. 67 * 68 * @return the new instance. 69 */ 70 @NonNull createInstance()71 static RuntimePermissionsPersistence createInstance() { 72 return new RuntimePermissionsPersistenceImpl(); 73 } 74 } 75