Merge \"Package changed/removed listeners for always-on VPN\" into nyc-dev
am: ee5e4cc836 Change-Id: Idd2e019feb73bd580aa7d8baba03c27083e26b02
This commit is contained in:
@@ -3388,7 +3388,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
* was no always-on VPN to start. {@code false} otherwise.
|
* was no always-on VPN to start. {@code false} otherwise.
|
||||||
*/
|
*/
|
||||||
private boolean startAlwaysOnVpn(int userId) {
|
private boolean startAlwaysOnVpn(int userId) {
|
||||||
final String alwaysOnPackage;
|
|
||||||
synchronized (mVpns) {
|
synchronized (mVpns) {
|
||||||
Vpn vpn = mVpns.get(userId);
|
Vpn vpn = mVpns.get(userId);
|
||||||
if (vpn == null) {
|
if (vpn == null) {
|
||||||
@@ -3397,27 +3396,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
Slog.wtf(TAG, "User " + userId + " has no Vpn configuration");
|
Slog.wtf(TAG, "User " + userId + " has no Vpn configuration");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
alwaysOnPackage = vpn.getAlwaysOnPackage();
|
|
||||||
// Skip if there is no service to start.
|
|
||||||
if (alwaysOnPackage == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// Skip if the service is already established. This isn't bulletproof: it's not bound
|
|
||||||
// until after establish(), so if it's mid-setup onStartCommand will be sent twice,
|
|
||||||
// which may restart the connection.
|
|
||||||
if (vpn.getNetworkInfo().isConnected()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start the VPN service declared in the app's manifest.
|
return vpn.startAlwaysOnVpn();
|
||||||
Intent serviceIntent = new Intent(VpnConfig.SERVICE_INTERFACE);
|
|
||||||
serviceIntent.setPackage(alwaysOnPackage);
|
|
||||||
try {
|
|
||||||
return mContext.startServiceAsUser(serviceIntent, UserHandle.of(userId)) != null;
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
Slog.w(TAG, "VpnService " + serviceIntent + " failed to start", e);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3449,17 +3429,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the configuration
|
vpn.saveAlwaysOnPackage();
|
||||||
final long token = Binder.clearCallingIdentity();
|
|
||||||
try {
|
|
||||||
final ContentResolver cr = mContext.getContentResolver();
|
|
||||||
Settings.Secure.putStringForUser(cr, Settings.Secure.ALWAYS_ON_VPN_APP,
|
|
||||||
packageName, userId);
|
|
||||||
Settings.Secure.putIntForUser(cr, Settings.Secure.ALWAYS_ON_VPN_LOCKDOWN,
|
|
||||||
(lockdown ? 1 : 0), userId);
|
|
||||||
} finally {
|
|
||||||
Binder.restoreCallingIdentity(token);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user