Skip to content

Commit

Permalink
Camera: Add support for miui camera mode [1/2]
Browse files Browse the repository at this point in the history
 * devices like ginkgo and some xiaomi sdm660 use miui camera mode in camera
   hal to activate certain functions in camera hal, these are enabled when
   vendor.camera.miui.apk is set to 1 based on sys.camera.miui.apk value

 * if this prop is set by default gcam crashes, so we must do it dynamically

 * xiaomi does this in stock libcameraservice but unfortunately we don't
   have stock android 12 to use prebuilt lib

To enable, set TARGET_USES_MIUI_CAMERA := true in BoardConfig.

Change-Id: I8d9ee4e650f3e2196546570c183c9d169b8aa335
Signed-off-by: tejas101k <[email protected]>
  • Loading branch information
adithya2306 authored and someone5678 committed Feb 17, 2025
1 parent 5aaf2d2 commit 5a2c714
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions camera/cameraserver/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ cc_binary {
"camera_package_name_defaults",
"camera_needs_client_info_lib_defaults",
"camera_needs_client_info_lib_oplus_defaults",
"uses_miui_camera_defaults",
],

header_libs: [
Expand Down
1 change: 1 addition & 0 deletions services/camera/libcameraservice/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ cc_library {
"camera_package_name_defaults",
"camera_needs_client_info_lib_defaults",
"camera_needs_client_info_lib_oplus_defaults",
"uses_miui_camera_defaults",
],
// Camera service source

Expand Down
13 changes: 13 additions & 0 deletions services/camera/libcameraservice/CameraService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <aidl/AidlCameraService.h>
#include <android-base/macros.h>
#include <android-base/parseint.h>
#include <android-base/properties.h>
#include <android_companion_virtualdevice_flags.h>
#include <android/companion/virtualnative/IVirtualDeviceManagerNative.h>
#include <binder/ActivityManager.h>
Expand Down Expand Up @@ -117,6 +118,7 @@ namespace {

namespace android {

using base::SetProperty;
using namespace camera3;
using namespace camera3::SessionConfigurationUtils;

Expand Down Expand Up @@ -4386,6 +4388,17 @@ status_t CameraService::BasicClient::startCameraOps() {

mOpsActive = true;

#ifdef USES_MIUI_CAMERA
// Configure miui camera mode
if (String8(mClientPackageName.c_str()) == "com.android.camera") {
SetProperty("sys.camera.miui.apk", "1");
ALOGI("Enabling miui camera mode");
} else {
SetProperty("sys.camera.miui.apk", "0");
ALOGI("Disabling miui camera mode");
}
#endif

// Transition device availability listeners from PRESENT -> NOT_AVAILABLE
sCameraService->updateStatus(StatusInternal::NOT_AVAILABLE, mCameraIdStr);

Expand Down

0 comments on commit 5a2c714

Please sign in to comment.