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

Commit 3440e920 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Allow to finish session when all views are gone" into oc-dev

parents 1c4c981c 494c3f5d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -37160,6 +37160,7 @@ package android.service.autofill {
    method public android.service.autofill.SaveInfo.Builder setDescription(java.lang.CharSequence);
    method public android.service.autofill.SaveInfo.Builder setNegativeAction(java.lang.CharSequence, android.content.IntentSender);
    method public android.service.autofill.SaveInfo.Builder setOptionalIds(android.view.autofill.AutofillId[]);
    method public android.service.autofill.SaveInfo.Builder setSaveOnAllViewsInvisible(boolean);
  }
  public final class SaveRequest implements android.os.Parcelable {
+1 −0
Original line number Diff line number Diff line
@@ -40270,6 +40270,7 @@ package android.service.autofill {
    method public android.service.autofill.SaveInfo.Builder setDescription(java.lang.CharSequence);
    method public android.service.autofill.SaveInfo.Builder setNegativeAction(java.lang.CharSequence, android.content.IntentSender);
    method public android.service.autofill.SaveInfo.Builder setOptionalIds(android.view.autofill.AutofillId[]);
    method public android.service.autofill.SaveInfo.Builder setSaveOnAllViewsInvisible(boolean);
  }
  public final class SaveRequest implements android.os.Parcelable {
+1 −0
Original line number Diff line number Diff line
@@ -37313,6 +37313,7 @@ package android.service.autofill {
    method public android.service.autofill.SaveInfo.Builder setDescription(java.lang.CharSequence);
    method public android.service.autofill.SaveInfo.Builder setNegativeAction(java.lang.CharSequence, android.content.IntentSender);
    method public android.service.autofill.SaveInfo.Builder setOptionalIds(android.view.autofill.AutofillId[]);
    method public android.service.autofill.SaveInfo.Builder setSaveOnAllViewsInvisible(boolean);
  }
  public final class SaveRequest implements android.os.Parcelable {
+55 −5
Original line number Diff line number Diff line
@@ -16,21 +16,16 @@

package android.app;

import android.metrics.LogMaker;
import android.graphics.Rect;
import android.os.SystemClock;
import android.view.ViewRootImpl.ActivityConfigCallback;
import android.view.autofill.AutofillId;
import android.view.autofill.AutofillManager;
import android.view.autofill.AutofillPopupWindow;
import android.view.autofill.AutofillValue;
import android.view.autofill.IAutofillWindowPresenter;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.app.IVoiceInteractor;
import com.android.internal.app.ToolbarActionBar;
import com.android.internal.app.WindowDecorActionBar;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto;
import com.android.internal.policy.PhoneWindow;

import android.annotation.CallSuper;
@@ -1234,6 +1229,13 @@ public class Activity extends ContextThemeWrapper
        mFragments.doLoaderStart();

        getApplication().dispatchActivityStarted(this);

        if (mAutoFillResetNeeded) {
            AutofillManager afm = getAutofillManager();
            if (afm != null) {
                afm.onVisibleForAutofill();
            }
        }
    }

    /**
@@ -7407,6 +7409,54 @@ public class Activity extends ContextThemeWrapper
        return true;
    }

    /** @hide */
    @Override
    public boolean getViewVisibility(int viewId) {
        Window window = getWindow();
        if (window == null) {
            Log.i(TAG, "no window");
            return false;
        }

        View decorView = window.peekDecorView();
        if (decorView == null) {
            Log.i(TAG, "no decorView");
            return false;
        }

        View view = decorView.findViewByAccessibilityIdTraversal(viewId);
        if (view == null) {
            Log.i(TAG, "cannot find view");
            return false;
        }

        // Check if the view is visible by checking all parents
        while (view != null) {
            if (view == decorView) {
                break;
            }

            if (view.getVisibility() != View.VISIBLE) {
                Log.i(TAG, view + " is not visible");
                return false;
            }

            if (view.getParent() instanceof View) {
                view = (View) view.getParent();
            } else {
                break;
            }
        }

        return true;
    }

    /** @hide */
    @Override
    public boolean isVisibleForAutofill() {
        return !mStopped;
    }

    /**
     * If set to true, this indicates to the system that it should never take a
     * screenshot of the activity to be used as a representation while it is not in a started state.
+27 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.view.autofill.Helper.DEBUG;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.assist.AssistStructure;
import android.content.IntentSender;
import android.os.Bundle;
import android.os.Parcel;
@@ -158,6 +159,7 @@ public final class SaveInfo implements Parcelable {
    private final AutofillId[] mRequiredIds;
    private final AutofillId[] mOptionalIds;
    private final CharSequence mDescription;
    private final boolean mSaveOnAllViewsInvisible;

    private SaveInfo(Builder builder) {
        mType = builder.mType;
@@ -166,6 +168,7 @@ public final class SaveInfo implements Parcelable {
        mRequiredIds = builder.mRequiredIds;
        mOptionalIds = builder.mOptionalIds;
        mDescription = builder.mDescription;
        mSaveOnAllViewsInvisible = builder.mSaveOnAllViewsInvisible;
    }

    /** @hide */
@@ -193,6 +196,11 @@ public final class SaveInfo implements Parcelable {
        return mType;
    }

    /** @hide */
    public boolean saveOnAllViewsInvisible() {
        return mSaveOnAllViewsInvisible;
    }

    /** @hide */
    public CharSequence getDescription() {
        return mDescription;
@@ -211,6 +219,7 @@ public final class SaveInfo implements Parcelable {
        private AutofillId[] mOptionalIds;
        private CharSequence mDescription;
        private boolean mDestroyed;
        private boolean mSaveOnAllViewsInvisible;

        /**
         * Creates a new builder.
@@ -258,6 +267,21 @@ public final class SaveInfo implements Parcelable {
            return this;
        }

        /**
         * Usually {@link AutofillService#onSaveRequest(AssistStructure, Bundle, SaveCallback)}
         * is called once the activity finishes. If this property is set it is called once all
         * autofillable or saved views become invisible.
         *
         * @param saveOnAllViewsInvisible Set to {@code true} if the data should be saved once
         *                                all the views become invisible.
         * @return This builder.
         */
        public @NonNull Builder setSaveOnAllViewsInvisible(boolean saveOnAllViewsInvisible) {
            throwIfDestroyed();
            mSaveOnAllViewsInvisible = saveOnAllViewsInvisible;
            return this;
        }

        /**
         * Sets the ids of additional, optional views the service would be interested to save.
         *
@@ -354,6 +378,7 @@ public final class SaveInfo implements Parcelable {
                .append(", requiredIds=").append(Arrays.toString(mRequiredIds))
                .append(", optionalIds=").append(Arrays.toString(mOptionalIds))
                .append(", description=").append(mDescription)
                .append(", saveOnNoVisibleTrackedViews=").append(mSaveOnAllViewsInvisible)
                .append("]").toString();
    }

@@ -374,6 +399,7 @@ public final class SaveInfo implements Parcelable {
        parcel.writeParcelable(mNegativeActionListener, flags);
        parcel.writeParcelableArray(mOptionalIds, flags);
        parcel.writeCharSequence(mDescription);
        parcel.writeBoolean(mSaveOnAllViewsInvisible);
    }

    public static final Parcelable.Creator<SaveInfo> CREATOR = new Parcelable.Creator<SaveInfo>() {
@@ -387,6 +413,7 @@ public final class SaveInfo implements Parcelable {
            builder.setNegativeAction(parcel.readCharSequence(), parcel.readParcelable(null));
            builder.setOptionalIds(parcel.readParcelableArray(null, AutofillId.class));
            builder.setDescription(parcel.readCharSequence());
            builder.setSaveOnAllViewsInvisible(parcel.readBoolean());
            return builder.build();
        }

Loading