aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher R. Palmer <crpalmer@gmail.com>2016-02-09 21:45:31 -0800
committerEthan Chen <intervigil@gmail.com>2016-02-11 10:09:04 -0800
commita15625f6418e0e2119dad020182ef74e3bde2fba (patch)
tree9f5975aba31f8f810286b9229485f8cf02aa6b80
parent4678d45384ac602679d65c7b6f4861e48424cf4d (diff)
msm8960dt: Add compat libraries and shims
Change-Id: Ib55939fe9cf9bc82ae57a869d8b10ed55dc1bd8f
-rw-r--r--cm.dependencies8
-rw-r--r--libshims/Android.mk52
-rw-r--r--libshims/gui/SensorManager.cpp163
-rw-r--r--libshims/gui/SensorManager.h75
-rw-r--r--libshims/moto_log.c100
-rw-r--r--libshims/moto_mdmcutback.c18
-rw-r--r--libshims/moto_ril.c27
-rw-r--r--msm8960dt-common.mk14
-rw-r--r--rootdir/etc/init.qcom.rc4
9 files changed, 454 insertions, 7 deletions
diff --git a/cm.dependencies b/cm.dependencies
index ca348d2..65aac4f 100644
--- a/cm.dependencies
+++ b/cm.dependencies
@@ -1,5 +1,13 @@
[
{
+ "repository": "android_external_stlport",
+ "target_path": "external/stlport"
+ },
+ {
+ "repository": "android_external_sony_boringssl-compat",
+ "target_path": "external/sony/boringssl-compat"
+ },
+ {
"repository": "android_device_qcom_common",
"target_path": "device/qcom/common"
},
diff --git a/libshims/Android.mk b/libshims/Android.mk
index 37cca10..f5c425e 100644
--- a/libshims/Android.mk
+++ b/libshims/Android.mk
@@ -1,14 +1,64 @@
LOCAL_PATH := $(call my-dir)
+# camera
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ gui/SensorManager.cpp
+
+LOCAL_SHARED_LIBRARIES := libutils libgui liblog libbinder
+LOCAL_MODULE := libshim_camera
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
+
+# liblog
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ moto_log.c
+
+LOCAL_MODULE := libshim_log
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
+
+# libmdmcutback
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ moto_mdmcutback.c
+
+LOCAL_MODULE := libshim_mdmcutback
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
+
# libqc-opt
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- icu53.c
+ icu53.c
LOCAL_SHARED_LIBRARIES := libicuuc libicui18n
LOCAL_MODULE := libshim_qcopt
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
+
+# libril
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ moto_ril.c
+
+LOCAL_SHARED_LIBRARIES := libbinder
+LOCAL_MODULE := libshim_ril
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/libshims/gui/SensorManager.cpp b/libshims/gui/SensorManager.cpp
new file mode 100644
index 0000000..0e9d23d
--- /dev/null
+++ b/libshims/gui/SensorManager.cpp
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "Sensors"
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <utils/Errors.h>
+#include <utils/RefBase.h>
+#include <utils/Singleton.h>
+
+#include <binder/IBinder.h>
+#include <binder/IServiceManager.h>
+
+#include <gui/ISensorServer.h>
+#include <gui/ISensorEventConnection.h>
+#include "gui/Sensor.h"
+#include "gui/SensorManager.h"
+#include <gui/SensorEventQueue.h>
+
+// ----------------------------------------------------------------------------
+namespace android {
+// ----------------------------------------------------------------------------
+
+static String16 gPackageName = String16("packageName");
+
+ANDROID_SINGLETON_STATIC_INSTANCE(SensorManager)
+
+SensorManager::SensorManager()
+ : mSensorList(0)
+{
+ // okay we're not locked here, but it's not needed during construction
+ assertStateLocked();
+}
+
+SensorManager::~SensorManager()
+{
+ free(mSensorList);
+}
+
+void SensorManager::sensorManagerDied()
+{
+ Mutex::Autolock _l(mLock);
+ mSensorServer.clear();
+ free(mSensorList);
+ mSensorList = NULL;
+ mSensors.clear();
+}
+
+status_t SensorManager::assertStateLocked() const {
+ if (mSensorServer == NULL) {
+ // try for one second
+ const String16 name("sensorservice");
+ for (int i=0 ; i<4 ; i++) {
+ status_t err = getService(name, &mSensorServer);
+ if (err == NAME_NOT_FOUND) {
+ usleep(250000);
+ continue;
+ }
+ if (err != NO_ERROR) {
+ return err;
+ }
+ break;
+ }
+
+ class DeathObserver : public IBinder::DeathRecipient {
+ SensorManager& mSensorManger;
+ virtual void binderDied(const wp<IBinder>& who) {
+ ALOGW("sensorservice died [%p]", who.unsafe_get());
+ mSensorManger.sensorManagerDied();
+ }
+ public:
+ DeathObserver(SensorManager& mgr) : mSensorManger(mgr) { }
+ };
+
+ mDeathObserver = new DeathObserver(*const_cast<SensorManager *>(this));
+ IInterface::asBinder(mSensorServer)->linkToDeath(mDeathObserver);
+
+ mSensors = mSensorServer->getSensorList(gPackageName);
+ size_t count = mSensors.size();
+ mSensorList = (Sensor const**)malloc(count * sizeof(Sensor*));
+ for (size_t i=0 ; i<count ; i++) {
+ mSensorList[i] = mSensors.array() + i;
+ }
+ }
+
+ return NO_ERROR;
+}
+
+
+
+ssize_t SensorManager::getSensorList(Sensor const* const** list) const
+{
+ Mutex::Autolock _l(mLock);
+ status_t err = assertStateLocked();
+ if (err < 0) {
+ return ssize_t(err);
+ }
+ *list = mSensorList;
+ return mSensors.size();
+}
+
+Sensor const* SensorManager::getDefaultSensor(int type)
+{
+ Mutex::Autolock _l(mLock);
+ if (assertStateLocked() == NO_ERROR) {
+ bool wakeUpSensor = false;
+ // For the following sensor types, return a wake-up sensor. These types are by default
+ // defined as wake-up sensors. For the rest of the sensor types defined in sensors.h return
+ // a non_wake-up version.
+ if (type == SENSOR_TYPE_PROXIMITY || type == SENSOR_TYPE_SIGNIFICANT_MOTION ||
+ type == SENSOR_TYPE_TILT_DETECTOR || type == SENSOR_TYPE_WAKE_GESTURE ||
+ type == SENSOR_TYPE_GLANCE_GESTURE || type == SENSOR_TYPE_PICK_UP_GESTURE) {
+ wakeUpSensor = true;
+ }
+ // For now we just return the first sensor of that type we find.
+ // in the future it will make sense to let the SensorService make
+ // that decision.
+ for (size_t i=0 ; i<mSensors.size() ; i++) {
+ if (mSensorList[i]->getType() == type &&
+ mSensorList[i]->isWakeUpSensor() == wakeUpSensor) {
+ return mSensorList[i];
+ }
+ }
+ }
+ return NULL;
+}
+
+sp<SensorEventQueue> SensorManager::createEventQueue()
+{
+ sp<SensorEventQueue> queue;
+
+ Mutex::Autolock _l(mLock);
+ while (assertStateLocked() == NO_ERROR) {
+ sp<ISensorEventConnection> connection =
+ mSensorServer->createSensorEventConnection(String8(""), 0, gPackageName);
+ if (connection == NULL) {
+ // SensorService just died.
+ ALOGE("createEventQueue: connection is NULL. SensorService died.");
+ continue;
+ }
+ queue = new SensorEventQueue(connection);
+ break;
+ }
+ return queue;
+}
+
+// ----------------------------------------------------------------------------
+}; // namespace android
diff --git a/libshims/gui/SensorManager.h b/libshims/gui/SensorManager.h
new file mode 100644
index 0000000..3176462
--- /dev/null
+++ b/libshims/gui/SensorManager.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_GUI_SENSOR_MANAGER_H
+#define ANDROID_GUI_SENSOR_MANAGER_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <binder/IBinder.h>
+
+#include <utils/Errors.h>
+#include <utils/RefBase.h>
+#include <utils/Singleton.h>
+#include <utils/Vector.h>
+
+#include <gui/SensorEventQueue.h>
+
+// ----------------------------------------------------------------------------
+// Concrete types for the NDK
+struct ASensorManager { };
+
+// ----------------------------------------------------------------------------
+namespace android {
+// ----------------------------------------------------------------------------
+
+class ISensorServer;
+class Sensor;
+class SensorEventQueue;
+
+// ----------------------------------------------------------------------------
+
+class SensorManager :
+ public ASensorManager,
+ public Singleton<SensorManager>
+{
+public:
+ SensorManager();
+ ~SensorManager();
+
+ ssize_t getSensorList(Sensor const* const** list) const;
+ Sensor const* getDefaultSensor(int type);
+ sp<SensorEventQueue> createEventQueue();
+
+private:
+ // DeathRecipient interface
+ void sensorManagerDied();
+
+ status_t assertStateLocked() const;
+
+private:
+ mutable Mutex mLock;
+ mutable sp<ISensorServer> mSensorServer;
+ mutable Sensor const** mSensorList;
+ mutable Vector<Sensor> mSensors;
+ mutable sp<IBinder::DeathRecipient> mDeathObserver;
+};
+
+// ----------------------------------------------------------------------------
+}; // namespace android
+
+#endif // ANDROID_GUI_SENSOR_MANAGER_H
diff --git a/libshims/moto_log.c b/libshims/moto_log.c
new file mode 100644
index 0000000..fa17711
--- /dev/null
+++ b/libshims/moto_log.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2015 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include <android/log.h>
+#include <sys/system_properties.h>
+
+/* Fallback when there is neither log.tag.<tag> nor log.tag.DEFAULT.
+ * this is compile-time defaulted to "info". The log startup code
+ * looks at the build tags to see about whether it should be DEBUG...
+ * -- just as is done in frameworks/base/core/jni/android_util_Log.cpp
+ */
+static int prio_fallback = ANDROID_LOG_INFO;
+
+/*
+ * public interface so native code can see "should i log this"
+ * and behave similar to java Log.isLoggable() calls.
+ *
+ * NB: we have (level,tag) here to match the other __android_log entries.
+ * The Java side uses (tag,level) for its ordering.
+ * since the args are (int,char*) vs (char*,char*) we won't get strange
+ * swapped-the-strings errors.
+ */
+
+#define LOGGING_PREFIX "log.tag."
+#define LOGGING_DEFAULT "log.tag.DEFAULT"
+
+int __android_log_loggable(int prio, const char *tag)
+{
+ int nprio;
+ char keybuf[PROP_NAME_MAX];
+ char results[PROP_VALUE_MAX];
+ int n;
+
+ /* we can NOT cache the log.tag.<tag> and log.tag.DEFAULT
+ * values because either one can be changed dynamically.
+ *
+ * damn, says the performance compulsive.
+ */
+
+ n = 0;
+ results[0] = '\0';
+ if (tag) {
+ memcpy (keybuf, LOGGING_PREFIX, strlen (LOGGING_PREFIX) + 1);
+ /* watch out for buffer overflow */
+ strncpy (keybuf + strlen (LOGGING_PREFIX), tag,
+ sizeof (keybuf) - strlen (LOGGING_PREFIX));
+ keybuf[sizeof (keybuf) - 1] = '\0';
+ n = __system_property_get (keybuf, results);
+ }
+ if (n == 0) {
+ /* nothing yet, look for the global */
+ memcpy (keybuf, LOGGING_DEFAULT, sizeof (LOGGING_DEFAULT));
+ n = __system_property_get (keybuf, results);
+ }
+
+ if (n == 0) {
+ nprio = prio_fallback;
+ } else {
+ switch (results[0]) {
+ case 'E':
+ nprio = ANDROID_LOG_ERROR;
+ break;
+ case 'W':
+ nprio = ANDROID_LOG_WARN;
+ break;
+ case 'I':
+ nprio = ANDROID_LOG_INFO;
+ break;
+ case 'D':
+ nprio = ANDROID_LOG_DEBUG;
+ break;
+ case 'V':
+ nprio = ANDROID_LOG_VERBOSE;
+ break;
+ case 'S':
+ nprio = ANDROID_LOG_SILENT;
+ break;
+ default:
+ /* unspecified or invalid */
+ nprio = prio_fallback;
+ break;
+ }
+ }
+
+ return ((prio >= nprio) ? 1 : 0);
+}
diff --git a/libshims/moto_mdmcutback.c b/libshims/moto_mdmcutback.c
new file mode 100644
index 0000000..d43d486
--- /dev/null
+++ b/libshims/moto_mdmcutback.c
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2016 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+int _ZN12NetlinkEvent11NlActionAddE = 1;
+int _ZN12NetlinkEvent14NlActionRemoveE = 2;
diff --git a/libshims/moto_ril.c b/libshims/moto_ril.c
new file mode 100644
index 0000000..a02d86e
--- /dev/null
+++ b/libshims/moto_ril.c
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2016 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+void RIL_register_socket(void *Init, int socketType, int argc, char **argv)
+{
+}
+
+/* status_t Parcel::writeString16 */
+extern int _ZN7android6Parcel13writeString16EPKDsj(void *addr, unsigned int size);
+
+int _ZN7android6Parcel13writeString16EPKtj(void *addr, unsigned int size)
+{
+ return _ZN7android6Parcel13writeString16EPKDsj(addr, size);
+}
diff --git a/msm8960dt-common.mk b/msm8960dt-common.mk
index f397b7d..210a97d 100644
--- a/msm8960dt-common.mk
+++ b/msm8960dt-common.mk
@@ -86,6 +86,16 @@ PRODUCT_PACKAGES += \
camera.msm8960 \
Snap
+# Compat
+PRODUCT_PACKAGES += \
+ libboringssl-compat \
+ libshim_camera \
+ libshim_log \
+ libshim_mdmcutback \
+ libshim_qcopt \
+ libshim_ril \
+ libstlport
+
# Display
PRODUCT_PACKAGES += \
copybit.msm8960 \
@@ -148,10 +158,6 @@ PRODUCT_PACKAGES += \
PRODUCT_PACKAGES += \
power.msm8960
-# Qualcomm
-PRODUCT_PACKAGES += \
- libshim_qcopt
-
# Ramdisk
PRODUCT_PACKAGES += \
init.qcom.bt.sh \
diff --git a/rootdir/etc/init.qcom.rc b/rootdir/etc/init.qcom.rc
index 9c8bcea..e571f4b 100644
--- a/rootdir/etc/init.qcom.rc
+++ b/rootdir/etc/init.qcom.rc
@@ -42,8 +42,8 @@ on early-init
# Create persist mount point
mkdir /persist 0771 system system
- # Symbols required for motorola blobs
- export LD_SHIM_LIBS "/system/lib/libqc-opt.so|libshim_qcopt.so"
+ # Symbols required for Motorola blobs
+ export LD_SHIM_LIBS "/system/vendor/lib/libgsl.so|libboringssl-compat.so:/system/lib/libmot_sensorlistener.so|libshim_camera.so:/system/lib/liblog.so|libshim_log.so:/system/lib/libmdmcutback.so|libshim_mdmcutback.so:/system/lib/libqc-opt.so|libshim_qcopt.so:/system/lib/libril.so|libshim_ril.so"
symlink /data/tombstones /tombstones