diff --git a/sample/.gitignore b/sample/.gitignore
new file mode 100644
index 000000000..2b75303ac
--- /dev/null
+++ b/sample/.gitignore
@@ -0,0 +1,13 @@
+*.iml
+.gradle
+/local.properties
+/.idea/caches
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
+.DS_Store
+/build
+/captures
+.externalNativeBuild
diff --git a/sample/app/.gitignore b/sample/app/.gitignore
new file mode 100644
index 000000000..796b96d1c
--- /dev/null
+++ b/sample/app/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/sample/app/build.gradle b/sample/app/build.gradle
new file mode 100644
index 000000000..1bc54c517
--- /dev/null
+++ b/sample/app/build.gradle
@@ -0,0 +1,36 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 28
+ defaultConfig {
+ applicationId "org.linphone.sample"
+ minSdkVersion 21
+ targetSdkVersion 28
+ versionCode 1
+ versionName "1.0"
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+repositories {
+ maven {
+ // Replace snapshots by releases for releases !
+ url "https://linphone.org/snapshots/maven_repository"
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation 'androidx.appcompat:appcompat:1.0.2'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'androidx.test:runner:1.1.1'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
+
+ implementation "org.linphone:linphone-sdk-android:4.2+"
+}
diff --git a/sample/app/proguard-rules.pro b/sample/app/proguard-rules.pro
new file mode 100644
index 000000000..f1b424510
--- /dev/null
+++ b/sample/app/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/sample/app/src/main/AndroidManifest.xml b/sample/app/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..9ce1a1c00
--- /dev/null
+++ b/sample/app/src/main/AndroidManifest.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sample/app/src/main/java/org/linphone/sample/CallActivity.java b/sample/app/src/main/java/org/linphone/sample/CallActivity.java
new file mode 100644
index 000000000..aa54854f9
--- /dev/null
+++ b/sample/app/src/main/java/org/linphone/sample/CallActivity.java
@@ -0,0 +1,149 @@
+package org.linphone.sample;
+
+import android.annotation.TargetApi;
+import android.app.Activity;
+import android.content.pm.PackageManager;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.util.DisplayMetrics;
+import android.view.TextureView;
+import android.widget.RelativeLayout;
+
+import androidx.annotation.Nullable;
+
+import org.linphone.core.Call;
+import org.linphone.core.Core;
+import org.linphone.core.CoreListenerStub;
+import org.linphone.core.VideoDefinition;
+import org.linphone.core.tools.Log;
+import org.linphone.mediastream.Version;
+
+public class CallActivity extends Activity {
+ // We use 2 TextureView, one for remote video and one for local camera preview
+ private TextureView mVideoView;
+ private TextureView mCaptureView;
+
+ private CoreListenerStub mCoreListener;
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.call);
+
+ mVideoView = findViewById(R.id.videoSurface);
+ mCaptureView = findViewById(R.id.videoCaptureSurface);
+
+ Core core = LinphoneService.getCore();
+ // We need to tell the core in which to display what
+ core.setNativeVideoWindowId(mVideoView);
+ core.setNativePreviewWindowId(mCaptureView);
+
+ // Listen for call state changes
+ mCoreListener = new CoreListenerStub() {
+ @Override
+ public void onCallStateChanged(Core lc, Call call, Call.State state, String message) {
+ if (state == Call.State.End || state == Call.State.Released) {
+ // Once call is finished (end state), terminate the activity
+ // We also check for released state (called a few seconds later) just in case
+ // we missed the first one
+ finish();
+ }
+ }
+ };
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ LinphoneService.getCore().addListener(mCoreListener);
+ resizePreview();
+ }
+
+ @Override
+ protected void onPause() {
+ LinphoneService.getCore().removeListener(mCoreListener);
+
+ super.onPause();
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ }
+
+ @TargetApi(24)
+ @Override
+ public void onUserLeaveHint() {
+ // If the device supports Picture in Picture let's use it
+ boolean supportsPip =
+ getPackageManager()
+ .hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE);
+ Log.i("[Call] Is picture in picture supported: " + supportsPip);
+ if (supportsPip && Version.sdkAboveOrEqual(24)) {
+ enterPictureInPictureMode();
+ }
+ }
+
+ @Override
+ public void onPictureInPictureModeChanged(
+ boolean isInPictureInPictureMode, Configuration newConfig) {
+ if (isInPictureInPictureMode) {
+ // Currently nothing to do has we only display video
+ // But if we had controls or other UI elements we should hide them
+ } else {
+ // If we did hide something, let's make them visible again
+ }
+ }
+
+ private void resizePreview() {
+ Core core = LinphoneService.getCore();
+ if (core.getCallsNb() > 0) {
+ Call call = core.getCurrentCall();
+ if (call == null) {
+ call = core.getCalls()[0];
+ }
+ if (call == null) return;
+
+ DisplayMetrics metrics = new DisplayMetrics();
+ getWindowManager().getDefaultDisplay().getMetrics(metrics);
+ int screenHeight = metrics.heightPixels;
+ int maxHeight =
+ screenHeight / 4; // Let's take at most 1/4 of the screen for the camera preview
+
+ VideoDefinition videoSize =
+ call.getCurrentParams()
+ .getSentVideoDefinition(); // It already takes care of rotation
+ if (videoSize.getWidth() == 0 || videoSize.getHeight() == 0) {
+ Log.w(
+ "[Video] Couldn't get sent video definition, using default video definition");
+ videoSize = core.getPreferredVideoDefinition();
+ }
+ int width = videoSize.getWidth();
+ int height = videoSize.getHeight();
+
+ Log.d("[Video] Video height is " + height + ", width is " + width);
+ width = width * maxHeight / height;
+ height = maxHeight;
+
+ if (mCaptureView == null) {
+ Log.e("[Video] mCaptureView is null !");
+ return;
+ }
+
+ RelativeLayout.LayoutParams newLp = new RelativeLayout.LayoutParams(width, height);
+ newLp.addRule(
+ RelativeLayout.ALIGN_PARENT_BOTTOM,
+ 1); // Clears the rule, as there is no removeRule until API 17.
+ newLp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1);
+ mCaptureView.setLayoutParams(newLp);
+ Log.d("[Video] Video preview size set to " + width + "x" + height);
+ }
+ }
+}
diff --git a/sample/app/src/main/java/org/linphone/sample/ConfigureAccountActivity.java b/sample/app/src/main/java/org/linphone/sample/ConfigureAccountActivity.java
new file mode 100644
index 000000000..6d4a226b6
--- /dev/null
+++ b/sample/app/src/main/java/org/linphone/sample/ConfigureAccountActivity.java
@@ -0,0 +1,113 @@
+package org.linphone.sample;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.RadioGroup;
+import android.widget.Toast;
+
+import androidx.annotation.Nullable;
+
+import org.linphone.core.AccountCreator;
+import org.linphone.core.Core;
+import org.linphone.core.CoreListenerStub;
+import org.linphone.core.ProxyConfig;
+import org.linphone.core.RegistrationState;
+import org.linphone.core.TransportType;
+
+public class ConfigureAccountActivity extends Activity {
+ private EditText mUsername, mPassword, mDomain;
+ private RadioGroup mTransport;
+ private Button mConnect;
+
+ private AccountCreator mAccountCreator;
+ private CoreListenerStub mCoreListener;
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.configure_account);
+
+ // Account creator can help you create/config accounts, even not sip.linphone.org ones
+ // As we only want to configure an existing account, no need for server URL to make requests
+ // to know whether or not account exists, etc...
+ mAccountCreator = LinphoneService.getCore().createAccountCreator(null);
+
+ mUsername = findViewById(R.id.username);
+ mPassword = findViewById(R.id.password);
+ mDomain = findViewById(R.id.domain);
+ mTransport = findViewById(R.id.assistant_transports);
+
+ mConnect = findViewById(R.id.configure);
+ mConnect.setOnClickListener(
+ new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ configureAccount();
+ }
+ });
+
+ mCoreListener = new CoreListenerStub() {
+ @Override
+ public void onRegistrationStateChanged(Core core, ProxyConfig cfg, RegistrationState state, String message) {
+ if (state == RegistrationState.Ok) {
+ finish();
+ } else if (state == RegistrationState.Failed) {
+ Toast.makeText(ConfigureAccountActivity.this, "Failure: " + message, Toast.LENGTH_LONG).show();
+ }
+ }
+ };
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ LinphoneService.getCore().addListener(mCoreListener);
+ }
+
+ @Override
+ protected void onPause() {
+ LinphoneService.getCore().removeListener(mCoreListener);
+
+ super.onPause();
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ }
+
+ private void configureAccount() {
+ // At least the 3 below values are required
+ mAccountCreator.setUsername(mUsername.getText().toString());
+ mAccountCreator.setDomain(mDomain.getText().toString());
+ mAccountCreator.setPassword(mPassword.getText().toString());
+
+ // By default it will be UDP if not set, but TLS is strongly recommended
+ switch (mTransport.getCheckedRadioButtonId()) {
+ case R.id.transport_udp:
+ mAccountCreator.setTransport(TransportType.Udp);
+ break;
+ case R.id.transport_tcp:
+ mAccountCreator.setTransport(TransportType.Tcp);
+ break;
+ case R.id.transport_tls:
+ mAccountCreator.setTransport(TransportType.Tls);
+ break;
+ }
+
+ // This will automatically create the proxy config and auth info and add them to the Core
+ ProxyConfig cfg = mAccountCreator.configure();
+ // Make sure the newly created one is the default
+ LinphoneService.getCore().setDefaultProxyConfig(cfg);
+ }
+}
diff --git a/sample/app/src/main/java/org/linphone/sample/LauncherActivity.java b/sample/app/src/main/java/org/linphone/sample/LauncherActivity.java
new file mode 100644
index 000000000..9321cb140
--- /dev/null
+++ b/sample/app/src/main/java/org/linphone/sample/LauncherActivity.java
@@ -0,0 +1,70 @@
+package org.linphone.sample;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+
+public class LauncherActivity extends Activity {
+ private Handler mHandler;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.launcher);
+
+ mHandler = new Handler();
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ // Check whether the Service is already running
+ if (LinphoneService.isReady()) {
+ onServiceReady();
+ } else {
+ // If it's not, let's start it
+ startService(
+ new Intent().setClass(this, LinphoneService.class));
+ // And wait for it to be ready, so we can safely use it afterwards
+ new ServiceWaitThread().start();
+ }
+ }
+
+ private void onServiceReady() {
+ // Once the service is ready, we can move on in the application
+ // We'll forward the intent action, type and extras so it can be handled
+ // by the next activity if needed, it's not the launcher job to do that
+ Intent intent = new Intent();
+ intent.setClass(LauncherActivity.this, MainActivity.class);
+ if (getIntent() != null && getIntent().getExtras() != null) {
+ intent.putExtras(getIntent().getExtras());
+ }
+ intent.setAction(getIntent().getAction());
+ intent.setType(getIntent().getType());
+ startActivity(intent);
+ }
+
+ // This thread will periodically check if the Service is ready, and then call onServiceReady
+ private class ServiceWaitThread extends Thread {
+ public void run() {
+ while (!LinphoneService.isReady()) {
+ try {
+ sleep(30);
+ } catch (InterruptedException e) {
+ throw new RuntimeException("waiting thread sleep() has been interrupted");
+ }
+ }
+ // As we're in a thread, we can't do UI stuff in it, must post a runnable in UI thread
+ mHandler.post(
+ new Runnable() {
+ @Override
+ public void run() {
+ onServiceReady();
+ }
+ });
+ }
+ }
+}
diff --git a/sample/app/src/main/java/org/linphone/sample/LinphoneService.java b/sample/app/src/main/java/org/linphone/sample/LinphoneService.java
new file mode 100644
index 000000000..5b933c9fd
--- /dev/null
+++ b/sample/app/src/main/java/org/linphone/sample/LinphoneService.java
@@ -0,0 +1,235 @@
+package org.linphone.sample;
+
+import android.app.Service;
+import android.content.Intent;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.os.Build;
+import android.os.Handler;
+import android.os.IBinder;
+
+import androidx.annotation.Nullable;
+
+import org.linphone.core.Call;
+import org.linphone.core.CallParams;
+import org.linphone.core.Core;
+import org.linphone.core.CoreListenerStub;
+import org.linphone.core.Factory;
+import org.linphone.core.LogCollectionState;
+import org.linphone.core.MediaDirection;
+import org.linphone.core.tools.Log;
+import org.linphone.mediastream.Version;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Timer;
+import java.util.TimerTask;
+
+public class LinphoneService extends Service {
+ private static final String START_LINPHONE_LOGS = " ==== Device information dump ====";
+ // Keep a static reference to the Service so we can access it from anywhere in the app
+ private static LinphoneService sInstance;
+
+ private Handler mHandler;
+ private Timer mTimer;
+
+ private Core mCore;
+ private CoreListenerStub mCoreListener;
+
+ public static boolean isReady() {
+ return sInstance != null;
+ }
+
+ public static LinphoneService getInstance() {
+ return sInstance;
+ }
+
+ public static Core getCore() {
+ return sInstance.mCore;
+ }
+
+ @Nullable
+ @Override
+ public IBinder onBind(Intent intent) {
+ return null;
+ }
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+
+ // The first call to liblinphone SDK MUST BE to a Factory method
+ // So let's enable the library debug logs & log collection
+ String basePath = getFilesDir().getAbsolutePath();
+ Factory.instance().setLogCollectionPath(basePath);
+ Factory.instance().enableLogCollection(LogCollectionState.Enabled);
+ Factory.instance().setDebugMode(true, getString(R.string.app_name));
+
+ // Dump some useful information about the device we're running on
+ Log.i(START_LINPHONE_LOGS);
+ dumpDeviceInformation();
+ dumpInstalledLinphoneInformation();
+
+ mHandler = new Handler();
+ // This will be our main Core listener, it will change activities depending on events
+ mCoreListener = new CoreListenerStub() {
+ @Override
+ public void onCallStateChanged(Core lc, Call call, Call.State state, String message) {
+ if (state == Call.State.IncomingReceived) {
+ // For this sample we will automatically answer incoming calls
+ CallParams params = getCore().createCallParams(call);
+ params.enableVideo(true);
+ call.acceptWithParams(params);
+ } else if (state == Call.State.Connected) {
+ // This stats means the call has been established, let's start the call activity
+ Intent intent = new Intent(LinphoneService.this, CallActivity.class);
+ // As it is the Service that is starting the activity, we have to give this flag
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ startActivity(intent);
+ }
+ }
+ };
+
+ try {
+ // Let's copy some RAW resources to the device
+ // The default config file must only be installed once (the first time)
+ copyIfNotExist(R.raw.linphonerc_default, basePath + "/.linphonerc");
+ // The factory config is used to override any other setting, let's copy it each time
+ copyFromPackage(R.raw.linphonerc_factory, "linphonerc");
+ } catch (IOException ioe) {
+ Log.e(ioe);
+ }
+
+ // Create the Core and add our listener
+ mCore = Factory.instance()
+ .createCore(basePath + "/.linphonerc", basePath + "/linphonerc", this);
+ mCore.addListener(mCoreListener);
+ // Core is ready to be configured
+ configureCore();
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ super.onStartCommand(intent, flags, startId);
+
+ // If our Service is already running, no need to continue
+ if (sInstance != null) {
+ return START_STICKY;
+ }
+
+ // Our Service has been started, we can keep our reference on it
+ // From now one the Launcher will be able to call onServiceReady()
+ sInstance = this;
+
+ // Core must be started after being created and configured
+ mCore.start();
+ // We also MUST call the iterate() method of the Core on a regular basis
+ TimerTask lTask =
+ new TimerTask() {
+ @Override
+ public void run() {
+ mHandler.post(
+ new Runnable() {
+ @Override
+ public void run() {
+ if (mCore != null) {
+ mCore.iterate();
+ }
+ }
+ });
+ }
+ };
+ mTimer = new Timer("Linphone scheduler");
+ mTimer.schedule(lTask, 0, 20);
+
+ return START_STICKY;
+ }
+
+ @Override
+ public void onDestroy() {
+ mCore.removeListener(mCoreListener);
+ mTimer.cancel();
+ mCore.stop();
+ // A stopped Core can be started again
+ // To ensure resources are freed, we must ensure it will be garbage collected
+ mCore = null;
+ // Don't forget to free the singleton as well
+ sInstance = null;
+
+ super.onDestroy();
+ }
+
+ @Override
+ public void onTaskRemoved(Intent rootIntent) {
+ // For this sample we will kill the Service at the same time we kill the app
+ stopSelf();
+
+ super.onTaskRemoved(rootIntent);
+ }
+
+ private void configureCore() {
+ // We will create a directory for user signed certificates if needed
+ String basePath = getFilesDir().getAbsolutePath();
+ String userCerts = basePath + "/user-certs";
+ File f = new File(userCerts);
+ if (!f.exists()) {
+ if (!f.mkdir()) {
+ Log.e(userCerts + " can't be created.");
+ }
+ }
+ mCore.setUserCertificatesPath(userCerts);
+ }
+
+ private void dumpDeviceInformation() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("DEVICE=").append(Build.DEVICE).append("\n");
+ sb.append("MODEL=").append(Build.MODEL).append("\n");
+ sb.append("MANUFACTURER=").append(Build.MANUFACTURER).append("\n");
+ sb.append("SDK=").append(Build.VERSION.SDK_INT).append("\n");
+ sb.append("Supported ABIs=");
+ for (String abi : Version.getCpuAbis()) {
+ sb.append(abi).append(", ");
+ }
+ sb.append("\n");
+ Log.i(sb.toString());
+ }
+
+ private void dumpInstalledLinphoneInformation() {
+ PackageInfo info = null;
+ try {
+ info = getPackageManager().getPackageInfo(getPackageName(), 0);
+ } catch (PackageManager.NameNotFoundException nnfe) {
+ Log.e(nnfe);
+ }
+
+ if (info != null) {
+ Log.i(
+ "[Service] Linphone version is ",
+ info.versionName + " (" + info.versionCode + ")");
+ } else {
+ Log.i("[Service] Linphone version is unknown");
+ }
+ }
+
+ private void copyIfNotExist(int ressourceId, String target) throws IOException {
+ File lFileToCopy = new File(target);
+ if (!lFileToCopy.exists()) {
+ copyFromPackage(ressourceId, lFileToCopy.getName());
+ }
+ }
+
+ private void copyFromPackage(int ressourceId, String target) throws IOException {
+ FileOutputStream lOutputStream = openFileOutput(target, 0);
+ InputStream lInputStream = getResources().openRawResource(ressourceId);
+ int readByte;
+ byte[] buff = new byte[8048];
+ while ((readByte = lInputStream.read(buff)) != -1) {
+ lOutputStream.write(buff, 0, readByte);
+ }
+ lOutputStream.flush();
+ lOutputStream.close();
+ lInputStream.close();
+ }
+}
diff --git a/sample/app/src/main/java/org/linphone/sample/MainActivity.java b/sample/app/src/main/java/org/linphone/sample/MainActivity.java
new file mode 100644
index 000000000..3d6298c84
--- /dev/null
+++ b/sample/app/src/main/java/org/linphone/sample/MainActivity.java
@@ -0,0 +1,152 @@
+package org.linphone.sample;
+
+import android.Manifest;
+import android.app.Activity;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.widget.ImageView;
+
+import androidx.annotation.Nullable;
+import androidx.core.app.ActivityCompat;
+
+import org.linphone.core.Core;
+import org.linphone.core.CoreListenerStub;
+import org.linphone.core.ProxyConfig;
+import org.linphone.core.RegistrationState;
+import org.linphone.core.tools.Log;
+
+import java.util.ArrayList;
+
+public class MainActivity extends Activity {
+ private ImageView mLed;
+ private CoreListenerStub mCoreListener;
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.main);
+
+ mLed = findViewById(R.id.led);
+
+ // Monitors the registration state of our account(s) and update the LED accordingly
+ mCoreListener = new CoreListenerStub() {
+ @Override
+ public void onRegistrationStateChanged(Core core, ProxyConfig cfg, RegistrationState state, String message) {
+ updateLed(state);
+ }
+ };
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ // Ask runtime permissions, such as record audio and camera
+ // We don't need them here but once the user has granted them we won't have to ask again
+ checkAndRequestCallPermissions();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ // The best way to use Core listeners in Activities is to add them in onResume
+ // and to remove them in onPause
+ LinphoneService.getCore().addListener(mCoreListener);
+
+ // Manually update the LED registration state, in case it has been registered before
+ // we add a chance to register the above listener
+ ProxyConfig proxyConfig = LinphoneService.getCore().getDefaultProxyConfig();
+ if (proxyConfig != null) {
+ updateLed(proxyConfig.getState());
+ } else {
+ // No account configured, we display the configuration activity
+ startActivity(new Intent(this, ConfigureAccountActivity.class));
+ }
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+
+ // Like I said above, remove unused Core listeners in onPause
+ LinphoneService.getCore().removeListener(mCoreListener);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ }
+
+ @Override
+ public void onRequestPermissionsResult(
+ int requestCode, String[] permissions, int[] grantResults) {
+ // Callback for when permissions are asked to the user
+ for (int i = 0; i < permissions.length; i++) {
+ Log.i(
+ "[Permission] "
+ + permissions[i]
+ + " is "
+ + (grantResults[i] == PackageManager.PERMISSION_GRANTED
+ ? "granted"
+ : "denied"));
+ }
+ }
+
+ private void updateLed(RegistrationState state) {
+ switch (state) {
+ case Ok: // This state means you are connected, to can make and receive calls & messages
+ mLed.setImageResource(R.drawable.led_connected);
+ break;
+ case None: // This state is the default state
+ case Cleared: // This state is when you disconnected
+ mLed.setImageResource(R.drawable.led_disconnected);
+ break;
+ case Failed: // This one means an error happened, for example a bad password
+ mLed.setImageResource(R.drawable.led_error);
+ break;
+ case Progress: // Connection is in progress, next state will be either Ok or Failed
+ mLed.setImageResource(R.drawable.led_inprogress);
+ break;
+ }
+ }
+
+ private void checkAndRequestCallPermissions() {
+ ArrayList permissionsList = new ArrayList<>();
+
+ // Some required permissions needs to be validated manually by the user
+ // Here we ask for record audio and camera to be able to make video calls with sound
+ // Once granted we don't have to ask them again, but if denied we can
+ int recordAudio =
+ getPackageManager()
+ .checkPermission(Manifest.permission.RECORD_AUDIO, getPackageName());
+ Log.i(
+ "[Permission] Record audio permission is "
+ + (recordAudio == PackageManager.PERMISSION_GRANTED
+ ? "granted"
+ : "denied"));
+ int camera =
+ getPackageManager().checkPermission(Manifest.permission.CAMERA, getPackageName());
+ Log.i(
+ "[Permission] Camera permission is "
+ + (camera == PackageManager.PERMISSION_GRANTED ? "granted" : "denied"));
+
+ if (recordAudio != PackageManager.PERMISSION_GRANTED) {
+ Log.i("[Permission] Asking for record audio");
+ permissionsList.add(Manifest.permission.RECORD_AUDIO);
+ }
+
+ if (camera != PackageManager.PERMISSION_GRANTED) {
+ Log.i("[Permission] Asking for camera");
+ permissionsList.add(Manifest.permission.CAMERA);
+ }
+
+ if (permissionsList.size() > 0) {
+ String[] permissions = new String[permissionsList.size()];
+ permissions = permissionsList.toArray(permissions);
+ ActivityCompat.requestPermissions(this, permissions, 0);
+ }
+ }
+}
diff --git a/sample/app/src/main/res/drawable/banner.png b/sample/app/src/main/res/drawable/banner.png
new file mode 100644
index 000000000..7d2ec10f4
Binary files /dev/null and b/sample/app/src/main/res/drawable/banner.png differ
diff --git a/sample/app/src/main/res/drawable/led_connected.png b/sample/app/src/main/res/drawable/led_connected.png
new file mode 100644
index 000000000..d0cc8fc84
Binary files /dev/null and b/sample/app/src/main/res/drawable/led_connected.png differ
diff --git a/sample/app/src/main/res/drawable/led_disconnected.png b/sample/app/src/main/res/drawable/led_disconnected.png
new file mode 100644
index 000000000..20c814333
Binary files /dev/null and b/sample/app/src/main/res/drawable/led_disconnected.png differ
diff --git a/sample/app/src/main/res/drawable/led_error.png b/sample/app/src/main/res/drawable/led_error.png
new file mode 100644
index 000000000..67418cc43
Binary files /dev/null and b/sample/app/src/main/res/drawable/led_error.png differ
diff --git a/sample/app/src/main/res/drawable/led_inprogress.png b/sample/app/src/main/res/drawable/led_inprogress.png
new file mode 100644
index 000000000..cf7263481
Binary files /dev/null and b/sample/app/src/main/res/drawable/led_inprogress.png differ
diff --git a/sample/app/src/main/res/layout/call.xml b/sample/app/src/main/res/layout/call.xml
new file mode 100644
index 000000000..1ab7d6c83
--- /dev/null
+++ b/sample/app/src/main/res/layout/call.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sample/app/src/main/res/layout/configure_account.xml b/sample/app/src/main/res/layout/configure_account.xml
new file mode 100644
index 000000000..6b9a232e7
--- /dev/null
+++ b/sample/app/src/main/res/layout/configure_account.xml
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sample/app/src/main/res/layout/launcher.xml b/sample/app/src/main/res/layout/launcher.xml
new file mode 100644
index 000000000..68605002e
--- /dev/null
+++ b/sample/app/src/main/res/layout/launcher.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sample/app/src/main/res/layout/main.xml b/sample/app/src/main/res/layout/main.xml
new file mode 100644
index 000000000..1e335a2d6
--- /dev/null
+++ b/sample/app/src/main/res/layout/main.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sample/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/sample/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 000000000..2119c642d
--- /dev/null
+++ b/sample/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/sample/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/sample/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 000000000..2119c642d
--- /dev/null
+++ b/sample/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/sample/app/src/main/res/mipmap-hdpi/ic_launcher.png b/sample/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 000000000..af7722189
Binary files /dev/null and b/sample/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/sample/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/sample/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
new file mode 100644
index 000000000..a0dc2e060
Binary files /dev/null and b/sample/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ
diff --git a/sample/app/src/main/res/mipmap-hdpi/linphone_launcher_icon_foreground.png b/sample/app/src/main/res/mipmap-hdpi/linphone_launcher_icon_foreground.png
new file mode 100644
index 000000000..bfe9d0bd0
Binary files /dev/null and b/sample/app/src/main/res/mipmap-hdpi/linphone_launcher_icon_foreground.png differ
diff --git a/sample/app/src/main/res/mipmap-mdpi/ic_launcher.png b/sample/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 000000000..4bf908cd7
Binary files /dev/null and b/sample/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/sample/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/sample/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
new file mode 100644
index 000000000..6822c177e
Binary files /dev/null and b/sample/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ
diff --git a/sample/app/src/main/res/mipmap-mdpi/linphone_launcher_icon_foreground.png b/sample/app/src/main/res/mipmap-mdpi/linphone_launcher_icon_foreground.png
new file mode 100644
index 000000000..645926eea
Binary files /dev/null and b/sample/app/src/main/res/mipmap-mdpi/linphone_launcher_icon_foreground.png differ
diff --git a/sample/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/sample/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 000000000..7e717e4d6
Binary files /dev/null and b/sample/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/sample/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/sample/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
new file mode 100644
index 000000000..af7199df7
Binary files /dev/null and b/sample/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ
diff --git a/sample/app/src/main/res/mipmap-xhdpi/linphone_launcher_icon_foreground.png b/sample/app/src/main/res/mipmap-xhdpi/linphone_launcher_icon_foreground.png
new file mode 100644
index 000000000..e6bc71240
Binary files /dev/null and b/sample/app/src/main/res/mipmap-xhdpi/linphone_launcher_icon_foreground.png differ
diff --git a/sample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/sample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 000000000..78b30bafa
Binary files /dev/null and b/sample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/sample/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/sample/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
new file mode 100644
index 000000000..62992b974
Binary files /dev/null and b/sample/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ
diff --git a/sample/app/src/main/res/mipmap-xxhdpi/linphone_launcher_icon_foreground.png b/sample/app/src/main/res/mipmap-xxhdpi/linphone_launcher_icon_foreground.png
new file mode 100644
index 000000000..8e9fc8ace
Binary files /dev/null and b/sample/app/src/main/res/mipmap-xxhdpi/linphone_launcher_icon_foreground.png differ
diff --git a/sample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/sample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 000000000..05c036329
Binary files /dev/null and b/sample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/sample/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/sample/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
new file mode 100644
index 000000000..e5f1eef82
Binary files /dev/null and b/sample/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ
diff --git a/sample/app/src/main/res/mipmap-xxxhdpi/linphone_launcher_icon_foreground.png b/sample/app/src/main/res/mipmap-xxxhdpi/linphone_launcher_icon_foreground.png
new file mode 100644
index 000000000..a04e29e28
Binary files /dev/null and b/sample/app/src/main/res/mipmap-xxxhdpi/linphone_launcher_icon_foreground.png differ
diff --git a/sample/app/src/main/res/raw/linphonerc_default b/sample/app/src/main/res/raw/linphonerc_default
new file mode 100644
index 000000000..df24fc818
--- /dev/null
+++ b/sample/app/src/main/res/raw/linphonerc_default
@@ -0,0 +1,20 @@
+[sip]
+contact="Linphone Android"
+use_info=0
+use_ipv6=1
+keepalive_period=30000
+sip_port=-1
+sip_tcp_port=-1
+sip_tls_port=-1
+media_encryption=none
+
+[video]
+size=vga
+
+[app]
+tunnel=disabled
+push_notification=1
+
+[misc]
+max_calls=10
+history_max_size=100
\ No newline at end of file
diff --git a/sample/app/src/main/res/raw/linphonerc_factory b/sample/app/src/main/res/raw/linphonerc_factory
new file mode 100644
index 000000000..06f7fec0f
--- /dev/null
+++ b/sample/app/src/main/res/raw/linphonerc_factory
@@ -0,0 +1,34 @@
+
+#
+#This file shall not contain path referencing package name, in order to be portable when app is renamed.
+#Paths to resources must be set from LinphoneManager, after creating LinphoneCore.
+[net]
+mtu=1300
+#Because dynamic bitrate adaption can increase bitrate, we must allow "no limit"
+download_bw=0
+upload_bw=0
+force_ice_disablement=0
+
+[sip]
+guess_hostname=1
+register_only_when_network_is_up=1
+auto_net_state_mon=1
+auto_answer_replacing_calls=1
+ping_with_options=0
+use_cpim=1
+
+[video]
+displaytype=MSAndroidTextureDisplay
+
+[misc]
+enable_basic_to_client_group_chat_room_migration=0
+enable_simple_group_chat_message_state=0
+aggregate_imdn=1
+notify_each_friend_individually_when_presence_received=0
+
+[app]
+activation_code_length=4
+prefer_basic_chat_room=1
+
+[assistant]
+xmlrpc_url=https://subscribe.linphone.org:444/wizard.php
\ No newline at end of file
diff --git a/sample/app/src/main/res/values/color.xml b/sample/app/src/main/res/values/color.xml
new file mode 100644
index 000000000..d9fad6796
--- /dev/null
+++ b/sample/app/src/main/res/values/color.xml
@@ -0,0 +1,5 @@
+
+
+ #ff5e00
+ #444444
+
\ No newline at end of file
diff --git a/sample/app/src/main/res/values/colors.xml b/sample/app/src/main/res/values/colors.xml
new file mode 100644
index 000000000..69b22338c
--- /dev/null
+++ b/sample/app/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+
+
+ #008577
+ #00574B
+ #D81B60
+
diff --git a/sample/app/src/main/res/values/strings.xml b/sample/app/src/main/res/values/strings.xml
new file mode 100644
index 000000000..4b33394e7
--- /dev/null
+++ b/sample/app/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ Linphone Sample
+
diff --git a/sample/app/src/main/res/values/styles.xml b/sample/app/src/main/res/values/styles.xml
new file mode 100644
index 000000000..b6183f666
--- /dev/null
+++ b/sample/app/src/main/res/values/styles.xml
@@ -0,0 +1,6 @@
+
+
+
+
diff --git a/sample/build.gradle b/sample/build.gradle
new file mode 100644
index 000000000..fafc1b970
--- /dev/null
+++ b/sample/build.gradle
@@ -0,0 +1,27 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ repositories {
+ google()
+ jcenter()
+
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:3.4.0'
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ google()
+ jcenter()
+
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/sample/gradle.properties b/sample/gradle.properties
new file mode 100644
index 000000000..199d16ede
--- /dev/null
+++ b/sample/gradle.properties
@@ -0,0 +1,20 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx1536m
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+# AndroidX package structure to make it clearer which packages are bundled with the
+# Android operating system, and which are packaged with your app's APK
+# https://developer.android.com/topic/libraries/support-library/androidx-rn
+android.useAndroidX=true
+# Automatically convert third-party libraries to use AndroidX
+android.enableJetifier=true
+
diff --git a/sample/gradle/wrapper/gradle-wrapper.jar b/sample/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 000000000..f6b961fd5
Binary files /dev/null and b/sample/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/sample/gradle/wrapper/gradle-wrapper.properties b/sample/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 000000000..eb67da204
--- /dev/null
+++ b/sample/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Sat May 04 08:50:48 CEST 2019
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
diff --git a/sample/gradlew b/sample/gradlew
new file mode 100755
index 000000000..cccdd3d51
--- /dev/null
+++ b/sample/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/sample/gradlew.bat b/sample/gradlew.bat
new file mode 100644
index 000000000..e95643d6a
--- /dev/null
+++ b/sample/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/sample/settings.gradle b/sample/settings.gradle
new file mode 100644
index 000000000..e7b4def49
--- /dev/null
+++ b/sample/settings.gradle
@@ -0,0 +1 @@
+include ':app'