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

Commit f966d48f authored by Felipe Leme's avatar Felipe Leme Committed by android-build-merger
Browse files

Merge "Refactored Autofill to move starting flag out of Session." into oc-dev

am: b63d261f

Change-Id: Icf8f2b15b932acfe45fe48ec1b79307280957a12
parents 8d6236be b63d261f
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ public class AssistStructure implements Parcelable {

    ComponentName mActivityComponent;
    private boolean mIsHomeActivity;
    private int mFlags;

    final ArrayList<WindowNode> mWindowNodes = new ArrayList<>();

@@ -186,6 +187,7 @@ public class AssistStructure implements Parcelable {
            mSanitizeOnWrite = as.mSanitizeOnWrite;
            mWriteStructure = as.waitForReady();
            ComponentName.writeToParcel(as.mActivityComponent, out);
            out.writeInt(as.mFlags);
            out.writeLong(as.mAcquisitionStartTime);
            out.writeLong(as.mAcquisitionEndTime);
            mNumWindows = as.mWindowNodes.size();
@@ -340,6 +342,7 @@ public class AssistStructure implements Parcelable {
        void go() {
            fetchData();
            mActivityComponent = ComponentName.readFromParcel(mCurParcel);
            mFlags = mCurParcel.readInt();
            mAcquisitionStartTime = mCurParcel.readLong();
            mAcquisitionEndTime = mCurParcel.readLong();
            final int N = mCurParcel.readInt();
@@ -1876,6 +1879,7 @@ public class AssistStructure implements Parcelable {
    public AssistStructure(Activity activity, boolean forAutoFill, int flags) {
        mHaveData = true;
        mActivityComponent = activity.getComponentName();
        mFlags = flags;
        ArrayList<ViewRootImpl> views = WindowManagerGlobal.getInstance().getRootViews(
                activity.getActivityToken());
        for (int i=0; i<views.size(); i++) {
@@ -1887,6 +1891,7 @@ public class AssistStructure implements Parcelable {
    public AssistStructure() {
        mHaveData = true;
        mActivityComponent = null;
        mFlags = 0;
    }

    /** @hide */
@@ -1913,6 +1918,7 @@ public class AssistStructure implements Parcelable {
        }
        Log.i(TAG, "Activity: " + mActivityComponent.flattenToShortString());
        Log.i(TAG, "Sanitize on write: " + mSanitizeOnWrite);
        Log.i(TAG, "Flags: " + mFlags);
        final int N = getWindowNodeCount();
        for (int i=0; i<N; i++) {
            WindowNode node = getWindowNodeAt(i);
@@ -2025,6 +2031,11 @@ public class AssistStructure implements Parcelable {
        return mActivityComponent;
    }

    /** @hide */
    public int getFlags() {
        return mFlags;
    }

    /**
     * Returns whether the activity associated with this AssistStructure was the home activity
     * (Launcher) at the time the assist data was acquired.
+3 −5
Original line number Diff line number Diff line
@@ -74,11 +74,9 @@ public final class FillContext implements Parcelable {

    @Override
    public String toString() {
        if (!DEBUG) {
            return super.toString();
        } else {
            return "FillContext [mRequestId=" + mRequestId + "]";
        }
        if (!DEBUG)  return super.toString();

        return "FillContext [reqId=" + mRequestId + "]";
    }

    @Override
+17 −16
Original line number Diff line number Diff line
@@ -107,11 +107,10 @@ public final class AutofillManager {
    @Deprecated
    public static final int FLAG_MANUAL_REQUEST = 0x1;

    // TODO(b/37563972): start from 0x1 once FLAG_MANUAL_REQUEST is gone
    /** @hide */ public static final int FLAG_START_SESSION = 0x80000000;
    /** @hide */ public static final int FLAG_VIEW_ENTERED =  0x40000000;
    /** @hide */ public static final int FLAG_VIEW_EXITED =   0x20000000;
    /** @hide */ public static final int FLAG_VALUE_CHANGED = 0x10000000;
    /** @hide */ public static final int ACTION_START_SESSION = 1;
    /** @hide */ public static final int ACTION_VIEW_ENTERED =  2;
    /** @hide */ public static final int ACTION_VIEW_EXITED = 3;
    /** @hide */ public static final int ACTION_VALUE_CHANGED = 4;

    private final MetricsLogger mMetricsLogger = new MetricsLogger();

@@ -404,7 +403,7 @@ public final class AutofillManager {
                    startSessionLocked(id, view.getWindowToken(), null, value, flags);
                } else {
                    // Update focus on existing session.
                    updateSessionLocked(id, null, value, FLAG_VIEW_ENTERED);
                    updateSessionLocked(id, null, value, ACTION_VIEW_ENTERED, flags);
                }
            }
        }
@@ -430,7 +429,7 @@ public final class AutofillManager {
                final AutofillId id = getAutofillId(view);

                // Update focus on existing session.
                updateSessionLocked(id, null, null, FLAG_VIEW_EXITED);
                updateSessionLocked(id, null, null, ACTION_VIEW_EXITED, 0);
            }
        }
    }
@@ -482,7 +481,7 @@ public final class AutofillManager {
                    startSessionLocked(id, view.getWindowToken(), bounds, null, flags);
                } else {
                    // Update focus on existing session.
                    updateSessionLocked(id, bounds, null, FLAG_VIEW_ENTERED);
                    updateSessionLocked(id, bounds, null, ACTION_VIEW_ENTERED, flags);
                }
            }
        }
@@ -510,7 +509,7 @@ public final class AutofillManager {
                final AutofillId id = getAutofillId(view, childId);

                // Update focus on existing session.
                updateSessionLocked(id, null, null, FLAG_VIEW_EXITED);
                updateSessionLocked(id, null, null, ACTION_VIEW_EXITED, 0);
            }
        }
    }
@@ -562,7 +561,7 @@ public final class AutofillManager {
                value = view.getAutofillValue();
            }

            updateSessionLocked(id, null, value, FLAG_VALUE_CHANGED);
            updateSessionLocked(id, null, value, ACTION_VALUE_CHANGED, 0);
        }
    }

@@ -583,7 +582,7 @@ public final class AutofillManager {
            }

            final AutofillId id = getAutofillId(view, childId);
            updateSessionLocked(id, null, value, FLAG_VALUE_CHANGED);
            updateSessionLocked(id, null, value, ACTION_VALUE_CHANGED, 0);
        }
    }

@@ -726,7 +725,7 @@ public final class AutofillManager {
            mSessionId = mService.startSession(mContext.getActivityToken(), windowToken,
                    mServiceClient.asBinder(), id, bounds, value, mContext.getUserId(),
                    mCallback != null, flags, mContext.getOpPackageName());
            AutofillClient client = getClientLocked();
            final AutofillClient client = getClientLocked();
            if (client != null) {
                client.autofillCallbackResetableStateAvailable();
            }
@@ -769,16 +768,18 @@ public final class AutofillManager {
        mTrackedViews = null;
    }

    private void updateSessionLocked(AutofillId id, Rect bounds, AutofillValue value, int flags) {
    private void updateSessionLocked(AutofillId id, Rect bounds, AutofillValue value, int action,
            int flags) {
        if (DEBUG) {
            if (VERBOSE || (flags & FLAG_VIEW_EXITED) != 0) {
            if (VERBOSE || action != ACTION_VIEW_EXITED) {
                Log.d(TAG, "updateSessionLocked(): id=" + id + ", bounds=" + bounds
                        + ", value=" + value + ", flags=" + flags);
                        + ", value=" + value + ", action=" + action + ", flags=" + flags);
            }
        }

        try {
            mService.updateSession(mSessionId, id, bounds, value, flags, mContext.getUserId());
            mService.updateSession(mSessionId, id, bounds, value, action, flags,
                    mContext.getUserId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ interface IAutoFillManager {
    boolean restoreSession(int sessionId, in IBinder activityToken, in IBinder appCallback);
    void setWindow(int sessionId, in IBinder windowToken);
    void updateSession(int sessionId, in AutofillId id, in Rect bounds,
            in AutofillValue value, int flags, int userId);
            in AutofillValue value, int action, int flags, int userId);
    void finishSession(int sessionId, int userId);
    void cancelSession(int sessionId, int userId);
    void setAuthenticationResult(in Bundle data, int sessionId, int userId);
+2 −2
Original line number Diff line number Diff line
@@ -509,12 +509,12 @@ public final class AutofillManagerService extends SystemService {

        @Override
        public void updateSession(int sessionId, AutofillId id, Rect bounds,
                AutofillValue value, int flags, int userId) {
                AutofillValue value, int action, int flags, int userId) {
            synchronized (mLock) {
                final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
                if (service != null) {
                    service.updateSessionLocked(sessionId, getCallingUid(), id, bounds, value,
                            flags);
                            action, flags);
                }
            }
        }
Loading