getHostHardwareCode static method

String getHostHardwareCode(
  1. LicenseHardwareCodeType hardwareCodeType
)

Retrieves the hardware code of the device using the requested hardware code type. This function retrieves the hardware code of the device you run the library on. The optional parameter is required:

  • On Android, it must be the JNIEnv* pointer cast as a void*.
  • In other cases, it must be set to NULL.

param hardwareCodeType The requested hardware code type. return The device hardware code. throws DocumentException An error has occurred during Document Library execution.

Implementation

static String getHostHardwareCode(LicenseHardwareCodeType hardwareCodeType) {
  Pointer<Char> pCode = calloc.allocate(256);
  Pointer<Int> pCodeSize = calloc.allocate(1);
  pCodeSize[0] = 256;
  Pointer<Void> pOptionalParameter = nullptr;
		if (Platform.isAndroid) {
			pOptionalParameter = getJniEnvPtr();
		}
  try {
    var err = documentSDK.id3DocumentLicense_GetHostHardwareCode(hardwareCodeType.value, pCode, pCodeSize, pOptionalParameter);
    if (err == DocumentError.insufficientBuffer.value) {
      calloc.free(pCode);
      pCode = calloc.allocate(pCodeSize.value);
      err = documentSDK.id3DocumentLicense_GetHostHardwareCode(hardwareCodeType.value, pCode, pCodeSize, pOptionalParameter);
      if (err != DocumentError.success.value) {
        throw DocumentException(err);
      }
    }
    final vCode = utf8.decode(Uint8List.fromList(pCode.cast<Uint8>().asTypedList(pCodeSize.value)));
    return vCode;
  } finally {
    calloc.free(pCode);
    calloc.free(pCodeSize);
  }
}