diff options
author | Ricardo Cerqueira <ricardo@cyngn.com> | 2015-11-05 01:41:42 +0000 |
---|---|---|
committer | Ricardo Cerqueira <ricardo@cyngn.com> | 2015-11-05 01:41:42 +0000 |
commit | 1cdd1b5ad204cb319174f86b522fcb0dc7968ed6 (patch) | |
tree | 208c78f58721f44168992cf88ae8d2b821f090de /libs | |
parent | 5e78568dab3b1bbddd1cbc0dd2004d9c2ddbdfeb (diff) | |
parent | 3492a21877f93b2240dc823392b7e8adb2e1809e (diff) | |
download | frameworks_native-1cdd1b5ad204cb319174f86b522fcb0dc7968ed6.tar.gz frameworks_native-1cdd1b5ad204cb319174f86b522fcb0dc7968ed6.tar.bz2 frameworks_native-1cdd1b5ad204cb319174f86b522fcb0dc7968ed6.zip |
Merge tag 'android-6.0.0_r26' into HEAD
Android 6.0.0 release 26
Conflicts:
include/android/input.h
Change-Id: Ifa374c6d3055be3b8a5d60967f8b4c0043da739b
Diffstat (limited to 'libs')
-rw-r--r-- | libs/gui/IGraphicBufferProducer.cpp | 4 | ||||
-rw-r--r-- | libs/gui/SensorManager.cpp | 72 | ||||
-rw-r--r-- | libs/input/InputTransport.cpp | 13 |
3 files changed, 82 insertions, 7 deletions
diff --git a/libs/gui/IGraphicBufferProducer.cpp b/libs/gui/IGraphicBufferProducer.cpp index 2118c9234..8bdbc22ec 100644 --- a/libs/gui/IGraphicBufferProducer.cpp +++ b/libs/gui/IGraphicBufferProducer.cpp @@ -348,7 +348,7 @@ status_t BnGraphicBufferProducer::onTransact( uint32_t height = data.readUint32(); PixelFormat format = static_cast<PixelFormat>(data.readInt32()); uint32_t usage = data.readUint32(); - int buf; + int buf = 0; sp<Fence> fence; int result = dequeueBuffer(&buf, &fence, async, width, height, format, usage); @@ -416,7 +416,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); diff --git a/libs/gui/SensorManager.cpp b/libs/gui/SensorManager.cpp index dd3778137..33608b5bd 100644 --- a/libs/gui/SensorManager.cpp +++ b/libs/gui/SensorManager.cpp @@ -36,6 +36,58 @@ namespace android { // ---------------------------------------------------------------------------- +android::Mutex android::SensorManager::sLock; +std::map<String16, SensorManager*> android::SensorManager::sPackageInstances; + +SensorManager& SensorManager::getInstanceForPackage(const String16& packageName) { + Mutex::Autolock _l(sLock); + SensorManager* sensorManager; + std::map<String16, SensorManager*>::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<IBinder> binder = defaultServiceManager()->getService(String16("permission")); + if (binder != 0) { + const uid_t uid = IPCThreadState::self()->getCallingUid(); + Vector<String16> packages; + interface_cast<IPermissionController>(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) { @@ -58,13 +110,23 @@ void SensorManager::sensorManagerDied() } status_t SensorManager::assertStateLocked() const { + bool initSensorManager = false; if (mSensorServer == NULL) { - // try for one second + 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<4 ; i++) { + for (int i = 0; i < 60; i++) { status_t err = getService(name, &mSensorServer); if (err == NAME_NOT_FOUND) { - usleep(250000); + sleep(1); continue; } if (err != NO_ERROR) { @@ -83,6 +145,8 @@ status_t SensorManager::assertStateLocked() const { DeathObserver(SensorManager& mgr) : mSensorManger(mgr) { } }; + LOG_ALWAYS_FATAL_IF(mSensorServer.get() == NULL, "getService(SensorService) NULL"); + mDeathObserver = new DeathObserver(*const_cast<SensorManager *>(this)); IInterface::asBinder(mSensorServer)->linkToDeath(mDeathObserver); @@ -90,6 +154,8 @@ status_t SensorManager::assertStateLocked() const { size_t count = mSensors.size(); mSensorList = static_cast<Sensor const**>(malloc(count * sizeof(Sensor*))); + LOG_ALWAYS_FATAL_IF(mSensorList == NULL, "mSensorList NULL"); + for (size_t i=0 ; i<count ; i++) { mSensorList[i] = mSensors.array() + i; } 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; } |