Loading services/core/java/com/android/server/pm/Settings.java +49 −43 Original line number Diff line number Diff line Loading @@ -3229,31 +3229,43 @@ public final class Settings { } } // Read preferred apps from .../etc/preferred-apps directory. File preferredDir = new File(Environment.getRootDirectory(), "etc/preferred-apps"); // Read preferred apps from .../etc/preferred-apps directories. int size = PackageManagerService.SYSTEM_PARTITIONS.size(); for (int index = 0; index < size; index++) { PackageManagerService.ScanPartition partition = PackageManagerService.SYSTEM_PARTITIONS.get(index); File preferredDir = new File(partition.folder, "etc/preferred-apps"); if (!preferredDir.exists() || !preferredDir.isDirectory()) { return; continue; } if (!preferredDir.canRead()) { Slog.w(TAG, "Directory " + preferredDir + " cannot be read"); return; continue; } // Iterate over the files in the directory and scan .xml files for (File f : preferredDir.listFiles()) { File[] files = preferredDir.listFiles(); if (ArrayUtils.isEmpty(files)) { continue; } for (File f : files) { if (!f.getPath().endsWith(".xml")) { Slog.i(TAG, "Non-xml file " + f + " in " + preferredDir + " directory, ignoring"); Slog.i(TAG, "Non-xml file " + f + " in " + preferredDir + " directory, ignoring"); continue; } if (!f.canRead()) { Slog.w(TAG, "Preferred apps file " + f + " cannot be read"); continue; } if (PackageManagerService.DEBUG_PREFERRED) { Log.d(TAG, "Reading default preferred " + f); } if (PackageManagerService.DEBUG_PREFERRED) Log.d(TAG, "Reading default preferred " + f); InputStream str = null; try { str = new BufferedInputStream(new FileInputStream(f)); try (InputStream str = new BufferedInputStream(new FileInputStream(f))) { XmlPullParser parser = Xml.newPullParser(); parser.setInput(str, null); Loading @@ -3277,12 +3289,6 @@ public final class Settings { Slog.w(TAG, "Error reading apps file " + f, e); } catch (IOException e) { Slog.w(TAG, "Error reading apps file " + f, e); } finally { if (str != null) { try { str.close(); } catch (IOException e) { } } } } Loading Loading
services/core/java/com/android/server/pm/Settings.java +49 −43 Original line number Diff line number Diff line Loading @@ -3229,31 +3229,43 @@ public final class Settings { } } // Read preferred apps from .../etc/preferred-apps directory. File preferredDir = new File(Environment.getRootDirectory(), "etc/preferred-apps"); // Read preferred apps from .../etc/preferred-apps directories. int size = PackageManagerService.SYSTEM_PARTITIONS.size(); for (int index = 0; index < size; index++) { PackageManagerService.ScanPartition partition = PackageManagerService.SYSTEM_PARTITIONS.get(index); File preferredDir = new File(partition.folder, "etc/preferred-apps"); if (!preferredDir.exists() || !preferredDir.isDirectory()) { return; continue; } if (!preferredDir.canRead()) { Slog.w(TAG, "Directory " + preferredDir + " cannot be read"); return; continue; } // Iterate over the files in the directory and scan .xml files for (File f : preferredDir.listFiles()) { File[] files = preferredDir.listFiles(); if (ArrayUtils.isEmpty(files)) { continue; } for (File f : files) { if (!f.getPath().endsWith(".xml")) { Slog.i(TAG, "Non-xml file " + f + " in " + preferredDir + " directory, ignoring"); Slog.i(TAG, "Non-xml file " + f + " in " + preferredDir + " directory, ignoring"); continue; } if (!f.canRead()) { Slog.w(TAG, "Preferred apps file " + f + " cannot be read"); continue; } if (PackageManagerService.DEBUG_PREFERRED) { Log.d(TAG, "Reading default preferred " + f); } if (PackageManagerService.DEBUG_PREFERRED) Log.d(TAG, "Reading default preferred " + f); InputStream str = null; try { str = new BufferedInputStream(new FileInputStream(f)); try (InputStream str = new BufferedInputStream(new FileInputStream(f))) { XmlPullParser parser = Xml.newPullParser(); parser.setInput(str, null); Loading @@ -3277,12 +3289,6 @@ public final class Settings { Slog.w(TAG, "Error reading apps file " + f, e); } catch (IOException e) { Slog.w(TAG, "Error reading apps file " + f, e); } finally { if (str != null) { try { str.close(); } catch (IOException e) { } } } } Loading