Add resolvePkgPrefix() method
This is a no-op refactor change to create resolvePkgPrefix()
helper method to prevent code duplication for the follow up
commit.
Bug: 291870956
Test: atest NetworkStaticLibTests
Change-Id: I8deea97acdb793dfa076ce55f7f2c3eb0b224461
diff --git a/staticlibs/device/com/android/net/module/util/DeviceConfigUtils.java b/staticlibs/device/com/android/net/module/util/DeviceConfigUtils.java
index 138c1e5..e5c5d0d 100644
--- a/staticlibs/device/com/android/net/module/util/DeviceConfigUtils.java
+++ b/staticlibs/device/com/android/net/module/util/DeviceConfigUtils.java
@@ -224,14 +224,7 @@
// If that fails retry by appending "go.tethering" instead
private static long resolveTetheringModuleVersion(@NonNull Context context)
throws PackageManager.NameNotFoundException {
- final String connResourcesPackage = getConnectivityResourcesPackageName(context);
- final int pkgPrefixLen = connResourcesPackage.indexOf("connectivity");
- if (pkgPrefixLen < 0) {
- throw new IllegalStateException(
- "Invalid connectivity resources package: " + connResourcesPackage);
- }
-
- final String pkgPrefix = connResourcesPackage.substring(0, pkgPrefixLen);
+ final String pkgPrefix = resolvePkgPrefix(context);
final PackageManager packageManager = context.getPackageManager();
try {
return packageManager.getPackageInfo(pkgPrefix + "tethering",
@@ -245,6 +238,17 @@
PackageManager.MATCH_APEX).getLongVersionCode();
}
+ private static String resolvePkgPrefix(Context context) {
+ final String connResourcesPackage = getConnectivityResourcesPackageName(context);
+ final int pkgPrefixLen = connResourcesPackage.indexOf("connectivity");
+ if (pkgPrefixLen < 0) {
+ throw new IllegalStateException(
+ "Invalid connectivity resources package: " + connResourcesPackage);
+ }
+
+ return connResourcesPackage.substring(0, pkgPrefixLen);
+ }
+
private static volatile long sModuleVersion = -1;
private static long getTetheringModuleVersion(@NonNull Context context) {
if (sModuleVersion >= 0) return sModuleVersion;