Merge "Better, consistent definition of AID_SHARED_GID."
This commit is contained in:
commit
b77ecd04d8
3 changed files with 14 additions and 6 deletions
|
@ -20,7 +20,7 @@
|
|||
libcutils_nonwindows_sources = [
|
||||
"android_get_control_file.cpp",
|
||||
"fs.cpp",
|
||||
"multiuser.c",
|
||||
"multiuser.cpp",
|
||||
"socket_inaddr_any_server_unix.cpp",
|
||||
"socket_local_client_unix.cpp",
|
||||
"socket_local_server_unix.cpp",
|
||||
|
|
|
@ -53,9 +53,11 @@ gid_t multiuser_get_ext_cache_gid(userid_t user_id, appid_t app_id) {
|
|||
}
|
||||
}
|
||||
|
||||
gid_t multiuser_get_shared_gid(userid_t user_id, appid_t app_id) {
|
||||
gid_t multiuser_get_shared_gid(userid_t, 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);
|
||||
return (app_id - AID_APP_START) + AID_SHARED_GID_START;
|
||||
} else if (app_id >= AID_ROOT && app_id <= AID_APP_START) {
|
||||
return app_id;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
|
@ -57,7 +57,10 @@ TEST(MultiuserTest, TestCache) {
|
|||
EXPECT_EQ(ERR_GID, multiuser_get_cache_gid(0, 1000));
|
||||
EXPECT_EQ(20000U, multiuser_get_cache_gid(0, 10000));
|
||||
EXPECT_EQ(ERR_GID, multiuser_get_cache_gid(0, 50000));
|
||||
EXPECT_EQ(ERR_GID, multiuser_get_cache_gid(10, 0));
|
||||
EXPECT_EQ(ERR_GID, multiuser_get_cache_gid(10, 1000));
|
||||
EXPECT_EQ(1020000U, multiuser_get_cache_gid(10, 10000));
|
||||
EXPECT_EQ(ERR_GID, multiuser_get_cache_gid(10, 50000));
|
||||
}
|
||||
|
||||
TEST(MultiuserTest, TestExt) {
|
||||
|
@ -77,9 +80,12 @@ TEST(MultiuserTest, TestExtCache) {
|
|||
}
|
||||
|
||||
TEST(MultiuserTest, TestShared) {
|
||||
EXPECT_EQ(ERR_GID, multiuser_get_shared_gid(0, 0));
|
||||
EXPECT_EQ(ERR_GID, multiuser_get_shared_gid(0, 1000));
|
||||
EXPECT_EQ(0U, multiuser_get_shared_gid(0, 0));
|
||||
EXPECT_EQ(1000U, multiuser_get_shared_gid(0, 1000));
|
||||
EXPECT_EQ(50000U, multiuser_get_shared_gid(0, 10000));
|
||||
EXPECT_EQ(ERR_GID, multiuser_get_shared_gid(0, 50000));
|
||||
EXPECT_EQ(1050000U, multiuser_get_shared_gid(10, 10000));
|
||||
EXPECT_EQ(0U, multiuser_get_shared_gid(10, 0));
|
||||
EXPECT_EQ(1000U, multiuser_get_shared_gid(10, 1000));
|
||||
EXPECT_EQ(50000U, multiuser_get_shared_gid(10, 10000));
|
||||
EXPECT_EQ(ERR_GID, multiuser_get_shared_gid(10, 50000));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue