message: Use the NnApiDelegate directly with Interpreter.Options.setUseNNAPI.
  The dynamic useNNAPI method is deprecated, so avoid it when using the
  blessed NNAPI path in Interpreter.Options.
diff: @@ -22,6 +22,7 @@ import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  +import org.tensorflow.lite.nnapi.NnApiDelegate;
  /**
  * An internal wrapper that wraps native interpreter and controls model execution.
  @@ -69,9 +70,6 @@ final class NativeInterpreterWrapper implements AutoCloseable {
  this.interpreterHandle = createInterpreter(modelHandle, errorHandle, options.numThreads);
  this.inputTensors = new Tensor[getInputCount(interpreterHandle)];
  this.outputTensors = new Tensor[getOutputCount(interpreterHandle)];
  - if (options.useNNAPI != null) {
  - setUseNNAPI(options.useNNAPI.booleanValue());
  - }
  if (options.allowFp16PrecisionForFp32 != null) {
  allowFp16PrecisionForFp32(
  interpreterHandle, options.allowFp16PrecisionForFp32.booleanValue());
  @@ -79,6 +77,10 @@ final class NativeInterpreterWrapper implements AutoCloseable {
  if (options.allowBufferHandleOutput != null) {
  allowBufferHandleOutput(interpreterHandle, options.allowBufferHandleOutput.booleanValue());
  }
  + if (options.useNNAPI != null && options.useNNAPI.booleanValue()) {
  + optionalNnApiDelegate = new NnApiDelegate();
  + applyDelegate(interpreterHandle, errorHandle, optionalNnApiDelegate.getNativeHandle());
  + }
  for (Delegate delegate : options.delegates) {
  applyDelegate(interpreterHandle, errorHandle, delegate.getNativeHandle());
  delegates.add(delegate);
  @@ -112,6 +114,10 @@ final class NativeInterpreterWrapper implements AutoCloseable {
  outputsIndexes = null;
  isMemoryAllocated = false;
  delegates.clear();
  + if (optionalNnApiDelegate != null) {
  + optionalNnApiDelegate.close();
  + optionalNnApiDelegate = null;
  + }
  }
  /** Sets inputs, runs model inference and returns outputs. */
  @@ -345,6 +351,10 @@ final class NativeInterpreterWrapper implements AutoCloseable {
  // delegates for safety.
  private final List<Delegate> delegates = new ArrayList<>();
  + // Prefer using the NnApiDelegate directly rather than the deprecated useNNNAPI() method when
  + // NNAPI is enabled via Interpreter.Options.
  + private NnApiDelegate optionalNnApiDelegate;
  +
  private static native long allocateTensors(long interpreterHandle, long errorHandle);
  private static native int getInputTensorIndex(long interpreterHandle, int inputIdx);
  