Merge "Implemented ACTION_REQUEST_SET_AUTOFILL_SERVICE." into oc-dev
am: c36ed203db
Change-Id: I5c27b2def2e7bea0c0cf575f5ff18db032b4519d
This commit is contained in:
@@ -3077,6 +3077,16 @@
|
|||||||
android:permission="android.permission.DUMP"
|
android:permission="android.permission.DUMP"
|
||||||
android:enabled="@bool/config_has_help" />
|
android:enabled="@bool/config_has_help" />
|
||||||
|
|
||||||
|
<activity android:name=".applications.defaultapps.AutofillPickerActivity"
|
||||||
|
android:taskAffinity=""
|
||||||
|
android:noHistory="true">
|
||||||
|
<intent-filter android:priority="1">
|
||||||
|
<action android:name="android.settings.REQUEST_SET_AUTOFILL_SERVICE" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:scheme="package" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<!-- This is the longest AndroidManifest.xml ever. -->
|
<!-- This is the longest AndroidManifest.xml ever. -->
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||||
|
* except in compliance with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||||
|
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the specific language governing
|
||||||
|
* permissions and limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.android.settings.applications.defaultapps;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.SettingsActivity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standalone activity used to launch {@link DefaultAppPickerFragment} from a
|
||||||
|
* {@link android.provider.Settings#ACTION_REQUEST_SET_AUTOFILL_SERVICE} intent.
|
||||||
|
*/
|
||||||
|
public class AutofillPickerActivity extends SettingsActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
final Intent intent = getIntent();
|
||||||
|
final String packageName = intent.getData().getSchemeSpecificPart();
|
||||||
|
intent.putExtra(EXTRA_SHOW_FRAGMENT, DefaultAutofillPicker.class.getName());
|
||||||
|
intent.putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.autofill_app);
|
||||||
|
intent.putExtra(DefaultAutofillPicker.EXTRA_PACKAGE_NAME, packageName);
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isValidFragment(String fragmentName) {
|
||||||
|
return super.isValidFragment(fragmentName)
|
||||||
|
|| DefaultAutofillPicker.class.getName().equals(fragmentName);
|
||||||
|
}
|
||||||
|
}
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.applications.defaultapps;
|
package com.android.settings.applications.defaultapps;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
@@ -38,6 +39,8 @@ public class DefaultAutofillPicker extends DefaultAppPickerFragment {
|
|||||||
static final String SETTING = Settings.Secure.AUTOFILL_SERVICE;
|
static final String SETTING = Settings.Secure.AUTOFILL_SERVICE;
|
||||||
static final Intent AUTOFILL_PROBE = new Intent(AutofillService.SERVICE_INTERFACE);
|
static final Intent AUTOFILL_PROBE = new Intent(AutofillService.SERVICE_INTERFACE);
|
||||||
|
|
||||||
|
static final String EXTRA_PACKAGE_NAME = "package_name";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MetricsProto.MetricsEvent.DEFAULT_AUTOFILL_PICKER;
|
return MetricsProto.MetricsEvent.DEFAULT_AUTOFILL_PICKER;
|
||||||
@@ -79,11 +82,24 @@ public class DefaultAutofillPicker extends DefaultAppPickerFragment {
|
|||||||
@Override
|
@Override
|
||||||
protected boolean setDefaultKey(String key) {
|
protected boolean setDefaultKey(String key) {
|
||||||
Settings.Secure.putString(getContext().getContentResolver(), SETTING, key);
|
Settings.Secure.putString(getContext().getContentResolver(), SETTING, key);
|
||||||
|
|
||||||
|
// Check if activity was launched from Settings.ACTION_REQUEST_SET_AUTOFILL_SERVICE
|
||||||
|
// intent, and set proper result if so...
|
||||||
|
final Activity activity = getActivity();
|
||||||
|
if (activity != null) {
|
||||||
|
final String packageName = activity.getIntent().getStringExtra(EXTRA_PACKAGE_NAME);
|
||||||
|
if (packageName != null) {
|
||||||
|
final int result = key != null && key.startsWith(packageName) ? Activity.RESULT_OK
|
||||||
|
: Activity.RESULT_CANCELED;
|
||||||
|
activity.setResult(result);
|
||||||
|
activity.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides Intent to setting activity for the specified auto-fill service.
|
* Provides Intent to setting activity for the specified autofill service.
|
||||||
*/
|
*/
|
||||||
static final class AutofillSettingIntentProvider implements SettingIntentProvider {
|
static final class AutofillSettingIntentProvider implements SettingIntentProvider {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user