1 /* <lambda>null2 * 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 com.android.healthconnect.controller.exportimport.api 18 19 /** 20 * Specifies the frequency of scheduled exports of Health Connect data (no data gets exported in 21 * case of [ExportFrequency.EXPORT_FREQUENCY_NEVER]). 22 * 23 * @param periodInDays: period in days between scheduled exports. 24 */ 25 enum class ExportFrequency(val periodInDays: Int) { 26 EXPORT_FREQUENCY_NEVER(0), 27 EXPORT_FREQUENCY_DAILY(1), 28 EXPORT_FREQUENCY_WEEKLY(7), 29 EXPORT_FREQUENCY_MONTHLY(30) 30 } 31 32 /** 33 * Returns [ExportFrequency] corresponding to the given period in days between scheduled exports of 34 * Health Connect data (or throws in case of unsupported period in days). 35 */ fromPeriodInDaysnull36fun fromPeriodInDays(periodInDays: Int): ExportFrequency { 37 ExportFrequency.values().forEach { frequency -> 38 if (frequency.periodInDays == periodInDays) { 39 return frequency 40 } 41 } 42 throw UnsupportedOperationException( 43 "Export frequency period in days $periodInDays is not supported") 44 } 45