settings(nfc): Remove reference to APM setting in NFC page

APM mode no longer affects NFC stack as of Android Q.

Bug: 275381319
Test: atest NfcEnablerTest NfcPreferenceControllerTest
Test: Manual settings page verification
Change-Id: I974a424332eb85e27d51816507183e1ca0def42c
This commit is contained in:
Roshan Pius
2023-03-29 10:48:23 -07:00
parent e78b3d3f7e
commit 3ebfceafa6
4 changed files with 7 additions and 117 deletions

View File

@@ -16,15 +16,12 @@
package com.android.settings.nfc;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import android.content.ContentResolver;
import android.content.Context;
import android.nfc.NfcAdapter;
import android.provider.Settings;
import com.android.settingslib.widget.MainSwitchPreference;
@@ -52,55 +49,14 @@ public class NfcEnablerTest {
mNfcEnabler = spy(new NfcEnabler(mContext, mNfcPreference));
}
@Test
public void isToggleable_AirplaneModeOff_shouldReturnTrue() {
final ContentResolver contentResolver = mContext.getContentResolver();
Settings.Global.putInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 0);
Settings.Global.putString(contentResolver,
Settings.Global.AIRPLANE_MODE_RADIOS, Settings.Global.RADIO_NFC);
Settings.Global.putString(contentResolver,
Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS, Settings.Global.RADIO_NFC);
assertThat(mNfcEnabler.isToggleable()).isTrue();
}
@Test
public void isToggleable_AirplaneModeOnNfcNotInAirplaneModeRadio_shouldReturnTrue() {
final ContentResolver contentResolver = mContext.getContentResolver();
Settings.Global.putInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 1);
Settings.Global.putString(contentResolver, Settings.Global.AIRPLANE_MODE_RADIOS, "");
assertThat(mNfcEnabler.isToggleable()).isTrue();
}
@Test
public void isToggleable_AirplaneModeOnNfcToggleable_shouldReturnTrue() {
final ContentResolver contentResolver = mContext.getContentResolver();
Settings.Global.putInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 1);
Settings.Global.putString(contentResolver,
Settings.Global.AIRPLANE_MODE_RADIOS, Settings.Global.RADIO_NFC);
Settings.Global.putString(contentResolver,
Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS, Settings.Global.RADIO_NFC);
assertThat(mNfcEnabler.isToggleable()).isTrue();
}
@Test
public void isToggleable_AirplaneModeOnNfcNotToggleable_shouldReturnFalse() {
final ContentResolver contentResolver = mContext.getContentResolver();
Settings.Global.putInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 1);
Settings.Global.putString(contentResolver,
Settings.Global.AIRPLANE_MODE_RADIOS, Settings.Global.RADIO_NFC);
Settings.Global.putString(contentResolver,
Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS, "");
assertThat(mNfcEnabler.isToggleable()).isFalse();
}
@Test
public void handleNfcStateChanged_stateOff_shouldCheckIfPreferenceEnableState() {
mNfcEnabler.handleNfcStateChanged(NfcAdapter.STATE_OFF);
verify(mNfcPreference).updateStatus(false);
verify(mNfcPreference).setEnabled(true);
verify(mNfcEnabler).isToggleable();
mNfcEnabler.handleNfcStateChanged(NfcAdapter.STATE_ON);
verify(mNfcPreference).updateStatus(true);
verify(mNfcPreference, times(2)).setEnabled(true);
}
}

View File

@@ -28,7 +28,6 @@ import android.content.Intent;
import android.nfc.NfcAdapter;
import android.nfc.NfcManager;
import android.os.UserManager;
import android.provider.Settings;
import androidx.preference.PreferenceScreen;
@@ -188,44 +187,6 @@ public class NfcPreferenceControllerTest {
assertThat(mNfcController.hasAsyncUpdate()).isTrue();
}
@Test
public void isToggleableInAirplaneMode_containNfc_shouldReturnTrue() {
Settings.Global.putString(mContext.getContentResolver(),
Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS,
Settings.Global.RADIO_NFC);
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.AIRPLANE_MODE_ON, 1);
assertThat(NfcPreferenceController.isToggleableInAirplaneMode(mContext)).isTrue();
}
@Test
public void isToggleableInAirplaneMode_withoutNfc_shouldReturnFalse() {
Settings.Global.putString(mContext.getContentResolver(),
Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS,
"null");
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.AIRPLANE_MODE_ON, 1);
assertThat(NfcPreferenceController.isToggleableInAirplaneMode(mContext)).isFalse();
}
@Test
public void shouldTurnOffNFCInAirplaneMode_airplaneModeRadiosContainsNfc_shouldReturnTrue() {
Settings.Global.putString(mContext.getContentResolver(),
Settings.Global.AIRPLANE_MODE_RADIOS, Settings.Global.RADIO_NFC);
assertThat(NfcPreferenceController.shouldTurnOffNFCInAirplaneMode(mContext)).isTrue();
}
@Test
public void shouldTurnOffNFCInAirplaneMode_airplaneModeRadiosWithoutNfc_shouldReturnFalse() {
Settings.Global.putString(mContext.getContentResolver(),
Settings.Global.AIRPLANE_MODE_RADIOS, "");
assertThat(NfcPreferenceController.shouldTurnOffNFCInAirplaneMode(mContext)).isFalse();
}
@Test
public void ncfSliceWorker_nfcBroadcast_noExtra_sliceDoesntUpdate() {
final NfcSliceWorker worker = spy(