橫屏平板微信打開攝像頭失敗

現象描述:新版本的微信錄製小視頻時,提示無權限,無法錄製

問題原因:微信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

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