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