Launch work profile activity to add Autofill service
ag/4666330 allowed choosing separate Autofill services for the main and work profile. However, the 'Add service' button for work profile always resolved action_view intent as the main user even when clicking the work profile preference. Now the intent is resolved to the right profile depending on the preference clicked. BUG: 112610177 Test: Verified manually Change-Id: I870346d7b5618e7c230edebd59ac7f52f8495d47
This commit is contained in:
@@ -35,6 +35,7 @@ import android.text.Html;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.Preference.OnPreferenceClickListener;
|
||||||
import com.android.internal.content.PackageMonitor;
|
import com.android.internal.content.PackageMonitor;
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
import com.android.internal.logging.nano.MetricsProto;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -168,11 +169,15 @@ public class DefaultAutofillPicker extends DefaultAppPickerFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Intent addNewServiceIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(searchUri));
|
final Intent addNewServiceIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(searchUri));
|
||||||
Preference preference = new Preference(getPrefContext());
|
final Context context = getPrefContext();
|
||||||
|
final Preference preference = new Preference(context);
|
||||||
|
preference.setOnPreferenceClickListener(p -> {
|
||||||
|
context.startActivityAsUser(addNewServiceIntent, UserHandle.of(mUserId));
|
||||||
|
return true;
|
||||||
|
});
|
||||||
preference.setTitle(R.string.print_menu_item_add_service);
|
preference.setTitle(R.string.print_menu_item_add_service);
|
||||||
preference.setIcon(R.drawable.ic_menu_add);
|
preference.setIcon(R.drawable.ic_menu_add);
|
||||||
preference.setOrder(Integer.MAX_VALUE -1);
|
preference.setOrder(Integer.MAX_VALUE -1);
|
||||||
preference.setIntent(addNewServiceIntent);
|
|
||||||
preference.setPersistent(false);
|
preference.setPersistent(false);
|
||||||
return preference;
|
return preference;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user