• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #define LOG_TAG "IUserManager"
18 #include <binder/Parcel.h>
19 #include <stdint.h>
20 #include <sys/types.h>
21 #include <utils/Log.h>
22 
23 #include "IUserManager.h"
24 
25 namespace android {
26 
27 class BpUserManager : public BpInterface<IUserManager> {
28  public:
BpUserManager(const sp<IBinder> & impl)29   explicit BpUserManager(const sp<IBinder>& impl)
30       : BpInterface<IUserManager>(impl) {}
getCredentialOwnerProfile(int32_t user_id)31   virtual int32_t getCredentialOwnerProfile(int32_t user_id) {
32     Parcel data, reply;
33     data.writeInterfaceToken(IUserManager::getInterfaceDescriptor());
34     data.writeInt32(user_id);
35     status_t rc =
36         remote()->transact(GET_CREDENTIAL_OWNER_PROFILE, data, &reply, 0);
37     if (rc != NO_ERROR) {
38       ALOGE("%s: failed (%d)\n", __func__, rc);
39       return -1;
40     }
41 
42     int32_t exception = reply.readExceptionCode();
43     if (exception != 0) {
44       ALOGE("%s: got exception (%d)\n", __func__, exception);
45       return -1;
46     }
47 
48     return reply.readInt32();
49   }
50 
getProfileParentId(int32_t user_handle)51   virtual int32_t getProfileParentId(int32_t user_handle) {
52     Parcel data, reply;
53     data.writeInterfaceToken(IUserManager::getInterfaceDescriptor());
54     data.writeInt32(user_handle);
55     status_t rc = remote()->transact(GET_PROFILE_PARENT_ID, data, &reply, 0);
56     if (rc != NO_ERROR) {
57       ALOGE("%s: failed (%d)\n", __func__, rc);
58       return -1;
59     }
60 
61     int32_t exception = reply.readExceptionCode();
62     if (exception != 0) {
63       ALOGE("%s: got exception (%d)\n", __func__, exception);
64       return -1;
65     }
66 
67     return reply.readInt32();
68   }
69 };
70 
71 IMPLEMENT_META_INTERFACE(UserManager, "android.os.IUserManager");
72 
73 };  // namespace android
74