Feature/sample app
13
sample/.gitignore
vendored
Normal file
|
@ -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
|
1
sample/app/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/build
|
36
sample/app/build.gradle
Normal file
|
@ -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+"
|
||||
}
|
21
sample/app/proguard-rules.pro
vendored
Normal file
|
@ -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
|
49
sample/app/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,49 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.linphone.sample">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:label="@string/app_name"
|
||||
android:banner="@drawable/banner"
|
||||
android:theme="@style/AppTheme">
|
||||
|
||||
<activity
|
||||
android:name=".LauncherActivity"
|
||||
android:noHistory="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:theme="@style/AppTheme" />
|
||||
|
||||
<activity
|
||||
android:name=".ConfigureAccountActivity"
|
||||
android:theme="@style/AppTheme" />
|
||||
|
||||
<activity
|
||||
android:name=".CallActivity"
|
||||
android:noHistory="true"
|
||||
android:launchMode="singleTop"
|
||||
android:supportsPictureInPicture="true"
|
||||
android:resizeableActivity="true"
|
||||
android:theme="@style/AppTheme" />
|
||||
|
||||
<service
|
||||
android:name=".LinphoneService"
|
||||
android:label="@string/app_name" />
|
||||
|
||||
</application>
|
||||
</manifest>
|
149
sample/app/src/main/java/org/linphone/sample/CallActivity.java
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
152
sample/app/src/main/java/org/linphone/sample/MainActivity.java
Normal file
|
@ -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<String> 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);
|
||||
}
|
||||
}
|
||||
}
|
BIN
sample/app/src/main/res/drawable/banner.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
sample/app/src/main/res/drawable/led_connected.png
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
sample/app/src/main/res/drawable/led_disconnected.png
Normal file
After Width: | Height: | Size: 904 B |
BIN
sample/app/src/main/res/drawable/led_error.png
Normal file
After Width: | Height: | Size: 840 B |
BIN
sample/app/src/main/res/drawable/led_inprogress.png
Normal file
After Width: | Height: | Size: 952 B |
19
sample/app/src/main/res/layout/call.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/background">
|
||||
|
||||
<TextureView
|
||||
android:id="@+id/videoSurface"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<TextureView
|
||||
android:id="@+id/videoCaptureSurface"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentBottom="true" />
|
||||
|
||||
</RelativeLayout>
|
71
sample/app/src/main/res/layout/configure_account.xml
Normal file
|
@ -0,0 +1,71 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/background">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/username"
|
||||
android:hint="Username"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/password"
|
||||
android:hint="Password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/domain"
|
||||
android:hint="Domain"
|
||||
android:text="sip.linphone.org"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/assistant_transports"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/transport_udp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:text="UDP" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/transport_tcp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:text="TCP" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/transport_tls"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:checked="true"
|
||||
android:text="TLS" />
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
<Button
|
||||
android:id="@+id/configure"
|
||||
android:text="Connect"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
21
sample/app/src/main/res/layout/launcher.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/background">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/banner"/>
|
||||
|
||||
<ProgressBar
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="50dp"
|
||||
android:indeterminate="true"/>
|
||||
|
||||
</RelativeLayout>
|
22
sample/app/src/main/res/layout/main.xml
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/background">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/led"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:src="@drawable/led_disconnected"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/banner"/>
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/primary" />
|
||||
<foreground android:drawable="@mipmap/linphone_launcher_icon_foreground" />
|
||||
</adaptive-icon>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/primary" />
|
||||
<foreground android:drawable="@mipmap/linphone_launcher_icon_foreground" />
|
||||
</adaptive-icon>
|
BIN
sample/app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
sample/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 1.8 KiB |
BIN
sample/app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
sample/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.2 KiB |
BIN
sample/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
sample/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 2.5 KiB |
BIN
sample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
sample/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 3.8 KiB |
BIN
sample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
sample/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 5.3 KiB |
20
sample/app/src/main/res/raw/linphonerc_default
Normal file
|
@ -0,0 +1,20 @@
|
|||
[sip]
|
||||
contact="Linphone Android" <sip:linphone.android@unknown-host>
|
||||
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
|
34
sample/app/src/main/res/raw/linphonerc_factory
Normal file
|
@ -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
|
5
sample/app/src/main/res/values/color.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="primary">#ff5e00</color>
|
||||
<color name="background">#444444</color>
|
||||
</resources>
|
6
sample/app/src/main/res/values/colors.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#008577</color>
|
||||
<color name="colorPrimaryDark">#00574B</color>
|
||||
<color name="colorAccent">#D81B60</color>
|
||||
</resources>
|
3
sample/app/src/main/res/values/strings.xml
Normal file
|
@ -0,0 +1,3 @@
|
|||
<resources>
|
||||
<string name="app_name">Linphone Sample</string>
|
||||
</resources>
|
6
sample/app/src/main/res/values/styles.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="AppTheme" parent="@style/Theme.AppCompat">
|
||||
<item name="android:colorPrimary">@color/primary</item>
|
||||
</style>
|
||||
</resources>
|
27
sample/build.gradle
Normal file
|
@ -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
|
||||
}
|
20
sample/gradle.properties
Normal file
|
@ -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
|
||||
|
BIN
sample/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
sample/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -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
|
172
sample/gradlew
vendored
Executable file
|
@ -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" "$@"
|
84
sample/gradlew.bat
vendored
Normal file
|
@ -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
|
1
sample/settings.gradle
Normal file
|
@ -0,0 +1 @@
|
|||
include ':app'
|