申请的进程中没有加入对应的组ID
Corresponding group ID not added to the process of the application
adb 命令adb shell dumpsys package com.hackerli.girl
可以帮助我获取应用程序信息。
在我请求 android.permission.WRITE_EXTERNAL_STORAGE
权限之前,我的应用有一个 gids=[3003]
。
requested permissions:
android.permission.INTERNET
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.READ_EXTERNAL_STORAGE
android.permission.ACCESS_NETWORK_STATE
install permissions:
android.permission.INTERNET: granted=true
android.permission.ACCESS_NETWORK_STATE: granted=true
User 0: ceDataInode=1531967 installed=true hidden=false suspended=false stopped=true notLaunched=false enabled=0
gids=[3003]
runtime permissions:
User 999: ceDataInode=0 installed=false hidden=false suspended=false stopped=true notLaunched=true enabled=0
gids=[3003]
runtime permissions:
授予运行时权限android.permission.WRITE_EXTERNAL_STORAGE
后,我得到以下信息。
requested permissions:
android.permission.INTERNET
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.READ_EXTERNAL_STORAGE
android.permission.ACCESS_NETWORK_STATE
install permissions:
android.permission.INTERNET: granted=true
android.permission.ACCESS_NETWORK_STATE: granted=true
User 0: ceDataInode=1531967 installed=true hidden=false suspended=false stopped=false notLaunched=false enabled=0
gids=[3003]
runtime permissions:
android.permission.READ_EXTERNAL_STORAGE: granted=true
android.permission.WRITE_EXTERNAL_STORAGE: granted=true
User 999: ceDataInode=0 installed=false hidden=false suspended=false stopped=true notLaunched=true enabled=0
gids=[3003]
runtime permissions:
如您所见,READ_EXTERNAL_STORAGE
权限也被授予,因为它与 WRITE_EXTERNAL_STORAGE
属于同一组。 但是gids
没有改变。我认为它应该更新所以我有什么错误吗?
总结
android.permission.WRITE_EXTERNAL_STORAGE
现在 (> API 23) 作为 built-in android 权限实施,现在已被管理由运行时。早些时候(< API 23)权限是 low-level 内核 强制执行的权限组的一部分,实现为 Linux Supplementary Group,即通过将组分配给应用程序安装时间。
Marshmallow 之前的行为 (< API 23)
在 Marshmallow 之前(特别是在引入 Runtime Permission), the android.permission.WRITE_EXTERNAL_STORAGE
was implemented at kernel level. Whenever any process try to access the external storage, the call goes through the kernel (the open()
系统调用之前),内核检查调用进程的权限(通常 Linux 东西...)。对于 极客 这是 call-stack 的样子:
读一个File
you open a stream to it using the FileOutputStream
. When we construct a FileOutputStream
, this calls IOBridge.open(String, int)
. IOBridge
是一个内部的class并且把开头委托给nativeJNI-call.
在IOBridge.open()
call, the method delegates to Libcore.os.open()
. Again Libcore
里面是一个内部class。
Libcore.os.open()
is a native method, implemented here. And here, the method calls the open()
系统调用和内核kicks-in!
Marshmallow 开始的行为 (>= API 23)
从 Marshmallow 开始(引入 Runtime Permission),开发人员需要向用户索要 android.permission.WRITE_EXTERNAL_STORAGE
。这会更改将权限分配给应用程序的方式。 Android 仍然在 安装 时分配 正常 权限,但对于 危险 应用 Android 要求应用程序显示一个弹出窗口,要求获得许可。当用户授予权限时,PackageManager
记录它并将其添加到应用程序的数据库记录中(在 /data/system/packages.xml
中)。如果权限是 low-level 权限,即由 kernel 使用 groups 实现,则PackageManager
也将应用程序的用户 ID 添加到相应的组。
早些时候 android.permission.WRITE_EXTERNAL_STORAGE
被实现为 low-level 权限(因此由内核管理)但现在应用程序被实现为 built-in 权限由运行时管理。
call-stack 现在看起来像:
读一个File
you open a stream to it using the FileOutputStream
. When we construct a FileOutputStream
, which calls the private FileOutputStream.open()
native function implemented here.
由运行时实现的本机 FileOutputStream.open()
calls the helper fileOpen()
which delegates call to JVM_Open()
,因此运行时现在管理权限。
由于app没有加入群组,所以在dumpsys
中没有显示。
有关 Android 的权限和安全性的更多详细信息,我建议您阅读 Android Security Internals by Nikolay Elenkov
adb 命令adb shell dumpsys package com.hackerli.girl
可以帮助我获取应用程序信息。
在我请求 android.permission.WRITE_EXTERNAL_STORAGE
权限之前,我的应用有一个 gids=[3003]
。
requested permissions:
android.permission.INTERNET
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.READ_EXTERNAL_STORAGE
android.permission.ACCESS_NETWORK_STATE
install permissions:
android.permission.INTERNET: granted=true
android.permission.ACCESS_NETWORK_STATE: granted=true
User 0: ceDataInode=1531967 installed=true hidden=false suspended=false stopped=true notLaunched=false enabled=0
gids=[3003]
runtime permissions:
User 999: ceDataInode=0 installed=false hidden=false suspended=false stopped=true notLaunched=true enabled=0
gids=[3003]
runtime permissions:
授予运行时权限android.permission.WRITE_EXTERNAL_STORAGE
后,我得到以下信息。
requested permissions:
android.permission.INTERNET
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.READ_EXTERNAL_STORAGE
android.permission.ACCESS_NETWORK_STATE
install permissions:
android.permission.INTERNET: granted=true
android.permission.ACCESS_NETWORK_STATE: granted=true
User 0: ceDataInode=1531967 installed=true hidden=false suspended=false stopped=false notLaunched=false enabled=0
gids=[3003]
runtime permissions:
android.permission.READ_EXTERNAL_STORAGE: granted=true
android.permission.WRITE_EXTERNAL_STORAGE: granted=true
User 999: ceDataInode=0 installed=false hidden=false suspended=false stopped=true notLaunched=true enabled=0
gids=[3003]
runtime permissions:
如您所见,READ_EXTERNAL_STORAGE
权限也被授予,因为它与 WRITE_EXTERNAL_STORAGE
属于同一组。 但是gids
没有改变。我认为它应该更新所以我有什么错误吗?
总结
android.permission.WRITE_EXTERNAL_STORAGE
现在 (> API 23) 作为 built-in android 权限实施,现在已被管理由运行时。早些时候(< API 23)权限是 low-level 内核 强制执行的权限组的一部分,实现为 Linux Supplementary Group,即通过将组分配给应用程序安装时间。
Marshmallow 之前的行为 (< API 23)
在 Marshmallow 之前(特别是在引入 Runtime Permission), the android.permission.WRITE_EXTERNAL_STORAGE
was implemented at kernel level. Whenever any process try to access the external storage, the call goes through the kernel (the open()
系统调用之前),内核检查调用进程的权限(通常 Linux 东西...)。对于 极客 这是 call-stack 的样子:
读一个
File
you open a stream to it using theFileOutputStream
. When we construct aFileOutputStream
, this callsIOBridge.open(String, int)
.IOBridge
是一个内部的class并且把开头委托给nativeJNI-call.在
IOBridge.open()
call, the method delegates toLibcore.os.open()
. AgainLibcore
里面是一个内部class。Libcore.os.open()
is a native method, implemented here. And here, the method calls theopen()
系统调用和内核kicks-in!
Marshmallow 开始的行为 (>= API 23)
从 Marshmallow 开始(引入 Runtime Permission),开发人员需要向用户索要 android.permission.WRITE_EXTERNAL_STORAGE
。这会更改将权限分配给应用程序的方式。 Android 仍然在 安装 时分配 正常 权限,但对于 危险 应用 Android 要求应用程序显示一个弹出窗口,要求获得许可。当用户授予权限时,PackageManager
记录它并将其添加到应用程序的数据库记录中(在 /data/system/packages.xml
中)。如果权限是 low-level 权限,即由 kernel 使用 groups 实现,则PackageManager
也将应用程序的用户 ID 添加到相应的组。
早些时候 android.permission.WRITE_EXTERNAL_STORAGE
被实现为 low-level 权限(因此由内核管理)但现在应用程序被实现为 built-in 权限由运行时管理。
call-stack 现在看起来像:
读一个
File
you open a stream to it using theFileOutputStream
. When we construct aFileOutputStream
, which calls the privateFileOutputStream.open()
native function implemented here.由运行时实现的本机
FileOutputStream.open()
calls the helperfileOpen()
which delegates call toJVM_Open()
,因此运行时现在管理权限。
由于app没有加入群组,所以在dumpsys
中没有显示。
有关 Android 的权限和安全性的更多详细信息,我建议您阅读 Android Security Internals by Nikolay Elenkov