Andres Morales | 2d08dce | 2015-04-03 16:40:15 -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 "gatekeeperd" |
| 18 | |
| 19 | #include "IGateKeeperService.h" |
| 20 | |
Andres Morales | 6a49c2f | 2015-04-16 13:16:24 -0700 | [diff] [blame] | 21 | #include <errno.h> |
| 22 | #include <stdint.h> |
| 23 | #include <inttypes.h> |
| 24 | #include <fcntl.h> |
| 25 | #include <unistd.h> |
| 26 | |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 27 | #include <cutils/log.h> |
| 28 | #include <utils/Log.h> |
| 29 | |
| 30 | #include <binder/IPCThreadState.h> |
| 31 | #include <binder/IServiceManager.h> |
| 32 | #include <binder/PermissionCache.h> |
| 33 | #include <utils/String16.h> |
Andres Morales | 835d96e | 2015-06-03 15:06:24 -0700 | [diff] [blame] | 34 | #include <utils/Log.h> |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 35 | |
| 36 | #include <keystore/IKeystoreService.h> |
Andres Morales | 2ae8b4c | 2015-04-13 09:20:09 -0700 | [diff] [blame] | 37 | #include <keystore/keystore.h> // For error code |
Andres Morales | 6a49c2f | 2015-04-16 13:16:24 -0700 | [diff] [blame] | 38 | #include <gatekeeper/password_handle.h> // for password_handle_t |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 39 | #include <hardware/gatekeeper.h> |
Andres Morales | 6a49c2f | 2015-04-16 13:16:24 -0700 | [diff] [blame] | 40 | #include <hardware/hw_auth_token.h> |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 41 | |
Andres Morales | 33dfdc7 | 2015-05-12 15:37:20 -0700 | [diff] [blame] | 42 | #include "SoftGateKeeperDevice.h" |
Andres Morales | 1cf7d25 | 2015-08-04 16:57:12 -0700 | [diff] [blame] | 43 | #include "IUserManager.h" |
Andres Morales | 33dfdc7 | 2015-05-12 15:37:20 -0700 | [diff] [blame] | 44 | |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 45 | namespace android { |
| 46 | |
| 47 | static const String16 KEYGUARD_PERMISSION("android.permission.ACCESS_KEYGUARD_SECURE_STORAGE"); |
| 48 | static const String16 DUMP_PERMISSION("android.permission.DUMP"); |
| 49 | |
| 50 | class GateKeeperProxy : public BnGateKeeperService { |
| 51 | public: |
| 52 | GateKeeperProxy() { |
| 53 | int ret = hw_get_module_by_class(GATEKEEPER_HARDWARE_MODULE_ID, NULL, &module); |
Andres Morales | fef908e | 2015-07-07 10:28:15 -0700 | [diff] [blame] | 54 | device = NULL; |
| 55 | |
Andres Morales | 33dfdc7 | 2015-05-12 15:37:20 -0700 | [diff] [blame] | 56 | if (ret < 0) { |
| 57 | ALOGW("falling back to software GateKeeper"); |
| 58 | soft_device.reset(new SoftGateKeeperDevice()); |
| 59 | } else { |
| 60 | ret = gatekeeper_open(module, &device); |
| 61 | if (ret < 0) |
| 62 | LOG_ALWAYS_FATAL_IF(ret < 0, "Unable to open GateKeeper HAL"); |
| 63 | } |
Andres Morales | 3c2086d | 2015-06-24 10:21:16 -0700 | [diff] [blame] | 64 | |
| 65 | if (mark_cold_boot()) { |
| 66 | ALOGI("cold boot: clearing state"); |
| 67 | if (device != NULL && device->delete_all_users != NULL) { |
| 68 | device->delete_all_users(device); |
| 69 | } |
| 70 | } |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | virtual ~GateKeeperProxy() { |
Andres Morales | 33dfdc7 | 2015-05-12 15:37:20 -0700 | [diff] [blame] | 74 | if (device) gatekeeper_close(device); |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 75 | } |
| 76 | |
Andres Morales | 6a49c2f | 2015-04-16 13:16:24 -0700 | [diff] [blame] | 77 | void store_sid(uint32_t uid, uint64_t sid) { |
| 78 | char filename[21]; |
| 79 | sprintf(filename, "%u", uid); |
| 80 | int fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR); |
| 81 | if (fd < 0) { |
Andres Morales | dcb3fbd | 2015-04-17 09:00:28 -0700 | [diff] [blame] | 82 | ALOGE("could not open file: %s: %s", filename, strerror(errno)); |
Andres Morales | 6a49c2f | 2015-04-16 13:16:24 -0700 | [diff] [blame] | 83 | return; |
| 84 | } |
| 85 | write(fd, &sid, sizeof(sid)); |
| 86 | close(fd); |
| 87 | } |
| 88 | |
Andres Morales | 3c2086d | 2015-06-24 10:21:16 -0700 | [diff] [blame] | 89 | bool mark_cold_boot() { |
| 90 | const char *filename = ".coldboot"; |
| 91 | if (access(filename, F_OK) == -1) { |
| 92 | int fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR); |
| 93 | if (fd < 0) { |
| 94 | ALOGE("could not open file: %s : %s", filename, strerror(errno)); |
| 95 | return false; |
| 96 | } |
| 97 | close(fd); |
| 98 | return true; |
| 99 | } |
| 100 | return false; |
| 101 | } |
| 102 | |
Andres Morales | 6a49c2f | 2015-04-16 13:16:24 -0700 | [diff] [blame] | 103 | void maybe_store_sid(uint32_t uid, uint64_t sid) { |
| 104 | char filename[21]; |
| 105 | sprintf(filename, "%u", uid); |
| 106 | if (access(filename, F_OK) == -1) { |
| 107 | store_sid(uid, sid); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | uint64_t read_sid(uint32_t uid) { |
| 112 | char filename[21]; |
| 113 | uint64_t sid; |
| 114 | sprintf(filename, "%u", uid); |
| 115 | int fd = open(filename, O_RDONLY); |
| 116 | if (fd < 0) return 0; |
| 117 | read(fd, &sid, sizeof(sid)); |
Andres Morales | 0b0435e | 2015-07-10 09:47:09 -0700 | [diff] [blame] | 118 | close(fd); |
Andres Morales | 6a49c2f | 2015-04-16 13:16:24 -0700 | [diff] [blame] | 119 | return sid; |
| 120 | } |
| 121 | |
Andres Morales | dcb3fbd | 2015-04-17 09:00:28 -0700 | [diff] [blame] | 122 | void clear_sid(uint32_t uid) { |
| 123 | char filename[21]; |
| 124 | sprintf(filename, "%u", uid); |
| 125 | if (remove(filename) < 0) { |
| 126 | ALOGE("%s: could not remove file [%s], attempting 0 write", __func__, strerror(errno)); |
| 127 | store_sid(uid, 0); |
| 128 | } |
| 129 | } |
| 130 | |
Andres Morales | ae24292 | 2015-05-18 09:26:19 -0700 | [diff] [blame] | 131 | virtual int enroll(uint32_t uid, |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 132 | const uint8_t *current_password_handle, uint32_t current_password_handle_length, |
| 133 | const uint8_t *current_password, uint32_t current_password_length, |
| 134 | const uint8_t *desired_password, uint32_t desired_password_length, |
| 135 | uint8_t **enrolled_password_handle, uint32_t *enrolled_password_handle_length) { |
| 136 | IPCThreadState* ipc = IPCThreadState::self(); |
| 137 | const int calling_pid = ipc->getCallingPid(); |
| 138 | const int calling_uid = ipc->getCallingUid(); |
| 139 | if (!PermissionCache::checkPermission(KEYGUARD_PERMISSION, calling_pid, calling_uid)) { |
| 140 | return PERMISSION_DENIED; |
| 141 | } |
| 142 | |
| 143 | // need a desired password to enroll |
| 144 | if (desired_password_length == 0) return -EINVAL; |
Andres Morales | 33dfdc7 | 2015-05-12 15:37:20 -0700 | [diff] [blame] | 145 | |
| 146 | int ret; |
| 147 | if (device) { |
Andres Morales | 835d96e | 2015-06-03 15:06:24 -0700 | [diff] [blame] | 148 | const gatekeeper::password_handle_t *handle = |
| 149 | reinterpret_cast<const gatekeeper::password_handle_t *>(current_password_handle); |
| 150 | |
Andres Morales | 7f6dcf6 | 2015-06-24 18:40:24 -0700 | [diff] [blame] | 151 | if (handle != NULL && handle->version != 0 && !handle->hardware_backed) { |
Andres Morales | 835d96e | 2015-06-03 15:06:24 -0700 | [diff] [blame] | 152 | // handle is being re-enrolled from a software version. HAL probably won't accept |
| 153 | // the handle as valid, so we nullify it and enroll from scratch |
| 154 | current_password_handle = NULL; |
| 155 | current_password_handle_length = 0; |
| 156 | current_password = NULL; |
| 157 | current_password_length = 0; |
| 158 | } |
| 159 | |
| 160 | ret = device->enroll(device, uid, current_password_handle, current_password_handle_length, |
Andres Morales | 33dfdc7 | 2015-05-12 15:37:20 -0700 | [diff] [blame] | 161 | current_password, current_password_length, |
| 162 | desired_password, desired_password_length, |
| 163 | enrolled_password_handle, enrolled_password_handle_length); |
| 164 | } else { |
| 165 | ret = soft_device->enroll(uid, |
| 166 | current_password_handle, current_password_handle_length, |
| 167 | current_password, current_password_length, |
| 168 | desired_password, desired_password_length, |
| 169 | enrolled_password_handle, enrolled_password_handle_length); |
| 170 | } |
| 171 | |
Alexey Polyudov | 8c63536 | 2016-09-07 18:51:28 -0700 | [diff] [blame] | 172 | if (ret == GATEKEEPER_RESPONSE_OK && (*enrolled_password_handle == nullptr || |
| 173 | *enrolled_password_handle_length != sizeof(password_handle_t))) { |
| 174 | ret = GATEKEEPER_RESPONSE_ERROR; |
| 175 | ALOGE("HAL: password_handle=%p size_of_handle=%" PRIu32 "\n", |
| 176 | *enrolled_password_handle, *enrolled_password_handle_length); |
| 177 | } |
| 178 | |
| 179 | if (ret == GATEKEEPER_RESPONSE_OK) { |
Andres Morales | 6a49c2f | 2015-04-16 13:16:24 -0700 | [diff] [blame] | 180 | gatekeeper::password_handle_t *handle = |
| 181 | reinterpret_cast<gatekeeper::password_handle_t *>(*enrolled_password_handle); |
| 182 | store_sid(uid, handle->user_id); |
Andres Morales | 531e3e8 | 2015-06-01 17:23:04 -0700 | [diff] [blame] | 183 | bool rr; |
| 184 | |
| 185 | // immediately verify this password so we don't ask the user to enter it again |
| 186 | // if they just created it. |
| 187 | verify(uid, *enrolled_password_handle, sizeof(password_handle_t), desired_password, |
| 188 | desired_password_length, &rr); |
Andres Morales | 6a49c2f | 2015-04-16 13:16:24 -0700 | [diff] [blame] | 189 | } |
Andres Morales | ae24292 | 2015-05-18 09:26:19 -0700 | [diff] [blame] | 190 | |
| 191 | return ret; |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 192 | } |
| 193 | |
Andres Morales | ae24292 | 2015-05-18 09:26:19 -0700 | [diff] [blame] | 194 | virtual int verify(uint32_t uid, |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 195 | const uint8_t *enrolled_password_handle, uint32_t enrolled_password_handle_length, |
Andres Morales | ae24292 | 2015-05-18 09:26:19 -0700 | [diff] [blame] | 196 | const uint8_t *provided_password, uint32_t provided_password_length, bool *request_reenroll) { |
Andres Morales | c828ae8 | 2015-04-10 21:03:07 -0700 | [diff] [blame] | 197 | uint8_t *auth_token; |
| 198 | uint32_t auth_token_length; |
| 199 | return verifyChallenge(uid, 0, enrolled_password_handle, enrolled_password_handle_length, |
| 200 | provided_password, provided_password_length, |
Andres Morales | ae24292 | 2015-05-18 09:26:19 -0700 | [diff] [blame] | 201 | &auth_token, &auth_token_length, request_reenroll); |
Andres Morales | c828ae8 | 2015-04-10 21:03:07 -0700 | [diff] [blame] | 202 | } |
| 203 | |
Andres Morales | ae24292 | 2015-05-18 09:26:19 -0700 | [diff] [blame] | 204 | virtual int verifyChallenge(uint32_t uid, uint64_t challenge, |
Andres Morales | c828ae8 | 2015-04-10 21:03:07 -0700 | [diff] [blame] | 205 | const uint8_t *enrolled_password_handle, uint32_t enrolled_password_handle_length, |
| 206 | const uint8_t *provided_password, uint32_t provided_password_length, |
Andres Morales | ae24292 | 2015-05-18 09:26:19 -0700 | [diff] [blame] | 207 | uint8_t **auth_token, uint32_t *auth_token_length, bool *request_reenroll) { |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 208 | IPCThreadState* ipc = IPCThreadState::self(); |
| 209 | const int calling_pid = ipc->getCallingPid(); |
| 210 | const int calling_uid = ipc->getCallingUid(); |
| 211 | if (!PermissionCache::checkPermission(KEYGUARD_PERMISSION, calling_pid, calling_uid)) { |
| 212 | return PERMISSION_DENIED; |
| 213 | } |
| 214 | |
| 215 | // can't verify if we're missing either param |
| 216 | if ((enrolled_password_handle_length | provided_password_length) == 0) |
| 217 | return -EINVAL; |
| 218 | |
Andres Morales | 33dfdc7 | 2015-05-12 15:37:20 -0700 | [diff] [blame] | 219 | int ret; |
| 220 | if (device) { |
Andres Morales | 835d96e | 2015-06-03 15:06:24 -0700 | [diff] [blame] | 221 | const gatekeeper::password_handle_t *handle = |
| 222 | reinterpret_cast<const gatekeeper::password_handle_t *>(enrolled_password_handle); |
Andres Morales | 7f6dcf6 | 2015-06-24 18:40:24 -0700 | [diff] [blame] | 223 | // handle version 0 does not have hardware backed flag, and thus cannot be upgraded to |
| 224 | // a HAL if there was none before |
| 225 | if (handle->version == 0 || handle->hardware_backed) { |
Andres Morales | 835d96e | 2015-06-03 15:06:24 -0700 | [diff] [blame] | 226 | ret = device->verify(device, uid, challenge, |
| 227 | enrolled_password_handle, enrolled_password_handle_length, |
| 228 | provided_password, provided_password_length, auth_token, auth_token_length, |
| 229 | request_reenroll); |
| 230 | } else { |
| 231 | // upgrade scenario, a HAL has been added to this device where there was none before |
| 232 | SoftGateKeeperDevice soft_dev; |
| 233 | ret = soft_dev.verify(uid, challenge, |
| 234 | enrolled_password_handle, enrolled_password_handle_length, |
| 235 | provided_password, provided_password_length, auth_token, auth_token_length, |
| 236 | request_reenroll); |
| 237 | |
| 238 | if (ret == 0) { |
| 239 | // success! re-enroll with HAL |
| 240 | *request_reenroll = true; |
| 241 | } |
| 242 | } |
Andres Morales | 33dfdc7 | 2015-05-12 15:37:20 -0700 | [diff] [blame] | 243 | } else { |
| 244 | ret = soft_device->verify(uid, challenge, |
| 245 | enrolled_password_handle, enrolled_password_handle_length, |
Andres Morales | ae24292 | 2015-05-18 09:26:19 -0700 | [diff] [blame] | 246 | provided_password, provided_password_length, auth_token, auth_token_length, |
| 247 | request_reenroll); |
Andres Morales | 33dfdc7 | 2015-05-12 15:37:20 -0700 | [diff] [blame] | 248 | } |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 249 | |
Andres Morales | ae24292 | 2015-05-18 09:26:19 -0700 | [diff] [blame] | 250 | if (ret == 0 && *auth_token != NULL && *auth_token_length > 0) { |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 251 | // TODO: cache service? |
| 252 | sp<IServiceManager> sm = defaultServiceManager(); |
| 253 | sp<IBinder> binder = sm->getService(String16("android.security.keystore")); |
| 254 | sp<IKeystoreService> service = interface_cast<IKeystoreService>(binder); |
| 255 | if (service != NULL) { |
Andres Morales | 2ae8b4c | 2015-04-13 09:20:09 -0700 | [diff] [blame] | 256 | status_t ret = service->addAuthToken(*auth_token, *auth_token_length); |
| 257 | if (ret != ResponseCode::NO_ERROR) { |
| 258 | ALOGE("Falure sending auth token to KeyStore: %d", ret); |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 259 | } |
| 260 | } else { |
| 261 | ALOGE("Unable to communicate with KeyStore"); |
| 262 | } |
| 263 | } |
| 264 | |
Andres Morales | ae24292 | 2015-05-18 09:26:19 -0700 | [diff] [blame] | 265 | if (ret == 0) { |
Andres Morales | 6a49c2f | 2015-04-16 13:16:24 -0700 | [diff] [blame] | 266 | maybe_store_sid(uid, reinterpret_cast<const gatekeeper::password_handle_t *>( |
| 267 | enrolled_password_handle)->user_id); |
Andres Morales | 6a49c2f | 2015-04-16 13:16:24 -0700 | [diff] [blame] | 268 | } |
| 269 | |
Andres Morales | ae24292 | 2015-05-18 09:26:19 -0700 | [diff] [blame] | 270 | return ret; |
Andres Morales | 6a49c2f | 2015-04-16 13:16:24 -0700 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | virtual uint64_t getSecureUserId(uint32_t uid) { |
Andres Morales | 1cf7d25 | 2015-08-04 16:57:12 -0700 | [diff] [blame] | 274 | uint64_t sid = read_sid(uid); |
| 275 | if (sid == 0) { |
| 276 | // might be a work profile, look up the parent |
| 277 | sp<IServiceManager> sm = defaultServiceManager(); |
| 278 | sp<IBinder> binder = sm->getService(String16("user")); |
| 279 | sp<IUserManager> um = interface_cast<IUserManager>(binder); |
| 280 | int32_t parent = um->getCredentialOwnerProfile(uid); |
| 281 | if (parent < 0) { |
| 282 | return 0; |
| 283 | } else if (parent != (int32_t) uid) { |
| 284 | return read_sid(parent); |
| 285 | } |
| 286 | } |
| 287 | return sid; |
| 288 | |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 289 | } |
| 290 | |
Andres Morales | 7c9c3bc | 2015-04-16 15:57:17 -0700 | [diff] [blame] | 291 | virtual void clearSecureUserId(uint32_t uid) { |
| 292 | IPCThreadState* ipc = IPCThreadState::self(); |
| 293 | const int calling_pid = ipc->getCallingPid(); |
| 294 | const int calling_uid = ipc->getCallingUid(); |
| 295 | if (!PermissionCache::checkPermission(KEYGUARD_PERMISSION, calling_pid, calling_uid)) { |
| 296 | ALOGE("%s: permission denied for [%d:%d]", __func__, calling_pid, calling_uid); |
| 297 | return; |
| 298 | } |
Andres Morales | dcb3fbd | 2015-04-17 09:00:28 -0700 | [diff] [blame] | 299 | clear_sid(uid); |
Andres Morales | 3c2086d | 2015-06-24 10:21:16 -0700 | [diff] [blame] | 300 | |
| 301 | if (device != NULL && device->delete_user != NULL) { |
| 302 | device->delete_user(device, uid); |
| 303 | } |
Andres Morales | 7c9c3bc | 2015-04-16 15:57:17 -0700 | [diff] [blame] | 304 | } |
| 305 | |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 306 | virtual status_t dump(int fd, const Vector<String16> &) { |
| 307 | IPCThreadState* ipc = IPCThreadState::self(); |
| 308 | const int pid = ipc->getCallingPid(); |
| 309 | const int uid = ipc->getCallingUid(); |
| 310 | if (!PermissionCache::checkPermission(DUMP_PERMISSION, pid, uid)) { |
| 311 | return PERMISSION_DENIED; |
| 312 | } |
| 313 | |
| 314 | if (device == NULL) { |
| 315 | const char *result = "Device not available"; |
| 316 | write(fd, result, strlen(result) + 1); |
| 317 | } else { |
| 318 | const char *result = "OK"; |
| 319 | write(fd, result, strlen(result) + 1); |
| 320 | } |
| 321 | |
| 322 | return NO_ERROR; |
| 323 | } |
| 324 | |
| 325 | private: |
| 326 | gatekeeper_device_t *device; |
Andres Morales | 33dfdc7 | 2015-05-12 15:37:20 -0700 | [diff] [blame] | 327 | UniquePtr<SoftGateKeeperDevice> soft_device; |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 328 | const hw_module_t *module; |
| 329 | }; |
| 330 | }// namespace android |
| 331 | |
Andres Morales | 6a49c2f | 2015-04-16 13:16:24 -0700 | [diff] [blame] | 332 | int main(int argc, char* argv[]) { |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 333 | ALOGI("Starting gatekeeperd..."); |
Andres Morales | 6a49c2f | 2015-04-16 13:16:24 -0700 | [diff] [blame] | 334 | if (argc < 2) { |
| 335 | ALOGE("A directory must be specified!"); |
| 336 | return 1; |
| 337 | } |
| 338 | if (chdir(argv[1]) == -1) { |
| 339 | ALOGE("chdir: %s: %s", argv[1], strerror(errno)); |
| 340 | return 1; |
| 341 | } |
| 342 | |
Andres Morales | 2d08dce | 2015-04-03 16:40:15 -0700 | [diff] [blame] | 343 | android::sp<android::IServiceManager> sm = android::defaultServiceManager(); |
| 344 | android::sp<android::GateKeeperProxy> proxy = new android::GateKeeperProxy(); |
| 345 | android::status_t ret = sm->addService( |
| 346 | android::String16("android.service.gatekeeper.IGateKeeperService"), proxy); |
| 347 | if (ret != android::OK) { |
| 348 | ALOGE("Couldn't register binder service!"); |
| 349 | return -1; |
| 350 | } |
| 351 | |
| 352 | /* |
| 353 | * We're the only thread in existence, so we're just going to process |
| 354 | * Binder transaction as a single-threaded program. |
| 355 | */ |
| 356 | android::IPCThreadState::self()->joinThreadPool(); |
| 357 | return 0; |
| 358 | } |