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
This commit is contained in:
@@ -224,14 +224,7 @@ public final class DeviceConfigUtils {
|
|||||||
// If that fails retry by appending "go.tethering" instead
|
// If that fails retry by appending "go.tethering" instead
|
||||||
private static long resolveTetheringModuleVersion(@NonNull Context context)
|
private static long resolveTetheringModuleVersion(@NonNull Context context)
|
||||||
throws PackageManager.NameNotFoundException {
|
throws PackageManager.NameNotFoundException {
|
||||||
final String connResourcesPackage = getConnectivityResourcesPackageName(context);
|
final String pkgPrefix = resolvePkgPrefix(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 PackageManager packageManager = context.getPackageManager();
|
final PackageManager packageManager = context.getPackageManager();
|
||||||
try {
|
try {
|
||||||
return packageManager.getPackageInfo(pkgPrefix + "tethering",
|
return packageManager.getPackageInfo(pkgPrefix + "tethering",
|
||||||
@@ -245,6 +238,17 @@ public final class DeviceConfigUtils {
|
|||||||
PackageManager.MATCH_APEX).getLongVersionCode();
|
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 volatile long sModuleVersion = -1;
|
||||||
private static long getTetheringModuleVersion(@NonNull Context context) {
|
private static long getTetheringModuleVersion(@NonNull Context context) {
|
||||||
if (sModuleVersion >= 0) return sModuleVersion;
|
if (sModuleVersion >= 0) return sModuleVersion;
|
||||||
|
|||||||
Reference in New Issue
Block a user