Merge "Fix LockdownVpnTracker deadlock when resetting legacy Always-On VPN"
This commit is contained in:
@@ -4550,7 +4550,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
Slog.w(TAG, "VPN for user " + user + " not ready yet. Skipping lockdown");
|
Slog.w(TAG, "VPN for user " + user + " not ready yet. Skipping lockdown");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
setLockdownTracker(new LockdownVpnTracker(mContext, mNMS, this, vpn, profile));
|
setLockdownTracker(new LockdownVpnTracker(mContext, this, mHandler, vpn, profile));
|
||||||
} else {
|
} else {
|
||||||
setLockdownTracker(null);
|
setLockdownTracker(null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ package com.android.server.net;
|
|||||||
import static android.Manifest.permission.CONNECTIVITY_INTERNAL;
|
import static android.Manifest.permission.CONNECTIVITY_INTERNAL;
|
||||||
import static android.provider.Settings.ACTION_VPN_SETTINGS;
|
import static android.provider.Settings.ACTION_VPN_SETTINGS;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
@@ -32,7 +34,7 @@ import android.net.LinkProperties;
|
|||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.NetworkInfo.DetailedState;
|
import android.net.NetworkInfo.DetailedState;
|
||||||
import android.net.NetworkInfo.State;
|
import android.net.NetworkInfo.State;
|
||||||
import android.os.INetworkManagementService;
|
import android.os.Handler;
|
||||||
import android.security.Credentials;
|
import android.security.Credentials;
|
||||||
import android.security.KeyStore;
|
import android.security.KeyStore;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -63,19 +65,18 @@ public class LockdownVpnTracker {
|
|||||||
|
|
||||||
private static final String ACTION_LOCKDOWN_RESET = "com.android.server.action.LOCKDOWN_RESET";
|
private static final String ACTION_LOCKDOWN_RESET = "com.android.server.action.LOCKDOWN_RESET";
|
||||||
|
|
||||||
private static final int ROOT_UID = 0;
|
@NonNull private final Context mContext;
|
||||||
|
@NonNull private final ConnectivityService mConnService;
|
||||||
|
@NonNull private final Handler mHandler;
|
||||||
|
@NonNull private final Vpn mVpn;
|
||||||
|
@NonNull private final VpnProfile mProfile;
|
||||||
|
|
||||||
private final Context mContext;
|
@NonNull private final Object mStateLock = new Object();
|
||||||
private final INetworkManagementService mNetService;
|
|
||||||
private final ConnectivityService mConnService;
|
|
||||||
private final Vpn mVpn;
|
|
||||||
private final VpnProfile mProfile;
|
|
||||||
|
|
||||||
private final Object mStateLock = new Object();
|
@NonNull private final PendingIntent mConfigIntent;
|
||||||
|
@NonNull private final PendingIntent mResetIntent;
|
||||||
private final PendingIntent mConfigIntent;
|
|
||||||
private final PendingIntent mResetIntent;
|
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private String mAcceptedEgressIface;
|
private String mAcceptedEgressIface;
|
||||||
|
|
||||||
private int mErrorCount;
|
private int mErrorCount;
|
||||||
@@ -84,11 +85,14 @@ public class LockdownVpnTracker {
|
|||||||
return KeyStore.getInstance().contains(Credentials.LOCKDOWN_VPN);
|
return KeyStore.getInstance().contains(Credentials.LOCKDOWN_VPN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LockdownVpnTracker(Context context, INetworkManagementService netService,
|
public LockdownVpnTracker(@NonNull Context context,
|
||||||
ConnectivityService connService, Vpn vpn, VpnProfile profile) {
|
@NonNull ConnectivityService connService,
|
||||||
|
@NonNull Handler handler,
|
||||||
|
@NonNull Vpn vpn,
|
||||||
|
@NonNull VpnProfile profile) {
|
||||||
mContext = Preconditions.checkNotNull(context);
|
mContext = Preconditions.checkNotNull(context);
|
||||||
mNetService = Preconditions.checkNotNull(netService);
|
|
||||||
mConnService = Preconditions.checkNotNull(connService);
|
mConnService = Preconditions.checkNotNull(connService);
|
||||||
|
mHandler = Preconditions.checkNotNull(handler);
|
||||||
mVpn = Preconditions.checkNotNull(vpn);
|
mVpn = Preconditions.checkNotNull(vpn);
|
||||||
mProfile = Preconditions.checkNotNull(profile);
|
mProfile = Preconditions.checkNotNull(profile);
|
||||||
|
|
||||||
@@ -198,7 +202,7 @@ public class LockdownVpnTracker {
|
|||||||
mVpn.setLockdown(true);
|
mVpn.setLockdown(true);
|
||||||
|
|
||||||
final IntentFilter resetFilter = new IntentFilter(ACTION_LOCKDOWN_RESET);
|
final IntentFilter resetFilter = new IntentFilter(ACTION_LOCKDOWN_RESET);
|
||||||
mContext.registerReceiver(mResetReceiver, resetFilter, CONNECTIVITY_INTERNAL, null);
|
mContext.registerReceiver(mResetReceiver, resetFilter, CONNECTIVITY_INTERNAL, mHandler);
|
||||||
|
|
||||||
handleStateChangedLocked();
|
handleStateChangedLocked();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user