Avoid mulitple calls to getActivity.
Change-Id: I789069d86e268aee5f5a1f961de3d703cd7940a7
This commit is contained in:
@@ -65,33 +65,34 @@ public class ResetNetworkConfirm extends InstrumentedFragment {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO maybe show a progress dialog if this ends up taking a while
|
// TODO maybe show a progress dialog if this ends up taking a while
|
||||||
|
Context context = getActivity();
|
||||||
|
|
||||||
ConnectivityManager connectivityManager = (ConnectivityManager)
|
ConnectivityManager connectivityManager = (ConnectivityManager)
|
||||||
getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
|
context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
if (connectivityManager != null) {
|
if (connectivityManager != null) {
|
||||||
connectivityManager.factoryReset();
|
connectivityManager.factoryReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
WifiManager wifiManager = (WifiManager)
|
WifiManager wifiManager = (WifiManager)
|
||||||
getActivity().getSystemService(Context.WIFI_SERVICE);
|
context.getSystemService(Context.WIFI_SERVICE);
|
||||||
if (wifiManager != null) {
|
if (wifiManager != null) {
|
||||||
wifiManager.factoryReset();
|
wifiManager.factoryReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
TelephonyManager telephonyManager = (TelephonyManager)
|
TelephonyManager telephonyManager = (TelephonyManager)
|
||||||
getActivity().getSystemService(Context.TELEPHONY_SERVICE);
|
context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
if (telephonyManager != null) {
|
if (telephonyManager != null) {
|
||||||
telephonyManager.factoryReset(mSubId);
|
telephonyManager.factoryReset(mSubId);
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkPolicyManager policyManager = (NetworkPolicyManager)
|
NetworkPolicyManager policyManager = (NetworkPolicyManager)
|
||||||
getActivity().getSystemService(Context.NETWORK_POLICY_SERVICE);
|
context.getSystemService(Context.NETWORK_POLICY_SERVICE);
|
||||||
if (policyManager != null) {
|
if (policyManager != null) {
|
||||||
String subscriberId = telephonyManager.getSubscriberId(mSubId);
|
String subscriberId = telephonyManager.getSubscriberId(mSubId);
|
||||||
policyManager.factoryReset(subscriberId);
|
policyManager.factoryReset(subscriberId);
|
||||||
}
|
}
|
||||||
|
|
||||||
Toast.makeText(getActivity(), R.string.reset_network_complete_toast, Toast.LENGTH_SHORT)
|
Toast.makeText(context, R.string.reset_network_complete_toast, Toast.LENGTH_SHORT)
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user