如何检查隐藏摄像头 ID 是否可用于打开摄像头?(Camera2 API)

huangapple go评论146阅读模式
英文:

How to check if a hidden camera id can be used to open camera? (Camera2 API)

问题

这是翻译好的部分:

许多设备(特别是中国品牌的设备)会隐藏一些相机 ID,以供非原生应用程序使用。

仍然有一种方法可以访问更多相机:

for (id in 0..511) {
    try {
        val cameraId = id.toString()
        manager.getCameraCharacteristics(cameraId)
        // 找到相机,没有异常
    } catch (e: Throwable) {
        // 忽略
    }
}

一些用户可以通过这种方法访问他们的小米设备上的超广角摄像头,以前他们只能访问主要背面和前置摄像头。

但这并不总是有效,当尝试使用 CameraManager.openCamera(...) 打开已找到的隐藏相机时,某些设备上的所有或部分隐藏相机可能无法工作,会出现异常。

但如果有一种方法可以在使用 CameraManager.openCamera(...) 之前检查是否可以使用这样的相机 ID 来打开相机,这样已经尝试使用相机进程并需要授予相机权限,是否有一种方法可以检查?

英文:

So many devices (especially brand-Chinese ones) hide some camera ids for non-native applications.

There is still a solution to access some more cameras:

for (id in 0..511) {
    try {
        val cameraId = id.toString()
        manager.getCameraCharacteristics(cameraId)
        // found a camera, no exception
    } catch (e: Throwable) {
        // ignore
    }
}

And some users can access for example ultra wide lens camera on their Xiaomi devices with it, before they could access only main back and front cameras.

But it doesn't always work, all or part of found hidden cameras may not work on some devices when you try to open them with CameraManager.openCamera(...), there will an exception.

But if there a method to check if such camera id can be used to open camera before using CameraManager.openCamera(...) which already tries to use camera process and needs camera permission granted?

答案1

得分: 1

不,隐藏这些ID的整个原因是因为它们实际上并没有遵循API规则。

制造商没有将这些摄像头报告为公开可用,因此它们没有经过Android合规性测试套件的合规性测试。它们的运作没有任何保证,也没有API可以查询它们,因为这样它们就会变成公开可用,并且必须通过这些合规性测试。

英文:

No, the whole reason these IDs are hidden is because they don't really follow the API rules.

The manufacturer isn't reporting these cameras as publicly available, so they're not compliance tested by Android's compliance test suite. Nothing about their operation is guaranteed, and there are no APIs to query them, because then they'd be publicly available and have to pass these compliance tests.

huangapple
  • 本文由 发表于 2023年7月24日 20:05:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76754339.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定