mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-31 22:25:08 +00:00
Package version checks
This commit is contained in:
@@ -8,10 +8,7 @@ import org.kde.connect.Types.NetworkPackage;
|
||||
|
||||
public class PingPackageEmitter extends BasePackageEmitter {
|
||||
|
||||
Context context;
|
||||
|
||||
public PingPackageEmitter(Context ctx) {
|
||||
context = ctx;
|
||||
}
|
||||
|
||||
public void sendPing() {
|
||||
|
@@ -13,11 +13,12 @@ import java.util.TimeZone;
|
||||
|
||||
public class NetworkPackage {
|
||||
|
||||
private int mVersion = 1;
|
||||
private final static int CURRENT_PACKAGE_VERSION = 1;
|
||||
|
||||
private long mId;
|
||||
private String mType;
|
||||
private JSONObject mBody;
|
||||
private int mVersion;
|
||||
|
||||
private NetworkPackage() {
|
||||
}
|
||||
@@ -26,6 +27,7 @@ public class NetworkPackage {
|
||||
mId = System.currentTimeMillis();
|
||||
mType = type;
|
||||
mBody = new JSONObject();
|
||||
mVersion = CURRENT_PACKAGE_VERSION;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
@@ -72,6 +74,9 @@ public class NetworkPackage {
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
if (np.mVersion > CURRENT_PACKAGE_VERSION) {
|
||||
Log.e("NetworkPackage.unserialize","Version "+np.mVersion+" greater than supported version "+CURRENT_PACKAGE_VERSION);
|
||||
}
|
||||
return np;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user