Migrate to TwoStatePreference

SwitchPreference and SwitchPreferenceCompat are both TwoStatePreference.

Using TwoStatePreference in Java will helps migration in the future.

Bug: 306771414
Test: manual - check Settings pages
Change-Id: I84e1d7b09451106797c2b23d127855c6976678ca
This commit is contained in:
Chaohui Wang
2023-10-23 12:38:18 +08:00
parent 7976f1e76d
commit 15ca95a31b
141 changed files with 391 additions and 395 deletions

View File

@@ -18,7 +18,6 @@ package com.android.settings.development;
import static com.android.settings.development.BluetoothA2dpHwOffloadPreferenceController.A2DP_OFFLOAD_DISABLED_PROPERTY;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothStatusCodes;
@@ -27,7 +26,7 @@ import android.os.SystemProperties;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -87,10 +86,10 @@ public class BluetoothLeAudioHwOffloadPreferenceController
if (leAudioEnabled && leAudioOffloadSupported && !a2dpOffloadDisabled) {
final boolean offloadDisabled =
SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, true);
((SwitchPreference) mPreference).setChecked(offloadDisabled);
((TwoStatePreference) mPreference).setChecked(offloadDisabled);
} else {
mPreference.setEnabled(false);
((SwitchPreference) mPreference).setChecked(true);
((TwoStatePreference) mPreference).setChecked(true);
}
}
@@ -108,7 +107,7 @@ public class BluetoothLeAudioHwOffloadPreferenceController
final boolean a2dpOffloadDisabled =
SystemProperties.getBoolean(A2DP_OFFLOAD_DISABLED_PROPERTY, false);
if (leAudioEnabled && leAudioOffloadSupported && !a2dpOffloadDisabled) {
((SwitchPreference) mPreference).setChecked(true);
((TwoStatePreference) mPreference).setChecked(true);
SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, "true");
} else {
mPreference.setEnabled(false);