title: Android Camera2 executable failed to get frames
body: <p>I have one Camera2 NDK code to open the camera and get images.</p>
  
  <p>The code work fine via Android Application/Service, but if I compile and run it as executable the camera opened but I don't get any frames.</p>
  
  <p>Any idea? someone succeeded to do it?</p>
  
  <hr>
  
  <p>NOTE</p>
  
  <ol>
  <li>I create my own AImageReader via "AImageReader_new"</li>
  <li>I create my own ANativeWindow via "AImageReader_getWindow"</li>
  </ol>
  
  <hr>
  
  <p>NOTE2 (ADDED)</p>
  
  <p>The calls is a little different</p>
  
  <p>For Android Application/Service the calls like:</p>
  
  <pre><code>public void onCreate() {
         JNIBridge.startPreview(null);
  }
  public void onDestroy() {
         JNIBridge.stopPreview();
  }
  </code></pre>
  
  <p>For the executable:</p>
  
  <pre><code>int main()
  {
  Java_com_y30_nativecamera2_JNIBridge_startPreview(nullptr, nullptr, nullptr);
  
  for(int i = 0; i &lt; 10; ++i)
  {
      std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  }
  
  Java_com_y30_nativecamera2_JNIBridge_stopPreview(nullptr, nullptr);
  
  return 0;
  }
  </code></pre>
  
  <hr>
  
  <p>UPDATE</p>
  
  <p>I tested it again on multi Android devices.</p>
  
  <p>S8/S9+ (With Andorid 8.0.0) it's reproduce.("ACameraManager_openCamera" status is OK, but I don't get any frames)</p>
  
  <p>Pixel (With Android 9) the method "ACameraManager_openCamera" failed.</p>
  
  <pre><code>10-09 10:45:04.933   933  1592 I CameraService: CameraService::connect call (PID -1 "", camera ID 0) for HAL version default and Camera API version 2
  10-09 10:45:04.933   933  1592 W ServiceManager: Permission failure: android.permission.CAMERA from uid=2000 pid=19606
  10-09 10:45:04.933   933  1592 E CameraService: Permission Denial: can't use the camera pid=19606, uid=2000
  10-09 10:45:04.933 19606 19606 E ACameraManager: openCamera: connect camera device failed: Status(-8): '1: validateClientPermissionsLocked:906: Caller "" (PID 2000, UID 19606) cannot open camera "0" without camera permission'
  </code></pre>
  
  <hr>
  
  <p>UPDATE2</p>
  
  <p>I tested it also with msm8996 EVB (With Android 7.1.1):</p>
  
  <p>(1) I get permission issue like the Pixel2.</p>
  
  <p>(2) I ran it with su and the permission issue fixed (the camera opened) but I already don't get any images.</p>