Commit 91863c2f authored by Bob Easterday's avatar Bob Easterday
Browse files

Merge pull request #64 from rjmunro/feature/eliminate-get-tasks

Eliminate need for GET_TASKS permission
parents 585a84c6 9f6465dc
Loading
Loading
Loading
Loading
+0 −1
Changes for README.md: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -59,7 +59,6 @@ This plugin is for use with [Cordova](http://incubator.apache.org/cordova/), and

2) Modify your **AndroidManifest.xml** and add the following lines to your manifest tag:

			<uses-permission android:name="android.permission.GET_TASKS" />
			<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
			<uses-permission android:name="android.permission.GET_ACCOUNTS" />
			<uses-permission android:name="android.permission.WAKE_LOCK" />
+0 −1
Changes for plugin.xml: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@
		</config-file>

		<config-file target="AndroidManifest.xml" parent="/manifest">
			<uses-permission android:name="android.permission.GET_TASKS" />
			<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
			<uses-permission android:name="android.permission.GET_ACCOUNTS" />
			<uses-permission android:name="android.permission.WAKE_LOCK" />
+4 −18
Changes for src/android/com/plugin/gcm/GCMIntentService.java: 4 added lines, 18 removed lines.
Original line number Diff line number Diff line
@@ -67,16 +67,14 @@ public class GCMIntentService extends GCMBaseIntentService {
		Bundle extras = intent.getExtras();
		if (extras != null)
		{
			boolean	foreground = this.isInForeground();

			extras.putBoolean("foreground", foreground);

			if (foreground)
			PushPlugin.sendExtras(extras);
			else

			// Send a notification if there is a message
			if (extras.getString("message").length() != 0) {
				createNotification(context, extras);
			}
		}
	}

	public void createNotification(Context context, Bundle extras)
	{
@@ -129,18 +127,6 @@ public class GCMIntentService extends GCMBaseIntentService {
		return (String)appName;
	}
	
	public boolean isInForeground()
	{
		ActivityManager activityManager = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
		List<RunningTaskInfo> services = activityManager
				.getRunningTasks(Integer.MAX_VALUE);

		if (services.get(0).topActivity.getPackageName().toString().equalsIgnoreCase(getApplicationContext().getPackageName().toString()))
			return true;

		return false;
	}	

	@Override
	public void onError(Context context, String errorId) {
		Log.e(TAG, "onError - errorId: " + errorId);