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

Changed abstract plugin to receive packages from unpaired device

Now plugin can register to receive network packages from unpaired
devices.

REVIEW: 124819
This commit is contained in:
Ashish Bansal
2015-08-19 21:27:27 +05:30
parent 403c18a056
commit 0868394596
2 changed files with 29 additions and 1 deletions

View File

@@ -548,12 +548,21 @@ public class Device implements BaseLink.PackageReceiver {
} else {
Log.e("KDE/onPackageReceived","Device not paired, ignoring package!");
Log.e("KDE/onPackageReceived","Device not paired, will pass package to unpairedPackageListeners");
if (pairStatus != PairStatus.Requested) {
unpair();
}
for (Plugin plugin : unpairedPackageListeners) {
try {
plugin.onUnpairedDevicePackageReceived(np);
} catch (Exception e) {
e.printStackTrace();
Log.e("KDE/Device", "Exception in "+plugin.getDisplayName()+"'s onPackageReceived() in unPairedPackageListeners");
}
}
}
}
@@ -716,6 +725,10 @@ public class Device implements BaseLink.PackageReceiver {
Log.e("KDE/removePlugin","Exception calling onDestroy for plugin "+pluginKey);
}
if (unpairedPackageListeners.contains(plugin)) {
unpairedPackageListeners.remove(plugin);
}
for (PluginsChangedListener listener : pluginsChangedListeners) {
listener.onPluginsChanged(this);
}
@@ -782,4 +795,11 @@ public class Device implements BaseLink.PackageReceiver {
pluginsChangedListeners.remove(listener);
}
private final ArrayList<Plugin> unpairedPackageListeners = new ArrayList<>();
public void registerUnpairedPackageListener(Plugin p) {
Log.e("KDE/registerUnpairedPackageListener", p.getPluginKey() + " plugin registered to receive package from unpaired device");
unpairedPackageListeners.add(p);
}
}