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:
@@ -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);
|
||||
|
Reference in New Issue
Block a user