diff options
| author | 2024-12-03 17:21:03 +0000 | |
|---|---|---|
| committer | 2024-12-03 17:21:03 +0000 | |
| commit | d2cf6ffd4dd18ee088d07a50f889bcd6104e9e99 (patch) | |
| tree | a6a566c93db15d56b74c343d3feeaec615297b92 | |
| parent | 57a37ccd4a87b0fbd3c140585a7ab455b9f9dfe1 (diff) | |
| parent | 164ec92f139976cabb37b1284fd677b004fb1f84 (diff) | |
Merge "Update Sensitivity Levels for Preferences" into main
| -rw-r--r-- | core/api/current.txt | 7 | ||||
| -rw-r--r-- | core/java/android/service/settings/preferences/SettingsPreferenceMetadata.java | 39 |
2 files changed, 31 insertions, 15 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index ac6e293c1729..814f117cd77c 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -42550,9 +42550,10 @@ package android.service.settings.preferences { method public boolean isWritable(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.service.settings.preferences.SettingsPreferenceMetadata> CREATOR; - field public static final int INTENT_ONLY = 2; // 0x2 - field public static final int NOT_SENSITIVE = 0; // 0x0 - field public static final int SENSITIVE = 1; // 0x1 + field public static final int EXPECT_POST_CONFIRMATION = 1; // 0x1 + field public static final int EXPECT_PRE_CONFIRMATION = 2; // 0x2 + field public static final int NO_DIRECT_ACCESS = 3; // 0x3 + field public static final int NO_SENSITIVITY = 0; // 0x0 } public static final class SettingsPreferenceMetadata.Builder { diff --git a/core/java/android/service/settings/preferences/SettingsPreferenceMetadata.java b/core/java/android/service/settings/preferences/SettingsPreferenceMetadata.java index 1acb7b8460cf..ea7d4a675713 100644 --- a/core/java/android/service/settings/preferences/SettingsPreferenceMetadata.java +++ b/core/java/android/service/settings/preferences/SettingsPreferenceMetadata.java @@ -187,27 +187,39 @@ public final class SettingsPreferenceMetadata implements Parcelable { /** @hide */ @IntDef(value = { - NOT_SENSITIVE, - SENSITIVE, - INTENT_ONLY + NO_SENSITIVITY, + EXPECT_POST_CONFIRMATION, + EXPECT_PRE_CONFIRMATION, + NO_DIRECT_ACCESS, }) @Retention(RetentionPolicy.SOURCE) public @interface WriteSensitivity {} /** - * Preference is not sensitive, thus its value is writable without explicit consent, assuming - * all necessary permissions are granted. + * Indicates preference is not sensitive. + * <p>Its value is writable without explicit consent, assuming all necessary permissions are + * granted. */ - public static final int NOT_SENSITIVE = 0; + public static final int NO_SENSITIVITY = 0; /** - * Preference is sensitive, meaning that in addition to necessary permissions, writing its value - * will also request explicit user consent. + * Indicates preference is mildly sensitive. + * <p>In addition to necessary permissions, after writing its value the user should be + * given the option to revert back. */ - public static final int SENSITIVE = 1; + public static final int EXPECT_POST_CONFIRMATION = 1; /** - * Preference is not permitted for write-access via API and must be changed via Settings page. + * Indicates preference is sensitive. + * <p>In addition to necessary permissions, the user should be prompted for confirmation prior + * to making a change. Otherwise it is suggested to provide a deeplink to the Preference's page + * instead, accessible via {@link #getLaunchIntent}. */ - public static final int INTENT_ONLY = 2; + public static final int EXPECT_PRE_CONFIRMATION = 2; + /** + * Indicates preference is highly sensitivity and carries significant user-risk. + * <p>This Preference cannot be changed through this API and no direct deeplink is available. + * Other Metadata is still available. + */ + public static final int NO_DIRECT_ACCESS = 3; private SettingsPreferenceMetadata(@NonNull Builder builder) { mKey = builder.mKey; @@ -303,7 +315,7 @@ public final class SettingsPreferenceMetadata implements Parcelable { private boolean mAvailable = false; private boolean mWritable = false; private boolean mRestricted = false; - @WriteSensitivity private int mSensitivity = INTENT_ONLY; + @WriteSensitivity private int mSensitivity = NO_DIRECT_ACCESS; private Intent mLaunchIntent; private Bundle mExtras; @@ -436,6 +448,9 @@ public final class SettingsPreferenceMetadata implements Parcelable { */ @NonNull public SettingsPreferenceMetadata build() { + if (mSensitivity == NO_DIRECT_ACCESS) { + mLaunchIntent = null; + } return new SettingsPreferenceMetadata(this); } } |