Do not finish activity when the input account doesn't exist
This is to avoid the caller getting the existing account list because the prompt respond reveals that the input account does not exist. Bug: 249981091 Test: robotest Change-Id: I4bb8ecead8233780443b1cd1a8780983b7e4d5de
This commit is contained in:
@@ -50,6 +50,7 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An extra {@link UserHandle} can be specified in the intent as {@link EXTRA_USER}, if the user for
|
* An extra {@link UserHandle} can be specified in the intent as {@link EXTRA_USER}, if the user for
|
||||||
@@ -189,7 +190,7 @@ public class ChooseAccountPreferenceController extends BasePreferenceController
|
|||||||
mScreen.addPreference(p);
|
mScreen.addPreference(p);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
if (mAuthorities != null && Log.isLoggable(TAG, Log.VERBOSE)) {
|
||||||
final StringBuilder auths = new StringBuilder();
|
final StringBuilder auths = new StringBuilder();
|
||||||
for (String a : mAuthorities) {
|
for (String a : mAuthorities) {
|
||||||
auths.append(a);
|
auths.append(a);
|
||||||
@@ -197,8 +198,14 @@ public class ChooseAccountPreferenceController extends BasePreferenceController
|
|||||||
}
|
}
|
||||||
Log.v(TAG, "No providers found for authorities: " + auths);
|
Log.v(TAG, "No providers found for authorities: " + auths);
|
||||||
}
|
}
|
||||||
|
if (mAccountTypesFilter != null) {
|
||||||
|
final StringJoiner types = new StringJoiner(", ", "", "");
|
||||||
|
mAccountTypesFilter.forEach(types::add);
|
||||||
|
Log.w(TAG, "No providers found for account types: " + types);
|
||||||
|
}
|
||||||
mActivity.setResult(RESULT_CANCELED);
|
mActivity.setResult(RESULT_CANCELED);
|
||||||
mActivity.finish();
|
// Do not finish activity to avoid the caller getting the existing account list because
|
||||||
|
// the prompt respond reveals that the input account does not exist.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -173,7 +173,7 @@ public class ChooseAccountPreferenceControllerTest {
|
|||||||
mActivity);
|
mActivity);
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
|
|
||||||
assertThat(mActivity.isFinishing()).isTrue();
|
assertThat(mActivity.isFinishing()).isFalse();
|
||||||
assertThat(mPreferenceScreen.getPreferenceCount()).isEqualTo(0);
|
assertThat(mPreferenceScreen.getPreferenceCount()).isEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user