diff --git a/app/build.gradle b/app/build.gradle index b240214a..1edf199f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,7 +5,7 @@ plugins { // 10,00,000 major-minor-build def AppMajorVersion = 1 def AppMinorVersion = 3 -def AppBuildNumber = 15 +def AppBuildNumber = 19 def AppVersionName = AppMajorVersion + "." + AppMinorVersion + "." + AppBuildNumber def AppVersionCode = AppMajorVersion * 100000 + AppMinorVersion * 1000 + AppBuildNumber diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index 393acd36..ab571788 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -46,12 +46,13 @@ add_definitions(-DUSING_HDRPLUS) add_definitions(-DUSING_EXEC_HDRP=1) set(USING_EXEC_HDRP 1) +add_definitions(-DUSING_ETHERNET) if(ANDROID_ABI STREQUAL "armeabi-v7a") add_definitions(-DUSING_N938) elseif(ANDROID_ABI STREQUAL "arm64-v8a") # add_definitions(-DUSING_N938) - add_definitions(-DUSING_PLZ) + # add_definitions(-DUSING_PLZ) endif() # include_directories(${OpenCV_DIR}/include) diff --git a/app/src/main/cpp/GPIOControl.h b/app/src/main/cpp/GPIOControl.h index c66baec4..b07bfa27 100644 --- a/app/src/main/cpp/GPIOControl.h +++ b/app/src/main/cpp/GPIOControl.h @@ -556,7 +556,7 @@ public: PowerControl(CMD_SET_OTG_STATE, CMD_SET_NETWORK_POWER_EN, CMD_SET_PIC1_POWER, CMD_SET_485_EN_STATE, closeDelayTime) #else // USING_N938 #ifdef USING_PLZ - PowerControl(CMD_SET_3V3_PWR_EN, CMD_SET_OTG_STATE, CMD_SET_PTZ_PWR_ENABLE, CMD_SET_100M_ENABLE, CMD_SET_100M_SWITCH_PWR_ENABLE, CMD_SET_485_ENABLE, CMD_SET_12V_EN_STATE, closeDelayTime) + PowerControl(CMD_SET_PTZ_PWR_ENABLE, CMD_SET_485_ENABLE, CMD_SET_12V_EN_STATE, closeDelayTime) #else // USING_PLZ PowerControl(CMD_SET_OTG_STATE, CMD_SET_12V_EN_STATE, closeDelayTime) #endif // USING_PLZ @@ -565,6 +565,23 @@ public: } }; +class EthernetPowerCtrl : public PowerControl +{ +public: + EthernetPowerCtrl(uint32_t closeDelayTime) : +#ifdef USING_N938 + PowerControl(CMD_SET_OTG_STATE, CMD_SET_NETWORK_POWER_EN, closeDelayTime) +#else // USING_N938 +#ifdef USING_PLZ + PowerControl(CMD_SET_3V3_PWR_EN, CMD_SET_OTG_STATE, CMD_SET_100M_ENABLE, CMD_SET_100M_SWITCH_PWR_ENABLE, closeDelayTime) +#else // USING_PLZ + PowerControl(CMD_SET_OTG_STATE, closeDelayTime) +#endif // USING_PLZ +#endif // USING_N938 + { + } +}; + class UsbCameraPowerCtrl : public PowerControl { public: diff --git a/app/src/main/cpp/MicroPhoto.cpp b/app/src/main/cpp/MicroPhoto.cpp index a5b03ead..92cf7bbc 100644 --- a/app/src/main/cpp/MicroPhoto.cpp +++ b/app/src/main/cpp/MicroPhoto.cpp @@ -318,7 +318,7 @@ Java_com_xypower_mpapp_MicroPhotoService_init( CTerminal* pTerminal = NewTerminal(protocol); - CPhoneDevice* device = new CPhoneDevice(vm, pThis, MakeString(appPathStr), NETID_UNSET, versionCode, MakeString(nativeLibraryDirStr)); + CPhoneDevice* device = new CPhoneDevice(vm, pThis, MakeString(appPathStr), (uint64_t)netHandle, versionCode, MakeString(nativeLibraryDirStr)); device->SetListener(pTerminal); device->UpdateSignalLevel(signalLevel); device->SetBuildTime(buildTime / 1000); @@ -941,6 +941,16 @@ Java_com_xypower_mpapp_MicroPhotoService_infoLog( env->ReleaseStringUTFChars(msg, msgStr); } +extern "C" JNIEXPORT jboolean JNICALL +Java_com_xypower_mpapp_MicroPhotoService_usingEthernet( + JNIEnv* env, jclass cls) { +#ifdef USING_ETHERNET + return JNI_TRUE; +#else + return JNI_FALSE; +#endif +} + extern "C" JNIEXPORT void JNICALL Java_com_xypower_mpapp_MicroPhotoService_setOtgState( JNIEnv* env, @@ -1336,7 +1346,34 @@ Java_com_xypower_mpapp_MicroPhotoService_updateEhernet( CPhoneDevice* device = (CPhoneDevice*)pTerminal->GetDevice(); if (device != NULL) { - device->UpdateEthernet(static_cast(networkHandle), available != JNI_FALSE); + bool changed = false; + device->UpdateNetwork(static_cast(networkHandle), available != JNI_FALSE, false, changed); + if (changed) + { + XYLOG(XYLOG_SEVERITY_DEBUG, "Ethernet Changed and Check socket connection"); + pTerminal->ResetNetwork(); + } + } + + return JNI_TRUE; +} + + +extern "C" JNIEXPORT jboolean JNICALL +Java_com_xypower_mpapp_MicroPhotoService_updateActiveNetwork( + JNIEnv* env, jobject pThis, jlong handle, jlong networkHandle, jboolean available) { + + CTerminal* pTerminal = reinterpret_cast(handle); + if (pTerminal == NULL) + { + return JNI_FALSE; + } + + CPhoneDevice* device = (CPhoneDevice*)pTerminal->GetDevice(); + if (device != NULL) + { + bool changed = false; + device->UpdateNetwork(static_cast(networkHandle), available != JNI_FALSE, true, changed); } return JNI_TRUE; diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index bfa69e76..b7a2491f 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -478,8 +478,8 @@ int32_t CPhoneDevice::CJpegCamera::getOutputFormat() const return AIMAGE_FORMAT_JPEG; } -CPhoneDevice::CPhoneDevice(JavaVM* vm, jobject service, const std::string& appPath, unsigned int netId, unsigned int versionCode, const std::string& nativeLibDir) - : mVersionCode(versionCode), m_nativeLibraryDir(nativeLibDir), m_network(NULL), m_ethnetHandle(NETWORK_UNSPECIFIED) +CPhoneDevice::CPhoneDevice(JavaVM* vm, jobject service, const std::string& appPath, uint64_t activeNetHandle, unsigned int versionCode, const std::string& nativeLibDir) + : mVersionCode(versionCode), m_nativeLibraryDir(nativeLibDir), m_network(NULL), m_defNetHandle(activeNetHandle), m_ethnetHandle(NETWORK_UNSPECIFIED) { mCamera = NULL; m_listener = NULL; @@ -490,8 +490,6 @@ CPhoneDevice::CPhoneDevice(JavaVM* vm, jobject service, const std::string& appPa m_javaService = NULL; m_appPath = appPath; - mNetId = netId; - m_signalLevel = 0; m_signalLevelUpdateTime = time(NULL); mBuildTime = 0; @@ -647,6 +645,22 @@ void CPhoneDevice::SetRecognizationCfg(const IDevice::CFG_RECOGNIZATION* pRecogn bool CPhoneDevice::BindNetwork(int sock) { +#ifdef USING_ETHERNET + m_devLocker.lock(); + net_handle_t defNetHandle = m_defNetHandle; + m_devLocker.unlock(); + if (defNetHandle != NETWORK_UNSPECIFIED) + { + int res = android_setsocknetwork(defNetHandle, sock); + if (res == -1) + { + int errcode = errno; + printf("android_setsocknetwork errno=%d", errcode); + } + return res == 0; + } +#endif // USING_ETHERNET + return true; } @@ -1497,6 +1511,9 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c std::this_thread::sleep_for(std::chrono::milliseconds(waitTime)); } + XYLOG(XYLOG_SEVERITY_DEBUG, "Ethernet Power ON"); + std::shared_ptr ethernetPowerCtrl = std::make_shared(1); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); SetStaticIp(); std::this_thread::sleep_for(std::chrono::milliseconds(256)); @@ -1604,6 +1621,9 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c std::this_thread::sleep_for(std::chrono::milliseconds(1000)); } + ethernetPowerCtrl.reset(); + XYLOG(XYLOG_SEVERITY_DEBUG, "Ethernet Power OFF"); + cv::Mat rgb; if (netCaptureResult && !img.empty()) { @@ -3745,13 +3765,28 @@ void CPhoneDevice::UpdateSimcard(const std::string& simcard) m_simcard = simcard; } -void CPhoneDevice::UpdateEthernet(net_handle_t nethandle, bool available) +void CPhoneDevice::UpdateNetwork(net_handle_t nethandle, bool available, bool defaultOrEthernet, bool& changed) { - m_devLocker.lock(); - m_ethnetHandle = available ? nethandle : NETWORK_UNSPECIFIED; - m_devLocker.unlock(); - - XYLOG(XYLOG_SEVERITY_WARNING, "NET Handle: %lld", available ? (uint64_t)nethandle : 0); + if (defaultOrEthernet) + { + net_handle_t oldHandle = NETWORK_UNSPECIFIED; + m_devLocker.lock(); + oldHandle = m_defNetHandle; + m_defNetHandle = available ? nethandle : NETWORK_UNSPECIFIED; + m_devLocker.unlock(); + changed = (oldHandle != nethandle); + XYLOG(XYLOG_SEVERITY_WARNING, "Active Network Handle: %lld", available ? (uint64_t)nethandle : 0); + } + else + { + net_handle_t oldHandle = NETWORK_UNSPECIFIED; + m_devLocker.lock(); + oldHandle = m_ethnetHandle; + m_ethnetHandle = available ? nethandle : NETWORK_UNSPECIFIED; + m_devLocker.unlock(); + changed = (oldHandle != nethandle); + XYLOG(XYLOG_SEVERITY_WARNING, "Ethernet Handle: %lld", available ? (uint64_t)nethandle : 0); + } } net_handle_t CPhoneDevice::GetEthnetHandle() const @@ -3761,7 +3796,6 @@ net_handle_t CPhoneDevice::GetEthnetHandle() const nethandle = m_ethnetHandle; m_devLocker.unlock(); return nethandle; - } void CPhoneDevice::SetStaticIp(const std::string& iface, const std::string& ip, const std::string& netmask, const std::string& gateway) diff --git a/app/src/main/cpp/PhoneDevice.h b/app/src/main/cpp/PhoneDevice.h index fa9e9fed..020b1236 100644 --- a/app/src/main/cpp/PhoneDevice.h +++ b/app/src/main/cpp/PhoneDevice.h @@ -208,7 +208,7 @@ public: uint64_t uid; }; - CPhoneDevice(JavaVM* vm, jobject service, const std::string& appPath, unsigned int netId, unsigned int versionCode, const std::string& nativeLibDir); + CPhoneDevice(JavaVM* vm, jobject service, const std::string& appPath, uint64_t activeNetHandle, unsigned int versionCode, const std::string& nativeLibDir); virtual ~CPhoneDevice(); virtual void SetListener(IListener* listener); @@ -260,7 +260,7 @@ public: mBuildTime = buildTime; } void UpdateSimcard(const std::string& simcard); - void UpdateEthernet(net_handle_t nethandle, bool available); + void UpdateNetwork(net_handle_t nethandle, bool available, bool defaultOrEthernet, bool& changed); net_handle_t GetEthnetHandle() const; @@ -354,6 +354,7 @@ protected: std::string m_nativeLibraryDir; NETWORK* m_network; + net_handle_t m_defNetHandle; net_handle_t m_ethnetHandle; jmethodID mRegisterHeartbeatMid; @@ -383,7 +384,6 @@ protected: IListener* m_listener; const CFG_RECOGNIZATION* m_pRecognizationCfg; bool mAIInitialized; - unsigned int mNetId; unsigned int mVersionCode; time_t mBuildTime; diff --git a/app/src/main/java/com/xypower/mpapp/MainActivity.java b/app/src/main/java/com/xypower/mpapp/MainActivity.java index 153548ab..bdcb78cd 100644 --- a/app/src/main/java/com/xypower/mpapp/MainActivity.java +++ b/app/src/main/java/com/xypower/mpapp/MainActivity.java @@ -133,8 +133,6 @@ public class MainActivity extends AppCompatActivity { Log.d(TAG, "MainActivity: reboot=" + rebootFlag + " noDelay=" + noDelay); - - final MicroPhotoContext.AppConfig appConfig = MicroPhotoContext.getMpAppConfig(appContext); if (TextUtils.isEmpty(appConfig.cmdid)) { appConfig.cmdid = MicroPhotoService.getSerialNumber(); @@ -178,8 +176,6 @@ public class MainActivity extends AppCompatActivity { } } - - if (MicroPhotoContext.hasMpAppConfig(appContext)) { Runnable runnable = new Runnable() { @Override diff --git a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java index 8c1801eb..ad668a34 100644 --- a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java +++ b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java @@ -60,6 +60,7 @@ import android.util.Log; import android.widget.RemoteViews; import android.widget.Toast; +import com.dev.api.XyDev; import com.dev.devapi.api.SysApi; import com.xypower.common.FileDownloader; import com.xypower.common.FilesUtils; @@ -250,6 +251,23 @@ public class MicroPhotoService extends Service { public void onCreate() { super.onCreate(); + try { + if (usingEthernet()) { + mConnectivityManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); + + Network[] nws = mConnectivityManager.getAllNetworks(); + for (Network nw : nws) { + NetworkInfo ni = mConnectivityManager.getNetworkInfo(nw); + if (ni.getType() == ConnectivityManager.TYPE_ETHERNET) { + updateEhernet(mNativeHandle, nw.getNetworkHandle(), true); + } + + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + try { final String appPath = MicroPhotoContext.buildMpAppDir(this); @@ -373,6 +391,12 @@ public class MicroPhotoService extends Service { getApplicationContext().unregisterReceiver(mScreenaAtionReceiver); getApplicationContext().unregisterReceiver(mNetworkChangedReceiver); + if (mConnectivityManager != null) { + if (mNetworkCallback != null) { + mConnectivityManager.unregisterNetworkCallback(mNetworkCallback); + } + } + LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(mLocalMsgReceiver); for(Map.Entry entry : mWakeLocks.entrySet()) { @@ -929,6 +953,23 @@ public class MicroPhotoService extends Service { return START_NOT_STICKY; } + long getDefaultNetworkHandle() { + long defaultNetHandle = 0; + if (mConnectivityManager != null) { + Network network = mConnectivityManager.getActiveNetwork(); + if (network != null) { + NetworkInfo networkInfo = mConnectivityManager.getNetworkInfo(network); + int type = networkInfo.getType(); + if (type == ConnectivityManager.TYPE_MOBILE || type == ConnectivityManager.TYPE_VPN || + type == ConnectivityManager.TYPE_MOBILE_DUN || type == ConnectivityManager.TYPE_MOBILE_HIPRI) { + defaultNetHandle = network.getNetworkHandle(); + } + } + } + + return defaultNetHandle; + } + private void startTerminalService(Intent intent) { if (MicroPhotoService.this.mNativeHandle != 0) { @@ -982,8 +1023,9 @@ public class MicroPhotoService extends Service { ex.printStackTrace(); } + long defaultNetHandle = service.getDefaultNetworkHandle(); service.mNativeHandle = init(appPath, server, port, cmdid, protocol, networkProtocol, - encryptData, 0, service.getSignalLevel(), versionCode, + encryptData, defaultNetHandle, service.getSignalLevel(), versionCode, BuildConfig.BUILD_TIMESTAMP, simcard, tfCardPath, nativeLibraryDir); if (service.mNativeHandle != 0) { @@ -994,6 +1036,70 @@ public class MicroPhotoService extends Service { long startTime = (date.getTime() + 999) / 1000; service.updateCaptureSchedule(startTime); + try { + if (usingEthernet()) { + mNetworkCallback = new ConnectivityManager.NetworkCallback() { + @Override + public void onLost(Network network) { + infoLog("Network Lost " + network.toString()); + updateEhernet(mNativeHandle, network.getNetworkHandle(), false); + updateDefaultNetwork(); + } + @Override + public void onAvailable(final Network network) { + String ip = ""; + try { + NetworkInfo ni = mConnectivityManager.getNetworkInfo(network); + LinkProperties lp = mConnectivityManager.getLinkProperties(network); + if (lp != null) { + List addresses = lp.getLinkAddresses(); + if (addresses != null && addresses.size() > 0) { + for (LinkAddress linkAddress : addresses) { + InetAddress inetAddress = linkAddress.getAddress(); + if (inetAddress != null && inetAddress instanceof Inet4Address) { + ip = inetAddress.getHostAddress(); + break; + } + } + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + + infoLog("Network Available " + network.toString() + " IP=" + ip + " Handle=" + Long.toString(network.getNetworkHandle())); + updateEhernet(mNativeHandle, network.getNetworkHandle(), true); + updateDefaultNetwork(); + } + + private void updateDefaultNetwork() { + MicroPhotoService thisService = MicroPhotoService.this; + long defaultNetHandle = thisService.getDefaultNetworkHandle(); + if (defaultNetHandle != 0) { + thisService.updateActiveNetwork(thisService.mNativeHandle, defaultNetHandle, true); + } + } + }; + + NetworkRequest request = new NetworkRequest.Builder() + .addTransportType(NetworkCapabilities.TRANSPORT_ETHERNET) + .build(); + + mConnectivityManager.registerNetworkCallback(request, mNetworkCallback); + + Network[] nws = mConnectivityManager.getAllNetworks(); + for (Network nw : nws) { + NetworkInfo ni = mConnectivityManager.getNetworkInfo(nw); + if (ni.getType() == ConnectivityManager.TYPE_ETHERNET) { + updateEhernet(mNativeHandle, nw.getNetworkHandle(), true); + } + + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + if (mPreviousLocation != null) { service.updatePosition(mNativeHandle, mPreviousLocation.getLongitude(), mPreviousLocation.getLatitude(), mPreviousLocation.getAccuracy(), mPreviousLocation.getTime() / 1000); @@ -1390,6 +1496,27 @@ public class MicroPhotoService extends Service { public static void restartApp(Context context, String packageName, String reason) { + // "com.xypower.mpmaster.ACT_REQ_RST_APP" + Intent intent = new Intent(); + intent.setAction("com.xypower.mpmaster.ACT_REQ_RST_APP"); + intent.setPackage(MicroPhotoContext.PACKAGE_NAME_MPMASTER); + intent.putExtra("noDelay", 1); + intent.putExtra("reason", reason); + intent.putExtra("packageName", context.getPackageName()); + context.sendBroadcast(intent); + System.exit(0); + + /* + if (TextUtils.equals(packageName, MicroPhotoContext.PACKAGE_NAME_MPAPP)) { + MicroPhotoContext.restartMpApp(context, reason, 0); + System.exit(0); + } else { + MicroPhotoContext.restartApp(context, packageName, reason); + } + + */ + + /* Intent intent = new Intent(context, MainActivity.class); int noDelay = 1; intent.putExtra("noDelay", noDelay); @@ -1397,11 +1524,10 @@ public class MicroPhotoService extends Service { intent.putExtra("reason", reason); } - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); context.startActivity(intent); System.exit(0); - - + */ /* Intent intent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()); int noDelay = 1; @@ -1505,58 +1631,6 @@ public class MicroPhotoService extends Service { public void setStaticNetwork(String iface, String ip, String netmask, String gateway) { - if (mConnectivityManager == null || mNetworkCallback == null) { - mConnectivityManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); - mNetworkCallback = new ConnectivityManager.NetworkCallback() { - - @Override - public void onLost(Network network) { - infoLog("Network Lost " + network.toString()); - updateEhernet(mNativeHandle, network.getNetworkHandle(), false); - } - @Override - public void onAvailable(final Network network) { - String ip = ""; - try { - NetworkInfo ni = mConnectivityManager.getNetworkInfo(network); - LinkProperties lp = mConnectivityManager.getLinkProperties(network); - if (lp != null) { - List addresses = lp.getLinkAddresses(); - if (addresses != null && addresses.size() > 0) { - for (LinkAddress linkAddress : addresses) { - InetAddress inetAddress = linkAddress.getAddress(); - if (inetAddress != null && inetAddress instanceof Inet4Address) { - ip = inetAddress.getHostAddress(); - break; - } - } - } - } - } catch (Exception ex) { - ex.printStackTrace(); - } - - infoLog("Network Available " + network.toString() + " IP=" + ip); - updateEhernet(mNativeHandle, network.getNetworkHandle(), true); - } - }; - - NetworkRequest request = new NetworkRequest.Builder() - .addTransportType(NetworkCapabilities.TRANSPORT_ETHERNET) - .build(); - - mConnectivityManager.registerNetworkCallback(request, mNetworkCallback); - - Network[] nws = mConnectivityManager.getAllNetworks(); - for (Network nw : nws) { - NetworkInfo ni = mConnectivityManager.getNetworkInfo(nw); - if (ni.getType() == ConnectivityManager.TYPE_ETHERNET) { - updateEhernet(mNativeHandle, nw.getNetworkHandle(), true); - } - - } - } - if (!TextUtils.equals("0.0.0.0", ip)) { Intent intent = new Intent(); intent.putExtra("cmd", "setnet"); @@ -1602,6 +1676,7 @@ cellSignalStrengthGsm.getDbm(); protected native boolean reloadConfigs(long handler); protected native void updatePosition(long handler, double lon, double lat, double radius, long ts); protected native boolean updateEhernet(long handler, long nativeNetworkHandle, boolean available); + protected native boolean updateActiveNetwork(long handler, long nativeNetworkHandle, boolean available); protected native boolean uninit(long handler); protected native void recordingFinished(long handler, boolean photoOrVideo, boolean result, String path, long videoId); protected native void captureFinished(long handler, boolean photoOrVideo, boolean result, Bitmap bm, long videoId); @@ -1612,6 +1687,8 @@ cellSignalStrengthGsm.getDbm(); public static native boolean sendExternalPhoto(long deviceHandle, String path, long photoInfo); public static native void infoLog(String log); + public static native boolean usingEthernet(); + public static native void setOtgState(boolean enabled); public static native void setCam3V3Enable(boolean enabled); public static native String getSerialNumber(); diff --git a/common/src/main/java/com/xypower/common/MicroPhotoContext.java b/common/src/main/java/com/xypower/common/MicroPhotoContext.java index 3e33894b..eb9c910e 100644 --- a/common/src/main/java/com/xypower/common/MicroPhotoContext.java +++ b/common/src/main/java/com/xypower/common/MicroPhotoContext.java @@ -398,9 +398,9 @@ public class MicroPhotoContext { intent.putExtra("reason", reason); } intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - PendingIntent restartIntent = PendingIntent.getActivity(context, 0, intent, 0); + PendingIntent restartIntent = PendingIntent.getActivity(context, 100, intent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager mgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); - mgr.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + delayedTimeMs, restartIntent); + mgr.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + ((delayedTimeMs > 0) ? delayedTimeMs : 10), restartIntent); } public static void restartApp(Context context, String packageName, String reason) { diff --git a/mpmaster/build.gradle b/mpmaster/build.gradle index 8883e0b8..1e0ea991 100644 --- a/mpmaster/build.gradle +++ b/mpmaster/build.gradle @@ -4,7 +4,7 @@ plugins { def AppMajorVersion = 1 def AppMinorVersion = 0 -def AppBuildNumber = 95 +def AppBuildNumber = 96 def AppVersionName = AppMajorVersion + "." + AppMinorVersion + "." + AppBuildNumber def AppVersionCode = AppMajorVersion * 100000 + AppMinorVersion * 1000 + AppBuildNumber diff --git a/mpmaster/src/main/java/com/xypower/mpmaster/MainActivity.java b/mpmaster/src/main/java/com/xypower/mpmaster/MainActivity.java index d96cf0e6..2d1bce84 100644 --- a/mpmaster/src/main/java/com/xypower/mpmaster/MainActivity.java +++ b/mpmaster/src/main/java/com/xypower/mpmaster/MainActivity.java @@ -129,10 +129,22 @@ public class MainActivity extends AppCompatActivity { startActivity(intent); } break; - case R.id.action_reboot_mp:{ + case R.id.action_notify_mp_reboot:{ MicroPhotoContext.restartMpApp(getApplicationContext(), "Manual Restart from MpMst"); } break; + + case R.id.action_reboot_mp: { + Context context = getApplicationContext(); + Intent intent = context.getPackageManager().getLaunchIntentForPackage(MicroPhotoContext.PACKAGE_NAME_MPAPP); + int noDelay = 1; + intent.putExtra("noDelay", noDelay); + intent.putExtra("reason", "Manual Restart from MpMst"); + + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + context.startActivity(intent); + } + break; case R.id.action_reboot_mpmst:{ MpMasterService.restartApp(getApplicationContext()); } diff --git a/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java b/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java index 0cd0e49b..5196e13d 100644 --- a/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java +++ b/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java @@ -14,6 +14,7 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.res.AssetManager; import android.os.Build; +import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.os.IBinder; @@ -70,6 +71,8 @@ public class MpMasterService extends Service { public static final String ACTION_STOP = "com.xypower.mpmaster.ACT_STOP"; public static final String ACTION_MAIN = "com.xypower.mpmaster.ACT_MAIN"; + public static final String ACTION_REQ_RESTART_APP = "com.xypower.mpmaster.ACT_REQ_RST_APP"; + public static final String ACTION_UPD_OTA = SysApi.OTA_RESULT_ACTION; public static final String ACTION_INSTALL_RESULT = SysApi.INSTALL_RESULT_ACTION; public static final String ACTION_UNINSTALL_RESULT = SysApi.UNINSTALL_RESULT_ACTION; @@ -245,6 +248,7 @@ public class MpMasterService extends Service { intentFilter.addAction(ACTION_UPD_OTA); intentFilter.addAction(ACTION_INSTALL_RESULT); intentFilter.addAction(ACTION_UNINSTALL_RESULT); + intentFilter.addAction(ACTION_REQ_RESTART_APP); intentFilter.addAction(MicroPhotoContext.ACTION_HEARTBEAT_MP); registerReceiver(mAlarmReceiver, intentFilter); @@ -649,8 +653,6 @@ public class MpMasterService extends Service { mService.detectMpAppAlive(); } else if (TextUtils.equals(MicroPhotoContext.ACTION_HEARTBEAT_MP, action)) { - - if (intent.hasExtra("HeartbeatDuration")) { int hbDuration = intent.getIntExtra("HeartbeatDuration", 600000); mService.mMpHeartbeatDuration = hbDuration > 0 ? hbDuration : 600000; @@ -712,6 +714,23 @@ public class MpMasterService extends Service { String pkname = intent.getStringExtra("pkname"); String msg = intent.getStringExtra("msg"); mService.logger.warning("UNINSTALL APP result =" + bSucc + ",pkname=" + pkname + ",msg=" + msg); + } else if (TextUtils.equals(ACTION_REQ_RESTART_APP, action)) { + + try { + String packageName = intent.getStringExtra("packageName"); + Intent restartIntent = context.getPackageManager().getLaunchIntentForPackage(packageName); + + Bundle bundle = intent.getExtras(); + bundle.remove("packageName"); + restartIntent.putExtras(bundle); + restartIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + context.startActivity(restartIntent); + + } catch (Exception ex) { + ex.printStackTrace(); + } + + } } } diff --git a/mpmaster/src/main/java/com/xypower/mpmaster/sms/SimUtil.java b/mpmaster/src/main/java/com/xypower/mpmaster/sms/SimUtil.java index 69f27934..4dde7d55 100644 --- a/mpmaster/src/main/java/com/xypower/mpmaster/sms/SimUtil.java +++ b/mpmaster/src/main/java/com/xypower/mpmaster/sms/SimUtil.java @@ -30,9 +30,11 @@ import com.xypower.common.FilesUtils; import com.xypower.common.JSONUtils; import com.xypower.common.MicroPhotoContext; import com.xypower.common.NetworkUtils; +import com.xypower.common.RegexUtil; import com.xypower.mpmaster.MpMasterService; import org.json.JSONArray; +import org.json.JSONException; import org.json.JSONObject; import java.io.File; @@ -79,7 +81,9 @@ public class SimUtil { } int slot = smsInfo.getSlot();//那张卡收到的短信 String sender = smsInfo.getSender();//收到的短信的手机号 - + String sendmessage = "ERROR";//要回复的短信 + List abslist = new ArrayList<>();//收到的短信内容拆分包装成数组 + boolean ifmessageCorrect = false;//用来判断收到的短信内容是否正确 if (StringUtils.isEmpty(content)) { return; } @@ -91,544 +95,451 @@ public class SimUtil { updateFile(content); } else if (content.toLowerCase().contains(SmsTypeEnum.GET_FILE.value().toLowerCase())) {//获取整个配置文件 queryFile(content); + } else if (content.contains(SmsTypeEnum.REBOOT1.value())) { + ifmessageCorrect = true; + restartType = 0; + sendmessage = getSendString(content, ifmessageCorrect); + } else if (content.contains(SmsTypeEnum.REBOOT2.value()) || content.contains(SmsTypeEnum.REBOOT3.value())) { + ifmessageCorrect = true; + restartType = 0; + sendmessage = getSendString(content, ifmessageCorrect); + } else if (content.contains(SmsTypeEnum.RESTART_MP.value()) || content.contains(SmsTypeEnum.RESTART_MP2.value())) { + ifmessageCorrect = true; + restartType = 1; + sendmessage = getSendString(content, ifmessageCorrect); + } else if (content.contains(SmsTypeEnum.RESTART_MPMST.value()) || content.contains(SmsTypeEnum.RESTART_MPMST2.value())) { + ifmessageCorrect = true; + restartType = 2; + sendmessage = getSendString(content, ifmessageCorrect); + } else if (content.contains(SmsTypeEnum.RESTART_BOTH_APPS.value()) || content.contains(SmsTypeEnum.RESTART_BOTH_APPS2.value())) { + ifmessageCorrect = true; + restartType = 3; + sendmessage = getSendString(content, ifmessageCorrect); + } else if (content.contains(SmsTypeEnum.SET_YW_SCHEDULE.value())) { + ifmessageCorrect = true; + String[] split1 = StringUtils.splitString1(content); + if (split1 != null && split1.length == 2) { + String s = split1[1]; + String[] split2 = StringUtils.splitString2(s); + int spilt2len = split2.length; + if (split2 != null && spilt2len > 1 && spilt2len % 2 == 1) { + String num = split2[0]; + Integer integer = StringUtils.convert2Int(num); + if (integer != null) { + if (integer == 0) {//删除所有运维 + ifmessageCorrect = true; + } else { + if (spilt2len == integer * 2 + 1) { + int times = 0; + for (int i = 0; i < spilt2len; i++) { + if (i == 0) { + continue; + } + String ts = split2[i]; + Integer time = StringUtils.convert2Int(ts); + if (i % 2 == 1) { + if (time > 23) { + ifmessageCorrect = false; + break; + } + times = time * 3600; + } else { + if (time > 59) { + ifmessageCorrect = false; + break; + } + times += time * 60; + abslist.add(times); + } + } + } + } + if (ifmessageCorrect) { + UpdateSysConfigUtil.setAbsHeartbeats(context, abslist); + } + } + } + } + restartType = 2; + sendmessage = getSendString(content, ifmessageCorrect); + } else if (content.contains(SmsTypeEnum.GET_YW_SCHEDULE.value())) { + List absHeartbeats = UpdateSysConfigUtil.getAbsHeartbeats(context); + if (absHeartbeats == null || absHeartbeats.size() == 0) { + sendmessage = SmsTypeEnum.GET_YW_SCHEDULE.value() + "=0"; + } else { + int length = absHeartbeats.size(); + sendmessage = SmsTypeEnum.GET_YW_SCHEDULE.value() + "=" + length; + for (int i = 0; i < length; i++) { + int mAbsHeartbeatTime = 0; + mAbsHeartbeatTime = absHeartbeats.get(i); + int hour = mAbsHeartbeatTime / 3600; + int minute = (mAbsHeartbeatTime % 3600) / 60; + sendmessage += "," + hour + "," + minute; + } + } + } else if (content.contains(SmsTypeEnum.SET_OPERATE.value())) { + String[] split1 = StringUtils.splitString1(content); + if (split1 != null && split1.length > 1) { + String s = split1[1]; + Integer integer = StringUtils.convert2Int(s); + if (integer != null) { + if (integer == 0 || integer == 1) { + ifmessageCorrect = true; + UpdateSysConfigUtil.setMntnMode(context, integer); + } + } + } + restartType = 2; + sendmessage = getSendString(content, ifmessageCorrect); + } else if (content.contains(SmsTypeEnum.GET_OPERATE.value())) { + int mntnMode = UpdateSysConfigUtil.getMntnMode(context); + sendmessage = SmsTypeEnum.GET_OPERATE.value() + "=" + mntnMode; + } else if (content.contains(SmsTypeEnum.SET_OPERATE_URL.value())) { + restartType = 2; + String[] split1 = StringUtils.splitString1(content); + if (split1 != null && split1.length > 1) { + String s = split1[1]; + String[] split2 = StringUtils.splitString2(s); + if (split2 != null && split2.length >= 2) { + String ipAddress = split2[0]; + String port = split2[1]; + boolean b = RegexUtil.checkIpAddress(ipAddress); + if (b) { + Integer integer = StringUtils.convert2Int(port); + if (integer != null) { + ifmessageCorrect = true; + UpdateSysConfigUtil.setMntnServer(context, ipAddress, integer); + } + } + } + } + sendmessage = getSendString(content, ifmessageCorrect); + } else if (content.contains(SmsTypeEnum.GET_OPERATE_URL.value())) { + String mntnServer = UpdateSysConfigUtil.getMntnServer(context); + sendmessage = SmsTypeEnum.GET_OPERATE_URL.value() + "=" + mntnServer; + } else if (content.contains(SmsTypeEnum.UPDATE.value())) { + String[] split1 = StringUtils.splitString1(content); + if (split1 != null && split1.length == 2) { + ifmessageCorrect = true; + String s = split1[1]; + DownloadUtils downloadUtils = new DownloadUtils(context.getApplicationContext(), s, "test.app"); + } + sendmessage = getSendString(content, ifmessageCorrect); + } else if (content.contains(SmsTypeEnum.SET_CMDID.value())) { + restartType = 1; + String[] split1 = StringUtils.splitString1(content); + if (split1 != null && split1.length > 1) { + ifmessageCorrect = true; + String cmdid = split1[1]; + UpdateSysConfigUtil.setCmdid(context, cmdid); + } + sendmessage = getSendString(content, ifmessageCorrect); + } else if (content.contains(SmsTypeEnum.GET_CMDID.value())) { + String cmdid = UpdateSysConfigUtil.getCmdid(context); + String serialNo = UpdateSysConfigUtil.getSerialNo(); + sendmessage = SmsTypeEnum.GET_CMDID.value() + "=" + serialNo + "," + cmdid; + } else if (content.contains(SmsTypeEnum.SET_IP.value())) { + restartType = 1; + String[] split1 = StringUtils.splitString1(content); + if (split1 != null && split1.length > 1) { + String s = split1[1]; + String[] split2 = StringUtils.splitString2(s); + if (split2 != null && (split2.length == 2 || split2.length == 4)) { + String server; + Integer integer; + server = split2[0]; + String port = split2[1]; + integer = StringUtils.convert2Int(port); + Integer utcp = -1; + Integer encrypto = -1; + if (integer != null) { + ifmessageCorrect = true; + if (split2.length == 4) { + String s1 = split2[2]; + utcp = StringUtils.convert2Int(s1); + utcp = getUtcp(utcp); + String s2 = split2[3]; + encrypto = StringUtils.convert2Int(s2); + encrypto = getEncrypto(encrypto); + if (utcp == -1 || encrypto == -1) { + ifmessageCorrect = false; + } + } + } + if (ifmessageCorrect) { + UpdateSysConfigUtil.setIP(context, server, integer, utcp, encrypto); + } + } + } + sendmessage = getSendString(content, ifmessageCorrect); + } else if (content.contains(SmsTypeEnum.GET_IP.value())) { + String ip = UpdateSysConfigUtil.getIP(context); + sendmessage = SmsTypeEnum.GET_IP.value() + "=" + ip; + } else if (content.contains(SmsTypeEnum.SET_OSD.value())) { + restartType = 1; + String[] split1 = StringUtils.splitString1(content); + sendmessage = getSendString(content, ifmessageCorrect); + if (split1 != null && split1.length == 2) { + ifmessageCorrect = true; + JSONObject osdmap = new JSONObject(); + String s = split1[1]; + String[] split2 = StringUtils.splitString2(s); + int spilt2len = split2.length; + if (split2 != null && spilt2len > 1 && spilt2len % 2 == 1) { + String num = split2[0]; + Integer integer = StringUtils.convert2Int(num); + if (integer != null) { + for (int i = 0; i < spilt2len; i++) { + if (i == 0) { + continue; + } + if (i % 2 == 1) { + if ((i + 1) <= spilt2len) { + String s1 = split2[i]; + Integer position = StringUtils.convert2Int(s1); + if (position != null) { + try { + if (position == 1) { + osdmap.put(UpdateSysConfigUtil.leftTop, split2[i + 1]); + } else if (position == 2) { + osdmap.put(UpdateSysConfigUtil.rightTop, split2[i + 1]); + } else if (position == 3) { + osdmap.put(UpdateSysConfigUtil.leftBottom, split2[i + 1]); + } else if (position == 4) { + osdmap.put(UpdateSysConfigUtil.rightBottom, split2[i + 1]); + } else { + ifmessageCorrect = false; + } + } catch (JSONException e) { + throw new RuntimeException(e); + } + } else { + ifmessageCorrect = false; + } + } else { + ifmessageCorrect = false; + } + } + } + if (integer == 0) {//所有通道 + ifmessageCorrect = true; + MicroPhotoContext.AppConfig mpAppConfig = MicroPhotoContext.getMpAppConfig(context); + int channelnum = mpAppConfig.channels; + if (channelnum != 0) { + if (ifmessageCorrect) { + for (int i = 1; i <= channelnum; i++) { + UpdateSysConfigUtil.setChannelOSD(i, osdmap); + } + } + } + } else { + if (ifmessageCorrect) { + UpdateSysConfigUtil.setChannelOSD(integer, osdmap); + } + } + + } + } + } + } else if (content.contains(SmsTypeEnum.GET_OSD.value())) { + String[] split = StringUtils.splitString1(content); + if (split != null && split.length == 2) { + sendmessage = SmsTypeEnum.GET_OSD.value() + "="; + ifmessageCorrect = true; + Integer channel = StringUtils.convert2Int(split[1]); + if (channel != null) { + if (channel == 0) { + MicroPhotoContext.AppConfig mpAppConfig = MicroPhotoContext.getMpAppConfig(context); + int channelnum = mpAppConfig.channels; + if (channelnum != 0) { + if (ifmessageCorrect) { + for (int i = 1; i <= channelnum; i++) { + sendmessage += channel + ":{"; + JSONObject channelOSD = UpdateSysConfigUtil.getChannelOSD(channel); + if (channelOSD != null) { + String leftTop = channelOSD.optString(UpdateSysConfigUtil.leftTop); + String rightTop = channelOSD.optString(UpdateSysConfigUtil.rightTop); + String leftBottom = channelOSD.optString(UpdateSysConfigUtil.leftBottom); + String rightBottom = channelOSD.optString(UpdateSysConfigUtil.rightBottom); + if (leftTop != null && StringUtils.isNotEmpty(leftTop)) { + sendmessage += "左上:" + leftTop; + } + if (rightTop != null && StringUtils.isNotEmpty(rightTop)) { + sendmessage += ",右上:" + rightTop; + } + if (leftBottom != null && StringUtils.isNotEmpty(leftBottom)) { + sendmessage += ",左下:" + leftBottom; + } + if (rightBottom != null && StringUtils.isNotEmpty(rightBottom)) { + sendmessage += ",右下:" + rightBottom; + } + } else { + sendmessage += "无水印"; + } + if (i == channelnum) { + sendmessage += channel + "}"; + } else { + sendmessage += channel + "},"; + } + } + } + } + } else { + JSONObject channelOSD = UpdateSysConfigUtil.getChannelOSD(channel); + if (channelOSD != null) { + String leftTop = channelOSD.optString(UpdateSysConfigUtil.leftTop); + String rightTop = channelOSD.optString(UpdateSysConfigUtil.rightTop); + String leftBottom = channelOSD.optString(UpdateSysConfigUtil.leftBottom); + String rightBottom = channelOSD.optString(UpdateSysConfigUtil.rightBottom); + if (leftTop != null && StringUtils.isNotEmpty(leftTop)) { + sendmessage += "左上:" + leftTop; + } + if (rightTop != null && StringUtils.isNotEmpty(rightTop)) { + sendmessage += ",右上:" + rightTop; + } + if (leftBottom != null && StringUtils.isNotEmpty(leftBottom)) { + sendmessage += ",左下:" + leftBottom; + } + if (rightBottom != null && StringUtils.isNotEmpty(rightBottom)) { + sendmessage += ",右下:" + rightBottom; + } + } else { + sendmessage += "无水印"; + } + } + } else { + ifmessageCorrect = false; + } + } + } else if (content.contains(SmsTypeEnum.SET_PHOTO_SCHEDULE_LIST.value())) { + restartType = 1; + String[] split1 = StringUtils.splitString1(content); + if (split1 != null && split1.length > 1) { + String s = split1[1]; + String[] split2 = StringUtils.splitString2(s); + if (split2 != null && split2.length == 2) { + Integer channel = StringUtils.convert2Int(split2[0]); + if (channel != null) { + ifmessageCorrect = true; + String msg = split2[1]; + UpdateSysConfigUtil.setPhotoSchedules(channel, msg); + } + } + } + sendmessage = getSendString(content, ifmessageCorrect); + } else if (content.contains(SmsTypeEnum.GET_PHOTO_SCHEDULE_LIST.value())) { + String[] split1 = StringUtils.splitString1(content); + if (split1 != null && split1.length == 2) { + Integer channel = StringUtils.convert2Int(split1[1]); + String photoSchedules = UpdateSysConfigUtil.getPhotoSchedules(channel); + sendmessage = SmsTypeEnum.GET_PHOTO_SCHEDULE_LIST.value() + "=" + photoSchedules; + } + } else if (content.contains(SmsTypeEnum.SET_RESOLUTION.value())) { + restartType = 1; + String[] split1 = StringUtils.splitString1(content); + if (split1 != null && split1.length > 1) { + String s = split1[1]; + String[] split2 = StringUtils.splitString1(s); + if (split2 != null && split2.length == 5) { + Integer channel = StringUtils.convert2Int(split2[0]); + Integer resolutionCX = StringUtils.convert2Int(split2[1]); + Integer resolutionCY = StringUtils.convert2Int(split2[2]); + Integer videoCX = StringUtils.convert2Int(split2[3]); + Integer videoCY = StringUtils.convert2Int(split2[4]); + if (channel != null && resolutionCX != null && resolutionCY != null && videoCX != null && videoCY != null) { + ifmessageCorrect = true; + UpdateSysConfigUtil.setChannelResolution(channel, resolutionCX, resolutionCY, videoCX, videoCY); + UpdateSysConfigUtil.restartApp(context); + } + } + } + sendmessage = getSendString(content, ifmessageCorrect); + } else if (content.contains(SmsTypeEnum.GET_RESOLUTION.value())) { + String[] split = StringUtils.splitString1(content); + Integer channel = StringUtils.convert2Int(split[0]); + HashMap hashMap = UpdateSysConfigUtil.getChannelResolution(channel); + Integer resolutionCX = hashMap.get("resolutionCX"); + Integer resolutionCY = hashMap.get("resolutionCY"); + Integer videoCX = hashMap.get("videoCX"); + Integer videoCY = hashMap.get("videoCY"); + sendmessage = SmsTypeEnum.GET_RESOLUTION.value() + "=" + resolutionCX + "," + resolutionCY + "," + videoCX + "," + videoCY; + } else if (content.contains(SmsTypeEnum.TAKE_PHOTO.value())) { + String[] split = StringUtils.splitString1(content); + if (split != null && split.length == 3) { + ifmessageCorrect = true; + Integer channel = StringUtils.convert2Int(split[0]); + Integer preset = StringUtils.convert2Int(split[1]); + Integer type = StringUtils.convert2Int(split[2]); + if (channel != null) { + boolean photoOrVideo; + if (type == 0) { + photoOrVideo = true; + } else { + photoOrVideo = false; + } + UpdateSysConfigUtil.takePhotoOrVideo(context, channel, preset, photoOrVideo); + } + sendmessage = getSendString(content, ifmessageCorrect); + } + } else if (content.contains(SmsTypeEnum.SET_HEART.value())) { + restartType = 1; + String[] split1 = StringUtils.splitString1(content); + if (split1 != null && split1.length == 2) { + ifmessageCorrect = true; + String s = split1[1]; + Integer integer = StringUtils.convert2Int(s); + UpdateSysConfigUtil.setHB(context, integer); + } + sendmessage = getSendString(content, ifmessageCorrect); + } else if (content.contains(SmsTypeEnum.GET_HEART.value())) { + int hb = UpdateSysConfigUtil.getHB(context); + sendmessage = SmsTypeEnum.GET_HEART.value() + "=" + hb; + } else if (content.contains(SmsTypeEnum.SIMCARD.value())) { + sendmessage = getSimcardInfo(context); + } else if (content.contains(SmsTypeEnum.SET_AUTO_TIME.value())) { + restartType = 1; + sendmessage = setAutoTime(context, content); + } else if (content.contains(SmsTypeEnum.SET_TP.value())) { + restartType = 1; + String[] split1 = StringUtils.splitString1(content); + if (split1 != null && split1.length == 2) { + ifmessageCorrect = true; + String s = split1[1]; + Integer integer = StringUtils.convert2Int(s); + UpdateSysConfigUtil.setTB(context, integer); + } + sendmessage = getSendString(content, ifmessageCorrect); + } else if (content.contains(SmsTypeEnum.GET_TP.value())) { + int tb = UpdateSysConfigUtil.getTB(context); + sendmessage = SmsTypeEnum.GET_TP.value() + "=" + tb; + } else if (content.contains(SmsTypeEnum.SET_PACKAGE.value())) { + restartType = 1; + String[] split1 = StringUtils.splitString1(content); + if (split1 != null && split1.length == 2) { + ifmessageCorrect = true; + String s = split1[1]; + Integer integer = StringUtils.convert2Int(s); + UpdateSysConfigUtil.setPackage(context, integer); + } + sendmessage = getSendString(content, ifmessageCorrect); + } else if (content.contains(SmsTypeEnum.GET_PACKAGE.value())) { + int aPackage = UpdateSysConfigUtil.getPackage(context); + sendmessage = SmsTypeEnum.GET_PACKAGE.value() + "=" + aPackage; + } else if (content.contains(SmsTypeEnum.CLEAR_PHOTO.value())) { + ifmessageCorrect = true; + UpdateSysConfigUtil.clearHistoryPic(context); + sendmessage = getSendString(content, ifmessageCorrect); + } else if (content.contains(SmsTypeEnum.CLEAR_LOG.value())) { + ifmessageCorrect = true; + UpdateSysConfigUtil.clearHistoryLogs(context); + sendmessage = getSendString(content, ifmessageCorrect); + } else if (content.contains(SmsTypeEnum.CLEAR_ALL.value())) { + ifmessageCorrect = true; + UpdateSysConfigUtil.clearHistoryPic(context); + UpdateSysConfigUtil.clearHistoryLogs(context); + sendmessage = getSendString(content, ifmessageCorrect); } sendSms(context, slot, sender, sendmessage, restartType); - -// if (content.toLowerCase().contains(SmsTypeEnum.ACT.value().toLowerCase())) { -// String[] cmdSpilt = StringUtils.splitString2(content); -// if (cmdSpilt != null && cmdSpilt.length > 1) { -// -// String actType = null; -// String restartType = null; -// ArrayList list = new ArrayList<>(); -// for (int i = 0; i < cmdSpilt.length; i++) { -// String cmd = cmdSpilt[i]; -// if (StringUtils.isEmpty(cmd)) { -// break; -// } -// String[] actSpilt = StringUtils.splitString1(cmd); -// if (actSpilt == null || actSpilt.length != 2) { -// break; -// } -// String key = actSpilt[0]; -// String value = actSpilt[1]; -// if (cmd.toLowerCase().contains(SmsTypeEnum.ACT.value().toLowerCase())) { -// if (value.toLowerCase().contains(SmsTypeEnum.SET.value().toLowerCase()) || value.toLowerCase().contains(SmsTypeEnum.GET.value().toLowerCase()) || value.toLowerCase().contains(SmsTypeEnum.SETFILE.value().toLowerCase()) || value.toLowerCase().contains(SmsTypeEnum.GETFILE.value().toLowerCase())) { -// actType = value; -// } else { -// break; -// } -// } else if (cmd.toLowerCase().contains(SmsTypeEnum.CFG.value().toLowerCase())) { -// if (value.toLowerCase().contains(SmsTypeEnum.MASTER.value().toLowerCase()) || value.toLowerCase().contains(SmsTypeEnum.APP.value().toLowerCase())) { -// HashMap hashMap = new HashMap<>(); -// hashMap.put(SmsTypeEnum.CFGFILE.value(), value); -// list.add(hashMap); -// } else { -// break; -// } -// } else if (cmd.toLowerCase().contains(SmsTypeEnum.RESTART.value().toLowerCase())) { -// restartType = value; -// } else { -// if (list.size() > 0) { -// HashMap hashMap = list.get(list.size() - 1); -// hashMap.put(key, value); -// } else { -// break; -// } -// } -// -// } -// UpdateSysConfigUtil.setCommon(context, actType, list, restartType); -// } -// } - - -// if (content.contains(SmsTypeEnum.REBOOT1.value())) { -// ifmessageCorrect = true; -// sendtype = SmsTypeEnum.REBOOT1.value(); -// sendmessage = getSendString(content, ifmessageCorrect); -// } else if (content.contains(SmsTypeEnum.REBOOT2.value()) || content.contains(SmsTypeEnum.REBOOT3.value())) { -// ifmessageCorrect = true; -// sendtype = SmsTypeEnum.REBOOT2.value(); -// sendmessage = getSendString(content, ifmessageCorrect); -// } else if (content.contains(SmsTypeEnum.RESTART_MP.value()) || content.contains(SmsTypeEnum.RESTART_MP2.value())) { -// ifmessageCorrect = true; -// sendtype = SmsTypeEnum.RESTART_MP.value(); -// sendmessage = getSendString(content, ifmessageCorrect); -// } else if (content.contains(SmsTypeEnum.RESTART_MPMST.value()) || content.contains(SmsTypeEnum.RESTART_MPMST2.value())) { -// ifmessageCorrect = true; -// sendtype = SmsTypeEnum.RESTART_MPMST.value(); -// sendmessage = getSendString(content, ifmessageCorrect); -// } else if (content.contains(SmsTypeEnum.RESTART_BOTH_APPS.value()) || content.contains(SmsTypeEnum.RESTART_BOTH_APPS2.value())) { -// ifmessageCorrect = true; -// sendtype = SmsTypeEnum.RESTART_BOTH_APPS.value(); -// sendmessage = getSendString(content, ifmessageCorrect); -// } else if (content.contains(SmsTypeEnum.SET_YW_SCHEDULE.value())) { -// ifmessageCorrect = true; -// String[] split1 = StringUtils.splitString1(content); -// if (split1 != null && split1.length == 2) { -// String s = split1[1]; -// String[] split2 = StringUtils.splitString2(s); -// int spilt2len = split2.length; -// if (split2 != null && spilt2len > 1 && spilt2len % 2 == 1) { -// String num = split2[0]; -// Integer integer = StringUtils.convert2Int(num); -// if (integer != null) { -// if (integer == 0) {//删除所有运维 -// ifmessageCorrect = true; -// } else { -// if (spilt2len == integer * 2 + 1) { -// int times = 0; -// for (int i = 0; i < spilt2len; i++) { -// if (i == 0) { -// continue; -// } -// String ts = split2[i]; -// Integer time = StringUtils.convert2Int(ts); -// if (i % 2 == 1) { -// if (time > 23) { -// ifmessageCorrect = false; -// break; -// } -// times = time * 3600; -// } else { -// if (time > 59) { -// ifmessageCorrect = false; -// break; -// } -// times += time * 60; -// abslist.add(times); -// } -// } -// } -// } -// if (ifmessageCorrect) { -// UpdateSysConfigUtil.setAbsHeartbeats(context, abslist); -// } -// } -// } -// } -// sendtype = SmsTypeEnum.SET_YW_SCHEDULE.value(); -// sendmessage = getSendString(content, ifmessageCorrect); -// } else if (content.contains(SmsTypeEnum.GET_YW_SCHEDULE.value())) { -// ifmessageCorrect = true; -// List absHeartbeats = UpdateSysConfigUtil.getAbsHeartbeats(context); -// if (absHeartbeats == null || absHeartbeats.size() == 0) { -// sendmessage = SmsTypeEnum.GET_YW_SCHEDULE.value() + "=0"; -// } else { -// int length = absHeartbeats.size(); -// sendmessage = SmsTypeEnum.GET_YW_SCHEDULE.value() + "=" + length; -// for (int i = 0; i < length; i++) { -// int mAbsHeartbeatTime = 0; -// mAbsHeartbeatTime = absHeartbeats.get(i); -// int hour = mAbsHeartbeatTime / 3600; -// int minute = (mAbsHeartbeatTime % 3600) / 60; -// sendmessage += "," + hour + "," + minute; -// } -// } -// } else if (content.contains(SmsTypeEnum.SET_OPERATE.value())) { -// sendtype = SmsTypeEnum.SET_OPERATE.value(); -// String[] split1 = StringUtils.splitString1(content); -// if (split1 != null && split1.length > 1) { -// String s = split1[1]; -// Integer integer = StringUtils.convert2Int(s); -// if (integer != null) { -// if (integer == 0 || integer == 1) { -// ifmessageCorrect = true; -// UpdateSysConfigUtil.setMntnMode(context, integer); -// } -// } -// } -// sendmessage = getSendString(content, ifmessageCorrect); -// } else if (content.contains(SmsTypeEnum.GET_OPERATE.value())) { -// sendtype = SmsTypeEnum.GET_OPERATE.value(); -// ifmessageCorrect = true; -// int mntnMode = UpdateSysConfigUtil.getMntnMode(context); -// sendmessage = SmsTypeEnum.GET_OPERATE.value() + "=" + mntnMode; -// } else if (content.contains(SmsTypeEnum.SET_OPERATE_URL.value())) { -// sendtype = SmsTypeEnum.SET_OPERATE_URL.value(); -// String[] split1 = StringUtils.splitString1(content); -// if (split1 != null && split1.length > 1) { -// String s = split1[1]; -// String[] split2 = StringUtils.splitString2(s); -// if (split2 != null && split2.length >= 2) { -// String ipAddress = split2[0]; -// String port = split2[1]; -// boolean b = RegexUtil.checkIpAddress(ipAddress); -// if (b) { -// Integer integer = StringUtils.convert2Int(port); -// if (integer != null) { -// ifmessageCorrect = true; -// UpdateSysConfigUtil.setMntnServer(context, ipAddress, integer); -// } -// } -// } -// } -// sendmessage = getSendString(content, ifmessageCorrect); -// } else if (content.contains(SmsTypeEnum.GET_OPERATE_URL.value())) { -// sendtype = SmsTypeEnum.GET_OPERATE_URL.value(); -// ifmessageCorrect = true; -// String mntnServer = UpdateSysConfigUtil.getMntnServer(context); -// sendmessage = SmsTypeEnum.GET_OPERATE_URL.value() + "=" + mntnServer; -// } else if (content.contains(SmsTypeEnum.UPDATE.value())) { -// sendtype = SmsTypeEnum.UPDATE.value(); -// String[] split1 = StringUtils.splitString1(content); -// if (split1 != null && split1.length == 2) { -// ifmessageCorrect = true; -// String s = split1[1]; -// DownloadUtils downloadUtils = new DownloadUtils(context.getApplicationContext(), s, "test.app"); -// } -// sendmessage = getSendString(content, ifmessageCorrect); -// } else if (content.contains(SmsTypeEnum.SET_CMDID.value())) { -// sendtype = SmsTypeEnum.SET_CMDID.value(); -// String[] split1 = StringUtils.splitString1(content); -// if (split1 != null && split1.length > 1) { -// ifmessageCorrect = true; -// String cmdid = split1[1]; -// UpdateSysConfigUtil.setCmdid(context, cmdid); -// } -// sendmessage = getSendString(content, ifmessageCorrect); -// } else if (content.contains(SmsTypeEnum.GET_CMDID.value())) { -// sendtype = SmsTypeEnum.GET_CMDID.value(); -// ifmessageCorrect = true; -// String cmdid = UpdateSysConfigUtil.getCmdid(context); -// String serialNo = UpdateSysConfigUtil.getSerialNo(); -// sendmessage = SmsTypeEnum.GET_CMDID.value() + "=" + serialNo + "," + cmdid; -// } else if (content.contains(SmsTypeEnum.SET_IP.value())) { -// sendtype = SmsTypeEnum.SET_IP.value(); -// String[] split1 = StringUtils.splitString1(content); -// if (split1 != null && split1.length > 1) { -// String s = split1[1]; -// String[] split2 = StringUtils.splitString2(s); -// if (split2 != null && (split2.length == 2 || split2.length == 4)) { -// String server; -// Integer integer; -// server = split2[0]; -// String port = split2[1]; -// integer = StringUtils.convert2Int(port); -// Integer utcp = -1; -// Integer encrypto = -1; -// if (integer != null) { -// ifmessageCorrect = true; -// if (split2.length == 4) { -// String s1 = split2[2]; -// utcp = StringUtils.convert2Int(s1); -// utcp = getUtcp(utcp); -// String s2 = split2[3]; -// encrypto = StringUtils.convert2Int(s2); -// encrypto = getEncrypto(encrypto); -// if (utcp == -1 || encrypto == -1) { -// ifmessageCorrect = false; -// } -// } -// } -// if (ifmessageCorrect) { -// UpdateSysConfigUtil.setIP(context, server, integer, utcp, encrypto); -// } -// } -// } -// sendmessage = getSendString(content, ifmessageCorrect); -// } else if (content.contains(SmsTypeEnum.GET_IP.value())) { -// sendtype = SmsTypeEnum.GET_IP.value(); -// ifmessageCorrect = true; -// String ip = UpdateSysConfigUtil.getIP(context); -// sendmessage = SmsTypeEnum.GET_IP.value() + "=" + ip; -// } else if (content.contains(SmsTypeEnum.SET_OSD.value())) { -// sendtype = SmsTypeEnum.SET_OSD.value(); -// String[] split1 = StringUtils.splitString1(content); -// sendmessage = getSendString(content, ifmessageCorrect); -// if (split1 != null && split1.length == 2) { -// ifmessageCorrect = true; -// JSONObject osdmap = new JSONObject(); -// String s = split1[1]; -// String[] split2 = StringUtils.splitString2(s); -// int spilt2len = split2.length; -// if (split2 != null && spilt2len > 1 && spilt2len % 2 == 1) { -// String num = split2[0]; -// Integer integer = StringUtils.convert2Int(num); -// if (integer != null) { -// for (int i = 0; i < spilt2len; i++) { -// if (i == 0) { -// continue; -// } -// if (i % 2 == 1) { -// if ((i + 1) <= spilt2len) { -// String s1 = split2[i]; -// Integer position = StringUtils.convert2Int(s1); -// if (position != null) { -// try { -// if (position == 1) { -// osdmap.put(UpdateSysConfigUtil.leftTop, split2[i + 1]); -// } else if (position == 2) { -// osdmap.put(UpdateSysConfigUtil.rightTop, split2[i + 1]); -// } else if (position == 3) { -// osdmap.put(UpdateSysConfigUtil.leftBottom, split2[i + 1]); -// } else if (position == 4) { -// osdmap.put(UpdateSysConfigUtil.rightBottom, split2[i + 1]); -// } else { -// ifmessageCorrect = false; -// } -// } catch (JSONException e) { -// throw new RuntimeException(e); -// } -// } else { -// ifmessageCorrect = false; -// } -// } else { -// ifmessageCorrect = false; -// } -// } -// } -// if (integer == 0) {//所有通道 -// ifmessageCorrect = true; -// MicroPhotoContext.AppConfig mpAppConfig = MicroPhotoContext.getMpAppConfig(context); -// int channelnum = mpAppConfig.channels; -// if (channelnum != 0) { -// if (ifmessageCorrect) { -// for (int i = 1; i <= channelnum; i++) { -// UpdateSysConfigUtil.setChannelOSD(i, osdmap); -// } -// } -// } -// } else { -// if (ifmessageCorrect) { -// UpdateSysConfigUtil.setChannelOSD(integer, osdmap); -// } -// } -// -// } -// } -// } -// } else if (content.contains(SmsTypeEnum.GET_OSD.value())) { -// sendtype = SmsTypeEnum.GET_OSD.value(); -// String[] split = StringUtils.splitString1(content); -// if (split != null && split.length == 2) { -// sendmessage = SmsTypeEnum.GET_OSD.value() + "="; -// ifmessageCorrect = true; -// Integer channel = StringUtils.convert2Int(split[1]); -// if (channel != null) { -// if (channel == 0) { -// MicroPhotoContext.AppConfig mpAppConfig = MicroPhotoContext.getMpAppConfig(context); -// int channelnum = mpAppConfig.channels; -// if (channelnum != 0) { -// if (ifmessageCorrect) { -// for (int i = 1; i <= channelnum; i++) { -// sendmessage += channel + ":{"; -// JSONObject channelOSD = UpdateSysConfigUtil.getChannelOSD(channel); -// if (channelOSD != null) { -// String leftTop = channelOSD.optString(UpdateSysConfigUtil.leftTop); -// String rightTop = channelOSD.optString(UpdateSysConfigUtil.rightTop); -// String leftBottom = channelOSD.optString(UpdateSysConfigUtil.leftBottom); -// String rightBottom = channelOSD.optString(UpdateSysConfigUtil.rightBottom); -// if (leftTop != null && StringUtils.isNotEmpty(leftTop)) { -// sendmessage += "左上:" + leftTop; -// } -// if (rightTop != null && StringUtils.isNotEmpty(rightTop)) { -// sendmessage += ",右上:" + rightTop; -// } -// if (leftBottom != null && StringUtils.isNotEmpty(leftBottom)) { -// sendmessage += ",左下:" + leftBottom; -// } -// if (rightBottom != null && StringUtils.isNotEmpty(rightBottom)) { -// sendmessage += ",右下:" + rightBottom; -// } -// } else { -// sendmessage += "无水印"; -// } -// if (i == channelnum) { -// sendmessage += channel + "}"; -// } else { -// sendmessage += channel + "},"; -// } -// } -// } -// } -// } else { -// JSONObject channelOSD = UpdateSysConfigUtil.getChannelOSD(channel); -// if (channelOSD != null) { -// String leftTop = channelOSD.optString(UpdateSysConfigUtil.leftTop); -// String rightTop = channelOSD.optString(UpdateSysConfigUtil.rightTop); -// String leftBottom = channelOSD.optString(UpdateSysConfigUtil.leftBottom); -// String rightBottom = channelOSD.optString(UpdateSysConfigUtil.rightBottom); -// if (leftTop != null && StringUtils.isNotEmpty(leftTop)) { -// sendmessage += "左上:" + leftTop; -// } -// if (rightTop != null && StringUtils.isNotEmpty(rightTop)) { -// sendmessage += ",右上:" + rightTop; -// } -// if (leftBottom != null && StringUtils.isNotEmpty(leftBottom)) { -// sendmessage += ",左下:" + leftBottom; -// } -// if (rightBottom != null && StringUtils.isNotEmpty(rightBottom)) { -// sendmessage += ",右下:" + rightBottom; -// } -// } else { -// sendmessage += "无水印"; -// } -// } -// -// } else { -// ifmessageCorrect = false; -// } -// } -// } else if (content.contains(SmsTypeEnum.SET_PHOTO_SCHEDULE_LIST.value())) { -// sendtype = SmsTypeEnum.SET_PHOTO_SCHEDULE_LIST.value(); -// String[] split1 = StringUtils.splitString1(content); -// if (split1 != null && split1.length > 1) { -// String s = split1[1]; -// String[] split2 = StringUtils.splitString2(s); -// if (split2 != null && split2.length == 2) { -// Integer channel = StringUtils.convert2Int(split2[0]); -// if (channel != null) { -// ifmessageCorrect = true; -// String msg = split2[1]; -// UpdateSysConfigUtil.setPhotoSchedules(channel, msg); -// } -// } -// } -// sendmessage = getSendString(content, ifmessageCorrect); -// } else if (content.contains(SmsTypeEnum.GET_PHOTO_SCHEDULE_LIST.value())) { -// sendtype = SmsTypeEnum.GET_PHOTO_SCHEDULE_LIST.value(); -// ifmessageCorrect = true; -// String[] split1 = StringUtils.splitString1(content); -// if (split1 != null && split1.length == 2) { -// Integer channel = StringUtils.convert2Int(split1[1]); -// String photoSchedules = UpdateSysConfigUtil.getPhotoSchedules(channel); -// sendmessage = SmsTypeEnum.GET_PHOTO_SCHEDULE_LIST.value() + "=" + photoSchedules; -// } -// } else if (content.contains(SmsTypeEnum.SET_RESOLUTION.value())) { -// sendtype = SmsTypeEnum.SET_RESOLUTION.value(); -// String[] split1 = StringUtils.splitString1(content); -// if (split1 != null && split1.length > 1) { -// String s = split1[1]; -// String[] split2 = StringUtils.splitString1(s); -// if (split2 != null && split2.length == 5) { -// Integer channel = StringUtils.convert2Int(split2[0]); -// Integer resolutionCX = StringUtils.convert2Int(split2[1]); -// Integer resolutionCY = StringUtils.convert2Int(split2[2]); -// Integer videoCX = StringUtils.convert2Int(split2[3]); -// Integer videoCY = StringUtils.convert2Int(split2[4]); -// if (channel != null && resolutionCX != null && resolutionCY != null && videoCX != null && videoCY != null) { -// ifmessageCorrect = true; -// UpdateSysConfigUtil.setChannelResolution(channel, resolutionCX, resolutionCY, videoCX, videoCY); -// UpdateSysConfigUtil.restartApp(context); -// } -// } -// } -// sendmessage = getSendString(content, ifmessageCorrect); -// } else if (content.contains(SmsTypeEnum.GET_RESOLUTION.value())) { -// sendtype = SmsTypeEnum.GET_RESOLUTION.value(); -// ifmessageCorrect = true; -// String[] split = StringUtils.splitString1(content); -// Integer channel = StringUtils.convert2Int(split[0]); -// HashMap hashMap = UpdateSysConfigUtil.getChannelResolution(channel); -// Integer resolutionCX = hashMap.get("resolutionCX"); -// Integer resolutionCY = hashMap.get("resolutionCY"); -// Integer videoCX = hashMap.get("videoCX"); -// Integer videoCY = hashMap.get("videoCY"); -// sendmessage = SmsTypeEnum.GET_RESOLUTION.value() + "=" + resolutionCX + "," + resolutionCY + "," + videoCX + "," + videoCY; -// } else if (content.contains(SmsTypeEnum.TAKE_PHOTO.value())) { -// sendtype = SmsTypeEnum.TAKE_PHOTO.value(); -// ifmessageCorrect = true; -// String[] split = StringUtils.splitString1(content); -// if (split != null && split.length == 3) { -// ifmessageCorrect = true; -// Integer channel = StringUtils.convert2Int(split[0]); -// Integer preset = StringUtils.convert2Int(split[1]); -// Integer type = StringUtils.convert2Int(split[2]); -// if (channel != null) { -// boolean photoOrVideo; -// if (type == 0) { -// photoOrVideo = true; -// } else { -// photoOrVideo = false; -// } -// UpdateSysConfigUtil.takePhotoOrVideo(context, channel, preset, photoOrVideo); -// } -// sendmessage = getSendString(content, ifmessageCorrect); -// } -// } else if (content.contains(SmsTypeEnum.SET_HEART.value())) { -// sendtype = SmsTypeEnum.SET_HEART.value(); -// String[] split1 = StringUtils.splitString1(content); -// if (split1 != null && split1.length == 2) { -// ifmessageCorrect = true; -// String s = split1[1]; -// Integer integer = StringUtils.convert2Int(s); -// UpdateSysConfigUtil.setHB(context, integer); -// } -// sendmessage = getSendString(content, ifmessageCorrect); -// } else if (content.contains(SmsTypeEnum.GET_HEART.value())) { -// sendtype = SmsTypeEnum.GET_HEART.value(); -// ifmessageCorrect = true; -// int hb = UpdateSysConfigUtil.getHB(context); -// sendmessage = SmsTypeEnum.GET_HEART.value() + "=" + hb; -// } else if (content.contains(SmsTypeEnum.SIMCARD.value())) { -// sendtype = SmsTypeEnum.SIMCARD.value(); -// ifmessageCorrect = true; -// sendmessage = getSimcardInfo(context); -// } else if (content.contains(SmsTypeEnum.SET_AUTO_TIME.value())) { -// sendtype = SmsTypeEnum.SET_AUTO_TIME.value(); -// ifmessageCorrect = true; -// sendmessage = setAutoTime(context, content); -// } else if (content.contains(SmsTypeEnum.UPD_CFG_FILE.value())) { -// sendtype = SmsTypeEnum.UPD_CFG_FILE.value(); -// ifmessageCorrect = true; -// sendmessage = " OK"; -// updateConfigFile(context, content); -// } else if (content.contains(SmsTypeEnum.GET_CFG_FILE.value())) { -// sendtype = SmsTypeEnum.GET_CFG_FILE.value(); -// ifmessageCorrect = true; -// sendmessage = queryConfigFile(context, content); -// } else if (content.contains(SmsTypeEnum.SET_TP.value())) { -// sendtype = SmsTypeEnum.SET_TP.value(); -// String[] split1 = StringUtils.splitString1(content); -// if (split1 != null && split1.length == 2) { -// ifmessageCorrect = true; -// String s = split1[1]; -// Integer integer = StringUtils.convert2Int(s); -// UpdateSysConfigUtil.setTB(context, integer); -// } -// sendmessage = getSendString(content, ifmessageCorrect); -// } else if (content.contains(SmsTypeEnum.GET_TP.value())) { -// sendtype = SmsTypeEnum.GET_TP.value(); -// ifmessageCorrect = true; -// int tb = UpdateSysConfigUtil.getTB(context); -// sendmessage = SmsTypeEnum.GET_TP.value() + "=" + tb; -// } else if (content.contains(SmsTypeEnum.SET_PACKAGE.value())) { -// sendtype = SmsTypeEnum.SET_PACKAGE.value(); -// String[] split1 = StringUtils.splitString1(content); -// if (split1 != null && split1.length == 2) { -// ifmessageCorrect = true; -// String s = split1[1]; -// Integer integer = StringUtils.convert2Int(s); -// UpdateSysConfigUtil.setPackage(context, integer); -// } -// sendmessage = getSendString(content, ifmessageCorrect); -// } else if (content.contains(SmsTypeEnum.GET_PACKAGE.value())) { -// sendtype = SmsTypeEnum.GET_PACKAGE.value(); -// ifmessageCorrect = true; -// int aPackage = UpdateSysConfigUtil.getPackage(context); -// sendmessage = SmsTypeEnum.GET_PACKAGE.value() + "=" + aPackage; -// } else if (content.contains(SmsTypeEnum.CLEAR_PHOTO.value())) { -// sendtype = SmsTypeEnum.CLEAR_PHOTO.value(); -// ifmessageCorrect = true; -// UpdateSysConfigUtil.clearHistoryPic(context); -// sendmessage = getSendString(content, ifmessageCorrect); -// } else if (content.contains(SmsTypeEnum.CLEAR_LOG.value())) { -// sendtype = SmsTypeEnum.CLEAR_LOG.value(); -// ifmessageCorrect = true; -// UpdateSysConfigUtil.clearHistoryLogs(context); -// sendmessage = getSendString(content, ifmessageCorrect); -// } else if (content.contains(SmsTypeEnum.CLEAR_ALL.value())) { -// sendtype = SmsTypeEnum.CLEAR_ALL.value(); -// ifmessageCorrect = true; -// UpdateSysConfigUtil.clearHistoryPic(context); -// UpdateSysConfigUtil.clearHistoryLogs(context); -// sendmessage = getSendString(content, ifmessageCorrect); -// } -// if (ifmessageCorrect) { -// sendSms(context, slot, sender, sendmessage, sendtype, ifmessageCorrect); -// } } } diff --git a/mpmaster/src/main/res/menu/menu_main.xml b/mpmaster/src/main/res/menu/menu_main.xml index f5a22eaa..350a55ee 100644 --- a/mpmaster/src/main/res/menu/menu_main.xml +++ b/mpmaster/src/main/res/menu/menu_main.xml @@ -17,6 +17,12 @@ android:title="@string/btn_dashboard" app:showAsAction="never" /> + + 运维APP Notification Name 操作区 + 通知MpAPP自重启 重启MpAPP 重启运维APP 刷新