ApkInfoParser.ApkInfo apkInfo = parser.parseApk(apkFile); if (!apkInfo.getPackageName().equals(mainPkgName)) { throw new RuntimeException("The main and the micro apps do not have the same package name."); " <rawPathResId>%4$s</rawPathResId>\n" + "</wearableApp>", apkInfo.getPackageName(), apkInfo.getVersionCode(), apkInfo.getVersionName(), resName);
/** * Parses the aapt output and returns an ApkInfo object. * @param aaptOutput the aapt output as a list of lines. * @return an ApkInfo object. */ @VisibleForTesting @NonNull static ApkInfo getApkInfo(@NonNull List<String> aaptOutput) { String pkgName = null, versionCode = null, versionName = null; for (String line : aaptOutput) { Matcher m = PATTERN.matcher(line); if (m.matches()) { pkgName = m.group(1); versionCode = m.group(2); versionName = m.group(3); break; } } if (pkgName == null) { throw new RuntimeException("Failed to find apk information with aapt"); } Integer intVersionCode = null; try { intVersionCode = Integer.parseInt(versionCode); } catch(NumberFormatException ignore) { // leave the version code as null. } return new ApkInfo(pkgName, intVersionCode, versionName); }
ApkInfoParser.ApkInfo apkInfo = parser.parseApk(apkFile); if (!apkInfo.getPackageName().equals(mainPkgName)) { throw new RuntimeException("The main and the micro apps do not have the same package name."); " <rawPathResId>%4$s</rawPathResId>\n" + "</wearableApp>", apkInfo.getPackageName(), apkInfo.getVersionCode(), apkInfo.getVersionName(), resName);
/** * Parses the aapt output and returns an ApkInfo object. * @param aaptOutput the aapt output as a list of lines. * @return an ApkInfo object. */ @VisibleForTesting @NonNull static ApkInfo getApkInfo(@NonNull List<String> aaptOutput) { String pkgName = null, versionCode = null, versionName = null; for (String line : aaptOutput) { Matcher m = PATTERN.matcher(line); if (m.matches()) { pkgName = m.group(1); versionCode = m.group(2); versionName = m.group(3); break; } } if (pkgName == null) { throw new RuntimeException("Failed to find apk information with aapt"); } Integer intVersionCode = null; try { intVersionCode = Integer.parseInt(versionCode); } catch(NumberFormatException ignore) { // leave the version code as null. } return new ApkInfo(pkgName, intVersionCode, versionName); }
@Nullable @Override public String getTestedApplicationId() { ApkInfoParser.ApkInfo apkInfo = loadTestedApkInfo(); return apkInfo.getPackageName(); }
@Nullable @Override public String getTestedApplicationId() { ApkInfoParser.ApkInfo apkInfo = loadTestedApkInfo(); return apkInfo.getPackageName(); }