Loading packages/SystemUI/src/com/android/systemui/biometrics/shared/model/SensorLocation.kt→packages/SystemUI/customization/src/com/android/systemui/shared/customization/data/SensorLocation.kt +24 −2 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ * limitations under the License. */ package com.android.systemui.biometrics.shared.model package com.android.systemui.shared.customization.data /** * Provides current sensor location information in the current screen resolution [scale]. Loading @@ -26,18 +26,40 @@ data class SensorLocation( private val naturalCenterX: Int, private val naturalCenterY: Int, private val naturalRadius: Int, private val scale: Float = 1f private val scale: Float = 1f, ) { val centerX: Float get() { return naturalCenterX * scale } val centerY: Float get() { return naturalCenterY * scale } val radius: Float get() { return naturalRadius * scale } fun encode(): String { return floatArrayOf( naturalCenterX.toFloat(), naturalCenterY.toFloat(), naturalRadius.toFloat(), scale, ) .joinToString(DELIMITER) } companion object { private const val DELIMITER: String = "," fun decode(encoded: String): SensorLocation { val array = encoded.split(DELIMITER).map { it.toFloat() }.toFloatArray() return SensorLocation(array[0].toInt(), array[1].toInt(), array[2].toInt(), array[3]) } } } packages/SystemUI/customization/src/com/android/systemui/shared/customization/data/content/CustomizationProviderClient.kt +3 −11 Original line number Diff line number Diff line Loading @@ -79,13 +79,6 @@ interface CustomizationProviderClient { */ fun observeFlags(): Flow<List<Flag>> /** * Returns [Flow] for observing the variables from the System UI. * * @see [queryRuntimeValues] */ fun observeRuntimeValues(): Flow<Bundle> /** * Returns all available affordances supported by the device, regardless of current slot * placement. Loading Loading @@ -291,6 +284,9 @@ class CustomizationProviderClientImpl( Contract.RuntimeValuesTable.KEY_IS_SHADE_LAYOUT_WIDE -> { putBoolean(name, cursor.getInt(valueColumnIndex) == 1) } Contract.RuntimeValuesTable.KEY_UDFPS_LOCATION -> { putString(name, cursor.getString(valueColumnIndex)) } } } } Loading @@ -307,10 +303,6 @@ class CustomizationProviderClientImpl( return observeUri(Contract.FlagsTable.URI).map { queryFlags() } } override fun observeRuntimeValues(): Flow<Bundle> { return observeUri(Contract.RuntimeValuesTable.URI).map { queryRuntimeValues() } } override suspend fun queryAffordances(): List<CustomizationProviderClient.Affordance> { return withContext(backgroundDispatcher) { context.contentResolver Loading packages/SystemUI/customization/src/com/android/systemui/shared/customization/data/content/CustomizationProviderContract.kt +6 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.shared.customization.data.content import android.content.ContentResolver import android.net.Uri import com.android.systemui.shared.customization.data.SensorLocation /** Contract definitions for querying content about keyguard quick affordances. */ object CustomizationProviderContract { Loading Loading @@ -213,6 +214,11 @@ object CustomizationProviderContract { * be as wide as the entire screen. */ const val KEY_IS_SHADE_LAYOUT_WIDE = "is_shade_layout_wide" /** * This key corresponds to a String value, representing the string form of [SensorLocation], * which contains the information of the UDFPS location. */ const val KEY_UDFPS_LOCATION = "udfps_location" object Columns { /** String. Unique ID for the value. */ Loading packages/SystemUI/customization/src/com/android/systemui/shared/customization/data/content/FakeCustomizationProviderClient.kt +0 −4 Original line number Diff line number Diff line Loading @@ -108,10 +108,6 @@ class FakeCustomizationProviderClient( return flags.asStateFlow() } override fun observeRuntimeValues(): Flow<Bundle> { return runtimeValues.asStateFlow() } override suspend fun queryAffordances(): List<CustomizationProviderClient.Affordance> { return affordances.value } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/shared/customization/data/SensorLocationTest.kt 0 → 100644 +36 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.shared.customization.data import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.google.common.truth.Truth.assertThat import org.junit.Test import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class SensorLocationTest : SysuiTestCase() { @Test fun encodeAndDecode() { val sensorLocation = SensorLocation(640, 2068, 117, 0.75f) assertThat(SensorLocation.decode(sensorLocation.encode())).isEqualTo(sensorLocation) } } Loading
packages/SystemUI/src/com/android/systemui/biometrics/shared/model/SensorLocation.kt→packages/SystemUI/customization/src/com/android/systemui/shared/customization/data/SensorLocation.kt +24 −2 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ * limitations under the License. */ package com.android.systemui.biometrics.shared.model package com.android.systemui.shared.customization.data /** * Provides current sensor location information in the current screen resolution [scale]. Loading @@ -26,18 +26,40 @@ data class SensorLocation( private val naturalCenterX: Int, private val naturalCenterY: Int, private val naturalRadius: Int, private val scale: Float = 1f private val scale: Float = 1f, ) { val centerX: Float get() { return naturalCenterX * scale } val centerY: Float get() { return naturalCenterY * scale } val radius: Float get() { return naturalRadius * scale } fun encode(): String { return floatArrayOf( naturalCenterX.toFloat(), naturalCenterY.toFloat(), naturalRadius.toFloat(), scale, ) .joinToString(DELIMITER) } companion object { private const val DELIMITER: String = "," fun decode(encoded: String): SensorLocation { val array = encoded.split(DELIMITER).map { it.toFloat() }.toFloatArray() return SensorLocation(array[0].toInt(), array[1].toInt(), array[2].toInt(), array[3]) } } }
packages/SystemUI/customization/src/com/android/systemui/shared/customization/data/content/CustomizationProviderClient.kt +3 −11 Original line number Diff line number Diff line Loading @@ -79,13 +79,6 @@ interface CustomizationProviderClient { */ fun observeFlags(): Flow<List<Flag>> /** * Returns [Flow] for observing the variables from the System UI. * * @see [queryRuntimeValues] */ fun observeRuntimeValues(): Flow<Bundle> /** * Returns all available affordances supported by the device, regardless of current slot * placement. Loading Loading @@ -291,6 +284,9 @@ class CustomizationProviderClientImpl( Contract.RuntimeValuesTable.KEY_IS_SHADE_LAYOUT_WIDE -> { putBoolean(name, cursor.getInt(valueColumnIndex) == 1) } Contract.RuntimeValuesTable.KEY_UDFPS_LOCATION -> { putString(name, cursor.getString(valueColumnIndex)) } } } } Loading @@ -307,10 +303,6 @@ class CustomizationProviderClientImpl( return observeUri(Contract.FlagsTable.URI).map { queryFlags() } } override fun observeRuntimeValues(): Flow<Bundle> { return observeUri(Contract.RuntimeValuesTable.URI).map { queryRuntimeValues() } } override suspend fun queryAffordances(): List<CustomizationProviderClient.Affordance> { return withContext(backgroundDispatcher) { context.contentResolver Loading
packages/SystemUI/customization/src/com/android/systemui/shared/customization/data/content/CustomizationProviderContract.kt +6 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.shared.customization.data.content import android.content.ContentResolver import android.net.Uri import com.android.systemui.shared.customization.data.SensorLocation /** Contract definitions for querying content about keyguard quick affordances. */ object CustomizationProviderContract { Loading Loading @@ -213,6 +214,11 @@ object CustomizationProviderContract { * be as wide as the entire screen. */ const val KEY_IS_SHADE_LAYOUT_WIDE = "is_shade_layout_wide" /** * This key corresponds to a String value, representing the string form of [SensorLocation], * which contains the information of the UDFPS location. */ const val KEY_UDFPS_LOCATION = "udfps_location" object Columns { /** String. Unique ID for the value. */ Loading
packages/SystemUI/customization/src/com/android/systemui/shared/customization/data/content/FakeCustomizationProviderClient.kt +0 −4 Original line number Diff line number Diff line Loading @@ -108,10 +108,6 @@ class FakeCustomizationProviderClient( return flags.asStateFlow() } override fun observeRuntimeValues(): Flow<Bundle> { return runtimeValues.asStateFlow() } override suspend fun queryAffordances(): List<CustomizationProviderClient.Affordance> { return affordances.value } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/shared/customization/data/SensorLocationTest.kt 0 → 100644 +36 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.shared.customization.data import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.google.common.truth.Truth.assertThat import org.junit.Test import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class SensorLocationTest : SysuiTestCase() { @Test fun encodeAndDecode() { val sensorLocation = SensorLocation(640, 2068, 117, 0.75f) assertThat(SensorLocation.decode(sensorLocation.encode())).isEqualTo(sensorLocation) } }