Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

frameworks-native: Commit

frameworks/native


Commit MetaInfo

Revision3f6986346e5215feddf22e6e0261a674d6272def (tree)
Time2015-12-22 13:05:59
AuthorChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

Merge branch 'android-ia' into lollipop-x86

Change Summary

Incremental Difference

--- a/include/android/native_window.h
+++ b/include/android/native_window.h
@@ -19,6 +19,8 @@
1919
2020 #include <android/rect.h>
2121
22+#include <system/window.h>
23+
2224 #ifdef __cplusplus
2325 extern "C" {
2426 #endif
@@ -32,9 +34,6 @@ enum {
3234 WINDOW_FORMAT_RGB_565 = 4,
3335 };
3436
35-struct ANativeWindow;
36-typedef struct ANativeWindow ANativeWindow;
37-
3837 typedef struct ANativeWindow_Buffer {
3938 // The number of pixels that are show horizontally.
4039 int32_t width;
--- a/libs/binder/BpBinder.cpp
+++ b/libs/binder/BpBinder.cpp
@@ -159,14 +159,20 @@ status_t BpBinder::dump(int fd, const Vector<String16>& args)
159159 status_t BpBinder::transact(
160160 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
161161 {
162- // Once a binder has died, it will never come back to life.
162+ // Once a binder has died, it will never come back to life. But
163+ // note that the special case of the global service manager cannot
164+ // die; there is no guarantee in the framework that it will be
165+ // alive before a binder service object is instantiated, so we
166+ // ignore errors for that special object so that
167+ // IServiceManager::addService() calls can be retried.
163168 if (mAlive) {
164169 status_t status = IPCThreadState::self()->transact(
165170 mHandle, code, data, reply, flags);
166- if (status == DEAD_OBJECT) mAlive = 0;
171+ if (status == DEAD_OBJECT)
172+ if (this != ProcessState::self()->getContextObject(NULL).get())
173+ mAlive = 0;
167174 return status;
168175 }
169-
170176 return DEAD_OBJECT;
171177 }
172178
--- a/libs/binder/IServiceManager.cpp
+++ b/libs/binder/IServiceManager.cpp
@@ -28,6 +28,8 @@
2828
2929 #include <unistd.h>
3030
31+#define ADD_SERVICE_RETRY_SECS 10
32+
3133 namespace android {
3234
3335 sp<IServiceManager> defaultServiceManager()
@@ -155,13 +157,26 @@ public:
155157 virtual status_t addService(const String16& name, const sp<IBinder>& service,
156158 bool allowIsolated)
157159 {
158- Parcel data, reply;
159- data.writeInterfaceToken(IServiceManager::getInterfaceDescriptor());
160- data.writeString16(name);
161- data.writeStrongBinder(service);
162- data.writeInt32(allowIsolated ? 1 : 0);
163- status_t err = remote()->transact(ADD_SERVICE_TRANSACTION, data, &reply);
164- return err == NO_ERROR ? reply.readExceptionCode() : err;
160+ status_t err;
161+ for (int i=0; i<ADD_SERVICE_RETRY_SECS; i++) {
162+ Parcel data, reply;
163+ data.writeInterfaceToken(IServiceManager::getInterfaceDescriptor());
164+ data.writeString16(name);
165+ data.writeStrongBinder(service);
166+ data.writeInt32(allowIsolated ? 1 : 0);
167+ err = remote()->transact(ADD_SERVICE_TRANSACTION, data, &reply);
168+ if (err == NO_ERROR)
169+ return reply.readExceptionCode();
170+ if (i != ADD_SERVICE_RETRY_SECS) {
171+ ALOGI("addService() %s failed (err %d - no service manager yet?). Retrying...\n",
172+ String8(name).string(), err);
173+ sleep(1);
174+ } else {
175+ ALOGE("addService() %s failed (err %d). Giving up.\n",
176+ String8(name).string(), err);
177+ }
178+ }
179+ return err;
165180 }
166181
167182 virtual Vector<String16> listServices()
--- a/libs/gui/Sensor.cpp
+++ b/libs/gui/Sensor.cpp
@@ -335,10 +335,10 @@ size_t Sensor::getFlattenedSize() const
335335 sizeof(int32_t) * 5;
336336
337337 size_t variableSize =
338- sizeof(uint32_t) + FlattenableUtils::align<4>(mName.length()) +
339- sizeof(uint32_t) + FlattenableUtils::align<4>(mVendor.length()) +
340- sizeof(uint32_t) + FlattenableUtils::align<4>(mStringType.length()) +
341- sizeof(uint32_t) + FlattenableUtils::align<4>(mRequiredPermission.length());
338+ sizeof(size_t) + FlattenableUtils::align<sizeof(size_t)>(mName.length()) +
339+ sizeof(size_t) + FlattenableUtils::align<sizeof(size_t)>(mVendor.length()) +
340+ sizeof(size_t) + FlattenableUtils::align<sizeof(size_t)>(mStringType.length()) +
341+ sizeof(size_t) + FlattenableUtils::align<sizeof(size_t)>(mRequiredPermission.length());
342342
343343 return fixedSize + variableSize;
344344 }
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -1441,6 +1441,9 @@ EGLBoolean eglGetConfigs( EGLDisplay dpy,
14411441 if (egl_display_t::is_valid(dpy) == EGL_FALSE)
14421442 return setError(EGL_BAD_DISPLAY, EGL_FALSE);
14431443
1444+ if (ggl_unlikely(num_config==0))
1445+ return setError(EGL_BAD_PARAMETER, EGL_FALSE);
1446+
14441447 GLint numConfigs = NELEM(gConfigs);
14451448 if (!configs) {
14461449 *num_config = numConfigs;
--- a/opengl/libs/EGL/eglApi.cpp
+++ b/opengl/libs/EGL/eglApi.cpp
@@ -23,6 +23,7 @@
2323
2424 #include <hardware/gralloc.h>
2525 #include <system/window.h>
26+#include <sys/mman.h>
2627
2728 #include <EGL/egl.h>
2829 #include <EGL/eglext.h>
@@ -369,6 +370,35 @@ EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
369370 }
370371
371372 // ----------------------------------------------------------------------------
373+// Utility procedure to test a NativeWindowType for validity before referencing
374+// through the pointer. It's not feasible to test for deliberate forgeries,
375+// but this heuristic is good enough to test for basic accidental cases, using
376+// the special "magic" value placed in a native-window structure.
377+// ----------------------------------------------------------------------------
378+EGLBoolean isValidNativeWindow(NativeWindowType window)
379+{
380+ ANativeWindow *nwindow = static_cast<ANativeWindow*>(window);
381+ // the msync system call returns with ENOMEM error for unmapped memory
382+ // pages. This is used here as a way to test whether we can read through a
383+ // pointer without getting a segfault.
384+ uintptr_t pagesize = (uintptr_t) sysconf(_SC_PAGESIZE);
385+ uintptr_t addr = ((uintptr_t)(&nwindow->common.magic)) & (~(pagesize - 1));
386+ int rc = msync((void *)addr, pagesize, MS_ASYNC);
387+ if (0 == rc) {
388+ if (nwindow->common.magic == ANDROID_NATIVE_WINDOW_MAGIC)
389+ return EGL_TRUE;
390+ else
391+ return EGL_FALSE;
392+ }
393+ if (ENOMEM == errno)
394+ return EGL_FALSE;
395+ ALOGE("error unexpected msync error: %s (%d)",
396+ strerror(-errno), errno);
397+ return EGL_FALSE;
398+}
399+
400+
401+// ----------------------------------------------------------------------------
372402 // surfaces
373403 // ----------------------------------------------------------------------------
374404
@@ -408,6 +438,10 @@ EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
408438 if (dp) {
409439 EGLDisplay iDpy = dp->disp.dpy;
410440
441+ if (!isValidNativeWindow(window)) {
442+ ALOGE("EGLNativeWindow %p invalid", window);
443+ return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
444+ }
411445 int result = native_window_api_connect(window, NATIVE_WINDOW_API_EGL);
412446 if (result != OK) {
413447 ALOGE("eglCreateWindowSurface: native_window_api_connect (win=%p) "
--- a/opengl/libs/EGL/egl_object.cpp
+++ b/opengl/libs/EGL/egl_object.cpp
@@ -108,11 +108,6 @@ void egl_context_t::onMakeCurrent(EGLSurface draw, EGLSurface read) {
108108 // call the implementation's glGetString(GL_EXTENSIONS)
109109 const char* exts = (const char *)gEGLImpl.hooks[version]->gl.glGetString(GL_EXTENSIONS);
110110 gl_extensions.setTo(exts);
111- if (gl_extensions.find("GL_EXT_debug_marker") < 0) {
112- String8 temp("GL_EXT_debug_marker ");
113- temp.append(gl_extensions);
114- gl_extensions.setTo(temp);
115- }
116111 }
117112 }
118113
--- a/opengl/libs/EGL/getProcAddress.cpp
+++ b/opengl/libs/EGL/getProcAddress.cpp
@@ -78,7 +78,7 @@ namespace android {
7878
7979 #elif defined(__i386__)
8080
81- #define API_ENTRY(_api) __attribute__((noinline)) _api
81+ #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api
8282
8383 #define CALL_GL_EXTENSION_API(_api) \
8484 register void** fn; \
@@ -100,7 +100,7 @@ namespace android {
100100
101101 #elif defined(__x86_64__)
102102
103- #define API_ENTRY(_api) __attribute__((noinline)) _api
103+ #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api
104104
105105 #define CALL_GL_EXTENSION_API(_api) \
106106 register void** fn; \
--- a/opengl/libs/GLES2/gl2.cpp
+++ b/opengl/libs/GLES2/gl2.cpp
@@ -82,7 +82,7 @@ using namespace android;
8282
8383 #elif defined(__i386__)
8484
85- #define API_ENTRY(_api) __attribute__((noinline)) _api
85+ #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api
8686
8787 #define CALL_GL_API(_api, ...) \
8888 register void** fn; \
@@ -101,7 +101,7 @@ using namespace android;
101101
102102 #elif defined(__x86_64__)
103103
104- #define API_ENTRY(_api) __attribute__((noinline)) _api
104+ #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api
105105
106106 #define CALL_GL_API(_api, ...) \
107107 register void** fn; \
--- a/opengl/libs/GLES_CM/gl.cpp
+++ b/opengl/libs/GLES_CM/gl.cpp
@@ -138,7 +138,7 @@ GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type,
138138
139139 #elif defined(__i386__)
140140
141- #define API_ENTRY(_api) __attribute__((noinline)) _api
141+ #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api
142142
143143 #define CALL_GL_API(_api, ...) \
144144 register void* fn; \
@@ -157,7 +157,7 @@ GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type,
157157
158158 #elif defined(__x86_64__)
159159
160- #define API_ENTRY(_api) __attribute__((noinline)) _api
160+ #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api
161161
162162 #define CALL_GL_API(_api, ...) \
163163 register void** fn; \
--- a/opengl/tests/EGLTest/EGL_test.cpp
+++ b/opengl/tests/EGLTest/EGL_test.cpp
@@ -53,6 +53,13 @@ protected:
5353 }
5454 };
5555
56+TEST_F(EGLTest, EGLGetConfigsWithNullNumConfigs) {
57+ EGLBoolean success;
58+ success = eglGetConfigs(mEglDisplay, NULL, 0, NULL);
59+ ASSERT_EQ(EGL_FALSE, success);
60+ ASSERT_EQ(EGL_BAD_PARAMETER, eglGetError());
61+}
62+
5663 TEST_F(EGLTest, DISABLED_EGLConfigEightBitFirst) {
5764
5865 EGLint numConfigs;
--- a/opengl/tests/EGLTest/egl_cache_test.cpp
+++ b/opengl/tests/EGLTest/egl_cache_test.cpp
@@ -41,7 +41,7 @@ protected:
4141 };
4242
4343 TEST_F(EGLCacheTest, UninitializedCacheAlwaysMisses) {
44- char buf[4] = { 0xee, 0xee, 0xee, 0xee };
44+ unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
4545 mCache->setBlob("abcd", 4, "efgh", 4);
4646 ASSERT_EQ(0, mCache->getBlob("abcd", 4, buf, 4));
4747 ASSERT_EQ(0xee, buf[0]);
@@ -51,7 +51,7 @@ TEST_F(EGLCacheTest, UninitializedCacheAlwaysMisses) {
5151 }
5252
5353 TEST_F(EGLCacheTest, InitializedCacheAlwaysHits) {
54- char buf[4] = { 0xee, 0xee, 0xee, 0xee };
54+ unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
5555 mCache->initialize(egl_display_t::get(EGL_DEFAULT_DISPLAY));
5656 mCache->setBlob("abcd", 4, "efgh", 4);
5757 ASSERT_EQ(4, mCache->getBlob("abcd", 4, buf, 4));
@@ -62,7 +62,7 @@ TEST_F(EGLCacheTest, InitializedCacheAlwaysHits) {
6262 }
6363
6464 TEST_F(EGLCacheTest, TerminatedCacheAlwaysMisses) {
65- char buf[4] = { 0xee, 0xee, 0xee, 0xee };
65+ unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
6666 mCache->initialize(egl_display_t::get(EGL_DEFAULT_DISPLAY));
6767 mCache->setBlob("abcd", 4, "efgh", 4);
6868 mCache->terminate();
@@ -94,7 +94,7 @@ protected:
9494 };
9595
9696 TEST_F(EGLCacheSerializationTest, ReinitializedCacheContainsValues) {
97- char buf[4] = { 0xee, 0xee, 0xee, 0xee };
97+ unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
9898 mCache->setCacheFilename(mFilename);
9999 mCache->initialize(egl_display_t::get(EGL_DEFAULT_DISPLAY));
100100 mCache->setBlob("abcd", 4, "efgh", 4);
--- a/services/inputflinger/EventHub.cpp
+++ b/services/inputflinger/EventHub.cpp
@@ -1065,8 +1065,17 @@ static const int32_t GAMEPAD_KEYCODES[] = {
10651065 };
10661066
10671067 status_t EventHub::openDeviceLocked(const char *devicePath) {
1068+ return openDeviceLocked(devicePath, false);
1069+}
1070+
1071+status_t EventHub::openDeviceLocked(const char *devicePath, bool ignoreAlreadyOpened) {
10681072 char buffer[80];
10691073
1074+ if (ignoreAlreadyOpened && (getDeviceByPathLocked(devicePath) != 0)) {
1075+ ALOGV("Ignoring device '%s' that has already been opened.", devicePath);
1076+ return 0;
1077+ }
1078+
10701079 ALOGV("Opening device: %s", devicePath);
10711080
10721081 int fd = open(devicePath, O_RDWR | O_CLOEXEC);
@@ -1264,7 +1273,11 @@ status_t EventHub::openDeviceLocked(const char *devicePath) {
12641273
12651274 // 'Q' key support = cheap test of whether this is an alpha-capable kbd
12661275 if (hasKeycodeLocked(device, AKEYCODE_Q)) {
1267- device->classes |= INPUT_DEVICE_CLASS_ALPHAKEY;
1276+ char value[PROPERTY_VALUE_MAX];
1277+ property_get("ro.ignore_atkbd", value, "0");
1278+ if ((device->identifier.name != "AT Translated Set 2 keyboard") || (!atoi(value))) {
1279+ device->classes |= INPUT_DEVICE_CLASS_ALPHAKEY;
1280+ }
12681281 }
12691282
12701283 // See if this device has a DPAD.
@@ -1588,7 +1601,7 @@ status_t EventHub::readNotifyLocked() {
15881601 if(event->len) {
15891602 strcpy(filename, event->name);
15901603 if(event->mask & IN_CREATE) {
1591- openDeviceLocked(devname);
1604+ openDeviceLocked(devname, true);
15921605 } else {
15931606 ALOGI("Removing device '%s' due to inotify event\n", devname);
15941607 closeDeviceByPathLocked(devname);
--- a/services/inputflinger/EventHub.h
+++ b/services/inputflinger/EventHub.h
@@ -371,6 +371,7 @@ private:
371371 };
372372
373373 status_t openDeviceLocked(const char *devicePath);
374+ status_t openDeviceLocked(const char *devicePath, bool ignoreAlreadyOpened);
374375 void createVirtualKeyboardLocked();
375376 void addDeviceLocked(Device* device);
376377 void assignDescriptorLocked(InputDeviceIdentifier& identifier);
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -400,7 +400,7 @@ status_t HWComposer::queryDisplayProperties(int disp) {
400400 }
401401
402402 // FIXME: what should we set the format to?
403- mDisplayData[disp].format = HAL_PIXEL_FORMAT_RGBA_8888;
403+ mDisplayData[disp].format = HAL_PIXEL_FORMAT_BGRA_8888;
404404 mDisplayData[disp].connected = true;
405405 return NO_ERROR;
406406 }
@@ -823,7 +823,7 @@ int HWComposer::getVisualID() const {
823823 // FIXME: temporary hack until HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED
824824 // is supported by the implementation. we can only be in this case
825825 // if we have HWC 1.1
826- return HAL_PIXEL_FORMAT_RGBA_8888;
826+ return HAL_PIXEL_FORMAT_BGRA_8888;
827827 //return HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
828828 } else {
829829 return mFbDev->format;
--- a/services/surfaceflinger/EventThread.cpp
+++ b/services/surfaceflinger/EventThread.cpp
@@ -276,11 +276,11 @@ Vector< sp<EventThread::Connection> > EventThread::waitForEvent(
276276 }
277277
278278 // Here we figure out if we need to enable or disable vsyncs
279- if (timestamp && !waitForVSync) {
280- // we received a VSYNC but we have no clients
281- // don't report it, and disable VSYNC events
279+ if (!waitForVSync) {
280+ // we have no clients waiting on next VSYNC
281+ // just disable VSYNC events.
282282 disableVSyncLocked();
283- } else if (!timestamp && waitForVSync) {
283+ } else if (!timestamp) {
284284 // we have at least one client, so we want vsync enabled
285285 // (TODO: this function is called right after we finish
286286 // notifying clients of a vsync, so this call will be made
Show on old repository browser