ignore quickLog startService exception
This commit is contained in:
parent
0b673ef1ab
commit
60e6841578
|
@ -35,9 +35,9 @@ public class UnifiedPushDistributor extends BroadcastReceiver {
|
||||||
public static final String ACTION_REGISTER = "org.unifiedpush.android.distributor.REGISTER";
|
public static final String ACTION_REGISTER = "org.unifiedpush.android.distributor.REGISTER";
|
||||||
public static final String ACTION_UNREGISTER = "org.unifiedpush.android.distributor.UNREGISTER";
|
public static final String ACTION_UNREGISTER = "org.unifiedpush.android.distributor.UNREGISTER";
|
||||||
|
|
||||||
|
|
||||||
// connector actions (these are actions used for distributor->connector broadcasts)
|
// connector actions (these are actions used for distributor->connector broadcasts)
|
||||||
public static final String ACTION_UNREGISTERED = "org.unifiedpush.android.connector.UNREGISTERED";
|
public static final String ACTION_UNREGISTERED =
|
||||||
|
"org.unifiedpush.android.connector.UNREGISTERED";
|
||||||
public static final String ACTION_BYTE_MESSAGE =
|
public static final String ACTION_BYTE_MESSAGE =
|
||||||
"org.unifiedpush.android.distributor.feature.BYTES_MESSAGE";
|
"org.unifiedpush.android.distributor.feature.BYTES_MESSAGE";
|
||||||
public static final String ACTION_REGISTRATION_FAILED =
|
public static final String ACTION_REGISTRATION_FAILED =
|
||||||
|
@ -79,10 +79,10 @@ public class UnifiedPushDistributor extends BroadcastReceiver {
|
||||||
switch (Strings.nullToEmpty(action)) {
|
switch (Strings.nullToEmpty(action)) {
|
||||||
case ACTION_REGISTER -> register(context, application, instance, features, messenger);
|
case ACTION_REGISTER -> register(context, application, instance, features, messenger);
|
||||||
case ACTION_UNREGISTER -> unregister(context, instance);
|
case ACTION_UNREGISTER -> unregister(context, instance);
|
||||||
case Intent.ACTION_PACKAGE_FULLY_REMOVED ->
|
case Intent.ACTION_PACKAGE_FULLY_REMOVED -> unregisterApplication(
|
||||||
unregisterApplication(context, intent.getData());
|
context, intent.getData());
|
||||||
default ->
|
default -> Log.d(
|
||||||
Log.d(Config.LOGTAG, "UnifiedPushDistributor received unknown action " + action);
|
Config.LOGTAG, "UnifiedPushDistributor received unknown action " + action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,11 @@ public class UnifiedPushDistributor extends BroadcastReceiver {
|
||||||
Log.d(
|
Log.d(
|
||||||
Config.LOGTAG,
|
Config.LOGTAG,
|
||||||
"successfully created UnifiedPush entry. waking up XmppConnectionService");
|
"successfully created UnifiedPush entry. waking up XmppConnectionService");
|
||||||
quickLog(context, String.format("successfully registered %s (token = %s) for UnifiedPushed", application, instance));
|
quickLog(
|
||||||
|
context,
|
||||||
|
String.format(
|
||||||
|
"successfully registered %s (token = %s) for UnifiedPushed",
|
||||||
|
application, instance));
|
||||||
final Intent serviceIntent = new Intent(context, XmppConnectionService.class);
|
final Intent serviceIntent = new Intent(context, XmppConnectionService.class);
|
||||||
serviceIntent.setAction(XmppConnectionService.ACTION_RENEW_UNIFIED_PUSH_ENDPOINTS);
|
serviceIntent.setAction(XmppConnectionService.ACTION_RENEW_UNIFIED_PUSH_ENDPOINTS);
|
||||||
serviceIntent.putExtra("instance", instance);
|
serviceIntent.putExtra("instance", instance);
|
||||||
|
@ -177,7 +181,11 @@ public class UnifiedPushDistributor extends BroadcastReceiver {
|
||||||
}
|
}
|
||||||
final UnifiedPushDatabase unifiedPushDatabase = UnifiedPushDatabase.getInstance(context);
|
final UnifiedPushDatabase unifiedPushDatabase = UnifiedPushDatabase.getInstance(context);
|
||||||
if (unifiedPushDatabase.deleteInstance(instance)) {
|
if (unifiedPushDatabase.deleteInstance(instance)) {
|
||||||
quickLog(context, String.format("successfully unregistered token %s from UnifiedPushed (application requested unregister)", instance));
|
quickLog(
|
||||||
|
context,
|
||||||
|
String.format(
|
||||||
|
"successfully unregistered token %s from UnifiedPushed (application requested unregister)",
|
||||||
|
instance));
|
||||||
Log.d(Config.LOGTAG, "successfully removed " + instance + " from UnifiedPush");
|
Log.d(Config.LOGTAG, "successfully removed " + instance + " from UnifiedPush");
|
||||||
// TODO send UNREGISTERED broadcast back to app?!
|
// TODO send UNREGISTERED broadcast back to app?!
|
||||||
}
|
}
|
||||||
|
@ -192,7 +200,11 @@ public class UnifiedPushDistributor extends BroadcastReceiver {
|
||||||
Log.d(Config.LOGTAG, "app " + application + " has been removed from the system");
|
Log.d(Config.LOGTAG, "app " + application + " has been removed from the system");
|
||||||
final UnifiedPushDatabase database = UnifiedPushDatabase.getInstance(context);
|
final UnifiedPushDatabase database = UnifiedPushDatabase.getInstance(context);
|
||||||
if (database.deleteApplication(application)) {
|
if (database.deleteApplication(application)) {
|
||||||
quickLog(context, String.format("successfully removed %s from UnifiedPushed (ACTION_PACKAGE_FULLY_REMOVED)", application));
|
quickLog(
|
||||||
|
context,
|
||||||
|
String.format(
|
||||||
|
"successfully removed %s from UnifiedPushed (ACTION_PACKAGE_FULLY_REMOVED)",
|
||||||
|
application));
|
||||||
Log.d(Config.LOGTAG, "successfully removed " + application + " from UnifiedPush");
|
Log.d(Config.LOGTAG, "successfully removed " + application + " from UnifiedPush");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,6 +222,6 @@ public class UnifiedPushDistributor extends BroadcastReceiver {
|
||||||
final Intent intent = new Intent(context, XmppConnectionService.class);
|
final Intent intent = new Intent(context, XmppConnectionService.class);
|
||||||
intent.setAction(XmppConnectionService.ACTION_QUICK_LOG);
|
intent.setAction(XmppConnectionService.ACTION_QUICK_LOG);
|
||||||
intent.putExtra("message", message);
|
intent.putExtra("message", message);
|
||||||
context.startService(intent);
|
Compatibility.startService(context, intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,6 @@ import android.content.pm.PackageManager;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.Preference;
|
|
||||||
import android.preference.PreferenceCategory;
|
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
@ -26,10 +24,6 @@ import eu.siacs.conversations.AppSettings;
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Compatibility {
|
public class Compatibility {
|
||||||
|
|
||||||
public static boolean hasStoragePermission(final Context context) {
|
public static boolean hasStoragePermission(final Context context) {
|
||||||
|
@ -100,7 +94,7 @@ public class Compatibility {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void startService(Context context, Intent intent) {
|
public static void startService(final Context context, final Intent intent) {
|
||||||
try {
|
try {
|
||||||
if (Compatibility.runsAndTargetsTwentySix(context)) {
|
if (Compatibility.runsAndTargetsTwentySix(context)) {
|
||||||
intent.putExtra(EXTRA_NEEDS_FOREGROUND_SERVICE, true);
|
intent.putExtra(EXTRA_NEEDS_FOREGROUND_SERVICE, true);
|
||||||
|
@ -108,7 +102,7 @@ public class Compatibility {
|
||||||
} else {
|
} else {
|
||||||
context.startService(intent);
|
context.startService(intent);
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
} catch (final RuntimeException e) {
|
||||||
Log.d(
|
Log.d(
|
||||||
Config.LOGTAG,
|
Config.LOGTAG,
|
||||||
context.getClass().getSimpleName() + " was unable to start service");
|
context.getClass().getSimpleName() + " was unable to start service");
|
||||||
|
|
Loading…
Reference in a new issue