2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-31 06:05:12 +00:00

Use StringUtils.contains().

This commit is contained in:
Isira Seneviratne
2020-07-09 15:17:58 +05:30
committed by Nicolas Fella
parent 84ca679d84
commit e74743c684
3 changed files with 7 additions and 11 deletions

View File

@@ -40,6 +40,7 @@ import androidx.annotation.RequiresApi;
import com.klinker.android.send_message.Utils; import com.klinker.android.send_message.Utils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@@ -257,17 +258,10 @@ public class SMSHelper {
null, null,
null) null)
) { ) {
if (availableColumnsCursor != null) { return availableColumnsCursor != null; // if we got the cursor, the query shouldn't fail
return true; // if we got the cursor, the query shouldn't fail
}
return false;
} catch (SQLiteException | IllegalArgumentException e) { } catch (SQLiteException | IllegalArgumentException e) {
// With uri content://mms-sms/conversations this query throws an exception if sub_id is not supported // With uri content://mms-sms/conversations this query throws an exception if sub_id is not supported
String errMessage = e.getMessage(); return !StringUtils.contains(e.getMessage(), Telephony.Sms.SUBSCRIPTION_ID);
if (errMessage != null && errMessage.contains(Telephony.Sms.SUBSCRIPTION_ID)) {
return false;
}
return true;
} }
} }

View File

@@ -34,6 +34,7 @@ import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.fragment.app.DialogFragment; import androidx.fragment.app.DialogFragment;
import org.apache.commons.lang3.StringUtils;
import org.kde.kdeconnect.Helpers.AppsHelper; import org.kde.kdeconnect.Helpers.AppsHelper;
import org.kde.kdeconnect.NetworkPacket; import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.NotificationsPlugin.NotificationReceiver; import org.kde.kdeconnect.Plugins.NotificationsPlugin.NotificationReceiver;
@@ -260,7 +261,7 @@ public class MprisReceiverPlugin extends Plugin {
private boolean hasPermission() { private boolean hasPermission() {
String notificationListenerList = Settings.Secure.getString(context.getContentResolver(), "enabled_notification_listeners"); String notificationListenerList = Settings.Secure.getString(context.getContentResolver(), "enabled_notification_listeners");
return (notificationListenerList != null && notificationListenerList.contains(context.getPackageName())); return StringUtils.contains(notificationListenerList, context.getPackageName());
} }
} }

View File

@@ -51,6 +51,7 @@ import androidx.fragment.app.DialogFragment;
import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.collections4.MultiValuedMap;
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray; import org.json.JSONArray;
import org.kde.kdeconnect.Helpers.AppsHelper; import org.kde.kdeconnect.Helpers.AppsHelper;
import org.kde.kdeconnect.NetworkPacket; import org.kde.kdeconnect.NetworkPacket;
@@ -121,7 +122,7 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
private boolean hasPermission() { private boolean hasPermission() {
String notificationListenerList = Settings.Secure.getString(context.getContentResolver(), "enabled_notification_listeners"); String notificationListenerList = Settings.Secure.getString(context.getContentResolver(), "enabled_notification_listeners");
return (notificationListenerList != null && notificationListenerList.contains(context.getPackageName())); return StringUtils.contains(notificationListenerList, context.getPackageName());
} }
@Override @Override