| Andres Morales | 1cf7d25 | 2015-08-04 16:57:12 -0700 | [diff] [blame] | 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 <stdint.h> | 
 | 19 | #include <sys/types.h> | 
 | 20 | #include <utils/Log.h> | 
 | 21 | #include <binder/Parcel.h> | 
 | 22 |  | 
 | 23 | #include "IUserManager.h" | 
 | 24 |  | 
 | 25 | namespace android { | 
 | 26 |  | 
 | 27 | class BpUserManager : public BpInterface<IUserManager> | 
 | 28 | { | 
 | 29 | public: | 
| Chih-Hung Hsieh | 1c563d9 | 2016-04-29 15:44:04 -0700 | [diff] [blame] | 30 |     explicit BpUserManager(const sp<IBinder>& impl) : | 
| Andres Morales | 1cf7d25 | 2015-08-04 16:57:12 -0700 | [diff] [blame] | 31 |             BpInterface<IUserManager>(impl) { | 
 | 32 |     } | 
 | 33 |     virtual int32_t getCredentialOwnerProfile(int32_t user_id) { | 
 | 34 |         Parcel data, reply; | 
 | 35 |         data.writeInterfaceToken(IUserManager::getInterfaceDescriptor()); | 
 | 36 |         data.writeInt32(user_id); | 
 | 37 |         status_t rc = remote()->transact(GET_CREDENTIAL_OWNER_PROFILE, data, &reply, 0); | 
 | 38 |         if (rc != NO_ERROR) { | 
 | 39 |             ALOGE("%s: failed (%d)\n", __func__, rc); | 
 | 40 |             return -1; | 
 | 41 |         } | 
 | 42 |  | 
 | 43 |         int32_t exception = reply.readExceptionCode(); | 
 | 44 |         if (exception != 0) { | 
 | 45 |             ALOGE("%s: got exception (%d)\n", __func__, exception); | 
 | 46 |             return -1; | 
 | 47 |         } | 
 | 48 |  | 
 | 49 |         return reply.readInt32(); | 
 | 50 |     } | 
 | 51 |  | 
 | 52 | }; | 
 | 53 |  | 
 | 54 | IMPLEMENT_META_INTERFACE(UserManager, "android.os.IUserManager"); | 
 | 55 |  | 
 | 56 | }; // namespace android | 
 | 57 |  |