Skip to content

Commit

Permalink
libgui: SensorManager: be compatible with MTK Lollipop blobs
Browse files Browse the repository at this point in the history
Change-Id: I1846c5f3c629293c0f0fc0a6762f6f7b5b9bd9b5

libgui: SensorManager: fix

Change-Id: I76e0ba036ef4e4acc15c9e6f87cb00dd37fae7c9

[Ported to N by @xen0n.]

Conflicts:
	include/gui/SensorManager.h
  • Loading branch information
xen0n committed Oct 5, 2016
1 parent 5b05e7b commit 95931f1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
19 changes: 19 additions & 0 deletions include/gui/SensorManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,24 @@ class SensorManager :
#endif
ssize_t getDynamicSensorList(Vector<Sensor>& list);
Sensor const* getDefaultSensor(int type);
#ifdef MTK_HARDWARE
sp<SensorEventQueue> createEventQueue(String8 packageName, int mode = 0);
sp<SensorEventQueue> createEventQueue();
#else
sp<SensorEventQueue> createEventQueue(String8 packageName = String8(""), int mode = 0);
#endif
bool isDataInjectionEnabled();

private:
// DeathRecipient interface
void sensorManagerDied();

SensorManager(const String16& opPackageName);

#ifdef MTK_HARDWARE
SensorManager();
#endif

#ifdef COMPAT_SENSORS_M
status_t assertStateLocked() const;
#else
Expand All @@ -95,6 +105,15 @@ class SensorManager :
const String16 mOpPackageName;
};


#ifdef MTK_HARDWARE
// be compatible with MTK Lollipop blobs
extern "C" {
extern android::Mutex _ZN7android9SingletonINS_13SensorManagerEE5sLockE;
extern SensorManager *_ZN7android9SingletonINS_13SensorManagerEE9sInstanceE;
}
#endif // MTK_HARDWARE

// ----------------------------------------------------------------------------
}; // namespace android

Expand Down
26 changes: 26 additions & 0 deletions libs/gui/SensorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,32 @@ namespace android {
android::Mutex android::SensorManager::sLock;
std::map<String16, SensorManager*> android::SensorManager::sPackageInstances;

#ifdef MTK_HARDWARE

static const String8 packageName8("");


// be compatible with MTK Lollipop blobs
extern "C" {
android::Mutex _ZN7android9SingletonINS_13SensorManagerEE5sLockE;
SensorManager *_ZN7android9SingletonINS_13SensorManagerEE9sInstanceE = nullptr;
}


// compatible ctor
SensorManager::SensorManager()
: mSensorList(0), mOpPackageName("")
{
// okay we're not locked here, but it's not needed during construction
assertStateLocked();
}


sp<SensorEventQueue> SensorManager::createEventQueue() {
return createEventQueue(packageName8, 0);
}
#endif // MTK_HARDWARE

SensorManager& SensorManager::getInstanceForPackage(const String16& packageName) {
Mutex::Autolock _l(sLock);
SensorManager* sensorManager;
Expand Down

0 comments on commit 95931f1

Please sign in to comment.