Update language to comply with Android's inclusive language guidance

See https://source.android.com/setup/contribute/respectful-code for reference

Bug: 161896447
Test: robotest & manual
Change-Id: Idf3cb1eca8b814d5863f286f6a46f79fc5e7a967
This commit is contained in:
Edgar Wang
2020-08-06 22:22:22 +08:00
parent 3d2f50d842
commit ed45314758
11 changed files with 50 additions and 50 deletions

View File

@@ -28,13 +28,13 @@ import java.util.List;
public class BasePreferenceControllerSignatureInspector extends CodeInspector { public class BasePreferenceControllerSignatureInspector extends CodeInspector {
private final List<String> grandfather; private final List<String> mExemptList;
public BasePreferenceControllerSignatureInspector(List<Class<?>> classes) { public BasePreferenceControllerSignatureInspector(List<Class<?>> classes) {
super(classes); super(classes);
grandfather = new ArrayList<>(); mExemptList = new ArrayList<>();
initializeGrandfatherList(grandfather, initializeExemptList(mExemptList,
"grandfather_invalid_base_preference_controller_constructor"); "exempt_invalid_base_preference_controller_constructor");
} }
@Override @Override
@@ -51,7 +51,7 @@ public class BasePreferenceControllerSignatureInspector extends CodeInspector {
continue; continue;
} }
final String className = c.getName(); final String className = c.getName();
if (grandfather.remove(className)) { if (mExemptList.remove(className)) {
continue; continue;
} }
final Constructor[] constructors = c.getDeclaredConstructors(); final Constructor[] constructors = c.getDeclaredConstructors();
@@ -76,10 +76,10 @@ public class BasePreferenceControllerSignatureInspector extends CodeInspector {
.that(badClasses.toString()) .that(badClasses.toString())
.isEmpty(); .isEmpty();
assertWithMessage("Something in the grandfather list is no longer relevant. Please remove" assertWithMessage("Something in the exempt list is no longer relevant. Please remove"
+ "it from packages/apps/Settings/tests/robotests/assets/" + "it from packages/apps/Settings/tests/robotests/assets/"
+ "grandfather_invalid_base_preference_controller_constructor") + "exempt_invalid_base_preference_controller_constructor")
.that(grandfather) .that(mExemptList)
.isEmpty(); .isEmpty();
} }

View File

@@ -48,13 +48,13 @@ public abstract class CodeInspector {
*/ */
public abstract void run(); public abstract void run();
protected void assertNoObsoleteInGrandfatherList(String listName, List<String> list) { protected void assertNoObsoleteInExemptList(String listName, List<String> list) {
final StringBuilder obsoleteGrandfatherItems = new StringBuilder(listName) final StringBuilder obsoleteExemptItems = new StringBuilder(listName).append(
.append(" contains item that should not be grandfathered.\n"); " contains item that should not be exempted.\n");
for (String c : list) { for (String c : list) {
obsoleteGrandfatherItems.append(c).append("\n"); obsoleteExemptItems.append(c).append("\n");
} }
assertWithMessage(obsoleteGrandfatherItems.toString()).that(list).isEmpty(); assertWithMessage(obsoleteExemptItems.toString()).that(list).isEmpty();
} }
protected boolean isConcreteSettingsClass(Class clazz) { protected boolean isConcreteSettingsClass(Class clazz) {
@@ -78,16 +78,16 @@ public abstract class CodeInspector {
return true; return true;
} }
public static void initializeGrandfatherList(List<String> grandfather, String filename) { public static void initializeExemptList(List<String> exemptList, String filename) {
try { try {
final InputStream in = RuntimeEnvironment.application.getAssets().open(filename); final InputStream in = RuntimeEnvironment.application.getAssets().open(filename);
BufferedReader reader = new BufferedReader(new InputStreamReader(in)); BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line; String line;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
grandfather.add(line); exemptList.add(line);
} }
} catch (Exception e) { } catch (Exception e) {
throw new IllegalArgumentException("Error initializing grandfather " + filename, e); throw new IllegalArgumentException("Error initializing exempt list " + filename, e);
} }
} }
} }

View File

@@ -34,13 +34,13 @@ import java.util.Set;
*/ */
public class InstrumentableFragmentCodeInspector extends CodeInspector { public class InstrumentableFragmentCodeInspector extends CodeInspector {
private final List<String> grandfather_notImplementingInstrumentable; private final List<String> mNotImplementingInstrumentableExemptList;
public InstrumentableFragmentCodeInspector(List<Class<?>> classes) { public InstrumentableFragmentCodeInspector(List<Class<?>> classes) {
super(classes); super(classes);
grandfather_notImplementingInstrumentable = new ArrayList<>(); mNotImplementingInstrumentableExemptList = new ArrayList<>();
initializeGrandfatherList(grandfather_notImplementingInstrumentable, initializeExemptList(mNotImplementingInstrumentableExemptList,
"grandfather_not_implementing_instrumentable"); "exempt_not_implementing_instrumentable");
} }
@Override @Override
@@ -54,7 +54,7 @@ public class InstrumentableFragmentCodeInspector extends CodeInspector {
final String className = clazz.getName(); final String className = clazz.getName();
// If it's a fragment, it must also be instrumentable. // If it's a fragment, it must also be instrumentable.
final boolean whitelisted = final boolean whitelisted =
grandfather_notImplementingInstrumentable.remove(className); mNotImplementingInstrumentableExemptList.remove(className);
if (Fragment.class.isAssignableFrom(clazz) if (Fragment.class.isAssignableFrom(clazz)
&& !Instrumentable.class.isAssignableFrom(clazz) && !Instrumentable.class.isAssignableFrom(clazz)
&& !whitelisted) { && !whitelisted) {
@@ -67,7 +67,7 @@ public class InstrumentableFragmentCodeInspector extends CodeInspector {
sb.append(c).append("\n"); sb.append(c).append("\n");
} }
assertWithMessage(sb.toString()).that(broken.isEmpty()).isTrue(); assertWithMessage(sb.toString()).that(broken.isEmpty()).isTrue();
assertNoObsoleteInGrandfatherList("grandfather_not_implementing_instrumentable", assertNoObsoleteInExemptList("exempt_not_implementing_instrumentable",
grandfather_notImplementingInstrumentable); mNotImplementingInstrumentableExemptList);
} }
} }

View File

@@ -57,21 +57,21 @@ public class SearchIndexProviderCodeInspector extends CodeInspector {
"SearchIndexableProvider must either provide no resource to index, or valid ones. " "SearchIndexableProvider must either provide no resource to index, or valid ones. "
+ "But the followings contain resource with xml id = 0\n"; + "But the followings contain resource with xml id = 0\n";
private final List<String> notImplementingIndexProviderGrandfatherList; private final List<String> mNotImplementingIndexProviderExemptList;
private final List<String> notInSearchIndexableRegistryGrandfatherList; private final List<String> mNotInSearchIndexableRegistryExemptList;
private final List<String> notSharingPrefControllersGrandfatherList; private final List<String> mNotSharingPrefControllersExemptList;
public SearchIndexProviderCodeInspector(List<Class<?>> classes) { public SearchIndexProviderCodeInspector(List<Class<?>> classes) {
super(classes); super(classes);
notImplementingIndexProviderGrandfatherList = new ArrayList<>(); mNotImplementingIndexProviderExemptList = new ArrayList<>();
notInSearchIndexableRegistryGrandfatherList = new ArrayList<>(); mNotInSearchIndexableRegistryExemptList = new ArrayList<>();
notSharingPrefControllersGrandfatherList = new ArrayList<>(); mNotSharingPrefControllersExemptList = new ArrayList<>();
initializeGrandfatherList(notImplementingIndexProviderGrandfatherList, initializeExemptList(mNotImplementingIndexProviderExemptList,
"grandfather_not_implementing_index_provider"); "exempt_not_implementing_index_provider");
initializeGrandfatherList(notInSearchIndexableRegistryGrandfatherList, initializeExemptList(mNotInSearchIndexableRegistryExemptList,
"grandfather_not_in_search_index_provider_registry"); "exempt_not_in_search_index_provider_registry");
initializeGrandfatherList(notSharingPrefControllersGrandfatherList, initializeExemptList(mNotSharingPrefControllersExemptList,
"grandfather_not_sharing_pref_controllers_with_search_provider"); "exempt_not_sharing_pref_controllers_with_search_provider");
} }
@Override @Override
@@ -100,7 +100,7 @@ public class SearchIndexProviderCodeInspector extends CodeInspector {
final boolean hasSearchIndexProvider = hasSearchIndexProvider(clazz); final boolean hasSearchIndexProvider = hasSearchIndexProvider(clazz);
// If it implements Indexable, it must also implement the index provider field. // If it implements Indexable, it must also implement the index provider field.
if (!hasSearchIndexProvider) { if (!hasSearchIndexProvider) {
if (!notImplementingIndexProviderGrandfatherList.remove(className)) { if (!mNotImplementingIndexProviderExemptList.remove(className)) {
notImplementingIndexProvider.add(className); notImplementingIndexProvider.add(className);
} }
continue; continue;
@@ -110,14 +110,14 @@ public class SearchIndexProviderCodeInspector extends CodeInspector {
final boolean isSharingPrefControllers = DashboardFragmentSearchIndexProviderInspector final boolean isSharingPrefControllers = DashboardFragmentSearchIndexProviderInspector
.isSharingPreferenceControllers(clazz); .isSharingPreferenceControllers(clazz);
if (!isSharingPrefControllers) { if (!isSharingPrefControllers) {
if (!notSharingPrefControllersGrandfatherList.remove(className)) { if (!mNotSharingPrefControllersExemptList.remove(className)) {
notSharingPreferenceControllers.add(className); notSharingPreferenceControllers.add(className);
} }
continue; continue;
} }
// Must be in SearchProviderRegistry // Must be in SearchProviderRegistry
if (!providerClasses.contains(clazz)) { if (!providerClasses.contains(clazz)) {
if (!notInSearchIndexableRegistryGrandfatherList.remove(className)) { if (!mNotInSearchIndexableRegistryExemptList.remove(className)) {
notInSearchProviderRegistry.add(className); notInSearchProviderRegistry.add(className);
} }
} }
@@ -149,13 +149,13 @@ public class SearchIndexProviderCodeInspector extends CodeInspector {
assertWithMessage(notProvidingValidResourceError) assertWithMessage(notProvidingValidResourceError)
.that(notProvidingValidResource) .that(notProvidingValidResource)
.isEmpty(); .isEmpty();
assertNoObsoleteInGrandfatherList("grandfather_not_implementing_index_provider", assertNoObsoleteInExemptList("exempt_not_implementing_index_provider",
notImplementingIndexProviderGrandfatherList); mNotImplementingIndexProviderExemptList);
assertNoObsoleteInGrandfatherList("grandfather_not_in_search_index_provider_registry", assertNoObsoleteInExemptList("exempt_not_in_search_index_provider_registry",
notInSearchIndexableRegistryGrandfatherList); mNotInSearchIndexableRegistryExemptList);
assertNoObsoleteInGrandfatherList( assertNoObsoleteInExemptList(
"grandfather_not_sharing_pref_controllers_with_search_provider", "exempt_not_sharing_pref_controllers_with_search_provider",
notSharingPrefControllersGrandfatherList); mNotSharingPrefControllersExemptList);
} }
private boolean hasSearchIndexProvider(Class clazz) { private boolean hasSearchIndexProvider(Class clazz) {

View File

@@ -54,13 +54,13 @@ public class SliceControllerInXmlCodeInspector extends CodeInspector {
); );
private final List<String> mXmlDeclaredControllers = new ArrayList<>(); private final List<String> mXmlDeclaredControllers = new ArrayList<>();
private final List<String> mGrandfatheredClasses = new ArrayList<>(); private final List<String> mExemptedClasses = new ArrayList<>();
private final String ERROR_MISSING_CONTROLLER = private final String ERROR_MISSING_CONTROLLER =
"The following controllers were expected to be declared by " "The following controllers were expected to be declared by "
+ "'settings:controller=Controller_Class_Name' in their corresponding Xml. " + "'settings:controller=Controller_Class_Name' in their corresponding Xml. "
+ "If it should not appear in XML, add the controller's classname to " + "If it should not appear in XML, add the controller's classname to "
+ "grandfather_slice_controller_not_in_xml. Controllers:\n"; + "exempt_slice_controller_not_in_xml. Controllers:\n";
private final Context mContext; private final Context mContext;
private final SearchFeatureProvider mSearchProvider; private final SearchFeatureProvider mSearchProvider;
@@ -73,8 +73,8 @@ public class SliceControllerInXmlCodeInspector extends CodeInspector {
mFakeFeatureFactory = FakeFeatureFactory.setupForTest(); mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
mFakeFeatureFactory.searchFeatureProvider = mSearchProvider; mFakeFeatureFactory.searchFeatureProvider = mSearchProvider;
CodeInspector.initializeGrandfatherList(mGrandfatheredClasses, CodeInspector.initializeExemptList(mExemptedClasses,
"grandfather_slice_controller_not_in_xml"); "exempt_slice_controller_not_in_xml");
initDeclaredControllers(); initDeclaredControllers();
} }
@@ -117,7 +117,7 @@ public class SliceControllerInXmlCodeInspector extends CodeInspector {
} }
// Removed whitelisted classes // Removed whitelisted classes
missingControllersInXml.removeAll(mGrandfatheredClasses); missingControllersInXml.removeAll(mExemptedClasses);
final String missingControllerError = final String missingControllerError =
buildErrorMessage(ERROR_MISSING_CONTROLLER, missingControllersInXml); buildErrorMessage(ERROR_MISSING_CONTROLLER, missingControllersInXml);