Use AFM.getAutofillServiceComponentName() in Settings's AutofillPickerTrampolineActivity
Fixes: 80189659 Test: m -j Settings && adb sync && adb shell kill `pid com.android.settings` && adb shell am start com.android.settings Change-Id: I3dc4ebd1a8ffb26b131905c3fc4ed59567049925
This commit is contained in:
@@ -14,9 +14,9 @@
|
|||||||
package com.android.settings.applications.autofill;
|
package com.android.settings.applications.autofill;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserHandle;
|
|
||||||
import android.view.autofill.AutofillManager;
|
import android.view.autofill.AutofillManager;
|
||||||
|
|
||||||
import com.android.settings.applications.defaultapps.DefaultAutofillPicker;
|
import com.android.settings.applications.defaultapps.DefaultAutofillPicker;
|
||||||
@@ -34,23 +34,23 @@ public class AutofillPickerTrampolineActivity extends Activity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
// First check if the current user's service already belongs to the app...
|
final AutofillManager afm = getSystemService(AutofillManager.class);
|
||||||
final Intent intent = getIntent();
|
|
||||||
final String packageName = intent.getData().getSchemeSpecificPart();
|
// First check if the Autofill is available for the current user...
|
||||||
final String currentService = DefaultAutofillPicker.getDefaultKey(
|
if (afm == null || !afm.hasAutofillFeature() || !afm.isAutofillSupported()) {
|
||||||
this, UserHandle.myUserId());
|
// ... and fail right away if it is not.
|
||||||
if (currentService != null && currentService.startsWith(packageName)) {
|
setResult(RESULT_CANCELED);
|
||||||
// ...and succeed right away if it does.
|
|
||||||
setResult(RESULT_OK);
|
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then check if the Autofill is available for the current user...
|
// Then check if the current user's service already belongs to the app...
|
||||||
final AutofillManager afm = getSystemService(AutofillManager.class);
|
final Intent intent = getIntent();
|
||||||
if (afm == null || !afm.hasAutofillFeature() || !afm.isAutofillSupported()) {
|
final String packageName = intent.getData().getSchemeSpecificPart();
|
||||||
// ... and fail right away if it is not.
|
final ComponentName currentService = afm.getAutofillServiceComponentName();
|
||||||
setResult(RESULT_CANCELED);
|
if (currentService != null && currentService.getPackageName().equals(packageName)) {
|
||||||
|
// ...and succeed right away if it does.
|
||||||
|
setResult(RESULT_OK);
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user