summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2017-09-21 16:54:44 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-09-21 16:54:44 +0000
commit56e5c3944b4ee6abc97745c04f419ea9b591326a (patch)
treed561b2f18c53b9c2b3fdd569a6ea639f86fb877c
parent66f2d565561cb3ac8cb9c7d5b50560856b35476a (diff)
parent650f7abc3fb3a7be419124f601a9941f5f7a7d2b (diff)
Merge "Remove finished sessions on ACTION_CLOSE_SYSTEM_DIALOGS." into oc-mr1-dev
-rw-r--r--core/java/android/view/autofill/AutofillManager.java18
-rw-r--r--core/java/android/view/autofill/IAutoFillManagerClient.aidl7
-rw-r--r--services/autofill/java/com/android/server/autofill/AutofillManagerService.java12
-rw-r--r--services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java14
-rw-r--r--services/autofill/java/com/android/server/autofill/Session.java23
-rw-r--r--services/autofill/java/com/android/server/autofill/ui/SaveUi.java2
6 files changed, 53 insertions, 23 deletions
diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java
index f888ba298339..e906a1fa7807 100644
--- a/core/java/android/view/autofill/AutofillManager.java
+++ b/core/java/android/view/autofill/AutofillManager.java
@@ -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));
}
}
}
diff --git a/core/java/android/view/autofill/IAutoFillManagerClient.aidl b/core/java/android/view/autofill/IAutoFillManagerClient.aidl
index db6855a4dbf4..3dabcec8636a 100644
--- a/core/java/android/view/autofill/IAutoFillManagerClient.aidl
+++ b/core/java/android/view/autofill/IAutoFillManagerClient.aidl
@@ -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);
}
diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java
index a1c75bfc16c0..b9bea163a8a5 100644
--- a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java
+++ b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java
@@ -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);
}
}
diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
index e28e1c9e6a90..4705f1e8dc1b 100644
--- a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
+++ b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
@@ -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++) {
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java
index ff6e94b2490d..2d10affd0e86 100644
--- a/services/autofill/java/com/android/server/autofill/Session.java
+++ b/services/autofill/java/com/android/server/autofill/Session.java
@@ -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(() -> {
+ 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);
+ }
}
/**
@@ -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;
}
diff --git a/services/autofill/java/com/android/server/autofill/ui/SaveUi.java b/services/autofill/java/com/android/server/autofill/ui/SaveUi.java
index 32f4d69fc3e3..218d185ce2b0 100644
--- a/services/autofill/java/com/android/server/autofill/ui/SaveUi.java
+++ b/services/autofill/java/com/android/server/autofill/ui/SaveUi.java
@@ -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 + ").");
}