Start a new session on manual request after session is "gone".
am: 7f33cd350b
Change-Id: I1f93cea2d1699e8d388da4136c379aec4462e270
This commit is contained in:
@@ -862,10 +862,10 @@ public class AssistStructure implements Parcelable {
|
||||
out.writeInt(mAutofillType);
|
||||
out.writeStringArray(mAutofillHints);
|
||||
final AutofillValue sanitizedValue;
|
||||
if (mAutofillOverlay != null && mAutofillOverlay.value != null) {
|
||||
sanitizedValue = mAutofillOverlay.value;
|
||||
} else if (writeSensitive) {
|
||||
if (writeSensitive) {
|
||||
sanitizedValue = mAutofillValue;
|
||||
} else if (mAutofillOverlay != null && mAutofillOverlay.value != null) {
|
||||
sanitizedValue = mAutofillOverlay.value;
|
||||
} else {
|
||||
sanitizedValue = null;
|
||||
}
|
||||
|
||||
@@ -804,9 +804,26 @@ public final class AutofillManager {
|
||||
+ ", value=" + value + ", action=" + action + ", flags=" + flags);
|
||||
}
|
||||
|
||||
boolean restartIfNecessary = (flags & FLAG_MANUAL_REQUEST) != 0;
|
||||
|
||||
try {
|
||||
mService.updateSession(mSessionId, id, bounds, value, action, flags,
|
||||
mContext.getUserId());
|
||||
if (restartIfNecessary) {
|
||||
final int newId = mService.updateOrRestartSession(mContext.getActivityToken(),
|
||||
mServiceClient.asBinder(), id, bounds, value, mContext.getUserId(),
|
||||
mCallback != null, flags, mContext.getOpPackageName(), mSessionId, action);
|
||||
if (newId != mSessionId) {
|
||||
if (sDebug) Log.d(TAG, "Session restarted: " + mSessionId + "=>" + newId);
|
||||
mSessionId = newId;
|
||||
final AutofillClient client = getClientLocked();
|
||||
if (client != null) {
|
||||
client.autofillCallbackResetableStateAvailable();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mService.updateSession(mSessionId, id, bounds, value, action, flags,
|
||||
mContext.getUserId());
|
||||
}
|
||||
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
@@ -39,6 +39,9 @@ interface IAutoFillManager {
|
||||
boolean restoreSession(int sessionId, in IBinder activityToken, in IBinder appCallback);
|
||||
void updateSession(int sessionId, in AutofillId id, in Rect bounds,
|
||||
in AutofillValue value, int action, int flags, int userId);
|
||||
int updateOrRestartSession(IBinder activityToken, in IBinder appCallback,
|
||||
in AutofillId autoFillId, in Rect bounds, in AutofillValue value, int userId,
|
||||
boolean hasCallback, int flags, String packageName, int sessionId, int action);
|
||||
void finishSession(int sessionId, int userId);
|
||||
void cancelSession(int sessionId, int userId);
|
||||
void setAuthenticationResult(in Bundle data, int sessionId, int authenticationId, int userId);
|
||||
|
||||
@@ -172,7 +172,6 @@ public final class AutofillManagerService extends SystemService {
|
||||
startTrackingPackageChanges();
|
||||
}
|
||||
|
||||
|
||||
private void startTrackingPackageChanges() {
|
||||
PackageMonitor monitor = new PackageMonitor() {
|
||||
@Override
|
||||
@@ -559,17 +558,38 @@ public final class AutofillManagerService extends SystemService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSession(int sessionId, AutofillId id, Rect bounds,
|
||||
public void updateSession(int sessionId, AutofillId autoFillId, Rect bounds,
|
||||
AutofillValue value, int action, int flags, int userId) {
|
||||
synchronized (mLock) {
|
||||
final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
|
||||
if (service != null) {
|
||||
service.updateSessionLocked(sessionId, getCallingUid(), id, bounds, value,
|
||||
action, flags);
|
||||
service.updateSessionLocked(sessionId, getCallingUid(), autoFillId, bounds,
|
||||
value, action, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateOrRestartSession(IBinder activityToken, IBinder appCallback,
|
||||
AutofillId autoFillId, Rect bounds, AutofillValue value, int userId,
|
||||
boolean hasCallback, int flags, String packageName, int sessionId, int action) {
|
||||
boolean restart = false;
|
||||
synchronized (mLock) {
|
||||
final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
|
||||
if (service != null) {
|
||||
restart = service.updateSessionLocked(sessionId, getCallingUid(), autoFillId,
|
||||
bounds, value, action, flags);
|
||||
}
|
||||
}
|
||||
if (restart) {
|
||||
return startSession(activityToken, appCallback, autoFillId, bounds, value, userId,
|
||||
hasCallback, flags, packageName);
|
||||
}
|
||||
|
||||
// Nothing changed...
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishSession(int sessionId, int userId) {
|
||||
synchronized (mLock) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.server.autofill;
|
||||
|
||||
import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST;
|
||||
import static android.view.autofill.AutofillManager.ACTION_START_SESSION;
|
||||
import static android.view.autofill.AutofillManager.NO_SESSION;
|
||||
|
||||
@@ -275,7 +276,7 @@ final class AutofillManagerServiceImpl {
|
||||
pruneAbandonedSessionsLocked();
|
||||
|
||||
final Session newSession = createSessionByTokenLocked(activityToken, uid, appCallbackToken,
|
||||
hasCallback, flags, packageName);
|
||||
hasCallback, packageName);
|
||||
if (newSession == null) {
|
||||
return NO_SESSION;
|
||||
}
|
||||
@@ -359,8 +360,7 @@ final class AutofillManagerServiceImpl {
|
||||
}
|
||||
|
||||
private Session createSessionByTokenLocked(@NonNull IBinder activityToken, int uid,
|
||||
@NonNull IBinder appCallbackToken, boolean hasCallback, int flags,
|
||||
@NonNull String packageName) {
|
||||
@NonNull IBinder appCallbackToken, boolean hasCallback, @NonNull String packageName) {
|
||||
// use random ids so that one app cannot know that another app creates sessions
|
||||
int sessionId;
|
||||
int tries = 0;
|
||||
@@ -402,18 +402,29 @@ final class AutofillManagerServiceImpl {
|
||||
}
|
||||
}
|
||||
|
||||
void updateSessionLocked(int sessionId, int uid, AutofillId autofillId, Rect virtualBounds,
|
||||
/**
|
||||
* Updates a session and returns whether it should be restarted.
|
||||
*/
|
||||
boolean updateSessionLocked(int sessionId, int uid, AutofillId autofillId, Rect virtualBounds,
|
||||
AutofillValue value, int action, int flags) {
|
||||
final Session session = mSessions.get(sessionId);
|
||||
if (session == null || session.uid != uid) {
|
||||
if (sVerbose) {
|
||||
Slog.v(TAG, "updateSessionLocked(): session gone for " + sessionId + "(" + uid
|
||||
+ ")");
|
||||
if ((flags & FLAG_MANUAL_REQUEST) != 0) {
|
||||
if (sDebug) {
|
||||
Slog.d(TAG, "restarting session " + sessionId + " due to manual request on "
|
||||
+ autofillId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return;
|
||||
if (sVerbose) {
|
||||
Slog.v(TAG, "updateSessionLocked(): session gone for " + sessionId
|
||||
+ "(" + uid + ")");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
session.updateLocked(autofillId, virtualBounds, value, action, flags);
|
||||
return false;
|
||||
}
|
||||
|
||||
void removeSessionLocked(int sessionId) {
|
||||
|
||||
Reference in New Issue
Block a user