diff --git a/res/layout/assistant_remote_provisioning.xml b/res/layout/assistant_remote_provisioning.xml
index c81a66f15..000bd4f53 100644
--- a/res/layout/assistant_remote_provisioning.xml
+++ b/res/layout/assistant_remote_provisioning.xml
@@ -59,5 +59,18 @@
android:paddingRight="10dp"
android:layout_marginTop="20dp"/>
+
+
+
\ No newline at end of file
diff --git a/res/layout/qrcode.xml b/res/layout/qrcode.xml
new file mode 100644
index 000000000..d2e51fef2
--- /dev/null
+++ b/res/layout/qrcode.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/video.xml b/res/layout/video.xml
index 86b7465e8..0180f70b4 100644
--- a/res/layout/video.xml
+++ b/res/layout/video.xml
@@ -1,20 +1,20 @@
-
-
-
-
+ android:id="@+id/video_frame"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+
+
+
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5ec07acec..5a422e2f7 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -84,6 +84,7 @@
Use SIP account
Fetch remote configuration
Fetch and apply
+ QRCode
Login
Echo canceler calibration in progress
Enter your login
diff --git a/src/android/org/linphone/LinphoneManager.java b/src/android/org/linphone/LinphoneManager.java
index e72e36b87..59138e3bc 100644
--- a/src/android/org/linphone/LinphoneManager.java
+++ b/src/android/org/linphone/LinphoneManager.java
@@ -1302,8 +1302,8 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
}
@Override
- public void onQrcodeFounded(Core lc, String result) {
-
+ public void onQrcodeFound(Core lc, String result) {
+
}
public void onCallEncryptionChanged(Core lc, Call call,
diff --git a/src/android/org/linphone/assistant/AssistantActivity.java b/src/android/org/linphone/assistant/AssistantActivity.java
index 409c7f3d6..ac20daf3f 100644
--- a/src/android/org/linphone/assistant/AssistantActivity.java
+++ b/src/android/org/linphone/assistant/AssistantActivity.java
@@ -100,6 +100,8 @@ private static AssistantActivity instance;
private boolean remoteProvisioningInProgress;
private boolean echoCancellerAlreadyDone;
private static final int PERMISSIONS_REQUEST_RECORD_AUDIO = 201;
+ private static final int PERMISSIONS_REQUEST_CAMERA = 202;
+ private static final int PERMISSIONS_ENABLED_CAMERA = 203;
private AccountCreator mAccountCreator;
private CountryListAdapter countryListAdapter;
@@ -190,6 +192,16 @@ private static AssistantActivity instance;
}
}
}
+
+ @Override
+ public void onQrcodeFound(Core lc, String result) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(AssistantActivity.instance());
+ builder.setMessage("QRCODE found: " + result);
+ builder.setCancelable(false);
+ builder.setNeutralButton(getString(R.string.ok), null);
+ builder.show();
+ }
+
};
instance = this;
}
@@ -308,6 +320,8 @@ private static AssistantActivity instance;
} else {
displayCreateAccount();
}
+ } else if (currentFragment == AssistantFragmentsEnum.QRCODE_READER) {
+ displayRemoteProvisioning();
}
}
@@ -323,6 +337,10 @@ private static AssistantActivity instance;
checkAndRequestPermission(Manifest.permission.RECORD_AUDIO, 0);
}
+ public void checkAndRequestVideoPermission() {
+ checkAndRequestPermission(Manifest.permission.CAMERA, 0);
+ }
+
public void checkAndRequestPermission(String permission, int result) {
int permissionGranted = getPackageManager().checkPermission(permission, getPackageName());
Log.i("[Permission] " + permission + " is " + (permissionGranted == PackageManager.PERMISSION_GRANTED ? "granted" : "denied"));
@@ -336,17 +354,30 @@ private static AssistantActivity instance;
}
@Override
- public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
+ public void onRequestPermissionsResult(int requestCode, String[] permissions, final int[] grantResults) {
for (int i = 0; i < permissions.length; i++) {
Log.i("[Permission] " + permissions[i] + " is " + (grantResults[i] == PackageManager.PERMISSION_GRANTED ? "granted" : "denied"));
}
- if (requestCode == PERMISSIONS_REQUEST_RECORD_AUDIO) {
- if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- launchEchoCancellerCalibration(true);
- } else {
- isEchoCalibrationFinished();
- }
+ switch (requestCode) {
+ case PERMISSIONS_REQUEST_CAMERA:
+
+ break;
+ case PERMISSIONS_ENABLED_CAMERA:
+
+ break;
+ case PERMISSIONS_REQUEST_RECORD_AUDIO:
+ LinphoneUtils.dispatchOnUIThread(new Runnable() {
+ @Override
+ public void run() {
+ if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ launchEchoCancellerCalibration(true);
+ } else {
+ isEchoCalibrationFinished();
+ }
+ }
+ });
+ break;
}
}
@@ -491,6 +522,13 @@ private static AssistantActivity instance;
back.setVisibility(View.VISIBLE);
}
+ public void displayQRCodeReader() {
+ fragment = new QrcodeFragment();
+ changeFragment(fragment);
+ currentFragment = AssistantFragmentsEnum.QRCODE_READER;
+ back.setVisibility(View.VISIBLE);
+ }
+
public void displayCountryChooser() {
fragment = new CountryListFragment();
changeFragment(fragment);
diff --git a/src/android/org/linphone/assistant/AssistantFragmentsEnum.java b/src/android/org/linphone/assistant/AssistantFragmentsEnum.java
index 52fcdd38a..eb9f6c8d3 100644
--- a/src/android/org/linphone/assistant/AssistantFragmentsEnum.java
+++ b/src/android/org/linphone/assistant/AssistantFragmentsEnum.java
@@ -28,5 +28,6 @@ public enum AssistantFragmentsEnum {
LOGIN,
REMOTE_PROVISIONING,
ECHO_CANCELLER_CALIBRATION,
- DOWNLOAD_CODEC;
+ DOWNLOAD_CODEC,
+ QRCODE_READER
}
diff --git a/src/android/org/linphone/assistant/QrcodeFragment.java b/src/android/org/linphone/assistant/QrcodeFragment.java
new file mode 100644
index 000000000..5fdad540d
--- /dev/null
+++ b/src/android/org/linphone/assistant/QrcodeFragment.java
@@ -0,0 +1,110 @@
+package org.linphone.assistant;
+
+/*
+QrcodeFragment.java
+Copyright (C) 2018 Belledonne Communications, Grenoble, France
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+import android.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.SurfaceView;
+import android.view.View;
+import android.view.ViewGroup;
+import org.linphone.LinphoneManager;
+import org.linphone.R;
+import org.linphone.mediastream.video.AndroidVideoWindowImpl;
+import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
+
+public class QrcodeFragment extends Fragment {
+ private SurfaceView mQrcodeView;
+ private AndroidVideoWindowImpl androidVideoWindowImpl;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.qrcode, container, false);
+
+ mQrcodeView = (SurfaceView) view.findViewById(R.id.qrcodeCaptureSurface);
+
+ return view;
+ }
+
+ private void enableQrcodeReader(boolean enable) {
+ //LinphoneManager.getLc().enableQrcodeVideoPreview(enable);
+ LinphoneManager.getLc().enableVideoPreview(enable);
+ }
+
+ private void setBackCamera(boolean useBackCamera) {
+ int camId = 0;
+ AndroidCameraConfiguration.AndroidCamera[] cameras = AndroidCameraConfiguration.retrieveCameras();
+ for (AndroidCameraConfiguration.AndroidCamera androidCamera : cameras) {
+ if (androidCamera.frontFacing == !useBackCamera)
+ camId = androidCamera.id;
+ }
+ String[] devices = LinphoneManager.getLc().getVideoDevicesList();
+ String newDevice = devices[camId];
+ LinphoneManager.getLc().setVideoDevice(newDevice);
+ }
+
+ private void launchQrcodeReader() {
+ setBackCamera(true);
+
+ androidVideoWindowImpl = new AndroidVideoWindowImpl(null, mQrcodeView, new AndroidVideoWindowImpl.VideoWindowListener() {
+ public void onVideoRenderingSurfaceReady(AndroidVideoWindowImpl vw, SurfaceView surface) {
+
+ }
+
+ public void onVideoRenderingSurfaceDestroyed(AndroidVideoWindowImpl vw) {
+
+ }
+
+ public void onVideoPreviewSurfaceReady(AndroidVideoWindowImpl vw, SurfaceView surface) {
+ mQrcodeView = surface;
+ LinphoneManager.getLc().setNativePreviewWindowId(vw);
+ }
+
+ public void onVideoPreviewSurfaceDestroyed(AndroidVideoWindowImpl vw) {
+
+ }
+ });
+
+ enableQrcodeReader(true);
+ LinphoneManager.getLc().setQrcodeDecodeRect(500,220,280,280);
+ }
+
+ @Override
+ public void onStart() {
+ AssistantActivity.instance().checkAndRequestVideoPermission();
+ super.onStart();
+ }
+
+ @Override
+ public void onResume() {
+ launchQrcodeReader();
+ super.onResume();
+ }
+
+ @Override
+ public void onPause() {
+ LinphoneManager.getLc().setNativePreviewWindowId(null);
+ androidVideoWindowImpl.release();
+ enableQrcodeReader(false);
+ setBackCamera(false);
+ super.onPause();
+ }
+}
diff --git a/src/android/org/linphone/assistant/RemoteProvisioningFragment.java b/src/android/org/linphone/assistant/RemoteProvisioningFragment.java
index c02587003..17ddfec54 100644
--- a/src/android/org/linphone/assistant/RemoteProvisioningFragment.java
+++ b/src/android/org/linphone/assistant/RemoteProvisioningFragment.java
@@ -36,7 +36,7 @@ import android.widget.EditText;
public class RemoteProvisioningFragment extends Fragment implements OnClickListener, TextWatcher{
private EditText remoteProvisioningUrl;
- private Button apply;
+ private Button apply, qrcode;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -45,6 +45,8 @@ public class RemoteProvisioningFragment extends Fragment implements OnClickListe
remoteProvisioningUrl = (EditText) view.findViewById(R.id.assistant_remote_provisioning_url);
remoteProvisioningUrl.addTextChangedListener(this);
+ qrcode = (Button) view.findViewById(R.id.assistant_qrcode);
+ qrcode.setOnClickListener(this);
apply = (Button) view.findViewById(R.id.assistant_apply);
apply.setEnabled(false);
apply.setOnClickListener(this);
@@ -62,6 +64,8 @@ public class RemoteProvisioningFragment extends Fragment implements OnClickListe
LinphonePreferences.instance().setRemoteProvisioningUrl(url);
LinphoneManager.getInstance().restartCore();
AssistantActivity.instance().setCoreListener();
+ } else if (id == R.id.assistant_qrcode) {
+ AssistantActivity.instance().displayQRCodeReader();
}
}
diff --git a/submodules/linphone b/submodules/linphone
index f985c8a7c..451f75275 160000
--- a/submodules/linphone
+++ b/submodules/linphone
@@ -1 +1 @@
-Subproject commit f985c8a7c3b84df3de6bb557c8fe0eabcb56ab05
+Subproject commit 451f75275ccb37866f4808c79c62c5f360980d17
diff --git a/submodules/mediastreamer2 b/submodules/mediastreamer2
index 9c69731ad..a46973154 160000
--- a/submodules/mediastreamer2
+++ b/submodules/mediastreamer2
@@ -1 +1 @@
-Subproject commit 9c69731add9f4d9fa9642ac6b163d610d48bcae8
+Subproject commit a46973154acaab7ea7aca926e382acff4445bb17