|
|
|
@ -29,6 +29,7 @@ import org.json.JSONObject;
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
|
import java.io.BufferedWriter;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileFilter;
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
import java.io.FilenameFilter;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
@ -70,6 +71,7 @@ public class AppMaster {
|
|
|
|
|
public static final String CMD_PUSH_FILE = "push_file";
|
|
|
|
|
public static final String CMD_DOWNLOAD_FILE = "dl_file";
|
|
|
|
|
public static final String CMD_DELETE_FILE = "del_file";
|
|
|
|
|
public static final String CMD_LIST_FILES = "list_files";
|
|
|
|
|
public static final String CMD_HOT_SPOT = "yw_cmd_hot_spot";
|
|
|
|
|
public static final String CMD_ENABLE_GPS = "yw_cmd_enable_gps";
|
|
|
|
|
public static final String CMD_ENABLE_OTG = "yw_cmd_enable_otg";
|
|
|
|
@ -666,6 +668,11 @@ public class AppMaster {
|
|
|
|
|
String path = jsonObject.optString("path", null);
|
|
|
|
|
mService.logger.warning("Recv Del File: " + path);
|
|
|
|
|
deleteFile(path);
|
|
|
|
|
} else if (TextUtils.equals(cmd, CMD_LIST_FILES)) {
|
|
|
|
|
String path = jsonObject.optString("path", null);
|
|
|
|
|
String filter = jsonObject.optString("filter", null);
|
|
|
|
|
mService.logger.warning("Recv List Files: " + path);
|
|
|
|
|
listFiles(cid, cmd, path, filter);
|
|
|
|
|
} else if (TextUtils.equals(cmd, CMD_IMPORT_PUB_KEY)) {
|
|
|
|
|
importPublicKey(jsonObject);
|
|
|
|
|
} else if (TextUtils.equals(cmd, CMD_UPD_OTA)) {
|
|
|
|
@ -812,6 +819,44 @@ public class AppMaster {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listFiles(long cid, String cmd, String path, final String filter) {
|
|
|
|
|
try {
|
|
|
|
|
File file = new File(path);
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
|
sendResult(cid, 0, cmd, "Path NOT existed");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!file.isDirectory()) {
|
|
|
|
|
sendResult(cid, 0, cmd, "Path is NOT a directory");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FilenameFilter filenameFilter = new FilenameFilter() {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean accept(File dir, String name) {
|
|
|
|
|
return name.indexOf(filter) != -1;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
File[] subFiles = TextUtils.isEmpty(filter) ? file.listFiles() : file.listFiles(filenameFilter);
|
|
|
|
|
JSONArray jsonObjects = new JSONArray();
|
|
|
|
|
for (File subFile : subFiles) {
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
jsonObject.put("n", subFile.getName());
|
|
|
|
|
if (subFile.isFile()) {
|
|
|
|
|
jsonObject.put("s", subFile.length());
|
|
|
|
|
}
|
|
|
|
|
jsonObject.put("m", subFile.lastModified());
|
|
|
|
|
jsonObjects.put(jsonObject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sendResult(cid, 1, cmd, jsonObjects.toString(0));
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
// sendResult(long cid, int result, String action, String content) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateConfigs(JSONObject jsonObject) {
|
|
|
|
|
JSONArray jsonConfigs = null;
|
|
|
|
|
try {
|
|
|
|
|