19509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey/*
29509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey * Copyright (C) 2012 The Android Open Source Project
39509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey *
49509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey * Licensed under the Apache License, Version 2.0 (the "License");
59509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey * you may not use this file except in compliance with the License.
69509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey * You may obtain a copy of the License at
79509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey *
89509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey *      http://www.apache.org/licenses/LICENSE-2.0
99509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey *
109509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey * Unless required by applicable law or agreed to in writing, software
119509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey * distributed under the License is distributed on an "AS IS" BASIS,
129509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey * See the License for the specific language governing permissions and
149509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey * limitations under the License.
159509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey */
169509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey
179509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey#include <cutils/multiuser.h>
189509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey
199685194fc94510a33201aee9b80c23f206ccfe67Jeff Sharkeyuserid_t multiuser_get_user_id(uid_t uid) {
209509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey    return uid / MULTIUSER_APP_PER_USER_RANGE;
219509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey}
229509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey
239685194fc94510a33201aee9b80c23f206ccfe67Jeff Sharkeyappid_t multiuser_get_app_id(uid_t uid) {
249509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey    return uid % MULTIUSER_APP_PER_USER_RANGE;
259509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey}
269509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey
279685194fc94510a33201aee9b80c23f206ccfe67Jeff Sharkeyuid_t multiuser_get_uid(userid_t userId, appid_t appId) {
289509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey    return userId * MULTIUSER_APP_PER_USER_RANGE + (appId % MULTIUSER_APP_PER_USER_RANGE);
299509d27252b16f69b6fd2ebb2c552201c34e5c0cJeff Sharkey}
30