Determine if running on a rooted device

后端 未结 24 2251
無奈伤痛
無奈伤痛 2020-11-22 06:43

My app has a certain piece of functionality that will only work on a device where root is available. Rather than having this feature fail when it is used (and then show an a

24条回答
  •  情话喂你
    2020-11-22 07:13

    if you don't want to use any 3rd party library or any random solution then just use google lib for detecting it.

    Android Device Verification

    response :

    {
      "timestampMs": 9860437986543,
      "nonce": "R2Rra24fVm5xa2Mg",
      "apkPackageName": "com.package.name.of.requesting.app",
      "apkCertificateDigestSha256": ["base64 encoded, SHA-256 hash of the
                                      certificate used to sign requesting app"],
      "ctsProfileMatch": true,
      "basicIntegrity": true,
    }
    

    ctsProfileMatch it gives false if the device is rooted.

    ref link: [1]: https://developer.android.com/training/safetynet/attestation

提交回复
热议问题