Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 65e15f48 authored by Jacky Wang's avatar Jacky Wang
Browse files

[Catalyst] Support sensitivity level

Bug: 380457585
Flag: com.android.settings.flags.catalyst
Test: Manual
Change-Id: I8477b376bd31020c19e8a22572bdd8d2fa6c4402
parent 66a5ee3b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -79,6 +79,8 @@ message PreferenceProto {
  optional IntentProto launch_intent = 14;
  // Descriptor of the preference value.
  optional PreferenceValueDescriptorProto value_descriptor = 15;
  // Indicate how sensitive of the preference.
  optional int32 sensitivity_level = 16;

  // Target of an Intent
  message ActionTarget {
+2 −1
Original line number Diff line number Diff line
@@ -55,9 +55,9 @@ import com.android.settingslib.metadata.RangeValue
import com.android.settingslib.metadata.ReadWritePermit
import com.android.settingslib.preference.PreferenceScreenFactory
import com.android.settingslib.preference.PreferenceScreenProvider
import java.util.Locale
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.util.Locale

private const val TAG = "PreferenceGraphBuilder"

@@ -387,6 +387,7 @@ fun PreferenceMetadata.toProto(
    }
    persistent = metadata.isPersistent(context)
    if (persistent) {
        if (metadata is PersistentPreference<*>) sensitivityLevel = metadata.sensitivityLevel
        if (
            flags.includeValue() &&
                enabled &&
+17 −0
Original line number Diff line number Diff line
@@ -42,6 +42,19 @@ annotation class ReadWritePermit {
    }
}

/** Indicates how sensitive of the data. */
@Retention(AnnotationRetention.SOURCE)
@Target(AnnotationTarget.TYPE)
annotation class SensitivityLevel {
    companion object {
        const val UNKNOWN_SENSITIVITY = 0
        const val NO_SENSITIVITY = 1
        const val LOW_SENSITIVITY = 2
        const val MEDIUM_SENSITIVITY = 3
        const val HIGH_SENSITIVITY = 4
    }
}

/** Preference interface that has a value persisted in datastore. */
interface PersistentPreference<T> {

@@ -86,6 +99,10 @@ interface PersistentPreference<T> {
            callingUid,
            this as PreferenceMetadata,
        )

    /** The sensitivity level of the preference. */
    val sensitivityLevel: @SensitivityLevel Int
        get() = SensitivityLevel.UNKNOWN_SENSITIVITY
}

/** Descriptor of values. */