Merge "[People Service] Fix issue in AOSP people service where `setupUser` in the People DataManager is stuck" into tm-qpr-dev
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 5ca8b05..2ea0d82 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -65,6 +65,7 @@
import android.provider.DocumentsProvider;
import android.provider.MediaStore;
import android.provider.OpenableColumns;
+import android.service.chooser.ChooserAction;
import android.telecom.PhoneAccount;
import android.telecom.TelecomManager;
import android.text.TextUtils;
@@ -5731,6 +5732,25 @@
= "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
/**
+ * A Parcelable[] of {@link ChooserAction} objects to provide the Android Sharesheet with
+ * app-specific actions to be presented to the user when invoking {@link #ACTION_CHOOSER}.
+ * @hide
+ */
+ public static final String EXTRA_CHOOSER_CUSTOM_ACTIONS =
+ "android.intent.extra.EXTRA_CHOOSER_CUSTOM_ACTIONS";
+
+ /**
+ * Optional argument to be used with {@link #ACTION_CHOOSER}.
+ * A {@link android.app.PendingIntent} to be sent when the user wants to do payload reselection
+ * in the sharesheet.
+ * A reselection action allows the user to return to the source app to change the content being
+ * shared.
+ * @hide
+ */
+ public static final String EXTRA_CHOOSER_PAYLOAD_RESELECTION_ACTION =
+ "android.intent.extra.EXTRA_CHOOSER_PAYLOAD_RESELECTION_ACTION";
+
+ /**
* An {@code ArrayList} of {@code String} annotations describing content for
* {@link #ACTION_CHOOSER}.
*
diff --git a/core/java/android/service/chooser/ChooserAction.java b/core/java/android/service/chooser/ChooserAction.java
new file mode 100644
index 0000000..3010049
--- /dev/null
+++ b/core/java/android/service/chooser/ChooserAction.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2022 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 android.service.chooser;
+
+import android.annotation.NonNull;
+import android.app.PendingIntent;
+import android.graphics.drawable.Icon;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.text.TextUtils;
+
+import java.util.Objects;
+
+/**
+ * A ChooserAction is an app-defined action that can be provided to the Android Sharesheet to
+ * be shown to the user when {@link android.content.Intent.ACTION_CHOOSER} is invoked.
+ *
+ * @see android.content.Intent.EXTRA_CHOOSER_CUSTOM_ACTIONS
+ * @see android.content.Intent.EXTRA_CHOOSER_PAYLOAD_RESELECTION_ACTION
+ * @hide
+ */
+public final class ChooserAction implements Parcelable {
+ private final Icon mIcon;
+ private final CharSequence mLabel;
+ private final PendingIntent mAction;
+
+ private ChooserAction(
+ Icon icon,
+ CharSequence label,
+ PendingIntent action) {
+ mIcon = icon;
+ mLabel = label;
+ mAction = action;
+ }
+
+ /**
+ * Return a user-readable label for this action.
+ */
+ @NonNull
+ public CharSequence getLabel() {
+ return mLabel;
+ }
+
+ /**
+ * Return an {@link Icon} representing this action.
+ */
+ @NonNull
+ public Icon getIcon() {
+ return mIcon;
+ }
+
+ /**
+ * Return the action intent.
+ */
+ @NonNull
+ public PendingIntent getAction() {
+ return mAction;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ mIcon.writeToParcel(dest, flags);
+ TextUtils.writeToParcel(mLabel, dest, flags);
+ mAction.writeToParcel(dest, flags);
+ }
+
+ @Override
+ public String toString() {
+ return "ChooserAction {" + "label=" + mLabel + ", intent=" + mAction + "}";
+ }
+
+ public static final Parcelable.Creator<ChooserAction> CREATOR =
+ new Creator<ChooserAction>() {
+ @Override
+ public ChooserAction createFromParcel(Parcel source) {
+ return new ChooserAction(
+ Icon.CREATOR.createFromParcel(source),
+ TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source),
+ PendingIntent.CREATOR.createFromParcel(source));
+ }
+
+ @Override
+ public ChooserAction[] newArray(int size) {
+ return new ChooserAction[size];
+ }
+ };
+
+ /**
+ * Builder class for {@link ChooserAction} objects
+ */
+ public static final class Builder {
+ private final Icon mIcon;
+ private final CharSequence mLabel;
+ private final PendingIntent mAction;
+
+ /**
+ * Construct a new builder for {@link ChooserAction} object.
+ *
+ * @param icon an {@link Icon} representing this action, consisting of a white foreground
+ * atop a transparent background.
+ * @param label label the user-readable label for this action.
+ * @param action {@link PendingIntent} to be invoked when the action is selected.
+ */
+ public Builder(
+ @NonNull Icon icon,
+ @NonNull CharSequence label,
+ @NonNull PendingIntent action) {
+ Objects.requireNonNull(icon, "icon can not be null");
+ Objects.requireNonNull(label, "label can not be null");
+ Objects.requireNonNull(action, "pending intent can not be null");
+ mIcon = icon;
+ mLabel = label;
+ mAction = action;
+ }
+
+ /**
+ * Combine all of the options that have been set and return a new {@link ChooserAction}
+ * object.
+ * @return the built action
+ */
+ public ChooserAction build() {
+ return new ChooserAction(mIcon, mLabel, mAction);
+ }
+ }
+}
diff --git a/packages/SystemUI/res/drawable/media_ttt_chip_background_receiver.xml b/packages/SystemUI/res/drawable/media_ttt_chip_background_receiver.xml
index 708bc1a..8aae276 100644
--- a/packages/SystemUI/res/drawable/media_ttt_chip_background_receiver.xml
+++ b/packages/SystemUI/res/drawable/media_ttt_chip_background_receiver.xml
@@ -19,8 +19,8 @@
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:shape="oval">
<size
- android:height="@dimen/media_ttt_chip_size_receiver"
- android:width="@dimen/media_ttt_chip_size_receiver"
+ android:height="@dimen/media_ttt_icon_size_receiver"
+ android:width="@dimen/media_ttt_icon_size_receiver"
/>
- <solid android:color="?androidprv:attr/colorSurface" />
+ <solid android:color="?androidprv:attr/colorAccentPrimary" />
</shape>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 5848237..ecb6560 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -1073,11 +1073,12 @@
<dimen name="media_ttt_last_item_start_margin">12dp</dimen>
<!-- Media tap-to-transfer chip for receiver device -->
- <dimen name="media_ttt_chip_size_receiver">100dp</dimen>
- <dimen name="media_ttt_icon_size_receiver">95dp</dimen>
+ <dimen name="media_ttt_icon_size_receiver">112dp</dimen>
<!-- Add some padding for the generic icon so it doesn't go all the way to the border. -->
- <dimen name="media_ttt_generic_icon_padding">12dp</dimen>
- <dimen name="media_ttt_receiver_vert_translation">20dp</dimen>
+ <!-- The generic icon should be 40dp, and the full icon is 112dp, so the padding should be
+ (112 - 40) / 2 = 36dp -->
+ <dimen name="media_ttt_generic_icon_padding">36dp</dimen>
+ <dimen name="media_ttt_receiver_vert_translation">40dp</dimen>
<!-- Window magnification -->
<dimen name="magnification_border_drag_size">35dp</dimen>