SDL: CreateService=y will create a persistent notification, so app is never killed
This commit is contained in:
@@ -6,13 +6,16 @@ JAVA_SRC_PATH=project/java
|
||||
|
||||
if [ "X$1" = "X-a" ]; then
|
||||
AUTO=a
|
||||
shift
|
||||
fi
|
||||
if [ "X$1" = "X-v" ]; then
|
||||
AUTO=v
|
||||
shift
|
||||
fi
|
||||
if [ "X$1" = "X-u" ]; then
|
||||
CHANGED=1
|
||||
AUTO=a
|
||||
shift
|
||||
fi
|
||||
if [ "X$1" = "X-h" ]; then
|
||||
echo "Usage: $0 [-a] [-v] [-u]"
|
||||
@@ -22,6 +25,25 @@ if [ "X$1" = "X-h" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$#" -gt 0 ]; then
|
||||
echo "Switching build target to $1"
|
||||
if [ -e project/jni/application/$1 ]; then
|
||||
rm -f project/jni/application/src
|
||||
ln -s "$1" project/jni/application/src
|
||||
else
|
||||
echo "Error: no app $1 under project/jni/application"
|
||||
echo "Available applications:"
|
||||
cd project/jni/application
|
||||
for f in *; do
|
||||
if [ -e "$f/AndroidAppSettings.cfg" ]; then
|
||||
echo "$f"
|
||||
fi
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
fi
|
||||
|
||||
. ./AndroidAppSettings.cfg
|
||||
|
||||
var=""
|
||||
|
||||
@@ -38,6 +38,10 @@
|
||||
android:windowSoftInputMode="stateUnspecified"
|
||||
android:process=":RestartMainActivity"
|
||||
/>
|
||||
<service android:name=".DummyService"
|
||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection"
|
||||
android:enabled="true"
|
||||
/>
|
||||
</application>
|
||||
|
||||
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="23"/>
|
||||
|
||||
137
project/java/DummyService.java
Normal file
137
project/java/DummyService.java
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2014 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.EditText;
|
||||
import android.text.Editable;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.FrameLayout;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.Color;
|
||||
import android.content.res.Configuration;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Intent;
|
||||
import android.view.View.OnKeyListener;
|
||||
import android.view.MenuItem;
|
||||
import android.view.Menu;
|
||||
import android.view.Gravity;
|
||||
import android.text.method.TextKeyListener;
|
||||
import java.util.LinkedList;
|
||||
import java.io.SequenceInputStream;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.CheckedInputStream;
|
||||
import java.util.zip.CRC32;
|
||||
import java.util.Set;
|
||||
import android.text.SpannedString;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.view.Display;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.text.InputType;
|
||||
import android.util.Log;
|
||||
import android.view.Surface;
|
||||
import android.app.ProgressDialog;
|
||||
import android.app.KeyguardManager;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.graphics.Rect;
|
||||
import android.view.InputDevice;
|
||||
import android.inputmethodservice.KeyboardView;
|
||||
import android.inputmethodservice.Keyboard;
|
||||
import android.app.Notification;
|
||||
import android.app.PendingIntent;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
public class DummyService extends Service
|
||||
{
|
||||
public DummyService()
|
||||
{
|
||||
super();
|
||||
}
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId)
|
||||
{
|
||||
if (intent != null && Intent.ACTION_DELETE.equals(intent.getAction()))
|
||||
{
|
||||
Log.v("SDL", "User dismissed notification, killing myself");
|
||||
System.exit(0);
|
||||
}
|
||||
Log.v("SDL", "Starting dummy service - displaying notification");
|
||||
Notification ntf = new Notification();
|
||||
ntf.icon = R.drawable.icon;
|
||||
ntf.flags |= Notification.FLAG_NO_CLEAR;
|
||||
PendingIntent killIntent = PendingIntent.getService(this, 5, new Intent(Intent.ACTION_DELETE, null, this, DummyService.class), PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
PendingIntent showIntent = PendingIntent.getActivity(this, 0, new Intent("", null, this, MainActivity.class), PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
ntf.deleteIntent = killIntent;
|
||||
ntf.tickerText = getString(getApplicationInfo().labelRes);
|
||||
RemoteViews view = new RemoteViews(getPackageName(), R.layout.notification);
|
||||
view.setCharSequence(R.id.notificationText, "setText", getString(R.string.notification_app_is_running, getString(getApplicationInfo().labelRes)));
|
||||
view.setOnClickPendingIntent(R.id.notificationText, showIntent);
|
||||
view.setOnClickPendingIntent(R.id.notificationIcon, showIntent);
|
||||
view.setOnClickPendingIntent(R.id.notificationView, showIntent);
|
||||
view.setOnClickPendingIntent(R.id.notificationStop, killIntent);
|
||||
ntf.contentView = view;
|
||||
startForeground(1, ntf);
|
||||
return Service.START_STICKY;
|
||||
}
|
||||
@Override
|
||||
public void onDestroy()
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public IBinder onBind(Intent intent)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -89,6 +89,8 @@ import android.graphics.Rect;
|
||||
import android.view.InputDevice;
|
||||
import android.inputmethodservice.KeyboardView;
|
||||
import android.inputmethodservice.Keyboard;
|
||||
import android.app.Notification;
|
||||
import android.app.PendingIntent;
|
||||
|
||||
public class MainActivity extends Activity
|
||||
{
|
||||
@@ -226,6 +228,7 @@ public class MainActivity extends Activity
|
||||
(new Thread(new Callback(this))).start();
|
||||
if( Globals.CreateService )
|
||||
{
|
||||
Log.v("SDL", "Starting dummy service - displaying notification");
|
||||
Intent intent = new Intent(this, DummyService.class);
|
||||
startService(intent);
|
||||
}
|
||||
@@ -1485,25 +1488,3 @@ abstract class SetLayerType
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DummyService extends Service
|
||||
{
|
||||
public DummyService()
|
||||
{
|
||||
super();
|
||||
}
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId)
|
||||
{
|
||||
return Service.START_STICKY;
|
||||
}
|
||||
@Override
|
||||
public void onDestroy()
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public IBinder onBind(Intent intent)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,4 +199,7 @@
|
||||
|
||||
<string name="restarting_please_wait">Restarting, please wait.</string>
|
||||
|
||||
<string name="notification_app_is_running">%s is running</string>
|
||||
<string name="notification_stop">Stop</string>
|
||||
|
||||
</resources>
|
||||
|
||||
Submodule project/jni/application/commandergenius/commandergenius updated: 29d9fe23e2...32b2e006f9
Submodule project/jni/application/hid-pc-keyboard/src updated: 5d839bd53d...470f8b02ca
Submodule project/jni/boost/src updated: 5824acb451...bc9ea9d303
Submodule project/jni/icuuc/src updated: a63fa87d2e...a6a6531070
Submodule project/jni/shmem updated: c2a28f528d...f6b49516cf
53
project/res/layout/notification.xml
Normal file
53
project/res/layout/notification.xml
Normal file
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:id="@+id/notificationView"
|
||||
android:clickable="true"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:id="@+id/notificationIcon"
|
||||
android:gravity="center_vertical"
|
||||
android:src="@drawable/icon"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:clickable="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:adjustViewBounds="true"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_toRightOf="@id/notificationIcon"
|
||||
android:id="@+id/notificationText"
|
||||
android:text="App is running"
|
||||
android:textColor="@android:color/primary_text_light"
|
||||
android:gravity="center_vertical"
|
||||
android:clickable="true"
|
||||
android:paddingLeft="10dp"
|
||||
/>
|
||||
|
||||
<!--
|
||||
android:textAppearance="@android:style/TextAppearance.StatusBar.EventContent.Title"
|
||||
-->
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:id="@+id/notificationStop"
|
||||
android:text="@string/notification_stop"
|
||||
android:gravity="center_vertical"
|
||||
android:singleLine="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:textAlignment="center"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
Reference in New Issue
Block a user