Loading packages/SettingsLib/Graph/graph.proto +2 −0 Original line number Diff line number Diff line Loading @@ -108,6 +108,7 @@ message PreferenceValueProto { oneof value { bool boolean_value = 1; int32 int_value = 2; float float_value = 3; } } Loading @@ -116,6 +117,7 @@ message PreferenceValueDescriptorProto { oneof type { bool boolean_type = 1; RangeValueProto range_value = 2; bool float_type = 3; } } Loading packages/SettingsLib/Graph/src/com/android/settingslib/graph/PreferenceGraphBuilder.kt +7 −7 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import com.android.settingslib.graph.proto.PreferenceProto.ActionTarget import com.android.settingslib.graph.proto.PreferenceScreenProto import com.android.settingslib.graph.proto.TextProto import com.android.settingslib.metadata.BooleanValue import com.android.settingslib.metadata.FloatPersistentPreference import com.android.settingslib.metadata.PersistentPreference import com.android.settingslib.metadata.PreferenceAvailabilityProvider import com.android.settingslib.metadata.PreferenceHierarchy Loading Loading @@ -399,15 +400,13 @@ fun PreferenceMetadata.toProto( metadata is PersistentPreference<*> && metadata.evalReadPermit(context, callingPid, callingUid) == ReadWritePermit.ALLOW ) { val storage = metadata.storage(context) value = preferenceValueProto { when (metadata) { is BooleanValue -> metadata.storage(context).getBoolean(metadata.key)?.let { booleanValue = it } is RangeValue -> { metadata.storage(context).getInt(metadata.key)?.let { intValue = it } } is BooleanValue -> storage.getBoolean(metadata.key)?.let { booleanValue = it } is RangeValue -> storage.getInt(metadata.key)?.let { intValue = it } is FloatPersistentPreference -> storage.getFloat(metadata.key)?.let { floatValue = it } else -> {} } } Loading @@ -421,6 +420,7 @@ fun PreferenceMetadata.toProto( max = metadata.getMaxValue(context) step = metadata.getIncrementStep(context) } is FloatPersistentPreference -> floatType = true else -> {} } } Loading packages/SettingsLib/Graph/src/com/android/settingslib/graph/PreferenceSetterApi.kt +6 −0 Original line number Diff line number Diff line Loading @@ -159,6 +159,12 @@ class PreferenceSetterApiHandler( } storage.setInt(key, intValue) return PreferenceSetterResult.OK } else if (value.hasFloatValue()) { val floatValue = value.floatValue val resultCode = metadata.checkWritePermit(floatValue) if (resultCode != PreferenceSetterResult.OK) return resultCode storage.setFloat(key, floatValue) return PreferenceSetterResult.OK } } catch (e: Exception) { return PreferenceSetterResult.INTERNAL_ERROR Loading packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PersistentPreference.kt +3 −0 Original line number Diff line number Diff line Loading @@ -201,3 +201,6 @@ interface RangeValue : ValueDescriptor { override fun isValidValue(context: Context, index: Int) = index in getMinValue(context)..getMaxValue(context) } /** A persistent preference that has a float value. */ interface FloatPersistentPreference : PersistentPreference<Float> Loading
packages/SettingsLib/Graph/graph.proto +2 −0 Original line number Diff line number Diff line Loading @@ -108,6 +108,7 @@ message PreferenceValueProto { oneof value { bool boolean_value = 1; int32 int_value = 2; float float_value = 3; } } Loading @@ -116,6 +117,7 @@ message PreferenceValueDescriptorProto { oneof type { bool boolean_type = 1; RangeValueProto range_value = 2; bool float_type = 3; } } Loading
packages/SettingsLib/Graph/src/com/android/settingslib/graph/PreferenceGraphBuilder.kt +7 −7 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import com.android.settingslib.graph.proto.PreferenceProto.ActionTarget import com.android.settingslib.graph.proto.PreferenceScreenProto import com.android.settingslib.graph.proto.TextProto import com.android.settingslib.metadata.BooleanValue import com.android.settingslib.metadata.FloatPersistentPreference import com.android.settingslib.metadata.PersistentPreference import com.android.settingslib.metadata.PreferenceAvailabilityProvider import com.android.settingslib.metadata.PreferenceHierarchy Loading Loading @@ -399,15 +400,13 @@ fun PreferenceMetadata.toProto( metadata is PersistentPreference<*> && metadata.evalReadPermit(context, callingPid, callingUid) == ReadWritePermit.ALLOW ) { val storage = metadata.storage(context) value = preferenceValueProto { when (metadata) { is BooleanValue -> metadata.storage(context).getBoolean(metadata.key)?.let { booleanValue = it } is RangeValue -> { metadata.storage(context).getInt(metadata.key)?.let { intValue = it } } is BooleanValue -> storage.getBoolean(metadata.key)?.let { booleanValue = it } is RangeValue -> storage.getInt(metadata.key)?.let { intValue = it } is FloatPersistentPreference -> storage.getFloat(metadata.key)?.let { floatValue = it } else -> {} } } Loading @@ -421,6 +420,7 @@ fun PreferenceMetadata.toProto( max = metadata.getMaxValue(context) step = metadata.getIncrementStep(context) } is FloatPersistentPreference -> floatType = true else -> {} } } Loading
packages/SettingsLib/Graph/src/com/android/settingslib/graph/PreferenceSetterApi.kt +6 −0 Original line number Diff line number Diff line Loading @@ -159,6 +159,12 @@ class PreferenceSetterApiHandler( } storage.setInt(key, intValue) return PreferenceSetterResult.OK } else if (value.hasFloatValue()) { val floatValue = value.floatValue val resultCode = metadata.checkWritePermit(floatValue) if (resultCode != PreferenceSetterResult.OK) return resultCode storage.setFloat(key, floatValue) return PreferenceSetterResult.OK } } catch (e: Exception) { return PreferenceSetterResult.INTERNAL_ERROR Loading
packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PersistentPreference.kt +3 −0 Original line number Diff line number Diff line Loading @@ -201,3 +201,6 @@ interface RangeValue : ValueDescriptor { override fun isValidValue(context: Context, index: Int) = index in getMinValue(context)..getMaxValue(context) } /** A persistent preference that has a float value. */ interface FloatPersistentPreference : PersistentPreference<Float>