frameworks/native
リビジョン | cfd43ef931af4a25db5cebee977a91e7016a1c27 (tree) |
---|---|
日時 | 2017-12-11 00:21:22 |
作者 | Chih-Wei Huang <cwhuang@linu...> |
コミッター | Chih-Wei Huang |
Merge branch 'android-ia' into oreo-x86
@@ -160,14 +160,20 @@ status_t BpBinder::dump(int fd, const Vector<String16>& args) | ||
160 | 160 | status_t BpBinder::transact( |
161 | 161 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
162 | 162 | { |
163 | - // Once a binder has died, it will never come back to life. | |
163 | + // Once a binder has died, it will never come back to life. But | |
164 | + // note that the special case of the global service manager cannot | |
165 | + // die; there is no guarantee in the framework that it will be | |
166 | + // alive before a binder service object is instantiated, so we | |
167 | + // ignore errors for that special object so that | |
168 | + // IServiceManager::addService() calls can be retried. | |
164 | 169 | if (mAlive) { |
165 | 170 | status_t status = IPCThreadState::self()->transact( |
166 | 171 | mHandle, code, data, reply, flags); |
167 | - if (status == DEAD_OBJECT) mAlive = 0; | |
172 | + if (status == DEAD_OBJECT) | |
173 | + if (this != ProcessState::self()->getContextObject(NULL).get()) | |
174 | + mAlive = 0; | |
168 | 175 | return status; |
169 | 176 | } |
170 | - | |
171 | 177 | return DEAD_OBJECT; |
172 | 178 | } |
173 | 179 |
@@ -29,6 +29,8 @@ | ||
29 | 29 | |
30 | 30 | #include <unistd.h> |
31 | 31 | |
32 | +#define ADD_SERVICE_RETRY_SECS 10 | |
33 | + | |
32 | 34 | namespace android { |
33 | 35 | |
34 | 36 | sp<IServiceManager> defaultServiceManager() |
@@ -163,13 +165,26 @@ public: | ||
163 | 165 | virtual status_t addService(const String16& name, const sp<IBinder>& service, |
164 | 166 | bool allowIsolated) |
165 | 167 | { |
166 | - Parcel data, reply; | |
167 | - data.writeInterfaceToken(IServiceManager::getInterfaceDescriptor()); | |
168 | - data.writeString16(name); | |
169 | - data.writeStrongBinder(service); | |
170 | - data.writeInt32(allowIsolated ? 1 : 0); | |
171 | - status_t err = remote()->transact(ADD_SERVICE_TRANSACTION, data, &reply); | |
172 | - return err == NO_ERROR ? reply.readExceptionCode() : err; | |
168 | + status_t err; | |
169 | + for (int i=0; i<ADD_SERVICE_RETRY_SECS; i++) { | |
170 | + Parcel data, reply; | |
171 | + data.writeInterfaceToken(IServiceManager::getInterfaceDescriptor()); | |
172 | + data.writeString16(name); | |
173 | + data.writeStrongBinder(service); | |
174 | + data.writeInt32(allowIsolated ? 1 : 0); | |
175 | + err = remote()->transact(ADD_SERVICE_TRANSACTION, data, &reply); | |
176 | + if (err == NO_ERROR) | |
177 | + return reply.readExceptionCode(); | |
178 | + if (i != ADD_SERVICE_RETRY_SECS) { | |
179 | + ALOGI("addService() %s failed (err %d - no service manager yet?). Retrying...\n", | |
180 | + String8(name).string(), err); | |
181 | + sleep(1); | |
182 | + } else { | |
183 | + ALOGE("addService() %s failed (err %d). Giving up.\n", | |
184 | + String8(name).string(), err); | |
185 | + } | |
186 | + } | |
187 | + return err; | |
173 | 188 | } |
174 | 189 | |
175 | 190 | virtual Vector<String16> listServices() |
@@ -462,10 +462,10 @@ size_t Sensor::getFlattenedSize() const { | ||
462 | 462 | sizeof(mRequiredAppOp) + sizeof(mMaxDelay) + sizeof(mFlags) + sizeof(mUuid); |
463 | 463 | |
464 | 464 | size_t variableSize = |
465 | - sizeof(uint32_t) + FlattenableUtils::align<4>(mName.length()) + | |
466 | - sizeof(uint32_t) + FlattenableUtils::align<4>(mVendor.length()) + | |
467 | - sizeof(uint32_t) + FlattenableUtils::align<4>(mStringType.length()) + | |
468 | - sizeof(uint32_t) + FlattenableUtils::align<4>(mRequiredPermission.length()); | |
465 | + sizeof(size_t) + FlattenableUtils::align<sizeof(size_t)>(mName.length()) + | |
466 | + sizeof(size_t) + FlattenableUtils::align<sizeof(size_t)>(mVendor.length()) + | |
467 | + sizeof(size_t) + FlattenableUtils::align<sizeof(size_t)>(mStringType.length()) + | |
468 | + sizeof(size_t) + FlattenableUtils::align<sizeof(size_t)>(mRequiredPermission.length()); | |
469 | 469 | |
470 | 470 | return fixedSize + variableSize; |
471 | 471 | } |
@@ -1127,8 +1127,17 @@ status_t EventHub::unregisterDeviceFromEpollLocked(Device* device) { | ||
1127 | 1127 | } |
1128 | 1128 | |
1129 | 1129 | status_t EventHub::openDeviceLocked(const char *devicePath) { |
1130 | + return openDeviceLocked(devicePath, false); | |
1131 | +} | |
1132 | + | |
1133 | +status_t EventHub::openDeviceLocked(const char *devicePath, bool ignoreAlreadyOpened) { | |
1130 | 1134 | char buffer[80]; |
1131 | 1135 | |
1136 | + if (ignoreAlreadyOpened && (getDeviceByPathLocked(devicePath) != 0)) { | |
1137 | + ALOGV("Ignoring device '%s' that has already been opened.", devicePath); | |
1138 | + return 0; | |
1139 | + } | |
1140 | + | |
1132 | 1141 | ALOGV("Opening device: %s", devicePath); |
1133 | 1142 | |
1134 | 1143 | int fd = open(devicePath, O_RDWR | O_CLOEXEC | O_NONBLOCK); |
@@ -1338,7 +1347,11 @@ status_t EventHub::openDeviceLocked(const char *devicePath) { | ||
1338 | 1347 | |
1339 | 1348 | // 'Q' key support = cheap test of whether this is an alpha-capable kbd |
1340 | 1349 | if (hasKeycodeLocked(device, AKEYCODE_Q)) { |
1341 | - device->classes |= INPUT_DEVICE_CLASS_ALPHAKEY; | |
1350 | + char value[PROPERTY_VALUE_MAX]; | |
1351 | + property_get("ro.ignore_atkbd", value, "0"); | |
1352 | + if ((device->identifier.name != "AT Translated Set 2 keyboard") || (!atoi(value))) { | |
1353 | + device->classes |= INPUT_DEVICE_CLASS_ALPHAKEY; | |
1354 | + } | |
1342 | 1355 | } |
1343 | 1356 | |
1344 | 1357 | // See if this device has a DPAD. |
@@ -1711,7 +1724,7 @@ status_t EventHub::readNotifyLocked() { | ||
1711 | 1724 | if(event->len) { |
1712 | 1725 | strcpy(filename, event->name); |
1713 | 1726 | if(event->mask & IN_CREATE) { |
1714 | - openDeviceLocked(devname); | |
1727 | + openDeviceLocked(devname, true); | |
1715 | 1728 | } else { |
1716 | 1729 | ALOGI("Removing device '%s' due to inotify event\n", devname); |
1717 | 1730 | closeDeviceByPathLocked(devname); |
@@ -394,6 +394,7 @@ private: | ||
394 | 394 | }; |
395 | 395 | |
396 | 396 | status_t openDeviceLocked(const char *devicePath); |
397 | + status_t openDeviceLocked(const char *devicePath, bool ignoreAlreadyOpened); | |
397 | 398 | void createVirtualKeyboardLocked(); |
398 | 399 | void addDeviceLocked(Device* device); |
399 | 400 | void assignDescriptorLocked(InputDeviceIdentifier& identifier); |
@@ -288,11 +288,11 @@ Vector< sp<EventThread::Connection> > EventThread::waitForEvent( | ||
288 | 288 | } |
289 | 289 | |
290 | 290 | // Here we figure out if we need to enable or disable vsyncs |
291 | - if (timestamp && !waitForVSync) { | |
292 | - // we received a VSYNC but we have no clients | |
293 | - // don't report it, and disable VSYNC events | |
291 | + if (!waitForVSync) { | |
292 | + // we have no clients waiting on next VSYNC | |
293 | + // just disable VSYNC events. | |
294 | 294 | disableVSyncLocked(); |
295 | - } else if (!timestamp && waitForVSync) { | |
295 | + } else if (!timestamp) { | |
296 | 296 | // we have at least one client, so we want vsync enabled |
297 | 297 | // (TODO: this function is called right after we finish |
298 | 298 | // notifying clients of a vsync, so this call will be made |