summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yan Yan <evitayan@google.com> 2025-02-26 13:55:32 -0800
committer Yan Yan <evitayan@google.com> 2025-02-27 11:20:32 -0800
commit052dcaf2ec154fb1f1c54d68b1a5c9ed292b8238 (patch)
treed040827927c2c4754bf819dd3fe7ce39046a96a1
parentf3a0cd48985ee541c89cd19409b8c2630215ad74 (diff)
Prevent VCN service from being registered twice
This patch is for migrating VCN registration from platform to Tethering module. Becuase the system image has switched to use mainline prebuilts, the mainline change cannot merged together with the platform change. The plan is to update the mainline prebuilt first and then merge the platform change. Thus there will be a short window where ConnectivityServiceInitializerB will be called twice to register VCN. This patch allows ConnectivityServiceInitializerB to prevent the duplicate registration. This patch allows Tethering module to know whether VCN is moved to mainline at runtime. If VCN is in mainline, Tethering module (instead of SystemServer) will register the VCN service. Bug: 385203616 Test: atest CtsVcnTestCases && FrameworksVcnTests Test: verified registration on Android B and Android V Flag: EXEMPT; no functional code change Change-Id: If551167f4bafc39a592d8b325be3ceecf16f0b6e
-rw-r--r--packages/Vcn/service-b/Android.bp5
-rw-r--r--packages/Vcn/service-b/src/com/android/server/ConnectivityServiceInitializerB.java20
2 files changed, 23 insertions, 2 deletions
diff --git a/packages/Vcn/service-b/Android.bp b/packages/Vcn/service-b/Android.bp
index 97574e6e35e3..aad534c3289c 100644
--- a/packages/Vcn/service-b/Android.bp
+++ b/packages/Vcn/service-b/Android.bp
@@ -29,7 +29,10 @@ filegroup {
"vcn-location-flag/platform/com/android/server/vcn/VcnLocation.java",
],
}),
- visibility: ["//frameworks/base/services/core"],
+ visibility: [
+ "//frameworks/base/services/core",
+ "//packages/modules/Connectivity/service-t",
+ ],
}
// TODO: b/374174952 This library is only used in "service-connectivity-b-platform"
diff --git a/packages/Vcn/service-b/src/com/android/server/ConnectivityServiceInitializerB.java b/packages/Vcn/service-b/src/com/android/server/ConnectivityServiceInitializerB.java
index 81c7edf4adf1..b3f7eb5590c1 100644
--- a/packages/Vcn/service-b/src/com/android/server/ConnectivityServiceInitializerB.java
+++ b/packages/Vcn/service-b/src/com/android/server/ConnectivityServiceInitializerB.java
@@ -38,9 +38,27 @@ public final class ConnectivityServiceInitializerB extends SystemService {
private static final String TAG = ConnectivityServiceInitializerB.class.getSimpleName();
private final VcnManagementService mVcnManagementService;
+ // STOPSHIP: b/385203616 This static flag is for handling a temporary case when the mainline
+ // module prebuilt has updated to register the VCN but the platform change to remove
+ // registration is not merged. After mainline prebuilt is updated, we should merge the platform
+ // ASAP and remove this static check. This check is safe because both mainline and platform
+ // registration are triggered from the same method on the same thread.
+ private static boolean sIsRegistered = false;
+
public ConnectivityServiceInitializerB(Context context) {
super(context);
- mVcnManagementService = VcnManagementService.create(context);
+
+ if (!sIsRegistered) {
+ mVcnManagementService = VcnManagementService.create(context);
+ sIsRegistered = true;
+ } else {
+ mVcnManagementService = null;
+ Log.e(
+ TAG,
+ "Ignore this registration since VCN is already registered. It will happen when"
+ + " the mainline module prebuilt has updated to register the VCN but the"
+ + " platform change to remove registration is not merged.");
+ }
}
@Override