Commits

Stephen Smalley committed 61129d1 Merge

Merge tag 'android-4.2.2_r1' into seandroid-4.2

Android 4.2.2 release 1

  • Participants
  • Parent commits 83f3ff7, 5a2f2bf
  • Branches seandroid-4.2

Comments (0)

Files changed (8)

File audio/audio_hw.c

     pthread_mutex_unlock(&adev->lock);
 }
 
+/* must be called with hw device mutex locked */
+bool get_bubblelevel(struct audio_device *adev)
+{
+    if (!adev->bubble_level) {
+        adev->bubble_level = bubble_level_create();
+        if (adev->bubble_level)
+            adev->bubble_level->set_callback(adev->bubble_level, bubblelevel_callback, adev);
+    }
+    return (adev->bubble_level != NULL);
+}
+
 static void force_non_hdmi_out_standby(struct audio_device *adev)
 {
     enum output_type type;
         set_hdmi_channels(adev, out->config.channels);
 
     /* anticipate level measurement in case we start capture later */
-    adev->bubble_level->poll_once(adev->bubble_level);
+    if (get_bubblelevel(adev))
+        adev->bubble_level->poll_once(adev->bubble_level);
 
     return 0;
 }
     in->ramp_step = (uint16_t)(USHRT_MAX / in->ramp_frames);
     in->ramp_vol = 0;;
 
-    adev->bubble_level->set_poll_interval(adev->bubble_level, BL_POLL_INTERVAL_MIN_SEC);
-    adev->bubble_level->start_polling(adev->bubble_level);
+    if (get_bubblelevel(adev)) {
+        adev->bubble_level->set_poll_interval(adev->bubble_level, BL_POLL_INTERVAL_MIN_SEC);
+        adev->bubble_level->start_polling(adev->bubble_level);
+    }
 
     return 0;
 }
         select_devices(in->dev);
         in->standby = true;
 
-        in->dev->bubble_level->stop_polling(in->dev->bubble_level);
+        if (get_bubblelevel(in->dev))
+            in->dev->bubble_level->stop_polling(in->dev->bubble_level);
     }
 
     eS305_SetActiveIoHandle(ES305_IO_HANDLE_NONE);
     if (adev->hdmi_drv_fd >= 0)
         close(adev->hdmi_drv_fd);
 
-    bubble_level_release(adev->bubble_level);
+    if (adev->bubble_level)
+        bubble_level_release(adev->bubble_level);
 
     free(device);
     return 0;
     adev->hdmi_drv_fd = -1;
     *device = &adev->hw_device.common;
 
-    adev->bubble_level = bubble_level_create();
-    adev->bubble_level->set_callback(adev->bubble_level, bubblelevel_callback, adev);
-
     return 0;
 }
 

File bubblelevel/Android.mk

 LOCAL_SRC_FILES := \
 	BubbleLevelImpl.cpp
 
-LOCAL_SHARED_LIBRARIES := liblog libutils libgui
+LOCAL_SHARED_LIBRARIES := liblog libutils libgui libbinder
 LOCAL_MODULE_TAGS := optional
 
 include $(BUILD_SHARED_LIBRARY)

File bubblelevel/BubbleLevelImpl.cpp

 //#define LOG_NDEBUG 0
 
 #include <utils/Log.h>
+#include <binder/IServiceManager.h>
 #include "BubbleLevelImpl.h"
 
 namespace android {
 #define BL_SENSOR_POLL_INTERVAL_MS 20
 #define BL_SENSOR_POLL_TIMEOUT_MS (BL_SENSOR_POLL_INTERVAL_MS * 5)
 #define BL_SENSOR_POLL_COUNT 10
-
+#define BL_SENSOR_LEVEL_THRESHOLD (2.0)
 
 BubbleLevelImpl::BubbleLevelImpl()
     : Thread(false),
       mState(BL_STATE_IDLE), mCmd(BL_CMD_NONE),
       mPollIntervalSec(BL_POLL_INTERVAL_DEFAULT_SEC), mPollCount(0), mLevelCount(0),
       mCallBack(NULL), mUserData(NULL),
-      mNumSensors(0), mAccelerometer(NULL)
+      mNumSensors(0), mAccelerometer(NULL),
+      mInitStatus(-ENODEV)
+{
+    init();
+}
 
+int BubbleLevelImpl::init()
 {
+    if (mInitStatus == 0) {
+        return 0;
+    }
+
+    if (defaultServiceManager()->checkService(String16("sensorservice")) == 0) {
+        ALOGW("CSTOR sensorservice not ready yet");
+        return mInitStatus;
+    }
+
     SensorManager& mgr(SensorManager::getInstance());
     Sensor const* const* sensorList;
 
 
     if (mNumSensors <= 0) {
         ALOGE("CSTOR mNumSensors error %d", mNumSensors);
-        return;
+        goto exit;
     }
     mAccelerometer = mgr.getDefaultSensor(Sensor::TYPE_ACCELEROMETER);
     if (mAccelerometer == NULL) {
         ALOGE("CSTOR mAccelerometer error NULL");
-        return;
+        goto exit;
     }
 
     mSensorEventQueue = mgr.createEventQueue();
-    if (mSensorEventQueue == NULL) {
-        ALOGE("createEventQueue returned NULL");
-        return;
+    if (mSensorEventQueue == 0) {
+        ALOGE("createEventQueue returned 0");
+        goto exit;
     }
 
     mLooper = new Looper(false);
     mLooper->addFd(mSensorEventQueue->getFd(), 0, ALOOPER_EVENT_INPUT, sensor_callback, this);
+
+    mInitStatus = 0;
+
+exit:
+    return mInitStatus;
 }
 
 BubbleLevelImpl::~BubbleLevelImpl()
 
 void BubbleLevelImpl::onFirstRef()
 {
-    run("Acc Loop", ANDROID_PRIORITY_URGENT_AUDIO);
+    if (mInitStatus == 0) {
+        run("Acc Loop", ANDROID_PRIORITY_URGENT_AUDIO);
+    }
 }
 
 bool BubbleLevelImpl::threadLoop() {
 int BubbleLevelImpl::setCallback(BubbleLevel_CallBack_t callback, void *userData)
 {
     Mutex::Autolock _l(mCallbackLock);
+    if (mInitStatus != 0) {
+        return mInitStatus;
+    }
     mCallBack = callback;
     mUserData = userData;
     return 0;
     }
 
     Mutex::Autolock _l(mStateLock);
+    if (mInitStatus != 0) {
+        return mInitStatus;
+    }
     mPollIntervalSec = seconds;
     return 0;
 }
 int BubbleLevelImpl::startPolling()
 {
     Mutex::Autolock _l(mStateLock);
+    if (mInitStatus != 0) {
+        return mInitStatus;
+    }
     if (mCmd != BL_CMD_EXIT) {
         mCmd = BL_CMD_START_POLL;
         mCond.signal();
 int BubbleLevelImpl::stopPolling()
 {
     Mutex::Autolock _l(mStateLock);
+    if (mInitStatus != 0) {
+        return mInitStatus;
+    }
     if (mCmd != BL_CMD_EXIT) {
         mCmd = BL_CMD_STOP_POLL;
         mCond.signal();
 int BubbleLevelImpl::pollOnce()
 {
     Mutex::Autolock _l(mStateLock);
+    if (mInitStatus != 0) {
+        return mInitStatus;
+    }
     if (mCmd != BL_CMD_EXIT) {
         mCmd = BL_CMD_POLL_ONCE;
         mCond.signal();
                       sensorEvents[i].vector.roll);
 
                 if ((sensorEvents[i].vector.roll > 0.0) &&
-                        (sensorEvents[i].vector.azimuth < 1.0) &&
-                        (sensorEvents[i].vector.azimuth > -1.0) &&
-                        (sensorEvents[i].vector.pitch < 1.0) &&
-                        (sensorEvents[i].vector.pitch > -1.0)) {
+                        (sensorEvents[i].vector.azimuth < BL_SENSOR_LEVEL_THRESHOLD) &&
+                        (sensorEvents[i].vector.azimuth > -BL_SENSOR_LEVEL_THRESHOLD) &&
+                        (sensorEvents[i].vector.pitch < BL_SENSOR_LEVEL_THRESHOLD) &&
+                        (sensorEvents[i].vector.pitch > -BL_SENSOR_LEVEL_THRESHOLD)) {
                     isLevel = true;
                 }
                 break;
 {
     bubble_level_C_impl *bl = new bubble_level_C_impl();
     bl->bubble_level = new android::BubbleLevelImpl();
+    if (bl->bubble_level->initStatus() != 0) {
+        bubble_level_release((struct bubble_level *)bl);
+        return NULL;
+    }
     bl->interface.set_callback = bl_set_callback;
     bl->interface.set_poll_interval = bl_set_poll_interval;
     bl->interface.start_polling = bl_start_polling;
     bl->interface.stop_polling = bl_stop_polling;
     bl->interface.poll_once = bl_poll_once;
 
-    return (bubble_level *)bl;
+    return (struct bubble_level *)bl;
 }
 
 void bubble_level_release(const struct bubble_level *bubble_level)
 {
     bubble_level_C_impl *bl = (bubble_level_C_impl *)bubble_level;
 
+    if (bl == NULL)
+        return;
+
     bl->bubble_level.clear();
     delete bubble_level;
 }

File bubblelevel/BubbleLevelImpl.h

     BubbleLevelImpl();
     virtual ~BubbleLevelImpl();
 
+    int initStatus() const { return mInitStatus; }
+
     // BubbleLevel interface
     int setCallback(BubbleLevel_CallBack_t callback, void *userData);
     int setPollInterval(unsigned int seconds);
         BL_CMD_EXIT,
     };
 
+    int init();
+
     Mutex  mStateLock;
     Mutex  mCallbackLock;
     Condition mCond;
     Sensor const* mAccelerometer;
     sp<SensorEventQueue> mSensorEventQueue;
     sp<Looper> mLooper;
-
+    int mInitStatus;
 };
 
 };
     BubbleLevelBase() { mBubbleLevel = new android::BubbleLevelImpl(); }
     virtual ~BubbleLevelBase() {}
 
+    int initStatus() {
+        return mBubbleLevel->initStatus();
+    }
+
     // BubbleLevel interface
     virtual int setCallback(BubbleLevel_CallBack_t callback, void *userData) {
         return mBubbleLevel->setCallback(callback, userData);
 };
 
 BubbleLevel *BubbleLevel::create() {
-    return static_cast<BubbleLevel *>(new BubbleLevelBase());
+    BubbleLevelBase *bl = new BubbleLevelBase();
+
+    if (bl->initStatus() != 0) {
+        delete bl;
+        bl = NULL;
+    }
+    return static_cast<BubbleLevel *>(bl);
 }
 
 struct bubble_level_C_impl

File dumpstate/dumpstate.c

     dump_file("ion exynos noncontig heap", "/d/ion/exynos_noncontig_heap");
     dump_file("ion exynos contig heap", "/d/ion/exynos_contig_heap");
     dump_file("shrinkers", "/d/shrinker");
+    dump_file("kbase carveout", "/d/kbase_carveout");
     dump_file("HDMI", "/d/exynos5-hdmi");
     dump_file("HDMI mixer", "/d/s5p-mixer");
 };

File kernel

Binary file modified.

File nfc/libnfc-brcm.conf

 #    Delay after turning off chip, before USERIAL_close returns (default 0)
 #
 #POWER_ON_DELAY=300
-#PRE_POWER_OFF_DELAY=0
+PRE_POWER_OFF_DELAY=10
 #POST_POWER_OFF_DELAY=0
 
 ###############################################################################

File power/power_manta.c

                 "90");
     sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay",
                 "140000");
+    sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/boostpulse_duration",
+                "500000");
 
     init_touchscreen_power_path(manta);
 }