From e6f6ad04ed1e0e73fc260a0100d5759a0456fdd6 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Mon, 22 Jun 2015 16:18:21 +0100 Subject: [PATCH 01/21] DO NOT MERGE. Cancel touches as well as pointer gestures. Bug: 19264992 Change-Id: If48e0953b972c9d69f516906adf7c6faf67e3eb8 --- services/inputflinger/InputReader.cpp | 29 ++++++++++++++++++++++++--- services/inputflinger/InputReader.h | 4 ++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp index ccf8ced55..006ec6bb8 100644 --- a/services/inputflinger/InputReader.cpp +++ b/services/inputflinger/InputReader.cpp @@ -3721,6 +3721,7 @@ void TouchInputMapper::reset(nsecs_t when) { mLastMouseIdBits.clear(); mPointerUsage = POINTER_USAGE_NONE; mSentHoverEnter = false; + mCurrentMotionAborted = false; mDownTime = 0; mCurrentVirtualKey.down = false; @@ -3874,10 +3875,15 @@ void TouchInputMapper::sync(nsecs_t when) { mCurrentCookedPointerData.idToIndex, mCurrentCookedPointerData.touchingIdBits); } + if (!mCurrentMotionAborted) { + dispatchHoverExit(when, policyFlags); + dispatchTouches(when, policyFlags); + dispatchHoverEnterAndMove(when, policyFlags); + } - dispatchHoverExit(when, policyFlags); - dispatchTouches(when, policyFlags); - dispatchHoverEnterAndMove(when, policyFlags); + if (mCurrentCookedPointerData.pointerCount == 0) { + mCurrentMotionAborted = false; + } } // Synthesize key up from raw buttons if needed. @@ -4018,6 +4024,22 @@ void TouchInputMapper::dispatchVirtualKey(nsecs_t when, uint32_t policyFlags, getListener()->notifyKey(&args); } +void TouchInputMapper::abortTouches(nsecs_t when, uint32_t policyFlags) { + BitSet32 currentIdBits = mCurrentCookedPointerData.touchingIdBits; + if (!currentIdBits.isEmpty()) { + int32_t metaState = getContext()->getGlobalMetaState(); + int32_t buttonState = mCurrentButtonState; + dispatchMotion(when, policyFlags, mSource, AMOTION_EVENT_ACTION_CANCEL, 0, + metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE, + mCurrentCookedPointerData.pointerProperties, + mCurrentCookedPointerData.pointerCoords, + mCurrentCookedPointerData.idToIndex, + currentIdBits, -1, + mOrientedXPrecision, mOrientedYPrecision, mDownTime); + mCurrentMotionAborted = true; + } +} + void TouchInputMapper::dispatchTouches(nsecs_t when, uint32_t policyFlags) { BitSet32 currentIdBits = mCurrentCookedPointerData.touchingIdBits; BitSet32 lastIdBits = mLastCookedPointerData.touchingIdBits; @@ -5733,6 +5755,7 @@ void TouchInputMapper::fadePointer() { void TouchInputMapper::cancelTouch(nsecs_t when) { abortPointerUsage(when, 0 /*policyFlags*/); + abortTouches(when, 0 /* policyFlags*/); } bool TouchInputMapper::isPointInsideSurface(int32_t x, int32_t y) { diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h index 34f20af47..62cd36a57 100644 --- a/services/inputflinger/InputReader.h +++ b/services/inputflinger/InputReader.h @@ -1364,6 +1364,9 @@ protected: // True if we sent a HOVER_ENTER event. bool mSentHoverEnter; + // Is the current stream of direct touch events aborted + bool mCurrentMotionAborted; + // The time the primary pointer last went down. nsecs_t mDownTime; @@ -1688,6 +1691,7 @@ private: void dispatchPointerUsage(nsecs_t when, uint32_t policyFlags, PointerUsage pointerUsage); void abortPointerUsage(nsecs_t when, uint32_t policyFlags); + void abortTouches(nsecs_t when, uint32_t policyFlags); void dispatchPointerGestures(nsecs_t when, uint32_t policyFlags, bool isTimeout); void abortPointerGestures(nsecs_t when, uint32_t policyFlags); From e6406e3589fa490bfa435384d2a3a6ac678e08fd Mon Sep 17 00:00:00 2001 From: Aravind Akella Date: Mon, 20 Jul 2015 17:29:33 -0700 Subject: [PATCH 02/21] Check for the presence of accel and magnetometer sensors before adding AOSP fusion sensors. DO NOT MERGE Bug: 22502485 Change-Id: I3d9018649302b98004e4e216b2173e8411a08501 (cherry picked from commit f504789dd3b3073de176fd2fa09dd9fc9de5bc1f) --- services/sensorservice/SensorService.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index c316ef6eb..30ec45834 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -82,7 +82,7 @@ void SensorService::onFirstRef() ssize_t count = dev.getSensorList(&list); if (count > 0) { ssize_t orientationIndex = -1; - bool hasGyro = false; + bool hasGyro = false, hasAccel = false, hasMag = false; uint32_t virtualSensorsNeeds = (1< Date: Fri, 24 Jul 2015 02:01:13 -0700 Subject: [PATCH 03/21] Dump raft logs in bugreports if they exist. Change-Id: I7773b8b86675d9ebf3f6d158eaaa11e47619800e --- cmds/dumpstate/dumpstate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index 1d9e6b8ad..58e2dc65c 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -47,6 +47,7 @@ static char screenshot_path[PATH_MAX] = ""; #define PSTORE_LAST_KMSG "/sys/fs/pstore/console-ramoops" +#define RAFT_DIR "/data/misc/raft/" #define TOMBSTONE_DIR "/data/tombstones" #define TOMBSTONE_FILE_PREFIX TOMBSTONE_DIR "/tombstone_" /* Can accomodate a tombstone number up to 9999. */ @@ -348,6 +349,8 @@ static void dumpstate() { } run_command("RADIO LOG", timeout / 1000, "logcat", "-b", "radio", "-v", "threadtime", "-d", "*:v", NULL); + run_command("RAFT LOGS", 300, SU_PATH, "root", "logcompressor", "-r", RAFT_DIR, NULL); + /* show the traces we collected in main(), if that was done */ if (dump_traces_path != NULL) { dump_file("VM TRACES JUST NOW", dump_traces_path); From cbf4004fc45d2f5a14ec9e00d39cd6ca49bd07ad Mon Sep 17 00:00:00 2001 From: Aravind Akella Date: Wed, 29 Jul 2015 18:03:48 -0700 Subject: [PATCH 04/21] Bug fix in SensorManager. If SensorService hasn't started when SensorManager instance is requested, keep retrying for a longer duration. Bug: 22529981 Change-Id: I3c506d962b61347085fc80b2c5832289539d6853 (cherry picked from commit e2806cb4456e3815e979f333ed23ec7df591a9ff) --- include/gui/SensorManager.h | 53 ++----------------------------- libs/gui/SensorManager.cpp | 62 +++++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 54 deletions(-) diff --git a/include/gui/SensorManager.h b/include/gui/SensorManager.h index 37960673c..0cff46c07 100644 --- a/include/gui/SensorManager.h +++ b/include/gui/SensorManager.h @@ -51,57 +51,7 @@ class SensorManager : public ASensorManager { public: - static SensorManager& getInstanceForPackage(const String16& packageName) { - Mutex::Autolock _l(sLock); - - SensorManager* sensorManager; - std::map::iterator iterator = - sPackageInstances.find(packageName); - - if (iterator != sPackageInstances.end()) { - sensorManager = iterator->second; - } else { - String16 opPackageName = packageName; - - // It is possible that the calling code has no access to the package name. - // In this case we will get the packages for the calling UID and pick the - // first one for attributing the app op. This will work correctly for - // runtime permissions as for legacy apps we will toggle the app op for - // all packages in the UID. The caveat is that the operation may be attributed - // to the wrong package and stats based on app ops may be slightly off. - if (opPackageName.size() <= 0) { - sp binder = defaultServiceManager()->getService(String16("permission")); - if (binder != 0) { - const uid_t uid = IPCThreadState::self()->getCallingUid(); - Vector packages; - interface_cast(binder)->getPackagesForUid(uid, packages); - if (!packages.isEmpty()) { - opPackageName = packages[0]; - } else { - ALOGE("No packages for calling UID"); - } - } else { - ALOGE("Cannot get permission service"); - } - } - - sensorManager = new SensorManager(opPackageName); - - // If we had no package name, we looked it up from the UID and the sensor - // manager instance we created should also be mapped to the empty package - // name, to avoid looking up the packages for a UID and get the same result. - if (packageName.size() <= 0) { - sPackageInstances.insert(std::make_pair(String16(), sensorManager)); - } - - // Stash the per package sensor manager. - sPackageInstances.insert(std::make_pair(opPackageName, sensorManager)); - } - - return *sensorManager; - } - - SensorManager(const String16& opPackageName); + static SensorManager& getInstanceForPackage(const String16& packageName); ~SensorManager(); ssize_t getSensorList(Sensor const* const** list) const; @@ -113,6 +63,7 @@ private: // DeathRecipient interface void sensorManagerDied(); + SensorManager(const String16& opPackageName); status_t assertStateLocked() const; private: diff --git a/libs/gui/SensorManager.cpp b/libs/gui/SensorManager.cpp index dd3778137..993415126 100644 --- a/libs/gui/SensorManager.cpp +++ b/libs/gui/SensorManager.cpp @@ -36,6 +36,58 @@ namespace android { // ---------------------------------------------------------------------------- +android::Mutex android::SensorManager::sLock; +std::map android::SensorManager::sPackageInstances; + +SensorManager& SensorManager::getInstanceForPackage(const String16& packageName) { + Mutex::Autolock _l(sLock); + SensorManager* sensorManager; + std::map::iterator iterator = + sPackageInstances.find(packageName); + + if (iterator != sPackageInstances.end()) { + sensorManager = iterator->second; + } else { + String16 opPackageName = packageName; + + // It is possible that the calling code has no access to the package name. + // In this case we will get the packages for the calling UID and pick the + // first one for attributing the app op. This will work correctly for + // runtime permissions as for legacy apps we will toggle the app op for + // all packages in the UID. The caveat is that the operation may be attributed + // to the wrong package and stats based on app ops may be slightly off. + if (opPackageName.size() <= 0) { + sp binder = defaultServiceManager()->getService(String16("permission")); + if (binder != 0) { + const uid_t uid = IPCThreadState::self()->getCallingUid(); + Vector packages; + interface_cast(binder)->getPackagesForUid(uid, packages); + if (!packages.isEmpty()) { + opPackageName = packages[0]; + } else { + ALOGE("No packages for calling UID"); + } + } else { + ALOGE("Cannot get permission service"); + } + } + + sensorManager = new SensorManager(opPackageName); + + // If we had no package name, we looked it up from the UID and the sensor + // manager instance we created should also be mapped to the empty package + // name, to avoid looking up the packages for a UID and get the same result. + if (packageName.size() <= 0) { + sPackageInstances.insert(std::make_pair(String16(), sensorManager)); + } + + // Stash the per package sensor manager. + sPackageInstances.insert(std::make_pair(opPackageName, sensorManager)); + } + + return *sensorManager; +} + SensorManager::SensorManager(const String16& opPackageName) : mSensorList(0), mOpPackageName(opPackageName) { @@ -59,12 +111,12 @@ void SensorManager::sensorManagerDied() status_t SensorManager::assertStateLocked() const { if (mSensorServer == NULL) { - // try for one second + // try for 10 seconds before giving up ... const String16 name("sensorservice"); - for (int i=0 ; i<4 ; i++) { + for (int i = 0;i < 10; i++) { status_t err = getService(name, &mSensorServer); if (err == NAME_NOT_FOUND) { - usleep(250000); + sleep(1); continue; } if (err != NO_ERROR) { @@ -83,6 +135,10 @@ status_t SensorManager::assertStateLocked() const { DeathObserver(SensorManager& mgr) : mSensorManger(mgr) { } }; + if (mSensorServer == NULL) { + ALOGE("FATAL getsensorservice returned NULL"); + } + mDeathObserver = new DeathObserver(*const_cast(this)); IInterface::asBinder(mSensorServer)->linkToDeath(mDeathObserver); From bcaa8d5a6c059d22d2fcf32ffab1a99f3b64c756 Mon Sep 17 00:00:00 2001 From: Lajos Molnar Date: Fri, 7 Aug 2015 10:07:07 -0700 Subject: [PATCH 05/21] OMX: clarify EOS signaling for tunneled decoders Bug: 22859209 Change-Id: Ie28da1b80e4a8dd5ae2806e300ed37287c9c57a8 --- include/media/openmax/OMX_Core.h | 6 +++++- include/media/openmax/OMX_VideoExt.h | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/media/openmax/OMX_Core.h b/include/media/openmax/OMX_Core.h index 521c223b0..f746a69d2 100644 --- a/include/media/openmax/OMX_Core.h +++ b/include/media/openmax/OMX_Core.h @@ -509,7 +509,7 @@ typedef enum OMX_EVENTTYPE OMX_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - /** Event when tunneled decoder has rendered an output + /** Event when tunneled decoder has rendered an output or reached EOS * nData1 must contain the number of timestamps returned * pEventData must point to an array of the OMX_VIDEO_RENDEREVENTTYPE structs containing the * render-timestamps of each frame. Component may batch rendered timestamps using this event, @@ -518,6 +518,10 @@ typedef enum OMX_EVENTTYPE * * If component is doing frame-rate conversion, it must signal the render time of each * converted frame, and must interpolate media timestamps for in-between frames. + * + * When the component reached EOS, it must signal an EOS timestamp using the same mechanism. + * This is in addition to the timestamp of the last rendered frame, and should follow that + * frame. */ OMX_EventOutputRendered = 0x7F000001, OMX_EventMax = 0x7FFFFFFF diff --git a/include/media/openmax/OMX_VideoExt.h b/include/media/openmax/OMX_VideoExt.h index 34c040574..3971bc5cc 100644 --- a/include/media/openmax/OMX_VideoExt.h +++ b/include/media/openmax/OMX_VideoExt.h @@ -203,10 +203,17 @@ typedef struct OMX_VIDEO_SLICESEGMENTSTYPE { OMX_BOOL bEnableLoopFilterAcrossSlices; } OMX_VIDEO_SLICESEGMENTSTYPE; -/** Structure to return timestamps of rendered output frames for tunneled components */ +/** Structure to return timestamps of rendered output frames as well as EOS + * for tunneled components. + */ typedef struct OMX_VIDEO_RENDEREVENTTYPE { OMX_S64 nMediaTimeUs; // timestamp of rendered video frame OMX_S64 nSystemTimeNs; // system monotonic time at the time frame was rendered + // Use INT64_MAX for nMediaTimeUs to signal that the EOS + // has been reached. In this case, nSystemTimeNs MUST be + // the system time when the last frame was rendered. + // This MUST be done in addition to returning (and + // following) the render information for the last frame. } OMX_VIDEO_RENDEREVENTTYPE; #ifdef __cplusplus From a180e855f66db8e4aa4796247e55ca5372d53de2 Mon Sep 17 00:00:00 2001 From: Nick Armstrong-Crews Date: Wed, 2 Sep 2015 13:00:52 -0700 Subject: [PATCH 06/21] Add KEYCODE_SOFT_SLEEP for Ungaze. BUG: b/23589870 Change-Id: I9bb575fe97bfae926ef4db37615e88057b81480c --- include/android/keycodes.h | 4 +++- include/input/InputEventLabels.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/android/keycodes.h b/include/android/keycodes.h index 1f55d9f37..421abe547 100644 --- a/include/android/keycodes.h +++ b/include/android/keycodes.h @@ -735,7 +735,9 @@ enum { AKEYCODE_MEDIA_SKIP_FORWARD = 272, AKEYCODE_MEDIA_SKIP_BACKWARD = 273, AKEYCODE_MEDIA_STEP_FORWARD = 274, - AKEYCODE_MEDIA_STEP_BACKWARD = 275 + AKEYCODE_MEDIA_STEP_BACKWARD = 275, + /** Put device to sleep unless a wakelock is held. */ + AKEYCODE_SOFT_SLEEP = 276 // NOTE: If you add a new keycode here you must also add it to several other files. // Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list. diff --git a/include/input/InputEventLabels.h b/include/input/InputEventLabels.h index 344f2f377..f0a6238e9 100644 --- a/include/input/InputEventLabels.h +++ b/include/input/InputEventLabels.h @@ -311,6 +311,7 @@ static const InputEventLabel KEYCODES[] = { DEFINE_KEYCODE(MEDIA_SKIP_BACKWARD), DEFINE_KEYCODE(MEDIA_STEP_FORWARD), DEFINE_KEYCODE(MEDIA_STEP_BACKWARD), + DEFINE_KEYCODE(SOFT_SLEEP), { NULL, 0 } }; From ac72bbf4e46d6689070df09a25db2960a9036eb2 Mon Sep 17 00:00:00 2001 From: Prashant Malani Date: Tue, 11 Aug 2015 18:29:28 -0700 Subject: [PATCH 07/21] inputflinger: Initial support for rotary encoders. This change introduces support for rotary encoder input devices. We also define a new input source (namely, AINPUT_SOURCE_ROTARY_ENCODER) and a new axis of input (namely, AXIS_SCROLL), since the rotary encoder motion doesn't necessarily tie to a horizontal or vertical scroll motion. A ROTARY_ENCODER input device class is also introduced, corresponding to the new input source. A new input source can be defined as producing rotary encoder motion events, if its corresponding .idc file contains the following declaration: device.type = rotaryEncoder Bug: 18707397 Change-Id: I8ccd540908311d1ff44fdfeba81b691895413641 Signed-off-by: Prashant Malani --- include/android/input.h | 9 +++ services/inputflinger/EventHub.cpp | 9 +++ services/inputflinger/EventHub.h | 3 + services/inputflinger/InputReader.cpp | 91 +++++++++++++++++++++++++++ services/inputflinger/InputReader.h | 20 ++++++ 5 files changed, 132 insertions(+) diff --git a/include/android/input.h b/include/android/input.h index 5ab4e2926..5eeb7fc89 100644 --- a/include/android/input.h +++ b/include/android/input.h @@ -643,6 +643,13 @@ enum { * against the surface. */ AMOTION_EVENT_AXIS_TILT = 25, + /** + * Axis constant: Generic scroll axis of a motion event. + * + * - This is used for scroll axis motion events that can't be classified as strictly + * vertical or horizontal. The movement of a rotating scroller is an example of this. + */ + AMOTION_EVENT_AXIS_SCROLL = 26, /** * Axis constant: Generic 1 axis of a motion event. * The interpretation of a generic axis is device-specific. @@ -817,6 +824,8 @@ enum { AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE, /** joystick */ AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK, + /** rotary encoder */ + AINPUT_SOURCE_ROTARY_ENCODER = 0x00400000 | AINPUT_SOURCE_CLASS_NONE, /** any */ AINPUT_SOURCE_ANY = 0xffffff00, diff --git a/services/inputflinger/EventHub.cpp b/services/inputflinger/EventHub.cpp index 6b60c7cf7..98cfe2b54 100644 --- a/services/inputflinger/EventHub.cpp +++ b/services/inputflinger/EventHub.cpp @@ -1177,6 +1177,15 @@ status_t EventHub::openDeviceLocked(const char *devicePath) { device->classes |= INPUT_DEVICE_CLASS_CURSOR; } + // See if this is a rotary encoder type device. + String8 deviceType = String8(); + if (device->configuration && + device->configuration->tryGetProperty(String8("device.type"), deviceType)) { + if (!deviceType.compare(String8("rotaryEncoder"))) { + device->classes |= INPUT_DEVICE_CLASS_ROTARY_ENCODER; + } + } + // See if this is a touch pad. // Is this a new modern multi-touch driver? if (test_bit(ABS_MT_POSITION_X, device->absBitmask) diff --git a/services/inputflinger/EventHub.h b/services/inputflinger/EventHub.h index 3ec49105c..7c3e11ec5 100644 --- a/services/inputflinger/EventHub.h +++ b/services/inputflinger/EventHub.h @@ -137,6 +137,9 @@ enum { /* The input device is an external stylus (has data we want to fuse with touch data). */ INPUT_DEVICE_CLASS_EXTERNAL_STYLUS = 0x00000800, + /* The input device has a rotary encoder */ + INPUT_DEVICE_CLASS_ROTARY_ENCODER = 0x00001000, + /* The input device is virtual (not a real device, not part of UI configuration). */ INPUT_DEVICE_CLASS_VIRTUAL = 0x40000000, diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp index 36095bf1e..d7329d939 100644 --- a/services/inputflinger/InputReader.cpp +++ b/services/inputflinger/InputReader.cpp @@ -450,6 +450,11 @@ InputDevice* InputReader::createDeviceLocked(int32_t deviceId, int32_t controlle device->addMapper(new SwitchInputMapper(device)); } + // Scroll wheel-like devices. + if (classes & INPUT_DEVICE_CLASS_ROTARY_ENCODER) { + device->addMapper(new RotaryEncoderInputMapper(device)); + } + // Vibrator-like devices. if (classes & INPUT_DEVICE_CLASS_VIBRATOR) { device->addMapper(new VibratorInputMapper(device)); @@ -2718,6 +2723,92 @@ void CursorInputMapper::fadePointer() { } } +// --- RotaryEncoderInputMapper --- + +RotaryEncoderInputMapper::RotaryEncoderInputMapper(InputDevice* device) : + InputMapper(device) { + mSource = AINPUT_SOURCE_ROTARY_ENCODER; +} + +RotaryEncoderInputMapper::~RotaryEncoderInputMapper() { +} + +uint32_t RotaryEncoderInputMapper::getSources() { + return mSource; +} + +void RotaryEncoderInputMapper::populateDeviceInfo(InputDeviceInfo* info) { + InputMapper::populateDeviceInfo(info); + + if (mRotaryEncoderScrollAccumulator.haveRelativeVWheel()) { + info->addMotionRange(AMOTION_EVENT_AXIS_SCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f); + } +} + +void RotaryEncoderInputMapper::dump(String8& dump) { + dump.append(INDENT2 "Rotary Encoder Input Mapper:\n"); + dump.appendFormat(INDENT3 "HaveWheel: %s\n", + toString(mRotaryEncoderScrollAccumulator.haveRelativeVWheel())); +} + +void RotaryEncoderInputMapper::configure(nsecs_t when, + const InputReaderConfiguration* config, uint32_t changes) { + InputMapper::configure(when, config, changes); + if (!changes) { + mRotaryEncoderScrollAccumulator.configure(getDevice()); + } +} + +void RotaryEncoderInputMapper::reset(nsecs_t when) { + mRotaryEncoderScrollAccumulator.reset(getDevice()); + + InputMapper::reset(when); +} + +void RotaryEncoderInputMapper::process(const RawEvent* rawEvent) { + mRotaryEncoderScrollAccumulator.process(rawEvent); + + if (rawEvent->type == EV_SYN && rawEvent->code == SYN_REPORT) { + sync(rawEvent->when); + } +} + +void RotaryEncoderInputMapper::sync(nsecs_t when) { + PointerCoords pointerCoords; + pointerCoords.clear(); + + PointerProperties pointerProperties; + pointerProperties.clear(); + pointerProperties.id = 0; + pointerProperties.toolType = AMOTION_EVENT_TOOL_TYPE_UNKNOWN; + + float scroll = mRotaryEncoderScrollAccumulator.getRelativeVWheel(); + bool scrolled = scroll != 0; + + // This is not a pointer, so it's not associated with a display. + int32_t displayId = ADISPLAY_ID_NONE; + + // Moving the rotary encoder should wake the device (if specified). + uint32_t policyFlags = 0; + if (scrolled && getDevice()->isExternal()) { + policyFlags |= POLICY_FLAG_WAKE; + } + + // Send motion event. + if (scrolled) { + int32_t metaState = mContext->getGlobalMetaState(); + pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_SCROLL, scroll); + + NotifyMotionArgs scrollArgs(when, getDeviceId(), mSource, policyFlags, + AMOTION_EVENT_ACTION_SCROLL, 0, 0, metaState, 0, + AMOTION_EVENT_EDGE_FLAG_NONE, + displayId, 1, &pointerProperties, &pointerCoords, + 0, 0, 0); + getListener()->notifyMotion(&scrollArgs); + } + + mRotaryEncoderScrollAccumulator.finishSync(); +} // --- TouchInputMapper --- diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h index 7cb4680ce..58db3dca6 100644 --- a/services/inputflinger/InputReader.h +++ b/services/inputflinger/InputReader.h @@ -1232,6 +1232,26 @@ private: }; +class RotaryEncoderInputMapper : public InputMapper { +public: + RotaryEncoderInputMapper(InputDevice* device); + virtual ~RotaryEncoderInputMapper(); + + virtual uint32_t getSources(); + virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo); + virtual void dump(String8& dump); + virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes); + virtual void reset(nsecs_t when); + virtual void process(const RawEvent* rawEvent); + +private: + CursorScrollAccumulator mRotaryEncoderScrollAccumulator; + + int32_t mSource; + + void sync(nsecs_t when); +}; + class TouchInputMapper : public InputMapper { public: TouchInputMapper(InputDevice* device); From 72da7fb77cc0aaeb272b0359679c841d02d5edfe Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Mon, 28 Sep 2015 08:55:01 -0700 Subject: [PATCH 08/21] Installd: Fully decouple pre- and post-bootcomplete properties Do not fall back to dalvik.vm.dex2oat-threads if dalvik.vm.boot-dex2oat-threads is not set. Also do not ever use the value of dalvik.vm.image-dex2oat-threads. Instead use the default behavior of dex2oat in that situation. (cherry picked from commit 919461cbeef3e9f35388fc099a5fcdae1cb79cc6) Bug: 24413760 Change-Id: I42e60996341414b95b8df2d243d5e07f7f5ff9b6 --- cmds/installd/commands.cpp | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/cmds/installd/commands.cpp b/cmds/installd/commands.cpp index d4aa7d31b..c05a3d3cb 100644 --- a/cmds/installd/commands.cpp +++ b/cmds/installd/commands.cpp @@ -770,24 +770,11 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name, dex2oat_compiler_filter_flag, NULL) > 0; char dex2oat_threads_buf[PROPERTY_VALUE_MAX]; - bool have_dex2oat_threads_flag = false; - if (!post_bootcomplete) { - have_dex2oat_threads_flag = property_get("dalvik.vm.boot-dex2oat-threads", - dex2oat_threads_buf, - NULL) > 0; - // If there's no boot property, fall back to the image property. - if (!have_dex2oat_threads_flag) { - have_dex2oat_threads_flag = property_get("dalvik.vm.image-dex2oat-threads", - dex2oat_threads_buf, - NULL) > 0; - } - // If there's neither, fall back to the default property. - } - if (!have_dex2oat_threads_flag) { - have_dex2oat_threads_flag = property_get("dalvik.vm.dex2oat-threads", - dex2oat_threads_buf, - NULL) > 0; - } + bool have_dex2oat_threads_flag = property_get(post_bootcomplete + ? "dalvik.vm.dex2oat-threads" + : "dalvik.vm.boot-dex2oat-threads", + dex2oat_threads_buf, + NULL) > 0; char dex2oat_threads_arg[PROPERTY_VALUE_MAX + 2]; if (have_dex2oat_threads_flag) { sprintf(dex2oat_threads_arg, "-j%s", dex2oat_threads_buf); From 05c862252d5021f55a69281473c67d76e7097422 Mon Sep 17 00:00:00 2001 From: Erik Wolsheimer Date: Fri, 2 Oct 2015 10:02:24 -0700 Subject: [PATCH 09/21] do not dumpstate raft BUG: 24159112 Change-Id: I344aa73808992b5f84cb0536201a3ab2eb6f2b3c --- cmds/dumpstate/dumpstate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index 713634c4d..59c1d12f7 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -351,7 +351,8 @@ static void dumpstate() { run_command("LOG STATISTICS", 10, "logcat", "-b", "all", "-S", NULL); - run_command("RAFT LOGS", 300, SU_PATH, "root", "logcompressor", "-r", RAFT_DIR, NULL); + // raft disabled as per http://b/24159112 + // run_command("RAFT LOGS", 300, SU_PATH, "root", "logcompressor", "-r", RAFT_DIR, NULL); /* show the traces we collected in main(), if that was done */ if (dump_traces_path != NULL) { From 31baf8d3c2833d13056b0be679f66ed0e53c8d26 Mon Sep 17 00:00:00 2001 From: Jason Parks Date: Mon, 12 Oct 2015 15:27:10 +0000 Subject: [PATCH 10/21] Revert "do not dumpstate raft BUG: 24159112" This reverts commit 05c862252d5021f55a69281473c67d76e7097422. Change-Id: Ib5984796734d2a0e33f47e0fb4e446b787e0d14f --- cmds/dumpstate/dumpstate.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index 59c1d12f7..713634c4d 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -351,8 +351,7 @@ static void dumpstate() { run_command("LOG STATISTICS", 10, "logcat", "-b", "all", "-S", NULL); - // raft disabled as per http://b/24159112 - // run_command("RAFT LOGS", 300, SU_PATH, "root", "logcompressor", "-r", RAFT_DIR, NULL); + run_command("RAFT LOGS", 300, SU_PATH, "root", "logcompressor", "-r", RAFT_DIR, NULL); /* show the traces we collected in main(), if that was done */ if (dump_traces_path != NULL) { From 392db573b35d6fe09c4da094ed81c54ed528a511 Mon Sep 17 00:00:00 2001 From: Tim Murray Date: Tue, 10 Nov 2015 14:29:45 -0800 Subject: [PATCH 11/21] Set cpuset from surfaceflinger. SurfaceFlinger shouldn't be limited to little cores exclusively, as the binder threads should be placed on big cores when they are in the critical path for a RenderThread. bug 25745866 Change-Id: I9fb65f6d951733f91b4735ff27018411b58b2bfb --- services/surfaceflinger/Android.mk | 4 ++++ services/surfaceflinger/main_surfaceflinger.cpp | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk index 1eb23616c..1901ef982 100644 --- a/services/surfaceflinger/Android.mk +++ b/services/surfaceflinger/Android.mk @@ -122,6 +122,10 @@ LOCAL_LDFLAGS := -Wl,--version-script,art/sigchainlib/version-script.txt -Wl,--e LOCAL_CFLAGS := -DLOG_TAG=\"SurfaceFlinger\" LOCAL_CPPFLAGS := -std=c++11 +ifneq ($(ENABLE_CPUSETS),) + LOCAL_CFLAGS += -DENABLE_CPUSETS +endif + LOCAL_SRC_FILES := \ main_surfaceflinger.cpp diff --git a/services/surfaceflinger/main_surfaceflinger.cpp b/services/surfaceflinger/main_surfaceflinger.cpp index a74bc4cd9..6fa8b5317 100644 --- a/services/surfaceflinger/main_surfaceflinger.cpp +++ b/services/surfaceflinger/main_surfaceflinger.cpp @@ -41,6 +41,13 @@ int main(int, char**) { set_sched_policy(0, SP_FOREGROUND); +#ifdef ENABLE_CPUSETS + // Put most SurfaceFlinger threads in the system-background cpuset + // Keeps us from unnecessarily using big cores + // Do this after the binder thread pool init + set_cpuset_policy(0, SP_SYSTEM); +#endif + // initialize before clients can connect flinger->init(); From 804339a59e4abcbcf5a50a60ff0543e6b404e572 Mon Sep 17 00:00:00 2001 From: Sharvil Nanavati Date: Fri, 27 Nov 2015 21:04:11 -0800 Subject: [PATCH 12/21] Increase raft timeout to 10min so we get complete logs from older devices. Devices like dory get slammed when bugreports are taken and can't compress all the raft logs in the current 5min timeout. Our dogfooders spend their precious time getting us bugreports and then we can't act on them because we have broken raft logs. :( This change bumps up the timeout in the hopes that we can get complete logs from even our slowest devices. Change-Id: I10741a6185b39544f4c0531f0ee74864d74a1aa4 --- cmds/dumpstate/dumpstate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index 713634c4d..b88b60551 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -351,7 +351,7 @@ static void dumpstate() { run_command("LOG STATISTICS", 10, "logcat", "-b", "all", "-S", NULL); - run_command("RAFT LOGS", 300, SU_PATH, "root", "logcompressor", "-r", RAFT_DIR, NULL); + run_command("RAFT LOGS", 600, SU_PATH, "root", "logcompressor", "-r", RAFT_DIR, NULL); /* show the traces we collected in main(), if that was done */ if (dump_traces_path != NULL) { From bd65161021cecc8d0cda8a5efb5650ce9782fee9 Mon Sep 17 00:00:00 2001 From: Tim Murray Date: Mon, 30 Nov 2015 10:59:55 -0800 Subject: [PATCH 13/21] DO NOT MERGE: add support for new sched tracepoint This tracepoint gives systrace the means to display the reason for uninterruptible sleep. bug 23350688 Change-Id: I9ee5b6904c27bcb5bd67c86fda66d45d0a3c0999 --- cmds/atrace/atrace.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp index 26c5b4ac3..7201e77ca 100644 --- a/cmds/atrace/atrace.cpp +++ b/cmds/atrace/atrace.cpp @@ -93,6 +93,7 @@ static const TracingCategory k_categories[] = { { "sched", "CPU Scheduling", 0, { { REQ, "/sys/kernel/debug/tracing/events/sched/sched_switch/enable" }, { REQ, "/sys/kernel/debug/tracing/events/sched/sched_wakeup/enable" }, + { OPT, "/sys/kernel/debug/tracing/events/sched/sched_blocked_reason/enable" }, } }, { "irq", "IRQ Events", 0, { { REQ, "/sys/kernel/debug/tracing/events/irq/enable" }, From d4db70a7b8b2d136c46c50f89b276f8150be5fc2 Mon Sep 17 00:00:00 2001 From: Jani Suonpera Date: Fri, 9 Oct 2015 11:45:57 +0300 Subject: [PATCH 14/21] DO NOT MERGE ANYWHERE Add new interface for sensor physical data This is special solution only for emerald branch. Changes including new const char* value/interface for sensor physical data. Sensor service and manager does not take care of content, structure or other details of string. Sensor HAL is taking care of parsing data from string and setting values to Sensor HW. Change-Id: I3abc3ddc7c6adc4b32a40b9a43f2a94c5af7b2b0 Signed-off-by: Ben Fennema --- include/gui/ISensorServer.h | 1 + include/gui/SensorManager.h | 2 +- libs/gui/ISensorServer.cpp | 21 ++++++++++++++++++++- libs/gui/SensorManager.cpp | 17 +++++++++++++++++ services/sensorservice/SensorDevice.cpp | 15 +++++++++++++++ services/sensorservice/SensorDevice.h | 1 + services/sensorservice/SensorService.cpp | 8 ++++++++ services/sensorservice/SensorService.h | 1 + 8 files changed, 64 insertions(+), 2 deletions(-) diff --git a/include/gui/ISensorServer.h b/include/gui/ISensorServer.h index 3dca2a373..e590ce9c3 100644 --- a/include/gui/ISensorServer.h +++ b/include/gui/ISensorServer.h @@ -41,6 +41,7 @@ public: virtual sp createSensorEventConnection(const String8& packageName, int mode, const String16& opPackageName) = 0; virtual int32_t isDataInjectionEnabled() = 0; + virtual status_t setSensorPhysicalData(const char* physicaldata) = 0; }; // ---------------------------------------------------------------------------- diff --git a/include/gui/SensorManager.h b/include/gui/SensorManager.h index 0cff46c07..2b07ca7ce 100644 --- a/include/gui/SensorManager.h +++ b/include/gui/SensorManager.h @@ -58,7 +58,7 @@ public: Sensor const* getDefaultSensor(int type); sp createEventQueue(String8 packageName = String8(""), int mode = 0); bool isDataInjectionEnabled(); - + bool SetPhysicalData(const char* data); private: // DeathRecipient interface void sensorManagerDied(); diff --git a/libs/gui/ISensorServer.cpp b/libs/gui/ISensorServer.cpp index f581b5c1d..8cd17254b 100644 --- a/libs/gui/ISensorServer.cpp +++ b/libs/gui/ISensorServer.cpp @@ -35,7 +35,8 @@ namespace android { enum { GET_SENSOR_LIST = IBinder::FIRST_CALL_TRANSACTION, CREATE_SENSOR_EVENT_CONNECTION, - ENABLE_DATA_INJECTION + ENABLE_DATA_INJECTION, + SET_SENSOR_PHYSICAL_DATA, }; class BpSensorServer : public BpInterface @@ -83,6 +84,16 @@ public: remote()->transact(ENABLE_DATA_INJECTION, data, &reply); return reply.readInt32(); } + + virtual status_t setSensorPhysicalData(const char* physicaldata) + { + Parcel data, reply; + //ALOGD("ISensorManager::SetSensorPhysicalData(%s)",physicaldata); + data.writeInterfaceToken(ISensorServer::getInterfaceDescriptor()); + data.writeCString(physicaldata); + remote()->transact(SET_SENSOR_PHYSICAL_DATA, data, &reply); + return reply.readInt32(); + } }; // Out-of-line virtual method definition to trigger vtable emission in this @@ -124,6 +135,14 @@ status_t BnSensorServer::onTransact( reply->writeInt32(static_cast(ret)); return NO_ERROR; } + case SET_SENSOR_PHYSICAL_DATA: { + CHECK_INTERFACE(ISensorServer, data, reply); + const char* physicaldata = data.readCString(); + //ALOGD("ISensorManager, BnSensorServer::onTransact, physicaldata is: (%s)",physicaldata); + status_t result = setSensorPhysicalData(physicaldata); + reply->writeInt32(result); + return NO_ERROR; + } } return BBinder::onTransact(code, data, reply, flags); } diff --git a/libs/gui/SensorManager.cpp b/libs/gui/SensorManager.cpp index 33608b5bd..343131fc0 100644 --- a/libs/gui/SensorManager.cpp +++ b/libs/gui/SensorManager.cpp @@ -227,5 +227,22 @@ bool SensorManager::isDataInjectionEnabled() { return false; } +bool SensorManager::SetPhysicalData(const char* data) +{ + status_t reply; + //ALOGD("SensorManager::SetPhysicalData(%s)",data); + + reply = mSensorServer->setSensorPhysicalData(data); + + if(reply == NO_ERROR) + { + return true; + } + else + { + return false; + } +} + // ---------------------------------------------------------------------------- }; // namespace android diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp index dd1bccfbe..48ae2fb7a 100644 --- a/services/sensorservice/SensorDevice.cpp +++ b/services/sensorservice/SensorDevice.cpp @@ -407,6 +407,21 @@ status_t SensorDevice::setMode(uint32_t mode) { return mSensorModule->set_operation_mode(mode); } +status_t SensorDevice::setSensorPhysicalData(const char* physicaldata) +{ + //ALOGD("SensorDevice::setSensorPhysicalData(%s)",physicaldata); + Mutex::Autolock _l(mLock); + if((mSensorModule->set_sensor_physical_data == NULL) || (getHalDeviceVersion() < SENSORS_DEVICE_API_VERSION_1_3_5)) + { + return NO_INIT; + } + else + { + return mSensorModule->set_sensor_physical_data(physicaldata); + } +} + + // --------------------------------------------------------------------------- int SensorDevice::Info::numActiveClients() { diff --git a/services/sensorservice/SensorDevice.h b/services/sensorservice/SensorDevice.h index c48484994..f65849749 100644 --- a/services/sensorservice/SensorDevice.h +++ b/services/sensorservice/SensorDevice.h @@ -104,6 +104,7 @@ public: void autoDisable(void *ident, int handle); status_t injectSensorData(const sensors_event_t *event); void dump(String8& result); + status_t setSensorPhysicalData(const char* physicaldata); }; // --------------------------------------------------------------------------- diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index fd72b2312..2548a3e81 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -735,6 +735,14 @@ Vector SensorService::getSensorList(const String16& opPackageName) return accessibleSensorList; } +status_t SensorService::setSensorPhysicalData(const char* physicaldata) +{ + SensorDevice& dev(SensorDevice::getInstance()); + + //ALOGD("SensorService::setSensorPhysicalData(%s)",physicaldata); + return dev.setSensorPhysicalData(physicaldata); +} + sp SensorService::createSensorEventConnection(const String8& packageName, int requestedMode, const String16& opPackageName) { // Only 2 modes supported for a SensorEventConnection ... NORMAL and DATA_INJECTION. diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h index 9a573ae78..3a1ffb25e 100644 --- a/services/sensorservice/SensorService.h +++ b/services/sensorservice/SensorService.h @@ -130,6 +130,7 @@ class SensorService : virtual sp createSensorEventConnection(const String8& packageName, int requestedMode, const String16& opPackageName); virtual int isDataInjectionEnabled(); + virtual status_t setSensorPhysicalData(const char* physicaldata); virtual status_t dump(int fd, const Vector& args); class SensorEventConnection : public BnSensorEventConnection, public LooperCallback { From 8c3e55f4149deda3ec7c7a67fda81216d5f9af25 Mon Sep 17 00:00:00 2001 From: Ben Fennema Date: Wed, 2 Dec 2015 01:04:40 +0000 Subject: [PATCH 15/21] Revert "DO NOT MERGE ANYWHERE Add new interface for sensor physical data" This reverts commit d4db70a7b8b2d136c46c50f89b276f8150be5fc2. Change-Id: Ifb52d5595970a5178e12c2a90da4aac0e38f5942 --- include/gui/ISensorServer.h | 1 - include/gui/SensorManager.h | 2 +- libs/gui/ISensorServer.cpp | 21 +-------------------- libs/gui/SensorManager.cpp | 17 ----------------- services/sensorservice/SensorDevice.cpp | 15 --------------- services/sensorservice/SensorDevice.h | 1 - services/sensorservice/SensorService.cpp | 8 -------- services/sensorservice/SensorService.h | 1 - 8 files changed, 2 insertions(+), 64 deletions(-) diff --git a/include/gui/ISensorServer.h b/include/gui/ISensorServer.h index e590ce9c3..3dca2a373 100644 --- a/include/gui/ISensorServer.h +++ b/include/gui/ISensorServer.h @@ -41,7 +41,6 @@ public: virtual sp createSensorEventConnection(const String8& packageName, int mode, const String16& opPackageName) = 0; virtual int32_t isDataInjectionEnabled() = 0; - virtual status_t setSensorPhysicalData(const char* physicaldata) = 0; }; // ---------------------------------------------------------------------------- diff --git a/include/gui/SensorManager.h b/include/gui/SensorManager.h index 2b07ca7ce..0cff46c07 100644 --- a/include/gui/SensorManager.h +++ b/include/gui/SensorManager.h @@ -58,7 +58,7 @@ public: Sensor const* getDefaultSensor(int type); sp createEventQueue(String8 packageName = String8(""), int mode = 0); bool isDataInjectionEnabled(); - bool SetPhysicalData(const char* data); + private: // DeathRecipient interface void sensorManagerDied(); diff --git a/libs/gui/ISensorServer.cpp b/libs/gui/ISensorServer.cpp index 8cd17254b..f581b5c1d 100644 --- a/libs/gui/ISensorServer.cpp +++ b/libs/gui/ISensorServer.cpp @@ -35,8 +35,7 @@ namespace android { enum { GET_SENSOR_LIST = IBinder::FIRST_CALL_TRANSACTION, CREATE_SENSOR_EVENT_CONNECTION, - ENABLE_DATA_INJECTION, - SET_SENSOR_PHYSICAL_DATA, + ENABLE_DATA_INJECTION }; class BpSensorServer : public BpInterface @@ -84,16 +83,6 @@ public: remote()->transact(ENABLE_DATA_INJECTION, data, &reply); return reply.readInt32(); } - - virtual status_t setSensorPhysicalData(const char* physicaldata) - { - Parcel data, reply; - //ALOGD("ISensorManager::SetSensorPhysicalData(%s)",physicaldata); - data.writeInterfaceToken(ISensorServer::getInterfaceDescriptor()); - data.writeCString(physicaldata); - remote()->transact(SET_SENSOR_PHYSICAL_DATA, data, &reply); - return reply.readInt32(); - } }; // Out-of-line virtual method definition to trigger vtable emission in this @@ -135,14 +124,6 @@ status_t BnSensorServer::onTransact( reply->writeInt32(static_cast(ret)); return NO_ERROR; } - case SET_SENSOR_PHYSICAL_DATA: { - CHECK_INTERFACE(ISensorServer, data, reply); - const char* physicaldata = data.readCString(); - //ALOGD("ISensorManager, BnSensorServer::onTransact, physicaldata is: (%s)",physicaldata); - status_t result = setSensorPhysicalData(physicaldata); - reply->writeInt32(result); - return NO_ERROR; - } } return BBinder::onTransact(code, data, reply, flags); } diff --git a/libs/gui/SensorManager.cpp b/libs/gui/SensorManager.cpp index 343131fc0..33608b5bd 100644 --- a/libs/gui/SensorManager.cpp +++ b/libs/gui/SensorManager.cpp @@ -227,22 +227,5 @@ bool SensorManager::isDataInjectionEnabled() { return false; } -bool SensorManager::SetPhysicalData(const char* data) -{ - status_t reply; - //ALOGD("SensorManager::SetPhysicalData(%s)",data); - - reply = mSensorServer->setSensorPhysicalData(data); - - if(reply == NO_ERROR) - { - return true; - } - else - { - return false; - } -} - // ---------------------------------------------------------------------------- }; // namespace android diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp index 48ae2fb7a..dd1bccfbe 100644 --- a/services/sensorservice/SensorDevice.cpp +++ b/services/sensorservice/SensorDevice.cpp @@ -407,21 +407,6 @@ status_t SensorDevice::setMode(uint32_t mode) { return mSensorModule->set_operation_mode(mode); } -status_t SensorDevice::setSensorPhysicalData(const char* physicaldata) -{ - //ALOGD("SensorDevice::setSensorPhysicalData(%s)",physicaldata); - Mutex::Autolock _l(mLock); - if((mSensorModule->set_sensor_physical_data == NULL) || (getHalDeviceVersion() < SENSORS_DEVICE_API_VERSION_1_3_5)) - { - return NO_INIT; - } - else - { - return mSensorModule->set_sensor_physical_data(physicaldata); - } -} - - // --------------------------------------------------------------------------- int SensorDevice::Info::numActiveClients() { diff --git a/services/sensorservice/SensorDevice.h b/services/sensorservice/SensorDevice.h index f65849749..c48484994 100644 --- a/services/sensorservice/SensorDevice.h +++ b/services/sensorservice/SensorDevice.h @@ -104,7 +104,6 @@ public: void autoDisable(void *ident, int handle); status_t injectSensorData(const sensors_event_t *event); void dump(String8& result); - status_t setSensorPhysicalData(const char* physicaldata); }; // --------------------------------------------------------------------------- diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index 2548a3e81..fd72b2312 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -735,14 +735,6 @@ Vector SensorService::getSensorList(const String16& opPackageName) return accessibleSensorList; } -status_t SensorService::setSensorPhysicalData(const char* physicaldata) -{ - SensorDevice& dev(SensorDevice::getInstance()); - - //ALOGD("SensorService::setSensorPhysicalData(%s)",physicaldata); - return dev.setSensorPhysicalData(physicaldata); -} - sp SensorService::createSensorEventConnection(const String8& packageName, int requestedMode, const String16& opPackageName) { // Only 2 modes supported for a SensorEventConnection ... NORMAL and DATA_INJECTION. diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h index 3a1ffb25e..9a573ae78 100644 --- a/services/sensorservice/SensorService.h +++ b/services/sensorservice/SensorService.h @@ -130,7 +130,6 @@ class SensorService : virtual sp createSensorEventConnection(const String8& packageName, int requestedMode, const String16& opPackageName); virtual int isDataInjectionEnabled(); - virtual status_t setSensorPhysicalData(const char* physicaldata); virtual status_t dump(int fd, const Vector& args); class SensorEventConnection : public BnSensorEventConnection, public LooperCallback { From 03d61d95fa6a321bf26548b320a1a9c8dc78e124 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Fri, 18 Dec 2015 10:14:46 -0800 Subject: [PATCH 16/21] dumpstate: increase logcat timeout to 40 seconds (DO NOT MERGE) - temporary measure until root issues can be resolved. Bug: 23685592 Change-Id: Ia33f4e3928a457c3dcd730ad2c2c57d13fbf133d --- cmds/dumpstate/dumpstate.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index b88b60551..a2e4f4bd5 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -262,6 +262,8 @@ static unsigned long logcat_timeout(char *name) { /* End copy from system/core/logd/LogBuffer.cpp */ +static const unsigned long logcat_min_timeout = 40000; /* ms */ + /* dumps the current system state to stdout */ static void dumpstate() { unsigned long timeout; @@ -334,18 +336,18 @@ static void dumpstate() { // dump_file("EVENT LOG TAGS", "/etc/event-log-tags"); // calculate timeout timeout = logcat_timeout("main") + logcat_timeout("system") + logcat_timeout("crash"); - if (timeout < 20000) { - timeout = 20000; + if (timeout < logcat_min_timeout) { + timeout = logcat_min_timeout; } run_command("SYSTEM LOG", timeout / 1000, "logcat", "-v", "threadtime", "-d", "*:v", NULL); timeout = logcat_timeout("events"); - if (timeout < 20000) { - timeout = 20000; + if (timeout < logcat_min_timeout) { + timeout = logcat_min_timeout; } run_command("EVENT LOG", timeout / 1000, "logcat", "-b", "events", "-v", "threadtime", "-d", "*:v", NULL); timeout = logcat_timeout("radio"); - if (timeout < 20000) { - timeout = 20000; + if (timeout < logcat_min_timeout) { + timeout = logcat_min_timeout; } run_command("RADIO LOG", timeout / 1000, "logcat", "-b", "radio", "-v", "threadtime", "-d", "*:v", NULL); From dded8fdbb700d6cc498debc69a780915bc34d755 Mon Sep 17 00:00:00 2001 From: Robert Shih Date: Mon, 11 Jan 2016 11:42:48 -0800 Subject: [PATCH 17/21] IGraphicBufferConsumer: fix ATTACH_BUFFER info leak Bug: 26338113 Change-Id: I019c4df2c6adbc944122df96968ddd11a02ebe33 --- libs/gui/IGraphicBufferConsumer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gui/IGraphicBufferConsumer.cpp b/libs/gui/IGraphicBufferConsumer.cpp index f6d087d3b..dc917a8b6 100644 --- a/libs/gui/IGraphicBufferConsumer.cpp +++ b/libs/gui/IGraphicBufferConsumer.cpp @@ -444,7 +444,7 @@ status_t BnGraphicBufferConsumer::onTransact( CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); sp buffer = new GraphicBuffer(); data.read(*buffer.get()); - int slot; + int slot = -1; int result = attachBuffer(&slot, buffer); reply->writeInt32(slot); reply->writeInt32(result); From d06421fd37fbb7fd07002e6738fac3a223cb1a62 Mon Sep 17 00:00:00 2001 From: Robert Shih Date: Mon, 11 Jan 2016 15:02:12 -0800 Subject: [PATCH 18/21] IGraphicBufferProducer: fix QUEUE_BUFFER info leak Bug: 26338109 Change-Id: I8a979469bfe1e317ebdefa43685e19f9302baea8 --- libs/gui/IGraphicBufferProducer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/gui/IGraphicBufferProducer.cpp b/libs/gui/IGraphicBufferProducer.cpp index b73e69e2b..e713c0449 100644 --- a/libs/gui/IGraphicBufferProducer.cpp +++ b/libs/gui/IGraphicBufferProducer.cpp @@ -219,6 +219,7 @@ status_t BnGraphicBufferProducer::onTransact( QueueBufferOutput* const output = reinterpret_cast( reply->writeInplace(sizeof(QueueBufferOutput))); + memset(output, 0, sizeof(QueueBufferOutput)); status_t result = queueBuffer(buf, input, output); reply->writeInt32(result); return NO_ERROR; From ee03865fe5fc6ffe9deda0e0870a18206027cfaf Mon Sep 17 00:00:00 2001 From: Prashant Malani Date: Mon, 11 Jan 2016 17:08:18 -0800 Subject: [PATCH 19/21] inputflinger: Add support for scaling and true value reporting -1/+1 somewhat simplifies the values that can be generated by rotary encoders, and rules out the possibility of batching and more nuanced movement reporting. So, we modify the device configuration to allow values other than -1 and 1 to be supported. In order to give the developer a sense of what these values map to in terms of angular displacement, we also parse a resolution configuration from the devices IDC file. This will be specified as: device.res = xxxx of type float. If a value is not provided, a default res value of 0.0f is used. This patch also adds a per device scaling factor, which is used to suitably modify the values reported (as well as the resolution) to tune the input events generated and resulting UI according to the hardware. This can be specified in the IDC file as: device.scalingFactor = xxxx of type float. If a scaling factor is not provided, a default of 1.0f is used. Bug: 22836852 Bug: 18707397 Change-Id: I13686f64de1b52d3f6c97b2587ae41e52d1db6e2 --- services/inputflinger/InputReader.cpp | 15 +++++++++++++-- services/inputflinger/InputReader.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp index 3ba38b56a..8063a755b 100644 --- a/services/inputflinger/InputReader.cpp +++ b/services/inputflinger/InputReader.cpp @@ -2751,7 +2751,18 @@ void RotaryEncoderInputMapper::populateDeviceInfo(InputDeviceInfo* info) { InputMapper::populateDeviceInfo(info); if (mRotaryEncoderScrollAccumulator.haveRelativeVWheel()) { - info->addMotionRange(AMOTION_EVENT_AXIS_SCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f); + float res = 0.0f; + if (!mDevice->getConfiguration().tryGetProperty(String8("device.res"), res)) { + ALOGW("Rotary Encoder device configuration file didn't specify resolution!\n"); + } + if (!mDevice->getConfiguration().tryGetProperty(String8("device.scalingFactor"), + mScalingFactor)) { + ALOGW("Rotary Encoder device configuration file didn't specify scaling factor," + "default to 1.0!\n"); + mScalingFactor = 1.0f; + } + info->addMotionRange(AMOTION_EVENT_AXIS_SCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, + res * mScalingFactor); } } @@ -2807,7 +2818,7 @@ void RotaryEncoderInputMapper::sync(nsecs_t when) { // Send motion event. if (scrolled) { int32_t metaState = mContext->getGlobalMetaState(); - pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_SCROLL, scroll); + pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_SCROLL, scroll * mScalingFactor); NotifyMotionArgs scrollArgs(when, getDeviceId(), mSource, policyFlags, AMOTION_EVENT_ACTION_SCROLL, 0, 0, metaState, 0, diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h index 3e931fef9..46d45d848 100644 --- a/services/inputflinger/InputReader.h +++ b/services/inputflinger/InputReader.h @@ -1247,6 +1247,7 @@ private: CursorScrollAccumulator mRotaryEncoderScrollAccumulator; int32_t mSource; + float mScalingFactor; void sync(nsecs_t when); }; From 2c09b78656dd97727f94fada81845b133cf142f3 Mon Sep 17 00:00:00 2001 From: Prashant Malani Date: Wed, 13 Jan 2016 01:00:08 -0800 Subject: [PATCH 20/21] Revert "inputflinger: Add support for scaling and true value reporting" This reverts commit ee03865fe5fc6ffe9deda0e0870a18206027cfaf. --- services/inputflinger/InputReader.cpp | 15 ++------------- services/inputflinger/InputReader.h | 1 - 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp index 8063a755b..3ba38b56a 100644 --- a/services/inputflinger/InputReader.cpp +++ b/services/inputflinger/InputReader.cpp @@ -2751,18 +2751,7 @@ void RotaryEncoderInputMapper::populateDeviceInfo(InputDeviceInfo* info) { InputMapper::populateDeviceInfo(info); if (mRotaryEncoderScrollAccumulator.haveRelativeVWheel()) { - float res = 0.0f; - if (!mDevice->getConfiguration().tryGetProperty(String8("device.res"), res)) { - ALOGW("Rotary Encoder device configuration file didn't specify resolution!\n"); - } - if (!mDevice->getConfiguration().tryGetProperty(String8("device.scalingFactor"), - mScalingFactor)) { - ALOGW("Rotary Encoder device configuration file didn't specify scaling factor," - "default to 1.0!\n"); - mScalingFactor = 1.0f; - } - info->addMotionRange(AMOTION_EVENT_AXIS_SCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, - res * mScalingFactor); + info->addMotionRange(AMOTION_EVENT_AXIS_SCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f); } } @@ -2818,7 +2807,7 @@ void RotaryEncoderInputMapper::sync(nsecs_t when) { // Send motion event. if (scrolled) { int32_t metaState = mContext->getGlobalMetaState(); - pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_SCROLL, scroll * mScalingFactor); + pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_SCROLL, scroll); NotifyMotionArgs scrollArgs(when, getDeviceId(), mSource, policyFlags, AMOTION_EVENT_ACTION_SCROLL, 0, 0, metaState, 0, diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h index 46d45d848..3e931fef9 100644 --- a/services/inputflinger/InputReader.h +++ b/services/inputflinger/InputReader.h @@ -1247,7 +1247,6 @@ private: CursorScrollAccumulator mRotaryEncoderScrollAccumulator; int32_t mSource; - float mScalingFactor; void sync(nsecs_t when); }; From d983fd11d4a00b03f92d09f32c08840e66d90777 Mon Sep 17 00:00:00 2001 From: Prashant Malani Date: Wed, 13 Jan 2016 01:00:25 -0800 Subject: [PATCH 21/21] Revert "inputflinger: Initial support for rotary encoders." This reverts commit ac72bbf4e46d6689070df09a25db2960a9036eb2. --- include/android/input.h | 9 --- services/inputflinger/EventHub.cpp | 9 --- services/inputflinger/EventHub.h | 3 - services/inputflinger/InputReader.cpp | 91 --------------------------- services/inputflinger/InputReader.h | 20 ------ 5 files changed, 132 deletions(-) diff --git a/include/android/input.h b/include/android/input.h index 5eeb7fc89..5ab4e2926 100644 --- a/include/android/input.h +++ b/include/android/input.h @@ -643,13 +643,6 @@ enum { * against the surface. */ AMOTION_EVENT_AXIS_TILT = 25, - /** - * Axis constant: Generic scroll axis of a motion event. - * - * - This is used for scroll axis motion events that can't be classified as strictly - * vertical or horizontal. The movement of a rotating scroller is an example of this. - */ - AMOTION_EVENT_AXIS_SCROLL = 26, /** * Axis constant: Generic 1 axis of a motion event. * The interpretation of a generic axis is device-specific. @@ -824,8 +817,6 @@ enum { AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE, /** joystick */ AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK, - /** rotary encoder */ - AINPUT_SOURCE_ROTARY_ENCODER = 0x00400000 | AINPUT_SOURCE_CLASS_NONE, /** any */ AINPUT_SOURCE_ANY = 0xffffff00, diff --git a/services/inputflinger/EventHub.cpp b/services/inputflinger/EventHub.cpp index 2a53dec41..585960628 100644 --- a/services/inputflinger/EventHub.cpp +++ b/services/inputflinger/EventHub.cpp @@ -1191,15 +1191,6 @@ status_t EventHub::openDeviceLocked(const char *devicePath) { device->classes |= INPUT_DEVICE_CLASS_CURSOR; } - // See if this is a rotary encoder type device. - String8 deviceType = String8(); - if (device->configuration && - device->configuration->tryGetProperty(String8("device.type"), deviceType)) { - if (!deviceType.compare(String8("rotaryEncoder"))) { - device->classes |= INPUT_DEVICE_CLASS_ROTARY_ENCODER; - } - } - // See if this is a touch pad. // Is this a new modern multi-touch driver? if (test_bit(ABS_MT_POSITION_X, device->absBitmask) diff --git a/services/inputflinger/EventHub.h b/services/inputflinger/EventHub.h index 686925311..0f94c770e 100644 --- a/services/inputflinger/EventHub.h +++ b/services/inputflinger/EventHub.h @@ -137,9 +137,6 @@ enum { /* The input device is an external stylus (has data we want to fuse with touch data). */ INPUT_DEVICE_CLASS_EXTERNAL_STYLUS = 0x00000800, - /* The input device has a rotary encoder */ - INPUT_DEVICE_CLASS_ROTARY_ENCODER = 0x00001000, - /* The input device is virtual (not a real device, not part of UI configuration). */ INPUT_DEVICE_CLASS_VIRTUAL = 0x40000000, diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp index 3ba38b56a..b2cbfe801 100644 --- a/services/inputflinger/InputReader.cpp +++ b/services/inputflinger/InputReader.cpp @@ -450,11 +450,6 @@ InputDevice* InputReader::createDeviceLocked(int32_t deviceId, int32_t controlle device->addMapper(new SwitchInputMapper(device)); } - // Scroll wheel-like devices. - if (classes & INPUT_DEVICE_CLASS_ROTARY_ENCODER) { - device->addMapper(new RotaryEncoderInputMapper(device)); - } - // Vibrator-like devices. if (classes & INPUT_DEVICE_CLASS_VIBRATOR) { device->addMapper(new VibratorInputMapper(device)); @@ -2733,92 +2728,6 @@ void CursorInputMapper::fadePointer() { } } -// --- RotaryEncoderInputMapper --- - -RotaryEncoderInputMapper::RotaryEncoderInputMapper(InputDevice* device) : - InputMapper(device) { - mSource = AINPUT_SOURCE_ROTARY_ENCODER; -} - -RotaryEncoderInputMapper::~RotaryEncoderInputMapper() { -} - -uint32_t RotaryEncoderInputMapper::getSources() { - return mSource; -} - -void RotaryEncoderInputMapper::populateDeviceInfo(InputDeviceInfo* info) { - InputMapper::populateDeviceInfo(info); - - if (mRotaryEncoderScrollAccumulator.haveRelativeVWheel()) { - info->addMotionRange(AMOTION_EVENT_AXIS_SCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f); - } -} - -void RotaryEncoderInputMapper::dump(String8& dump) { - dump.append(INDENT2 "Rotary Encoder Input Mapper:\n"); - dump.appendFormat(INDENT3 "HaveWheel: %s\n", - toString(mRotaryEncoderScrollAccumulator.haveRelativeVWheel())); -} - -void RotaryEncoderInputMapper::configure(nsecs_t when, - const InputReaderConfiguration* config, uint32_t changes) { - InputMapper::configure(when, config, changes); - if (!changes) { - mRotaryEncoderScrollAccumulator.configure(getDevice()); - } -} - -void RotaryEncoderInputMapper::reset(nsecs_t when) { - mRotaryEncoderScrollAccumulator.reset(getDevice()); - - InputMapper::reset(when); -} - -void RotaryEncoderInputMapper::process(const RawEvent* rawEvent) { - mRotaryEncoderScrollAccumulator.process(rawEvent); - - if (rawEvent->type == EV_SYN && rawEvent->code == SYN_REPORT) { - sync(rawEvent->when); - } -} - -void RotaryEncoderInputMapper::sync(nsecs_t when) { - PointerCoords pointerCoords; - pointerCoords.clear(); - - PointerProperties pointerProperties; - pointerProperties.clear(); - pointerProperties.id = 0; - pointerProperties.toolType = AMOTION_EVENT_TOOL_TYPE_UNKNOWN; - - float scroll = mRotaryEncoderScrollAccumulator.getRelativeVWheel(); - bool scrolled = scroll != 0; - - // This is not a pointer, so it's not associated with a display. - int32_t displayId = ADISPLAY_ID_NONE; - - // Moving the rotary encoder should wake the device (if specified). - uint32_t policyFlags = 0; - if (scrolled && getDevice()->isExternal()) { - policyFlags |= POLICY_FLAG_WAKE; - } - - // Send motion event. - if (scrolled) { - int32_t metaState = mContext->getGlobalMetaState(); - pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_SCROLL, scroll); - - NotifyMotionArgs scrollArgs(when, getDeviceId(), mSource, policyFlags, - AMOTION_EVENT_ACTION_SCROLL, 0, 0, metaState, 0, - AMOTION_EVENT_EDGE_FLAG_NONE, - displayId, 1, &pointerProperties, &pointerCoords, - 0, 0, 0); - getListener()->notifyMotion(&scrollArgs); - } - - mRotaryEncoderScrollAccumulator.finishSync(); -} // --- TouchInputMapper --- diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h index 3e931fef9..30c84b126 100644 --- a/services/inputflinger/InputReader.h +++ b/services/inputflinger/InputReader.h @@ -1231,26 +1231,6 @@ private: }; -class RotaryEncoderInputMapper : public InputMapper { -public: - RotaryEncoderInputMapper(InputDevice* device); - virtual ~RotaryEncoderInputMapper(); - - virtual uint32_t getSources(); - virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo); - virtual void dump(String8& dump); - virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes); - virtual void reset(nsecs_t when); - virtual void process(const RawEvent* rawEvent); - -private: - CursorScrollAccumulator mRotaryEncoderScrollAccumulator; - - int32_t mSource; - - void sync(nsecs_t when); -}; - class TouchInputMapper : public InputMapper { public: TouchInputMapper(InputDevice* device);