# mini-change 分支改动说明

基于老的 WBH5FaceVerifySDK 做兼容性改造：新增 `faceid` 域名支持 + 核身音频权限申请。

## 1. 人脸核身兼容慧眼新域名 faceid

在 `WBH5FaceVerifySDK.isTencentH5FaceVerify` 函数中，新增对 `faceid` 域名的兼容判断：

```java
// 新增条件：|| thirdName.contains("faceid")
if (thirdName.contains("kyc") || thirdName.contains("ida") || thirdName.contains("faceid"))
```

涉及文件：`app/src/main/java/com/wb/testcloud/WBH5FaceVerifySDK.java`（两个重载方法）

## 2. 核身 + 视频 / 朗读模式：新增音频权限申请

根据业务实际情况，如果人脸核身模式为「核身 + 视频」或「核身 + 朗读」，需要额外申请麦克风权限。

### 2.1 AndroidManifest.xml — 添加麦克风权限声明

```xml
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
```

### 2.2 MainActivity.java — requestCameraPermission 方法整体替换

TRTC 模式同时检查相机和麦克风权限，任意缺失则申请所需权限。

```java
public void requestCameraPermission(boolean trtc, boolean belowApi21) {
    this.belowApi21 = belowApi21;
    if (trtc) {
        // TRTC 模式：同时需要相机和麦克风权限
        boolean hasCamera = checkSdkPermission(Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED;
        boolean hasAudio  = checkSdkPermission(Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED;
        if (hasCamera && hasAudio) {
            Log.d(TAG, "checkSelfPermission true (trtc)");
            webViewClient.enterTrtcFaceVerify();
        } else {
            Log.d(TAG, "checkSelfPermission false (trtc), hasCamera=" + hasCamera + ", hasAudio=" + hasAudio);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                java.util.ArrayList<String> needPermissions = new java.util.ArrayList<>();
                if (!hasCamera) needPermissions.add(Manifest.permission.CAMERA);
                if (!hasAudio)  needPermissions.add(Manifest.permission.RECORD_AUDIO);
                ActivityCompat.requestPermissions(this,
                        needPermissions.toArray(new String[0]),
                        PERMISSION_QUEST_TRTC_CAMERA_VERIFY);
            } else {
                openAppDetail(PERMISSION_QUEST_TRTC_CAMERA_VERIFY);
            }
        }
    } else {
        // 录制模式：仅需要相机权限，保持原有逻辑
        if (checkSdkPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
            Log.d(TAG, "checkSelfPermission false");
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                ActivityCompat.requestPermissions(this,
                        new String[]{Manifest.permission.CAMERA},
                        PERMISSION_QUEST_OLD_CAMERA_VERIFY);
            } else {
                openAppDetail(PERMISSION_QUEST_OLD_CAMERA_VERIFY);
            }
        } else {
            Log.d(TAG, "checkSelfPermission true");
            webViewClient.enterOldModeFaceVerify(belowApi21);
        }
    }
}
```

### 2.3 onRequestPermissionsResult — 替换 PERMISSION_QUEST_TRTC_CAMERA_VERIFY 分支

支持多个权限（相机 + 麦克风）的回调处理：

```java
case PERMISSION_QUEST_TRTC_CAMERA_VERIFY: // TRTC 模式（相机 + 麦克风）
    if (grantResults.length > 0) {
        boolean allGranted = true;
        for (int result : grantResults) {
            if (result != PackageManager.PERMISSION_GRANTED) {
                allGranted = false;
                break;
            }
        }
        if (allGranted) {
            Log.d(TAG, "onRequestPermissionsResult camera+audio all granted");
            webViewClient.enterTrtcFaceVerify();
        } else {
            boolean deniedForever = false;
            for (String p : permissions) {
                if (checkSdkPermission(p) != PackageManager.PERMISSION_GRANTED
                        && !ActivityCompat.shouldShowRequestPermissionRationale(this, p)) {
                    deniedForever = true;
                    break;
                }
            }
            if (deniedForever) {
                Log.d(TAG, "onRequestPermissionsResult camera/audio denied forever");
                openAppDetail(PERMISSION_QUEST_TRTC_CAMERA_VERIFY);
            } else {
                Log.d(TAG, "onRequestPermissionsResult deny but not forever");
                askPermissionError();
            }
        }
    }
    break;
```
