1 /* 2 * Copyright (C) 2024 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 android.health.connect; 18 19 import static android.health.connect.Constants.MAXIMUM_PAGE_SIZE; 20 import static android.health.connect.Constants.MINIMUM_PAGE_SIZE; 21 import static android.health.connect.datatypes.validation.ValidationUtils.requireInRange; 22 23 import static com.android.healthfitness.flags.Flags.FLAG_PERSONAL_HEALTH_RECORD; 24 25 import android.annotation.FlaggedApi; 26 import android.annotation.IntRange; 27 import android.health.connect.aidl.ReadMedicalResourcesRequestParcel; 28 29 /** 30 * A base class to represent a read request for {@link HealthConnectManager#readMedicalResources}. 31 */ 32 @FlaggedApi(FLAG_PERSONAL_HEALTH_RECORD) 33 public abstract class ReadMedicalResourcesRequest { 34 private final int mPageSize; 35 36 /** 37 * @param pageSize The maximum number of {@code MedicalResource}s to be returned by the read 38 * operation. 39 * @throws IllegalArgumentException if {@code pageSize} is less than 1 or more than 5000. 40 * @hide 41 */ ReadMedicalResourcesRequest( @ntRangefrom = MINIMUM_PAGE_SIZE, to = MAXIMUM_PAGE_SIZE) int pageSize)42 protected ReadMedicalResourcesRequest( 43 @IntRange(from = MINIMUM_PAGE_SIZE, to = MAXIMUM_PAGE_SIZE) int pageSize) { 44 requireInRange(pageSize, MINIMUM_PAGE_SIZE, MAXIMUM_PAGE_SIZE, "pageSize"); 45 mPageSize = pageSize; 46 } 47 48 /** 49 * Returns maximum number of {@code MedicalResource}s to be returned by the read operation if 50 * set, 1000 otherwise. 51 */ 52 @IntRange(from = MINIMUM_PAGE_SIZE, to = MAXIMUM_PAGE_SIZE) getPageSize()53 public int getPageSize() { 54 return mPageSize; 55 } 56 57 /** 58 * Returns an instance of {@link ReadMedicalResourcesRequestParcel} to carry the request. 59 * 60 * @hide 61 */ 62 @SuppressWarnings("HiddenAbstractMethod") toParcel()63 abstract ReadMedicalResourcesRequestParcel toParcel(); 64 } 65