-1

In the documentation of Android N preview is mentioned:

This early build is not Compatibility Test Suite (CTS) approved. Apps that depend on CTS approved builds won’t work (Android Pay for example).

In my Android app I want to check whether the device/build is CTS approved on the first launch. Is this possible? How does Android Pay do it?

ligi
  • 39,001
  • 44
  • 144
  • 244
friedger
  • 645
  • 7
  • 21
  • Link to the documentation: http://developer.android.com/preview/support.html#general (might be outdated soon) – friedger Apr 21 '16 at 19:01

1 Answers1

3

The SafetyNet API allows you to run a compatibility check which:

allows your app to check if the device where it is running matches the profile of a device that has passed Android compatibility testing. The compatibility check creates a device profile by gathering information about the device hardware and software characteristics, including the platform build.

Once you have a connected GoogleApiClient using the SafetyNet.API, you can call

byte[] nonce = getRequestNonce(); // Should be at least 16 bytes in length.
SafetyNet.SafetyNetApi.attest(mGoogleApiClient, nonce)
.setResultCallback(new ResultCallback<SafetyNetApi.AttestationResult>() {
  @Override
  public void onResult(SafetyNetApi.AttestationResult result) {
    Status status = result.getStatus();
    if (status.isSuccess()) {
      // Indicates communication with the service was successful.
      // result.getJwsResult() contains the result data
    } else {
      // An error occurred while communicating with the service
    }
  }
});

And parse the response as per the instructions, looking for "ctsProfileMatch": true in the resulting JSON.

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443