Improvements on ACTION_REQUEST_SET_AUTOFILL_SERVICE:
- Moved to proper package. - Returns right away when: - AutofillService for package is already selected - Autofill is not available Bug: 37576671 Bug: 37673809 Test: manual verification Test: make RunSettingsRoboTests -j90 Change-Id: Icda260cea1b4ce6cdefd8eff9625b2b768a5ed86
This commit is contained in:
@@ -18,10 +18,13 @@ package com.android.settings.applications.defaultapps;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.service.autofill.AutofillService;
|
||||
import android.service.autofill.AutofillServiceInfo;
|
||||
@@ -30,6 +33,7 @@ import android.text.TextUtils;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.defaultapps.DefaultAppPickerFragment.ConfirmationDialogFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -39,7 +43,35 @@ public class DefaultAutofillPicker extends DefaultAppPickerFragment {
|
||||
static final String SETTING = Settings.Secure.AUTOFILL_SERVICE;
|
||||
static final Intent AUTOFILL_PROBE = new Intent(AutofillService.SERVICE_INTERFACE);
|
||||
|
||||
static final String EXTRA_PACKAGE_NAME = "package_name";
|
||||
/**
|
||||
* Extra set when the fragment is implementing ACTION_REQUEST_SET_AUTOFILL_SERVICE.
|
||||
*/
|
||||
public static final String EXTRA_PACKAGE_NAME = "package_name";
|
||||
|
||||
/**
|
||||
* Set when the fragment is implementing ACTION_REQUEST_SET_AUTOFILL_SERVICE.
|
||||
*/
|
||||
public DialogInterface.OnClickListener mCancelListener;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null && activity.getIntent().getStringExtra(EXTRA_PACKAGE_NAME) != null) {
|
||||
mCancelListener = (d, w) -> {
|
||||
activity.setResult(Activity.RESULT_CANCELED);
|
||||
activity.finish();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConfirmationDialogFragment newConfirmationDialogFragment(String selectedKey,
|
||||
CharSequence confirmationMessage) {
|
||||
return ConfirmationDialogFragment.newInstance(this, selectedKey, confirmationMessage,
|
||||
mCancelListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
@@ -63,9 +95,13 @@ public class DefaultAutofillPicker extends DefaultAppPickerFragment {
|
||||
return candidates;
|
||||
}
|
||||
|
||||
public static String getDefaultKey(Context context) {
|
||||
return Settings.Secure.getString(context.getContentResolver(), SETTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultKey() {
|
||||
return Settings.Secure.getString(getContext().getContentResolver(), SETTING);
|
||||
return getDefaultKey(getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user