Procházet zdrojové kódy

handle no camera device bug

billyyoyo před 6 roky
rodič
revize
1c86d6329c

binární
app/libs/face-sdk-release.aar


+ 19 - 17
app/src/main/java/com/sheep/gamegroup/module/qrcode/FaceWithQRActivity.java

@@ -15,6 +15,7 @@ import com.baidu.idl.face.platform.FaceSDKManager;
 import com.sheep.gamegroup.absBase.BaseActivity;
 import com.sheep.gamegroup.util.Constant;
 import com.sheep.gamegroup.util.DeviceUtil;
+import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.upfile.UpFileListener;
 import com.sheep.gamegroup.util.upfile.UpFileUtils;
 import com.snail.antifake.jni.EmulatorDetectUtil;
@@ -69,26 +70,25 @@ public class FaceWithQRActivity extends BaseActivity {
     }
 
     private void dispatch() {
-//        if (CameraUtil.hasCamera()) {
-//        if (!useQR) {
-        if(!EmulatorDetectUtil.isEmulator()){
+        if (!EmulatorDetectUtil.isEmulator()) {
             if (type == Constant.INTENT_DETECT_LIVENESS) {
                 FaceSDKManager.getInstance().goLivenessCheck(this, FaceSDKManager.NEED_FILEPATH);
             } else {
                 FaceSDKManager.getInstance().goFaceDetect(this, FaceSDKManager.NEED_FILEPATH);
             }
         } else {
-            Intent intent = new Intent(this, QRCodeActivity.class);
-            if(type == Constant.INTENT_DETECT_LIVENESS){
-                intent.putExtra("req", "sheep://liveness");
-            }else{
-                intent.putExtra("req", "sheep://facedetect");
-            }
-            intent.putExtra("message", "检测到你的账号异常,需要人脸识别验证");
-            intent.putExtra("token", token);
-            intent.putExtra("extra", "");
-            startActivityForResult(intent, Constant.INTENT_QRCODE_DATA);
+            showQRCode();
+        }
+    }
+
+    private void showQRCode() {
+        String req = null;
+        if (type == Constant.INTENT_DETECT_LIVENESS) {
+            req = "sheep://liveness";
+        } else {
+            req = "sheep://facedetect";
         }
+        Jump2View.getInstance().gotoShowQRCode(this, req, token, "检测到你的账号异常,需要人脸识别验证", Constant.INTENT_QRCODE_DATA);
     }
 
     @Override
@@ -97,10 +97,12 @@ public class FaceWithQRActivity extends BaseActivity {
         if (resultCode == RESULT_OK && data != null) {
             if (requestCode == Constant.INTENT_QRCODE_DATA) {
                 returnResult(data.getStringExtra("result"));
-            } else if (requestCode == Constant.INTENT_DETECT_LIVENESS) {
-                uploadFace(data.getStringExtra("bestPath"));
-            } else if (requestCode == Constant.INTENT_DETECT_FACE) {
-                uploadFace(data.getStringExtra("bestPath"));
+            } else if (requestCode == Constant.INTENT_DETECT_LIVENESS || requestCode == Constant.INTENT_DETECT_FACE) {
+                if (data.hasExtra("no_camera")) {
+                    showQRCode();
+                } else {
+                    uploadFace(data.getStringExtra("bestPath"));
+                }
             } else {
                 finish();
             }

+ 1 - 0
app/src/main/java/com/sheep/gamegroup/util/Constant.java

@@ -7,4 +7,5 @@ public class Constant {
     public final static int INTENT_RECHARGE = 1004;
     public final static int INTENT_CAPTURE_QRCODE = 1005;
     public final static int INTENT_QRCODE_DATA = 1006;
+    public final static int INTENT_SHOW_QRCODE = 1007;
 }

+ 10 - 0
app/src/main/java/com/sheep/gamegroup/util/Jump2View.java

@@ -66,6 +66,7 @@ import com.sheep.gamegroup.module.game.activity.ActGitBagList;
 import com.sheep.gamegroup.module.game.activity.ActMyGameList;
 import com.sheep.gamegroup.module.guide.NewbieGuideHelper;
 import com.sheep.gamegroup.module.qrcode.FaceWithQRActivity;
+import com.sheep.gamegroup.module.qrcode.QRCodeActivity;
 import com.sheep.gamegroup.module.search.ActSearch;
 import com.sheep.gamegroup.module.game.activity.ActWelfareSpecialArea;
 import com.sheep.gamegroup.module.game.model.GameCenterType;
@@ -713,6 +714,15 @@ public class Jump2View {
         }
     }
 
+    public void gotoShowQRCode(Activity activity, String req, String token, String message, int action) {
+        Intent intent = new Intent(activity, QRCodeActivity.class);
+        intent.putExtra("req", req);
+        intent.putExtra("message", message);
+        intent.putExtra("token", token);
+        intent.putExtra("extra", "");
+        activity.startActivityForResult(intent, action);
+    }
+
     public synchronized void goVideoTaskView(Context context, Integer id) {
         Intent intent = new Intent(context, VideoTaskActivity.class);
         intent.putExtra("task_id", id);