mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-03 15:45:10 +00:00
Using capabilities, packages no longer need to validate received packages
This commit is contained in:
@@ -54,6 +54,7 @@ import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@@ -562,7 +563,7 @@ public class Device implements BaseLink.PackageReceiver {
|
||||
} else if (isPaired()) {
|
||||
|
||||
//If capabilities are not supported, iterate all plugins
|
||||
Collection<String> targetPlugins = (protocolVersion > 6)? pluginsByIncomingInterface.get(np.getType()) : plugins.keySet();
|
||||
Collection<String> targetPlugins = pluginsByIncomingInterface.get(np.getType());
|
||||
if (targetPlugins != null && !targetPlugins.isEmpty()) {
|
||||
for (String pluginKey : targetPlugins) {
|
||||
Plugin plugin = plugins.get(pluginKey);
|
||||
@@ -587,7 +588,7 @@ public class Device implements BaseLink.PackageReceiver {
|
||||
unpair();
|
||||
|
||||
//If capabilities are not supported, iterate all plugins
|
||||
Collection<String> targetPlugins = (protocolVersion > 6)? pluginsByIncomingInterface.get(np.getType()) : plugins.keySet();
|
||||
Collection<String> targetPlugins = pluginsByIncomingInterface.get(np.getType());
|
||||
if (targetPlugins != null && !targetPlugins.isEmpty()) {
|
||||
for (String pluginKey : targetPlugins) {
|
||||
Plugin plugin = plugins.get(pluginKey);
|
||||
|
@@ -102,7 +102,6 @@ public class BatteryPlugin extends Plugin {
|
||||
|
||||
@Override
|
||||
public boolean onPackageReceived(NetworkPackage np) {
|
||||
if (!np.getType().equals(PACKAGE_TYPE_BATTERY_REQUEST)) return false;
|
||||
|
||||
if (np.getBoolean("request")) {
|
||||
if (lastInfo != null) {
|
||||
|
@@ -65,9 +65,6 @@ public class ClipboardPlugin extends Plugin {
|
||||
|
||||
@Override
|
||||
public boolean onPackageReceived(NetworkPackage np) {
|
||||
if (!np.getType().equals(PACKAGE_TYPE_CLIPBOARD)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String content = np.getString("content");
|
||||
listener.setText(content);
|
||||
|
@@ -33,8 +33,6 @@ public class FindMyPhonePlugin extends Plugin {
|
||||
|
||||
@Override
|
||||
public boolean onPackageReceived(NetworkPackage np) {
|
||||
if (np.getType().equals(PACKAGE_TYPE_FINDMYPHONE_REQUEST)) {
|
||||
//Log.e("PingPackageReceiver", "was a find my phone!");
|
||||
|
||||
Intent intent = new Intent(context,FindMyPhoneActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
@@ -42,8 +40,6 @@ public class FindMyPhonePlugin extends Plugin {
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPackageTypes() {
|
||||
|
@@ -119,7 +119,6 @@ public class MprisPlugin extends Plugin {
|
||||
|
||||
@Override
|
||||
public boolean onPackageReceived(NetworkPackage np) {
|
||||
if (!np.getType().equals(PACKAGE_TYPE_MPRIS)) return false;
|
||||
|
||||
if (np.has("nowPlaying") || np.has("volume") || np.has("isPlaying") || np.has("length") || np.has("pos")) {
|
||||
if (np.getString("player").equals(player)) {
|
||||
|
@@ -272,7 +272,6 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
|
||||
|
||||
@Override
|
||||
public boolean onPackageReceived(final NetworkPackage np) {
|
||||
if (!np.getType().equals(PACKAGE_TYPE_NOTIFICATION_REQUEST) && !np.getType().equals(PACKAGE_TYPE_NOTIFICATION)) return false;
|
||||
/*
|
||||
if (np.getBoolean("sendIcons")) {
|
||||
sendIcons = true;
|
||||
|
@@ -82,7 +82,6 @@ public class RunCommandPlugin extends Plugin {
|
||||
|
||||
@Override
|
||||
public boolean onPackageReceived(NetworkPackage np) {
|
||||
if (!np.getType().equals(PACKAGE_TYPE_RUNCOMMAND)) return false;
|
||||
|
||||
if (np.has("commandList")) {
|
||||
commandList.clear();
|
||||
|
@@ -61,7 +61,6 @@ public class SftpPlugin extends Plugin {
|
||||
|
||||
@Override
|
||||
public boolean onPackageReceived(NetworkPackage np) {
|
||||
if (!np.getType().equals(PACKAGE_TYPE_SFTP_REQUEST)) return false;
|
||||
|
||||
if (np.getBoolean("startBrowsing")) {
|
||||
if (server.start()) {
|
||||
|
@@ -103,10 +103,6 @@ public class SharePlugin extends Plugin {
|
||||
@Override
|
||||
public boolean onPackageReceived(NetworkPackage np) {
|
||||
|
||||
if (!np.getType().equals(PACKAGE_TYPE_SHARE_REQUEST)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
if (np.hasPayload()) {
|
||||
|
||||
|
@@ -230,9 +230,6 @@ public class TelephonyPlugin extends Plugin {
|
||||
|
||||
@Override
|
||||
public boolean onPackageReceived(NetworkPackage np) {
|
||||
if (!np.getType().equals(PACKAGE_TYPE_TELEPHONY_REQUEST)) {
|
||||
return false;
|
||||
}
|
||||
if (np.getString("action").equals("mute")) {
|
||||
if (!isMuted) {
|
||||
AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||
|
Reference in New Issue
Block a user