- Don't print PII on Dataset.toString()
- Use proper method to get last response
Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases
Bug:
67867469
Change-Id: I41579ba30366e07193ab4f7790e5a107c85d6ec2
public String toString() {
if (!sDebug) return super.toString();
- return new StringBuilder("Dataset " + mId + " [")
- .append("fieldIds=").append(mFieldIds)
+ final StringBuilder builder = new StringBuilder("Dataset[id=");
+ if (mId == null) {
+ builder.append("null");
+ } else {
+ // Cannot disclose id because it could contain PII.
+ builder.append(mId.length()).append("_chars");
+ }
+
+ return builder
+ .append(", fieldIds=").append(mFieldIds)
.append(", fieldValues=").append(mFieldValues)
.append(", fieldPresentations=")
.append(mFieldPresentations == null ? 0 : mFieldPresentations.size())
}
@Override
+ public String toString() {
+ return mEvents == null ? "no events" : mEvents.toString();
+ }
+
+ @Override
public int describeContents() {
return 0;
}
private FillResponse(@NonNull Builder builder) {
mDatasets = (builder.mDatasets != null) ? new ParceledListSlice<>(builder.mDatasets) : null;
mSaveInfo = builder.mSaveInfo;
- mClientState = builder.mCLientState;
+ mClientState = builder.mClientState;
mPresentation = builder.mPresentation;
mAuthentication = builder.mAuthentication;
mAuthenticationIds = builder.mAuthenticationIds;
public static final class Builder {
private ArrayList<Dataset> mDatasets;
private SaveInfo mSaveInfo;
- private Bundle mCLientState;
+ private Bundle mClientState;
private RemoteViews mPresentation;
private IntentSender mAuthentication;
private AutofillId[] mAuthenticationIds;
*/
public Builder setClientState(@Nullable Bundle clientState) {
throwIfDestroyed();
- mCLientState = clientState;
+ mClientState = clientState;
return this;
}
* when necessary.
*/
public void logContextCommittedLocked() {
- if (mResponses == null) {
- if (sVerbose) Slog.v(TAG, "logContextCommittedLocked(): skipped (no responses)");
- return;
- }
+ final FillResponse lastResponse = getLastResponseLocked("logContextCommited()");
+ if (lastResponse == null) return;
- final FillResponse lastResponse = mResponses.valueAt(mResponses.size() -1);
final int flags = lastResponse.getFlags();
if ((flags & FillResponse.FLAG_TRACK_CONTEXT_COMMITED) == 0) {
if (sDebug) Slog.d(TAG, "logContextCommittedLocked(): ignored by flags " + flags);
* Checks whether a view should be ignored.
*/
private boolean isIgnoredLocked(AutofillId id) {
- if (mResponses == null || mResponses.size() == 0) {
- return false;
- }
// Always check the latest response only
- final FillResponse response = mResponses.valueAt(mResponses.size() - 1);
+ final FillResponse response = getLastResponseLocked(null);
+ if (response == null) return false;
+
return ArrayUtils.contains(response.getIgnoredIds(), id);
}
}
private void updateTrackedIdsLocked() {
- if (mResponses == null || mResponses.size() == 0) {
- return;
- }
-
// Only track the views of the last response as only those are reported back to the
// service, see #showSaveLocked
- final FillResponse response = mResponses.valueAt(getLastResponseIndexLocked());
+ final FillResponse response = getLastResponseLocked(null);
+ if (response == null) return;
ArraySet<AutofillId> trackedViews = null;
boolean saveOnAllViewsInvisible = false;