|
|
@ -195,7 +195,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
|
|
Log.d(TAG, "MainActivity: reboot=" + rebootFlag + " noDelay=" + noDelay);
|
|
|
|
Log.d(TAG, "MainActivity: reboot=" + rebootFlag + " noDelay=" + noDelay);
|
|
|
|
|
|
|
|
|
|
|
|
MicroPhotoContext.AppConfig appConfig = getAppConfig();
|
|
|
|
final MicroPhotoContext.AppConfig appConfig = getAppConfig();
|
|
|
|
if (TextUtils.isEmpty(appConfig.cmdid)) {
|
|
|
|
if (TextUtils.isEmpty(appConfig.cmdid)) {
|
|
|
|
appConfig.cmdid = MicroPhotoService.getSerialNumber();
|
|
|
|
appConfig.cmdid = MicroPhotoService.getSerialNumber();
|
|
|
|
binding.cmdid.setText(appConfig.cmdid);
|
|
|
|
binding.cmdid.setText(appConfig.cmdid);
|
|
|
@ -361,11 +361,6 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
|
|
|
|
|
|
|
// Intent intent = new Intent(MainActivity.this, MicroPhotoService.class);
|
|
|
|
|
|
|
|
// intent.setAction(MicroPhotoService.ACTION_STOP);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// MainActivity.this.stopService(intent);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MicroPhotoService.stopTerminalService(getApplicationContext());
|
|
|
|
MicroPhotoService.stopTerminalService(getApplicationContext());
|
|
|
|
|
|
|
|
|
|
|
|
binding.btnStartServ.setEnabled(true);
|
|
|
|
binding.btnStartServ.setEnabled(true);
|
|
|
@ -373,32 +368,6 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
binding.simchange.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// defaultDataSubId = getDefaultDataSubId();
|
|
|
|
|
|
|
|
// System.out.println(defaultDataSubId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
binding.simchange2.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
if (defaultDataSubId == 0) {
|
|
|
|
|
|
|
|
setDefaultDataSubId(1);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (defaultDataSubId == 1) {
|
|
|
|
|
|
|
|
setDefaultDataSubId(2);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
setDefaultDataSubId(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
binding.btnChannels.setOnClickListener(new View.OnClickListener() {
|
|
|
|
binding.btnChannels.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
public void onClick(View v) {
|
|
|
@ -407,93 +376,31 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
binding.gps.setOnClickListener(new View.OnClickListener() {
|
|
|
|
if (MicroPhotoService.isRunning) {
|
|
|
|
@Override
|
|
|
|
Intent intent2 = new Intent(MainActivity.this, MicroPhotoService.class);
|
|
|
|
public void onClick(View view) {
|
|
|
|
try {
|
|
|
|
// gpsTake();
|
|
|
|
stopService(intent2);
|
|
|
|
startLocate();
|
|
|
|
} catch (Exception ex) {
|
|
|
|
// LocationUtils.unregister();
|
|
|
|
ex.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
binding.netgps.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
|
|
|
// startLocate();
|
|
|
|
|
|
|
|
boolean gpsEnabled = LocationUtil.isGpsEnabled(MainActivity.this);
|
|
|
|
|
|
|
|
System.out.printf("g" + gpsEnabled);
|
|
|
|
|
|
|
|
LocationUtil.register(MainActivity.this, 0, 0, new LocationUtil.OnLocationChangeListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void getLastKnownLocation(Location location) {
|
|
|
|
|
|
|
|
Log.e("xyh", "onLocationChanged: " + location.getLatitude());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onLocationChanged(Location location) {
|
|
|
|
|
|
|
|
//位置信息变化时触发
|
|
|
|
|
|
|
|
Log.e("xyh", "定位方式:" + location.getProvider());
|
|
|
|
|
|
|
|
Log.e("xyh", "纬度:" + location.getLatitude());
|
|
|
|
|
|
|
|
Log.e("xyh", "经度:" + location.getLongitude());
|
|
|
|
|
|
|
|
Log.e("xyh", "海拔:" + location.getAltitude());
|
|
|
|
|
|
|
|
Log.e("xyh", "时间:" + location.getTime());
|
|
|
|
|
|
|
|
Log.e("xyh", "国家:" + LocationUtil.getCountryName(MainActivity.this, location.getLatitude(), location.getLongitude()));
|
|
|
|
|
|
|
|
Log.e("xyh", "获取地理位置:" + LocationUtil.getAddress(MainActivity.this, location.getLatitude(), location.getLongitude()));
|
|
|
|
|
|
|
|
Log.e("xyh", "所在地:" + LocationUtil.getLocality(MainActivity.this, location.getLatitude(), location.getLongitude()));
|
|
|
|
|
|
|
|
Log.e("xyh", "所在街道:" + LocationUtil.getStreet(MainActivity.this, location.getLatitude(), location.getLongitude()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onStatusChanged(String provider, int status, Bundle extras) {
|
|
|
|
|
|
|
|
System.out.println("dfsad");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!MicroPhotoService.isRunning && !TextUtils.isEmpty(appConfig.cmdid) && !TextUtils.isEmpty(appConfig.server) && appConfig.port != 0) {
|
|
|
|
|
|
|
|
Handler handler = new Handler();
|
|
|
|
|
|
|
|
Runnable runnable = new Runnable() {
|
|
|
|
Runnable runnable = new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!MicroPhotoService.isRunning && !TextUtils.isEmpty(appConfig.cmdid) && !TextUtils.isEmpty(appConfig.server) && appConfig.port != 0) {
|
|
|
|
if (binding.btnStartServ.isEnabled()) {
|
|
|
|
if (binding.btnStartServ.isEnabled()) {
|
|
|
|
binding.btnStartServ.performClick();
|
|
|
|
binding.btnStartServ.performClick();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
handler.postDelayed(runnable, noDelay != 0 ? 1000 : 5000);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
mHandler.postDelayed(runnable, noDelay != 0 ? 1000 : 5000);
|
|
|
|
|
|
|
|
|
|
|
|
binding.btnStartServ.setEnabled(!MicroPhotoService.isRunning);
|
|
|
|
binding.btnStartServ.setEnabled(!MicroPhotoService.isRunning);
|
|
|
|
binding.btnStopServ.setEnabled(MicroPhotoService.isRunning);
|
|
|
|
binding.btnStopServ.setEnabled(MicroPhotoService.isRunning);
|
|
|
|
|
|
|
|
|
|
|
|
binding.tcpudp.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
|
|
|
// initSocket();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
binding.tcpudpsend.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
|
|
|
// byte[] bytes = {(byte) 0xA5, 0x5A, 0x04, 0x00, 0x58, 0x59, 0x49, 0x47, 0x51, 0x31, 0x30, 0x44, 0x32, 0x32, 0x31, 0x30, 0x30, 0x30, 0x31, 0x30, 0x30, 0x07, (byte) 0xE7, 0x37, (byte) 0x86, (byte) 0x96, (byte) 0xD4, 0x64, (byte) 0xB5, (byte) 0xFB, (byte) 0x96};
|
|
|
|
|
|
|
|
byte[] bytes = {(byte) 0xA5, 0x5A, 0x04, 0x00, 0x58, 0x59, 0x49, 0x47, 0x51, 0x31, 0x30, 0x44, 0x32, 0x32, 0x31, 0x30, 0x30, 0x30, 0x31, 0x30, 0x30, 0x07, (byte) 0xE6, (byte) 0xEA, 0x52, (byte) 0xB7, (byte) 0xD4, 0x64, 0x5C, 0x7E, (byte) 0x96};
|
|
|
|
|
|
|
|
// NettyChatClient.getInstance().sendByteMessage(bytes);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
binding.video.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
binding.video2.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
binding.btnSendHb.setOnClickListener(new View.OnClickListener() {
|
|
|
|
binding.btnSendHb.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
public void onClick(View v) {
|
|
|
@ -563,6 +470,12 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onDestroy() {
|
|
|
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
|
|
|
// System.exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void startMicroPhotoService(Context context, MicroPhotoContext.AppConfig curAppConfig, Messenger messenger) {
|
|
|
|
public static void startMicroPhotoService(Context context, MicroPhotoContext.AppConfig curAppConfig, Messenger messenger) {
|
|
|
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(curAppConfig.cmdid) || TextUtils.isEmpty(curAppConfig.server) || curAppConfig.port == 0) {
|
|
|
|
if (TextUtils.isEmpty(curAppConfig.cmdid) || TextUtils.isEmpty(curAppConfig.server) || curAppConfig.port == 0) {
|
|
|
@ -690,10 +603,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onDestroy() {
|
|
|
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setDefaultDataSubId(int subId) {
|
|
|
|
private void setDefaultDataSubId(int subId) {
|
|
|
|
SubscriptionManager subscriptionManager = (SubscriptionManager) getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
|
|
|
SubscriptionManager subscriptionManager = (SubscriptionManager) getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
|
|
|