From aa95b3230d1847f4eca6ae568c59bc83df62519a Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 16 Aug 2014 11:18:23 +0200 Subject: [PATCH] Move check for update intent to update service Refs #1867 --- AndroidManifest.xml | 2 +- src/biz/bokhorst/xprivacy/ActivityShare.java | 11 +---------- src/biz/bokhorst/xprivacy/UpdateService.java | 19 ++++++++++++++----- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index e096017cc..cd6d8db24 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -149,7 +149,6 @@ - @@ -191,6 +190,7 @@ android:process=":update" > + diff --git a/src/biz/bokhorst/xprivacy/ActivityShare.java b/src/biz/bokhorst/xprivacy/ActivityShare.java index 1205aa22a..b265e5531 100644 --- a/src/biz/bokhorst/xprivacy/ActivityShare.java +++ b/src/biz/bokhorst/xprivacy/ActivityShare.java @@ -124,7 +124,6 @@ public class ActivityShare extends ActivityBase { public static final String ACTION_FETCH = "biz.bokhorst.xprivacy.action.FETCH"; public static final String ACTION_SUBMIT = "biz.bokhorst.xprivacy.action.SUBMIT"; public static final String ACTION_TOGGLE = "biz.bokhorst.xprivacy.action.TOGGLE"; - public static final String ACTION_UPDATE = "biz.bokhorst.xprivacy.action.UPDATE"; public static final int CHOICE_CLEAR = 1; public static final int CHOICE_TEMPLATE = 2; @@ -168,8 +167,7 @@ protected void onCreate(Bundle savedInstanceState) { finish(); return; } - } else if (action.equals(ACTION_FETCH) || action.equals(ACTION_UPDATE) - || (action.equals(ACTION_TOGGLE) && uids.length > 1)) { + } else if (action.equals(ACTION_FETCH) || (action.equals(ACTION_TOGGLE) && uids.length > 1)) { if (Util.hasProLicense(this) == null) { Util.viewUri(this, ActivityMain.cProUri); finish(); @@ -183,13 +181,6 @@ protected void onCreate(Bundle savedInstanceState) { return; } - // Update - if (action.equals(ACTION_UPDATE)) { - new UpdateTask(getApplicationContext()).executeOnExecutor(mExecutor); - finish(); - return; - } - // Check whether we need a user interface if (extras != null && extras.containsKey(cInteractive) && extras.getBoolean(cInteractive, false)) mInteractive = true; diff --git a/src/biz/bokhorst/xprivacy/UpdateService.java b/src/biz/bokhorst/xprivacy/UpdateService.java index a080019d2..139c5acb0 100644 --- a/src/biz/bokhorst/xprivacy/UpdateService.java +++ b/src/biz/bokhorst/xprivacy/UpdateService.java @@ -19,10 +19,11 @@ import android.util.Log; public class UpdateService extends Service { - public static String cAction = "Action"; - public static int cActionBoot = 1; - public static int cActionUpdated = 2; - public static String cFlush = "biz.bokhorst.xprivacy.action.FLUSH"; + public static final String cAction = "Action"; + public static final int cActionBoot = 1; + public static final int cActionUpdated = 2; + public static final String cFlush = "biz.bokhorst.xprivacy.action.FLUSH"; + public static final String cUpdate = "biz.bokhorst.xprivacy.action.UPDATE"; private static Thread mWorkerThread; @@ -39,7 +40,7 @@ public int onStartCommand(Intent intent, int flags, int startId) { return 0; } - // Check intent + // Flush if (cFlush.equals(intent.getAction())) { try { PrivacyService.getClient().flush(); @@ -50,6 +51,14 @@ public int onStartCommand(Intent intent, int flags, int startId) { return 0; } + // Update + if (cUpdate.equals(intent.getAction())) { + if (Util.hasProLicense(this) != null) + new ActivityShare.UpdateTask(this).execute(); + stopSelf(); + return 0; + } + // Check action Bundle extras = intent.getExtras(); if (extras.containsKey(cAction)) {