summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2020-10-06 10:47:33 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2020-10-06 10:47:33 +0000
commite50b18b0c6436e55bed0f54e5120faa054420cf7 (patch)
treed997b0d9d2fb369fd930850fc3c345ca34f731bb
parent33130380175d69480c89049c3d2eab2fc01930e2 (diff)
parentbceef6f4230a307f0c075f4742018e97499eab42 (diff)
Merge "Add synchronized to make sure data correctness"
-rw-r--r--services/core/java/com/android/server/connectivity/Vpn.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java
index 8e1fccd07f7a..500dd8a3eab7 100644
--- a/services/core/java/com/android/server/connectivity/Vpn.java
+++ b/services/core/java/com/android/server/connectivity/Vpn.java
@@ -1130,7 +1130,13 @@ public class Vpn {
return mNetworkInfo;
}
- public int getNetId() {
+ /**
+ * Return netId of current running VPN network.
+ *
+ * @return a netId if there is a running VPN network or NETID_UNSET if there is no running VPN
+ * network or network is null.
+ */
+ public synchronized int getNetId() {
final NetworkAgent agent = mNetworkAgent;
if (null == agent) return NETID_UNSET;
final Network network = agent.getNetwork();
@@ -1708,7 +1714,7 @@ public class Vpn {
/**
* Return the configuration of the currently running VPN.
*/
- public VpnConfig getVpnConfig() {
+ public synchronized VpnConfig getVpnConfig() {
enforceControlPermission();
return mConfig;
}