summaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorRemi NGUYEN VAN <reminv@google.com>2021-03-17 23:14:53 +0900
committerLorenzo Colitti <lorenzo@google.com>2021-03-20 22:35:16 +0900
commit4f8084867e032e634c5aaa4cde866a1ab7821f61 (patch)
tree8d7b56c9173e578f4c9efa310a6986382484f451 /services
parentf969377a96b827d7704957d6164151ef248b29e7 (diff)
Migrate framework-connectivity internal resources
Use ServiceConnectivityResources instead. Start by creating resources in the ServiceConnectivityResources package to match the internal configuration, and common overlays. Bug: 182125649 Test: device boots, has connectivity Change-Id: I77a3efca2cd644f9828db1ed5d3cae8070fb8363 Merged-In: I77a3efca2cd644f9828db1ed5d3cae8070fb8363
Diffstat (limited to 'services')
-rw-r--r--services/core/Android.bp1
-rw-r--r--services/core/java/com/android/server/ConnectivityService.java2
-rw-r--r--services/core/java/com/android/server/connectivity/ConnectivityResources.java83
3 files changed, 1 insertions, 85 deletions
diff --git a/services/core/Android.bp b/services/core/Android.bp
index f91e69240605..c40afbfe4f97 100644
--- a/services/core/Android.bp
+++ b/services/core/Android.bp
@@ -209,7 +209,6 @@ filegroup {
"java/com/android/server/TestNetworkService.java",
"java/com/android/server/connectivity/AutodestructReference.java",
"java/com/android/server/connectivity/ConnectivityConstants.java",
- "java/com/android/server/connectivity/ConnectivityResources.java",
"java/com/android/server/connectivity/DnsManager.java",
"java/com/android/server/connectivity/KeepaliveTracker.java",
"java/com/android/server/connectivity/LingerMonitor.java",
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 4ac249aa8d31..f63bf6271237 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -165,6 +165,7 @@ import android.net.UnderlyingNetworkInfo;
import android.net.Uri;
import android.net.VpnManager;
import android.net.VpnTransportInfo;
+import android.net.ConnectivityResources;
import android.net.metrics.IpConnectivityLog;
import android.net.metrics.NetworkEvent;
import android.net.netlink.InetDiagMessage;
@@ -223,7 +224,6 @@ import com.android.net.module.util.LocationPermissionChecker;
import com.android.net.module.util.NetworkCapabilitiesUtils;
import com.android.net.module.util.PermissionUtils;
import com.android.server.connectivity.AutodestructReference;
-import com.android.server.connectivity.ConnectivityResources;
import com.android.server.connectivity.DnsManager;
import com.android.server.connectivity.DnsManager.PrivateDnsValidationUpdate;
import com.android.server.connectivity.KeepaliveTracker;
diff --git a/services/core/java/com/android/server/connectivity/ConnectivityResources.java b/services/core/java/com/android/server/connectivity/ConnectivityResources.java
deleted file mode 100644
index 45cf21e035ca..000000000000
--- a/services/core/java/com/android/server/connectivity/ConnectivityResources.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.server.connectivity;
-
-import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.content.res.Resources;
-import android.util.Log;
-
-import com.android.server.ConnectivityService;
-
-import java.util.List;
-
-/**
- * Utility to obtain the {@link ConnectivityService} {@link Resources}, in the
- * ServiceConnectivityResources APK.
- */
-public class ConnectivityResources {
- private static final String RESOURCES_APK_INTENT =
- "com.android.server.connectivity.intent.action.SERVICE_CONNECTIVITY_RESOURCES_APK";
- private static final String RES_PKG_DIR = "/apex/com.android.tethering/";
-
- @NonNull
- private final Context mContext;
-
- @Nullable
- private Resources mResources = null;
-
- public ConnectivityResources(Context context) {
- mContext = context;
- }
-
- /**
- * Get the {@link Resources} of the ServiceConnectivityResources APK.
- */
- public synchronized Resources get() {
- if (mResources != null) {
- return mResources;
- }
-
- final List<ResolveInfo> pkgs = mContext.getPackageManager()
- .queryIntentActivities(new Intent(RESOURCES_APK_INTENT), MATCH_SYSTEM_ONLY);
- pkgs.removeIf(pkg -> !pkg.activityInfo.applicationInfo.sourceDir.startsWith(RES_PKG_DIR));
- if (pkgs.size() > 1) {
- Log.wtf(ConnectivityResources.class.getSimpleName(),
- "More than one package found: " + pkgs);
- }
- if (pkgs.isEmpty()) {
- throw new IllegalStateException("No connectivity resource package found");
- }
-
- final Context pkgContext;
- try {
- pkgContext = mContext.createPackageContext(
- pkgs.get(0).activityInfo.applicationInfo.packageName, 0 /* flags */);
- } catch (PackageManager.NameNotFoundException e) {
- throw new IllegalStateException("Resolved package not found", e);
- }
-
- mResources = pkgContext.getResources();
- return mResources;
- }
-}