diff --git a/core/res/res/layout/autofill_save.xml b/core/res/res/layout/autofill_save.xml
index 50ff50f195647..63675ab03916b 100644
--- a/core/res/res/layout/autofill_save.xml
+++ b/core/res/res/layout/autofill_save.xml
@@ -44,8 +44,14 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
+
+
20%
+
+ 100dp
+
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 655a7f1cf6930..16a92978bcc49 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2901,8 +2901,9 @@
-
+
+
@@ -2926,6 +2927,7 @@
+
diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
index 512e1288d861a..2b7a671fc99db 100644
--- a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
+++ b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
@@ -34,6 +34,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Binder;
import android.os.Bundle;
@@ -481,10 +482,16 @@ final class AutofillManagerServiceImpl {
sendStateToClients(true);
}
+ @NonNull
CharSequence getServiceLabel() {
return mInfo.getServiceInfo().loadLabel(mContext.getPackageManager());
}
+ @NonNull
+ Drawable getServiceIcon() {
+ return mInfo.getServiceInfo().loadIcon(mContext.getPackageManager());
+ }
+
/**
* Initializes the last fill selection after an autofill service returned a new
* {@link FillResponse}.
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java
index e0e379f46309d..dd0c874530ddd 100644
--- a/services/autofill/java/com/android/server/autofill/Session.java
+++ b/services/autofill/java/com/android/server/autofill/Session.java
@@ -970,8 +970,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
mService.logSaveShown(id);
final IAutoFillManagerClient client = getClient();
mPendingSaveUi = new PendingUi(mActivityToken, id, client);
- getUiForShowing().showSaveUi(mService.getServiceLabel(), saveInfo,
- valueFinder, mPackageName, this, mPendingSaveUi);
+ getUiForShowing().showSaveUi(mService.getServiceLabel(), mService.getServiceIcon(),
+ saveInfo, valueFinder, mPackageName, this, mPendingSaveUi);
if (client != null) {
try {
client.setSaveUiState(id, true);
@@ -1774,7 +1774,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
/**
* Checks whether this session is hiding the Save UI to handle a custom description link for
- * a specific {@code token} created by {@link PendingUi#PendingUi(IBinder)}.
+ * a specific {@code token} created by
+ * {@link PendingUi#PendingUi(IBinder, int, IAutoFillManagerClient)}.
*/
boolean isSaveUiPendingForToken(@NonNull IBinder token) {
return isSaveUiPending() && token.equals(mPendingSaveUi.getToken());
diff --git a/services/autofill/java/com/android/server/autofill/ui/AutoFillUI.java b/services/autofill/java/com/android/server/autofill/ui/AutoFillUI.java
index a6f6713476cff..cac2bff579ed7 100644
--- a/services/autofill/java/com/android/server/autofill/ui/AutoFillUI.java
+++ b/services/autofill/java/com/android/server/autofill/ui/AutoFillUI.java
@@ -22,6 +22,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.content.IntentSender;
+import android.graphics.drawable.Drawable;
import android.metrics.LogMaker;
import android.os.Bundle;
import android.os.Handler;
@@ -244,8 +245,8 @@ public final class AutoFillUI {
/**
* Shows the UI asking the user to save for autofill.
*/
- public void showSaveUi(@NonNull CharSequence providerLabel, @NonNull SaveInfo info,
- @NonNull ValueFinder valueFinder, @NonNull String packageName,
+ public void showSaveUi(@NonNull CharSequence serviceLabel, @NonNull Drawable serviceIcon,
+ @NonNull SaveInfo info,@NonNull ValueFinder valueFinder, @NonNull String packageName,
@NonNull AutoFillUiCallback callback, @NonNull PendingUi pendingSaveUi) {
if (sVerbose) Slog.v(TAG, "showSaveUi() for " + packageName + ": " + info);
int numIds = 0;
@@ -261,8 +262,8 @@ public final class AutoFillUI {
return;
}
hideAllUiThread(callback);
- mSaveUi = new SaveUi(mContext, pendingSaveUi, providerLabel, info, valueFinder,
- mOverlayControl, new SaveUi.OnSaveListener() {
+ mSaveUi = new SaveUi(mContext, pendingSaveUi, serviceLabel, serviceIcon, info,
+ valueFinder, mOverlayControl, new SaveUi.OnSaveListener() {
@Override
public void onSave() {
log.setType(MetricsProto.MetricsEvent.TYPE_ACTION);
diff --git a/services/autofill/java/com/android/server/autofill/ui/SaveUi.java b/services/autofill/java/com/android/server/autofill/ui/SaveUi.java
index 160c84cbeffd9..d0b2e9240b584 100644
--- a/services/autofill/java/com/android/server/autofill/ui/SaveUi.java
+++ b/services/autofill/java/com/android/server/autofill/ui/SaveUi.java
@@ -22,10 +22,14 @@ import static com.android.server.autofill.Helper.sVerbose;
import android.annotation.NonNull;
import android.app.Dialog;
import android.app.PendingIntent;
-import android.app.PendingIntent.CanceledException;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
@@ -43,7 +47,7 @@ import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.view.autofill.AutofillManager;
-import android.view.autofill.IAutoFillManagerClient;
+import android.widget.ImageView;
import android.widget.RemoteViews;
import android.widget.ScrollView;
import android.widget.TextView;
@@ -121,9 +125,9 @@ final class SaveUi {
private boolean mDestroyed;
SaveUi(@NonNull Context context, @NonNull PendingUi pendingUi,
- @NonNull CharSequence providerLabel, @NonNull SaveInfo info,
- @NonNull ValueFinder valueFinder, @NonNull OverlayControl overlayControl,
- @NonNull OnSaveListener listener) {
+ @NonNull CharSequence serviceLabel, @NonNull Drawable serviceIcon,
+ @NonNull SaveInfo info, @NonNull ValueFinder valueFinder,
+ @NonNull OverlayControl overlayControl, @NonNull OnSaveListener listener) {
mPendingUi= pendingUi;
mListener = new OneTimeListener(listener);
mOverlayControl = overlayControl;
@@ -155,24 +159,25 @@ final class SaveUi {
switch (types.size()) {
case 1:
mTitle = Html.fromHtml(context.getString(R.string.autofill_save_title_with_type,
- types.valueAt(0), providerLabel), 0);
+ types.valueAt(0), serviceLabel), 0);
break;
case 2:
mTitle = Html.fromHtml(context.getString(R.string.autofill_save_title_with_2types,
- types.valueAt(0), types.valueAt(1), providerLabel), 0);
+ types.valueAt(0), types.valueAt(1), serviceLabel), 0);
break;
case 3:
mTitle = Html.fromHtml(context.getString(R.string.autofill_save_title_with_3types,
- types.valueAt(0), types.valueAt(1), types.valueAt(2), providerLabel), 0);
+ types.valueAt(0), types.valueAt(1), types.valueAt(2), serviceLabel), 0);
break;
default:
// Use generic if more than 3 or invalid type (size 0).
mTitle = Html.fromHtml(
- context.getString(R.string.autofill_save_title, providerLabel), 0);
+ context.getString(R.string.autofill_save_title, serviceLabel), 0);
}
-
titleView.setText(mTitle);
+ setServiceIcon(context, view, serviceIcon);
+
ScrollView subtitleContainer = null;
final CustomDescription customDescription = info.getCustomDescription();
if (customDescription != null) {
@@ -284,6 +289,30 @@ final class SaveUi {
show();
}
+ private void setServiceIcon(Context context, View view, Drawable serviceIcon) {
+ final ImageView iconView = view.findViewById(R.id.autofill_save_icon);
+ final Resources res = context.getResources();
+
+ final int maxWidth = res.getDimensionPixelSize(R.dimen.autofill_save_icon_max_size);
+ final int maxHeight = maxWidth;
+ final int actualWidth = serviceIcon.getMinimumWidth();
+ final int actualHeight = serviceIcon.getMinimumHeight();
+
+ if (actualWidth <= maxWidth && actualHeight <= maxHeight) {
+ if (sDebug) {
+ Slog.d(TAG, "Addingservice icon "
+ + "(" + actualWidth + "x" + actualHeight + ") as it's less than maximum "
+ + "(" + maxWidth + "x" + maxHeight + ").");
+ }
+ iconView.setImageDrawable(serviceIcon);
+ } else {
+ Slog.w(TAG, "Not adding service icon of size "
+ + "(" + actualWidth + "x" + actualHeight + ") because maximum is "
+ + "(" + maxWidth + "x" + maxHeight + ").");
+ iconView.setVisibility(View.INVISIBLE);
+ }
+ }
+
/**
* Update the pending UI, if any.
*