1 /* 2 * Copyright (C) 2022 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.server.healthconnect.permission; 18 19 import android.annotation.IntDef; 20 import android.annotation.NonNull; 21 import android.os.UserHandle; 22 23 import java.io.File; 24 import java.lang.annotation.Retention; 25 import java.lang.annotation.RetentionPolicy; 26 27 /** 28 * Class for managing health permissions first grant time datastore. 29 * 30 * @hide 31 */ 32 public interface FirstGrantTimeDatastore { 33 34 @Retention(RetentionPolicy.SOURCE) 35 @IntDef({DATA_TYPE_CURRENT, DATA_TYPE_STAGED}) 36 public @interface DataType {} 37 38 /* Type used for storing general grant time */ 39 int DATA_TYPE_CURRENT = 0; 40 41 /* Type used for applying backup data when it's needed. */ 42 int DATA_TYPE_STAGED = 1; 43 44 /** 45 * Read {@link UserGrantTimeState for given user}. 46 * 47 * @hide 48 */ 49 @NonNull readForUser(@onNull UserHandle user, @DataType int dataType)50 UserGrantTimeState readForUser(@NonNull UserHandle user, @DataType int dataType); 51 52 /** 53 * Write {@link UserGrantTimeState for given user}. 54 * 55 * @hide 56 */ writeForUser( @onNull UserGrantTimeState grantTimesState, @NonNull UserHandle user, @DataType int dataType)57 void writeForUser( 58 @NonNull UserGrantTimeState grantTimesState, 59 @NonNull UserHandle user, 60 @DataType int dataType); 61 62 /** 63 * Returns the name of the files used by the store for the given user. 64 * 65 * @hide 66 */ getFile(@onNull UserHandle user, @DataType int dataType)67 File getFile(@NonNull UserHandle user, @DataType int dataType); 68 69 /** 70 * Create instance of the datastore class. 71 * 72 * @hide 73 */ 74 @NonNull createInstance()75 static FirstGrantTimeDatastore createInstance() { 76 return new FirstGrantTimeDatastoreXmlPersistence(); 77 } 78 } 79