Android 6.0上的Android文件权限

Android 6.0上的Android文件权限,android,linux,file,file-permissions,android-shell,Android,Linux,File,File Permissions,Android Shell,我想在Android中列出“/proc”下的文件和目录。当作为我的应用程序进程运行时,许多文件是不可读的 如果我将目录列为shell用户,我将得到以下输出: shell@flounder:/ $ whoami shell shell@flounder:/ $ /system/bin/toolbox ls -l /proc dr-xr-xr-x root root 2015-09-12 03:30 1 dr-xr-xr-x root root

我想在Android中列出
“/proc”
下的文件和目录。当作为我的应用程序进程运行时,许多文件是不可读的


如果我将目录列为
shell
用户,我将得到以下输出:

shell@flounder:/ $ whoami
shell
shell@flounder:/ $ /system/bin/toolbox ls -l /proc
dr-xr-xr-x root     root              2015-09-12 03:30 1
dr-xr-xr-x root     root              2015-09-12 03:31 10
dr-xr-xr-x root     root              2015-09-12 03:31 101
dr-xr-xr-x shell    shell             2015-09-15 03:24 10196
dr-xr-xr-x root     root              2015-09-12 03:31 102
dr-xr-xr-x root     root              2015-09-12 03:31 103
dr-xr-xr-x root     root              2015-09-12 03:31 104
dr-xr-xr-x u0_a15   u0_a15            2015-09-14 07:37 10451
dr-xr-xr-x root     root              2015-09-12 03:31 105
dr-xr-xr-x wifi     wifi              2015-09-14 08:53 10570
dr-xr-xr-x root     root              2015-09-12 03:31 106
dr-xr-xr-x root     root              2015-09-12 03:31 107
dr-xr-xr-x root     root              2015-09-12 03:31 108
dr-xr-xr-x root     root              2015-09-12 03:31 11
dr-xr-xr-x root     root              2015-09-12 03:31 110
dr-xr-xr-x root     root              2015-09-12 03:31 111
dr-xr-xr-x root     root              2015-09-12 03:31 112
dr-xr-xr-x root     root              2015-09-12 03:31 113
dr-xr-xr-x root     root              2015-09-12 03:31 114
dr-xr-xr-x root     root              2015-09-12 03:31 115
dr-xr-xr-x root     root              2015-09-12 03:31 116
dr-xr-xr-x root     root              2015-09-12 03:31 117
dr-xr-xr-x root     root              2015-09-12 03:31 118
dr-xr-xr-x root     root              2015-09-12 03:31 119
dr-xr-xr-x u0_a26   u0_a26            2015-09-12 03:31 1193
dr-xr-xr-x root     root              2015-09-12 03:31 12
dr-xr-xr-x root     root              2015-09-12 03:31 120
dr-xr-xr-x u0_a57   u0_a57            2015-09-12 03:31 1209
dr-xr-xr-x root     root              2015-09-12 03:31 121
dr-xr-xr-x root     root              2015-09-12 03:31 122
dr-xr-xr-x nfc      nfc               2015-09-12 03:31 1227
dr-xr-xr-x root     root              2015-09-12 03:31 123
dr-xr-xr-x radio    radio             2015-09-12 03:31 1239
dr-xr-xr-x root     root              2015-09-12 03:31 124
dr-xr-xr-x u0_a26   u0_a26            2015-09-12 03:31 1246
dr-xr-xr-x root     root              2015-09-12 03:31 125
dr-xr-xr-x root     root              2015-09-12 03:31 126
dr-xr-xr-x root     root              2015-09-12 03:31 127
dr-xr-xr-x root     root              2015-09-12 03:30 128
dr-xr-xr-x root     root              2015-09-12 03:31 13
dr-xr-xr-x u0_a26   u0_a26            2015-09-12 03:31 1305
dr-xr-xr-x root     root              2015-09-12 03:30 132
dr-xr-xr-x root     root              2015-09-12 03:31 134
dr-xr-xr-x u0_a86   u0_a86            2015-09-14 07:16 1343
dr-xr-xr-x root     root              2015-09-12 03:31 135
dr-xr-xr-x root     root              2015-09-12 03:31 136
dr-xr-xr-x root     root              2015-09-12 03:31 137
dr-xr-xr-x root     root              2015-09-12 03:31 138
dr-xr-xr-x root     root              2015-09-12 03:31 139
dr-xr-xr-x root     root              2015-09-12 03:31 14
dr-xr-xr-x root     root              2015-09-12 03:31 140
dr-xr-xr-x root     root              2015-09-12 03:31 141
dr-xr-xr-x root     root              2015-09-12 03:31 142
dr-xr-xr-x root     root              2015-09-12 03:31 143
dr-xr-xr-x root     root              2015-09-12 03:31 144
dr-xr-xr-x root     root              2015-09-12 03:31 145
dr-xr-xr-x root     root              2015-09-12 03:31 149
dr-xr-xr-x root     root              2015-09-12 03:31 150
dr-xr-xr-x logd     logd              2015-09-12 03:30 153
dr-xr-xr-x root     root              2015-09-12 03:30 155
dr-xr-xr-x root     root              2015-09-12 03:31 16
dr-xr-xr-x root     root              2015-09-12 03:31 160
dr-xr-xr-x root     root              2015-09-12 03:30 163
dr-xr-xr-x root     root              2015-09-12 03:30 164
dr-xr-xr-x system   system            2015-09-12 03:30 165
dr-xr-xr-x u0_a9    u0_a9             2015-09-12 03:31 1652
dr-xr-xr-x system   graphics          2015-09-12 03:30 166
dr-xr-xr-x root     root              2015-09-12 03:31 17
dr-xr-xr-x system   system            2015-09-14 05:30 18227
dr-xr-xr-x root     root              2015-09-12 03:31 188
dr-xr-xr-x root     root              2015-09-12 03:31 192
dr-xr-xr-x root     root              2015-09-12 03:31 193
dr-xr-xr-x root     root              2015-09-12 03:31 194
dr-xr-xr-x root     root              2015-09-12 03:31 195
dr-xr-xr-x root     root              2015-09-12 03:31 2
dr-xr-xr-x root     root              2015-09-12 03:31 20
dr-xr-xr-x u0_a19   u0_a19            2015-09-14 05:36 20564
dr-xr-xr-x root     root              2015-09-12 03:31 207
dr-xr-xr-x u0_a45   u0_a45            2015-09-15 03:00 20763
dr-xr-xr-x root     root              2015-09-12 03:31 208
dr-xr-xr-x root     root              2015-09-12 03:31 21
dr-xr-xr-x shell    shell             2015-09-12 03:31 210
dr-xr-xr-x root     root              2015-09-12 03:31 215
dr-xr-xr-x root     root              2015-09-12 03:31 216
dr-xr-xr-x root     root              2015-09-12 03:31 217
dr-xr-xr-x drm      drm               2015-09-12 03:31 218
dr-xr-xr-x media    audio             2015-09-12 03:31 219
dr-xr-xr-x root     root              2015-09-12 03:31 22
dr-xr-xr-x root     root              2015-09-12 03:31 220
dr-xr-xr-x keystore keystore          2015-09-12 03:31 222
dr-xr-xr-x system   system            2015-09-12 03:31 223
dr-xr-xr-x root     root              2015-09-12 03:31 224
dr-xr-xr-x root     root              2015-09-12 03:31 225
dr-xr-xr-x shell    shell             2015-09-15 03:15 2258
dr-xr-xr-x system   root              2015-09-12 03:31 226
dr-xr-xr-x gps      system            2015-09-12 03:31 227
dr-xr-xr-x u0_a67   u0_a67            2015-09-15 03:15 2270
dr-xr-xr-x root     root              2015-09-12 03:31 23
dr-xr-xr-x root     root              2015-09-12 03:31 24
dr-xr-xr-x root     root              2015-09-12 03:31 2428
dr-xr-xr-x root     root              2015-09-15 03:05 24353
dr-xr-xr-x root     root              2015-09-12 03:31 25
dr-xr-xr-x root     root              2015-09-15 03:11 25597
dr-xr-xr-x root     root              2015-09-12 03:31 26
dr-xr-xr-x root     root              2015-09-15 03:11 26671
dr-xr-xr-x root     root              2015-09-12 03:31 27
dr-xr-xr-x u0_a84   u0_a84            2015-09-15 03:15 2738
dr-xr-xr-x root     root              2015-09-12 03:31 28
dr-xr-xr-x root     root              2015-09-12 03:31 29
dr-xr-xr-x root     root              2015-09-15 03:11 29355
dr-xr-xr-x root     root              2015-09-15 03:16 2958
dr-xr-xr-x root     root              2015-09-12 03:31 3
dr-xr-xr-x root     root              2015-09-12 03:31 30
dr-xr-xr-x u0_a5    u0_a5             2015-09-15 03:10 30095
dr-xr-xr-x u0_a18   u0_a18            2015-09-15 03:11 30266
dr-xr-xr-x u0_a40   u0_a40            2015-09-15 03:11 30290
dr-xr-xr-x system   system            2015-09-15 03:11 30333
dr-xr-xr-x u0_a37   u0_a37            2015-09-15 03:11 30382
dr-xr-xr-x u0_a77   u0_a77            2015-09-15 03:11 30420
dr-xr-xr-x u0_a61   u0_a61            2015-09-15 03:11 30458
dr-xr-xr-x root     root              2015-09-14 09:56 30729
dr-xr-xr-x u0_a4    u0_a4             2015-09-14 11:12 30994
dr-xr-xr-x root     root              2015-09-12 03:31 31
dr-xr-xr-x u0_a9    u0_a9             2015-09-14 13:31 31453
dr-xr-xr-x shell    shell             2015-09-15 03:12 31844
dr-xr-xr-x root     root              2015-09-12 03:31 32
dr-xr-xr-x u0_a6    u0_a6             2015-09-15 01:13 32176
dr-xr-xr-x root     root              2015-09-15 02:34 32422
dr-xr-xr-x root     root              2015-09-15 03:13 32476
dr-xr-xr-x shell    shell             2015-09-15 02:39 32552
dr-xr-xr-x root     root              2015-09-12 03:31 33
dr-xr-xr-x root     root              2015-09-12 03:31 47
dr-xr-xr-x root     root              2015-09-12 03:31 48
dr-xr-xr-x root     root              2015-09-12 03:31 49
dr-xr-xr-x root     root              2015-09-12 03:31 5
dr-xr-xr-x root     root              2015-09-12 03:31 50
dr-xr-xr-x system   system            2015-09-12 03:31 590
dr-xr-xr-x root     root              2015-09-12 03:31 64
dr-xr-xr-x root     root              2015-09-12 03:31 65
dr-xr-xr-x root     root              2015-09-12 03:31 66
dr-xr-xr-x media_rw media_rw          2015-09-12 03:31 666
dr-xr-xr-x root     root              2015-09-12 03:31 67
dr-xr-xr-x root     root              2015-09-12 03:31 68
dr-xr-xr-x root     root              2015-09-12 03:31 69
dr-xr-xr-x u0_a24   u0_a24            2015-09-12 03:31 694
dr-xr-xr-x root     root              2015-09-12 03:31 7
dr-xr-xr-x root     root              2015-09-12 03:31 70
dr-xr-xr-x root     root              2015-09-12 03:31 71
dr-xr-xr-x u0_a88   u0_a88            2015-09-14 06:14 7104
dr-xr-xr-x root     root              2015-09-12 03:31 72
dr-xr-xr-x u0_a88   u0_a88            2015-09-14 06:15 7217
dr-xr-xr-x root     root              2015-09-15 03:21 7221
dr-xr-xr-x root     root              2015-09-12 03:31 73
dr-xr-xr-x root     root              2015-09-12 03:31 74
dr-xr-xr-x root     root              2015-09-15 03:21 7487
dr-xr-xr-x root     root              2015-09-12 03:31 75
dr-xr-xr-x root     root              2015-09-12 03:31 76
dr-xr-xr-x root     root              2015-09-12 03:31 77
dr-xr-xr-x root     root              2015-09-12 03:31 78
dr-xr-xr-x root     root              2015-09-12 03:31 79
dr-xr-xr-x root     root              2015-09-12 03:31 8
dr-xr-xr-x root     root              2015-09-12 03:31 81
dr-xr-xr-x root     root              2015-09-12 03:31 82
dr-xr-xr-x u0_a14   u0_a14            2015-09-15 02:45 8250
dr-xr-xr-x root     root              2015-09-12 03:31 83
dr-xr-xr-x root     root              2015-09-12 03:31 84
dr-xr-xr-x root     root              2015-09-12 03:31 85
dr-xr-xr-x u0_a53   u0_a53            2015-09-13 11:39 8517
dr-xr-xr-x root     root              2015-09-12 03:31 87
dr-xr-xr-x root     root              2015-09-12 03:31 88
dr-xr-xr-x root     root              2015-09-12 03:31 89
dr-xr-xr-x root     root              2015-09-12 03:31 9
dr-xr-xr-x root     root              2015-09-12 03:31 90
dr-xr-xr-x u0_a9    u0_a9             2015-09-12 03:31 903
dr-xr-xr-x root     root              2015-09-12 03:31 91
dr-xr-xr-x u0_a9    u0_a9             2015-09-13 11:45 9159
dr-xr-xr-x root     root              2015-09-12 03:31 93
dr-xr-xr-x u0_a66   u0_a66            2015-09-14 08:52 9356
dr-xr-xr-x root     root              2015-09-12 03:31 94
dr-xr-xr-x root     root              2015-09-12 03:31 95
dr-xr-xr-x root     root              2015-09-12 03:31 97
dr-xr-xr-x root     root              2015-09-12 03:31 98
dr-xr-xr-x root     root              2015-09-12 03:31 99
dr-xr-xr-x root     root              2015-09-15 03:24 asound
dr-xr-xr-x root     root              2015-09-15 03:24 bluetooth
-r--r--r-- root     root            0 2015-09-15 03:24 buddyinfo
dr-xr-xr-x root     root              2015-09-15 03:24 bus
-r--r--r-- root     root            0 2015-09-15 03:24 cgroups
-r--r----- root     radio           0 2015-09-15 03:24 cmdline
-r--r--r-- root     root            0 2015-09-15 03:24 consoles
-r--r--r-- root     root            0 2015-09-15 03:24 cpuinfo
-r--r--r-- root     root            0 2015-09-15 03:24 crypto
dr-xr-xr-x root     root              2015-09-15 03:24 device-tree
-r--r--r-- root     root            0 2015-09-15 03:24 devices
-r--r--r-- root     root            0 2015-09-15 03:24 diskstats
dr-xr-xr-x root     root              2015-09-15 03:24 driver
-r--r--r-- root     root            0 2015-09-15 03:24 execdomains
-r--r--r-- root     root            0 2015-09-15 03:24 fb
-r--r--r-- root     root            0 2015-09-15 03:24 filesystems
dr-xr-xr-x root     root              2015-09-15 03:24 fs
-r--r--r-- root     root            0 2015-09-15 03:24 interrupts
-r--r--r-- root     root            0 2015-09-15 03:24 iomem
-r--r--r-- root     root            0 2015-09-15 03:24 ioports
dr-xr-xr-x root     root              2015-09-15 03:24 irq
-r--r--r-- root     root            0 2015-09-15 03:24 kallsyms
-r--r----- root     system          0 2015-09-12 03:30 kmsg
-r-------- root     root            0 2015-09-15 03:24 kpagecount
-r-------- root     root            0 2015-09-15 03:24 kpageflags
-r--r--r-- root     root            0 2015-09-15 03:24 loadavg
-r--r--r-- root     root            0 2015-09-15 03:24 locks
-r--r--r-- root     root            0 2015-09-15 03:24 meminfo
-r--r--r-- root     root            0 2015-09-15 03:24 misc
lrwxrwxrwx root     root              2015-09-15 03:24 mounts -> self/mounts
lrwxrwxrwx root     root              2015-09-15 03:24 net -> self/net
-r--r--r-- root     root            0 2015-09-15 03:24 pagetypeinfo
-r--r--r-- root     root            0 2015-09-15 03:24 partitions
dr-xr-xr-x root     root              2015-09-15 03:24 quadd
-r--r--r-- root     root            0 2015-09-15 03:24 sched_debug
-r--r--r-- root     root            0 2015-09-15 03:24 schedstat
dr-xr-xr-x root     root              2015-09-15 03:24 scsi
lrwxrwxrwx root     root              1969-12-31 16:00 self -> 10196
-r--r----- root     log             0 2015-09-15 03:24 slabinfo
-r--r--r-- root     root            0 2015-09-15 03:24 softirqs
-r--r--r-- root     root            0 2015-09-15 03:24 stat
-r--r--r-- root     root            0 2015-09-15 03:24 swaps
dr-xr-xr-x root     root              2015-09-14 06:13 sys
lstat '/proc/sysrq-trigger' failed: Permission denied
dr-xr-xr-x root     root              2015-09-15 03:24 sysvipc
-r--r--r-- root     root            0 2015-09-15 03:24 timer_list
-rw-r--r-- root     root            0 2015-09-15 03:24 timer_stats
dr-xr-xr-x root     root              2015-09-15 03:24 tty
dr-xr-xr-x root     root              2015-09-15 03:24 uid_cputime
dr-xr-xr-x root     root              2015-09-15 03:24 uid_stat
-r--r--r-- root     root            0 2015-09-15 03:24 uptime
-r--r--r-- root     root            0 2015-09-15 03:24 version
-r--r----- root     log             0 2015-09-15 03:24 vmallocinfo
-r--r--r-- root     root            0 2015-09-15 03:24 vmstat
-r--r--r-- root     root            0 2015-09-15 03:24 zoneinfo
如果我将目录列为我的应用程序进程(使用
作为[PACKAGE\u NAME]
运行):

显然,我在上收到“权限被拒绝”错误的文件不能使用
newjava.io.File(“/proc”).listFiles()读取任意一个


我的问题:
为什么我的应用程序进程不能读取这些目录?这些权限授予“其他”用户读取权限(“dr-xr-xr-x”)。

Android 5及以上版本使用SELinux,它使用两种形式的访问控制。传统的Linux使用自主访问控制列表。SE组件还强制执行强制访问控制列表。前者是默认允许,后者是默认拒绝

只有在两组权限都允许的情况下,您或进程才能访问对象。访问由SE上下文决定。Shell和应用程序上下文具有不同的权限,不幸的是,没有任何已知的方法来提供应用程序Shell上下文

您可以使用以下方式查看安全上下文:

ls -Z
我没有要测试的棉花糖设备,但是要给你的应用程序提供必要的上下文,需要获得usagestatsmanager的许可。用户必须启用it安全设置,我被告知三星设备没有必要的菜单。在黑暗中拍摄你的心灵

如果您想尝试,请参见以下问题:


此页面可能会为您提供有关权限的更多信息:

@Jared,无法按照您在另一篇文章中的建议,通过排序OOM分数来可靠地估计前台应用程序。到目前为止,基于此方法的前台应用程序检测正在三星Galaxy S4、三星Galaxy Note、华硕Zenfone上运行,而不是在HTC one 8上运行,索尼ExperiaI也有同样的问题,是否已解决?我也有同样的问题,使用su nibary 777模式创建图像,但使用adb shell,它显示了同样的错误(拒绝许可)@兰斯,你有什么线索吗?同样的问题现在摆在我面前。
ls -Z