2016年10月16日 星期日

更改Android下的system檔案權限

環境: imx6 + kernel 3.0.35

./device/fsl/imx6/sabresd_6dq.mk
...
...
...
PRODUCT_COPY_FILES += \
    frameworks/native/data/etc/android.hardware.location.gps.xml:system/etc/permissions/android.hardware.location.gps.xml \
    frameworks/native/data/etc/android.hardware.wifi.xml:system/etc/permissions/android.hardware.wifi.xml \
    frameworks/native/data/etc/android.hardware.wifi.direct.xml:system/etc/permissions/android.hardware.wifi.direct.xml \
...
...
...
Android OS下/system/etc/permissions裡的一些xml
是從./frameworks/native/data/etc/下拷貝過去的,
而這些permissions應該是寫app時宣告時用到的,
但在 /system/ 下,通常都是 read-only,就算有root也沒變法改變權限,
所以在 build bsp 時就要先設定 ./system/core/include/private/android_filesystem_config.h
有root也沒變法改變權限
chown system system /system/etc/android.hardware.location.gps.xml
chmod 0555 /system/etc/android.hardware.location.gps.xml
改變/system/下的權限
...
...
...
static const struct fs_path_config android_dirs[] =  //設定dirs
{ 
    { 00770, AID_SYSTEM, AID_CACHE,  0, "cache" },
    { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app" },
    { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app-private" },
    { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/dalvik-cache" },
    { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/data" },
    { 00771, AID_SHELL,  AID_SHELL,  0, "data/local/tmp" },
    { 00771, AID_SHELL,  AID_SHELL,  0, "data/local" },
    { 01771, AID_SYSTEM, AID_MISC,   0, "data/misc" },
    { 00770, AID_DHCP,   AID_DHCP,   0, "data/misc/dhcp" },
    { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media" },
    { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media/Music" },
    { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data" },
    { 00750, AID_ROOT,   AID_SHELL,  0, "sbin" },
    { 00755, AID_ROOT,   AID_SHELL,  0, "system/bin" },
    { 00755, AID_ROOT,   AID_SHELL,  0, "system/vendor" },
    { 00755, AID_ROOT,   AID_SHELL,  0, "system/xbin" },
    { 00755, AID_ROOT,   AID_ROOT,   0, "system/etc/ppp" },
    { 00755, AID_ROOT,   AID_SHELL,  0, "vendor" },
    { 00777, AID_ROOT,   AID_ROOT,   0, "sdcard" },
    { 00755, AID_ROOT,   AID_ROOT,   0, 0 },
};
...
...
...
static const struct fs_path_config android_files[] = //設定files
{
...
...
...
    { 00755, AID_ROOT,      AID_ROOT,      0, "bin/*" },
    { 00750, AID_ROOT,      AID_SHELL,     0, "init*" },
    { 00750, AID_ROOT,      AID_SHELL,     0, "charger*" },
    { 00750, AID_ROOT,      AID_SHELL,     0, "sbin/fs_mgr" },
    { 00640, AID_ROOT,      AID_SHELL,     0, "fstab.*" },
    { 00777, AID_SYSTEM,    AID_SHELL,     0, "system/etc/permissions/android.hardware.usb.accessory.xml" },
    { 00777, AID_SYSTEM,    AID_SHELL,     0, "system/etc/permissions/android.hardware.usb.host.xml" },
    { 00644, AID_ROOT,      AID_ROOT,      0, 0 },
};
ref : 蝸牛慢慢

沒有留言:

張貼留言