Check availability on start for TetherSettings

mUnavailable variable is only assigned when creating the activity. This make the app crash when we disable tethering and then resume + toggle on the Bluetooth Tethering. This cl remove the variable and directly check whenever the app start.

Bug: 270285631
Test: manual
Change-Id: I0dff1d11cbcc06816a69985f96eee828bb83e87c
This commit is contained in:
Hieu Dang
2023-03-30 06:16:03 +00:00
parent 5e8769bcc5
commit 12fc50ca3b

View File

@@ -123,7 +123,6 @@ public class TetherSettings extends RestrictedSettingsFragment
private boolean mMassStorageActive;
private boolean mBluetoothEnableForTether;
private boolean mUnavailable;
private DataSaverBackend mDataSaverBackend;
private boolean mDataSaverEnabled;
@@ -168,7 +167,6 @@ public class TetherSettings extends RestrictedSettingsFragment
setIfOnlyAvailableForAdmins(true);
if (isUiRestricted()) {
mUnavailable = true;
getPreferenceScreen().removeAll();
return;
}
@@ -360,7 +358,7 @@ public class TetherSettings extends RestrictedSettingsFragment
public void onStart() {
super.onStart();
if (mUnavailable) {
if (isUiRestricted()) {
if (!isUiRestrictedByOnlyAdmin()) {
getEmptyTextView().setText(R.string.tethering_settings_not_available);
}
@@ -388,7 +386,7 @@ public class TetherSettings extends RestrictedSettingsFragment
public void onStop() {
super.onStop();
if (mUnavailable) {
if (isUiRestricted()) {
return;
}
getActivity().unregisterReceiver(mTetherChangeReceiver);