在开机向导界面连续点击几次屏幕启动QR打开摄像头,默认是打开后摄像头。如果机器只有一个前摄像头,判断扫码应用时,需要把camera的facing信息上报为BACK。修改如下:
frameworks/base
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index 6ba77cd..e0e6914 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -116,6 +116,7 @@ import android.util.ArraySet;
import android.util.DebugUtils;
import android.util.Pools.SynchronizedPool;
import android.util.Slog;
+import android.os.SystemProperties;
import android.window.RemoteTransition;
import com.android.internal.annotations.VisibleForTesting;
@@ -867,6 +868,8 @@ class ActivityStarter {
if (err == ActivityManager.START_SUCCESS) {
Slog.i(TAG, "START u" + userId + " {" + intent.toShortString(true, true, true, false)
+ "} from uid " + callingUid);
+ SystemProperties.set("sys.camera.callprocess", intent.getComponent().getPackageName());
+ Slog.i("Camera", "callprocess:" + intent.getComponent().getPackageName());
}
ActivityRecord sourceRecord = null;
frameworks/av
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index c91f962..433fd74 100755
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -107,6 +107,7 @@ volatile int32_t gLogLevel = 0;
#define LOG1(...) ALOGD_IF(gLogLevel >= 1, __VA_ARGS__);
#define LOG2(...) ALOGD_IF(gLogLevel >= 2, __VA_ARGS__);
+#define CONFIG_CAMERA_BACK_APK "<com.google.android.setupwizard>"
static void setLogLevel(int level) {
android_atomic_write(level, &gLogLevel);
@@ -725,7 +726,16 @@ Status CameraService::getCameraInfo(int cameraId,
strerror(-err), err);
logServiceError(String8::format("Error retrieving camera info from device %d",cameraId),
ERROR_INVALID_OPERATION);
- }
+ } else {
+ char value[PROPERTY_VALUE_MAX];
+ property_get("sys.camera.callprocess", value, "none");
+ ALOGE("getCameraInfo camera callprocess:%s", value);
+ if (strstr(CONFIG_CAMERA_BACK_APK, value)) {
+ if (mNumberOfCameras == 1) {
+ cameraInfo->facing = CAMERA_FACING_BACK;
+ }
+ }
+ }
return ret;