summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/CredentialManager/src/com/android/credentialmanager/autofill/CredentialAutofillService.kt19
-rw-r--r--services/autofill/java/com/android/server/autofill/AutofillManagerService.java20
-rw-r--r--services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java20
3 files changed, 50 insertions, 9 deletions
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/autofill/CredentialAutofillService.kt b/packages/CredentialManager/src/com/android/credentialmanager/autofill/CredentialAutofillService.kt
index 52038f8c1529..9355517d8bf9 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/autofill/CredentialAutofillService.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/autofill/CredentialAutofillService.kt
@@ -39,6 +39,7 @@ import android.service.autofill.SaveRequest
import android.service.credentials.CredentialProviderService
import android.util.Log
import android.view.autofill.AutofillId
+import org.json.JSONException
import android.widget.inline.InlinePresentationSpec
import androidx.autofill.inline.v1.InlineSuggestionUi
import com.android.credentialmanager.GetFlowUtils
@@ -56,11 +57,9 @@ class CredentialAutofillService : AutofillService() {
private const val SYS_PROVIDER_REQ_KEY = "isSystemProviderRequired"
private const val CRED_OPTIONS_KEY = "credentialOptions"
private const val TYPE_KEY = "type"
+ private const val REQ_TYPE_KEY = "get"
}
- private val credentialManager: CredentialManager =
- getSystemService(Context.CREDENTIAL_SERVICE) as CredentialManager
-
override fun onFillRequest(
request: FillRequest,
cancellationSignal: CancellationSignal,
@@ -73,9 +72,12 @@ class CredentialAutofillService : AutofillService() {
val getCredRequest: GetCredentialRequest? = getCredManRequest(structure)
if (getCredRequest == null) {
+ Log.i(TAG, "No credential manager request found")
callback.onFailure("No credential manager request found")
return
}
+ val credentialManager: CredentialManager =
+ getSystemService(Context.CREDENTIAL_SERVICE) as CredentialManager
val outcome = object : OutcomeReceiver<GetCandidateCredentialsResponse,
GetCandidateCredentialsException> {
@@ -244,8 +246,12 @@ class CredentialAutofillService : AutofillService() {
val credentialOptions: MutableList<CredentialOption> = mutableListOf()
for (credentialHint in credentialHints) {
- convertJsonToCredentialOption(credentialHint, autofillId)
- .let { credentialOptions.addAll(it) }
+ try {
+ convertJsonToCredentialOption(credentialHint, autofillId)
+ .let { credentialOptions.addAll(it) }
+ } catch (e: JSONException) {
+ Log.i(TAG, "Exception while parsing response: " + e.message)
+ }
}
return credentialOptions
}
@@ -257,7 +263,8 @@ class CredentialAutofillService : AutofillService() {
val credentialOptions: MutableList<CredentialOption> = mutableListOf()
val json = JSONObject(jsonString)
- val options = json.getJSONArray(CRED_OPTIONS_KEY)
+ val jsonGet = json.getJSONObject(REQ_TYPE_KEY)
+ val options = jsonGet.getJSONArray(CRED_OPTIONS_KEY)
for (i in 0 until options.length()) {
val option = options.getJSONObject(i)
val candidateBundle = convertJsonToBundle(option.getJSONObject(CANDIDATE_DATA_KEY))
diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java
index 3e134992c763..72242d265e79 100644
--- a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java
+++ b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java
@@ -228,6 +228,9 @@ public final class AutofillManagerService
private int mMaxInputLengthForAutofill;
@GuardedBy("mFlagLock")
+ private boolean mAutofillCredmanIntegrationEnabled;
+
+ @GuardedBy("mFlagLock")
private boolean mIsFillFieldsFromCurrentSessionOnly;
// Default flag values for Autofill PCC
@@ -705,13 +708,16 @@ public final class AutofillManagerService
DeviceConfig.NAMESPACE_AUTOFILL,
AutofillFeatureFlags.DEVICE_CONFIG_MAX_INPUT_LENGTH_FOR_AUTOFILL,
AutofillFeatureFlags.DEFAULT_MAX_INPUT_LENGTH_FOR_AUTOFILL);
+ mAutofillCredmanIntegrationEnabled = Flags.autofillCredmanIntegration();
mIsFillFieldsFromCurrentSessionOnly = Flags.fillFieldsFromCurrentSessionOnly();
if (verbose) {
Slog.v(mTag, "setDeviceConfigProperties() for PCC: "
+ "mPccClassificationEnabled=" + mPccClassificationEnabled
+ ", mPccPreferProviderOverPcc=" + mPccPreferProviderOverPcc
+ ", mPccUseFallbackDetection=" + mPccUseFallbackDetection
- + ", mPccProviderHints=" + mPccProviderHints);
+ + ", mPccProviderHints=" + mPccProviderHints
+ + ", mAutofillCredmanIntegrationEnabled="
+ + mAutofillCredmanIntegrationEnabled);
}
}
}
@@ -970,6 +976,15 @@ public final class AutofillManagerService
}
/**
+ * Whether the Autofill-Credman integration feature flag is enabled.
+ */
+ public boolean isAutofillCredmanIntegrationEnabled() {
+ synchronized (mFlagLock) {
+ return mAutofillCredmanIntegrationEnabled;
+ }
+ }
+
+ /**
* Whether the Autofill Provider shouldbe preferred over PCC results for selecting datasets.
*/
public boolean preferProviderOverPcc() {
@@ -2110,6 +2125,9 @@ public final class AutofillManagerService
pw.print(";");
pw.print("mPccProviderHints=");
pw.println(mPccProviderHints);
+ pw.print(";");
+ pw.print("mAutofillCredmanIntegrationEnabled=");
+ pw.println(mAutofillCredmanIntegrationEnabled);
}
// Dump per-user services
dumpLocked("", pw);
diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
index 5b8bdd57ccbb..518b81f19467 100644
--- a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
+++ b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
@@ -19,6 +19,7 @@ package com.android.server.autofill;
import static android.service.autofill.FillEventHistory.Event.NO_SAVE_UI_REASON_NONE;
import static android.service.autofill.FillEventHistory.Event.UI_TYPE_INLINE;
import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST;
+import static android.service.autofill.FillRequest.FLAG_SCREEN_HAS_CREDMAN_FIELD;
import static android.view.autofill.AutofillManager.ACTION_START_SESSION;
import static android.view.autofill.AutofillManager.FLAG_ADD_CLIENT_ENABLED;
import static android.view.autofill.AutofillManager.FLAG_ADD_CLIENT_ENABLED_FOR_AUGMENTED_AUTOFILL_ONLY;
@@ -103,6 +104,10 @@ final class AutofillManagerServiceImpl
extends AbstractPerUserSystemService<AutofillManagerServiceImpl, AutofillManagerService> {
private static final String TAG = "AutofillManagerServiceImpl";
+
+ private static final ComponentName CREDMAN_SERVICE_COMPONENT_NAME =
+ new ComponentName("com.android.credentialmanager",
+ "com.android.credentialmanager.autofill.CredentialAutofillService");
private static final int MAX_SESSION_ID_CREATE_TRIES = 2048;
/** Minimum interval to prune abandoned sessions */
@@ -532,9 +537,16 @@ final class AutofillManagerServiceImpl
assertCallerLocked(clientActivity, compatMode);
- // It's null when the session is just for augmented autofill
- final ComponentName serviceComponentName = mInfo == null ? null
+ ComponentName serviceComponentName = mInfo == null ? null
: mInfo.getServiceInfo().getComponentName();
+
+ if (isAutofillCredmanIntegrationEnabled()
+ && ((flags & FLAG_SCREEN_HAS_CREDMAN_FIELD) != 0)) {
+ // Hardcode to credential manager proxy service
+ Slog.i(TAG, "Routing to CredentialAutofillService");
+ serviceComponentName = CREDMAN_SERVICE_COMPONENT_NAME;
+ }
+
final Session newSession = new Session(this, mUi, getContext(), mHandler, mUserId, mLock,
sessionId, taskId, clientUid, clientActivityToken, clientCallback, hasCallback,
mUiLatencyHistory, mWtfHistory, serviceComponentName,
@@ -1747,6 +1759,10 @@ final class AutofillManagerServiceImpl
}
}
+ public boolean isAutofillCredmanIntegrationEnabled() {
+ return mMaster.isAutofillCredmanIntegrationEnabled();
+ }
+
/**
* Called when the {@link AutofillManagerService#mFieldClassificationResolver}
* changed (among other places).