From bdd94d9979e28c39539e25fbb98621df3cbe86f2 Mon Sep 17 00:00:00 2001 From: Calin Juravle Date: Thu, 17 May 2018 01:23:15 -0700 Subject: [PATCH] Allow adb to pull profile snapshots The snapshot profile produced with `adb cmd package snapshot-profile` needs to be readable by the others group so that adb can pull it. Test: adb shell cmd package snapshot-profile pkg; adb pull /data/misc/profman/pkg.prof Bug: 74081010 Change-Id: Ibef8551704116e0b695f725e95f1671acbb82b5d --- .../com/android/server/pm/PackageManagerShellCommand.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java index 01f84c44498bd..cd9efdcf8224b 100644 --- a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java +++ b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java @@ -78,6 +78,8 @@ import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserManager; import android.os.storage.StorageManager; +import android.system.ErrnoException; +import android.system.Os; import android.text.TextUtils; import android.text.format.DateUtils; import android.util.ArraySet; @@ -1373,7 +1375,9 @@ class PackageManagerShellCommand extends ShellCommand { try (OutputStream outStream = new FileOutputStream(outputProfilePath)) { Streams.copy(inStream, outStream); } - } catch (IOException e) { + // Give read permissions to the other group. + Os.chmod(outputProfilePath, /*mode*/ 0644 ); + } catch (IOException | ErrnoException e) { pw.println("Error when reading the profile fd: " + e.getMessage()); e.printStackTrace(pw); return -1;