Merge "Use CS identity to update setting while performing factory reset"
This commit is contained in:
@@ -8668,28 +8668,32 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
public void factoryReset() {
|
public void factoryReset() {
|
||||||
enforceSettingsPermission();
|
enforceSettingsPermission();
|
||||||
|
|
||||||
if (mUserManager.hasUserRestriction(UserManager.DISALLOW_NETWORK_RESET)) {
|
final int uid = mDeps.getCallingUid();
|
||||||
|
final long token = Binder.clearCallingIdentity();
|
||||||
|
try {
|
||||||
|
if (mUserManager.hasUserRestrictionForUser(UserManager.DISALLOW_NETWORK_RESET,
|
||||||
|
UserHandle.getUserHandleForUid(uid))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final long token = Binder.clearCallingIdentity();
|
|
||||||
try {
|
|
||||||
final IpMemoryStore ipMemoryStore = IpMemoryStore.getMemoryStore(mContext);
|
final IpMemoryStore ipMemoryStore = IpMemoryStore.getMemoryStore(mContext);
|
||||||
ipMemoryStore.factoryReset();
|
ipMemoryStore.factoryReset();
|
||||||
} finally {
|
|
||||||
Binder.restoreCallingIdentity(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Turn airplane mode off
|
// Turn airplane mode off
|
||||||
setAirplaneMode(false);
|
setAirplaneMode(false);
|
||||||
|
|
||||||
// restore private DNS settings to default mode (opportunistic)
|
// restore private DNS settings to default mode (opportunistic)
|
||||||
if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_PRIVATE_DNS)) {
|
if (!mUserManager.hasUserRestrictionForUser(UserManager.DISALLOW_CONFIG_PRIVATE_DNS,
|
||||||
ConnectivitySettingsManager.setPrivateDnsMode(mContext, PRIVATE_DNS_MODE_OPPORTUNISTIC);
|
UserHandle.getUserHandleForUid(uid))) {
|
||||||
|
ConnectivitySettingsManager.setPrivateDnsMode(mContext,
|
||||||
|
PRIVATE_DNS_MODE_OPPORTUNISTIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings.Global.putString(mContext.getContentResolver(),
|
Settings.Global.putString(mContext.getContentResolver(),
|
||||||
ConnectivitySettingsManager.NETWORK_AVOID_BAD_WIFI, null);
|
ConnectivitySettingsManager.NETWORK_AVOID_BAD_WIFI, null);
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user