diff options
| author | 2017-04-05 01:52:50 +0000 | |
|---|---|---|
| committer | 2017-04-05 01:52:55 +0000 | |
| commit | 045c71f1be06b89614102420b47d9184055cd190 (patch) | |
| tree | 69c09ef73b84964ed9aea6ab48ed3b4bd5f70eb6 | |
| parent | a6c7f413f80b0d4918cad019cfe4aca185e03cb9 (diff) | |
| parent | ff35509ee9ef89f42607d1424fa6b4df8de98a90 (diff) | |
Merge "Adds a config for default autofill service." into oc-dev
5 files changed, 36 insertions, 7 deletions
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 85ecaff26b21..221e30874367 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -2822,4 +2822,11 @@ <!-- Whether the device supports quick settings and its associated APIs --> <bool name="config_quickSettingsSupported">true</bool> + + <!-- The component name, flattened to a string, for the default autofill service + to enabled for an user. This service must be trusted, as it can be activated + without explicit consent of the user. If no autofill service with the + specified name exists on the device, autofill will be disabled by default. + --> + <string name="config_defaultAutofillService" translatable="false"></string> </resources> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index ae05a69da20d..c12116a22b16 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2944,6 +2944,7 @@ <java-symbol type="string" name="notification_channel_alerts" /> <java-symbol type="string" name="notification_channel_retail_mode" /> <java-symbol type="string" name="notification_channel_usb" /> + <java-symbol type="string" name="config_defaultAutofillService" /> <!-- ETWS primary messages --> <java-symbol type="string" name="etws_primary_default_message_earthquake" /> diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java index 0d0ddf2046a7..1f559e4eb88a 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java @@ -2798,7 +2798,7 @@ public class SettingsProvider extends ContentProvider { } private final class UpgradeController { - private static final int SETTINGS_VERSION = 143; + private static final int SETTINGS_VERSION = 144; private final int mUserId; @@ -3324,7 +3324,7 @@ public class SettingsProvider extends ContentProvider { } if (currentVersion == 141) { - // Version 141: We added the notion of a default and whether the system set + // Version 142: We added the notion of a default and whether the system set // the setting. This is used for resetting the internal state and we need // to make sure this value is updated for the existing settings, otherwise // we would delete system set settings while they should stay unmodified. @@ -3344,7 +3344,7 @@ public class SettingsProvider extends ContentProvider { } if (currentVersion == 142) { - // Version 142: Set a default value for Wi-Fi wakeup feature. + // Version 143: Set a default value for Wi-Fi wakeup feature. if (userId == UserHandle.USER_SYSTEM) { final SettingsState globalSettings = getGlobalSettingsLocked(); Setting currentSetting = globalSettings.getSettingLocked( @@ -3361,6 +3361,27 @@ public class SettingsProvider extends ContentProvider { currentVersion = 143; } + if (currentVersion == 143) { + // Version 144: Set a default value for Autofill service. + final SettingsState secureSettings = getSecureSettingsLocked(userId); + final Setting currentSetting = secureSettings + .getSettingLocked(Settings.Secure.AUTOFILL_SERVICE); + if (currentSetting.isNull()) { + final String defaultValue = getContext().getResources().getString( + com.android.internal.R.string.config_defaultAutofillService); + if (defaultValue != null) { + Slog.d(LOG_TAG, "Setting [" + defaultValue + "] as Autofill Service " + + "for user " + userId); + secureSettings.insertSettingLocked(Settings.Secure.AUTOFILL_SERVICE, + defaultValue, null, true, SettingsState.SYSTEM_PACKAGE_NAME); + } + } + + currentVersion = 144; + } + + // vXXX: Add new settings above this point. + if (currentVersion != newVersion) { Slog.wtf("SettingsProvider", "warning: upgrading settings database to version " + newVersion + " left it at " @@ -3372,8 +3393,6 @@ public class SettingsProvider extends ContentProvider { } } - // vXXX: Add new settings above this point. - // Return the current version. return currentVersion; } diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java index be14440a6a5c..502b5fc1ea6f 100644 --- a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java +++ b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java @@ -23,7 +23,6 @@ import static com.android.server.autofill.Helper.DEBUG; import static com.android.server.autofill.Helper.VERBOSE; import static com.android.server.autofill.Helper.bundleToString; -import android.Manifest; import android.annotation.NonNull; import android.app.ActivityManagerInternal; import android.content.BroadcastReceiver; @@ -36,7 +35,6 @@ import android.content.pm.UserInfo; import android.database.ContentObserver; import android.graphics.Rect; import android.net.Uri; -import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java index dbf1e83f8eac..15ec98fd67b2 100644 --- a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java +++ b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java @@ -57,6 +57,7 @@ import android.view.autofill.AutofillId; import android.view.autofill.AutofillValue; import android.view.autofill.IAutoFillManagerClient; +import com.android.internal.R; import com.android.internal.annotations.GuardedBy; import com.android.internal.os.HandlerCaller; import com.android.internal.os.IResultReceiver; @@ -431,8 +432,11 @@ final class AutofillManagerServiceImpl { void dumpLocked(String prefix, PrintWriter pw) { final String prefix2 = prefix + " "; + pw.print(prefix); pw.print("User :"); pw.println(mUserId); pw.print(prefix); pw.print("Component:"); pw.println(mInfo != null ? mInfo.getServiceInfo().getComponentName() : null); + pw.print(prefix); pw.print("Default component: "); + pw.println(mContext.getString(R.string.config_defaultAutofillService)); pw.print(prefix); pw.print("Disabled:"); pw.println(mDisabled); if (VERBOSE && mInfo != null) { |