Merge "Fix errorprone warnings that should be errors" am: 5744d7c560

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/2255054

Change-Id: I65ce6c4fdedd32ff6feb4b5e210b508aafc4e589
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2022-10-31 22:57:02 +00:00
committed by Automerger Merge Worker
23 changed files with 114 additions and 122 deletions

View File

@@ -171,8 +171,8 @@ class TrustedCredentialsDialogBuilder extends AlertDialog.Builder {
} else { } else {
new AlertDialog.Builder(mActivity) new AlertDialog.Builder(mActivity)
.setMessage(R.string.trusted_credentials_remove_confirmation) .setMessage(R.string.trusted_credentials_remove_confirmation)
.setPositiveButton(android.R.string.yes, onConfirm) .setPositiveButton(android.R.string.ok, onConfirm)
.setNegativeButton(android.R.string.no, null) .setNegativeButton(android.R.string.cancel, null)
.show(); .show();
} }

View File

@@ -122,6 +122,7 @@ public class AccountDashboardFragment extends DashboardFragment {
return controllers; return controllers;
} }
@SuppressWarnings("MissingSuperCall") // TODO: Fix me
@Override @Override
public List<SearchIndexableRaw> getDynamicRawDataToIndex(Context context, public List<SearchIndexableRaw> getDynamicRawDataToIndex(Context context,
boolean enabled) { boolean enabled) {

View File

@@ -31,7 +31,7 @@ import java.util.stream.Collectors;
* A buffer of the supported link data. This {@link SupportedLinkWrapper} wraps the host, enabled * A buffer of the supported link data. This {@link SupportedLinkWrapper} wraps the host, enabled
* and a list of {@link DomainOwner}. * and a list of {@link DomainOwner}.
*/ */
public class SupportedLinkWrapper implements Comparable { public class SupportedLinkWrapper implements Comparable<SupportedLinkWrapper> {
private static final String TAG = "SupportedLinkWrapper"; private static final String TAG = "SupportedLinkWrapper";
private String mHost; private String mHost;
@@ -112,8 +112,7 @@ public class SupportedLinkWrapper implements Comparable {
} }
@Override @Override
public int compareTo(Object o) { public int compareTo(SupportedLinkWrapper that) {
final SupportedLinkWrapper that = (SupportedLinkWrapper) o;
if (this.mIsEnabled != that.mIsEnabled) { if (this.mIsEnabled != that.mIsEnabled) {
return this.mIsEnabled ? -1 : 1; return this.mIsEnabled ? -1 : 1;
} }

View File

@@ -1035,6 +1035,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
} }
} }
@SuppressWarnings("MissingSuperCall") // TODO: Fix me
@Override @Override
public void onConfigurationChanged(@NonNull Configuration newConfig) { public void onConfigurationChanged(@NonNull Configuration newConfig) {
switch(newConfig.orientation) { switch(newConfig.orientation) {

View File

@@ -57,8 +57,8 @@ public class DisableLogPersistWarningDialog extends InstrumentedDialogFragment i
return new AlertDialog.Builder(getActivity()) return new AlertDialog.Builder(getActivity())
.setTitle(R.string.dev_logpersist_clear_warning_title) .setTitle(R.string.dev_logpersist_clear_warning_title)
.setMessage(R.string.dev_logpersist_clear_warning_message) .setMessage(R.string.dev_logpersist_clear_warning_message)
.setPositiveButton(android.R.string.yes, this /* onClickListener */) .setPositiveButton(android.R.string.ok, this /* onClickListener */)
.setNegativeButton(android.R.string.no, this /* onClickListener */) .setNegativeButton(android.R.string.cancel, this /* onClickListener */)
.create(); .create();
} }

View File

@@ -52,8 +52,8 @@ public class EnableAdbWarningDialog extends InstrumentedDialogFragment implement
return new AlertDialog.Builder(getActivity()) return new AlertDialog.Builder(getActivity())
.setTitle(R.string.adb_warning_title) .setTitle(R.string.adb_warning_title)
.setMessage(R.string.adb_warning_message) .setMessage(R.string.adb_warning_message)
.setPositiveButton(android.R.string.yes, this /* onClickListener */) .setPositiveButton(android.R.string.ok, this /* onClickListener */)
.setNegativeButton(android.R.string.no, this /* onClickListener */) .setNegativeButton(android.R.string.cancel, this /* onClickListener */)
.create(); .create();
} }

View File

@@ -53,8 +53,8 @@ public class EnableDevelopmentSettingWarningDialog extends InstrumentedDialogFra
return new AlertDialog.Builder(getActivity()) return new AlertDialog.Builder(getActivity())
.setMessage(R.string.dev_settings_warning_message) .setMessage(R.string.dev_settings_warning_message)
.setTitle(R.string.dev_settings_warning_title) .setTitle(R.string.dev_settings_warning_title)
.setPositiveButton(android.R.string.yes, this) .setPositiveButton(android.R.string.ok, this)
.setNegativeButton(android.R.string.no, this) .setNegativeButton(android.R.string.cancel, this)
.create(); .create();
} }

View File

@@ -34,7 +34,6 @@ import com.android.settings.homepage.contextualcards.slices.SliceContextualCardR
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ContextualCardLookupTable { public class ContextualCardLookupTable {
@@ -65,41 +64,39 @@ public class ContextualCardLookupTable {
} }
@VisibleForTesting @VisibleForTesting
static final Set<ControllerRendererMapping> LOOKUP_TABLE = static final Set<ControllerRendererMapping> LOOKUP_TABLE = Set.of(
new TreeSet<ControllerRendererMapping>() {{ new ControllerRendererMapping(CardType.CONDITIONAL,
add(new ControllerRendererMapping(CardType.CONDITIONAL, ConditionContextualCardRenderer.VIEW_TYPE_HALF_WIDTH,
ConditionContextualCardRenderer.VIEW_TYPE_HALF_WIDTH, ConditionContextualCardController.class,
ConditionContextualCardController.class, ConditionContextualCardRenderer.class),
ConditionContextualCardRenderer.class)); new ControllerRendererMapping(CardType.CONDITIONAL,
add(new ControllerRendererMapping(CardType.CONDITIONAL, ConditionContextualCardRenderer.VIEW_TYPE_FULL_WIDTH,
ConditionContextualCardRenderer.VIEW_TYPE_FULL_WIDTH, ConditionContextualCardController.class,
ConditionContextualCardController.class, ConditionContextualCardRenderer.class),
ConditionContextualCardRenderer.class)); new ControllerRendererMapping(CardType.LEGACY_SUGGESTION,
add(new ControllerRendererMapping(CardType.LEGACY_SUGGESTION, LegacySuggestionContextualCardRenderer.VIEW_TYPE,
LegacySuggestionContextualCardRenderer.VIEW_TYPE, LegacySuggestionContextualCardController.class,
LegacySuggestionContextualCardController.class, LegacySuggestionContextualCardRenderer.class),
LegacySuggestionContextualCardRenderer.class)); new ControllerRendererMapping(CardType.SLICE,
add(new ControllerRendererMapping(CardType.SLICE, SliceContextualCardRenderer.VIEW_TYPE_FULL_WIDTH,
SliceContextualCardRenderer.VIEW_TYPE_FULL_WIDTH, SliceContextualCardController.class,
SliceContextualCardController.class, SliceContextualCardRenderer.class),
SliceContextualCardRenderer.class)); new ControllerRendererMapping(CardType.SLICE,
add(new ControllerRendererMapping(CardType.SLICE, SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH,
SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH, SliceContextualCardController.class,
SliceContextualCardController.class, SliceContextualCardRenderer.class),
SliceContextualCardRenderer.class)); new ControllerRendererMapping(CardType.SLICE,
add(new ControllerRendererMapping(CardType.SLICE, SliceContextualCardRenderer.VIEW_TYPE_STICKY,
SliceContextualCardRenderer.VIEW_TYPE_STICKY, SliceContextualCardController.class,
SliceContextualCardController.class, SliceContextualCardRenderer.class),
SliceContextualCardRenderer.class)); new ControllerRendererMapping(CardType.CONDITIONAL_FOOTER,
add(new ControllerRendererMapping(CardType.CONDITIONAL_FOOTER, ConditionFooterContextualCardRenderer.VIEW_TYPE,
ConditionFooterContextualCardRenderer.VIEW_TYPE, ConditionContextualCardController.class,
ConditionContextualCardController.class, ConditionFooterContextualCardRenderer.class),
ConditionFooterContextualCardRenderer.class)); new ControllerRendererMapping(CardType.CONDITIONAL_HEADER,
add(new ControllerRendererMapping(CardType.CONDITIONAL_HEADER, ConditionHeaderContextualCardRenderer.VIEW_TYPE,
ConditionHeaderContextualCardRenderer.VIEW_TYPE, ConditionContextualCardController.class,
ConditionContextualCardController.class, ConditionHeaderContextualCardRenderer.class));
ConditionHeaderContextualCardRenderer.class));
}};
public static Class<? extends ContextualCardController> getCardControllerClass( public static Class<? extends ContextualCardController> getCardControllerClass(
@CardType int cardType) { @CardType int cardType) {

View File

@@ -55,7 +55,6 @@ import java.util.ArrayList;
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.TreeSet;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -196,11 +195,10 @@ public class ContextualCardManager implements ContextualCardLoader.CardContentLo
// except Conditional cards, all other cards are from the database. So when the map sent // except Conditional cards, all other cards are from the database. So when the map sent
// here is empty, we only keep Conditional cards. // here is empty, we only keep Conditional cards.
if (cardTypes.isEmpty()) { if (cardTypes.isEmpty()) {
final Set<Integer> conditionalCardTypes = new TreeSet<Integer>() {{ final Set<Integer> conditionalCardTypes = Set.of(
add(ContextualCard.CardType.CONDITIONAL); ContextualCard.CardType.CONDITIONAL,
add(ContextualCard.CardType.CONDITIONAL_HEADER); ContextualCard.CardType.CONDITIONAL_HEADER,
add(ContextualCard.CardType.CONDITIONAL_FOOTER); ContextualCard.CardType.CONDITIONAL_FOOTER);
}};
cardsToKeep = mContextualCards.stream() cardsToKeep = mContextualCards.stream()
.filter(card -> conditionalCardTypes.contains(card.getCardType())) .filter(card -> conditionalCardTypes.contains(card.getCardType()))
.collect(Collectors.toList()); .collect(Collectors.toList());

View File

@@ -202,7 +202,7 @@ public class LocaleListEditor extends RestrictedSettingsFragment {
new AlertDialog.Builder(getActivity()) new AlertDialog.Builder(getActivity())
.setTitle(R.string.dlg_remove_locales_error_title) .setTitle(R.string.dlg_remove_locales_error_title)
.setMessage(R.string.dlg_remove_locales_error_message) .setMessage(R.string.dlg_remove_locales_error_message)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
} }
@@ -228,7 +228,7 @@ public class LocaleListEditor extends RestrictedSettingsFragment {
} }
builder.setTitle(title) builder.setTitle(title)
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
setRemoveMode(false); setRemoveMode(false);

View File

@@ -35,7 +35,7 @@ public class TetherProvisioningCarrierDialogActivity extends Activity {
.setTitle(R.string.wifi_tether_carrier_unsupport_dialog_title) .setTitle(R.string.wifi_tether_carrier_unsupport_dialog_title)
.setMessage(R.string.wifi_tether_carrier_unsupport_dialog_content) .setMessage(R.string.wifi_tether_carrier_unsupport_dialog_content)
.setCancelable(false) .setCancelable(false)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
dialog.cancel(); dialog.cancel();
finish(); finish();

View File

@@ -580,7 +580,7 @@ public class ApnEditor extends SettingsPreferenceFragment
// Network code // Network code
final String mnc = (subInfo == null) ? null : subInfo.getMncString(); final String mnc = (subInfo == null) ? null : subInfo.getMncString();
if ((!TextUtils.isEmpty(mcc)) && (!TextUtils.isEmpty(mcc))) { if (!TextUtils.isEmpty(mcc)) {
// Auto populate MNC and MCC for new entries, based on what SIM reports // Auto populate MNC and MCC for new entries, based on what SIM reports
mMcc.setText(mcc); mMcc.setText(mcc);
mMnc.setText(mnc); mMnc.setText(mnc);

View File

@@ -70,8 +70,8 @@ public class RoamingDialogFragment extends InstrumentedDialogFragment implements
builder.setMessage(getResources().getString(message)) builder.setMessage(getResources().getString(message))
.setTitle(title) .setTitle(title)
.setIconAttribute(android.R.attr.alertDialogIcon) .setIconAttribute(android.R.attr.alertDialogIcon)
.setPositiveButton(android.R.string.yes, this) .setPositiveButton(android.R.string.ok, this)
.setNegativeButton(android.R.string.no, this); .setNegativeButton(android.R.string.cancel, this);
AlertDialog dialog = builder.create(); AlertDialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(false); dialog.setCanceledOnTouchOutside(false);
return dialog; return dialog;

View File

@@ -363,7 +363,7 @@ public class SoundWorkSettingsController extends AbstractPreferenceController
() -> context.getString(R.string.work_sync_dialog_message))) () -> context.getString(R.string.work_sync_dialog_message)))
.setPositiveButton(R.string.work_sync_dialog_yes, .setPositiveButton(R.string.work_sync_dialog_yes,
SoundWorkSettingsController.UnifyWorkDialogFragment.this) SoundWorkSettingsController.UnifyWorkDialogFragment.this)
.setNegativeButton(android.R.string.no, /* listener= */ null) .setNegativeButton(android.R.string.cancel, /* listener= */ null)
.create(); .create();
} }

View File

@@ -10,7 +10,7 @@ import java.util.Objects;
* Holds packageName:userId pairs without any heavyweight fields. * Holds packageName:userId pairs without any heavyweight fields.
* {@see ApplicationInfo} * {@see ApplicationInfo}
*/ */
class AppVpnInfo implements Comparable { class AppVpnInfo implements Comparable<AppVpnInfo> {
public final int userId; public final int userId;
public final String packageName; public final String packageName;
@@ -20,12 +20,10 @@ class AppVpnInfo implements Comparable {
} }
@Override @Override
public int compareTo(Object other) { public int compareTo(AppVpnInfo other) {
AppVpnInfo that = (AppVpnInfo) other; int result = packageName.compareTo(other.packageName);
int result = packageName.compareTo(that.packageName);
if (result == 0) { if (result == 0) {
result = that.userId - userId; result = other.userId - userId;
} }
return result; return result;
} }

View File

@@ -117,6 +117,7 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase,
} }
} }
@SuppressWarnings("MissingSuperCall") // TODO: Fix me
@Override @Override
protected void onStart() { protected void onStart() {
final ImageButton ssidScannerButton = findViewById(R.id.ssid_scanner_button); final ImageButton ssidScannerButton = findViewById(R.id.ssid_scanner_button);

View File

@@ -137,6 +137,7 @@ public class WifiDialog2 extends AlertDialog implements WifiConfigUiBase2,
window.setAttributes(lp); window.setAttributes(lp);
} }
@SuppressWarnings("MissingSuperCall") // TODO: Fix me
@Override @Override
protected void onStart() { protected void onStart() {
final ImageButton ssidScannerButton = findViewById(R.id.ssid_scanner_button); final ImageButton ssidScannerButton = findViewById(R.id.ssid_scanner_button);

View File

@@ -405,6 +405,7 @@ public class ToggleFeaturePreferenceFragmentTest {
// do nothing // do nothing
} }
@SuppressWarnings("MissingSuperCall")
@Override @Override
public void onDestroyView() { public void onDestroyView() {
// do nothing // do nothing

View File

@@ -473,6 +473,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
// do nothing // do nothing
} }
@SuppressWarnings("MissingSuperCall")
@Override @Override
public void onDestroyView() { public void onDestroyView() {
// do nothing // do nothing

View File

@@ -50,6 +50,7 @@ public class AppFilterItemTest {
assertThat(item).isEqualTo(item2); assertThat(item).isEqualTo(item2);
} }
@SuppressWarnings("SelfComparison")
@Test @Test
public void compare_sameContent_return0() { public void compare_sameContent_return0() {
final AppFilterItem item = AppFilterRegistry.getInstance().get(FILTER_APPS_USAGE_ACCESS); final AppFilterItem item = AppFilterRegistry.getInstance().get(FILTER_APPS_USAGE_ACCESS);

View File

@@ -141,10 +141,9 @@ public class BluetoothSampleRateDialogPreferenceControllerTest {
@Test @Test
public void getSelectableIndex_verifyList() { public void getSelectableIndex_verifyList() {
List<BluetoothCodecConfig> mCodecConfigs = new ArrayList() {{ List<BluetoothCodecConfig> mCodecConfigs = List.of(
add(mCodecConfigAAC); mCodecConfigAAC,
add(mCodecConfigSBC); mCodecConfigSBC);
}};
mCodecStatus = new BluetoothCodecStatus.Builder() mCodecStatus = new BluetoothCodecStatus.Builder()
.setCodecConfig(mCodecConfigAAC) .setCodecConfig(mCodecConfigAAC)
.setCodecsSelectableCapabilities(mCodecConfigs) .setCodecsSelectableCapabilities(mCodecConfigs)

View File

@@ -43,16 +43,16 @@ public class ConfirmCredentialTest {
// Launch only one instance at a time. // Launch only one instance at a time.
assertThat(LastTryDialog.show( assertThat(LastTryDialog.show(
fm, "title", mContext.getString(android.R.string.yes), fm, "title", mContext.getString(android.R.string.ok),
android.R.string.ok, false)).isTrue(); android.R.string.ok, false)).isTrue();
assertThat(LastTryDialog.show( assertThat(LastTryDialog.show(
fm, "title", mContext.getString(android.R.string.yes), fm, "title", mContext.getString(android.R.string.ok),
android.R.string.ok, false)).isFalse(); android.R.string.ok, false)).isFalse();
// After cancelling, the dialog should be re-shown when asked for. // After cancelling, the dialog should be re-shown when asked for.
LastTryDialog.hide(fm); LastTryDialog.hide(fm);
assertThat(LastTryDialog.show( assertThat(LastTryDialog.show(
fm, "title", mContext.getString(android.R.string.yes), fm, "title", mContext.getString(android.R.string.ok),
android.R.string.ok, false)).isTrue(); android.R.string.ok, false)).isTrue();
} }
} }

View File

@@ -29,7 +29,7 @@ import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.Suppress; import android.test.suitebuilder.annotation.Suppress;
import java.util.HashMap; import java.util.Map;
public class SoundSettingsTest extends InstrumentationTestCase { public class SoundSettingsTest extends InstrumentationTestCase {
private static final String PAGE = Settings.ACTION_SOUND_SETTINGS; private static final String PAGE = Settings.ACTION_SOUND_SETTINGS;
@@ -40,60 +40,54 @@ public class SoundSettingsTest extends InstrumentationTestCase {
private SettingsHelper mHelper; private SettingsHelper mHelper;
private HashMap ringtoneSounds = new HashMap<String, String>() {{ private final Map<String, String> ringtoneSounds = Map.of(
put("angler","Dione"); "angler", "Dione",
put("bullhead","Dione"); "bullhead", "Dione",
put("marlin","Spaceship"); "marlin", "Spaceship",
put("sailfish","Spaceship"); "sailfish", "Spaceship",
put("walleye","Copycat"); "walleye", "Copycat",
put("taimen","Copycat"); "taimen", "Copycat");
}};
private HashMap ringtoneCodes = new HashMap<String, String>() {{ private final Map<String, String> ringtoneCodes = Map.of(
put("angler","38"); "angler", "38",
put("bullhead","38"); "bullhead", "38",
put("marlin","37"); "marlin", "37",
put("sailfish","37"); "sailfish", "37",
put("walleye","26"); "walleye", "26",
put("taimen","26"); "taimen", "26");
}};
private HashMap alarmSounds = new HashMap<String, String>() {{ private final Map<String, String> alarmSounds = Map.of(
put("angler","Awaken"); "angler", "Awaken",
put("bullhead","Awaken"); "bullhead", "Awaken",
put("marlin","Bounce"); "marlin", "Bounce",
put("sailfish","Bounce"); "sailfish", "Bounce",
put("walleye","Cuckoo clock"); "walleye", "Cuckoo clock",
put("taimen","Cuckoo clock"); "taimen", "Cuckoo clock");
}};
private HashMap alarmCodes = new HashMap<String, String>() {{ private final Map<String, String> alarmCodes = Map.of(
put("angler","6"); "angler", "6",
put("bullhead","6"); "bullhead", "6",
put("marlin","49"); "marlin", "49",
put("sailfish","49"); "sailfish", "49",
put("walleye","15"); "walleye", "15",
put("taimen","15"); "taimen", "15");
}};
private HashMap notificationSounds = new HashMap<String, String>() {{ private final Map<String, String> notificationSounds = Map.of(
put("angler","Ceres"); "angler", "Ceres",
put("bullhead","Ceres"); "bullhead", "Ceres",
put("marlin","Trill"); "marlin", "Trill",
put("sailfish","Trill"); "sailfish", "Trill",
put("walleye","Pipes"); "walleye", "Pipes",
put("taimen","Pipes"); "taimen", "Pipes");
}};
private HashMap notificationCodes = new HashMap<String, String>() {{ private final Map<String, String> notificationCodes = Map.of(
put("angler","26"); "angler", "26",
put("bullhead","26"); "bullhead", "26",
put("marlin","57"); "marlin", "57",
put("sailfish","57"); "sailfish", "57",
put("walleye","69"); "walleye", "69",
put("taimen","69"); "taimen", "69");
}};
@Override @Override
public void setUp() throws Exception { public void setUp() throws Exception {