mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-30 21:55:10 +00:00
Make lint suppression less aggressive for SMSHelper
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
package org.kde.kdeconnect.Helpers;
|
package org.kde.kdeconnect.Helpers;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
@@ -43,6 +44,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
|
|
||||||
|
@SuppressLint("InlinedApi")
|
||||||
public class SMSHelper {
|
public class SMSHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,7 +96,6 @@ public class SMSHelper {
|
|||||||
* @param threadID Thread to look up
|
* @param threadID Thread to look up
|
||||||
* @return List of all messages in the thread
|
* @return List of all messages in the thread
|
||||||
*/
|
*/
|
||||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
|
||||||
public static List<Message> getMessagesInThread(Context context, ThreadID threadID) {
|
public static List<Message> getMessagesInThread(Context context, ThreadID threadID) {
|
||||||
final String selection = ThreadID.lookupColumn + " == ?";
|
final String selection = ThreadID.lookupColumn + " == ?";
|
||||||
final String[] selectionArgs = new String[] { threadID.toString() };
|
final String[] selectionArgs = new String[] { threadID.toString() };
|
||||||
@@ -108,7 +109,6 @@ public class SMSHelper {
|
|||||||
* @param timestamp epoch in millis matching the timestamp to return
|
* @param timestamp epoch in millis matching the timestamp to return
|
||||||
* @return null if no matching message is found, otherwise return a Message
|
* @return null if no matching message is found, otherwise return a Message
|
||||||
*/
|
*/
|
||||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
|
||||||
public static List<Message> getMessagesSinceTimestamp(Context context, long timestamp) {
|
public static List<Message> getMessagesSinceTimestamp(Context context, long timestamp) {
|
||||||
final String selection = Message.DATE + " > ?";
|
final String selection = Message.DATE + " > ?";
|
||||||
final String[] selectionArgs = new String[] {Long.toString(timestamp)};
|
final String[] selectionArgs = new String[] {Long.toString(timestamp)};
|
||||||
@@ -125,7 +125,6 @@ public class SMSHelper {
|
|||||||
* @param selectionArgs Parameters for selection. May be null.
|
* @param selectionArgs Parameters for selection. May be null.
|
||||||
* @return Returns HashMap<ThreadID, List<Message>>, which is transformed in caller functions into other classes.
|
* @return Returns HashMap<ThreadID, List<Message>>, which is transformed in caller functions into other classes.
|
||||||
*/
|
*/
|
||||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
|
||||||
private static HashMap<ThreadID, List<Message>> getMessages(Uri Uri,
|
private static HashMap<ThreadID, List<Message>> getMessages(Uri Uri,
|
||||||
Context context,
|
Context context,
|
||||||
String selection,
|
String selection,
|
||||||
@@ -171,7 +170,6 @@ public class SMSHelper {
|
|||||||
* @param selectionArgs Parameters for selection. May be null.
|
* @param selectionArgs Parameters for selection. May be null.
|
||||||
* @return List of messages matching the filter
|
* @return List of messages matching the filter
|
||||||
*/
|
*/
|
||||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
|
||||||
private static List<Message> getMessagesWithFilter(Context context, String selection, String[] selectionArgs) {
|
private static List<Message> getMessagesWithFilter(Context context, String selection, String[] selectionArgs) {
|
||||||
HashMap<ThreadID, List<Message>> result = getMessages(SMSHelper.getSMSUri(), context, selection, selectionArgs);
|
HashMap<ThreadID, List<Message>> result = getMessages(SMSHelper.getSMSUri(), context, selection, selectionArgs);
|
||||||
List<Message> toReturn = new ArrayList<>();
|
List<Message> toReturn = new ArrayList<>();
|
||||||
@@ -189,7 +187,6 @@ public class SMSHelper {
|
|||||||
* @param context android.content.Context running the request
|
* @param context android.content.Context running the request
|
||||||
* @return Mapping of thread_id to the first message in each thread
|
* @return Mapping of thread_id to the first message in each thread
|
||||||
*/
|
*/
|
||||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
|
||||||
public static Map<ThreadID, Message> getConversations(Context context) {
|
public static Map<ThreadID, Message> getConversations(Context context) {
|
||||||
HashMap<ThreadID, List<Message>> result = getMessages(SMSHelper.getConversationUri(), context, null, null);
|
HashMap<ThreadID, List<Message>> result = getMessages(SMSHelper.getConversationUri(), context, null, null);
|
||||||
HashMap<ThreadID, Message> toReturn = new HashMap<>();
|
HashMap<ThreadID, Message> toReturn = new HashMap<>();
|
||||||
@@ -219,7 +216,6 @@ public class SMSHelper {
|
|||||||
/**
|
/**
|
||||||
* Represent an ID used to uniquely identify a message thread
|
* Represent an ID used to uniquely identify a message thread
|
||||||
*/
|
*/
|
||||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
|
||||||
public static class ThreadID {
|
public static class ThreadID {
|
||||||
final Long threadID;
|
final Long threadID;
|
||||||
static final String lookupColumn = Telephony.Sms.THREAD_ID;
|
static final String lookupColumn = Telephony.Sms.THREAD_ID;
|
||||||
@@ -247,7 +243,6 @@ public class SMSHelper {
|
|||||||
/**
|
/**
|
||||||
* Represent a message and all of its interesting data columns
|
* Represent a message and all of its interesting data columns
|
||||||
*/
|
*/
|
||||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
|
||||||
public static class Message {
|
public static class Message {
|
||||||
|
|
||||||
final String address;
|
final String address;
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
package org.kde.kdeconnect.Plugins.SMSPlugin;
|
package org.kde.kdeconnect.Plugins.SMSPlugin;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -65,6 +66,7 @@ import androidx.core.content.ContextCompat;
|
|||||||
import static org.kde.kdeconnect.Plugins.TelephonyPlugin.TelephonyPlugin.PACKET_TYPE_TELEPHONY;
|
import static org.kde.kdeconnect.Plugins.TelephonyPlugin.TelephonyPlugin.PACKET_TYPE_TELEPHONY;
|
||||||
|
|
||||||
@PluginFactory.LoadablePlugin
|
@PluginFactory.LoadablePlugin
|
||||||
|
@SuppressLint("InlinedApi")
|
||||||
public class SMSPlugin extends Plugin {
|
public class SMSPlugin extends Plugin {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -181,7 +183,6 @@ public class SMSPlugin extends Plugin {
|
|||||||
* In this case, this onChange expects to be called whenever *anything* in the Messages
|
* In this case, this onChange expects to be called whenever *anything* in the Messages
|
||||||
* database changes and simply reports those updated messages to anyone who might be listening
|
* database changes and simply reports those updated messages to anyone who might be listening
|
||||||
*/
|
*/
|
||||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
|
||||||
@Override
|
@Override
|
||||||
public void onChange(boolean selfChange) {
|
public void onChange(boolean selfChange) {
|
||||||
if (mPlugin.mostRecentTimestamp == 0) {
|
if (mPlugin.mostRecentTimestamp == 0) {
|
||||||
@@ -275,7 +276,6 @@ public class SMSPlugin extends Plugin {
|
|||||||
device.sendPacket(np);
|
device.sendPacket(np);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreate() {
|
public boolean onCreate() {
|
||||||
permissionExplanation = R.string.telepathy_permission_explanation;
|
permissionExplanation = R.string.telepathy_permission_explanation;
|
||||||
@@ -301,7 +301,6 @@ public class SMSPlugin extends Plugin {
|
|||||||
return context.getResources().getString(R.string.pref_plugin_telepathy_desc);
|
return context.getResources().getString(R.string.pref_plugin_telepathy_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPacketReceived(NetworkPacket np) {
|
public boolean onPacketReceived(NetworkPacket np) {
|
||||||
|
|
||||||
@@ -344,7 +343,6 @@ public class SMSPlugin extends Plugin {
|
|||||||
* @param messages Messages to include in the packet
|
* @param messages Messages to include in the packet
|
||||||
* @return NetworkPacket of type PACKET_TYPE_SMS_MESSAGE
|
* @return NetworkPacket of type PACKET_TYPE_SMS_MESSAGE
|
||||||
*/
|
*/
|
||||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
|
||||||
private static NetworkPacket constructBulkMessagePacket(Collection<SMSHelper.Message> messages) {
|
private static NetworkPacket constructBulkMessagePacket(Collection<SMSHelper.Message> messages) {
|
||||||
NetworkPacket reply = new NetworkPacket(PACKET_TYPE_SMS_MESSAGE);
|
NetworkPacket reply = new NetworkPacket(PACKET_TYPE_SMS_MESSAGE);
|
||||||
|
|
||||||
@@ -373,7 +371,6 @@ public class SMSPlugin extends Plugin {
|
|||||||
* <p>
|
* <p>
|
||||||
* Send one packet of type PACKET_TYPE_SMS_MESSAGE with the first message in all conversations
|
* Send one packet of type PACKET_TYPE_SMS_MESSAGE with the first message in all conversations
|
||||||
*/
|
*/
|
||||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
|
||||||
private boolean handleRequestConversations(NetworkPacket packet) {
|
private boolean handleRequestConversations(NetworkPacket packet) {
|
||||||
Map<SMSHelper.ThreadID, SMSHelper.Message> conversations = SMSHelper.getConversations(this.context);
|
Map<SMSHelper.ThreadID, SMSHelper.Message> conversations = SMSHelper.getConversations(this.context);
|
||||||
|
|
||||||
@@ -394,7 +391,6 @@ public class SMSPlugin extends Plugin {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
|
||||||
private boolean handleRequestConversation(NetworkPacket packet) {
|
private boolean handleRequestConversation(NetworkPacket packet) {
|
||||||
SMSHelper.ThreadID threadID = new SMSHelper.ThreadID(packet.getLong("threadID"));
|
SMSHelper.ThreadID threadID = new SMSHelper.ThreadID(packet.getLong("threadID"));
|
||||||
|
|
||||||
@@ -443,6 +439,9 @@ public class SMSPlugin extends Plugin {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* I suspect we can actually go lower than this, but it might get unstable
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getMinSdk() {
|
public int getMinSdk() {
|
||||||
return Build.VERSION_CODES.KITKAT;
|
return Build.VERSION_CODES.KITKAT;
|
||||||
|
Reference in New Issue
Block a user