横屏平板微信打开摄像头失败

现象描述:新版本的微信录制小视频时,提示无权限,无法录制

问题原因:微信QQ对摄像头方向的限制比较高,当检测摄像头方向与要求的不一致是,会直接提示无权限,并不能录制小视频

解决方案:在Camera的Hal进行检查,如果是微信小视频的activity,则旋转camera的orientation,具体修改如下:

MTK平台:

diff --git a/frameworks/base/core/java/android/view/OrientationEventListener.java b/frameworks/base/core/java/android/view/OrientationEventListener.java

old mode 100644

new mode 100755

index cd48a4f..3b9c0e2

--- a/frameworks/base/core/java/android/view/OrientationEventListener.java

+++ b/frameworks/base/core/java/android/view/OrientationEventListener.java

@@ -22,6 +22,7 @@ import android.hardware.SensorEvent;

 import android.hardware.SensorEventListener;

 import android.hardware.SensorManager;

 import android.util.Log;

+import android.os.SystemProperties;

 

 /**

  * Helper class for receiving notifications from the SensorManager when

@@ -120,6 +121,10 @@ public abstract class OrientationEventListener {

             int orientation = ORIENTATION_UNKNOWN;

             float X = -values[_DATA_X];

             float Y = -values[_DATA_Y];

+            if ("1".equals(SystemProperties.get("persist.sys.wechatcapture", "0"))) {

+                Y = values[_DATA_X];

+                X = -values[_DATA_Y];

+            }

             float Z = -values[_DATA_Z];       

             float magnitude = X*X + Y*Y;

             // Don't trust the angle if the magnitude is small compared to the y value

diff --git a/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java b/frameworks/base/services/core/java/com/android/server/wm/WindowManagerServ

index bc70662..e886074 100755

--- a/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java

+++ b/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java

@@ -4088,6 +4088,11 @@ public class WindowManagerService extends IWindowManager.Stub

                 if (newFocus == null) {

                     Slog.w(TAG_WM, "Attempted to set focus to non-existing app token: " + token);

                 } else {

+                    if ((newFocus.toString().indexOf("plugin.mmsight.ui.SightCaptureUI") != -1)) {

+                        SystemProperties.set("persist.sys.wechatcapture", "1");

+                    } else {

+                        SystemProperties.set("persist.sys.wechatcapture", "0");

+                    }

                     Intent mFocus = new Intent("com.hp.intent.action.StartActivity");

                     mFocus.putExtra("StartActivity", newFocus + "");

diff --git a/vendor/mediatek/proprietary/hardware/mtkcam/legacy/module_hal/devicemgr/CamDeviceManagerBase.cpp b/vendor/mediatek/proprietary/hardware/mtkcam/legacy/module_ha

index ab06f6e..48341cb 100755

--- a/vendor/mediatek/proprietary/hardware/mtkcam/legacy/module_hal/devicemgr/CamDeviceManagerBase.cpp

+++ b/vendor/mediatek/proprietary/hardware/mtkcam/legacy/module_hal/devicemgr/CamDeviceManagerBase.cpp

@@ -36,6 +36,7 @@

  */

 

 #define LOG_TAG "MtkCam/devicemgr"

+#include <cutils/properties.h>  // For property_get().

 //

 #include "MyUtils.h"

 #if (PLATFORM_SDK_VERSION >= 21)

@@ -243,6 +244,9 @@ getDeviceInfo(int const deviceId, camera_info& rInfo)

     rInfo.conflicting_devices = 0;

     rInfo.conflicting_devices_length = 0;

     //

+    char value[PROPERTY_VALUE_MAX] = {'\0'};

+    property_get("persist.sys.wechatcapture", value, "0");

+    if ((strcmp(value, "1") == 0)) rInfo.orientation = 90;

     MY_LOGD("deviceId:%d device_version:0x%x facing:%d orientation:%d", deviceId, rInfo.device_version, rInfo.facing, rInfo.orientation);

     return  OK;

 }

RK平台:

diff --git a/hardware/rk29/camera/CameraHal.h b/hardware/rk29/camera/CameraHal.h

index d173db7..1cce24b 100755

--- a/hardware/rk29/camera/CameraHal.h

+++ b/hardware/rk29/camera/CameraHal.h

@@ -259,6 +259,7 @@ namespace android {

 #define CONFIG_CAMERA_PRVIEW_BUF_CNT        4

 #define CONFIG_CAMERA_UVC_INVAL_FRAMECNT    5

 #define CONFIG_CAMERA_ORIENTATION_SKYPE     0

+#define CONFIG_CAMERA_ORIENTATION_WECHAT     1

 #define CONFIG_CAMERA_FRONT_ORIENTATION_SKYPE     0

 #define CONFIG_CAMERA_BACK_ORIENTATION_SKYPE      0

 

diff --git a/hardware/rk29/camera/CameraHal_Module.cpp b/hardware/rk29/camera/CameraHal_Module.cpp

index fdd0195..49ac2d4 100755

--- a/hardware/rk29/camera/CameraHal_Module.cpp

+++ b/hardware/rk29/camera/CameraHal_Module.cpp

@@ -752,7 +752,7 @@ int camera_get_camera_info(int camera_id, struct camera_info *info)

         goto end;

     }

    

-#if CONFIG_CAMERA_ORIENTATION_SKYPE

+#if CONFIG_CAMERA_ORIENTATION_WECHAT

     process_name[0] = 0x00;

     sprintf(process_name,"/proc/%d/cmdline",getCallingPid());

     fp = open(process_name, O_RDONLY);

@@ -767,8 +767,8 @@ int camera_get_camera_info(int camera_id, struct camera_info *info)

     }

 

     info->facing = gCamInfos[camera_id].facing_info.facing;

-    if (strstr(process_name,"com.skype.rover")) {

-        info->orientation = (info->facing == CAMERA_FACING_BACK)? CONFIG_CAMERA_BACK_ORIENTATION_SKYPE : CONFIG_CAMERA_FRONT_ORIENTATION_SKYPE;       

+    if (strstr(process_name,"com.tencent.mm:tools")) {

+        info->orientation = 90;      

     } else {       

         info->orientation = gCamInfos[camera_id].facing_info.orientation;      

     }

另外

1:关于QQ(普通版本)视频通话旋转问题总结:

       (1):视频顺时针旋转90度

        处理方式:在device中添加ro值:ro.qq.camera.sensor=3

       (2):视屏逆时针旋转90度

        处理方式:在device中添加ro值:ro.qq.camera.sensor=0

        如果是在不同的版本中旋转的角度不一致,可以通过宏控开关进行控制。

    2:若是在QQ(HD版本)出现视屏通话旋转问题,处理方式:

       (1):首先在QQ普通版上修改,视屏通话过程中正常以后,在进行第二步处理

       (2):QQ普通版视屏通话正常前提下,将设备型号,QQ普通版视屏通话正常的ro值,厂商提供给:QQ(HD)负责人(由于原因。不写出联系人,需要的可以私聊), 做一个专门配置。

        例如:

             1. 厂商:LENOVO

             2. 型号:xxxxxx(不能写出来)       

            3. 手机QQ可以正常使用时的:ro.qq.camera.sensor = 3

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章