Fix crash in AllInOneTetherSettings when user is not admin

When user is not admin, we should skip the setup and tear down
procedures in AllInOneTetherSettings' lifecycle. Also, the switch for
"Hotspot & tethering" on "Network & internet" should be disabled in such
case.

Bug: 151648198
Test: Build and flashed to crosshatch device. Using guest user, the
settings won't crash when using AllInOneTetherSetting and the switch is
disabled.

Change-Id: Ibd2f4111c53b8b9fa6a18504a681a27b966a3c46
This commit is contained in:
Zhen Zhang
2020-03-23 12:18:14 -07:00
parent 7f2d6ce058
commit 3b53b80715
2 changed files with 27 additions and 6 deletions

View File

@@ -249,18 +249,31 @@ public class AllInOneTetherSettings extends RestrictedDashboardFragment
@Override
public void onResume() {
super.onResume();
mTetherEnabler.addListener(mStateUpdateListener);
if (mUnavailable) {
return;
}
if (mTetherEnabler != null) {
mTetherEnabler.addListener(mStateUpdateListener);
}
}
@Override
public void onPause() {
super.onPause();
mTetherEnabler.removeListener(mStateUpdateListener);
if (mUnavailable) {
return;
}
if (mTetherEnabler != null) {
mTetherEnabler.removeListener(mStateUpdateListener);
}
}
@Override
public void onStop() {
super.onStop();
if (mUnavailable) {
return;
}
final Context context = getContext();
if (context != null) {
context.unregisterReceiver(mTetherChangeReceiver);