From 70bcf38e2cf27cfcd920ebf17500fa97478dc0d0 Mon Sep 17 00:00:00 2001 From: Felipe Leme Date: Thu, 24 Jan 2019 14:55:03 -0800 Subject: [PATCH] Moved Content Capture settings to DeviceConfig. To test, manually played with 'adb shell device_config'. Examples: $ adb shell device_config list content_capture $ adb shell device_config delete content_capture enable_contentcapture $ adb shell stop && adb shell start $ adb shell service check content_capture Service content_capture: not found $ adb shell device_config put content_capture enable_contentcapture always $ adb shell stop && adb shell start $ adb shell service check content_capture Service content_capture: found Then ran CTS and FrameworkCoreTests below... Test: atest CtsContentCaptureServiceTestCases \ FrameworksCoreTests:android.provider.SettingsBackupTest#secureSettingsBackedUpOrBlacklisted Test: m update-api Bug: 121037717 Bug: 121153631 Change-Id: Ib93bf8181253228ccbdb3edbd84c5d0431c84eb4 --- api/system-current.txt | 4 +++ core/java/android/provider/DeviceConfig.java | 33 +++++++++++++++++++ core/java/android/provider/Settings.java | 23 ------------- .../android/providers/settings/global.proto | 7 +--- .../android/provider/SettingsBackupTest.java | 1 - .../settings/SettingsProtoDumpUtil.java | 6 ---- .../java/com/android/server/SystemServer.java | 10 +++--- 7 files changed, 43 insertions(+), 41 deletions(-) diff --git a/api/system-current.txt b/api/system-current.txt index e0af359c999bd..c0385d3feece8 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -5749,6 +5749,10 @@ package android.provider { field public static final String PROPERTY_SERVICE_ENABLED = "service_enabled"; } + public static interface DeviceConfig.ContentCapture { + field public static final String NAMESPACE = "content_capture"; + } + public static interface DeviceConfig.FsiBoot { field public static final String NAMESPACE = "fsi_boot"; field public static final String OOB_ENABLED = "oob_enabled"; diff --git a/core/java/android/provider/DeviceConfig.java b/core/java/android/provider/DeviceConfig.java index d58e00af5054d..f2f906681e44a 100644 --- a/core/java/android/provider/DeviceConfig.java +++ b/core/java/android/provider/DeviceConfig.java @@ -69,6 +69,39 @@ public final class DeviceConfig { @SystemApi public static final String NAMESPACE_AUTOFILL = "autofill"; + /** + * ContentCapture-related properties definitions. + * + * @hide + */ + @SystemApi + public interface ContentCapture { + String NAMESPACE = "content_capture"; + + /** + * Property used by {@code com.android.server.SystemServer} on start to decide whether + * the Content Capture service should be created or not. + * + *

Possible values are: + * + *

+ * + * @hide + */ + // TODO(b/121153631): revert back to SERVICE_EXPLICITLY_ENABLED approach + String PROPERTY_CONTENTCAPTURE_ENABLED = "enable_contentcapture"; + } + /** * Namespace for content capture feature used by on-device machine intelligence * to provide suggestions in a privacy-safe manner. diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 927c729758b50..4b46310abc180 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -13261,29 +13261,6 @@ public final class Settings { public static final String MAX_SOUND_TRIGGER_DETECTION_SERVICE_OPS_PER_DAY = "max_sound_trigger_detection_service_ops_per_day"; - /** - * Property used by {@code com.android.server.SystemServer} on start to decide whether - * the Content Capture service should be created or not. - * - *

Possible values are: - * - *

- * - * @hide - */ - public static final String CONTENT_CAPTURE_SERVICE_EXPLICITLY_ENABLED = - "content_capture_service_explicitly_enabled"; - /** {@hide} */ public static final String ISOLATED_STORAGE_LOCAL = "isolated_storage_local"; /** {@hide} */ diff --git a/core/proto/android/providers/settings/global.proto b/core/proto/android/providers/settings/global.proto index 7e7942e6ddf1a..602f9acb09fdc 100644 --- a/core/proto/android/providers/settings/global.proto +++ b/core/proto/android/providers/settings/global.proto @@ -230,12 +230,7 @@ message GlobalSettingsProto { } optional Connectivity connectivity = 32; - message ContentCapture { - option (android.msg_privacy).dest = DEST_EXPLICIT; - - optional SettingProto service_explicitly_enabled = 1 [ (android.privacy).dest = DEST_AUTOMATIC ]; - } - optional ContentCapture content_capture = 145; + reserved 145; // Used to be ContentCapture, which moved to DeviceConfig optional SettingProto contact_metadata_sync_enabled = 33 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto contacts_database_wal_enabled = 34 [ (android.privacy).dest = DEST_AUTOMATIC ]; diff --git a/core/tests/coretests/src/android/provider/SettingsBackupTest.java b/core/tests/coretests/src/android/provider/SettingsBackupTest.java index 2a29f8336adcc..02782bbde4523 100644 --- a/core/tests/coretests/src/android/provider/SettingsBackupTest.java +++ b/core/tests/coretests/src/android/provider/SettingsBackupTest.java @@ -192,7 +192,6 @@ public class SettingsBackupTest { Settings.Global.CONNECTIVITY_METRICS_BUFFER_SIZE, Settings.Global.CONNECTIVITY_SAMPLING_INTERVAL_IN_SECONDS, Settings.Global.CONTACT_METADATA_SYNC_ENABLED, - Settings.Global.CONTENT_CAPTURE_SERVICE_EXPLICITLY_ENABLED, Settings.Global.CONVERSATION_ACTIONS_UPDATE_CONTENT_URL, Settings.Global.CONVERSATION_ACTIONS_UPDATE_METADATA_URL, Settings.Global.CONTACTS_DATABASE_WAL_ENABLED, diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java index a1aefabfc7f24..c458fed844db2 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java @@ -422,12 +422,6 @@ class SettingsProtoDumpUtil { Settings.Global.CONTACTS_DATABASE_WAL_ENABLED, GlobalSettingsProto.CONTACTS_DATABASE_WAL_ENABLED); - final long contentCaptureToken = p.start(GlobalSettingsProto.CONTENT_CAPTURE); - dumpSetting(s, p, - Settings.Global.CONTENT_CAPTURE_SERVICE_EXPLICITLY_ENABLED, - GlobalSettingsProto.ContentCapture.SERVICE_EXPLICITLY_ENABLED); - p.end(contentCaptureToken); - final long dataToken = p.start(GlobalSettingsProto.DATA); // Settings.Global.DEFAULT_RESTRICT_BACKGROUND_DATA intentionally excluded. dumpSetting(s, p, diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 5861368026197..80552d88a49d0 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -55,6 +55,7 @@ import android.os.SystemProperties; import android.os.Trace; import android.os.UserHandle; import android.os.storage.IStorageManager; +import android.provider.DeviceConfig; import android.provider.Settings; import android.sysprop.VoldProperties; import android.text.TextUtils; @@ -2212,10 +2213,9 @@ public final class SystemServer { } private void startContentCaptureService(@NonNull Context context) { - - // Check if it was explicitly enabled by Settings - final String settings = Settings.Global.getString(context.getContentResolver(), - Settings.Global.CONTENT_CAPTURE_SERVICE_EXPLICITLY_ENABLED); + // Check if it was explicitly enabled by DeviceConfig + final String settings = DeviceConfig.getProperty(DeviceConfig.ContentCapture.NAMESPACE, + DeviceConfig.ContentCapture.PROPERTY_CONTENTCAPTURE_ENABLED); if (settings == null) { // Better be safe than sorry... Slog.d(TAG, "ContentCaptureService disabled because its not set by OEM"); @@ -2224,7 +2224,7 @@ public final class SystemServer { switch (settings) { case "always": // Should be used only during development - Slog.d(TAG, "ContentCaptureService explicitly enabled by Settings"); + Slog.d(TAG, "ContentCaptureService explicitly enabled by DeviceConfig"); break; case "default": // Default case: check if OEM overlaid the resource that defines the service.