Loading services/autofill/java/com/android/server/autofill/AutofillManagerService.java +5 −6 Original line number Diff line number Diff line Loading @@ -84,7 +84,6 @@ import com.android.internal.util.Preconditions; import com.android.internal.util.SyncResultReceiver; import com.android.server.FgThread; import com.android.server.LocalServices; import com.android.server.SystemService.TargetUser; import com.android.server.autofill.ui.AutoFillUI; import com.android.server.infra.AbstractMasterSystemService; import com.android.server.infra.FrameworkResourcesServiceNameResolver; Loading Loading @@ -170,7 +169,7 @@ public final class AutofillManagerService // beneath it is brought back to top. Ideally, we should just hide the UI and // bring it back when the activity resumes. synchronized (mLock) { visitServicesLocked((s) -> s.destroyFinishedSessionsLocked()); visitServicesLocked((s) -> s.forceRemoveFinishedSessionsLocked()); } mUi.hideAll(null); } Loading Loading @@ -386,18 +385,18 @@ public final class AutofillManagerService } // Called by Shell command. void destroySessions(@UserIdInt int userId, IResultReceiver receiver) { Slog.i(TAG, "destroySessions() for userId " + userId); void removeAllSessions(@UserIdInt int userId, IResultReceiver receiver) { Slog.i(TAG, "removeAllSessions() for userId " + userId); enforceCallingPermissionForManagement(); synchronized (mLock) { if (userId != UserHandle.USER_ALL) { AutofillManagerServiceImpl service = peekServiceForUserLocked(userId); if (service != null) { service.destroySessionsLocked(); service.forceRemoveAllSessionsLocked(); } } else { visitServicesLocked((s) -> s.destroySessionsLocked()); visitServicesLocked((s) -> s.forceRemoveAllSessionsLocked()); } } Loading services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java +23 −17 Original line number Diff line number Diff line Loading @@ -215,14 +215,14 @@ final class AutofillManagerServiceImpl @GuardedBy("mLock") @Override // from PerUserSystemService protected boolean updateLocked(boolean disabled) { destroySessionsLocked(); forceRemoveAllSessionsLocked(); final boolean enabledChanged = super.updateLocked(disabled); if (enabledChanged) { if (!isEnabledLocked()) { final int sessionCount = mSessions.size(); for (int i = sessionCount - 1; i >= 0; i--) { final Session session = mSessions.valueAt(i); session.removeSelfLocked(); session.removeFromServiceLocked(); } } sendStateToClients(/* resetClient= */ false); Loading Loading @@ -442,7 +442,7 @@ final class AutofillManagerServiceImpl if (sVerbose) Slog.v(TAG, "finishSessionLocked(): session finished on save? " + finished); if (finished) { session.removeSelfLocked(); session.removeFromServiceLocked(); } } Loading @@ -457,7 +457,7 @@ final class AutofillManagerServiceImpl Slog.w(TAG, "cancelSessionLocked(): no session for " + sessionId + "(" + uid + ")"); return; } session.removeSelfLocked(); session.removeFromServiceLocked(); } @GuardedBy("mLock") Loading @@ -483,7 +483,7 @@ final class AutofillManagerServiceImpl componentName.getPackageName()); Settings.Secure.putStringForUser(getContext().getContentResolver(), Settings.Secure.AUTOFILL_SERVICE, null, mUserId); destroySessionsLocked(); forceRemoveAllSessionsLocked(); } else { Slog.w(TAG, "disableOwnedServices(): ignored because current service (" + serviceInfo + ") does not match Settings (" + autoFillService + ")"); Loading Loading @@ -1107,35 +1107,41 @@ final class AutofillManagerServiceImpl } @GuardedBy("mLock") void destroySessionsLocked() { if (mSessions.size() == 0) { void forceRemoveAllSessionsLocked() { final int sessionCount = mSessions.size(); if (sessionCount == 0) { mUi.destroyAll(null, null, false); return; } while (mSessions.size() > 0) { mSessions.valueAt(0).forceRemoveSelfLocked(); for (int i = sessionCount - 1; i >= 0; i--) { mSessions.valueAt(i).forceRemoveFromServiceLocked(); } } @GuardedBy("mLock") void destroySessionsForAugmentedAutofillOnlyLocked() { void forceRemoveForAugmentedOnlySessionsLocked() { final int sessionCount = mSessions.size(); for (int i = sessionCount - 1; i >= 0; i--) { mSessions.valueAt(i).forceRemoveSelfIfForAugmentedAutofillOnlyLocked(); mSessions.valueAt(i).forceRemoveFromServiceIfForAugmentedOnlyLocked(); } } /** * This method is called exclusively in response to {@code Intent.ACTION_CLOSE_SYSTEM_DIALOGS}. * The method removes all sessions that are finished but showing SaveUI due to how SaveUI is * managed (see b/64940307). Otherwise it will remove any augmented autofill generated windows. */ // TODO(b/64940307): remove this method if SaveUI is refactored to be attached on activities @GuardedBy("mLock") void destroyFinishedSessionsLocked() { void forceRemoveFinishedSessionsLocked() { 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(); } else { session.forceRemoveFromServiceLocked(); } else { session.destroyAugmentedAutofillWindowsLocked(); } } Loading Loading @@ -1261,7 +1267,7 @@ final class AutofillManagerServiceImpl Slog.v(TAG, "updateRemoteAugmentedAutofillService(): " + "destroying old remote service"); } destroySessionsForAugmentedAutofillOnlyLocked(); forceRemoveForAugmentedOnlySessionsLocked(); mRemoteAugmentedAutofillService.unbind(); mRemoteAugmentedAutofillService = null; mRemoteAugmentedAutofillServiceInfo = null; Loading Loading @@ -1663,7 +1669,7 @@ final class AutofillManagerServiceImpl Slog.i(TAG, "Prune session " + sessionToRemove.id + " (" + sessionToRemove.getActivityTokenLocked() + ")"); } sessionToRemove.removeSelfLocked(); sessionToRemove.removeFromServiceLocked(); } } } Loading services/autofill/java/com/android/server/autofill/AutofillManagerServiceShellCommand.java +1 −1 Original line number Diff line number Diff line Loading @@ -355,7 +355,7 @@ public final class AutofillManagerServiceShellCommand extends ShellCommand { latch.countDown(); } }; return requestSessionCommon(pw, latch, () -> mService.destroySessions(userId, receiver)); return requestSessionCommon(pw, latch, () -> mService.removeAllSessions(userId, receiver)); } private int requestList(PrintWriter pw) { Loading services/autofill/java/com/android/server/autofill/Session.java +50 −50 Original line number Diff line number Diff line Loading @@ -227,8 +227,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState private boolean mHasCallback; /** * Extras sent by service on {@code onFillRequest()} calls; the first non-null extra is saved * and used on subsequent {@code onFillRequest()} and {@code onSaveRequest()} calls. * Extras sent by service on {@code onFillRequest()} calls; the most recent non-null extra is * saved and used on subsequent {@code onFillRequest()} and {@code onSaveRequest()} calls. */ @GuardedBy("mLock") private Bundle mClientState; Loading Loading @@ -1086,7 +1086,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (showMessage) { getUiForShowing().showError(message, this); } removeSelf(); removeFromService(); } // FillServiceCallbacks Loading @@ -1111,7 +1111,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } // Nothing left to do... removeSelf(); removeFromService(); } // FillServiceCallbacks Loading Loading @@ -1147,7 +1147,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (showMessage) { getUiForShowing().showError(message, this); } removeSelf(); removeFromService(); } /** Loading Loading @@ -1179,7 +1179,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState @Override public void onServiceDied(@NonNull RemoteFillService service) { Slog.w(TAG, "removing session because service died"); forceRemoveSelfLocked(); forceRemoveFromServiceLocked(); } // AutoFillUiCallback Loading @@ -1199,7 +1199,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } fillInIntent = createAuthFillInIntentLocked(requestId, extras); if (fillInIntent == null) { forceRemoveSelfLocked(); forceRemoveFromServiceLocked(); return; } } Loading Loading @@ -1255,7 +1255,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } } mHandler.sendMessage(obtainMessage( Session::removeSelf, this)); Session::removeFromService, this)); } // AutoFillUiCallback Loading Loading @@ -1327,7 +1327,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState @Override public void cancelSession() { synchronized (mLock) { removeSelfLocked(); removeFromServiceLocked(); } } Loading @@ -1347,7 +1347,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState return; } if (intent == null) { removeSelfLocked(); removeFromServiceLocked(); } } mHandler.sendMessage(obtainMessage( Loading Loading @@ -1401,13 +1401,13 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // Typically happens when app explicitly called cancel() while the service was showing // the auth UI. Slog.w(TAG, "setAuthenticationResultLocked(" + authenticationId + "): no responses"); removeSelf(); removeFromService(); return; } final FillResponse authenticatedResponse = mResponses.get(requestId); if (authenticatedResponse == null || data == null) { Slog.w(TAG, "no authenticated response"); removeSelf(); removeFromService(); return; } Loading @@ -1418,7 +1418,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState final Dataset dataset = authenticatedResponse.getDatasets().get(datasetIdx); if (dataset == null) { Slog.w(TAG, "no dataset with index " + datasetIdx + " on fill response"); removeSelf(); removeFromService(); return; } } Loading Loading @@ -1504,7 +1504,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState Slog.d(TAG, "Rejecting empty/invalid auth result"); } mService.resetLastAugmentedAutofillResponse(); removeSelfLocked(); removeFromServiceLocked(); return; } Loading Loading @@ -2715,7 +2715,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState return; } if (sDebug) Slog.d(TAG, "Finishing session because URL bar changed"); forceRemoveSelfLocked(AutofillManager.STATE_UNKNOWN_COMPAT_MODE); forceRemoveFromServiceLocked(AutofillManager.STATE_UNKNOWN_COMPAT_MODE); return; } if (!Objects.equals(value, viewState.getCurrentValue())) { Loading Loading @@ -3226,7 +3226,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } // Nothing to be done, but need to notify client. notifyUnavailableToClient(AutofillManager.STATE_FINISHED, autofillableIds); removeSelf(); removeFromService(); } else { if ((flags & FLAG_PASSWORD_INPUT_TYPE) != 0) { if (sVerbose) { Loading Loading @@ -3392,20 +3392,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState return mAugmentedAutofillDestroyer; } @GuardedBy("mLock") private void logAugmentedAutofillRequestLocked(int mode, ComponentName augmentedRemoteServiceName, AutofillId focusedId, boolean isWhitelisted, Boolean isInline) { final String historyItem = "aug:id=" + id + " u=" + uid + " m=" + mode + " a=" + ComponentName.flattenToShortString(mComponentName) + " f=" + focusedId + " s=" + augmentedRemoteServiceName + " w=" + isWhitelisted + " i=" + isInline; mService.getMaster().logRequestLocked(historyItem); } @GuardedBy("mLock") private void cancelAugmentedAutofillLocked() { final RemoteAugmentedAutofillService remoteService = mService Loading Loading @@ -3574,7 +3560,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState setViewStatesLocked(null, dataset, ViewState.STATE_WAITING_DATASET_AUTH, false); final Intent fillInIntent = createAuthFillInIntentLocked(requestId, mClientState); if (fillInIntent == null) { forceRemoveSelfLocked(); forceRemoveFromServiceLocked(); return; } final int authenticationId = AutofillManager.makeAuthenticationId(requestId, Loading Loading @@ -3923,12 +3909,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } /** * Cleans up this session. * Destroy this session and perform any clean up work. * * <p>Typically called in 2 scenarios: * * <ul> * <li>When the session naturally finishes (i.e., from {@link #removeSelfLocked()}. * <li>When the session naturally finishes (i.e., from {@link #removeFromServiceLocked()}. * <li>When the service hosting the session is finished (for example, because the user * disabled it). * </ul> Loading Loading @@ -3990,32 +3976,32 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } /** * Cleans up this session and remove it from the service always, even if it does have a pending * Destroy this session and remove it from the service always, even if it does have a pending * Save UI. */ @GuardedBy("mLock") void forceRemoveSelfLocked() { forceRemoveSelfLocked(AutofillManager.STATE_UNKNOWN); void forceRemoveFromServiceLocked() { forceRemoveFromServiceLocked(AutofillManager.STATE_UNKNOWN); } @GuardedBy("mLock") void forceRemoveSelfIfForAugmentedAutofillOnlyLocked() { void forceRemoveFromServiceIfForAugmentedOnlyLocked() { if (sVerbose) { Slog.v(TAG, "forceRemoveSelfIfForAugmentedAutofillOnly(" + this.id + "): " Slog.v(TAG, "forceRemoveFromServiceIfForAugmentedOnlyLocked(" + this.id + "): " + mForAugmentedAutofillOnly); } if (!mForAugmentedAutofillOnly) return; forceRemoveSelfLocked(); forceRemoveFromServiceLocked(); } @GuardedBy("mLock") void forceRemoveSelfLocked(int clientState) { if (sVerbose) Slog.v(TAG, "forceRemoveSelfLocked(): " + mPendingSaveUi); void forceRemoveFromServiceLocked(int clientState) { if (sVerbose) Slog.v(TAG, "forceRemoveFromServiceLocked(): " + mPendingSaveUi); final boolean isPendingSaveUi = isSaveUiPendingLocked(); mPendingSaveUi = null; removeSelfLocked(); removeFromServiceLocked(); mUi.destroyAll(mPendingSaveUi, this, false); if (!isPendingSaveUi) { try { Loading @@ -4036,28 +4022,28 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } /** * Thread-safe version of {@link #removeSelfLocked()}. * Thread-safe version of {@link #removeFromServiceLocked()}. */ private void removeSelf() { private void removeFromService() { synchronized (mLock) { removeSelfLocked(); removeFromServiceLocked(); } } /** * Cleans up this session and remove it from the service, but but only if it does not have a * Destroy this session and remove it from the service, but but only if it does not have a * pending Save UI. */ @GuardedBy("mLock") void removeSelfLocked() { if (sVerbose) Slog.v(TAG, "removeSelfLocked(" + this.id + "): " + mPendingSaveUi); void removeFromServiceLocked() { if (sVerbose) Slog.v(TAG, "removeFromServiceLocked(" + this.id + "): " + mPendingSaveUi); if (mDestroyed) { Slog.w(TAG, "Call to Session#removeSelfLocked() rejected - session: " Slog.w(TAG, "Call to Session#removeFromServiceLocked() rejected - session: " + id + " destroyed"); return; } if (isSaveUiPendingLocked()) { Slog.i(TAG, "removeSelfLocked() ignored, waiting for pending save ui"); Slog.i(TAG, "removeFromServiceLocked() ignored, waiting for pending save ui"); return; } Loading Loading @@ -4139,6 +4125,20 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState requestLog.addTaggedData(tag, value); } @GuardedBy("mLock") private void logAugmentedAutofillRequestLocked(int mode, ComponentName augmentedRemoteServiceName, AutofillId focusedId, boolean isWhitelisted, Boolean isInline) { final String historyItem = "aug:id=" + id + " u=" + uid + " m=" + mode + " a=" + ComponentName.flattenToShortString(mComponentName) + " f=" + focusedId + " s=" + augmentedRemoteServiceName + " w=" + isWhitelisted + " i=" + isInline; mService.getMaster().logRequestLocked(historyItem); } private void wtf(@Nullable Exception e, String fmt, Object...args) { final String message = String.format(fmt, args); synchronized (mLock) { Loading Loading
services/autofill/java/com/android/server/autofill/AutofillManagerService.java +5 −6 Original line number Diff line number Diff line Loading @@ -84,7 +84,6 @@ import com.android.internal.util.Preconditions; import com.android.internal.util.SyncResultReceiver; import com.android.server.FgThread; import com.android.server.LocalServices; import com.android.server.SystemService.TargetUser; import com.android.server.autofill.ui.AutoFillUI; import com.android.server.infra.AbstractMasterSystemService; import com.android.server.infra.FrameworkResourcesServiceNameResolver; Loading Loading @@ -170,7 +169,7 @@ public final class AutofillManagerService // beneath it is brought back to top. Ideally, we should just hide the UI and // bring it back when the activity resumes. synchronized (mLock) { visitServicesLocked((s) -> s.destroyFinishedSessionsLocked()); visitServicesLocked((s) -> s.forceRemoveFinishedSessionsLocked()); } mUi.hideAll(null); } Loading Loading @@ -386,18 +385,18 @@ public final class AutofillManagerService } // Called by Shell command. void destroySessions(@UserIdInt int userId, IResultReceiver receiver) { Slog.i(TAG, "destroySessions() for userId " + userId); void removeAllSessions(@UserIdInt int userId, IResultReceiver receiver) { Slog.i(TAG, "removeAllSessions() for userId " + userId); enforceCallingPermissionForManagement(); synchronized (mLock) { if (userId != UserHandle.USER_ALL) { AutofillManagerServiceImpl service = peekServiceForUserLocked(userId); if (service != null) { service.destroySessionsLocked(); service.forceRemoveAllSessionsLocked(); } } else { visitServicesLocked((s) -> s.destroySessionsLocked()); visitServicesLocked((s) -> s.forceRemoveAllSessionsLocked()); } } Loading
services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java +23 −17 Original line number Diff line number Diff line Loading @@ -215,14 +215,14 @@ final class AutofillManagerServiceImpl @GuardedBy("mLock") @Override // from PerUserSystemService protected boolean updateLocked(boolean disabled) { destroySessionsLocked(); forceRemoveAllSessionsLocked(); final boolean enabledChanged = super.updateLocked(disabled); if (enabledChanged) { if (!isEnabledLocked()) { final int sessionCount = mSessions.size(); for (int i = sessionCount - 1; i >= 0; i--) { final Session session = mSessions.valueAt(i); session.removeSelfLocked(); session.removeFromServiceLocked(); } } sendStateToClients(/* resetClient= */ false); Loading Loading @@ -442,7 +442,7 @@ final class AutofillManagerServiceImpl if (sVerbose) Slog.v(TAG, "finishSessionLocked(): session finished on save? " + finished); if (finished) { session.removeSelfLocked(); session.removeFromServiceLocked(); } } Loading @@ -457,7 +457,7 @@ final class AutofillManagerServiceImpl Slog.w(TAG, "cancelSessionLocked(): no session for " + sessionId + "(" + uid + ")"); return; } session.removeSelfLocked(); session.removeFromServiceLocked(); } @GuardedBy("mLock") Loading @@ -483,7 +483,7 @@ final class AutofillManagerServiceImpl componentName.getPackageName()); Settings.Secure.putStringForUser(getContext().getContentResolver(), Settings.Secure.AUTOFILL_SERVICE, null, mUserId); destroySessionsLocked(); forceRemoveAllSessionsLocked(); } else { Slog.w(TAG, "disableOwnedServices(): ignored because current service (" + serviceInfo + ") does not match Settings (" + autoFillService + ")"); Loading Loading @@ -1107,35 +1107,41 @@ final class AutofillManagerServiceImpl } @GuardedBy("mLock") void destroySessionsLocked() { if (mSessions.size() == 0) { void forceRemoveAllSessionsLocked() { final int sessionCount = mSessions.size(); if (sessionCount == 0) { mUi.destroyAll(null, null, false); return; } while (mSessions.size() > 0) { mSessions.valueAt(0).forceRemoveSelfLocked(); for (int i = sessionCount - 1; i >= 0; i--) { mSessions.valueAt(i).forceRemoveFromServiceLocked(); } } @GuardedBy("mLock") void destroySessionsForAugmentedAutofillOnlyLocked() { void forceRemoveForAugmentedOnlySessionsLocked() { final int sessionCount = mSessions.size(); for (int i = sessionCount - 1; i >= 0; i--) { mSessions.valueAt(i).forceRemoveSelfIfForAugmentedAutofillOnlyLocked(); mSessions.valueAt(i).forceRemoveFromServiceIfForAugmentedOnlyLocked(); } } /** * This method is called exclusively in response to {@code Intent.ACTION_CLOSE_SYSTEM_DIALOGS}. * The method removes all sessions that are finished but showing SaveUI due to how SaveUI is * managed (see b/64940307). Otherwise it will remove any augmented autofill generated windows. */ // TODO(b/64940307): remove this method if SaveUI is refactored to be attached on activities @GuardedBy("mLock") void destroyFinishedSessionsLocked() { void forceRemoveFinishedSessionsLocked() { 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(); } else { session.forceRemoveFromServiceLocked(); } else { session.destroyAugmentedAutofillWindowsLocked(); } } Loading Loading @@ -1261,7 +1267,7 @@ final class AutofillManagerServiceImpl Slog.v(TAG, "updateRemoteAugmentedAutofillService(): " + "destroying old remote service"); } destroySessionsForAugmentedAutofillOnlyLocked(); forceRemoveForAugmentedOnlySessionsLocked(); mRemoteAugmentedAutofillService.unbind(); mRemoteAugmentedAutofillService = null; mRemoteAugmentedAutofillServiceInfo = null; Loading Loading @@ -1663,7 +1669,7 @@ final class AutofillManagerServiceImpl Slog.i(TAG, "Prune session " + sessionToRemove.id + " (" + sessionToRemove.getActivityTokenLocked() + ")"); } sessionToRemove.removeSelfLocked(); sessionToRemove.removeFromServiceLocked(); } } } Loading
services/autofill/java/com/android/server/autofill/AutofillManagerServiceShellCommand.java +1 −1 Original line number Diff line number Diff line Loading @@ -355,7 +355,7 @@ public final class AutofillManagerServiceShellCommand extends ShellCommand { latch.countDown(); } }; return requestSessionCommon(pw, latch, () -> mService.destroySessions(userId, receiver)); return requestSessionCommon(pw, latch, () -> mService.removeAllSessions(userId, receiver)); } private int requestList(PrintWriter pw) { Loading
services/autofill/java/com/android/server/autofill/Session.java +50 −50 Original line number Diff line number Diff line Loading @@ -227,8 +227,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState private boolean mHasCallback; /** * Extras sent by service on {@code onFillRequest()} calls; the first non-null extra is saved * and used on subsequent {@code onFillRequest()} and {@code onSaveRequest()} calls. * Extras sent by service on {@code onFillRequest()} calls; the most recent non-null extra is * saved and used on subsequent {@code onFillRequest()} and {@code onSaveRequest()} calls. */ @GuardedBy("mLock") private Bundle mClientState; Loading Loading @@ -1086,7 +1086,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (showMessage) { getUiForShowing().showError(message, this); } removeSelf(); removeFromService(); } // FillServiceCallbacks Loading @@ -1111,7 +1111,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } // Nothing left to do... removeSelf(); removeFromService(); } // FillServiceCallbacks Loading Loading @@ -1147,7 +1147,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (showMessage) { getUiForShowing().showError(message, this); } removeSelf(); removeFromService(); } /** Loading Loading @@ -1179,7 +1179,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState @Override public void onServiceDied(@NonNull RemoteFillService service) { Slog.w(TAG, "removing session because service died"); forceRemoveSelfLocked(); forceRemoveFromServiceLocked(); } // AutoFillUiCallback Loading @@ -1199,7 +1199,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } fillInIntent = createAuthFillInIntentLocked(requestId, extras); if (fillInIntent == null) { forceRemoveSelfLocked(); forceRemoveFromServiceLocked(); return; } } Loading Loading @@ -1255,7 +1255,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } } mHandler.sendMessage(obtainMessage( Session::removeSelf, this)); Session::removeFromService, this)); } // AutoFillUiCallback Loading Loading @@ -1327,7 +1327,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState @Override public void cancelSession() { synchronized (mLock) { removeSelfLocked(); removeFromServiceLocked(); } } Loading @@ -1347,7 +1347,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState return; } if (intent == null) { removeSelfLocked(); removeFromServiceLocked(); } } mHandler.sendMessage(obtainMessage( Loading Loading @@ -1401,13 +1401,13 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // Typically happens when app explicitly called cancel() while the service was showing // the auth UI. Slog.w(TAG, "setAuthenticationResultLocked(" + authenticationId + "): no responses"); removeSelf(); removeFromService(); return; } final FillResponse authenticatedResponse = mResponses.get(requestId); if (authenticatedResponse == null || data == null) { Slog.w(TAG, "no authenticated response"); removeSelf(); removeFromService(); return; } Loading @@ -1418,7 +1418,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState final Dataset dataset = authenticatedResponse.getDatasets().get(datasetIdx); if (dataset == null) { Slog.w(TAG, "no dataset with index " + datasetIdx + " on fill response"); removeSelf(); removeFromService(); return; } } Loading Loading @@ -1504,7 +1504,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState Slog.d(TAG, "Rejecting empty/invalid auth result"); } mService.resetLastAugmentedAutofillResponse(); removeSelfLocked(); removeFromServiceLocked(); return; } Loading Loading @@ -2715,7 +2715,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState return; } if (sDebug) Slog.d(TAG, "Finishing session because URL bar changed"); forceRemoveSelfLocked(AutofillManager.STATE_UNKNOWN_COMPAT_MODE); forceRemoveFromServiceLocked(AutofillManager.STATE_UNKNOWN_COMPAT_MODE); return; } if (!Objects.equals(value, viewState.getCurrentValue())) { Loading Loading @@ -3226,7 +3226,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } // Nothing to be done, but need to notify client. notifyUnavailableToClient(AutofillManager.STATE_FINISHED, autofillableIds); removeSelf(); removeFromService(); } else { if ((flags & FLAG_PASSWORD_INPUT_TYPE) != 0) { if (sVerbose) { Loading Loading @@ -3392,20 +3392,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState return mAugmentedAutofillDestroyer; } @GuardedBy("mLock") private void logAugmentedAutofillRequestLocked(int mode, ComponentName augmentedRemoteServiceName, AutofillId focusedId, boolean isWhitelisted, Boolean isInline) { final String historyItem = "aug:id=" + id + " u=" + uid + " m=" + mode + " a=" + ComponentName.flattenToShortString(mComponentName) + " f=" + focusedId + " s=" + augmentedRemoteServiceName + " w=" + isWhitelisted + " i=" + isInline; mService.getMaster().logRequestLocked(historyItem); } @GuardedBy("mLock") private void cancelAugmentedAutofillLocked() { final RemoteAugmentedAutofillService remoteService = mService Loading Loading @@ -3574,7 +3560,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState setViewStatesLocked(null, dataset, ViewState.STATE_WAITING_DATASET_AUTH, false); final Intent fillInIntent = createAuthFillInIntentLocked(requestId, mClientState); if (fillInIntent == null) { forceRemoveSelfLocked(); forceRemoveFromServiceLocked(); return; } final int authenticationId = AutofillManager.makeAuthenticationId(requestId, Loading Loading @@ -3923,12 +3909,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } /** * Cleans up this session. * Destroy this session and perform any clean up work. * * <p>Typically called in 2 scenarios: * * <ul> * <li>When the session naturally finishes (i.e., from {@link #removeSelfLocked()}. * <li>When the session naturally finishes (i.e., from {@link #removeFromServiceLocked()}. * <li>When the service hosting the session is finished (for example, because the user * disabled it). * </ul> Loading Loading @@ -3990,32 +3976,32 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } /** * Cleans up this session and remove it from the service always, even if it does have a pending * Destroy this session and remove it from the service always, even if it does have a pending * Save UI. */ @GuardedBy("mLock") void forceRemoveSelfLocked() { forceRemoveSelfLocked(AutofillManager.STATE_UNKNOWN); void forceRemoveFromServiceLocked() { forceRemoveFromServiceLocked(AutofillManager.STATE_UNKNOWN); } @GuardedBy("mLock") void forceRemoveSelfIfForAugmentedAutofillOnlyLocked() { void forceRemoveFromServiceIfForAugmentedOnlyLocked() { if (sVerbose) { Slog.v(TAG, "forceRemoveSelfIfForAugmentedAutofillOnly(" + this.id + "): " Slog.v(TAG, "forceRemoveFromServiceIfForAugmentedOnlyLocked(" + this.id + "): " + mForAugmentedAutofillOnly); } if (!mForAugmentedAutofillOnly) return; forceRemoveSelfLocked(); forceRemoveFromServiceLocked(); } @GuardedBy("mLock") void forceRemoveSelfLocked(int clientState) { if (sVerbose) Slog.v(TAG, "forceRemoveSelfLocked(): " + mPendingSaveUi); void forceRemoveFromServiceLocked(int clientState) { if (sVerbose) Slog.v(TAG, "forceRemoveFromServiceLocked(): " + mPendingSaveUi); final boolean isPendingSaveUi = isSaveUiPendingLocked(); mPendingSaveUi = null; removeSelfLocked(); removeFromServiceLocked(); mUi.destroyAll(mPendingSaveUi, this, false); if (!isPendingSaveUi) { try { Loading @@ -4036,28 +4022,28 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } /** * Thread-safe version of {@link #removeSelfLocked()}. * Thread-safe version of {@link #removeFromServiceLocked()}. */ private void removeSelf() { private void removeFromService() { synchronized (mLock) { removeSelfLocked(); removeFromServiceLocked(); } } /** * Cleans up this session and remove it from the service, but but only if it does not have a * Destroy this session and remove it from the service, but but only if it does not have a * pending Save UI. */ @GuardedBy("mLock") void removeSelfLocked() { if (sVerbose) Slog.v(TAG, "removeSelfLocked(" + this.id + "): " + mPendingSaveUi); void removeFromServiceLocked() { if (sVerbose) Slog.v(TAG, "removeFromServiceLocked(" + this.id + "): " + mPendingSaveUi); if (mDestroyed) { Slog.w(TAG, "Call to Session#removeSelfLocked() rejected - session: " Slog.w(TAG, "Call to Session#removeFromServiceLocked() rejected - session: " + id + " destroyed"); return; } if (isSaveUiPendingLocked()) { Slog.i(TAG, "removeSelfLocked() ignored, waiting for pending save ui"); Slog.i(TAG, "removeFromServiceLocked() ignored, waiting for pending save ui"); return; } Loading Loading @@ -4139,6 +4125,20 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState requestLog.addTaggedData(tag, value); } @GuardedBy("mLock") private void logAugmentedAutofillRequestLocked(int mode, ComponentName augmentedRemoteServiceName, AutofillId focusedId, boolean isWhitelisted, Boolean isInline) { final String historyItem = "aug:id=" + id + " u=" + uid + " m=" + mode + " a=" + ComponentName.flattenToShortString(mComponentName) + " f=" + focusedId + " s=" + augmentedRemoteServiceName + " w=" + isWhitelisted + " i=" + isInline; mService.getMaster().logRequestLocked(historyItem); } private void wtf(@Nullable Exception e, String fmt, Object...args) { final String message = String.format(fmt, args); synchronized (mLock) { Loading