diff options
| author | 2023-10-16 13:34:16 +0200 | |
|---|---|---|
| committer | 2025-02-03 01:19:16 -0800 | |
| commit | 541da82c3929af3d2f473b10e54bfc4e5a859485 (patch) | |
| tree | a26fb44886b69c4d665aa7b5d966ac81bdecd136 | |
| parent | c9c97bec35c821735f25777f943107c105f619f0 (diff) | |
Change file permissions for shutdown files
Make the shutdown-checkpoints files readable for platform apps.
Test: Check that shutdown-checkpoint file is created with correct
permission
1 Generate a new shutdown-checkpoint file
This can be done by a reboot from the device power menu
PS "adb reboot" does not generate a shutdown-checkpoint file
2 Check the permissions with adb
$ adb shell ls -laZ /data/system/shutdown-checkpoints | grep shutdown_checkpoints
drwxr-xr-x 2 system system u:object_r:shutdown_checkpoints_system_data_file:s0 3452 2023-10-19 10:21 .
-rw-r--r-- 1 system system u:object_r:shutdown_checkpoints_system_data_file:s0 1307 2023-10-19 10:21 checkpoints-1697703667771
3 Check that the shutdown-checkpoint dir permission is "drwxr-xr-x"
4 Check that a new shutdown-checkpoint file has been created with
the permission "-rw-r--r--"
Bug: 306198106
Change-Id: I1639d59f1eb41063c5ac4898738a9f8f5c882028
| -rw-r--r-- | services/core/java/com/android/server/power/ShutdownCheckPoints.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/power/ShutdownCheckPoints.java b/services/core/java/com/android/server/power/ShutdownCheckPoints.java index dafaa7d5f134..399e214aa955 100644 --- a/services/core/java/com/android/server/power/ShutdownCheckPoints.java +++ b/services/core/java/com/android/server/power/ShutdownCheckPoints.java @@ -350,17 +350,23 @@ public final class ShutdownCheckPoints { private final ShutdownCheckPoints mInstance; private final File mBaseFile; + private final File mBaseDir; private final int mFileCountLimit; FileDumperThread(ShutdownCheckPoints instance, File baseFile, int fileCountLimit) { mInstance = instance; mBaseFile = baseFile; + mBaseDir = baseFile.getParentFile(); mFileCountLimit = fileCountLimit; } @Override public void run() { - mBaseFile.getParentFile().mkdirs(); + if (!mBaseDir.exists()) { + mBaseDir.mkdirs(); + mBaseDir.setExecutable(true, false); + mBaseDir.setReadable(true, false); + } File[] checkPointFiles = listCheckPointsFiles(); int filesToDelete = checkPointFiles.length - mFileCountLimit + 1; @@ -375,7 +381,7 @@ public final class ShutdownCheckPoints { private File[] listCheckPointsFiles() { String filePrefix = mBaseFile.getName() + "-"; - File[] files = mBaseFile.getParentFile().listFiles(new FilenameFilter() { + File[] files = mBaseDir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { if (!name.startsWith(filePrefix)) { @@ -412,6 +418,7 @@ public final class ShutdownCheckPoints { } } mBaseFile.renameTo(file); + file.setReadable(true, false); } } } |