2
0
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:
Simon Redman
2019-06-05 22:13:59 -06:00
parent 56d01ed082
commit 49295c0de9
2 changed files with 7 additions and 13 deletions

View File

@@ -20,6 +20,7 @@
package org.kde.kdeconnect.Helpers;
import android.annotation.SuppressLint;
import android.content.Context;
import android.database.ContentObserver;
import android.database.Cursor;
@@ -43,6 +44,7 @@ import java.util.concurrent.locks.ReentrantLock;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
@SuppressLint("InlinedApi")
public class SMSHelper {
/**
@@ -94,7 +96,6 @@ public class SMSHelper {
* @param threadID Thread to look up
* @return List of all messages in the thread
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static List<Message> getMessagesInThread(Context context, ThreadID threadID) {
final String selection = ThreadID.lookupColumn + " == ?";
final String[] selectionArgs = new String[] { threadID.toString() };
@@ -108,7 +109,6 @@ public class SMSHelper {
* @param timestamp epoch in millis matching the timestamp to return
* @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) {
final String selection = Message.DATE + " > ?";
final String[] selectionArgs = new String[] {Long.toString(timestamp)};
@@ -125,7 +125,6 @@ public class SMSHelper {
* @param selectionArgs Parameters for selection. May be null.
* @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,
Context context,
String selection,
@@ -171,7 +170,6 @@ public class SMSHelper {
* @param selectionArgs Parameters for selection. May be null.
* @return List of messages matching the filter
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private static List<Message> getMessagesWithFilter(Context context, String selection, String[] selectionArgs) {
HashMap<ThreadID, List<Message>> result = getMessages(SMSHelper.getSMSUri(), context, selection, selectionArgs);
List<Message> toReturn = new ArrayList<>();
@@ -189,7 +187,6 @@ public class SMSHelper {
* @param context android.content.Context running the request
* @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) {
HashMap<ThreadID, List<Message>> result = getMessages(SMSHelper.getConversationUri(), context, null, null);
HashMap<ThreadID, Message> toReturn = new HashMap<>();
@@ -219,7 +216,6 @@ public class SMSHelper {
/**
* Represent an ID used to uniquely identify a message thread
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static class ThreadID {
final Long threadID;
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
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
public static class Message {
final String address;

View File

@@ -22,6 +22,7 @@
package org.kde.kdeconnect.Plugins.SMSPlugin;
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -65,6 +66,7 @@ import androidx.core.content.ContextCompat;
import static org.kde.kdeconnect.Plugins.TelephonyPlugin.TelephonyPlugin.PACKET_TYPE_TELEPHONY;
@PluginFactory.LoadablePlugin
@SuppressLint("InlinedApi")
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
* database changes and simply reports those updated messages to anyone who might be listening
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onChange(boolean selfChange) {
if (mPlugin.mostRecentTimestamp == 0) {
@@ -275,7 +276,6 @@ public class SMSPlugin extends Plugin {
device.sendPacket(np);
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public boolean onCreate() {
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);
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public boolean onPacketReceived(NetworkPacket np) {
@@ -344,7 +343,6 @@ public class SMSPlugin extends Plugin {
* @param messages Messages to include in the packet
* @return NetworkPacket of type PACKET_TYPE_SMS_MESSAGE
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private static NetworkPacket constructBulkMessagePacket(Collection<SMSHelper.Message> messages) {
NetworkPacket reply = new NetworkPacket(PACKET_TYPE_SMS_MESSAGE);
@@ -373,7 +371,6 @@ public class SMSPlugin extends Plugin {
* <p>
* 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) {
Map<SMSHelper.ThreadID, SMSHelper.Message> conversations = SMSHelper.getConversations(this.context);
@@ -394,7 +391,6 @@ public class SMSPlugin extends Plugin {
return true;
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private boolean handleRequestConversation(NetworkPacket packet) {
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
public int getMinSdk() {
return Build.VERSION_CODES.KITKAT;