問題原因:微信QQ對攝像頭方向的限制比較高,當檢測攝像頭方向與要求的不一致是,會直接提示無權限,並不能錄製小視頻
解決方案:在Camera的Hal進行檢查,如果是微信小視頻的activity,則旋轉camera的orientation,具體修改如下:
diff --git a/frameworks/base/core/java/android/view/OrientationEventListener.java b/frameworks/base/core/java/android/view/OrientationEventListener.java
--- 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.os.SystemProperties;
* Helper class for receiving notifications from the SensorManager when
@@ -120,6 +121,10 @@ public abstract class OrientationEventListener {
int orientation = ORIENTATION_UNKNOWN;
+ if ("1".equals(SystemProperties.get("persist.sys.wechatcapture", "0"))) {
// 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
--- 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
Slog.w(TAG_WM, "Attempted to set focus to non-existing app token: " + token);
+ if ((newFocus.toString().indexOf("plugin.mmsight.ui.SightCaptureUI") != -1)) {
+ SystemProperties.set("persist.sys.wechatcapture", "1");
+ 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
--- a/vendor/mediatek/proprietary/hardware/mtkcam/legacy/module_hal/devicemgr/CamDeviceManagerBase.cpp
+++ b/vendor/mediatek/proprietary/hardware/mtkcam/legacy/module_hal/devicemgr/CamDeviceManagerBase.cpp
#define LOG_TAG "MtkCam/devicemgr"
+#include <cutils/properties.h> // For property_get().
#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);
diff --git a/hardware/rk29/camera/CameraHal.h b/hardware/rk29/camera/CameraHal.h
--- 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
--- 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)
-#if CONFIG_CAMERA_ORIENTATION_SKYPE
+#if CONFIG_CAMERA_ORIENTATION_WECHAT
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 = gCamInfos[camera_id].facing_info.orientation;
處理方式:在device中添加ro值:ro.qq.camera.sensor=3
處理方式:在device中添加ro值:ro.qq.camera.sensor=0
如果是在不同的版本中旋轉的角度不一致,可以通過宏控開關進行控制。
(1):首先在QQ普通版上修改,視屏通話過程中正常以後,在進行第二步處理
(2):QQ普通版視屏通話正常前提下,將設備型號,QQ普通版視屏通話正常的ro值,廠商提供給:QQ(HD)負責人(由於原因。不寫出聯繫人,需要的可以私聊), 做一個專門配置。