|
|
|
@ -1,12 +1,10 @@
|
|
|
|
|
package com.xypower.mpremote;
|
|
|
|
|
|
|
|
|
|
import androidx.appcompat.app.ActionBar;
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
|
|
import android.app.AlertDialog;
|
|
|
|
|
import android.app.ProgressDialog;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.content.res.Resources;
|
|
|
|
|
import android.database.Cursor;
|
|
|
|
@ -15,11 +13,8 @@ import android.os.Bundle;
|
|
|
|
|
import android.os.Handler;
|
|
|
|
|
import android.text.Html;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.text.format.Formatter;
|
|
|
|
|
import android.util.Base64;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.Menu;
|
|
|
|
|
import android.view.MenuItem;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
@ -28,12 +23,12 @@ import com.xypower.common.JSONUtils;
|
|
|
|
|
import com.xypower.common.MicroPhotoContext;
|
|
|
|
|
import com.xypower.mpremote.databinding.ActivityDeviceBinding;
|
|
|
|
|
import com.xypower.mpremote.utils.AdbUtils;
|
|
|
|
|
import com.xypower.mpremote.utils.AlertDialogUtils;
|
|
|
|
|
import com.xypower.mpremote.utils.FileUtils;
|
|
|
|
|
|
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
import org.w3c.dom.Text;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.net.Socket;
|
|
|
|
|
import java.nio.charset.Charset;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
@ -43,198 +38,94 @@ import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import dadb.AdbKeyPair;
|
|
|
|
|
import dadb.AdbShellResponse;
|
|
|
|
|
import dadb.Dadb;
|
|
|
|
|
|
|
|
|
|
public class DeviceActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
public class DeviceActivity extends AppCompatActivity implements View.OnClickListener {
|
|
|
|
|
private static final String TAG = "ADB";
|
|
|
|
|
|
|
|
|
|
private static final boolean DEBUG = false;
|
|
|
|
|
|
|
|
|
|
public static final int RSSI_LEVELS = 5;
|
|
|
|
|
|
|
|
|
|
private static final String PACKAGE_NAME_MP = "com.xypower.mpapp";
|
|
|
|
|
private static final String REMOTE_PATH_ROOT = "/sdcard/" + PACKAGE_NAME_MP + "/";
|
|
|
|
|
private static final String REMOTE_PATH_DATA = REMOTE_PATH_ROOT + "data/";
|
|
|
|
|
private static final String REMOTE_PATH_DATA_CHANNELS = REMOTE_PATH_ROOT + "data/channels/";
|
|
|
|
|
private static final String REMOTE_PATH_PHOTOS = REMOTE_PATH_ROOT + "photos/";
|
|
|
|
|
private static final String REMOTE_PATH_TMP = REMOTE_PATH_ROOT + "tmp/";
|
|
|
|
|
|
|
|
|
|
private static final String KEY_APP_BV = "app.bv";
|
|
|
|
|
private static final String KEY_APP_BCV = "app.bcv";
|
|
|
|
|
private static final String KEY_RO_SERIALNO = "ro.serialno";
|
|
|
|
|
private static final String KEY_RO_CUSTOM_OTA_VERSION = "ro.custom.ota.version";
|
|
|
|
|
private static final String KEY_RO_MODEMS_MAX_COUNT = "telephony.active_modems.max_count";
|
|
|
|
|
// ro.telephony.sim.count
|
|
|
|
|
private static final String KEY_RO_SIGNAL_STRNGTH_PREFIX = "vendor.ril.nw.signalstrength.lte.";
|
|
|
|
|
|
|
|
|
|
private static final String KEY_RO_ICCID_PREFIX = "persist.vendor.radio.cfu.iccid.";
|
|
|
|
|
|
|
|
|
|
private static final String KEY_GSM_VENDOR_NAME = "gsm.operator.alpha";
|
|
|
|
|
|
|
|
|
|
// private static final String KEY_RO_MODEMS_MAX_COUNT = "telephony.active_modems.max_count";
|
|
|
|
|
|
|
|
|
|
// // [ro.bootimage.build.date.utc]: [1716880263]
|
|
|
|
|
// // [ro.build.date.utc]: [1716880263]
|
|
|
|
|
// // [ro.product.model]: [MSRDT-1-WP]
|
|
|
|
|
// // [ro.serialno]: [XYV12WPC202406215]
|
|
|
|
|
// // [telephony.active_modems.max_count]: [2]
|
|
|
|
|
// // [vendor.ril.nw.signalstrength.lte.1]: [-93,-2]
|
|
|
|
|
// //[vendor.ril.nw.signalstrength.lte.2]: [-103,21]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String KEY_APP_MP_VERSION = "mpapp.version";
|
|
|
|
|
|
|
|
|
|
private static final String KEY_PREFIX_GLOBAL_SETTING = "settings.global.";
|
|
|
|
|
|
|
|
|
|
private static final String KEY_IMEI = KEY_PREFIX_GLOBAL_SETTING + "dev_imei";
|
|
|
|
|
private static final String KEY_IMEI2 = KEY_PREFIX_GLOBAL_SETTING + "dev_imei2";
|
|
|
|
|
|
|
|
|
|
// [vendor.ril.nw.signalstrength.lte.1]: [-85,27]
|
|
|
|
|
//[vendor.ril.nw.signalstrength.lte.2]: [-86,27]
|
|
|
|
|
|
|
|
|
|
private ActivityDeviceBinding binding;
|
|
|
|
|
private ProgressDialog mProgressDialog;
|
|
|
|
|
private Handler mHandler;
|
|
|
|
|
private Handler mHandler = new Handler();
|
|
|
|
|
private String mCmdId;
|
|
|
|
|
private String mDeviceIp;
|
|
|
|
|
|
|
|
|
|
private Map<String, String> mProps = new HashMap<>();
|
|
|
|
|
private Map<Integer, JSONObject> mChannelCfgs = new HashMap();
|
|
|
|
|
private String mSerialNo = "";
|
|
|
|
|
|
|
|
|
|
private MicroPhotoContext.AppConfig mAppConfig = new MicroPhotoContext.AppConfig();
|
|
|
|
|
private int mBatteryVoltage = -1;
|
|
|
|
|
private int mBatteryChargingVoltage = -1;
|
|
|
|
|
private String mDeviceIp;
|
|
|
|
|
private String localIp;
|
|
|
|
|
private String configPath;//存放App配置文件
|
|
|
|
|
private String tmp;//存放配置文件的目录
|
|
|
|
|
private AlertDialog alertDialog;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
|
|
binding = ActivityDeviceBinding.inflate(getLayoutInflater());
|
|
|
|
|
setContentView(binding.getRoot());
|
|
|
|
|
|
|
|
|
|
ActionBar actionBar = getSupportActionBar();
|
|
|
|
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
|
|
|
// actionBar.setTitle(R.string.title_activity_device);
|
|
|
|
|
|
|
|
|
|
Intent intent = getIntent();
|
|
|
|
|
mDeviceIp = intent.getStringExtra("deviceIp");
|
|
|
|
|
|
|
|
|
|
mHandler = new Handler();
|
|
|
|
|
|
|
|
|
|
binding.takePhoto1.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
takePhoto(1, 255, true);
|
|
|
|
|
initData();
|
|
|
|
|
initView();
|
|
|
|
|
initEvent();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
binding.takeVideo1.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
takeVideo(1, 255, false);
|
|
|
|
|
private void initEvent() {
|
|
|
|
|
//加载设备信息
|
|
|
|
|
loadDeviceInfo( true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
binding.takePhoto2.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
takePhoto(2, 255, true);
|
|
|
|
|
private void initView() {
|
|
|
|
|
binding.takePhoto1.setOnClickListener(this);
|
|
|
|
|
binding.takePhoto2.setOnClickListener(this);
|
|
|
|
|
binding.takePhoto3.setOnClickListener(this);
|
|
|
|
|
binding.takePhoto4.setOnClickListener(this);
|
|
|
|
|
binding.takeVideo1.setOnClickListener(this);
|
|
|
|
|
binding.takeVideo2.setOnClickListener(this);
|
|
|
|
|
binding.takeVideo3.setOnClickListener(this);
|
|
|
|
|
binding.takeVideo4.setOnClickListener(this);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
binding.takeVideo2.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
takeVideo(2, 255, false);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
binding.takePhoto3.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
takePhoto(3, 255, true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
binding.takeVideo3.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
takeVideo(3, 255, false);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
binding.takePhoto4.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
takePhoto(4, 255, true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
binding.takeVideo4.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
takeVideo(4, 255, false);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
private void initData() {
|
|
|
|
|
Intent intent = getIntent();
|
|
|
|
|
mDeviceIp = intent.getStringExtra("deviceIp");//
|
|
|
|
|
localIp = intent.getStringExtra("localIp");//
|
|
|
|
|
|
|
|
|
|
final Context context = getApplicationContext();
|
|
|
|
|
loadDeviceInfo(context, true);
|
|
|
|
|
//获取配置文件在本机的存储路径
|
|
|
|
|
tmp = FileUtils.join(getFilesDir(), "tmp");
|
|
|
|
|
configPath = FileUtils.join(tmp, "App.json");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onDestroy() {
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
|
|
|
|
|
AdbManager.releaseAdb(mDeviceIp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void loadDeviceInfo(final Context context, boolean firstConnect) {
|
|
|
|
|
|
|
|
|
|
protected void loadDeviceInfo(boolean firstConnect) {
|
|
|
|
|
binding.deviceInfo.setText("");
|
|
|
|
|
|
|
|
|
|
String msg = firstConnect ? "连接" + mDeviceIp + "中" : "刷新数据中";
|
|
|
|
|
mProgressDialog = ProgressDialog.show(this, "", msg, true, true);
|
|
|
|
|
mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onCancel(DialogInterface dialogInterface) {
|
|
|
|
|
DeviceActivity.this.finish();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
final File fileTmp = new File(getFilesDir(), "tmp");
|
|
|
|
|
if (!fileTmp.exists()) {
|
|
|
|
|
fileTmp.mkdirs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(new Thread(new Runnable() {
|
|
|
|
|
alertDialog = AlertDialogUtils.show(this, msg);
|
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
runImpl();
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mHandler.post(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
mProgressDialog.dismiss();
|
|
|
|
|
alertDialog.dismiss();
|
|
|
|
|
showAppInfo();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}).start();
|
|
|
|
|
}
|
|
|
|
|
private void runImpl() {
|
|
|
|
|
Log.d(TAG, "Adb discovering " + mDeviceIp);
|
|
|
|
|
|
|
|
|
|
Dadb adb = AdbManager.getAdb(mDeviceIp, AdbUtils.DEFAULT_ADB_PORT);
|
|
|
|
|
|
|
|
|
|
Log.d(TAG, "Adb Connected");
|
|
|
|
|
if (adb == null) {
|
|
|
|
|
mHandler.postDelayed(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
@ -244,19 +135,16 @@ public class DeviceActivity extends AppCompatActivity {
|
|
|
|
|
}, 100);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Log.d(TAG, mDeviceIp + " Connected");
|
|
|
|
|
boolean res = false;
|
|
|
|
|
|
|
|
|
|
File appConfigFile = new File(fileTmp, "App.json");
|
|
|
|
|
res = pullFile(adb, REMOTE_PATH_DATA + "App.json", appConfigFile);
|
|
|
|
|
File file = FileUtils.getFile(configPath);
|
|
|
|
|
if (file != null) {
|
|
|
|
|
res = pullFile(adb, Constants.REMOTE_PATH_DATA + "App.json", file);
|
|
|
|
|
}
|
|
|
|
|
if (res) {
|
|
|
|
|
|
|
|
|
|
final MicroPhotoContext.AppConfig appConfig = MicroPhotoContext.getMpAppConfig(context, appConfigFile.getAbsolutePath());
|
|
|
|
|
final MicroPhotoContext.AppConfig appConfig = MicroPhotoContext.getMpAppConfig(getApplicationContext(), configPath);
|
|
|
|
|
if (appConfig != null) {
|
|
|
|
|
mAppConfig = appConfig;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DeviceActivity.this.mHandler.post(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
@ -264,9 +152,6 @@ public class DeviceActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Log.d(TAG, "App.json Pulled");
|
|
|
|
|
|
|
|
|
|
final int numberOfChannels = (mAppConfig != null) ? mAppConfig.channels : 0;
|
|
|
|
|
mHandler.post(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
@ -274,35 +159,28 @@ public class DeviceActivity extends AppCompatActivity {
|
|
|
|
|
updateButtons(numberOfChannels);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
mChannelCfgs.clear();
|
|
|
|
|
if (mAppConfig != null && mAppConfig.channels > 0) {
|
|
|
|
|
for (int channel = 1; channel <= mAppConfig.channels; channel++) {
|
|
|
|
|
String remoteFilePath = REMOTE_PATH_DATA_CHANNELS + Integer.toString(channel) + ".json";
|
|
|
|
|
File localFilePath = new File(fileTmp, Integer.toString(channel) + ".json");
|
|
|
|
|
if (localFilePath.exists()) {
|
|
|
|
|
localFilePath.delete();
|
|
|
|
|
}
|
|
|
|
|
res = pullFile(adb, remoteFilePath, localFilePath);
|
|
|
|
|
String remoteFilePath = Constants.REMOTE_PATH_DATA_CHANNELS + Integer.toString(channel) + ".json";
|
|
|
|
|
String join = FileUtils.join(tmp, Integer.toString(channel) + ".json");
|
|
|
|
|
File channelfile = FileUtils.getFile(join);
|
|
|
|
|
res = pullFile(adb, remoteFilePath, channelfile);
|
|
|
|
|
if (res) {
|
|
|
|
|
JSONObject channelJson = JSONUtils.loadJson(localFilePath.getAbsolutePath());
|
|
|
|
|
JSONObject channelJson = JSONUtils.loadJson(channelfile.getAbsolutePath());
|
|
|
|
|
if (channelJson != null) {
|
|
|
|
|
mChannelCfgs.put(new Integer(channel), channelJson);
|
|
|
|
|
}
|
|
|
|
|
localFilePath.delete();
|
|
|
|
|
channelfile.delete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Log.d(TAG, "Channel config Pulled");
|
|
|
|
|
|
|
|
|
|
AdbShellResponse adbShellResponse = null;
|
|
|
|
|
try {
|
|
|
|
|
adbShellResponse = adb.shell("settings list global");
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (adbShellResponse.getExitCode() == 0) {
|
|
|
|
|
String[] lines = FilesUtils.splitLines(adbShellResponse.getAllOutput());
|
|
|
|
|
for (String line : lines) {
|
|
|
|
@ -310,20 +188,16 @@ public class DeviceActivity extends AppCompatActivity {
|
|
|
|
|
if (pos != -1) {
|
|
|
|
|
String key = line.substring(0, pos);
|
|
|
|
|
String val = line.substring(pos + 1);
|
|
|
|
|
mProps.put(KEY_PREFIX_GLOBAL_SETTING + key, val);
|
|
|
|
|
mProps.put(Constants.KEY_PREFIX_GLOBAL_SETTING + key, val);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Log.d(TAG, "Global settings Pulled");
|
|
|
|
|
|
|
|
|
|
adbShellResponse = null;
|
|
|
|
|
try {
|
|
|
|
|
adbShellResponse = adb.shell("getprop");
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (adbShellResponse.getExitCode() == 0) {
|
|
|
|
|
String[] lines = FilesUtils.splitLines(adbShellResponse.getAllOutput());
|
|
|
|
|
for (String line : lines) {
|
|
|
|
@ -335,34 +209,27 @@ public class DeviceActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Log.d(TAG, "getprop Finished");
|
|
|
|
|
|
|
|
|
|
if (mProps.containsKey(KEY_RO_SERIALNO)) {
|
|
|
|
|
mSerialNo = (String)mProps.get(KEY_RO_SERIALNO);
|
|
|
|
|
if (mProps.containsKey(Constants.KEY_RO_SERIALNO)) {
|
|
|
|
|
mSerialNo = (String)mProps.get(Constants.KEY_RO_SERIALNO);
|
|
|
|
|
}
|
|
|
|
|
// adb shell pm dump com.xypower.mpremote | grep "versionName"
|
|
|
|
|
adbShellResponse = null;
|
|
|
|
|
try {
|
|
|
|
|
adbShellResponse = adb.shell("pm dump " + PACKAGE_NAME_MP + " | grep \"versionName\"");
|
|
|
|
|
adbShellResponse = adb.shell("pm dump " + Constants.PACKAGE_NAME_MP + " | grep \"versionName\"");
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (adbShellResponse.getExitCode() == 0) {
|
|
|
|
|
String[] lines = FilesUtils.splitLines(adbShellResponse.getAllOutput());
|
|
|
|
|
for (String line : lines) {
|
|
|
|
|
int pos = line.indexOf("versionName=");
|
|
|
|
|
if (pos != -1) {
|
|
|
|
|
String val = line.substring(pos + 12);
|
|
|
|
|
mProps.put(KEY_APP_MP_VERSION, val);
|
|
|
|
|
mProps.put(Constants.KEY_APP_MP_VERSION, val);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Log.d(TAG, "Dump App version Finished");
|
|
|
|
|
|
|
|
|
|
String cmd = "content query --uri content://com.xypower.mpapp.provider/queryBatVol";
|
|
|
|
|
adbShellResponse = null;
|
|
|
|
|
try {
|
|
|
|
@ -370,14 +237,12 @@ public class DeviceActivity extends AppCompatActivity {
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (adbShellResponse.getExitCode() == 0) {
|
|
|
|
|
Cursor cursor = AdbUtils.parseContentResponse(adbShellResponse.getAllOutput());
|
|
|
|
|
if (cursor != null && cursor.getCount() > 0) {
|
|
|
|
|
cursor.moveToFirst();
|
|
|
|
|
@SuppressLint("Range") String bv = cursor.getString(cursor.getColumnIndex("bv"));
|
|
|
|
|
@SuppressLint("Range") String bcv = cursor.getString(cursor.getColumnIndex("bcv"));
|
|
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(bv)) {
|
|
|
|
|
mBatteryVoltage = Integer.parseInt(bv);
|
|
|
|
|
}
|
|
|
|
@ -386,19 +251,11 @@ public class DeviceActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Log.d(TAG, "queryBatVol Finished");
|
|
|
|
|
}
|
|
|
|
|
})).start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected boolean pullFile(Dadb adb, String remoteFilePath, File localFilePath) {
|
|
|
|
|
if (localFilePath.exists()) {
|
|
|
|
|
localFilePath.delete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Log.i(TAG, "PULL: " + remoteFilePath);
|
|
|
|
|
|
|
|
|
|
boolean res = false;
|
|
|
|
|
try {
|
|
|
|
|
adb.pull(localFilePath, remoteFilePath);
|
|
|
|
@ -406,7 +263,6 @@ public class DeviceActivity extends AppCompatActivity {
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res && localFilePath.exists();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -507,7 +363,7 @@ public class DeviceActivity extends AppCompatActivity {
|
|
|
|
|
int cameraId = channel - 1;
|
|
|
|
|
|
|
|
|
|
final String fileName = "IMG-" + Integer.toString(channel) + "-" + simpleDateFormat.format(dt) + (photoOrVideo ? ".jpg" : ".mp4");
|
|
|
|
|
final String remoteFilePath = REMOTE_PATH_TMP + fileName;
|
|
|
|
|
final String remoteFilePath = Constants.REMOTE_PATH_TMP + fileName;
|
|
|
|
|
|
|
|
|
|
String leftTopOsd = "";
|
|
|
|
|
if (mAppConfig != null) {
|
|
|
|
@ -529,7 +385,7 @@ public class DeviceActivity extends AppCompatActivity {
|
|
|
|
|
cameraId = channelJson.optInt("cameraId", cameraId);
|
|
|
|
|
}
|
|
|
|
|
// content update --uri content://com.xypower.mpapp.provider/importPriKey
|
|
|
|
|
final String cmd = "content update --uri content://" + PACKAGE_NAME_MP + ".provider/takePhoto --bind path:s:\""
|
|
|
|
|
final String cmd = "content update --uri content://" + Constants.PACKAGE_NAME_MP + ".provider/takePhoto --bind path:s:\""
|
|
|
|
|
+ remoteFilePath + "\" --bind usb:b:" + usb + " --bind cameraId:i:" + Integer.toString(cameraId) + " --bind channel:i:"
|
|
|
|
|
+ Integer.toString(channel) + " --bind preset:i:" + Integer.toString(preset) + " --bind leftTopOsd:s:" + Base64.encodeToString(leftTopOsdBytes, Base64.DEFAULT | Base64.NO_WRAP) + "";
|
|
|
|
|
// adbShellResponse = null;
|
|
|
|
@ -540,8 +396,7 @@ public class DeviceActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected long takeVideo(int channel, int preset, final boolean photoOrVideo) {
|
|
|
|
|
Intent intent = getIntent();
|
|
|
|
|
String localIp = intent.getStringExtra("localIp");
|
|
|
|
|
|
|
|
|
|
showStreaming(channel, channel - 1, "rtmp://" + mDeviceIp + "/live/0", localIp);
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
@ -701,10 +556,7 @@ public class DeviceActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void showAppInfo() {
|
|
|
|
|
ActionBar actionBar = getSupportActionBar();
|
|
|
|
|
|
|
|
|
|
// 视频浏览,拍照,设备信息及状态查询(编号,版本,双SIM卡状态,电池及太阳能电压等),可以参考东视
|
|
|
|
|
|
|
|
|
|
Resources resources = getResources();
|
|
|
|
|
// String buildTime = BuildConfig.BUILD_
|
|
|
|
|
// Date date = new Date(BuildConfig.BUILD_TIMESTAMP);
|
|
|
|
@ -714,32 +566,31 @@ public class DeviceActivity extends AppCompatActivity {
|
|
|
|
|
if (mAppConfig != null && !TextUtils.isEmpty(mAppConfig.cmdid)) {
|
|
|
|
|
title = mAppConfig.cmdid;
|
|
|
|
|
}
|
|
|
|
|
actionBar.setTitle(title);
|
|
|
|
|
|
|
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
ConnectivityManager mConnectivityManager;
|
|
|
|
|
|
|
|
|
|
if (mProps.containsKey(KEY_RO_SERIALNO)) {
|
|
|
|
|
String val = (String)mProps.get(KEY_RO_SERIALNO);
|
|
|
|
|
if (mProps.containsKey(Constants.KEY_RO_SERIALNO)) {
|
|
|
|
|
String val = (String)mProps.get(Constants.KEY_RO_SERIALNO);
|
|
|
|
|
appendKeyValue(stringBuilder, "序列号", val, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mProps.containsKey(KEY_RO_CUSTOM_OTA_VERSION)) {
|
|
|
|
|
String val = (String)mProps.get(KEY_RO_CUSTOM_OTA_VERSION);
|
|
|
|
|
if (mProps.containsKey(Constants.KEY_RO_CUSTOM_OTA_VERSION)) {
|
|
|
|
|
String val = (String)mProps.get(Constants.KEY_RO_CUSTOM_OTA_VERSION);
|
|
|
|
|
appendKeyValue(stringBuilder, "系统版本", val, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int numberOfSimcard = 0;
|
|
|
|
|
if (mProps.containsKey(KEY_RO_MODEMS_MAX_COUNT)) {
|
|
|
|
|
String val = (String)mProps.get(KEY_RO_MODEMS_MAX_COUNT);
|
|
|
|
|
if (mProps.containsKey(Constants.KEY_RO_MODEMS_MAX_COUNT)) {
|
|
|
|
|
String val = (String)mProps.get(Constants.KEY_RO_MODEMS_MAX_COUNT);
|
|
|
|
|
numberOfSimcard = Integer.parseInt(val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String signalLevel = "";
|
|
|
|
|
List<String> iccids = new ArrayList<>();
|
|
|
|
|
for (int idx = 1; idx <= numberOfSimcard; idx++) {
|
|
|
|
|
String key = KEY_RO_SIGNAL_STRNGTH_PREFIX + Integer.toString(idx);
|
|
|
|
|
String key = Constants.KEY_RO_SIGNAL_STRNGTH_PREFIX + Integer.toString(idx);
|
|
|
|
|
if (mProps.containsKey(key)) {
|
|
|
|
|
String val = (String)mProps.get(key);
|
|
|
|
|
int pos = val.indexOf(",");
|
|
|
|
@ -755,7 +606,7 @@ public class DeviceActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
key = KEY_RO_ICCID_PREFIX + Integer.toString(idx - 1);
|
|
|
|
|
key = Constants.KEY_RO_ICCID_PREFIX + Integer.toString(idx - 1);
|
|
|
|
|
if (mProps.containsKey(key)) {
|
|
|
|
|
String val = (String)mProps.get(key);
|
|
|
|
|
byte[] bytes = Base64.decode(val, Base64.DEFAULT);
|
|
|
|
@ -770,14 +621,14 @@ public class DeviceActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
appendKeyValue(stringBuilder, "通道数", Integer.toString(mAppConfig.channels));
|
|
|
|
|
|
|
|
|
|
if (mProps.containsKey(KEY_APP_MP_VERSION)) {
|
|
|
|
|
String val = (String)mProps.get(KEY_APP_MP_VERSION);
|
|
|
|
|
if (mProps.containsKey(Constants.KEY_APP_MP_VERSION)) {
|
|
|
|
|
String val = (String)mProps.get(Constants.KEY_APP_MP_VERSION);
|
|
|
|
|
appendKeyValue(stringBuilder, "APP版本", val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String vendorName = "";
|
|
|
|
|
if (mProps.containsKey(KEY_GSM_VENDOR_NAME)) {
|
|
|
|
|
vendorName = mProps.get(KEY_GSM_VENDOR_NAME);
|
|
|
|
|
if (mProps.containsKey(Constants.KEY_GSM_VENDOR_NAME)) {
|
|
|
|
|
vendorName = mProps.get(Constants.KEY_GSM_VENDOR_NAME);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
appendKeyValue(stringBuilder, "移动运营商", vendorName);
|
|
|
|
@ -786,13 +637,13 @@ public class DeviceActivity extends AppCompatActivity {
|
|
|
|
|
appendKeyValue(stringBuilder, "ICCID", iccid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mProps.containsKey(KEY_IMEI)) {
|
|
|
|
|
String val = (String)mProps.get(KEY_IMEI);
|
|
|
|
|
if (mProps.containsKey(Constants.KEY_IMEI)) {
|
|
|
|
|
String val = (String)mProps.get(Constants.KEY_IMEI);
|
|
|
|
|
appendKeyValue(stringBuilder, "IMEI1", val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mProps.containsKey(KEY_IMEI2)) {
|
|
|
|
|
String val = (String)mProps.get(KEY_IMEI2);
|
|
|
|
|
if (mProps.containsKey(Constants.KEY_IMEI2)) {
|
|
|
|
|
String val = (String)mProps.get(Constants.KEY_IMEI2);
|
|
|
|
|
appendKeyValue(stringBuilder, "IMEI2", val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -819,25 +670,36 @@ public class DeviceActivity extends AppCompatActivity {
|
|
|
|
|
stringBuilder.append("<br>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
|
|
// Inflate the menu; this adds items to the action bar if it is present.
|
|
|
|
|
getMenuInflater().inflate(R.menu.device_activity_actions, menu);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
|
case android.R.id.home:
|
|
|
|
|
finish();
|
|
|
|
|
return false;
|
|
|
|
|
case R.id.action_refresh:
|
|
|
|
|
loadDeviceInfo(getApplicationContext(), false);
|
|
|
|
|
return false;
|
|
|
|
|
default:
|
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
switch (v.getId()) {
|
|
|
|
|
case R.id.takePhoto1:
|
|
|
|
|
takePhoto(1, 255, true);
|
|
|
|
|
break;
|
|
|
|
|
case R.id.takePhoto2:
|
|
|
|
|
takePhoto(2, 255, true);
|
|
|
|
|
break;
|
|
|
|
|
case R.id.takePhoto3:
|
|
|
|
|
takePhoto(3, 255, true);
|
|
|
|
|
break;
|
|
|
|
|
case R.id.takePhoto4:
|
|
|
|
|
takePhoto(4, 255, true);
|
|
|
|
|
break;
|
|
|
|
|
case R.id.takeVideo1:
|
|
|
|
|
takeVideo(1, 255, false);
|
|
|
|
|
break;
|
|
|
|
|
case R.id.takeVideo2:
|
|
|
|
|
takeVideo(2, 255, false);
|
|
|
|
|
break;
|
|
|
|
|
case R.id.takeVideo3:
|
|
|
|
|
takeVideo(3, 255, false);
|
|
|
|
|
break;
|
|
|
|
|
case R.id.takeVideo4:
|
|
|
|
|
takeVideo(4, 255, false);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|