Merge "Remove finished sessions on ACTION_CLOSE_SYSTEM_DIALOGS." into oc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
56e5c3944b
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1413,7 +1419,7 @@ public final class AutofillManager {
|
||||
|
||||
if (sessionFinished) {
|
||||
// Callback call was "hijacked" to also update the session state.
|
||||
setSessionFinished();
|
||||
setSessionFinished(STATE_FINISHED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -641,6 +641,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++) {
|
||||
|
||||
@@ -1368,7 +1368,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);
|
||||
@@ -1780,18 +1780,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(() -> {
|
||||
try {
|
||||
mClient.setState(mService.isEnabled(), true, false);
|
||||
} catch (RemoteException e) {
|
||||
Slog.w(TAG, "error updating client state: " + e);
|
||||
}
|
||||
});
|
||||
|
||||
mUi.destroyAll(mPendingSaveUi, this, false);
|
||||
if (!isPendingSaveUi) {
|
||||
try {
|
||||
mClient.setSessionFinished(AutofillManager.STATE_UNKNOWN);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Error notifying client to finish session", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1814,7 +1813,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;
|
||||
}
|
||||
@@ -1835,14 +1834,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -305,7 +305,7 @@ final class SaveUi {
|
||||
|
||||
if (actualWidth <= maxWidth && actualHeight <= maxHeight) {
|
||||
if (sDebug) {
|
||||
Slog.d(TAG, "Addingservice icon "
|
||||
Slog.d(TAG, "Adding service icon "
|
||||
+ "(" + actualWidth + "x" + actualHeight + ") as it's less than maximum "
|
||||
+ "(" + maxWidth + "x" + maxHeight + ").");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user