Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bab851c7 authored by Felipe Leme's avatar Felipe Leme
Browse files

Refined session management so Save can be automatically called.

This is yet another big refactoring:

- AutoFillManager keeps track of its current AutoFillSession.
- Views call AFM.startSession(View) when they can trigger autofill.
  (virtual views can call it as well). At this point, the manager
  sets an AutoFillSession, gets the activity token, and passes it to
  the service.
- Subsequent calls to AFM.start() will be ignored since the session
  is set.
- When the Activity is gone, it calls AFM.finishSession().
- Simlilarly, virtual views could call it as well.
- Added getAutoFillValue() to View.
- Removed AFM.updateAutoFillInput(childId): virtual views should now
  call startSession(childId) to start a session, and use the
  VirtualViewListener callbacks for updates.
- Change AutoFillValue to use String (which is immutable) instead of
  CharSequence for text values.
- Check if view is enabled before auto-filling.
- Removed 'cmd autofill fill' since it would require the appCallback
- Automatically dismiss the snack bar after 30s
- Moved the "don't change autofill value when autofilling" Inception
  logic into the service side.
- Etc...

BUG: 34819567
BUG: 33269702
BUG: 31001899

Test: manual verification
Test: CtsAutoFillServiceTestCases passes

Change-Id: I5fad928d4d666701302049d142026a1efa7291cd
parent 040ba81c
Loading
Loading
Loading
Loading
+7 −13
Original line number Diff line number Diff line
@@ -44391,7 +44391,8 @@ package android.view {
    method public android.view.animation.Animation getAnimation();
    method public android.os.IBinder getApplicationWindowToken();
    method public android.view.autofill.AutoFillType getAutoFillType();
    method public android.view.autofill.VirtualViewDelegate getAutoFillVirtualViewDelegate(android.view.autofill.VirtualViewDelegate.Callback);
    method public android.view.autofill.AutoFillValue getAutoFillValue();
    method public android.view.autofill.VirtualViewDelegate getAutoFillVirtualViewDelegate();
    method public android.graphics.drawable.Drawable getBackground();
    method public android.content.res.ColorStateList getBackgroundTintList();
    method public android.graphics.PorterDuff.Mode getBackgroundTintMode();
@@ -46740,11 +46741,11 @@ package android.view.autofill {
  }
  public final class AutoFillManager {
    method public void onValueChanged(android.view.View, android.view.autofill.AutoFillValue);
    method public void updateAutoFillInput(android.view.View, int);
    method public void updateAutoFillInput(android.view.View, int, android.graphics.Rect, int);
    field public static final int FLAG_UPDATE_UI_HIDE = 2; // 0x2
    field public static final int FLAG_UPDATE_UI_SHOW = 1; // 0x1
    method public void focusChanged(android.view.View, boolean);
    method public void reset();
    method public void valueChanged(android.view.View);
    method public void virtualFocusChanged(android.view.View, int, android.graphics.Rect, android.view.autofill.AutoFillValue, boolean);
    method public void virtualValueChanged(android.view.View, int, android.view.autofill.AutoFillValue);
  }
  public final class AutoFillType implements android.os.Parcelable {
@@ -46806,13 +46807,6 @@ package android.view.autofill {
    method public abstract void autoFill(int, android.view.autofill.AutoFillValue);
  }
  public static abstract class VirtualViewDelegate.Callback {
    ctor public VirtualViewDelegate.Callback();
    method public void onAutoFillInputUpdated(int, android.graphics.Rect, int);
    method public void onNodeRemoved(int...);
    method public void onValueChanged(int);
  }
}
package android.view.inputmethod {
+7 −13
Original line number Diff line number Diff line
@@ -47798,7 +47798,8 @@ package android.view {
    method public android.view.animation.Animation getAnimation();
    method public android.os.IBinder getApplicationWindowToken();
    method public android.view.autofill.AutoFillType getAutoFillType();
    method public android.view.autofill.VirtualViewDelegate getAutoFillVirtualViewDelegate(android.view.autofill.VirtualViewDelegate.Callback);
    method public android.view.autofill.AutoFillValue getAutoFillValue();
    method public android.view.autofill.VirtualViewDelegate getAutoFillVirtualViewDelegate();
    method public android.graphics.drawable.Drawable getBackground();
    method public android.content.res.ColorStateList getBackgroundTintList();
    method public android.graphics.PorterDuff.Mode getBackgroundTintMode();
@@ -50150,11 +50151,11 @@ package android.view.autofill {
  }
  public final class AutoFillManager {
    method public void onValueChanged(android.view.View, android.view.autofill.AutoFillValue);
    method public void updateAutoFillInput(android.view.View, int);
    method public void updateAutoFillInput(android.view.View, int, android.graphics.Rect, int);
    field public static final int FLAG_UPDATE_UI_HIDE = 2; // 0x2
    field public static final int FLAG_UPDATE_UI_SHOW = 1; // 0x1
    method public void focusChanged(android.view.View, boolean);
    method public void reset();
    method public void valueChanged(android.view.View);
    method public void virtualFocusChanged(android.view.View, int, android.graphics.Rect, android.view.autofill.AutoFillValue, boolean);
    method public void virtualValueChanged(android.view.View, int, android.view.autofill.AutoFillValue);
  }
  public final class AutoFillType implements android.os.Parcelable {
@@ -50216,13 +50217,6 @@ package android.view.autofill {
    method public abstract void autoFill(int, android.view.autofill.AutoFillValue);
  }
  public static abstract class VirtualViewDelegate.Callback {
    ctor public VirtualViewDelegate.Callback();
    method public void onAutoFillInputUpdated(int, android.graphics.Rect, int);
    method public void onNodeRemoved(int...);
    method public void onValueChanged(int);
  }
}
package android.view.inputmethod {
+7 −13
Original line number Diff line number Diff line
@@ -44697,7 +44697,8 @@ package android.view {
    method public android.view.animation.Animation getAnimation();
    method public android.os.IBinder getApplicationWindowToken();
    method public android.view.autofill.AutoFillType getAutoFillType();
    method public android.view.autofill.VirtualViewDelegate getAutoFillVirtualViewDelegate(android.view.autofill.VirtualViewDelegate.Callback);
    method public android.view.autofill.AutoFillValue getAutoFillValue();
    method public android.view.autofill.VirtualViewDelegate getAutoFillVirtualViewDelegate();
    method public android.graphics.drawable.Drawable getBackground();
    method public android.content.res.ColorStateList getBackgroundTintList();
    method public android.graphics.PorterDuff.Mode getBackgroundTintMode();
@@ -47053,11 +47054,11 @@ package android.view.autofill {
  }
  public final class AutoFillManager {
    method public void onValueChanged(android.view.View, android.view.autofill.AutoFillValue);
    method public void updateAutoFillInput(android.view.View, int);
    method public void updateAutoFillInput(android.view.View, int, android.graphics.Rect, int);
    field public static final int FLAG_UPDATE_UI_HIDE = 2; // 0x2
    field public static final int FLAG_UPDATE_UI_SHOW = 1; // 0x1
    method public void focusChanged(android.view.View, boolean);
    method public void reset();
    method public void valueChanged(android.view.View);
    method public void virtualFocusChanged(android.view.View, int, android.graphics.Rect, android.view.autofill.AutoFillValue, boolean);
    method public void virtualValueChanged(android.view.View, int, android.view.autofill.AutoFillValue);
  }
  public final class AutoFillType implements android.os.Parcelable {
@@ -47119,13 +47120,6 @@ package android.view.autofill {
    method public abstract void autoFill(int, android.view.autofill.AutoFillValue);
  }
  public static abstract class VirtualViewDelegate.Callback {
    ctor public VirtualViewDelegate.Callback();
    method public void onAutoFillInputUpdated(int, android.graphics.Rect, int);
    method public void onNodeRemoved(int...);
    method public void onValueChanged(int);
  }
}
package android.view.inputmethod {
+15 −11
Original line number Diff line number Diff line
@@ -49,7 +49,6 @@ import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ParceledListSlice;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -74,8 +73,6 @@ import android.os.ServiceManager.ServiceNotFoundException;
import android.os.StrictMode;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.service.autofill.AutoFillService;
import android.service.autofill.IAutoFillAppCallback;
import android.text.Selection;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
@@ -116,7 +113,6 @@ import android.view.Window.WindowControllerCallback;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.view.accessibility.AccessibilityEvent;
import android.view.autofill.AutoFillId;
import android.view.autofill.AutoFillManager;
import android.view.autofill.AutoFillSession;
import android.widget.AdapterView;
@@ -127,7 +123,6 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -1700,16 +1695,21 @@ public class Activity extends ContextThemeWrapper
    }

    /**
     * Lazily gets the {@link IAutoFillAppCallback} for this activitity.
     *
     * <p>This callback is used by the {@link AutoFillService} app to auto-fill the activity fields.
     * Lazily attachs the activity to the current {@link AutoFillSession} (if any).
     */
    IAutoFillAppCallback getAutoFillCallback() {
    void attachToAutoFillSession() {
        synchronized (this) {
            if (mAutoFillSession == null) {
                mAutoFillSession = new AutoFillSession(this);
                final AutoFillManager afm = getSystemService(AutoFillManager.class);
                if (afm != null) {
                    mAutoFillSession = afm.getSession();
                    if (mAutoFillSession != null) {
                        mAutoFillSession.attachActivity(this);
                    } else {
                        Log.w(TAG, "attachToAutoFillSession(): not in a session");
                    }
                }
            }
            return mAutoFillSession.getCallback();
        }
    }

@@ -1798,6 +1798,10 @@ public class Activity extends ContextThemeWrapper
        getApplication().dispatchActivityStopped(this);
        mTranslucentCallback = null;
        mCalled = true;
        if (mAutoFillSession != null && isFinishing()) {
            mAutoFillSession.finishSession();
            mAutoFillSession = null;
        }
    }

    /**
+0 −6
Original line number Diff line number Diff line
@@ -153,12 +153,6 @@ public abstract class ActivityManagerInternal {
     */
    public abstract List<IBinder> getTopVisibleActivities();

    /**
     * Returns the top, focused activity of the currently visible stack, but only if it belongs to
     * the given UID.
     */
    public abstract IBinder getTopVisibleActivity(int uid);

    /**
     * Callback for window manager to let activity manager know that docked stack changes its
     * minimized state.
Loading