Loading core/java/android/view/autofill/AutofillManager.java +12 −6 Original line number Diff line number Diff line Loading @@ -1342,11 +1342,17 @@ public final class AutofillManager { } } private void setSessionFinished() { if (sVerbose) Log.v(TAG, "setSessionFinished()"); /** * Marks the state of the session as finished. * * @param newState {@link #STATE_FINISHED} (because the autofill service returned a {@code null} * FillResponse) or {@link #STATE_UNKNOWN} (because the session was removed). */ private void setSessionFinished(int newState) { synchronized (mLock) { if (sVerbose) Log.v(TAG, "setSessionFinished(): from " + mState + " to " + newState); resetSessionLocked(); mState = STATE_FINISHED; mState = newState; } } Loading Loading @@ -1413,7 +1419,7 @@ public final class AutofillManager { if (sessionFinished) { // Callback call was "hijacked" to also update the session state. setSessionFinished(); setSessionFinished(STATE_FINISHED); } } Loading Loading @@ -1898,10 +1904,10 @@ public final class AutofillManager { } @Override public void setSessionFinished() { public void setSessionFinished(int newState) { final AutofillManager afm = mAfm.get(); if (afm != null) { afm.post(() -> afm.setSessionFinished()); afm.post(() -> afm.setSessionFinished(newState)); } } } Loading core/java/android/view/autofill/IAutoFillManagerClient.aidl +4 −3 Original line number Diff line number Diff line Loading @@ -82,8 +82,9 @@ oneway interface IAutoFillManagerClient { void setSaveUiState(int sessionId, boolean shown); /** * Marks the state of the session as finished (because the AutofillService returned a null * FillResponse). * Marks the state of the session as finished. * @param newState STATE_FINISHED (because the autofill service returned a null * FillResponse) or STATE_UNKNOWN (because the session was removed). */ void setSessionFinished(); void setSessionFinished(int newState); } services/autofill/java/com/android/server/autofill/AutofillManagerService.java +12 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,18 @@ public final class AutofillManagerService extends SystemService { @Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(intent.getAction())) { if (sDebug) Slog.d(TAG, "Close system dialogs"); // TODO(b/64940307): we need to destroy all sessions that are finished but showing // Save UI because there is no way to show the Save UI back when the activity // beneath it is brought back to top. Ideally, we should just hide the UI and // bring it back when the activity resumes. synchronized (mLock) { for (int i = 0; i < mServicesCache.size(); i++) { mServicesCache.valueAt(i).destroyFinishedSessionsLocked(); } } mUi.hideAll(null); } } Loading services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java +13 −1 Original line number Diff line number Diff line Loading @@ -452,7 +452,7 @@ final class AutofillManagerServiceImpl { final int sessionCount = mSessions.size(); for (int i = sessionCount - 1; i >= 0; i--) { final Session session = mSessions.valueAt(i); if (session.isSaveUiPendingForToken(token)) { if (session.isSaveUiPendingForTokenLocked(token)) { session.onPendingSaveUi(operation, token); return; } Loading Loading @@ -646,6 +646,18 @@ final class AutofillManagerServiceImpl { } } // TODO(b/64940307): remove this method if SaveUI is refactored to be attached on activities void destroyFinishedSessionsLocked() { final int sessionCount = mSessions.size(); for (int i = sessionCount - 1; i >= 0; i--) { final Session session = mSessions.valueAt(i); if (session.isSavingLocked()) { if (sDebug) Slog.d(TAG, "destroyFinishedSessionsLocked(): " + session.id); session.forceRemoveSelfLocked(); } } } void listSessionsLocked(ArrayList<String> output) { final int numSessions = mSessions.size(); for (int i = 0; i < numSessions; i++) { Loading services/autofill/java/com/android/server/autofill/Session.java +11 −12 Original line number Diff line number Diff line Loading @@ -1376,7 +1376,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (mHasCallback) { mClient.notifyNoFillUi(id, mCurrentViewId, sessionFinished); } else if (sessionFinished) { mClient.setSessionFinished(); mClient.setSessionFinished(AutofillManager.STATE_FINISHED); } } catch (RemoteException e) { Slog.e(TAG, "Error notifying client no fill UI: id=" + mCurrentViewId, e); Loading Loading @@ -1795,18 +1795,17 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState void forceRemoveSelfLocked() { if (sVerbose) Slog.v(TAG, "forceRemoveSelfLocked(): " + mPendingSaveUi); final boolean isPendingSaveUi = isSaveUiPendingLocked(); mPendingSaveUi = null; removeSelfLocked(); mHandlerCaller.getHandler().post(() -> { mUi.destroyAll(mPendingSaveUi, this, false); if (!isPendingSaveUi) { try { mClient.setState(mService.isEnabled(), true, false); mClient.setSessionFinished(AutofillManager.STATE_UNKNOWN); } catch (RemoteException e) { Slog.w(TAG, "error updating client state: " + e); Slog.e(TAG, "Error notifying client to finish session", e); } } }); mUi.destroyAll(mPendingSaveUi, this, false); } /** Loading @@ -1829,7 +1828,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState + id + " destroyed"); return; } if (isSaveUiPending()) { if (isSaveUiPendingLocked()) { Slog.i(TAG, "removeSelfLocked() ignored, waiting for pending save ui"); return; } Loading @@ -1850,14 +1849,14 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState * a specific {@code token} created by * {@link PendingUi#PendingUi(IBinder, int, IAutoFillManagerClient)}. */ boolean isSaveUiPendingForToken(@NonNull IBinder token) { return isSaveUiPending() && token.equals(mPendingSaveUi.getToken()); boolean isSaveUiPendingForTokenLocked(@NonNull IBinder token) { return isSaveUiPendingLocked() && token.equals(mPendingSaveUi.getToken()); } /** * Checks whether this session is hiding the Save UI to handle a custom description link. */ private boolean isSaveUiPending() { private boolean isSaveUiPendingLocked() { return mPendingSaveUi != null && mPendingSaveUi.getState() == PendingUi.STATE_PENDING; } Loading services/autofill/java/com/android/server/autofill/ui/SaveUi.java +1 −1 File changed.Contains only whitespace changes. Show changes Loading
core/java/android/view/autofill/AutofillManager.java +12 −6 Original line number Diff line number Diff line Loading @@ -1342,11 +1342,17 @@ public final class AutofillManager { } } private void setSessionFinished() { if (sVerbose) Log.v(TAG, "setSessionFinished()"); /** * Marks the state of the session as finished. * * @param newState {@link #STATE_FINISHED} (because the autofill service returned a {@code null} * FillResponse) or {@link #STATE_UNKNOWN} (because the session was removed). */ private void setSessionFinished(int newState) { synchronized (mLock) { if (sVerbose) Log.v(TAG, "setSessionFinished(): from " + mState + " to " + newState); resetSessionLocked(); mState = STATE_FINISHED; mState = newState; } } Loading Loading @@ -1413,7 +1419,7 @@ public final class AutofillManager { if (sessionFinished) { // Callback call was "hijacked" to also update the session state. setSessionFinished(); setSessionFinished(STATE_FINISHED); } } Loading Loading @@ -1898,10 +1904,10 @@ public final class AutofillManager { } @Override public void setSessionFinished() { public void setSessionFinished(int newState) { final AutofillManager afm = mAfm.get(); if (afm != null) { afm.post(() -> afm.setSessionFinished()); afm.post(() -> afm.setSessionFinished(newState)); } } } Loading
core/java/android/view/autofill/IAutoFillManagerClient.aidl +4 −3 Original line number Diff line number Diff line Loading @@ -82,8 +82,9 @@ oneway interface IAutoFillManagerClient { void setSaveUiState(int sessionId, boolean shown); /** * Marks the state of the session as finished (because the AutofillService returned a null * FillResponse). * Marks the state of the session as finished. * @param newState STATE_FINISHED (because the autofill service returned a null * FillResponse) or STATE_UNKNOWN (because the session was removed). */ void setSessionFinished(); void setSessionFinished(int newState); }
services/autofill/java/com/android/server/autofill/AutofillManagerService.java +12 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,18 @@ public final class AutofillManagerService extends SystemService { @Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(intent.getAction())) { if (sDebug) Slog.d(TAG, "Close system dialogs"); // TODO(b/64940307): we need to destroy all sessions that are finished but showing // Save UI because there is no way to show the Save UI back when the activity // beneath it is brought back to top. Ideally, we should just hide the UI and // bring it back when the activity resumes. synchronized (mLock) { for (int i = 0; i < mServicesCache.size(); i++) { mServicesCache.valueAt(i).destroyFinishedSessionsLocked(); } } mUi.hideAll(null); } } Loading
services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java +13 −1 Original line number Diff line number Diff line Loading @@ -452,7 +452,7 @@ final class AutofillManagerServiceImpl { final int sessionCount = mSessions.size(); for (int i = sessionCount - 1; i >= 0; i--) { final Session session = mSessions.valueAt(i); if (session.isSaveUiPendingForToken(token)) { if (session.isSaveUiPendingForTokenLocked(token)) { session.onPendingSaveUi(operation, token); return; } Loading Loading @@ -646,6 +646,18 @@ final class AutofillManagerServiceImpl { } } // TODO(b/64940307): remove this method if SaveUI is refactored to be attached on activities void destroyFinishedSessionsLocked() { final int sessionCount = mSessions.size(); for (int i = sessionCount - 1; i >= 0; i--) { final Session session = mSessions.valueAt(i); if (session.isSavingLocked()) { if (sDebug) Slog.d(TAG, "destroyFinishedSessionsLocked(): " + session.id); session.forceRemoveSelfLocked(); } } } void listSessionsLocked(ArrayList<String> output) { final int numSessions = mSessions.size(); for (int i = 0; i < numSessions; i++) { Loading
services/autofill/java/com/android/server/autofill/Session.java +11 −12 Original line number Diff line number Diff line Loading @@ -1376,7 +1376,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (mHasCallback) { mClient.notifyNoFillUi(id, mCurrentViewId, sessionFinished); } else if (sessionFinished) { mClient.setSessionFinished(); mClient.setSessionFinished(AutofillManager.STATE_FINISHED); } } catch (RemoteException e) { Slog.e(TAG, "Error notifying client no fill UI: id=" + mCurrentViewId, e); Loading Loading @@ -1795,18 +1795,17 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState void forceRemoveSelfLocked() { if (sVerbose) Slog.v(TAG, "forceRemoveSelfLocked(): " + mPendingSaveUi); final boolean isPendingSaveUi = isSaveUiPendingLocked(); mPendingSaveUi = null; removeSelfLocked(); mHandlerCaller.getHandler().post(() -> { mUi.destroyAll(mPendingSaveUi, this, false); if (!isPendingSaveUi) { try { mClient.setState(mService.isEnabled(), true, false); mClient.setSessionFinished(AutofillManager.STATE_UNKNOWN); } catch (RemoteException e) { Slog.w(TAG, "error updating client state: " + e); Slog.e(TAG, "Error notifying client to finish session", e); } } }); mUi.destroyAll(mPendingSaveUi, this, false); } /** Loading @@ -1829,7 +1828,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState + id + " destroyed"); return; } if (isSaveUiPending()) { if (isSaveUiPendingLocked()) { Slog.i(TAG, "removeSelfLocked() ignored, waiting for pending save ui"); return; } Loading @@ -1850,14 +1849,14 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState * a specific {@code token} created by * {@link PendingUi#PendingUi(IBinder, int, IAutoFillManagerClient)}. */ boolean isSaveUiPendingForToken(@NonNull IBinder token) { return isSaveUiPending() && token.equals(mPendingSaveUi.getToken()); boolean isSaveUiPendingForTokenLocked(@NonNull IBinder token) { return isSaveUiPendingLocked() && token.equals(mPendingSaveUi.getToken()); } /** * Checks whether this session is hiding the Save UI to handle a custom description link. */ private boolean isSaveUiPending() { private boolean isSaveUiPendingLocked() { return mPendingSaveUi != null && mPendingSaveUi.getState() == PendingUi.STATE_PENDING; } Loading
services/autofill/java/com/android/server/autofill/ui/SaveUi.java +1 −1 File changed.Contains only whitespace changes. Show changes