From 687aa22c9281e37b7a8bd674bd2de183aebcc22b Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Fri, 10 Jul 2015 13:08:28 -0700 Subject: [PATCH 01/19] Show charging speed on Keyguard Bug: 8099739 Change-Id: I2e5c21dd7ec028ce47fb03ab71e74f7fccaa9e36 --- include/batteryservice/BatteryService.h | 1 + services/batteryservice/BatteryProperties.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/batteryservice/BatteryService.h b/include/batteryservice/BatteryService.h index 6211cf4ca..f0a2790a9 100644 --- a/include/batteryservice/BatteryService.h +++ b/include/batteryservice/BatteryService.h @@ -57,6 +57,7 @@ struct BatteryProperties { bool chargerAcOnline; bool chargerUsbOnline; bool chargerWirelessOnline; + int maxChargingCurrent; int batteryStatus; int batteryHealth; bool batteryPresent; diff --git a/services/batteryservice/BatteryProperties.cpp b/services/batteryservice/BatteryProperties.cpp index ab636a9f8..f13d6e8b4 100644 --- a/services/batteryservice/BatteryProperties.cpp +++ b/services/batteryservice/BatteryProperties.cpp @@ -33,6 +33,7 @@ status_t BatteryProperties::readFromParcel(Parcel* p) { chargerAcOnline = p->readInt32() == 1 ? true : false; chargerUsbOnline = p->readInt32() == 1 ? true : false; chargerWirelessOnline = p->readInt32() == 1 ? true : false; + maxChargingCurrent = p->readInt32(); batteryStatus = p->readInt32(); batteryHealth = p->readInt32(); batteryPresent = p->readInt32() == 1 ? true : false; @@ -47,6 +48,7 @@ status_t BatteryProperties::writeToParcel(Parcel* p) const { p->writeInt32(chargerAcOnline ? 1 : 0); p->writeInt32(chargerUsbOnline ? 1 : 0); p->writeInt32(chargerWirelessOnline ? 1 : 0); + p->writeInt32(maxChargingCurrent); p->writeInt32(batteryStatus); p->writeInt32(batteryHealth); p->writeInt32(batteryPresent ? 1 : 0); From 14cd37cf3d7d783eaeb4cfb5f1f9e712d3b49578 Mon Sep 17 00:00:00 2001 From: Dan Stoza Date: Thu, 9 Jul 2015 12:43:33 -0700 Subject: [PATCH 02/19] SF: Track missed frames and optionally drop them Adds code to track whether SurfaceFlinger has sent two frames to HWC in the same vsync window. This can occur if one frame is delayed so far it slips into the next window or just if one frame takes an abnormal amount of time. If this occurs, it shows up as FrameMissed in systrace. Also adds a property debug.sf.drop_missed_frames which, if set, tells SurfaceFlinger to skip sending a frame to HWC (i.e., calling prepare/set) when we detect this condition, which can help prevent backpressure from the HWC implementation. Bug: 22513558 Change-Id: I2df0d44cec5fd6edba419388d8c90b5710d1a5b6 --- services/surfaceflinger/SurfaceFlinger.cpp | 34 ++++++++++++++++++---- services/surfaceflinger/SurfaceFlinger.h | 1 + 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 9b9867d84..01ffac29b 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -163,6 +163,9 @@ SurfaceFlinger::SurfaceFlinger() property_get("ro.bq.gpu_to_cpu_unsupported", value, "0"); mGpuToCpuSupported = !atoi(value); + property_get("debug.sf.drop_missed_frames", value, "0"); + mDropMissedFrames = atoi(value); + property_get("debug.sf.showupdates", value, "0"); mDebugRegion = atoi(value); @@ -919,12 +922,31 @@ bool SurfaceFlinger::handleMessageInvalidate() { void SurfaceFlinger::handleMessageRefresh() { ATRACE_CALL(); - preComposition(); - rebuildLayerStacks(); - setUpHWComposer(); - doDebugFlashRegions(); - doComposition(); - postComposition(); + + static nsecs_t previousExpectedPresent = 0; + nsecs_t expectedPresent = mPrimaryDispSync.computeNextRefresh(0); + static bool previousFrameMissed = false; + bool frameMissed = (expectedPresent == previousExpectedPresent); + if (frameMissed != previousFrameMissed) { + ATRACE_INT("FrameMissed", static_cast(frameMissed)); + } + previousFrameMissed = frameMissed; + + if (CC_UNLIKELY(mDropMissedFrames && frameMissed)) { + // Latch buffers, but don't send anything to HWC, then signal another + // wakeup for the next vsync + preComposition(); + repaintEverything(); + } else { + preComposition(); + rebuildLayerStacks(); + setUpHWComposer(); + doDebugFlashRegions(); + doComposition(); + postComposition(); + } + + previousExpectedPresent = mPrimaryDispSync.computeNextRefresh(0); } void SurfaceFlinger::doDebugFlashRegions() diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 3759a9240..b3baadd46 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -445,6 +445,7 @@ private: RenderEngine* mRenderEngine; nsecs_t mBootTime; bool mGpuToCpuSupported; + bool mDropMissedFrames; sp mEventThread; sp mSFEventThread; sp mEventControlThread; From 5a373bb9b0ffb9a58686079c971aaa4d8788218f Mon Sep 17 00:00:00 2001 From: Narayan Kamath Date: Wed, 29 Jul 2015 09:36:05 +0000 Subject: [PATCH 03/19] Revert "Bug fix in SensorManager." This reverts commit 869eb2089ec8a6286b944bfcff57e4cbe0c7e207. Change-Id: I4fb865e3b18bbb011fa4e4b4732336930c3a45ae --- include/gui/SensorManager.h | 4 +--- libs/gui/SensorManager.cpp | 11 +++-------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/include/gui/SensorManager.h b/include/gui/SensorManager.h index 9794d4e08..37960673c 100644 --- a/include/gui/SensorManager.h +++ b/include/gui/SensorManager.h @@ -101,6 +101,7 @@ public: return *sensorManager; } + SensorManager(const String16& opPackageName); ~SensorManager(); ssize_t getSensorList(Sensor const* const** list) const; @@ -112,7 +113,6 @@ private: // DeathRecipient interface void sensorManagerDied(); - SensorManager(const String16& opPackageName); status_t assertStateLocked() const; private: @@ -127,8 +127,6 @@ private: const String16 mOpPackageName; }; -android::Mutex android::SensorManager::sLock; -std::map android::SensorManager::sPackageInstances; // ---------------------------------------------------------------------------- }; // namespace android diff --git a/libs/gui/SensorManager.cpp b/libs/gui/SensorManager.cpp index ead535e63..dd3778137 100644 --- a/libs/gui/SensorManager.cpp +++ b/libs/gui/SensorManager.cpp @@ -59,13 +59,12 @@ void SensorManager::sensorManagerDied() status_t SensorManager::assertStateLocked() const { if (mSensorServer == NULL) { + // try for one second const String16 name("sensorservice"); - // try 10 times before giving up ... - for (int i = 0; i < 10; ++i) { + for (int i=0 ; i<4 ; i++) { status_t err = getService(name, &mSensorServer); if (err == NAME_NOT_FOUND) { - // Sleep for 1 second before retrying. - sleep(1); + usleep(250000); continue; } if (err != NO_ERROR) { @@ -74,10 +73,6 @@ status_t SensorManager::assertStateLocked() const { break; } - if (mSensorServer == NULL) { - ALOGE("FATAL getsensorservice returned` NULL"); - } - class DeathObserver : public IBinder::DeathRecipient { SensorManager& mSensorManger; virtual void binderDied(const wp& who) { From e2806cb4456e3815e979f333ed23ec7df591a9ff Mon Sep 17 00:00:00 2001 From: Aravind Akella Date: Wed, 29 Jul 2015 18:03:48 -0700 Subject: [PATCH 04/19] 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 --- 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 8f35ca973063e1449c5ec40b618393187a47ec58 Mon Sep 17 00:00:00 2001 From: Aravind Akella Date: Mon, 17 Aug 2015 15:22:12 -0700 Subject: [PATCH 05/19] SensorManager fixes. i) Use pingBinder() to check the status of sensorservice everytime an event_queue is created. Retry to establish the binder connection if SensorService has recovered from a runtime restart. ii) LOG_ALWAYS_FATAL_IF getService(SensorService) returns NULL or malloc returns NULL. Bug: 22634472 Change-Id: I4e3912839b6f4114be1a124510878774dbd576a4 --- libs/gui/SensorManager.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/libs/gui/SensorManager.cpp b/libs/gui/SensorManager.cpp index 993415126..33608b5bd 100644 --- a/libs/gui/SensorManager.cpp +++ b/libs/gui/SensorManager.cpp @@ -110,10 +110,20 @@ void SensorManager::sensorManagerDied() } status_t SensorManager::assertStateLocked() const { + bool initSensorManager = false; if (mSensorServer == NULL) { - // try for 10 seconds before giving up ... + initSensorManager = true; + } else { + // Ping binder to check if sensorservice is alive. + status_t err = IInterface::asBinder(mSensorServer)->pingBinder(); + if (err != NO_ERROR) { + initSensorManager = true; + } + } + if (initSensorManager) { + // try for 300 seconds (60*5(getService() tries for 5 seconds)) before giving up ... const String16 name("sensorservice"); - for (int i = 0;i < 10; i++) { + for (int i = 0; i < 60; i++) { status_t err = getService(name, &mSensorServer); if (err == NAME_NOT_FOUND) { sleep(1); @@ -135,9 +145,7 @@ status_t SensorManager::assertStateLocked() const { DeathObserver(SensorManager& mgr) : mSensorManger(mgr) { } }; - if (mSensorServer == NULL) { - ALOGE("FATAL getsensorservice returned NULL"); - } + LOG_ALWAYS_FATAL_IF(mSensorServer.get() == NULL, "getService(SensorService) NULL"); mDeathObserver = new DeathObserver(*const_cast(this)); IInterface::asBinder(mSensorServer)->linkToDeath(mDeathObserver); @@ -146,6 +154,8 @@ status_t SensorManager::assertStateLocked() const { size_t count = mSensors.size(); mSensorList = static_cast(malloc(count * sizeof(Sensor*))); + LOG_ALWAYS_FATAL_IF(mSensorList == NULL, "mSensorList NULL"); + for (size_t i=0 ; i Date: Thu, 27 Aug 2015 20:09:39 -0700 Subject: [PATCH 06/19] Add XML for pro audio feature Bug: 23604253 Change-Id: I480cf0a46c286badc6fd95a3b42e6cb1ed056b1b --- data/etc/android.hardware.audio.pro.xml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 data/etc/android.hardware.audio.pro.xml diff --git a/data/etc/android.hardware.audio.pro.xml b/data/etc/android.hardware.audio.pro.xml new file mode 100644 index 000000000..5328d415c --- /dev/null +++ b/data/etc/android.hardware.audio.pro.xml @@ -0,0 +1,22 @@ + + + + + + + From 0bcd97a7485d971c5276e19b1a6c2672539dc38d Mon Sep 17 00:00:00 2001 From: Martijn Coenen Date: Wed, 15 Jul 2015 14:25:23 +0200 Subject: [PATCH 07/19] Map realtime to clock_monotonic. This maps a monotonic timestamp to the corresponding real-time timestamp, which can be used to match up the traces with other logs that use real-time. Also write clock_sync records first instead of at the end, to avoid not being to write it due to the buffer being full. Bug: 23668823 Change-Id: I644aeea496197e194ec30f808f754e3e043d905f --- cmds/atrace/atrace.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp index 9def406ea..26c5b4ac3 100644 --- a/cmds/atrace/atrace.cpp +++ b/cmds/atrace/atrace.cpp @@ -264,9 +264,27 @@ static bool appendStr(const char* filename, const char* str) static void writeClockSyncMarker() { char buffer[128]; + int len = 0; + int fd = open(k_traceMarkerPath, O_WRONLY); + if (fd == -1) { + fprintf(stderr, "error opening %s: %s (%d)\n", k_traceMarkerPath, + strerror(errno), errno); + return; + } float now_in_seconds = systemTime(CLOCK_MONOTONIC) / 1000000000.0f; - snprintf(buffer, 128, "trace_event_clock_sync: parent_ts=%f\n", now_in_seconds); - writeStr(k_traceMarkerPath, buffer); + + len = snprintf(buffer, 128, "trace_event_clock_sync: parent_ts=%f\n", now_in_seconds); + if (write(fd, buffer, len) != len) { + fprintf(stderr, "error writing clock sync marker %s (%d)\n", strerror(errno), errno); + } + + int64_t realtime_in_ms = systemTime(CLOCK_REALTIME) / 1000000; + len = snprintf(buffer, 128, "trace_event_clock_sync: realtime_ts=%" PRId64 "\n", realtime_in_ms); + if (write(fd, buffer, len) != len) { + fprintf(stderr, "error writing clock sync marker %s (%d)\n", strerror(errno), errno); + } + + close(fd); } // Enable or disable a kernel option by writing a "1" or a "0" into a /sys @@ -646,7 +664,6 @@ static bool startTrace() // Disable tracing in the kernel. static void stopTrace() { - writeClockSyncMarker(); setTracingEnabled(false); } @@ -940,6 +957,7 @@ int main(int argc, char **argv) // another. ok = clearTrace(); + writeClockSyncMarker(); if (ok && !async) { // Sleep to allow the trace to be captured. struct timespec timeLeft; From f2699fc3a8c12b2bf95120c068801e050168bd96 Mon Sep 17 00:00:00 2001 From: Dan Stoza Date: Mon, 31 Aug 2015 12:06:48 -0700 Subject: [PATCH 08/19] SF: Add colorTransform to DisplayInfo Adds the colorTransform field, which defines a vendor-specific color transform (e.g., wide gamut, sRGB, etc.) to the DisplayInfo class, and populates it from the HWC interface. Bug: 20853317 Change-Id: I153edc36a361407656f3eb5082b96c2da2ecbec7 --- include/ui/DisplayInfo.h | 1 + .../DisplayHardware/HWComposer.cpp | 27 ++++++++++++++++--- .../DisplayHardware/HWComposer.h | 1 + services/surfaceflinger/SurfaceFlinger.cpp | 1 + 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/include/ui/DisplayInfo.h b/include/ui/DisplayInfo.h index 799944f3e..ad73ee72f 100644 --- a/include/ui/DisplayInfo.h +++ b/include/ui/DisplayInfo.h @@ -36,6 +36,7 @@ struct DisplayInfo { bool secure; nsecs_t appVsyncOffset; nsecs_t presentationDeadline; + int colorTransform; }; /* Display orientations as defined in Surface.java and ISurfaceComposer.h. */ diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp index 2dad00517..085914915 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp +++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp @@ -336,10 +336,20 @@ static const uint32_t DISPLAY_ATTRIBUTES[] = { HWC_DISPLAY_HEIGHT, HWC_DISPLAY_DPI_X, HWC_DISPLAY_DPI_Y, + HWC_DISPLAY_COLOR_TRANSFORM, HWC_DISPLAY_NO_ATTRIBUTE, }; #define NUM_DISPLAY_ATTRIBUTES (sizeof(DISPLAY_ATTRIBUTES) / sizeof(DISPLAY_ATTRIBUTES)[0]) +static const uint32_t PRE_HWC15_DISPLAY_ATTRIBUTES[] = { + HWC_DISPLAY_VSYNC_PERIOD, + HWC_DISPLAY_WIDTH, + HWC_DISPLAY_HEIGHT, + HWC_DISPLAY_DPI_X, + HWC_DISPLAY_DPI_Y, + HWC_DISPLAY_NO_ATTRIBUTE, +}; + status_t HWComposer::queryDisplayProperties(int disp) { LOG_ALWAYS_FATAL_IF(!mHwc || !hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)); @@ -362,6 +372,12 @@ status_t HWComposer::queryDisplayProperties(int disp) { for (size_t c = 0; c < numConfigs; ++c) { err = mHwc->getDisplayAttributes(mHwc, disp, configs[c], DISPLAY_ATTRIBUTES, values); + // If this is a pre-1.5 HWC, it may not know about color transform, so + // try again with a smaller set of attributes + if (err != NO_ERROR) { + err = mHwc->getDisplayAttributes(mHwc, disp, configs[c], + PRE_HWC15_DISPLAY_ATTRIBUTES, values); + } if (err != NO_ERROR) { // we can't get this display's info. turn it off. mDisplayData[disp].connected = false; @@ -386,6 +402,9 @@ status_t HWComposer::queryDisplayProperties(int disp) { case HWC_DISPLAY_DPI_Y: config.ydpi = values[i] / 1000.0f; break; + case HWC_DISPLAY_COLOR_TRANSFORM: + config.colorTransform = values[i]; + break; default: ALOG_ASSERT(false, "unknown display attribute[%zu] %#x", i, DISPLAY_ATTRIBUTES[i]); @@ -1162,9 +1181,11 @@ void HWComposer::dump(String8& result) const { result.appendFormat(" Display[%zd] configurations (* current):\n", i); for (size_t c = 0; c < disp.configs.size(); ++c) { const DisplayConfig& config(disp.configs[c]); - result.appendFormat(" %s%zd: %ux%u, xdpi=%f, ydpi=%f, refresh=%" PRId64 "\n", - c == disp.currentConfig ? "* " : "", c, config.width, config.height, - config.xdpi, config.ydpi, config.refresh); + result.appendFormat(" %s%zd: %ux%u, xdpi=%f, ydpi=%f" + ", refresh=%" PRId64 ", colorTransform=%d\n", + c == disp.currentConfig ? "* " : "", c, + config.width, config.height, config.xdpi, config.ydpi, + config.refresh, config.colorTransform); } if (disp.list) { diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h index cc98b4c20..5e0b3d85e 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.h +++ b/services/surfaceflinger/DisplayHardware/HWComposer.h @@ -257,6 +257,7 @@ public: float xdpi; float ydpi; nsecs_t refresh; + int colorTransform; }; // Query display parameters. Pass in a display index (e.g. diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 01ffac29b..fdc36505c 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -632,6 +632,7 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp& display, info.ydpi = ydpi; info.fps = float(1e9 / hwConfig.refresh); info.appVsyncOffset = VSYNC_EVENT_PHASE_OFFSET_NS; + info.colorTransform = hwConfig.colorTransform; // This is how far in advance a buffer must be queued for // presentation at a given time. If you want a buffer to appear From e35c7d65bb3c226fe3c5fc5e3933f64f0963eaeb Mon Sep 17 00:00:00 2001 From: Prashant Malani Date: Thu, 20 Aug 2015 17:19:05 -0700 Subject: [PATCH 09/19] Add body sensors app op for custom sensors If the custom sensor requires the BODY SENSOR permission, we should add the body sensors app op for the custom sensor Bug: 23396558 Change-Id: I132917d1bca12c76c8a9fb146e00951cba3e6d7a --- libs/gui/Sensor.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/gui/Sensor.cpp b/libs/gui/Sensor.cpp index 2545eec33..4b3603ee1 100644 --- a/libs/gui/Sensor.cpp +++ b/libs/gui/Sensor.cpp @@ -223,6 +223,10 @@ Sensor::Sensor(struct sensor_t const* hwSensor, int halVersion) } if (halVersion > SENSORS_DEVICE_API_VERSION_1_0 && hwSensor->requiredPermission) { mRequiredPermission = hwSensor->requiredPermission; + if (!strcmp(mRequiredPermission, SENSOR_PERMISSION_BODY_SENSORS)) { + AppOpsManager appOps; + mRequiredAppOp = appOps.permissionToOpCode(String16(SENSOR_PERMISSION_BODY_SENSORS)); + } } if (halVersion >= SENSORS_DEVICE_API_VERSION_1_3) { From 6afc38c45af45eb8f64793bca2903b3f4c55579b Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Wed, 9 Sep 2015 22:59:25 +0900 Subject: [PATCH 10/19] Dump the ND offload status and address table in bugreports. Also, move NetworkDiagnostics between the two runs of getting the wifi counters, so we can see the effect on the counters of sending our probe packets. Bug: 23661687 Change-Id: I3f81c003a35f50ac1cb8e77d0a8c73dae4fd91f3 --- cmds/dumpstate/dumpstate.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index ef8db0693..792f0155c 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -434,8 +434,6 @@ static void dumpstate() { run_command("ARP CACHE", 10, "ip", "-4", "neigh", "show", NULL); run_command("IPv6 ND CACHE", 10, "ip", "-6", "neigh", "show", NULL); - run_command("NETWORK DIAGNOSTICS", 10, "dumpsys", "connectivity", "--diag", NULL); - run_command("IPTABLES", 10, SU_PATH, "root", "iptables", "-L", "-nvx", NULL); run_command("IP6TABLES", 10, SU_PATH, "root", "ip6tables", "-L", "-nvx", NULL); run_command("IPTABLE NAT", 10, SU_PATH, "root", "iptables", "-t", "nat", "-L", "-nvx", NULL); @@ -447,25 +445,29 @@ static void dumpstate() { SU_PATH, "root", "wpa_cli", "IFNAME=wlan0", "list_networks", NULL); #ifdef FWDUMP_bcmdhd - run_command("DUMP WIFI INTERNAL COUNTERS", 20, + run_command("ND OFFLOAD TABLE", 5, + SU_PATH, "root", "wlutil", "nd_hostip", NULL); + + run_command("DUMP WIFI INTERNAL COUNTERS (1)", 20, SU_PATH, "root", "wlutil", "counters", NULL); + + run_command("ND OFFLOAD STATUS (1)", 5, + SU_PATH, "root", "wlutil", "nd_status", NULL); + #endif dump_file("INTERRUPTS (1)", "/proc/interrupts"); - property_get("dhcp.wlan0.gateway", network, ""); - if (network[0]) - run_command("PING GATEWAY", 10, "ping", "-c", "3", "-i", ".5", network, NULL); - property_get("dhcp.wlan0.dns1", network, ""); - if (network[0]) - run_command("PING DNS1", 10, "ping", "-c", "3", "-i", ".5", network, NULL); - property_get("dhcp.wlan0.dns2", network, ""); - if (network[0]) - run_command("PING DNS2", 10, "ping", "-c", "3", "-i", ".5", network, NULL); + run_command("NETWORK DIAGNOSTICS", 10, "dumpsys", "connectivity", "--diag", NULL); + #ifdef FWDUMP_bcmdhd run_command("DUMP WIFI STATUS", 20, SU_PATH, "root", "dhdutil", "-i", "wlan0", "dump", NULL); - run_command("DUMP WIFI INTERNAL COUNTERS", 20, + + run_command("DUMP WIFI INTERNAL COUNTERS (2)", 20, SU_PATH, "root", "wlutil", "counters", NULL); + + run_command("ND OFFLOAD STATUS (2)", 5, + SU_PATH, "root", "wlutil", "nd_status", NULL); #endif dump_file("INTERRUPTS (2)", "/proc/interrupts"); From 21948005f0294a64a42932b21a33ae75295dc3d9 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Mon, 14 Sep 2015 16:33:11 -0700 Subject: [PATCH 11/19] Installd: Allow different behavior before bootcomplete Check dev.bootcomplete in dex2oat(). Use the information for two changes. Only switch to the background when we're post bootcomplete. This will ensure better utilization after upgrades. Add a second dex2oat-threads property that is used pre bootcomplete. A separation of these phases allows using less cores when the device is up, freeing up resources for other purposes, e.g., avoid jank. The precedence during boot is the boot property, or the image property if the former doesn't exist, or the default property as a fallback. Bug: 23898216 Bug: 24004256 Change-Id: I5063f3fc4b437cbe88c4e94584e01c1c78eccc4d --- cmds/installd/commands.cpp | 55 +++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/cmds/installd/commands.cpp b/cmds/installd/commands.cpp index 7090b3677..769cd341f 100644 --- a/cmds/installd/commands.cpp +++ b/cmds/installd/commands.cpp @@ -746,7 +746,7 @@ static bool check_boolean_property(const char* property_name, bool default_value static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name, const char* output_file_name, int swap_fd, const char *pkgname, const char *instruction_set, - bool vm_safe_mode, bool debuggable) + bool vm_safe_mode, bool debuggable, bool post_bootcomplete) { static const unsigned int MAX_INSTRUCTION_SET_LEN = 7; @@ -770,8 +770,24 @@ 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 = property_get("dalvik.vm.dex2oat-threads", dex2oat_threads_buf, - NULL) > 0; + 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; + } char dex2oat_threads_arg[PROPERTY_VALUE_MAX + 2]; if (have_dex2oat_threads_flag) { sprintf(dex2oat_threads_arg, "-j%s", dex2oat_threads_buf); @@ -1065,6 +1081,27 @@ static bool calculate_odex_file_path(char path[PKG_PATH_MAX], return true; } +static bool IsPostBootComplete() { + char dev_bootcomplete_prop_buf[PROPERTY_VALUE_MAX]; + if (property_get("dev.bootcomplete", dev_bootcomplete_prop_buf, "0") > 0) { + return (strcmp(dev_bootcomplete_prop_buf, "1") == 0); + } + return false; +} + +static void SetDex2OatAndPatchOatScheduling(bool set_to_bg) { + if (set_to_bg) { + if (set_sched_policy(0, SP_BACKGROUND) < 0) { + ALOGE("set_sched_policy failed: %s\n", strerror(errno)); + exit(70); + } + if (setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_BACKGROUND) < 0) { + ALOGE("setpriority failed: %s\n", strerror(errno)); + exit(71); + } + } +} + int dexopt(const char *apk_path, uid_t uid, bool is_public, const char *pkgname, const char *instruction_set, int dexopt_needed, bool vm_safe_mode, bool debuggable, const char* oat_dir) @@ -1076,6 +1113,7 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public, const char *input_file; char in_odex_path[PKG_PATH_MAX]; int res, input_fd=-1, out_fd=-1, swap_fd=-1; + bool post_bootcomplete = IsPostBootComplete(); // Early best-effort check whether we can fit the the path into our buffers. // Note: the cache path will require an additional 5 bytes for ".swap", but we'll try to run @@ -1198,14 +1236,7 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public, ALOGE("capset failed: %s\n", strerror(errno)); exit(66); } - if (set_sched_policy(0, SP_BACKGROUND) < 0) { - ALOGE("set_sched_policy failed: %s\n", strerror(errno)); - exit(70); - } - if (setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_BACKGROUND) < 0) { - ALOGE("setpriority failed: %s\n", strerror(errno)); - exit(71); - } + SetDex2OatAndPatchOatScheduling(post_bootcomplete); if (flock(out_fd, LOCK_EX | LOCK_NB) != 0) { ALOGE("flock(%s) failed: %s\n", out_path, strerror(errno)); exit(67); @@ -1222,7 +1253,7 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public, input_file_name++; } run_dex2oat(input_fd, out_fd, input_file_name, out_path, swap_fd, pkgname, - instruction_set, vm_safe_mode, debuggable); + instruction_set, vm_safe_mode, debuggable, post_bootcomplete); } else { ALOGE("Invalid dexopt needed: %d\n", dexopt_needed); exit(73); From 38b4b28c19c38a6043c6d914f4315926dcb9d94d Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Mon, 14 Sep 2015 16:33:11 -0700 Subject: [PATCH 12/19] Installd: Allow different behavior before bootcomplete Check dev.bootcomplete in dex2oat(). Use the information for two changes. Only switch to the background when we're post bootcomplete. This will ensure better utilization after upgrades. Add a second dex2oat-threads property that is used pre bootcomplete. A separation of these phases allows using less cores when the device is up, freeing up resources for other purposes, e.g., avoid jank. The precedence during boot is the boot property, or the image property if the former doesn't exist, or the default property as a fallback. Bug: 23898216 Bug: 24004256 Change-Id: I5063f3fc4b437cbe88c4e94584e01c1c78eccc4d --- cmds/installd/commands.cpp | 55 +++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/cmds/installd/commands.cpp b/cmds/installd/commands.cpp index 7090b3677..769cd341f 100644 --- a/cmds/installd/commands.cpp +++ b/cmds/installd/commands.cpp @@ -746,7 +746,7 @@ static bool check_boolean_property(const char* property_name, bool default_value static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name, const char* output_file_name, int swap_fd, const char *pkgname, const char *instruction_set, - bool vm_safe_mode, bool debuggable) + bool vm_safe_mode, bool debuggable, bool post_bootcomplete) { static const unsigned int MAX_INSTRUCTION_SET_LEN = 7; @@ -770,8 +770,24 @@ 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 = property_get("dalvik.vm.dex2oat-threads", dex2oat_threads_buf, - NULL) > 0; + 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; + } char dex2oat_threads_arg[PROPERTY_VALUE_MAX + 2]; if (have_dex2oat_threads_flag) { sprintf(dex2oat_threads_arg, "-j%s", dex2oat_threads_buf); @@ -1065,6 +1081,27 @@ static bool calculate_odex_file_path(char path[PKG_PATH_MAX], return true; } +static bool IsPostBootComplete() { + char dev_bootcomplete_prop_buf[PROPERTY_VALUE_MAX]; + if (property_get("dev.bootcomplete", dev_bootcomplete_prop_buf, "0") > 0) { + return (strcmp(dev_bootcomplete_prop_buf, "1") == 0); + } + return false; +} + +static void SetDex2OatAndPatchOatScheduling(bool set_to_bg) { + if (set_to_bg) { + if (set_sched_policy(0, SP_BACKGROUND) < 0) { + ALOGE("set_sched_policy failed: %s\n", strerror(errno)); + exit(70); + } + if (setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_BACKGROUND) < 0) { + ALOGE("setpriority failed: %s\n", strerror(errno)); + exit(71); + } + } +} + int dexopt(const char *apk_path, uid_t uid, bool is_public, const char *pkgname, const char *instruction_set, int dexopt_needed, bool vm_safe_mode, bool debuggable, const char* oat_dir) @@ -1076,6 +1113,7 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public, const char *input_file; char in_odex_path[PKG_PATH_MAX]; int res, input_fd=-1, out_fd=-1, swap_fd=-1; + bool post_bootcomplete = IsPostBootComplete(); // Early best-effort check whether we can fit the the path into our buffers. // Note: the cache path will require an additional 5 bytes for ".swap", but we'll try to run @@ -1198,14 +1236,7 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public, ALOGE("capset failed: %s\n", strerror(errno)); exit(66); } - if (set_sched_policy(0, SP_BACKGROUND) < 0) { - ALOGE("set_sched_policy failed: %s\n", strerror(errno)); - exit(70); - } - if (setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_BACKGROUND) < 0) { - ALOGE("setpriority failed: %s\n", strerror(errno)); - exit(71); - } + SetDex2OatAndPatchOatScheduling(post_bootcomplete); if (flock(out_fd, LOCK_EX | LOCK_NB) != 0) { ALOGE("flock(%s) failed: %s\n", out_path, strerror(errno)); exit(67); @@ -1222,7 +1253,7 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public, input_file_name++; } run_dex2oat(input_fd, out_fd, input_file_name, out_path, swap_fd, pkgname, - instruction_set, vm_safe_mode, debuggable); + instruction_set, vm_safe_mode, debuggable, post_bootcomplete); } else { ALOGE("Invalid dexopt needed: %d\n", dexopt_needed); exit(73); From 72ebebed876a62e719b098e43d9d516361bde029 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Mon, 21 Sep 2015 13:21:30 -0700 Subject: [PATCH 13/19] Installd: Take boot status as dexopt parameter Expect the boot status explicitly as a parameter so that we do not have to rely on dev.bootcomplete, which isn't meaningfully set when the device needs the decryption screen on boot. Bug: 23898216 Change-Id: I9b34298caf70b1e5d40970cc0d04c469016a80a7 --- cmds/installd/commands.cpp | 15 +++------------ cmds/installd/installd.cpp | 6 +++--- cmds/installd/installd.h | 2 +- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/cmds/installd/commands.cpp b/cmds/installd/commands.cpp index 769cd341f..d4aa7d31b 100644 --- a/cmds/installd/commands.cpp +++ b/cmds/installd/commands.cpp @@ -1081,14 +1081,6 @@ static bool calculate_odex_file_path(char path[PKG_PATH_MAX], return true; } -static bool IsPostBootComplete() { - char dev_bootcomplete_prop_buf[PROPERTY_VALUE_MAX]; - if (property_get("dev.bootcomplete", dev_bootcomplete_prop_buf, "0") > 0) { - return (strcmp(dev_bootcomplete_prop_buf, "1") == 0); - } - return false; -} - static void SetDex2OatAndPatchOatScheduling(bool set_to_bg) { if (set_to_bg) { if (set_sched_policy(0, SP_BACKGROUND) < 0) { @@ -1104,7 +1096,7 @@ static void SetDex2OatAndPatchOatScheduling(bool set_to_bg) { int dexopt(const char *apk_path, uid_t uid, bool is_public, const char *pkgname, const char *instruction_set, int dexopt_needed, - bool vm_safe_mode, bool debuggable, const char* oat_dir) + bool vm_safe_mode, bool debuggable, const char* oat_dir, bool boot_complete) { struct utimbuf ut; struct stat input_stat; @@ -1113,7 +1105,6 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public, const char *input_file; char in_odex_path[PKG_PATH_MAX]; int res, input_fd=-1, out_fd=-1, swap_fd=-1; - bool post_bootcomplete = IsPostBootComplete(); // Early best-effort check whether we can fit the the path into our buffers. // Note: the cache path will require an additional 5 bytes for ".swap", but we'll try to run @@ -1236,7 +1227,7 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public, ALOGE("capset failed: %s\n", strerror(errno)); exit(66); } - SetDex2OatAndPatchOatScheduling(post_bootcomplete); + SetDex2OatAndPatchOatScheduling(boot_complete); if (flock(out_fd, LOCK_EX | LOCK_NB) != 0) { ALOGE("flock(%s) failed: %s\n", out_path, strerror(errno)); exit(67); @@ -1253,7 +1244,7 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public, input_file_name++; } run_dex2oat(input_fd, out_fd, input_file_name, out_path, swap_fd, pkgname, - instruction_set, vm_safe_mode, debuggable, post_bootcomplete); + instruction_set, vm_safe_mode, debuggable, boot_complete); } else { ALOGE("Invalid dexopt needed: %d\n", dexopt_needed); exit(73); diff --git a/cmds/installd/installd.cpp b/cmds/installd/installd.cpp index 13e316868..f67e8384d 100644 --- a/cmds/installd/installd.cpp +++ b/cmds/installd/installd.cpp @@ -48,9 +48,9 @@ static int do_install(char **arg, char reply[REPLY_MAX] __unused) static int do_dexopt(char **arg, char reply[REPLY_MAX] __unused) { /* apk_path, uid, is_public, pkgname, instruction_set, - * dexopt_needed, vm_safe_mode, debuggable, oat_dir */ + * dexopt_needed, vm_safe_mode, debuggable, oat_dir, boot_complete */ return dexopt(arg[0], atoi(arg[1]), atoi(arg[2]), arg[3], arg[4], atoi(arg[5]), - atoi(arg[6]), atoi(arg[7]), arg[8]); + atoi(arg[6]), atoi(arg[7]), arg[8], atoi(arg[9])); } static int do_mark_boot_complete(char **arg, char reply[REPLY_MAX] __unused) @@ -194,7 +194,7 @@ struct cmdinfo { struct cmdinfo cmds[] = { { "ping", 0, do_ping }, { "install", 5, do_install }, - { "dexopt", 9, do_dexopt }, + { "dexopt", 10, do_dexopt }, { "markbootcomplete", 1, do_mark_boot_complete }, { "movedex", 3, do_move_dex }, { "rmdex", 2, do_rm_dex }, diff --git a/cmds/installd/installd.h b/cmds/installd/installd.h index 7ec579382..24b908465 100644 --- a/cmds/installd/installd.h +++ b/cmds/installd/installd.h @@ -243,7 +243,7 @@ int get_size(const char *uuid, const char *pkgname, int userid, int free_cache(const char *uuid, int64_t free_size); int dexopt(const char *apk_path, uid_t uid, bool is_public, const char *pkgName, const char *instruction_set, int dexopt_needed, bool vm_safe_mode, - bool debuggable, const char* oat_dir); + bool debuggable, const char* oat_dir, bool boot_complete); int mark_boot_complete(const char *instruction_set); int movefiles(); int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int userId); From fa2d40f750e0770cc890eeed5d5f6f41f9be5f50 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Mon, 21 Sep 2015 13:21:30 -0700 Subject: [PATCH 14/19] Installd: Take boot status as dexopt parameter Expect the boot status explicitly as a parameter so that we do not have to rely on dev.bootcomplete, which isn't meaningfully set when the device needs the decryption screen on boot. Bug: 23898216 Change-Id: I9b34298caf70b1e5d40970cc0d04c469016a80a7 --- cmds/installd/commands.cpp | 15 +++------------ cmds/installd/installd.cpp | 6 +++--- cmds/installd/installd.h | 2 +- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/cmds/installd/commands.cpp b/cmds/installd/commands.cpp index 769cd341f..d4aa7d31b 100644 --- a/cmds/installd/commands.cpp +++ b/cmds/installd/commands.cpp @@ -1081,14 +1081,6 @@ static bool calculate_odex_file_path(char path[PKG_PATH_MAX], return true; } -static bool IsPostBootComplete() { - char dev_bootcomplete_prop_buf[PROPERTY_VALUE_MAX]; - if (property_get("dev.bootcomplete", dev_bootcomplete_prop_buf, "0") > 0) { - return (strcmp(dev_bootcomplete_prop_buf, "1") == 0); - } - return false; -} - static void SetDex2OatAndPatchOatScheduling(bool set_to_bg) { if (set_to_bg) { if (set_sched_policy(0, SP_BACKGROUND) < 0) { @@ -1104,7 +1096,7 @@ static void SetDex2OatAndPatchOatScheduling(bool set_to_bg) { int dexopt(const char *apk_path, uid_t uid, bool is_public, const char *pkgname, const char *instruction_set, int dexopt_needed, - bool vm_safe_mode, bool debuggable, const char* oat_dir) + bool vm_safe_mode, bool debuggable, const char* oat_dir, bool boot_complete) { struct utimbuf ut; struct stat input_stat; @@ -1113,7 +1105,6 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public, const char *input_file; char in_odex_path[PKG_PATH_MAX]; int res, input_fd=-1, out_fd=-1, swap_fd=-1; - bool post_bootcomplete = IsPostBootComplete(); // Early best-effort check whether we can fit the the path into our buffers. // Note: the cache path will require an additional 5 bytes for ".swap", but we'll try to run @@ -1236,7 +1227,7 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public, ALOGE("capset failed: %s\n", strerror(errno)); exit(66); } - SetDex2OatAndPatchOatScheduling(post_bootcomplete); + SetDex2OatAndPatchOatScheduling(boot_complete); if (flock(out_fd, LOCK_EX | LOCK_NB) != 0) { ALOGE("flock(%s) failed: %s\n", out_path, strerror(errno)); exit(67); @@ -1253,7 +1244,7 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public, input_file_name++; } run_dex2oat(input_fd, out_fd, input_file_name, out_path, swap_fd, pkgname, - instruction_set, vm_safe_mode, debuggable, post_bootcomplete); + instruction_set, vm_safe_mode, debuggable, boot_complete); } else { ALOGE("Invalid dexopt needed: %d\n", dexopt_needed); exit(73); diff --git a/cmds/installd/installd.cpp b/cmds/installd/installd.cpp index 13e316868..f67e8384d 100644 --- a/cmds/installd/installd.cpp +++ b/cmds/installd/installd.cpp @@ -48,9 +48,9 @@ static int do_install(char **arg, char reply[REPLY_MAX] __unused) static int do_dexopt(char **arg, char reply[REPLY_MAX] __unused) { /* apk_path, uid, is_public, pkgname, instruction_set, - * dexopt_needed, vm_safe_mode, debuggable, oat_dir */ + * dexopt_needed, vm_safe_mode, debuggable, oat_dir, boot_complete */ return dexopt(arg[0], atoi(arg[1]), atoi(arg[2]), arg[3], arg[4], atoi(arg[5]), - atoi(arg[6]), atoi(arg[7]), arg[8]); + atoi(arg[6]), atoi(arg[7]), arg[8], atoi(arg[9])); } static int do_mark_boot_complete(char **arg, char reply[REPLY_MAX] __unused) @@ -194,7 +194,7 @@ struct cmdinfo { struct cmdinfo cmds[] = { { "ping", 0, do_ping }, { "install", 5, do_install }, - { "dexopt", 9, do_dexopt }, + { "dexopt", 10, do_dexopt }, { "markbootcomplete", 1, do_mark_boot_complete }, { "movedex", 3, do_move_dex }, { "rmdex", 2, do_rm_dex }, diff --git a/cmds/installd/installd.h b/cmds/installd/installd.h index 7ec579382..24b908465 100644 --- a/cmds/installd/installd.h +++ b/cmds/installd/installd.h @@ -243,7 +243,7 @@ int get_size(const char *uuid, const char *pkgname, int userid, int free_cache(const char *uuid, int64_t free_size); int dexopt(const char *apk_path, uid_t uid, bool is_public, const char *pkgName, const char *instruction_set, int dexopt_needed, bool vm_safe_mode, - bool debuggable, const char* oat_dir); + bool debuggable, const char* oat_dir, bool boot_complete); int mark_boot_complete(const char *instruction_set); int movefiles(); int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int userId); From a16b98c64f5246650aa5b6bc397a2d1fa6539107 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Tue, 22 Sep 2015 21:04:33 +0100 Subject: [PATCH 15/19] DO NOT MERGE Revert "am f37143d8: Merge "Cancel touches as well as pointer gestures." into mnc-dev" This reverts commit 9b70ab7a3cb260205e81e40ba181a86710d2eb95, reversing changes made to 153008efb5a00ed3c18d588ce15f90d2442a9786. Bug: 24302031 Change-Id: Ia746381b30be3b54cb646ed412b7271962c4b02a --- include/android/keycodes.h | 15 +- include/input/InputEventLabels.h | 8 - services/inputflinger/InputReader.cpp | 34 +--- services/inputflinger/InputReader.h | 4 - services/inputflinger/host/InputDriver.cpp | 220 ++++----------------- services/inputflinger/host/InputDriver.h | 2 - 6 files changed, 45 insertions(+), 238 deletions(-) diff --git a/include/android/keycodes.h b/include/android/keycodes.h index 1f55d9f37..15bb78684 100644 --- a/include/android/keycodes.h +++ b/include/android/keycodes.h @@ -722,20 +722,7 @@ enum { AKEYCODE_NAVIGATE_PREVIOUS = 260, AKEYCODE_NAVIGATE_NEXT = 261, AKEYCODE_NAVIGATE_IN = 262, - AKEYCODE_NAVIGATE_OUT = 263, - /** Primary stem key for Wear - * Main power/reset button on watch. */ - AKEYCODE_STEM_PRIMARY = 264, - /** Generic stem key 1 for Wear */ - AKEYCODE_STEM_1 = 265, - /** Generic stem key 2 for Wear */ - AKEYCODE_STEM_2 = 266, - /** Generic stem key 3 for Wear */ - AKEYCODE_STEM_3 = 267, - AKEYCODE_MEDIA_SKIP_FORWARD = 272, - AKEYCODE_MEDIA_SKIP_BACKWARD = 273, - AKEYCODE_MEDIA_STEP_FORWARD = 274, - AKEYCODE_MEDIA_STEP_BACKWARD = 275 + AKEYCODE_NAVIGATE_OUT = 263 // 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..3962001dd 100644 --- a/include/input/InputEventLabels.h +++ b/include/input/InputEventLabels.h @@ -303,14 +303,6 @@ static const InputEventLabel KEYCODES[] = { DEFINE_KEYCODE(NAVIGATE_NEXT), DEFINE_KEYCODE(NAVIGATE_IN), DEFINE_KEYCODE(NAVIGATE_OUT), - DEFINE_KEYCODE(STEM_PRIMARY), - DEFINE_KEYCODE(STEM_1), - DEFINE_KEYCODE(STEM_2), - DEFINE_KEYCODE(STEM_3), - DEFINE_KEYCODE(MEDIA_SKIP_FORWARD), - DEFINE_KEYCODE(MEDIA_SKIP_BACKWARD), - DEFINE_KEYCODE(MEDIA_STEP_FORWARD), - DEFINE_KEYCODE(MEDIA_STEP_BACKWARD), { NULL, 0 } }; diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp index 36095bf1e..8a22e3d1a 100644 --- a/services/inputflinger/InputReader.cpp +++ b/services/inputflinger/InputReader.cpp @@ -3860,7 +3860,6 @@ void TouchInputMapper::reset(nsecs_t when) { mPointerUsage = POINTER_USAGE_NONE; mSentHoverEnter = false; mHavePointerIds = false; - mCurrentMotionAborted = false; mDownTime = 0; mCurrentVirtualKey.down = false; @@ -4088,17 +4087,11 @@ void TouchInputMapper::cookAndDispatch(nsecs_t when) { mCurrentCookedState.cookedPointerData.touchingIdBits); } - if (!mCurrentMotionAborted) { - dispatchButtonRelease(when, policyFlags); - dispatchHoverExit(when, policyFlags); - dispatchTouches(when, policyFlags); - dispatchHoverEnterAndMove(when, policyFlags); - dispatchButtonPress(when, policyFlags); - } - - if (mCurrentCookedState.cookedPointerData.pointerCount == 0) { - mCurrentMotionAborted = false; - } + dispatchButtonRelease(when, policyFlags); + dispatchHoverExit(when, policyFlags); + dispatchTouches(when, policyFlags); + dispatchHoverEnterAndMove(when, policyFlags); + dispatchButtonPress(when, policyFlags); } // Synthesize key up from raw buttons if needed. @@ -4323,22 +4316,6 @@ void TouchInputMapper::dispatchVirtualKey(nsecs_t when, uint32_t policyFlags, getListener()->notifyKey(&args); } -void TouchInputMapper::abortTouches(nsecs_t when, uint32_t policyFlags) { - BitSet32 currentIdBits = mCurrentCookedState.cookedPointerData.touchingIdBits; - if (!currentIdBits.isEmpty()) { - int32_t metaState = getContext()->getGlobalMetaState(); - int32_t buttonState = mCurrentCookedState.buttonState; - dispatchMotion(when, policyFlags, mSource, AMOTION_EVENT_ACTION_CANCEL, 0, 0, - metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE, - mCurrentCookedState.cookedPointerData.pointerProperties, - mCurrentCookedState.cookedPointerData.pointerCoords, - mCurrentCookedState.cookedPointerData.idToIndex, - currentIdBits, -1, - mOrientedXPrecision, mOrientedYPrecision, mDownTime); - mCurrentMotionAborted = true; - } -} - void TouchInputMapper::dispatchTouches(nsecs_t when, uint32_t policyFlags) { BitSet32 currentIdBits = mCurrentCookedState.cookedPointerData.touchingIdBits; BitSet32 lastIdBits = mLastCookedState.cookedPointerData.touchingIdBits; @@ -6112,7 +6089,6 @@ 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 7cb4680ce..4062ec787 100644 --- a/services/inputflinger/InputReader.h +++ b/services/inputflinger/InputReader.h @@ -1469,9 +1469,6 @@ protected: // Have we assigned pointer IDs for this stream bool mHavePointerIds; - // Is the current stream of direct touch events aborted - bool mCurrentMotionAborted; - // The time the primary pointer last went down. nsecs_t mDownTime; @@ -1805,7 +1802,6 @@ private: void dispatchButtonPress(nsecs_t when, uint32_t policyFlags); const BitSet32& findActiveIdBits(const CookedPointerData& cookedPointerData); void cookPointerData(); - void abortTouches(nsecs_t when, uint32_t policyFlags); void dispatchPointerUsage(nsecs_t when, uint32_t policyFlags, PointerUsage pointerUsage); void abortPointerUsage(nsecs_t when, uint32_t policyFlags); diff --git a/services/inputflinger/host/InputDriver.cpp b/services/inputflinger/host/InputDriver.cpp index cb4ccbeea..630a596b7 100644 --- a/services/inputflinger/host/InputDriver.cpp +++ b/services/inputflinger/host/InputDriver.cpp @@ -14,11 +14,8 @@ * limitations under the License. */ -#include #include #include -#include -#include #define LOG_TAG "InputDriver" @@ -28,9 +25,7 @@ #include "InputHost.h" #include -#include #include -#include #include #define INDENT2 " " @@ -42,7 +37,6 @@ static input_host_callbacks_t kCallbacks = { .create_device_definition = create_device_definition, .create_input_report_definition = create_input_report_definition, .create_output_report_definition = create_output_report_definition, - .free_report_definition = free_report_definition, .input_device_definition_add_report = input_device_definition_add_report, .input_report_definition_add_collection = input_report_definition_add_collection, .input_report_definition_declare_usage_int = input_report_definition_declare_usage_int, @@ -75,214 +69,78 @@ void InputDriver::dump(String8& result) { result.appendFormat(INDENT2 "HAL Input Driver (%s)\n", mName.string()); } -} // namespace android - -struct input_property_map { - android::PropertyMap* propertyMap; -}; - -struct input_property { - android::String8 key; - android::String8 value; -}; - -struct input_device_identifier { - const char* name; - const char* uniqueId; - input_bus_t bus; - int32_t vendorId; - int32_t productId; - int32_t version; -}; - -struct input_device_definition { - std::vector reportDefs; -}; - -struct input_device_handle { - input_device_identifier_t* id; - input_device_definition_t* def; -}; - -struct input_int_usage { - input_usage_t usage; - int32_t min; - int32_t max; - float resolution; -}; - -struct input_collection { - int32_t arity; - std::vector intUsages; - std::vector boolUsages; -}; - -struct InputCollectionIdHasher { - std::size_t operator()(const input_collection_id& id) const { - return std::hash()(static_cast(id)); - } -}; - -struct input_report_definition { - std::unordered_map collections; -}; // HAL wrapper functions -namespace android { - -::input_device_identifier_t* create_device_identifier(input_host_t* host, +input_device_identifier_t* create_device_identifier(input_host_t* host, const char* name, int32_t product_id, int32_t vendor_id, input_bus_t bus, const char* unique_id) { - auto identifier = new ::input_device_identifier { - .name = name, - .productId = product_id, - .vendorId = vendor_id, - //.bus = bus, - .uniqueId = unique_id, - }; - // store this identifier somewhere? in the host? - return identifier; -} - -input_device_definition_t* create_device_definition(input_host_t* host) { - return new ::input_device_definition; -} - -input_report_definition_t* create_input_report_definition(input_host_t* host) { - return new ::input_report_definition; -} - -input_report_definition_t* create_output_report_definition(input_host_t* host) { - return new ::input_report_definition; -} - -void free_report_definition(input_host_t* host, input_report_definition_t* report_def) { - delete report_def; -} - -void input_device_definition_add_report(input_host_t* host, - input_device_definition_t* d, input_report_definition_t* r) { - d->reportDefs.push_back(r); -} - -void input_report_definition_add_collection(input_host_t* host, - input_report_definition_t* report, input_collection_id_t id, int32_t arity) { - report->collections[id] = {.arity = arity}; -} - -void input_report_definition_declare_usage_int(input_host_t* host, - input_report_definition_t* report, input_collection_id_t id, - input_usage_t usage, int32_t min, int32_t max, float resolution) { - if (report->collections.find(id) != report->collections.end()) { - report->collections[id].intUsages.push_back({ - .usage = usage, .min = min, .max = max, .resolution = resolution}); - } -} - -void input_report_definition_declare_usages_bool(input_host_t* host, - input_report_definition_t* report, input_collection_id_t id, - input_usage_t* usage, size_t usage_count) { - if (report->collections.find(id) != report->collections.end()) { - for (size_t i = 0; i < usage_count; ++i) { - report->collections[id].boolUsages.push_back(usage[i]); - } - } -} - -input_device_handle_t* register_device(input_host_t* host, - input_device_identifier_t* id, input_device_definition_t* d) { - ALOGD("Registering device %s with %d input reports", id->name, d->reportDefs.size()); - return new input_device_handle{ .id = id, .def = d }; -} - -input_report_t* input_allocate_report(input_host_t* host, input_report_definition_t* r) { - ALOGD("Allocating input report for definition %p", r); return nullptr; } +input_device_definition_t* create_device_definition(input_host_t* host) { + return nullptr; +} + +input_report_definition_t* create_input_report_definition(input_host_t* host) { + return nullptr; +} + +input_report_definition_t* create_output_report_definition(input_host_t* host) { + return nullptr; +} + +void input_device_definition_add_report(input_host_t* host, + input_device_definition_t* d, input_report_definition_t* r) { } + +void input_report_definition_add_collection(input_host_t* host, + input_report_definition_t* report, input_collection_id_t id, int32_t arity) { } + +void input_report_definition_declare_usage_int(input_host_t* host, + input_report_definition_t* report, input_collection_id_t id, + input_usage_t usage, int32_t min, int32_t max, float resolution) { } + +void input_report_definition_declare_usages_bool(input_host_t* host, + input_report_definition_t* report, input_collection_id_t id, + input_usage_t* usage, size_t usage_count) { } + + +input_device_handle_t* register_device(input_host_t* host, + input_device_identifier_t* id, input_device_definition_t* d) { + return nullptr; +} + +input_report_t* input_allocate_report(input_host_t* host, input_report_definition_t* r) { + return nullptr; +} void input_report_set_usage_int(input_host_t* host, input_report_t* r, input_collection_id_t id, input_usage_t usage, int32_t value, int32_t arity_index) { } void input_report_set_usage_bool(input_host_t* host, input_report_t* r, input_collection_id_t id, input_usage_t usage, bool value, int32_t arity_index) { } -void report_event(input_host_t* host, input_device_handle_t* d, input_report_t* report) { - ALOGD("report_event %p for handle %p", report, d); -} +void report_event(input_host_t* host, input_device_handle_t* d, input_report_t* report) { } input_property_map_t* input_get_device_property_map(input_host_t* host, input_device_identifier_t* id) { - InputDeviceIdentifier idi; - idi.name = id->name; - idi.uniqueId = id->uniqueId; - idi.bus = id->bus; - idi.vendor = id->vendorId; - idi.product = id->productId; - idi.version = id->version; - - String8 configFile = getInputDeviceConfigurationFilePathByDeviceIdentifier( - idi, INPUT_DEVICE_CONFIGURATION_FILE_TYPE_CONFIGURATION); - if (configFile.isEmpty()) { - ALOGD("No input device configuration file found for device '%s'.", - idi.name.string()); - } else { - auto propMap = new input_property_map_t(); - status_t status = PropertyMap::load(configFile, &propMap->propertyMap); - if (status) { - ALOGE("Error loading input device configuration file for device '%s'. " - "Using default configuration.", - idi.name.string()); - delete propMap; - return nullptr; - } - return propMap; - } return nullptr; } input_property_t* input_get_device_property(input_host_t* host, input_property_map_t* map, const char* key) { - String8 keyString(key); - if (map != nullptr) { - if (map->propertyMap->hasProperty(keyString)) { - auto prop = new input_property_t(); - if (!map->propertyMap->tryGetProperty(keyString, prop->value)) { - delete prop; - return nullptr; - } - prop->key = keyString; - return prop; - } - } return nullptr; } const char* input_get_property_key(input_host_t* host, input_property_t* property) { - if (property != nullptr) { - return property->key.string(); - } return nullptr; } const char* input_get_property_value(input_host_t* host, input_property_t* property) { - if (property != nullptr) { - return property->value.string(); - } return nullptr; } -void input_free_device_property(input_host_t* host, input_property_t* property) { - if (property != nullptr) { - delete property; - } -} +void input_free_device_property(input_host_t* host, input_property_t* property) { } -void input_free_device_property_map(input_host_t* host, input_property_map_t* map) { - if (map != nullptr) { - delete map->propertyMap; - delete map; - } -} +void input_free_device_property_map(input_host_t* host, input_property_map_t* map) { } } // namespace android diff --git a/services/inputflinger/host/InputDriver.h b/services/inputflinger/host/InputDriver.h index 9bc14a7a3..7734ac296 100644 --- a/services/inputflinger/host/InputDriver.h +++ b/services/inputflinger/host/InputDriver.h @@ -68,8 +68,6 @@ input_report_definition_t* create_input_report_definition(input_host_t* host); input_report_definition_t* create_output_report_definition(input_host_t* host); -void free_report_definition(input_host_t* host, input_report_definition_t* report_def); - void input_device_definition_add_report(input_host_t* host, input_device_definition_t* d, input_report_definition_t* r); From 8e812826015786e07cb83664f22f69b2f2c72586 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Mon, 22 Jun 2015 16:18:21 +0100 Subject: [PATCH 16/19] DO NOT MERGE Cancel touches as well as pointer gestures. Bug: 24302031 Change-Id: Idbe964a1a35c190a32f845e2a19542d54652d011 --- services/inputflinger/InputReader.cpp | 34 +++++++++++++++++++++++---- services/inputflinger/InputReader.h | 4 ++++ 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp index 8a22e3d1a..36095bf1e 100644 --- a/services/inputflinger/InputReader.cpp +++ b/services/inputflinger/InputReader.cpp @@ -3860,6 +3860,7 @@ void TouchInputMapper::reset(nsecs_t when) { mPointerUsage = POINTER_USAGE_NONE; mSentHoverEnter = false; mHavePointerIds = false; + mCurrentMotionAborted = false; mDownTime = 0; mCurrentVirtualKey.down = false; @@ -4087,11 +4088,17 @@ void TouchInputMapper::cookAndDispatch(nsecs_t when) { mCurrentCookedState.cookedPointerData.touchingIdBits); } - dispatchButtonRelease(when, policyFlags); - dispatchHoverExit(when, policyFlags); - dispatchTouches(when, policyFlags); - dispatchHoverEnterAndMove(when, policyFlags); - dispatchButtonPress(when, policyFlags); + if (!mCurrentMotionAborted) { + dispatchButtonRelease(when, policyFlags); + dispatchHoverExit(when, policyFlags); + dispatchTouches(when, policyFlags); + dispatchHoverEnterAndMove(when, policyFlags); + dispatchButtonPress(when, policyFlags); + } + + if (mCurrentCookedState.cookedPointerData.pointerCount == 0) { + mCurrentMotionAborted = false; + } } // Synthesize key up from raw buttons if needed. @@ -4316,6 +4323,22 @@ void TouchInputMapper::dispatchVirtualKey(nsecs_t when, uint32_t policyFlags, getListener()->notifyKey(&args); } +void TouchInputMapper::abortTouches(nsecs_t when, uint32_t policyFlags) { + BitSet32 currentIdBits = mCurrentCookedState.cookedPointerData.touchingIdBits; + if (!currentIdBits.isEmpty()) { + int32_t metaState = getContext()->getGlobalMetaState(); + int32_t buttonState = mCurrentCookedState.buttonState; + dispatchMotion(when, policyFlags, mSource, AMOTION_EVENT_ACTION_CANCEL, 0, 0, + metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE, + mCurrentCookedState.cookedPointerData.pointerProperties, + mCurrentCookedState.cookedPointerData.pointerCoords, + mCurrentCookedState.cookedPointerData.idToIndex, + currentIdBits, -1, + mOrientedXPrecision, mOrientedYPrecision, mDownTime); + mCurrentMotionAborted = true; + } +} + void TouchInputMapper::dispatchTouches(nsecs_t when, uint32_t policyFlags) { BitSet32 currentIdBits = mCurrentCookedState.cookedPointerData.touchingIdBits; BitSet32 lastIdBits = mLastCookedState.cookedPointerData.touchingIdBits; @@ -6089,6 +6112,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 4062ec787..7cb4680ce 100644 --- a/services/inputflinger/InputReader.h +++ b/services/inputflinger/InputReader.h @@ -1469,6 +1469,9 @@ protected: // Have we assigned pointer IDs for this stream bool mHavePointerIds; + // Is the current stream of direct touch events aborted + bool mCurrentMotionAborted; + // The time the primary pointer last went down. nsecs_t mDownTime; @@ -1802,6 +1805,7 @@ private: void dispatchButtonPress(nsecs_t when, uint32_t policyFlags); const BitSet32& findActiveIdBits(const CookedPointerData& cookedPointerData); void cookPointerData(); + void abortTouches(nsecs_t when, uint32_t policyFlags); void dispatchPointerUsage(nsecs_t when, uint32_t policyFlags, PointerUsage pointerUsage); void abortPointerUsage(nsecs_t when, uint32_t policyFlags); From b414255f53b560a06e642251535b019327ba0d7b Mon Sep 17 00:00:00 2001 From: Naveen Leekha Date: Tue, 22 Sep 2015 18:04:44 -0700 Subject: [PATCH 17/19] Initialize local variables to avoid data leak The uninitialized local variables pick up whatever the memory content was there on stack. This data gets sent to the remote process in case of a failed transaction, which is a security issue. Fixed. (Partial manual merge of master change 12ba0f57d028a9c8f4eb3afddc326b70677d1e0c. Rest to automerge from klp-dev) For b/23696300 Change-Id: I704c9fab327b3545c58e8a9a96ac542eb7469c2a --- libs/gui/IGraphicBufferProducer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gui/IGraphicBufferProducer.cpp b/libs/gui/IGraphicBufferProducer.cpp index 1e28f9bb8..dd9db3378 100644 --- a/libs/gui/IGraphicBufferProducer.cpp +++ b/libs/gui/IGraphicBufferProducer.cpp @@ -344,7 +344,7 @@ status_t BnGraphicBufferProducer::onTransact( CHECK_INTERFACE(IGraphicBufferProducer, data, reply); sp buffer = new GraphicBuffer(); data.read(*buffer.get()); - int slot; + int slot = 0; int result = attachBuffer(&slot, buffer); reply->writeInt32(slot); reply->writeInt32(result); From c4bd7211373cf5b745c7d4f849f43f7a2d2b1141 Mon Sep 17 00:00:00 2001 From: Naveen Leekha Date: Thu, 24 Sep 2015 15:55:21 -0700 Subject: [PATCH 18/19] resolved conflicts for 7534e4e6 to lmp-mr1-ub-dev Change-Id: I543df164076b44578b14d41031800bb62b81586d --- libs/gui/IGraphicBufferProducer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/gui/IGraphicBufferProducer.cpp b/libs/gui/IGraphicBufferProducer.cpp index d09eba0b3..74a40eeb5 100644 --- a/libs/gui/IGraphicBufferProducer.cpp +++ b/libs/gui/IGraphicBufferProducer.cpp @@ -324,7 +324,7 @@ status_t BnGraphicBufferProducer::onTransact( uint32_t height = data.readUint32(); PixelFormat format = static_cast(data.readInt32()); uint32_t usage = data.readUint32(); - int buf; + int buf = 0; sp fence; int result = dequeueBuffer(&buf, &fence, async, width, height, format, usage); @@ -392,7 +392,7 @@ status_t BnGraphicBufferProducer::onTransact( } case QUERY: { CHECK_INTERFACE(IGraphicBufferProducer, data, reply); - int value; + int value = 0; int what = data.readInt32(); int res = query(what, &value); reply->writeInt32(value); From de18f6c32add6fb22065807a00ddc88b363df527 Mon Sep 17 00:00:00 2001 From: Andrew de los Reyes Date: Thu, 1 Oct 2015 15:57:25 -0700 Subject: [PATCH 19/19] InputResampling: Don't extrapolate for very low frame rates. In very low framerate situations, extrapolation is generally going to either cause no benefit or make a mistake. We can safely turn it off with no user-visible negative impact. BUG=https://buganizer.corp.google.com/u/0/issues/24550942 TEST=Scrolled very slowly and saw mispredictions on Angler. With change, saw the log message that the mispredictions were suppressed. Change-Id: Ic9747d3ff098d7918047ada2ed1c2d21282c65b0 --- libs/input/InputTransport.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libs/input/InputTransport.cpp b/libs/input/InputTransport.cpp index 0382f5788..7f83da523 100644 --- a/libs/input/InputTransport.cpp +++ b/libs/input/InputTransport.cpp @@ -51,6 +51,10 @@ static const nsecs_t RESAMPLE_LATENCY = 5 * NANOS_PER_MS; // Minimum time difference between consecutive samples before attempting to resample. static const nsecs_t RESAMPLE_MIN_DELTA = 2 * NANOS_PER_MS; +// Maximum time difference between consecutive samples before attempting to resample +// by extrapolation. +static const nsecs_t RESAMPLE_MAX_DELTA = 20 * NANOS_PER_MS; + // Maximum time to predict forward from the last known state, to avoid predicting too // far into the future. This time is further bounded by 50% of the last time delta. static const nsecs_t RESAMPLE_MAX_PREDICTION = 8 * NANOS_PER_MS; @@ -724,7 +728,7 @@ void InputConsumer::resampleTouchState(nsecs_t sampleTime, MotionEvent* event, nsecs_t delta = future.eventTime - current->eventTime; if (delta < RESAMPLE_MIN_DELTA) { #if DEBUG_RESAMPLING - ALOGD("Not resampled, delta time is %lld ns.", delta); + ALOGD("Not resampled, delta time is too small: %lld ns.", delta); #endif return; } @@ -736,7 +740,12 @@ void InputConsumer::resampleTouchState(nsecs_t sampleTime, MotionEvent* event, nsecs_t delta = current->eventTime - other->eventTime; if (delta < RESAMPLE_MIN_DELTA) { #if DEBUG_RESAMPLING - ALOGD("Not resampled, delta time is %lld ns.", delta); + ALOGD("Not resampled, delta time is too small: %lld ns.", delta); +#endif + return; + } else if (delta > RESAMPLE_MAX_DELTA) { +#if DEBUG_RESAMPLING + ALOGD("Not resampled, delta time is too large: %lld ns.", delta); #endif return; }