1 /* 2 * Copyright 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.photopicker.core.configuration 18 19 import android.content.Intent 20 import android.os.SystemProperties 21 22 /** Check system properties to determine if the device is considered debuggable */ 23 private val buildIsDebuggable = SystemProperties.getInt("ro.debuggable", 0) == 1 24 25 /** The default selection maximum size if not set by the caller */ 26 const val DEFAULT_SELECTION_LIMIT = 1 27 28 /** Enum that describes the current runtime environment of the Photopicker. */ 29 enum class PhotopickerRuntimeEnv { 30 ACTIVITY, 31 EMBEDDED, 32 } 33 34 /** 35 * Data object that represents a possible configuration state of the Photopicker. 36 * 37 * @property runtimeEnv The current Photopicker runtime environment, this should never be changed 38 * during configuration updates. 39 * @property action the [Intent#getAction] that Photopicker is currently serving. 40 * @property intent the [Intent] that Photopicker was launched with. 41 * @property selectionLimit the value of [MediaStore.EXTRA_PICK_IMAGES_MAX] with a default value of 42 * [DEFAULT_SELECTION_LIMIT], and max value of [MediaStore.getPickImagesMaxLimit()] if it was not 43 * set or set to too large a limit. 44 * @property flags a snapshot of the relevant flags in [DeviceConfig]. These are not live values. 45 * @property deviceIsDebuggable if the device is running a build which has [ro.debuggable == 1] 46 */ 47 data class PhotopickerConfiguration( 48 val runtimeEnv: PhotopickerRuntimeEnv = PhotopickerRuntimeEnv.ACTIVITY, 49 val action: String, 50 val intent: Intent? = null, 51 val selectionLimit: Int = DEFAULT_SELECTION_LIMIT, 52 val deviceIsDebuggable: Boolean = buildIsDebuggable, 53 val flags: PhotopickerFlags = PhotopickerFlags(), 54 ) 55