summaryrefslogtreecommitdiff
path: root/pjsip-apps
diff options
context:
space:
mode:
authorRiza Sulistyo <riza@teluu.com>2013-04-24 04:55:00 +0000
committerRiza Sulistyo <riza@teluu.com>2013-04-24 04:55:00 +0000
commit27896c14e3d5edab41fca3f87c39221dd1a06668 (patch)
tree3e18544a25d5a8dfb919cb3732d5d64c5b4e2148 /pjsip-apps
parenteecacb732f39da108cbf3f0cd702d86ccc2caf4f (diff)
Re #1655: pjsua app CLI for android
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4496 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip-apps')
-rw-r--r--pjsip-apps/src/pjsua/android/.classpath8
-rw-r--r--pjsip-apps/src/pjsua/android/.project101
-rw-r--r--pjsip-apps/src/pjsua/android/AndroidManifest.xml45
-rw-r--r--pjsip-apps/src/pjsua/android/jni/Android.mk61
-rwxr-xr-xpjsip-apps/src/pjsua/android/jni/pjsua.i29
-rw-r--r--pjsip-apps/src/pjsua/android/jni/pjsua_app_callback.cpp113
-rw-r--r--pjsip-apps/src/pjsua/android/jni/pjsua_app_callback.h36
-rw-r--r--pjsip-apps/src/pjsua/android/lint.xml3
-rw-r--r--pjsip-apps/src/pjsua/android/proguard-project.txt20
-rw-r--r--pjsip-apps/src/pjsua/android/project.properties14
-rwxr-xr-xpjsip-apps/src/pjsua/android/res/drawable-hdpi/main_image.pngbin0 -> 8269 bytes
-rwxr-xr-xpjsip-apps/src/pjsua/android/res/drawable-ldpi/main_image.pngbin0 -> 3863 bytes
-rwxr-xr-xpjsip-apps/src/pjsua/android/res/drawable-mdpi/main_image.pngbin0 -> 5059 bytes
-rwxr-xr-xpjsip-apps/src/pjsua/android/res/drawable-xhdpi/main_image.pngbin0 -> 12058 bytes
-rw-r--r--pjsip-apps/src/pjsua/android/res/layout/activity_main.xml34
-rw-r--r--pjsip-apps/src/pjsua/android/res/values-v11/styles.xml5
-rw-r--r--pjsip-apps/src/pjsua/android/res/values-v14/styles.xml5
-rw-r--r--pjsip-apps/src/pjsua/android/res/values/strings.xml6
-rw-r--r--pjsip-apps/src/pjsua/android/res/values/styles.xml5
-rw-r--r--pjsip-apps/src/pjsua/android/src/org/pjsip/pjsua/MainActivity.java242
20 files changed, 727 insertions, 0 deletions
diff --git a/pjsip-apps/src/pjsua/android/.classpath b/pjsip-apps/src/pjsua/android/.classpath
new file mode 100644
index 00000000..3f9691c5
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
diff --git a/pjsip-apps/src/pjsua/android/.project b/pjsip-apps/src/pjsua/android/.project
new file mode 100644
index 00000000..ec83832d
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/.project
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>pjsua</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ <dictionary>
+ <key>?name?</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.append_environment</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.autoBuildTarget</key>
+ <value>all</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildArguments</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildCommand</key>
+ <value>make</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
+ <value>clean</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.contents</key>
+ <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+ <value>false</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableFullBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.fullBuildTarget</key>
+ <value>all</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.stopOnError</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+ <value>true</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ </natures>
+</projectDescription>
diff --git a/pjsip-apps/src/pjsua/android/AndroidManifest.xml b/pjsip-apps/src/pjsua/android/AndroidManifest.xml
new file mode 100644
index 00000000..e5a0088a
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/AndroidManifest.xml
@@ -0,0 +1,45 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.pjsip.pjsua"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="15"
+ android:targetSdkVersion="15" />
+
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
+ <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
+ <uses-permission android:name="android.permission.WRITE_SETTINGS" />
+ <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
+ <uses-permission android:name="android.permission.VIBRATE" />
+ <uses-permission android:name="android.permission.READ_LOGS" />
+ <uses-permission android:name="android.permission.USE_SIP" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.CAMERA" />
+
+ <uses-feature
+ android:name="android.hardware.microphone"
+ android:required="true" />
+
+ <application
+ android:icon="@drawable/main_image"
+ android:label="@string/app_name"
+ android:theme="@android:style/Theme.DeviceDefault.NoActionBar" >
+ <activity
+ android:name=".MainActivity"
+ android:windowSoftInputMode="stateHidden"
+ android:label="@string/app_name" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest> \ No newline at end of file
diff --git a/pjsip-apps/src/pjsua/android/jni/Android.mk b/pjsip-apps/src/pjsua/android/jni/Android.mk
new file mode 100644
index 00000000..bcbdbbd6
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/jni/Android.mk
@@ -0,0 +1,61 @@
+# $id$
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+# Get PJ build settings
+include ../../../../build.mak
+include $(PJDIR)/build/common.mak
+
+# Path to SWIG
+MY_SWIG := swig
+
+#========================================================================
+# Choose console application to load
+#========================================================================
+
+# pjlib test
+#MY_MODULE := $(PJDIR)/pjlib/build/output/pjlib-test-$(TARGET_NAME)/*.o
+
+# pjlib-util test
+#MY_MODULE := $(PJDIR)/pjlib-util/build/output/pjlib-util-test-$(TARGET_NAME)/*.o
+
+# pjsip test
+#MY_MODULE := $(PJDIR)/pjsip/build/output/pjsip-test-$(TARGET_NAME)/*.o
+
+# pjnath test
+#MY_MODULE := $(PJDIR)/pjnath/build/output/pjnath-test-$(TARGET_NAME)/*.o
+
+# pjmedia test
+# Note: jbuf test requires Jbtest.dat, this jbuf test must be disabled (for now).
+#MY_MODULE := $(PJDIR)/pjmedia/build/output/pjmedia-test-$(TARGET_NAME)/*.o
+
+# pjsystest app (not supported yet)
+# Todo: this test requires some input and output files (log & WAV).
+#MY_MODULE := $(PJDIR)/pjsip-apps/build/output/pjsystest-$(TARGET_NAME)/*.o
+
+# pjsua app
+# Note: must set USE_GUI to zero in config_site.h
+MY_MODULE := $(PJDIR)/pjsip-apps/build/output/pjsua-$(TARGET_NAME)/*.o
+
+#========================================================================
+
+# Constants
+MY_JNI_WRAP := pjsua_wrap.cpp
+MY_JNI_DIR := jni
+
+# Android build settings
+LOCAL_MODULE := libpjsua
+LOCAL_CFLAGS := -Werror $(APP_CFLAGS) -frtti
+LOCAL_LDFLAGS := $(APP_LDFLAGS)
+LOCAL_LDLIBS := $(MY_MODULE) $(APP_LDLIBS)
+LOCAL_SRC_FILES := $(MY_JNI_WRAP) pjsua_app_callback.cpp
+
+# Invoke SWIG
+$(MY_JNI_DIR)/$(MY_JNI_WRAP):
+ @echo "Invoking SWIG..."
+ $(MY_SWIG) -c++ -o $(MY_JNI_DIR)/$(MY_JNI_WRAP) -package org.pjsip.pjsua -outdir src/org/pjsip/pjsua -java $(MY_JNI_DIR)/pjsua.i
+
+.PHONY: $(MY_JNI_DIR)/$(MY_JNI_WRAP)
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/pjsip-apps/src/pjsua/android/jni/pjsua.i b/pjsip-apps/src/pjsua/android/jni/pjsua.i
new file mode 100755
index 00000000..99443160
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/jni/pjsua.i
@@ -0,0 +1,29 @@
+%module (directors="1") pjsua
+
+%{
+#include "pjsua_app_callback.h"
+#include "../../pjsua_app.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ int pjsuaStart();
+ void pjsuaDestroy();
+ int pjsuaRestart();
+ void setCallbackObject(PjsuaAppCallback* callback);
+#ifdef __cplusplus
+}
+#endif
+%}
+
+int pjsuaStart();
+void pjsuaDestroy();
+int pjsuaRestart();
+
+/* turn on director wrapping PjsuaAppCallback */
+%feature("director") PjsuaAppCallback;
+
+%include "pjsua_app_callback.h"
+
+void setCallbackObject(PjsuaAppCallback* callback);
+
diff --git a/pjsip-apps/src/pjsua/android/jni/pjsua_app_callback.cpp b/pjsip-apps/src/pjsua/android/jni/pjsua_app_callback.cpp
new file mode 100644
index 00000000..6268b55e
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/jni/pjsua_app_callback.cpp
@@ -0,0 +1,113 @@
+/* $Id: pjsua_app_callback.cpp $ */
+/*
+ * Copyright (C) 2012-2012 Teluu Inc. (http://www.teluu.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "pjsua_app_callback.h"
+#include "../../pjsua_app.h"
+#include "../../pjsua_app_config.h"
+
+#if defined(PJ_ANDROID) && PJ_ANDROID != 0
+
+static PjsuaAppCallback* registeredCallbackObject = NULL;
+static pjsua_app_cfg_t android_app_config;
+static int restart_argc;
+static char **restart_argv;
+
+extern const char *pjsua_app_def_argv[];
+
+#define THIS_FILE "pjsua_app_callback.cpp"
+
+/** Callback wrapper **/
+void on_cli_started(pj_status_t status, const char *msg)
+{
+ char errmsg[PJ_ERR_MSG_SIZE];
+ if (registeredCallbackObject) {
+ if ((status != PJ_SUCCESS) && (!msg || !*msg)) {
+ pj_strerror(status, errmsg, sizeof(errmsg));
+ msg = errmsg;
+ }
+ registeredCallbackObject->onStarted(msg);
+ }
+}
+
+void on_cli_stopped(pj_bool_t restart, int argc, char **argv)
+{
+ if (restart) {
+ restart_argc = argc;
+ restart_argv = argv;
+ }
+
+ if (registeredCallbackObject) {
+ registeredCallbackObject->onStopped(restart);
+ }
+}
+
+static int initMain(int argc, char **argv)
+{
+ pj_status_t status;
+ android_app_config.argc = argc;
+ android_app_config.argv = argv;
+
+ status = pjsua_app_init(&android_app_config);
+ if (status == PJ_SUCCESS) {
+ status = pjsua_app_run(PJ_FALSE);
+ } else {
+ pjsua_app_destroy();
+ }
+
+ return status;
+}
+
+int pjsuaStart()
+{
+ pj_status_t status;
+
+ const char **argv = pjsua_app_def_argv;
+ int argc = pjsua_app_def_argc;
+
+ pj_bzero(&android_app_config, sizeof(android_app_config));
+
+ android_app_config.on_started = &on_cli_started;
+ android_app_config.on_stopped = &on_cli_stopped;
+
+ return initMain(argc, (char**)argv);
+}
+
+void pjsuaDestroy()
+{
+ pjsua_app_destroy();
+
+ /** This is on purpose **/
+ pjsua_app_destroy();
+}
+
+int pjsuaRestart()
+{
+ pj_status_t status;
+
+ pjsuaDestroy();
+
+ return initMain(restart_argc, restart_argv);
+}
+
+void setCallbackObject(PjsuaAppCallback* callback)
+{
+ registeredCallbackObject = callback;
+}
+
+#endif
diff --git a/pjsip-apps/src/pjsua/android/jni/pjsua_app_callback.h b/pjsip-apps/src/pjsua/android/jni/pjsua_app_callback.h
new file mode 100644
index 00000000..561b5ce3
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/jni/pjsua_app_callback.h
@@ -0,0 +1,36 @@
+/* $Id: pjsua_app_callback.h $ */
+/*
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef __PJSUA_APP_CALLBACK_H__
+#define __PJSUA_APP_CALLBACK_H__
+
+class PjsuaAppCallback {
+public:
+ virtual ~PjsuaAppCallback() {}
+ virtual void onStarted(const char *msg) {}
+ virtual void onStopped(int restart) {}
+};
+
+extern "C" {
+int pjsuaStart();
+void pjsuaDestroy();
+int pjsuaRestart();
+void setCallbackObject(PjsuaAppCallback* callback);
+}
+
+#endif /* __PJSUA_APP_CALLBACK_H__ */
diff --git a/pjsip-apps/src/pjsua/android/lint.xml b/pjsip-apps/src/pjsua/android/lint.xml
new file mode 100644
index 00000000..ee0eead5
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/lint.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lint>
+</lint> \ No newline at end of file
diff --git a/pjsip-apps/src/pjsua/android/proguard-project.txt b/pjsip-apps/src/pjsua/android/proguard-project.txt
new file mode 100644
index 00000000..f2fe1559
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# 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 *;
+#}
diff --git a/pjsip-apps/src/pjsua/android/project.properties b/pjsip-apps/src/pjsua/android/project.properties
new file mode 100644
index 00000000..9b84a6b4
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/project.properties
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-16
diff --git a/pjsip-apps/src/pjsua/android/res/drawable-hdpi/main_image.png b/pjsip-apps/src/pjsua/android/res/drawable-hdpi/main_image.png
new file mode 100755
index 00000000..a9c5328c
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/res/drawable-hdpi/main_image.png
Binary files differ
diff --git a/pjsip-apps/src/pjsua/android/res/drawable-ldpi/main_image.png b/pjsip-apps/src/pjsua/android/res/drawable-ldpi/main_image.png
new file mode 100755
index 00000000..969971f8
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/res/drawable-ldpi/main_image.png
Binary files differ
diff --git a/pjsip-apps/src/pjsua/android/res/drawable-mdpi/main_image.png b/pjsip-apps/src/pjsua/android/res/drawable-mdpi/main_image.png
new file mode 100755
index 00000000..8312fcf2
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/res/drawable-mdpi/main_image.png
Binary files differ
diff --git a/pjsip-apps/src/pjsua/android/res/drawable-xhdpi/main_image.png b/pjsip-apps/src/pjsua/android/res/drawable-xhdpi/main_image.png
new file mode 100755
index 00000000..9978b0af
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/res/drawable-xhdpi/main_image.png
Binary files differ
diff --git a/pjsip-apps/src/pjsua/android/res/layout/activity_main.xml b/pjsip-apps/src/pjsua/android/res/layout/activity_main.xml
new file mode 100644
index 00000000..da258b76
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/res/layout/activity_main.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical" >
+
+ <ImageView
+ android:id="@+id/imageApp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_above="@+id/textApp"
+ android:layout_centerHorizontal="true"
+ android:contentDescription="@string/app_name"
+ android:src="@drawable/main_image" />
+
+ <TextView
+ android:id="@+id/textApp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerHorizontal="true"
+ android:layout_centerVertical="true"
+ android:text="@string/app_name"
+ android:textSize="40sp"
+ android:typeface="serif" />
+
+ <TextView
+ android:id="@+id/textStatus"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_centerHorizontal="true"
+ android:textIsSelectable="false"/>
+
+</RelativeLayout> \ No newline at end of file
diff --git a/pjsip-apps/src/pjsua/android/res/values-v11/styles.xml b/pjsip-apps/src/pjsua/android/res/values-v11/styles.xml
new file mode 100644
index 00000000..d408cbc3
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/res/values-v11/styles.xml
@@ -0,0 +1,5 @@
+<resources>
+
+ <style name="AppTheme" parent="android:Theme.Holo.Light" />
+
+</resources> \ No newline at end of file
diff --git a/pjsip-apps/src/pjsua/android/res/values-v14/styles.xml b/pjsip-apps/src/pjsua/android/res/values-v14/styles.xml
new file mode 100644
index 00000000..1c089a78
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/res/values-v14/styles.xml
@@ -0,0 +1,5 @@
+<resources>
+
+ <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar" />
+
+</resources> \ No newline at end of file
diff --git a/pjsip-apps/src/pjsua/android/res/values/strings.xml b/pjsip-apps/src/pjsua/android/res/values/strings.xml
new file mode 100644
index 00000000..dd5ee690
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/res/values/strings.xml
@@ -0,0 +1,6 @@
+<resources>
+
+ <string name="app_name">pjsua</string>
+ <string name="title_activity_main">MainActivity</string>
+
+</resources> \ No newline at end of file
diff --git a/pjsip-apps/src/pjsua/android/res/values/styles.xml b/pjsip-apps/src/pjsua/android/res/values/styles.xml
new file mode 100644
index 00000000..4dba0d0a
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/res/values/styles.xml
@@ -0,0 +1,5 @@
+<resources>
+
+ <style name="AppTheme" parent="android:Theme.Light" />
+
+</resources> \ No newline at end of file
diff --git a/pjsip-apps/src/pjsua/android/src/org/pjsip/pjsua/MainActivity.java b/pjsip-apps/src/pjsua/android/src/org/pjsip/pjsua/MainActivity.java
new file mode 100644
index 00000000..aa0f9876
--- /dev/null
+++ b/pjsip-apps/src/pjsua/android/src/org/pjsip/pjsua/MainActivity.java
@@ -0,0 +1,242 @@
+/* $Id: MainActivity.java $ */
+/*
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package org.pjsip.pjsua;
+
+import java.lang.ref.WeakReference;
+
+import android.app.Activity;
+import android.content.pm.ApplicationInfo;
+import android.os.Bundle;
+import android.util.Log;
+import android.os.Handler;
+import android.os.Message;
+import android.widget.TextView;
+
+class CONST {
+ public static final String LIB_FILENAME = "pjsua";
+ public static final String TAG = "pjsua";
+ public static final Boolean AUTOKILL_ON_FINISH = true;
+ public enum MSG_TYPE {
+ STR_DEBUG,
+ STR_INFO,
+ STR_ERROR,
+ CLI_STOP,
+ CLI_RESTART,
+ QUIT
+ };
+}
+
+class LOG {
+ public static void DEBUG(Handler h, String str) {
+ Message msg = Message.obtain(h, CONST.MSG_TYPE.STR_DEBUG.ordinal(),
+ str);
+ msg.sendToTarget();
+ }
+ public static void INFO(Handler h, String str) {
+ Message msg = Message.obtain(h, CONST.MSG_TYPE.STR_INFO.ordinal(),
+ str);
+ msg.sendToTarget();
+ }
+ public static void ERROR(Handler h, String str) {
+ Message msg = Message.obtain(h, CONST.MSG_TYPE.STR_ERROR.ordinal(),
+ str);
+ msg.sendToTarget();
+ }
+}
+
+public class MainActivity extends Activity {
+ private MyHandler ui_handler = new MyHandler(this);
+ private static MyCallback callback;
+
+ private static class MyHandler extends Handler {
+ private final WeakReference<MainActivity> mTarget;
+
+ public MyHandler(MainActivity target) {
+ mTarget = new WeakReference<MainActivity>(target);
+ }
+
+ @Override
+ public void handleMessage(Message m) {
+ MainActivity target = mTarget.get();
+ if (target == null)
+ return;
+
+ if (m.what == CONST.MSG_TYPE.STR_DEBUG.ordinal()) {
+ Log.d(CONST.TAG, (String)m.obj);
+ } else if (m.what == CONST.MSG_TYPE.STR_INFO.ordinal()) {
+ target.updateStatus((String)m.obj);
+ Log.i(CONST.TAG, (String)m.obj);
+ } else if (m.what == CONST.MSG_TYPE.STR_ERROR.ordinal()) {
+ target.updateStatus((String)m.obj);
+ Log.e(CONST.TAG, (String)m.obj);
+ } else if (m.what == CONST.MSG_TYPE.CLI_STOP.ordinal()) {
+ pjsua.pjsuaDestroy();
+ LOG.INFO(this, "Telnet Unavailable");
+ } else if (m.what == CONST.MSG_TYPE.CLI_RESTART.ordinal()) {
+ int status = pjsua.pjsuaRestart();
+ if (status != 0) {
+ LOG.INFO(this, "Failed restarting telnet");
+ }
+ } else if (m.what == CONST.MSG_TYPE.QUIT.ordinal()) {
+ target.finish();
+ System.gc();
+ android.os.Process.killProcess(android.os.Process.myPid());
+ }
+ }
+ }
+
+ /** Callback object **/
+ private static class MyCallback extends PjsuaAppCallback {
+ private WeakReference<Handler> ui_handler;
+
+ public MyCallback(Handler in_ui_handler) {
+ set_ui_handler(in_ui_handler);
+ }
+
+ public void set_ui_handler(Handler in_ui_handler) {
+ ui_handler = new WeakReference<Handler>(in_ui_handler);
+ }
+
+ @Override
+ public void onStarted(String msg) {
+ Handler ui = ui_handler.get();
+ LOG.INFO(ui, msg);
+ }
+
+ @Override
+ public void onStopped(int restart) {
+ Handler ui = ui_handler.get();
+ /** Use timer to stopped/restart **/
+ if (restart != 0) {
+ LOG.INFO(ui, "Telnet Restarting");
+ Message msg = Message.obtain(ui,
+ CONST.MSG_TYPE.CLI_RESTART.ordinal());
+ ui.sendMessageDelayed(msg, 100);
+ } else {
+ LOG.INFO(ui, "Telnet Stopping");
+ Message msg = Message.obtain(ui,
+ CONST.MSG_TYPE.CLI_STOP.ordinal());
+ ui.sendMessageDelayed(msg, 100);
+ }
+ }
+ }
+
+ private void updateStatus(String output) {
+ TextView tStatus = (TextView) findViewById(R.id.textStatus);
+ tStatus.setText(output);
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ LOG.DEBUG(ui_handler, "=== Activity::onCreate() ===");
+ super.onCreate(savedInstanceState);
+
+ init_view();
+
+ init_lib();
+ }
+
+ @Override
+ protected void onStart() {
+ LOG.DEBUG(ui_handler, "=== Activity::onStart() ===");
+ super.onStart();
+ }
+
+ @Override
+ protected void onRestart() {
+ LOG.DEBUG(ui_handler, "=== Activity::onRestart() ===");
+ super.onRestart();
+ }
+
+ @Override
+ protected void onResume() {
+ LOG.DEBUG(ui_handler, "=== Activity::onResume() ===");
+ super.onResume();
+ }
+
+ @Override
+ protected void onPause() {
+ LOG.DEBUG(ui_handler, "=== Activity::onPause() ===");
+ super.onPause();
+ }
+
+ @Override
+ protected void onStop() {
+ LOG.DEBUG(ui_handler, "=== Activity::onStop() ===");
+ super.onStop();
+ }
+
+ @Override
+ protected void onDestroy() {
+ LOG.DEBUG(ui_handler, "=== Activity::onDestroy() ===");
+ super.onDestroy();
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onRestoreInstanceState(Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
+ }
+
+ private void init_view() {
+ setContentView(R.layout.activity_main);
+ }
+
+ private int init_lib() {
+ LOG.INFO(ui_handler, "Loading module...");
+ try {
+ System.loadLibrary(CONST.LIB_FILENAME);
+ } catch (UnsatisfiedLinkError e) {
+ LOG.ERROR(ui_handler, "UnsatisfiedLinkError: " + e.getMessage());
+ return -1;
+ }
+
+ // Wait for GDB to init
+ if ((getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0)
+ {
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ LOG.ERROR(ui_handler, "InterruptedException: " +
+ e.getMessage());
+ }
+ }
+
+ // Set callback object
+ if (callback == null)
+ callback = new MyCallback(ui_handler);
+
+ pjsua.setCallbackObject(callback);
+
+ LOG.INFO(ui_handler, "Starting module..");
+
+ int rc = pjsua.pjsuaStart();
+
+ if (rc != 0) {
+ LOG.INFO(ui_handler, "Failed starting telnet");
+ }
+
+ return 0;
+ }
+}