Loading core/java/android/os/FileUtils.java +10 −0 Original line number Diff line number Diff line Loading @@ -316,6 +316,16 @@ public class FileUtils { stringToFile(file.getAbsolutePath(), string); } /* * Writes the bytes given in {@code content} to the file whose absolute path * is {@code filename}. */ public static void bytesToFile(String filename, byte[] content) throws IOException { try (FileOutputStream fos = new FileOutputStream(filename)) { fos.write(content); } } /** * Writes string to file. Basically same as "echo -n $string > $filename" * Loading services/core/java/com/android/server/pm/Settings.java +4 −1 Original line number Diff line number Diff line Loading @@ -2470,7 +2470,10 @@ final class Settings { final File file = new File(dir, "appid"); try { FileUtils.stringToFile(file, Integer.toString(ps.appId)); // Note that the use of US_ASCII here is safe, we're only writing a decimal // number to the file. FileUtils.bytesToFile(file.getAbsolutePath(), Integer.toString(ps.appId).getBytes(StandardCharsets.US_ASCII)); mKernelMapping.put(ps.name, ps.appId); } catch (IOException ignored) { } Loading Loading
core/java/android/os/FileUtils.java +10 −0 Original line number Diff line number Diff line Loading @@ -316,6 +316,16 @@ public class FileUtils { stringToFile(file.getAbsolutePath(), string); } /* * Writes the bytes given in {@code content} to the file whose absolute path * is {@code filename}. */ public static void bytesToFile(String filename, byte[] content) throws IOException { try (FileOutputStream fos = new FileOutputStream(filename)) { fos.write(content); } } /** * Writes string to file. Basically same as "echo -n $string > $filename" * Loading
services/core/java/com/android/server/pm/Settings.java +4 −1 Original line number Diff line number Diff line Loading @@ -2470,7 +2470,10 @@ final class Settings { final File file = new File(dir, "appid"); try { FileUtils.stringToFile(file, Integer.toString(ps.appId)); // Note that the use of US_ASCII here is safe, we're only writing a decimal // number to the file. FileUtils.bytesToFile(file.getAbsolutePath(), Integer.toString(ps.appId).getBytes(StandardCharsets.US_ASCII)); mKernelMapping.put(ps.name, ps.appId); } catch (IOException ignored) { } Loading