Loading services/core/java/com/android/server/pm/OtaDexoptService.java +45 −36 Original line number Original line Diff line number Diff line Loading @@ -274,23 +274,56 @@ public class OtaDexoptService extends IOtaDexopt.Stub { // Intercept and collect dexopt requests // Intercept and collect dexopt requests final List<String> commands = new ArrayList<String>(); final List<String> commands = new ArrayList<String>(); final Installer collectingInstaller = new Installer(mContext, true) { final Installer collectingInstaller = new Installer(mContext, true) { /** * Encode the dexopt command into a string. * * Note: If you have to change the signature of this function, increase the version * number, and update the counterpart in * frameworks/native/cmds/installd/otapreopt.cpp. */ @Override @Override public void dexopt(String apkPath, int uid, @Nullable String pkgName, public void dexopt(String apkPath, int uid, @Nullable String pkgName, String instructionSet, int dexoptNeeded, @Nullable String outputPath, String instructionSet, int dexoptNeeded, @Nullable String outputPath, int dexFlags, String compilerFilter, @Nullable String volumeUuid, int dexFlags, String compilerFilter, @Nullable String volumeUuid, @Nullable String sharedLibraries, @Nullable String seInfo) throws InstallerException { @Nullable String sharedLibraries, @Nullable String seInfo) throws InstallerException { commands.add(buildCommand("dexopt", final StringBuilder builder = new StringBuilder(); apkPath, uid, // The version. Right now it's 2. pkgName, builder.append("2 "); instructionSet, dexoptNeeded, builder.append("dexopt"); outputPath, dexFlags, encodeParameter(builder, apkPath); compilerFilter, encodeParameter(builder, uid); volumeUuid, encodeParameter(builder, pkgName); sharedLibraries, encodeParameter(builder, instructionSet); seInfo)); encodeParameter(builder, dexoptNeeded); encodeParameter(builder, outputPath); encodeParameter(builder, dexFlags); encodeParameter(builder, compilerFilter); encodeParameter(builder, volumeUuid); encodeParameter(builder, sharedLibraries); encodeParameter(builder, seInfo); commands.add(builder.toString()); } /** * Encode a parameter as necessary for the commands string. */ private void encodeParameter(StringBuilder builder, Object arg) { builder.append(' '); if (arg == null) { builder.append('!'); } String txt = String.valueOf(arg); if (txt.indexOf('\0') != -1 || txt.indexOf(' ') != -1 || "!".equals(txt)) { throw new IllegalArgumentException( "Invalid argument while executing " + arg); } builder.append(txt); } } }; }; Loading Loading @@ -430,28 +463,4 @@ public class OtaDexoptService extends IOtaDexopt.Stub { super(installer, installLock, context, "*otadexopt*"); super(installer, installLock, context, "*otadexopt*"); } } } } /** * Cook up argument list in the format that {@code installd} expects. */ private static String buildCommand(Object... args) { final StringBuilder builder = new StringBuilder(); for (Object arg : args) { String escaped; if (arg == null) { escaped = ""; } else { escaped = String.valueOf(arg); } if (escaped.indexOf('\0') != -1 || escaped.indexOf(' ') != -1 || "!".equals(escaped)) { throw new IllegalArgumentException( "Invalid argument while executing " + Arrays.toString(args)); } if (TextUtils.isEmpty(escaped)) { escaped = "!"; } builder.append(' ').append(escaped); } return builder.toString(); } } } Loading
services/core/java/com/android/server/pm/OtaDexoptService.java +45 −36 Original line number Original line Diff line number Diff line Loading @@ -274,23 +274,56 @@ public class OtaDexoptService extends IOtaDexopt.Stub { // Intercept and collect dexopt requests // Intercept and collect dexopt requests final List<String> commands = new ArrayList<String>(); final List<String> commands = new ArrayList<String>(); final Installer collectingInstaller = new Installer(mContext, true) { final Installer collectingInstaller = new Installer(mContext, true) { /** * Encode the dexopt command into a string. * * Note: If you have to change the signature of this function, increase the version * number, and update the counterpart in * frameworks/native/cmds/installd/otapreopt.cpp. */ @Override @Override public void dexopt(String apkPath, int uid, @Nullable String pkgName, public void dexopt(String apkPath, int uid, @Nullable String pkgName, String instructionSet, int dexoptNeeded, @Nullable String outputPath, String instructionSet, int dexoptNeeded, @Nullable String outputPath, int dexFlags, String compilerFilter, @Nullable String volumeUuid, int dexFlags, String compilerFilter, @Nullable String volumeUuid, @Nullable String sharedLibraries, @Nullable String seInfo) throws InstallerException { @Nullable String sharedLibraries, @Nullable String seInfo) throws InstallerException { commands.add(buildCommand("dexopt", final StringBuilder builder = new StringBuilder(); apkPath, uid, // The version. Right now it's 2. pkgName, builder.append("2 "); instructionSet, dexoptNeeded, builder.append("dexopt"); outputPath, dexFlags, encodeParameter(builder, apkPath); compilerFilter, encodeParameter(builder, uid); volumeUuid, encodeParameter(builder, pkgName); sharedLibraries, encodeParameter(builder, instructionSet); seInfo)); encodeParameter(builder, dexoptNeeded); encodeParameter(builder, outputPath); encodeParameter(builder, dexFlags); encodeParameter(builder, compilerFilter); encodeParameter(builder, volumeUuid); encodeParameter(builder, sharedLibraries); encodeParameter(builder, seInfo); commands.add(builder.toString()); } /** * Encode a parameter as necessary for the commands string. */ private void encodeParameter(StringBuilder builder, Object arg) { builder.append(' '); if (arg == null) { builder.append('!'); } String txt = String.valueOf(arg); if (txt.indexOf('\0') != -1 || txt.indexOf(' ') != -1 || "!".equals(txt)) { throw new IllegalArgumentException( "Invalid argument while executing " + arg); } builder.append(txt); } } }; }; Loading Loading @@ -430,28 +463,4 @@ public class OtaDexoptService extends IOtaDexopt.Stub { super(installer, installLock, context, "*otadexopt*"); super(installer, installLock, context, "*otadexopt*"); } } } } /** * Cook up argument list in the format that {@code installd} expects. */ private static String buildCommand(Object... args) { final StringBuilder builder = new StringBuilder(); for (Object arg : args) { String escaped; if (arg == null) { escaped = ""; } else { escaped = String.valueOf(arg); } if (escaped.indexOf('\0') != -1 || escaped.indexOf(' ') != -1 || "!".equals(escaped)) { throw new IllegalArgumentException( "Invalid argument while executing " + Arrays.toString(args)); } if (TextUtils.isEmpty(escaped)) { escaped = "!"; } builder.append(' ').append(escaped); } return builder.toString(); } } }