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

Commit 05ea98a3 authored by Felipe Leme's avatar Felipe Leme
Browse files

Dismiss Autofill Save UI when a new Activity is launched.

Test: manual verification using Settings
Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases -tandroid.autofillservice.cts.SimpleSaveActivityTest#testDismissSave_byLaunchingNewActivity
Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases -tandroid.autofillservice.cts.LoginActivityTest#testSaveGoesAwayWhenLaunchingNewActivity
Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases

Fixes: 64693551

Change-Id: I323031c7285a4b49f9f0ca06618425a0ab7833da
parent 9ad54229
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1006,6 +1006,11 @@ public class Activity extends ContextThemeWrapper
            Parcelable p = savedInstanceState.getParcelable(FRAGMENTS_TAG);
            mFragments.restoreAllState(p, mLastNonConfigurationInstances != null
                    ? mLastNonConfigurationInstances.fragments : null);
        } else {
            AutofillManager afm = getAutofillManager();
            if (afm != null) {
                afm.dismissUi();
            }
        }
        mFragments.dispatchCreate();
        getApplication().dispatchActivityCreated(this, savedInstanceState);
+19 −0
Original line number Diff line number Diff line
@@ -1338,6 +1338,25 @@ public final class AutofillManager {
        client.runOnUiThread(runnable);
    }

    /**
     * Dismiss the Autofill UI, even if associated with other sessions.
     *
     * <p>Typically called when a new activity starts so it can hide the existing Save UI (if any).
     *
     * @hide
     */
    public void dismissUi() {
        if (sVerbose) Log.v(TAG, "dismissUi()");

        if (mService == null) return;

        try {
            mService.dismissUi();
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }

    /**
     * View tracking information. Once all tracked views become invisible the session is finished.
     */
+1 −0
Original line number Diff line number Diff line
@@ -49,4 +49,5 @@ interface IAutoFillManager {
    void disableOwnedAutofillServices(int userId);
    boolean isServiceSupported(int userId);
    boolean isServiceEnabled(int userId, String packageName);
    void dismissUi();
}
+13 −0
Original line number Diff line number Diff line
@@ -654,6 +654,19 @@ public final class AutofillManagerService extends SystemService {
            }
        }

        @Override
        public void dismissUi() {
            final UserHandle user = getCallingUserHandle();

            synchronized (mLock) {
                final AutofillManagerServiceImpl service = peekServiceForUserLocked(
                        user.getIdentifier());
                if (service != null) {
                    service.dismissUi();
                }
            }
        }

        @Override
        public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
            if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
+6 −1
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.service.autofill.AutofillService;
@@ -635,6 +634,12 @@ final class AutofillManagerServiceImpl {
        }
    }

    void dismissUi() {
        if (sVerbose) Slog.v(TAG, "dismissUi()");

        mUi.hideAll(null);
    }

    private void sendStateToClients(boolean resetClient) {
        final RemoteCallbackList<IAutoFillManagerClient> clients;
        final int userClientCount;