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:
@@ -28,13 +28,13 @@ import java.util.List;
|
||||
|
||||
public class BasePreferenceControllerSignatureInspector extends CodeInspector {
|
||||
|
||||
private final List<String> grandfather;
|
||||
private final List<String> mExemptList;
|
||||
|
||||
public BasePreferenceControllerSignatureInspector(List<Class<?>> classes) {
|
||||
super(classes);
|
||||
grandfather = new ArrayList<>();
|
||||
initializeGrandfatherList(grandfather,
|
||||
"grandfather_invalid_base_preference_controller_constructor");
|
||||
mExemptList = new ArrayList<>();
|
||||
initializeExemptList(mExemptList,
|
||||
"exempt_invalid_base_preference_controller_constructor");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,7 +51,7 @@ public class BasePreferenceControllerSignatureInspector extends CodeInspector {
|
||||
continue;
|
||||
}
|
||||
final String className = c.getName();
|
||||
if (grandfather.remove(className)) {
|
||||
if (mExemptList.remove(className)) {
|
||||
continue;
|
||||
}
|
||||
final Constructor[] constructors = c.getDeclaredConstructors();
|
||||
@@ -76,10 +76,10 @@ public class BasePreferenceControllerSignatureInspector extends CodeInspector {
|
||||
.that(badClasses.toString())
|
||||
.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/"
|
||||
+ "grandfather_invalid_base_preference_controller_constructor")
|
||||
.that(grandfather)
|
||||
+ "exempt_invalid_base_preference_controller_constructor")
|
||||
.that(mExemptList)
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
|
@@ -48,13 +48,13 @@ public abstract class CodeInspector {
|
||||
*/
|
||||
public abstract void run();
|
||||
|
||||
protected void assertNoObsoleteInGrandfatherList(String listName, List<String> list) {
|
||||
final StringBuilder obsoleteGrandfatherItems = new StringBuilder(listName)
|
||||
.append(" contains item that should not be grandfathered.\n");
|
||||
protected void assertNoObsoleteInExemptList(String listName, List<String> list) {
|
||||
final StringBuilder obsoleteExemptItems = new StringBuilder(listName).append(
|
||||
" contains item that should not be exempted.\n");
|
||||
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) {
|
||||
@@ -78,16 +78,16 @@ public abstract class CodeInspector {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void initializeGrandfatherList(List<String> grandfather, String filename) {
|
||||
public static void initializeExemptList(List<String> exemptList, String filename) {
|
||||
try {
|
||||
final InputStream in = RuntimeEnvironment.application.getAssets().open(filename);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
grandfather.add(line);
|
||||
exemptList.add(line);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Error initializing grandfather " + filename, e);
|
||||
throw new IllegalArgumentException("Error initializing exempt list " + filename, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -34,13 +34,13 @@ import java.util.Set;
|
||||
*/
|
||||
public class InstrumentableFragmentCodeInspector extends CodeInspector {
|
||||
|
||||
private final List<String> grandfather_notImplementingInstrumentable;
|
||||
private final List<String> mNotImplementingInstrumentableExemptList;
|
||||
|
||||
public InstrumentableFragmentCodeInspector(List<Class<?>> classes) {
|
||||
super(classes);
|
||||
grandfather_notImplementingInstrumentable = new ArrayList<>();
|
||||
initializeGrandfatherList(grandfather_notImplementingInstrumentable,
|
||||
"grandfather_not_implementing_instrumentable");
|
||||
mNotImplementingInstrumentableExemptList = new ArrayList<>();
|
||||
initializeExemptList(mNotImplementingInstrumentableExemptList,
|
||||
"exempt_not_implementing_instrumentable");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,7 +54,7 @@ public class InstrumentableFragmentCodeInspector extends CodeInspector {
|
||||
final String className = clazz.getName();
|
||||
// If it's a fragment, it must also be instrumentable.
|
||||
final boolean whitelisted =
|
||||
grandfather_notImplementingInstrumentable.remove(className);
|
||||
mNotImplementingInstrumentableExemptList.remove(className);
|
||||
if (Fragment.class.isAssignableFrom(clazz)
|
||||
&& !Instrumentable.class.isAssignableFrom(clazz)
|
||||
&& !whitelisted) {
|
||||
@@ -67,7 +67,7 @@ public class InstrumentableFragmentCodeInspector extends CodeInspector {
|
||||
sb.append(c).append("\n");
|
||||
}
|
||||
assertWithMessage(sb.toString()).that(broken.isEmpty()).isTrue();
|
||||
assertNoObsoleteInGrandfatherList("grandfather_not_implementing_instrumentable",
|
||||
grandfather_notImplementingInstrumentable);
|
||||
assertNoObsoleteInExemptList("exempt_not_implementing_instrumentable",
|
||||
mNotImplementingInstrumentableExemptList);
|
||||
}
|
||||
}
|
||||
|
@@ -57,21 +57,21 @@ public class SearchIndexProviderCodeInspector extends CodeInspector {
|
||||
"SearchIndexableProvider must either provide no resource to index, or valid ones. "
|
||||
+ "But the followings contain resource with xml id = 0\n";
|
||||
|
||||
private final List<String> notImplementingIndexProviderGrandfatherList;
|
||||
private final List<String> notInSearchIndexableRegistryGrandfatherList;
|
||||
private final List<String> notSharingPrefControllersGrandfatherList;
|
||||
private final List<String> mNotImplementingIndexProviderExemptList;
|
||||
private final List<String> mNotInSearchIndexableRegistryExemptList;
|
||||
private final List<String> mNotSharingPrefControllersExemptList;
|
||||
|
||||
public SearchIndexProviderCodeInspector(List<Class<?>> classes) {
|
||||
super(classes);
|
||||
notImplementingIndexProviderGrandfatherList = new ArrayList<>();
|
||||
notInSearchIndexableRegistryGrandfatherList = new ArrayList<>();
|
||||
notSharingPrefControllersGrandfatherList = new ArrayList<>();
|
||||
initializeGrandfatherList(notImplementingIndexProviderGrandfatherList,
|
||||
"grandfather_not_implementing_index_provider");
|
||||
initializeGrandfatherList(notInSearchIndexableRegistryGrandfatherList,
|
||||
"grandfather_not_in_search_index_provider_registry");
|
||||
initializeGrandfatherList(notSharingPrefControllersGrandfatherList,
|
||||
"grandfather_not_sharing_pref_controllers_with_search_provider");
|
||||
mNotImplementingIndexProviderExemptList = new ArrayList<>();
|
||||
mNotInSearchIndexableRegistryExemptList = new ArrayList<>();
|
||||
mNotSharingPrefControllersExemptList = new ArrayList<>();
|
||||
initializeExemptList(mNotImplementingIndexProviderExemptList,
|
||||
"exempt_not_implementing_index_provider");
|
||||
initializeExemptList(mNotInSearchIndexableRegistryExemptList,
|
||||
"exempt_not_in_search_index_provider_registry");
|
||||
initializeExemptList(mNotSharingPrefControllersExemptList,
|
||||
"exempt_not_sharing_pref_controllers_with_search_provider");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -100,7 +100,7 @@ public class SearchIndexProviderCodeInspector extends CodeInspector {
|
||||
final boolean hasSearchIndexProvider = hasSearchIndexProvider(clazz);
|
||||
// If it implements Indexable, it must also implement the index provider field.
|
||||
if (!hasSearchIndexProvider) {
|
||||
if (!notImplementingIndexProviderGrandfatherList.remove(className)) {
|
||||
if (!mNotImplementingIndexProviderExemptList.remove(className)) {
|
||||
notImplementingIndexProvider.add(className);
|
||||
}
|
||||
continue;
|
||||
@@ -110,14 +110,14 @@ public class SearchIndexProviderCodeInspector extends CodeInspector {
|
||||
final boolean isSharingPrefControllers = DashboardFragmentSearchIndexProviderInspector
|
||||
.isSharingPreferenceControllers(clazz);
|
||||
if (!isSharingPrefControllers) {
|
||||
if (!notSharingPrefControllersGrandfatherList.remove(className)) {
|
||||
if (!mNotSharingPrefControllersExemptList.remove(className)) {
|
||||
notSharingPreferenceControllers.add(className);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// Must be in SearchProviderRegistry
|
||||
if (!providerClasses.contains(clazz)) {
|
||||
if (!notInSearchIndexableRegistryGrandfatherList.remove(className)) {
|
||||
if (!mNotInSearchIndexableRegistryExemptList.remove(className)) {
|
||||
notInSearchProviderRegistry.add(className);
|
||||
}
|
||||
}
|
||||
@@ -149,13 +149,13 @@ public class SearchIndexProviderCodeInspector extends CodeInspector {
|
||||
assertWithMessage(notProvidingValidResourceError)
|
||||
.that(notProvidingValidResource)
|
||||
.isEmpty();
|
||||
assertNoObsoleteInGrandfatherList("grandfather_not_implementing_index_provider",
|
||||
notImplementingIndexProviderGrandfatherList);
|
||||
assertNoObsoleteInGrandfatherList("grandfather_not_in_search_index_provider_registry",
|
||||
notInSearchIndexableRegistryGrandfatherList);
|
||||
assertNoObsoleteInGrandfatherList(
|
||||
"grandfather_not_sharing_pref_controllers_with_search_provider",
|
||||
notSharingPrefControllersGrandfatherList);
|
||||
assertNoObsoleteInExemptList("exempt_not_implementing_index_provider",
|
||||
mNotImplementingIndexProviderExemptList);
|
||||
assertNoObsoleteInExemptList("exempt_not_in_search_index_provider_registry",
|
||||
mNotInSearchIndexableRegistryExemptList);
|
||||
assertNoObsoleteInExemptList(
|
||||
"exempt_not_sharing_pref_controllers_with_search_provider",
|
||||
mNotSharingPrefControllersExemptList);
|
||||
}
|
||||
|
||||
private boolean hasSearchIndexProvider(Class clazz) {
|
||||
|
@@ -54,13 +54,13 @@ public class SliceControllerInXmlCodeInspector extends CodeInspector {
|
||||
);
|
||||
|
||||
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 =
|
||||
"The following controllers were expected to be declared by "
|
||||
+ "'settings:controller=Controller_Class_Name' in their corresponding Xml. "
|
||||
+ "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 SearchFeatureProvider mSearchProvider;
|
||||
@@ -73,8 +73,8 @@ public class SliceControllerInXmlCodeInspector extends CodeInspector {
|
||||
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
mFakeFeatureFactory.searchFeatureProvider = mSearchProvider;
|
||||
|
||||
CodeInspector.initializeGrandfatherList(mGrandfatheredClasses,
|
||||
"grandfather_slice_controller_not_in_xml");
|
||||
CodeInspector.initializeExemptList(mExemptedClasses,
|
||||
"exempt_slice_controller_not_in_xml");
|
||||
initDeclaredControllers();
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public class SliceControllerInXmlCodeInspector extends CodeInspector {
|
||||
}
|
||||
|
||||
// Removed whitelisted classes
|
||||
missingControllersInXml.removeAll(mGrandfatheredClasses);
|
||||
missingControllersInXml.removeAll(mExemptedClasses);
|
||||
|
||||
final String missingControllerError =
|
||||
buildErrorMessage(ERROR_MISSING_CONTROLLER, missingControllersInXml);
|
||||
|
Reference in New Issue
Block a user