Loading include/cutils/multiuser.h +1 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ extern appid_t multiuser_get_app_id(uid_t uid); extern uid_t multiuser_get_uid(userid_t user_id, appid_t app_id); extern gid_t multiuser_get_cache_gid(userid_t user_id, appid_t app_id); extern gid_t multiuser_get_ext_gid(userid_t user_id, appid_t app_id); extern gid_t multiuser_get_shared_gid(userid_t user_id, appid_t app_id); /* TODO: switch callers over to multiuser_get_shared_gid() */ Loading include/private/android_filesystem_config.h +4 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,7 @@ #define AID_MEDIA_VIDEO 1056 /* GID for video files on internal media storage */ #define AID_MEDIA_IMAGE 1057 /* GID for image files on internal media storage */ #define AID_TOMBSTONED 1058 /* tombstoned user */ #define AID_MEDIA_OBB 1059 /* GID for OBB files on internal media storage */ /* Changes to this file must be made in AOSP, *not* in internal branches. */ #define AID_SHELL 2000 /* adb and debug shell user */ Loading Loading @@ -165,6 +166,9 @@ #define AID_CACHE_GID_START 20000 /* start of gids for apps to mark cached data */ #define AID_CACHE_GID_END 29999 /* end of gids for apps to mark cached data */ #define AID_EXT_GID_START 30000 /* start of gids for apps to mark external data */ #define AID_EXT_GID_END 39999 /* end of gids for apps to mark external data */ #define AID_SHARED_GID_START 50000 /* start of gids for apps in each user to share */ #define AID_SHARED_GID_END 59999 /* end of gids for apps in each user to share */ Loading libcutils/multiuser.c +8 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,14 @@ gid_t multiuser_get_cache_gid(userid_t user_id, appid_t app_id) { } } gid_t multiuser_get_ext_gid(userid_t user_id, appid_t app_id) { if (app_id >= AID_APP_START && app_id <= AID_APP_END) { return multiuser_get_uid(user_id, (app_id - AID_APP_START) + AID_EXT_GID_START); } else { return -1; } } gid_t multiuser_get_shared_gid(userid_t user_id, appid_t app_id) { if (app_id >= AID_APP_START && app_id <= AID_APP_END) { return multiuser_get_uid(user_id, (app_id - AID_APP_START) + AID_SHARED_GID_START); Loading libcutils/tests/multiuser_test.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,14 @@ TEST(MultiuserTest, TestCache) { EXPECT_EQ(1020000, multiuser_get_cache_gid(10, 10000)); } TEST(MultiuserTest, TestExt) { EXPECT_EQ(-1, multiuser_get_ext_gid(0, 0)); EXPECT_EQ(-1, multiuser_get_ext_gid(0, 1000)); EXPECT_EQ(30000, multiuser_get_ext_gid(0, 10000)); EXPECT_EQ(-1, multiuser_get_ext_gid(0, 50000)); EXPECT_EQ(1030000, multiuser_get_ext_gid(10, 10000)); } TEST(MultiuserTest, TestShared) { EXPECT_EQ(-1, multiuser_get_shared_gid(0, 0)); EXPECT_EQ(-1, multiuser_get_shared_gid(0, 1000)); Loading Loading
include/cutils/multiuser.h +1 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ extern appid_t multiuser_get_app_id(uid_t uid); extern uid_t multiuser_get_uid(userid_t user_id, appid_t app_id); extern gid_t multiuser_get_cache_gid(userid_t user_id, appid_t app_id); extern gid_t multiuser_get_ext_gid(userid_t user_id, appid_t app_id); extern gid_t multiuser_get_shared_gid(userid_t user_id, appid_t app_id); /* TODO: switch callers over to multiuser_get_shared_gid() */ Loading
include/private/android_filesystem_config.h +4 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,7 @@ #define AID_MEDIA_VIDEO 1056 /* GID for video files on internal media storage */ #define AID_MEDIA_IMAGE 1057 /* GID for image files on internal media storage */ #define AID_TOMBSTONED 1058 /* tombstoned user */ #define AID_MEDIA_OBB 1059 /* GID for OBB files on internal media storage */ /* Changes to this file must be made in AOSP, *not* in internal branches. */ #define AID_SHELL 2000 /* adb and debug shell user */ Loading Loading @@ -165,6 +166,9 @@ #define AID_CACHE_GID_START 20000 /* start of gids for apps to mark cached data */ #define AID_CACHE_GID_END 29999 /* end of gids for apps to mark cached data */ #define AID_EXT_GID_START 30000 /* start of gids for apps to mark external data */ #define AID_EXT_GID_END 39999 /* end of gids for apps to mark external data */ #define AID_SHARED_GID_START 50000 /* start of gids for apps in each user to share */ #define AID_SHARED_GID_END 59999 /* end of gids for apps in each user to share */ Loading
libcutils/multiuser.c +8 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,14 @@ gid_t multiuser_get_cache_gid(userid_t user_id, appid_t app_id) { } } gid_t multiuser_get_ext_gid(userid_t user_id, appid_t app_id) { if (app_id >= AID_APP_START && app_id <= AID_APP_END) { return multiuser_get_uid(user_id, (app_id - AID_APP_START) + AID_EXT_GID_START); } else { return -1; } } gid_t multiuser_get_shared_gid(userid_t user_id, appid_t app_id) { if (app_id >= AID_APP_START && app_id <= AID_APP_END) { return multiuser_get_uid(user_id, (app_id - AID_APP_START) + AID_SHARED_GID_START); Loading
libcutils/tests/multiuser_test.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,14 @@ TEST(MultiuserTest, TestCache) { EXPECT_EQ(1020000, multiuser_get_cache_gid(10, 10000)); } TEST(MultiuserTest, TestExt) { EXPECT_EQ(-1, multiuser_get_ext_gid(0, 0)); EXPECT_EQ(-1, multiuser_get_ext_gid(0, 1000)); EXPECT_EQ(30000, multiuser_get_ext_gid(0, 10000)); EXPECT_EQ(-1, multiuser_get_ext_gid(0, 50000)); EXPECT_EQ(1030000, multiuser_get_ext_gid(10, 10000)); } TEST(MultiuserTest, TestShared) { EXPECT_EQ(-1, multiuser_get_shared_gid(0, 0)); EXPECT_EQ(-1, multiuser_get_shared_gid(0, 1000)); Loading