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.writeInt(mAutofillType);
|
||||||
out.writeStringArray(mAutofillHints);
|
out.writeStringArray(mAutofillHints);
|
||||||
final AutofillValue sanitizedValue;
|
final AutofillValue sanitizedValue;
|
||||||
if (mAutofillOverlay != null && mAutofillOverlay.value != null) {
|
if (writeSensitive) {
|
||||||
sanitizedValue = mAutofillOverlay.value;
|
|
||||||
} else if (writeSensitive) {
|
|
||||||
sanitizedValue = mAutofillValue;
|
sanitizedValue = mAutofillValue;
|
||||||
|
} else if (mAutofillOverlay != null && mAutofillOverlay.value != null) {
|
||||||
|
sanitizedValue = mAutofillOverlay.value;
|
||||||
} else {
|
} else {
|
||||||
sanitizedValue = null;
|
sanitizedValue = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -804,9 +804,26 @@ public final class AutofillManager {
|
|||||||
+ ", value=" + value + ", action=" + action + ", flags=" + flags);
|
+ ", value=" + value + ", action=" + action + ", flags=" + flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean restartIfNecessary = (flags & FLAG_MANUAL_REQUEST) != 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
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,
|
mService.updateSession(mSessionId, id, bounds, value, action, flags,
|
||||||
mContext.getUserId());
|
mContext.getUserId());
|
||||||
|
}
|
||||||
|
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ interface IAutoFillManager {
|
|||||||
boolean restoreSession(int sessionId, in IBinder activityToken, in IBinder appCallback);
|
boolean restoreSession(int sessionId, in IBinder activityToken, in IBinder appCallback);
|
||||||
void updateSession(int sessionId, in AutofillId id, in Rect bounds,
|
void updateSession(int sessionId, in AutofillId id, in Rect bounds,
|
||||||
in AutofillValue value, int action, int flags, int userId);
|
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 finishSession(int sessionId, int userId);
|
||||||
void cancelSession(int sessionId, int userId);
|
void cancelSession(int sessionId, int userId);
|
||||||
void setAuthenticationResult(in Bundle data, int sessionId, int authenticationId, int userId);
|
void setAuthenticationResult(in Bundle data, int sessionId, int authenticationId, int userId);
|
||||||
|
|||||||
@@ -172,7 +172,6 @@ public final class AutofillManagerService extends SystemService {
|
|||||||
startTrackingPackageChanges();
|
startTrackingPackageChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void startTrackingPackageChanges() {
|
private void startTrackingPackageChanges() {
|
||||||
PackageMonitor monitor = new PackageMonitor() {
|
PackageMonitor monitor = new PackageMonitor() {
|
||||||
@Override
|
@Override
|
||||||
@@ -559,17 +558,38 @@ public final class AutofillManagerService extends SystemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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) {
|
AutofillValue value, int action, int flags, int userId) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
|
final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
service.updateSessionLocked(sessionId, getCallingUid(), id, bounds, value,
|
service.updateSessionLocked(sessionId, getCallingUid(), autoFillId, bounds,
|
||||||
action, flags);
|
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
|
@Override
|
||||||
public void finishSession(int sessionId, int userId) {
|
public void finishSession(int sessionId, int userId) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.server.autofill;
|
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.ACTION_START_SESSION;
|
||||||
import static android.view.autofill.AutofillManager.NO_SESSION;
|
import static android.view.autofill.AutofillManager.NO_SESSION;
|
||||||
|
|
||||||
@@ -275,7 +276,7 @@ final class AutofillManagerServiceImpl {
|
|||||||
pruneAbandonedSessionsLocked();
|
pruneAbandonedSessionsLocked();
|
||||||
|
|
||||||
final Session newSession = createSessionByTokenLocked(activityToken, uid, appCallbackToken,
|
final Session newSession = createSessionByTokenLocked(activityToken, uid, appCallbackToken,
|
||||||
hasCallback, flags, packageName);
|
hasCallback, packageName);
|
||||||
if (newSession == null) {
|
if (newSession == null) {
|
||||||
return NO_SESSION;
|
return NO_SESSION;
|
||||||
}
|
}
|
||||||
@@ -359,8 +360,7 @@ final class AutofillManagerServiceImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Session createSessionByTokenLocked(@NonNull IBinder activityToken, int uid,
|
private Session createSessionByTokenLocked(@NonNull IBinder activityToken, int uid,
|
||||||
@NonNull IBinder appCallbackToken, boolean hasCallback, int flags,
|
@NonNull IBinder appCallbackToken, boolean hasCallback, @NonNull String packageName) {
|
||||||
@NonNull String packageName) {
|
|
||||||
// use random ids so that one app cannot know that another app creates sessions
|
// use random ids so that one app cannot know that another app creates sessions
|
||||||
int sessionId;
|
int sessionId;
|
||||||
int tries = 0;
|
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) {
|
AutofillValue value, int action, int flags) {
|
||||||
final Session session = mSessions.get(sessionId);
|
final Session session = mSessions.get(sessionId);
|
||||||
if (session == null || session.uid != uid) {
|
if (session == null || session.uid != uid) {
|
||||||
if (sVerbose) {
|
if ((flags & FLAG_MANUAL_REQUEST) != 0) {
|
||||||
Slog.v(TAG, "updateSessionLocked(): session gone for " + sessionId + "(" + uid
|
if (sDebug) {
|
||||||
+ ")");
|
Slog.d(TAG, "restarting session " + sessionId + " due to manual request on "
|
||||||
|
+ autofillId);
|
||||||
}
|
}
|
||||||
return;
|
return true;
|
||||||
|
}
|
||||||
|
if (sVerbose) {
|
||||||
|
Slog.v(TAG, "updateSessionLocked(): session gone for " + sessionId
|
||||||
|
+ "(" + uid + ")");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.updateLocked(autofillId, virtualBounds, value, action, flags);
|
session.updateLocked(autofillId, virtualBounds, value, action, flags);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeSessionLocked(int sessionId) {
|
void removeSessionLocked(int sessionId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user