diff --git a/AdbWinApi.dll b/AdbWinApi.dll
new file mode 100644
index 0000000..7abe26c
Binary files /dev/null and b/AdbWinApi.dll differ
diff --git a/AdbWinUsbApi.dll b/AdbWinUsbApi.dll
new file mode 100644
index 0000000..e7a6de1
Binary files /dev/null and b/AdbWinUsbApi.dll differ
diff --git a/README.md b/README.md
index 67ad174..f23b581 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,8 @@
# Lugia_ADB
Application to control android device through ADB
# Screenshot
-![image](files/lugia.png)
\ No newline at end of file
+Teleport:
+![image](files/teleport.png)
+
+Devices:
+![image](files/devices.png)
\ No newline at end of file
diff --git a/adb.exe b/adb.exe
new file mode 100644
index 0000000..1c75897
Binary files /dev/null and b/adb.exe differ
diff --git a/files/devices.png b/files/devices.png
new file mode 100644
index 0000000..b699c30
Binary files /dev/null and b/files/devices.png differ
diff --git a/files/icon.ico b/files/icon.ico
new file mode 100644
index 0000000..34b187f
Binary files /dev/null and b/files/icon.ico differ
diff --git a/files/icon.png b/files/icon.png
new file mode 100644
index 0000000..e112d68
Binary files /dev/null and b/files/icon.png differ
diff --git a/files/lugia.png b/files/lugia.png
deleted file mode 100644
index 2ffb91a..0000000
Binary files a/files/lugia.png and /dev/null differ
diff --git a/files/teleport.png b/files/teleport.png
new file mode 100644
index 0000000..a5135ca
Binary files /dev/null and b/files/teleport.png differ
diff --git a/index.html b/index.html
index c90b3a8..cb47e71 100644
--- a/index.html
+++ b/index.html
@@ -1,4 +1,4 @@
-
+
@@ -27,7 +27,8 @@
Cooldown
@@ -81,20 +86,69 @@
Routes
Using special routes for field quests.
Coming Soon
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
diff --git a/index.js b/index.js
index 5e207bf..f4c9ef5 100644
--- a/index.js
+++ b/index.js
@@ -1,148 +1,261 @@
const {remote, Tray, shell} = require('electron')
const {PythonShell} = require('python-shell')
const path = require('path');
+const exec = require('child_process').exec
+const fs = require('fs')
-// let options = {
-// mode: 'text',
-// pythonOptions: ['-u'],
-// scriptPath: 'py/',
-// args: ['list']
-// };
-
-// let adb_devices = {num_devices:0}
-// let device_listeners = []
-// deep_info = []
-
-// refresh_adb_list = document.getElementById("refresh-adb")
-// refresh_adb_list.addEventListener('click', function(){
-// PythonShell.run('devices.py', options, function(err, results){
-// if (err) throw err;
-// console.log("ADB devices loaded!")
-// adb_devices = JSON.parse(results[0])
-// console.log(adb_devices)
-// } )
-
-// var block = document.getElementById("adb_list")
-// block.textContent = '';
-
-// for(let id in adb_devices){
-// if(id=="num_devices"){
-// console.log("Number of devices :" + adb_devices[id])
-// }else{
-// console.log(adb_devices[id])
-// var btn = document.createElement("button");
-// btn.id = adb_devices[id]
-// var text = document.createTextNode(adb_devices[id])
-// btn.appendChild(text)
-// options = {
-// mode: 'text',
-// pythonOptions: ['-u'],
-// scriptPath: 'py/',
-// args: ['info',adb_devices[id]]
-// };
-// PythonShell.run('devices.py', options, function(err, results){
-// if (err) throw err;
-// // console.log(results)
-// deep_info[adb_devices[id]] = JSON.parse(results[0])
-// console.log(deep_info)
-// })
-// if(deep_info.authorized=="False"){
-// btn.classList = "btn btn-danger"
-// }
-// else{
-// btn.classList = "btn btn-success"
-// }
-// block.appendChild(btn)
-// device_listeners[id] = document.getElementById(adb_devices[id])
-// device_listeners[id].addEventListener('click', function(){
-// // [TODO] : complete dialog box
-// const { dialog } = require('electron').remote
-// console.log(dialog.showMessageBoxSync(options={message: JSON.stringify(deep_info[adb_devices[id]]), buttons:['OK']}))
-// })
-// }
-// }
-// })
+function set_info(element){
+ var device_id = element.id;
+ active_device = document.getElementById("active_device").innerHTML;
+ console.log("Active Device: "+active_device);
+ if(active_device != device_id){
+ document.getElementById("active_device").innerHTML = device_id;
+ console.log("Setting active device : "+device_id);
+ }
+ var cmd_path = ("cd "+__dirname+" &&");
+ child = exec( cmd_path+"adb devices -l", function(err, stdout, stderr){
+ devices = stdout.split("\n");
+ for(let entry in devices){
+ id = devices[entry].split(' ')[0];
+ id = id.split(':')[0];
+ if(id == device_id){
+ var ip = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
+ let dev_info = document.getElementById("adb_info");
+ dev_info.textContent = "";
+ parsed_info = devices[entry].split(" ");
+ var filtered = parsed_info.filter(function (el) {
+ return el != "";
+ });
+ console.log(filtered);
+ // Dapibus ac facilisis in
+
+ // ID
+ var value = filtered[0].split(":")[0];
+ var info_element = document.createElement('li');
+ info_element.classList = "list-group-item";
+ var info_text = document.createTextNode("ID: "+value);
+ info_element.appendChild(info_text);
+ dev_info.appendChild(info_element);
-// complete fly section javascript is managed here
-current_coords = -1
+ if(ip.test(value)){
+ info_element = document.createElement('li');
+ info_element.classList = "list-group-item";
+ info_text = document.createTextNode("Over WiFi: YES");
+ info_element.appendChild(info_text);
+ dev_info.appendChild(info_element);
+ }
+ else{
+ info_element = document.createElement('li');
+ info_element.classList = "list-group-item";
+ info_text = document.createTextNode("Over WiFi: NO");
+ info_element.appendChild(info_text);
+ dev_info.appendChild(info_element);
+ }
+
+ //authorization
+ value = filtered[1];
+ if(value=="device"){
+ value = "authorized";
+ }
+ info_element = document.createElement('li');
+ info_element.classList = "list-group-item";
+ info_text = document.createTextNode("State: "+value);
+ info_element.appendChild(info_text);
+ dev_info.appendChild(info_element);
-const form = document.getElementById("Fly-coord")
-form.addEventListener('submit',function(event){
+ //Product
+ value = filtered[2].split(':')[1];
+ info_element = document.createElement('li');
+ info_element.classList = "list-group-item";
+ info_text = document.createTextNode("Product: "+value);
+ info_element.appendChild(info_text);
+ dev_info.appendChild(info_element);
+
+ //Device
+ value = filtered[4].split(':')[1];
+ info_element = document.createElement('li');
+ info_element.classList = "list-group-item";
+ info_text = document.createTextNode("Device: "+value);
+ info_element.appendChild(info_text);
+ dev_info.appendChild(info_element);
+
+ }
+ }
+ })
+}
+
+function refresh_devices(){
+ var cmd_path = ("cd "+__dirname+" &&");
+ console.log("adb Path:"+cmd_path);
+ exec(cmd_path+"adb devices -l", function(err, stdout, stderr){
+ var list = document.getElementById("adb_list");
+ list.textContent = "";
+ devices = stdout.split("\n");
+ // console.log(stdout);
+ console.log(devices);
+ verified_list = [];
+ for(let entry in devices){
+ var hex = /^[0-9A-Fa-f]+$/;
+ var ip = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
+ id = devices[entry].split(' ')[0];
+ id = id.split(":")[0];
+ console.log(id);
+ if(hex.test(id) || ip.test(id)){
+ console.log("valid");
+ list_element = document.getElementById('adb_list');
+ var btn = document.createElement("button");
+ btn.id = id;
+ var text = document.createTextNode(id);
+ btn.appendChild(text);
+ btn.type = "button";
+ btn.classList = "list-group-item list-group-item-action";
+ list_element.appendChild(btn);
+ btn.addEventListener("click", function(btn){
+ set_info(this);
+ })
+ }
+ else{
+ console.log("invalid");
+ }
+ }
+ })
+}
+
+const connect_form = document.getElementById('tcpip_add')
+connect_form.addEventListener('submit', function(event){
event.preventDefault();
- entered_coords = event.target[0].value;
- console.log(event)
- if (event.target[1].checked == true){
- fly_path = path.join(__dirname,"fly.py")
- current_coords = entered_coords;
- current_coords = entered_coords;
- temp = current_coords.split(',');
- document.getElementById("curr_lat").innerText = "Latitude : " + temp[0];
- document.getElementById("curr_lon").innerText = "Longitude : " + temp[1];
- options = {
- mode: 'text',
- pythonOptions: ['-u']
- };
- options.args = ['fly', current_coords]
- PythonShell.run(fly_path, options, function(err){
+ console.log(event);
+ console.log(event.target);
+ console.log(event.target[0]);
+ console.log(event.target[0].value);
+ input_ip = event.target[0].value;
+ add_wifi_device(input_ip);
+})
+
+function add_wifi_device(address){
+ var ip = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
+ if(ip.test(address)){
+ var cmd_path = ("cd "+__dirname+" &&");
+
+ child = exec(cmd_path+"adb connect "+address, function(err, stdout, stderr){
if (err) throw err;
+ console.log(stdout);
+ })
+ child.on('exit', function(code){
+ refresh_devices();
})
}
else{
- let options = {
- mode: 'text',
- pythonOptions: ['-u']
- };
- console.log(options)
- if(current_coords == -1){
+ console.log("Worng Format of IP address used!");
+ }
+
+}
+
+refresh_adb = document.getElementById('refresh-adb');
+refresh_adb.addEventListener('click',refresh_devices);
+
+
+// complete fly section javascript is managed here
+current_coords = -1
+
+const form = document.getElementById("Fly-coord")
+form.addEventListener('submit',function(event){
+ event.preventDefault();
+ active_device = document.getElementById("active_device").innerHTML;
+ var hex = /^[0-9A-Fa-f]+$/;
+ var ip = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
+ var cmd_path = ("cd "+__dirname+" &&");
+
+ if(hex.test(active_device) || ip.test(active_device)){
+ entered_coords = event.target[0].value;
+ console.log(event);
+ if (event.target[1].checked == true){
+ // fly_path = path.join(__dirname,"fly.py")
current_coords = entered_coords;
+ temp = current_coords.split(',');
+ document.getElementById("curr_lat").innerText = "Latitude : " + temp[0];
+ document.getElementById("curr_lon").innerText = "Longitude : " + temp[1];
+ // options = {
+ // mode: 'text',
+ // pythonOptions: ['-u']
+ // };
+ // options.args = ['fly', current_coords]
+ // PythonShell.run(fly_path, options, function(err, results){
+ // if (err) throw err;
+ // console.log(results[0]);
+ // })
+ fly_command = cmd_path+"adb -s " + active_device + " shell am start-foreground-service -a theappninjas.gpsjoystick.TELEPORT --ef lat " + temp[0] + " --ef lng " + temp[1];
+ child = exec(fly_command, function(err, stdout, stderr){
+ if (err) throw err;
+ console.log(stdout);
+ })
}
- options.args = ['getcd', entered_coords, current_coords]
- console.log(options.args)
- fly_path = path.join(__dirname,"fly.py")
- PythonShell.run(fly_path, options, function(err, results){
- if (err) throw err;
- console.log(results);
- cd = JSON.parse(results[0]);
- cd = cd.cooldown;
- cd = cd * 10;
- let counter = 0;
- // console.log(cd)
- cd_bar = document.getElementById('cooldown_bar');
- cd_bar.style.display = 'flex';
- var per = 0
- cd_bar.style.width = per+"%";
- function update_progress(){
+ else{
+ let options = {
+ mode: 'text',
+ pythonOptions: ['-u']
+ };
+ console.log(options)
+ if(current_coords == -1){
+ current_coords = entered_coords;
+ }
+ options.args = ['getcd', entered_coords, current_coords]
+ console.log(options.args)
+ fly_path = path.join(__dirname,"fly.py")
+ PythonShell.run(fly_path, options, function(err, results){
+ if (err) throw err;
+ console.log(results);
+ cd = JSON.parse(results[0]);
+ cd = cd.cooldown;
+ cd = cd * 10;
+ let counter = 0;
+ // console.log(cd)
+ cd_bar = document.getElementById('cooldown_bar');
+ cd_bar.style.display = 'flex';
+ var per = 0
cd_bar.style.width = per+"%";
- per += 1;
- console.log("progress: "+per+"%");
- if(per<100){
- setTimeout(update_progress,cd);
+ function update_progress(){
+ cd_bar.style.width = per+"%";
+ per += 1;
+ console.log("progress: "+per+"%");
+ if(per<100){
+ setTimeout(update_progress,cd);
+ }
+ else{
+ current_coords = entered_coords;
+ temp = current_coords.split(',');
+ console.log("Cooldown over!")
+ // console.log(temp)
+ document.getElementById("curr_lat").innerText = "Latitude : " + temp[0];
+ document.getElementById("curr_lon").innerText = "Longitude : " + temp[1];
+ cd_bar.style.display = 'none';
+ // options = {
+ // mode: 'text',
+ // pythonOptions: ['-u']
+ // };
+ // options.args = ['fly', current_coords]
+ // PythonShell.run(fly_path, options, function(err, results){
+ // if (err) throw err;
+ // console.log(results[0]);
+ // })
+ fly_command = cmd_path+"adb -s " + active_device + " shell am start-foreground-service -a theappninjas.gpsjoystick.TELEPORT --ef lat " + temp[0] + " --ef lng " + temp[1];
+ child = exec(fly_command, function(err, stdout, stderr){
+ if (err) throw err;
+ console.log(stdout);
+ })
+ }
}
- else{
- //[todo] : call actual fly
- current_coords = entered_coords;
- temp = current_coords.split(',');
- console.log("Cooldown over!")
- console.log(temp)
- document.getElementById("curr_lat").innerText = "Latitude : " + temp[0];
- document.getElementById("curr_lon").innerText = "Longitude : " + temp[1];
- cd_bar.style.display = 'none';
- options = {
- mode: 'text',
- pythonOptions: ['-u']
- };
- options.args = ['fly', current_coords]
- PythonShell.run(fly_path, options, function(err){
- if (err) throw err;
- })
- }
- }
- setTimeout(update_progress,cd)
- })
+ setTimeout(update_progress,cd)
+ })
+ }
}
+ else{
+ console.log("No Device Selected!");
+ }
+
// console.log(entered_coords)
diff --git a/main.js b/main.js
index 1d7fbe1..8059397 100644
--- a/main.js
+++ b/main.js
@@ -4,8 +4,8 @@ const { remote } = require('electron')
function createWindow () {
// Create the browser window.
const win = new BrowserWindow({
- width: 600,
- height: 380,
+ width: 830,
+ height: 500,
resizable: false,
show: false,
webPreferences: {
diff --git a/package.json b/package.json
index af71de7..715e312 100644
--- a/package.json
+++ b/package.json
@@ -38,7 +38,7 @@
},
"win": {
"target": "portable",
- "icon": "files/icon.png"
+ "icon": "files/icon.ico"
}
},
"repository": {