【无标题】

  //安全检测服务
    public void securityFunction() {
        //安全检测对象
        SafetyDetectClient mClient = SafetyDetect.getClient(this);
        // TODO(developer): Change the nonce generation to include your own, used once value,
        // ideally from your remote server.
        byte[] nonce = ("Sample" + System.currentTimeMillis()).getBytes();
        Log.i(TAG, "securityFunction:=========== " + nonce.length);
        SysIntegrityRequest sysintegrityrequest = new SysIntegrityRequest();
        sysintegrityrequest.setAppId("106321561");//APPID
        sysintegrityrequest.setNonce(nonce);//

        sysintegrityrequest.setAlg("PS256");//RS256
        Task task = mClient.sysIntegrity(sysintegrityrequest);
        task.addOnSuccessListener(new OnSuccessListener<SysIntegrityResp>() {
            @Override
            public void onSuccess(SysIntegrityResp response) {
                Log.i(TAG, "onSuccess: 系统检测成功!!!");
                // Indicates communication with the service was successful.
                // Use response.getResult() to get the result data.
                String jwsStr = response.getResult();
                Log.i(TAG, "onSuccess: " + jwsStr);
            }
        }).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(Exception e) {
                Log.i(TAG, "onFailure: 系统检测失败!!!" + e.getMessage());
                // An error occurred while communicating with the service.
                if (e instanceof ApiException) {
                    // An error with the HMS API contains some
                    // additional details.
                    ApiException apiException = (ApiException) e;
                    // You can retrieve the status code using
                    // the apiException.getStatusCode() method.
                    Log.e(TAG, "Error: " + SafetyDetectStatusCodes.getStatusCodeString(apiException.getStatusCode()) + ": " + apiException.getMessage());
                } else {
                    // A different, unknown type of error occurred.
                    Log.e(TAG, "ERROR:" + e.getMessage());
                }
            }
        });
    }
 

 private static final String TAG = "MainActivity";

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值