Gamma correction was incorrectly skewing both color inversion and
Daltonization, which resulted in washed-out colors.
Bug: 20346301
Change-Id: I34d879f902c3be115b2d23f09c3ed3902799759e
(cherry picked from commit 3acd9f1d8f)
Gamma correction was incorrectly skewing both color inversion and
Daltonization, which resulted in washed-out colors.
Bug: 20346301
Change-Id: I34d879f902c3be115b2d23f09c3ed3902799759e
Adds a new method IGBP::allowAllocation, which controls whether
dequeueBuffer is permitted to allocate a new buffer. If allocation is
disallowed, dequeueBuffer will block or return an error as it
normally would (as controlled by *ControlledByApp).
If there are free buffers, but they are not of the correct dimensions,
format, or usage, they may be freed if a more suitable buffer is not
found first.
Bug: 19801715
Change-Id: I0d604958b78b2fd775c2547690301423f9a52165
On normal Layers, we defer applying resize transactions until a buffer
of the correct size arrives. This breaks with sideband streams, because
buffers are not seen by SurfaceFlinger. This change applies
transactions immediately for Layers which have a sideband stream
attached to avoid that problem.
Bug: 20428254
Change-Id: I379d8aaef460d467cdf8432764b4a504928fb65a
(cherry picked from commit c300b8b506536e1bf94ffd8a3b75d46e776923e0)
Temporarily increase the stylus timeout while we figure out where the
delay in BT information is coming from.
Change-Id: I27ab5a4db4ad14358c6e6803961612420371fce9
Sometimes stylus data will be delayed by 30 - 40ms. By increasing the
timeout we pretty much always pick up stylus data and the touch
latency feels surprisingly small.
Change-Id: I39f5b9037ce0444b1e957149d3f1c3a3137804cb
This prevents us from dropping any states (namely the pressure
transition from non-zero to zero) if we get the touch up before we
get the stylus data.
Change-Id: Ifc198628d35b7079dc5ec23d81f9681d122757a0
This modifies EventThread such that its phase offsets for both
Choreographer and SurfaceFlinger may be modified at runtime. It also
plumbs this functionality up to the SurfaceFlinger debug interface so
that it is possible to rapidly test different offsets without
restarting the framework.
Change-Id: I426873f8553f931250dfebc9a8a4a78e9f1f4309
Passes the surface damage from the incoming SurfaceFlingerConsumer
BufferQueue down to the hardware composer HAL interface, if the
HWC version number is 1.5 or greater.
Bug: 11239309
Change-Id: Ic4305210593874a8d6deba3319055b2b8c57e926
To avoid nan or infinity when orientation value is used for
calculation without being initialized, check mOrientedRanges.haveOrientation
value before using mOrientedRanges.orientation.min or .max value.
Change-Id: I68ed9ab36819c5faa6422e9f061e1275aeed11e3
Signed-off-by: Baik Han <baik.han@lge.com>
Early during the boot, before activity manager is ready to handle
permission checks, the system needs to be able to change the display
state. Added a hardcoded exemption for AID_SYSTEM (which already
has permission to talk to surface flinger anyhow).
Bug: 19029490
Change-Id: I6222edcab8e394e5fb6adf7a982be446e4505a1e
Add dataSpace to buffer queues; remove old format enums.
(cherry picked from commit 82c6bcc970)
libgui: Prepare for IGBC::BufferItem removal
(cherry picked from commit cf3834db10)
SurfaceFlinger: Stop using IGBC::BufferItem
(cherry picked from commit 11611f9be5)
Change-Id: Ic2e4770b916d2d1477e5ce98c4b49a0072ea03ff
(cherry picked from commit 6c45010175)
In restricted mode, only CTS tests can register for sensors or call flush() on them. The requests
from other applications will be ignored.
Change-Id: Ieb923df3e0cfe3390fe2d052af776da79589744b
Switches all uses of IGraphicBufferConsumer::BufferItem (and
BufferQueue::BufferItem) to the BufferItem in libgui. Depends on
frameworks/native I699ed0a6837076867ca756b28d1ffb2238f7a0d9.
Cherry pick of I187b3a7d05196b6289596afac8fb9a9d4aebff76
Change-Id: I5bc79fb96b6cba6021af64b20890967aa3b7fcbf
- Wire up new dataSpace parameter through buffer queue stack
- Update tests to include the parameter
- Switch eglApi to using dataSpace to indicate sRGB gamma/linear
difference
- Remove RAW_SENSOR in favor of RAW16
- Remove use of sRGB format enums
- Add default dataspace to buffer queue core
- Add query for default dataspace
Cherry pick of I070bd2e7c56506055c419004c29e2e3feac725df
Change-Id: I461952389c18051176c6b75e664f20ad369f5760
Enables -Weverything and -Werror, with just a few exceptions for
warnings we can't (or shouldn't need to) work around.
Cherry pick of I034abec27bf4020d84af60d7acc1939c59986dd6 plus a
couple of minor changes to CpuConsumer.cpp to make it work with a
prior change:
Uncomment CC_LOGV on line 46
Change C-style cast to static_cast on line 71
Change-Id: Iaec610477ea0122317b0578fb74caf2383d4cf08
Switches all uses of IGraphicBufferConsumer::BufferItem (and
BufferQueue::BufferItem) to the BufferItem in libgui. Depends on
frameworks/native I699ed0a6837076867ca756b28d1ffb2238f7a0d9.
Change-Id: I187b3a7d05196b6289596afac8fb9a9d4aebff76
Adds a --static-screen option to dumpsys SurfaceFlinger, which
displays screen-on time broken down by the time between the prior
frame and the current frame. An example dump looks like this:
$ adb shell dumpsys SurfaceFlinger --static-screen
Static screen stats:
< 1 frames: 12.235 s (3.5%)
< 2 frames: 29.898 s (8.7%)
< 3 frames: 15.370 s (4.4%)
< 4 frames: 13.103 s (3.8%)
< 5 frames: 15.780 s (4.6%)
< 6 frames: 2.022 s (0.6%)
< 7 frames: 0.201 s (0.1%)
7+ frames: 256.887 s (74.4%)
The buckets are exclusive, so '< 3 frames' covers the interval
[2, 3) frames
Bug: 19543586
Change-Id: I3253a54c23995d25e96016997acedd0775956b60
- Wire up new dataSpace parameter through buffer queue stack
- Update tests to include the parameter
- Switch eglApi to using dataSpace to indicate sRGB gamma/linear
difference
- Remove RAW_SENSOR in favor of RAW16
- Remove use of sRGB format enums
- Add default dataspace to buffer queue core
- Add query for default dataspace
Change-Id: I070bd2e7c56506055c419004c29e2e3feac725df
Tests always get built with the platform now anyways. Also, remove
the dependency on libandroidfw since it causes issues on PDK builds.
Change-Id: Ib73ec620abac3782d9fdae48778064c06b30aae0
frameworks/native/services/surfaceflinger/tests/vsync/vsync.cpp:55:44: error: 'ALOOPER_EVENT_INPUT' was not declared in this scope
loop->addFd(myDisplayEvent.getFd(), 0, ALOOPER_EVENT_INPUT, receiver,
^
frameworks/native/services/surfaceflinger/tests/vsync/vsync.cpp:64:18: error: 'ALOOPER_POLL_WAKE' was not declared in this scope
case ALOOPER_POLL_WAKE:
^
frameworks/native/services/surfaceflinger/tests/vsync/vsync.cpp:67:18: error: 'ALOOPER_POLL_CALLBACK' was not declared in this scope
case ALOOPER_POLL_CALLBACK:
^
frameworks/native/services/surfaceflinger/tests/vsync/vsync.cpp:70:18: error: 'ALOOPER_POLL_TIMEOUT' was not declared in this scope
case ALOOPER_POLL_TIMEOUT:
^
frameworks/native/services/surfaceflinger/tests/vsync/vsync.cpp:73:18: error: 'ALOOPER_POLL_ERROR' was not declared in this scope
case ALOOPER_POLL_ERROR:
^
it is missing one header file
Change-Id: Ie2fb02523a866b13a99edf837f072d101cacb466
Signed-off-by: Nanik Tolaram <nanikjava@gmail.com>
The waitforvsync.cpp throws error when compiling. Following is the error log
target thumb C++: test-waitforvsync <= frameworks/native/services/surfaceflinger/tests/waitforvsync/waitforvsync.cpp
frameworks/native/services/surfaceflinger/tests/waitforvsync/waitforvsync.cpp: In function 'int main(int, char**)':
frameworks/native/services/surfaceflinger/tests/waitforvsync/waitforvsync.cpp:43:17: error: 'close' was not declared in this scope
close(fd);
^
....
....
make: *** [out/target/product/grouper/obj/EXECUTABLES/test-waitforvsync_intermediates/waitforvsync.o] Error 1
the file is missing #include <unistd.h>
Change-Id: I57728dbde65641cd3138625f9a590f9db8648158
Signed-off-by: Nanik Tolaram <nanikjava@gmail.com>
When the touch firmware or driver sends a key event that is triggered
by a low-level gesture such as a palm slap. For this to work, the
touch device's .kl file must specify the "GESTURE" flag for each
key that is produced by a gesture.
Note that the "VIRTUAL" flag should also be specified for any such
keys for which we would like to generate haptic feedback.
eg. key 142 SLEEP VIRTUAL GESTURE
Bug: 19264992
Change-Id: Ief494ec7e3ca66d2358a1001fdfae4f263ee1cd1
This tracks fds when layers are created and destroyed in an effort to
determine which specific app (if any) is active when fds are leaked
Bug: 19017008
Change-Id: I1f1d5a9cbc1399e3df3a2d350324f80b3a4e3477
Rather than trying to acquire the state lock without waiting three
times at 1 second intervals in SurfaceFlinger::dump(), just try to
acquire the lock once with a 1 second timeout. Avoids spurious mutex
acquire failures that lead to flaky
com.android.cts.jank.opengl.CtsHostJankOpenGl results.
Bug: 18842510
Change-Id: I00ce6109647de2aef8831dd2f8fa98652ba7f4e0
This code doesn't need to run on the Mac, and the BoringSSL transition
will be easier without references to external/openssl.
Change-Id: I14ea11fa2911af0f4e95e69636e6a2c26126cbe0
Use LOCAL_WHOLE_STATIC_LIBRARIES to instruct static linker
to export symbols from the static library.
(cherry picked from commit 4340a14fbf)
Bug: 18701723
Change-Id: I70f6fdb64b0d1adbadf96c8de85870a903ec186a
Enables -Weverything and -Werror, with just a few exceptions for
warnings we can't (or shouldn't need to) work around.
This is a squashed commit based on an initial change with a couple of
fixes to avoid breaking certain targets. The source commits are:
d723bd766900d504c06e429ba89cd2
Change-Id: I034abec27bf4020d84af60d7acc1939c59986dd6
Enables -Weverything and -Werror, with just a few exceptions for
warnings we can't (or shouldn't need to) work around.
Change-Id: I034abec27bf4020d84af60d7acc1939c59986dd6
Enables clang and C++11 for libui/libgui/surfaceflinger, and
eliminates all compile-time warnings.
Change-Id: Ie237fdb5ae44f2bfcddaa884f9c65ec3f08ae50f
(cherry picked from commit f10c46ef85)
"Do less work when using PTS" broke the invalidate path up from HWC
to SurfaceFlinger. When HWC would signal an invalidate, SurfaceFinger
would wake up, see no new buffers, and go back to sleep. This is fine,
except when the invalidate is a result of an HDMI hotplug, in which
case the screen remains blank. This change makes that functionality
work again.
Bug: 18564815
Bug: 18558468
Change-Id: I2e2171d86839945f4e4e6555d66f7e2895bd096a
Count items as they are added and removed rather than iterating over the
entire list to count them.
Increases performance slightly, particularly when tracing is turned on,
which causes count to be queried more often, and when the number of
items in the queues grow large. This can happen due to applications not
responding, for example.
Change-Id: I0f11f7edd46089612af910cdfabfeb3ee685d7d9
clang warns about SensorEventConnection::dump overloading BBinder::dump
in some conditions.
Since the cause isn't fixable without changing the API, tell clang not
to error out on it.
Change-Id: I15659de7c5499d937019599cfefb01305039e6b5
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
A sensor name containing a format string could have interesting side
effects...
Change-Id: If7f1378aa68572d9716c339728eab18faa6b9f2a
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
Ensure that the adjusted transparent region is within
the display bounds by clamping after the transformation
is applied and clean up transform's inverse function.
Bug: 18452546
Change-Id: Ia473e483ee8374177bcb84d8192eb1f0e86f022a
* Explicit conversion for atomic_uintptr_t initialization.
* Fix string literal concatenation to not be a UD literal.
* Use __typeof__ instead of typeof (should become decltype once this
actually moves to C++11).
Bug: 18466763
Change-Id: I4eedddfb945a2a703ed27317cb6e2b3041b1ebfc
Currently, SurfaceFlinger is very dumb about how it handles buffer
updates at less than 60fps. If there is a new frame pending, but its
timestamp says not to present it until later SurfaceFlinger will wake
up every vsync until it is time to present it. Even worse, if
SurfaceFlinger has woken up but nothing has changed, it still goes
through the entire composition process.
This change (mostly) fixes that inefficiency. SurfaceFlinger will
still wake up every refresh period while there is a new frame
pending, but if there is no work to do, it will almost immediately go
back to sleep.
Bug: 18111837
Change-Id: I7825bacd37f40bf26edcc6a5e0f051dce45291fb
keyBitmask and ledBitmask are arrays, "!their address" always evaluates to
false. clang complains about this.
Change-Id: I6aed45a203b0eeaad2093dbdebea03a2c2fc1a3d
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
so we can do NULL checks again, and update calls to IInterface::asBinder()
to use the new static version.
Change-Id: Ia7b10eb38ca55b72278bfd33d3bf647f338b4e6a
I'm pretty sure I had done this before... Must have been new
dependencies that slipped in when L merged in.
Bug: 15193147
Change-Id: Ib9b1b8a65665d25c33c6141b9476a8e13c4084e0
so we can do NULL checks again, and update calls to IInterface::asBinder()
to use the new static version.
Change-Id: Ia7b10eb38ca55b72278bfd33d3bf647f338b4e6a
Enables clang and C++11 for libui/libgui/surfaceflinger, and
eliminates all compile-time warnings.
Change-Id: Ie237fdb5ae44f2bfcddaa884f9c65ec3f08ae50f
This code is no longer necessary and was preventing input from
reaching their desired windows. See bug 17648830.
Change-Id: Ib1c026ece70e6fa98343340b89af4199d6d0ffca
Passes the BufferItem for the queued buffer to the onFrameAvailable
callback so the consumer can track the BufferQueue's contents. Also
adds an onFrameReplaced callback, which is necessary if the consumer
wants to do anything more than simple queue length tracking.
Bug: 18111837
Change-Id: If9d07229c9b586c668e5f99074e9b63b0468feb0
Validate the display binder by adding a NULL check in getDisplayConfigs.
This will prevent a false match if the caller queries the display
configs for an inactive display (whose binder is NULL by default).
Without this change we might end up attempting to index the display
config array, which is unpopulated for inactive displays, and this will
result in a crash. (See getDisplayInfo in SurfaceComposerClient.cpp for
an example of this scenario)
Change-Id: I1a12f43b7c375b9c01998dadd5b658275c733fb2
Acked-by: Tatenda Chipeperekwa <tatendac@codeaurora.org>
If SensorService is holding a wake_lock and there are no acknowledgements
from ANY app within 5 seconds, release the wake_lock and reset the wake_lock
refcounts for all connections.
Bug: 16874240
Change-Id: I5e950dd393c20173c439cbd5a4ba614ee09d61f4
warning: comparison of integers of different signs: 'int' and 'size_t'
(aka 'unsigned int') [-Wsign-compare]
arning: comparison of integers of different signs: 'int32_t' (aka
'int') and 'const uint32_t' (aka 'const unsigned int')
[-Wsign-compare]
Change-Id: I823257aa7218c5fd492a3277853210db539bb2e2
(cherry picked from f9bfdc6c94)
warning: struct 'HWComposer' was previously declared as a class
[-Wmismatched-tags]
warning: class 'DisplayInfo' was previously declared as a struct
[-Wmismatched-tags]
Change-Id: I13db9f8aab3a957ce8ff8d64598dae1807d6fe7e
(cherry picked from commit 646f541050)
This change watches for a MAX_VIRTUAL_DISPLAY_DIMENSION value, which
will be set (if necessary) in BoardConfig.mk. If the value is set,
any virtual displays that have a width or a height greater than that
dimension will bypass the hardware composer HAL and be handled only
by SurfaceFlinger.
Bug: 17701816
Change-Id: Ia6ca44dfd6a7a9bc0f054493d3f13006bc32fa14
After creating a syncKHR object with type EGL_SYNC_NATIVE_FENCE_ANDROID,
glFlush must be called before the EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute
is populated with a sync fd. We currently call eglDupNativeFenceFDANDROID
before issuing the flush.
Bug 18052459
Taken verbatim from matthew.k.gumbel@intel.com.
Change-Id: I3781d14f92862076e2bca7d27341a6dc6e7e3775
ANativeWindow::queueBuffer takes ownership of the fence fd passed to
it, and will close it before returning. SurfaceFlinger's screenshot
code was also closing the syncFd it passed to queueBuffer. Most of the
time this meant the second close() silently failed, but in a rare race
condition the file descriptor could be reused between the two
close()s.
Bug: 17946343
Change-Id: Ib74fcb1dce52cc21328059c99b7c4c76f41aa3a5
Use LOCAL_WHOLE_STATIC_LIBRARIES to instruct static linker
to export symbols from the static library.
Change-Id: I0e41cf173be96c52cdad72b1ef4a1bf819e65dd2
And export necessary symbols to preempt calls from libart.so
Bug: 15345057
Bug: 15426766
(cherry picked from commit f3da24d8cf)
Change-Id: I03b632e0bf2cbaf4a0e68cd0af4e991f7f6b08e4
Print more details about the exact reason that an ANR has occurred.
Also start checking that the window actually has a registered
input connection that is not in a broken state. These windows
are supposed to be cleaned up by the window manager promptly
as if the app had crashed but the pattern of ANRs we are observing
suggests that broken windows might be sticking around longer than
they should.
Bug: 17721767
Change-Id: Ie2803a3fa9642381ecadc198fec15e1b70d93c20
Blobcache is not yet enabled for surfaceflinger (as it should be).
As a temporary workaround, generate all needed shaders during
surfaceflinger initialization instead of doing the compilation
on-demand during ui transitions.
Change-Id: I14455b20a3f85f177d85c9c8b76d8ccc35379b39
i) Call removeFd() only if the fd in the BitTube has been
previously added to the Looper. Use a flag to determine whether the fd
has been previously added or not.
ii) Increment mPendingFlushEventsToSend after holding a connectionLock.
iii) Store the number of acks that are pending in SensorEventQueue
and send them all at once.
Bug: 17472228
Change-Id: I1ec834fea1112a9cfbd9cddd2198438793698502
Blobcache is not yet enabled for surfaceflinger (as it should be).
As a temporary workaround, generate all needed shaders during
surfaceflinger initialization instead of doing the compilation
on-demand during ui transitions.
Change-Id: I14455b20a3f85f177d85c9c8b76d8ccc35379b39
We normally recompute layer visibility when a layer gets its first
buffer; before then it's treated as invisible. Sideband layers never
get a buffer (as far as SurfaceFlinger knows), so never became
visible. Now we also recompute visibility when a layer gets a new
sideband stream.
Bug: 17752511
Change-Id: I84e150f196eb2eb7bcd2616248e5e3fa73624809
* commit 'b17044adcf951b66ce2ecb7f7835572d7448bd64':
Revert "Fix sockfd leakage in SensorService. Remove sockfd from Looper when the connection is removed from mActiveConnections."
When HWC doesn't provide DPI values for a display, we pick a default
DPI based on resolution. The intent was that 1080p and higher displays
would get XHIGH density, and lower resolutions would get TV density.
In KK (and possibly forever) we had a bug that we'd always use TV
density. That was fixed in L, but that fix exposed a pre-existing bug
that we always used the display's height in its native orientation,
rather than in landscape orientation. So an 800x1280 tablet like N7v1
started getting XHIGH density instead of the intended TV density.
Bug: 17461633
Change-Id: Ia57fa49e61f36bdda63ce283ef62c9953297222c
If the destructor of SensorEventConnection gets called when the main
sendEvents loop of SensorService is executing it may result in a deadlock.
The loop promotes each connection to a strong_pointer, calls sendEvents
and cleans up the connection if necessary. It is possible that the sp's
destructor may delete SensorEventConnection which will call the dtor
~SensorEventConnection(). This dtor again needs SensorService mLock to
execute which may result in a deadlock.
Bug: 17617897
Change-Id: I76c244dbe85fadb591c0bd1a9a5eb01d93f56505
* commit '71e351d96b551ccdbc39b52a0c66da86cae83701':
Revert "Fix sockfd leakage in SensorService. Remove sockfd from Looper when the connection is removed from mActiveConnections."
* commit '71e351d96b551ccdbc39b52a0c66da86cae83701':
Revert "Fix sockfd leakage in SensorService. Remove sockfd from Looper when the connection is removed from mActiveConnections."
* commit '8f12365b768a05e7e28094e3e90ff01afca284ba':
Fix sockfd leakage in SensorService. Remove sockfd from Looper when the connection is removed from mActiveConnections.
* commit '5105960d49bfa86efeeea8f87c87aa96b5771c37':
Fix sockfd leakage in SensorService. Remove sockfd from Looper when the connection is removed from mActiveConnections.
* commit '5105960d49bfa86efeeea8f87c87aa96b5771c37':
Fix sockfd leakage in SensorService. Remove sockfd from Looper when the connection is removed from mActiveConnections.
This is used by media service to schedule video frames at the
proper time, based on precise vsync timings.
Bug: 14659809
Change-Id: I1a90603f3dc09dca9aa4f90a3aa845fab56e0a5e
i) Initialize sensor_event.flags to zero or wake_up flag before sending dropped flush_complete_events. This will avoid unnecessary acks.
Currently it is not set to anything which may result in garbage values for flags field.
ii) Change the dump format of SensorEventConnection.
iii) Add const to method signatures wherever applicable.
Bug id: https://b2.corp.google.com/issues/17498626
Change-Id: Ia736ffb01c366540aab73cdcf596ce852c052593
i) Significant Motion multiple clients fix. Make a copy of
mActiveConnections vector before cleaning up SensorEventConnections
when one-shot sensors trigger.
ii) Maintain a mapping between flush_complete_events and
SensorEventConnections to accurately map flush() API calls and
corresponding flush_complete_events
iii) Remove all references to 1_1 and 1_2 HALs.
iv) Dynamically allocate sensor_event buffers in SensorService main
threadLoop.
Bug: 17412359
Change-Id: If3c3986197660cafef2d2e0b4dc7582e229cf1c4
+ This is needed so that activity manager does not
have to do cpu side rotations when capturing recents
thumbnails.
Change-Id: If998008e675ad01305db8399fd643cf4608b7025
But provide a temporary escape hatch for AudioFlinger.
This oneway option will be removed as soon as possible.
Bug: 16408906
Change-Id: I20d6da1969ae05b96e72795463470eb4c1f8fbdc
warning: comparison of integers of different signs: 'int' and 'size_t'
(aka 'unsigned int') [-Wsign-compare]
arning: comparison of integers of different signs: 'int32_t' (aka
'int') and 'const uint32_t' (aka 'const unsigned int')
[-Wsign-compare]
Change-Id: I823257aa7218c5fd492a3277853210db539bb2e2
make all binder call to power manager service one way so that
they don't block calling thread and are processed in the
incoming order.
Bug: 16408906.
Change-Id: I94034df7f0a36d967e085b53fdc37fff7b44757b
warning: struct 'HWComposer' was previously declared as a class
[-Wmismatched-tags]
warning: class 'DisplayInfo' was previously declared as a struct
[-Wmismatched-tags]
Change-Id: I13db9f8aab3a957ce8ff8d64598dae1807d6fe7e
i) Fix a possible race condition when adding a pending flush connection
to mActiveSensors data structure.
ii) Invalidate flush_complete_events as soon as they are consumed by a
connection so that they are not used by other connections which are
registered for the same sensor.
Change-Id: I1491bea8c2081c4aab1feacc60add13b7aa26bb7
This makes it possible to tell whether two HW vsync signals are too
far apart because one was late, or because we turned HW vsync off
briefly between them.
Bug: 17259382
Change-Id: If4fba2a8a6013568349949ce87c5c36f0468d2a2
1) Limit maxEventsToWrite depending on the size of the socket
buffer allocated (Fix for write failure on manta).
2) Do not call flush() if the sensor is not activated (OEM issue).
Change-Id: I81ea78dbdef3a3773af505ca1c9a5e39492c0b48