-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
143 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/de/tudarmstadt/informatik/hostage/event/BeaconEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package de.tudarmstadt.informatik.hostage.event; | ||
|
||
import org.json.JSONArray; | ||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
import java.io.File; | ||
|
||
import de.tudarmstadt.informatik.hostage.commons.JSONHelper; | ||
import de.tudarmstadt.informatik.hostage.ui.activity.MainActivity; | ||
|
||
public class BeaconEvent implements Event { | ||
private static final String PERSIST_FILENAME = "beaconInfo.json"; | ||
File file = new File("/data/data/" + MainActivity.getContext().getPackageName() + "/" + PERSIST_FILENAME); | ||
|
||
@Override | ||
public JSONObject toJSON() { | ||
JSONObject jsonObject = new JSONObject(); | ||
try { | ||
jsonObject.put("deviceid",deviceId); | ||
jsonObject.put("open","working"); | ||
|
||
} catch (JSONException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
return jsonObject; | ||
} | ||
private JSONArray persistData() { | ||
JSONArray array = new JSONArray(); | ||
array.put(this.toJSON()); | ||
|
||
return array; | ||
} | ||
@Override | ||
public void writeData() { | ||
JSONHelper jsonHelper = new JSONHelper(); | ||
jsonHelper.jsonWriter(persistData(),file); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/de/tudarmstadt/informatik/hostage/event/DeviceEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package de.tudarmstadt.informatik.hostage.event; | ||
|
||
import android.content.Context; | ||
|
||
import com.jaredrummler.android.device.DeviceName; | ||
|
||
import org.json.JSONArray; | ||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
import java.io.File; | ||
import de.tudarmstadt.informatik.hostage.commons.JSONHelper; | ||
import de.tudarmstadt.informatik.hostage.system.Device; | ||
import de.tudarmstadt.informatik.hostage.ui.activity.MainActivity; | ||
|
||
public class DeviceEvent implements Event{ | ||
Context context; | ||
String manufacturer; | ||
String model; | ||
String deviceName; | ||
private static final String PERSIST_FILENAME = "deviceInfo.json"; | ||
File file = new File("/data/data/" + MainActivity.getContext().getPackageName() + "/" + PERSIST_FILENAME); | ||
|
||
public DeviceEvent(Context context){ | ||
this.context = context; | ||
} | ||
|
||
public void getDeviceInfo() { | ||
DeviceName.with(context).request((info, error) -> { | ||
manufacturer = info.manufacturer; // "Samsung" | ||
model = info.model; // "SM-G955W" | ||
deviceName = info.getName(); // "Galaxy S8+" | ||
}); | ||
} | ||
|
||
|
||
private JSONArray persistData() { | ||
JSONArray array = new JSONArray(); | ||
array.put(this.toJSON()); | ||
|
||
return array; | ||
} | ||
|
||
@Override | ||
public JSONObject toJSON() { | ||
JSONObject jsonObject = new JSONObject(); | ||
try { | ||
jsonObject.put("deviceid",deviceId); | ||
jsonObject.put("manufacturer",manufacturer); | ||
jsonObject.put("model",model); | ||
jsonObject.put("deciveName",deviceName); | ||
jsonObject.put("rooted",Device.isRooted()); | ||
} catch (JSONException e) { | ||
e.printStackTrace(); | ||
} | ||
return jsonObject; | ||
} | ||
|
||
@Override | ||
public void writeData() { | ||
JSONHelper jsonHelper = new JSONHelper(); | ||
jsonHelper.jsonWriter(persistData(),file); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/de/tudarmstadt/informatik/hostage/event/Event.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package de.tudarmstadt.informatik.hostage.event; | ||
|
||
|
||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
import java.util.UUID; | ||
|
||
public interface Event { | ||
String deviceId = UUID.randomUUID().toString(); | ||
|
||
JSONObject toJSON() throws JSONException; | ||
void writeData(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters