1 /*
2  * wpadebug - wpa_supplicant and Wi-Fi debugging app for Android
3  * Copyright (c) 2018, The Linux Foundation
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 package w1.fi.wpadebug;
10 
11 import android.app.Activity;
12 import android.util.Log;
13 import android.content.Intent;
14 import android.hardware.Camera;
15 import android.os.Bundle;
16 
17 public class QrCodeReadActivity extends Activity {
18 
19     private static final String TAG = "wpadebug";
20 
21     @Override
onCreate(Bundle savedInstanceState)22     protected void onCreate(Bundle savedInstanceState) {
23         super.onCreate(savedInstanceState);
24         int numberOfCameras = Camera.getNumberOfCameras();
25 
26         if (numberOfCameras > 0) {
27             Log.e(TAG, "Number of cameras found: " + numberOfCameras);
28             Intent QrCodeScanIntent = new Intent(QrCodeReadActivity.this,
29 						 QrCodeScannerActivity.class);
30             QrCodeReadActivity.this.startActivity(QrCodeScanIntent);
31             finish();
32         } else {
33             Log.e(TAG, "No cameras found, input the QR Code");
34             Intent QrCodeInputIntent = new Intent(QrCodeReadActivity.this,
35 						  InputUri.class);
36             QrCodeReadActivity.this.startActivity(QrCodeInputIntent);
37             finish();
38         }
39     }
40 }
41