XI.CHEN 4 months ago
commit 99b0d9ef70

@ -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

@ -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)

@ -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:

@ -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<net_handle_t>(networkHandle), available != JNI_FALSE);
bool changed = false;
device->UpdateNetwork(static_cast<net_handle_t>(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<CTerminal *>(handle);
if (pTerminal == NULL)
{
return JNI_FALSE;
}
CPhoneDevice* device = (CPhoneDevice*)pTerminal->GetDevice();
if (device != NULL)
{
bool changed = false;
device->UpdateNetwork(static_cast<net_handle_t>(networkHandle), available != JNI_FALSE, true, changed);
}
return JNI_TRUE;

@ -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<PowerControl> ethernetPowerCtrl = std::make_shared<EthernetPowerCtrl>(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)
{
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();
XYLOG(XYLOG_SEVERITY_WARNING, "NET Handle: %lld", available ? (uint64_t)nethandle : 0);
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)

@ -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;

@ -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

@ -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<String, PowerManager.WakeLock> 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<LinkAddress> 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<LinkAddress> 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();

@ -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) {

@ -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

@ -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());
}

@ -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();
}
}
}
}

@ -17,6 +17,12 @@
android:title="@string/btn_dashboard"
app:showAsAction="never" />
<item
android:id="@+id/action_notify_mp_reboot"
android:orderInCategory="100"
android:title="@string/btn_notify_mp_reboot"
app:showAsAction="never" />
<item
android:id="@+id/action_reboot_mp"
android:orderInCategory="100"

@ -2,6 +2,7 @@
<string name="app_name">运维APP</string>
<string name="text_name_notification">Notification Name</string>
<string name="btn_dashboard">操作区</string>
<string name="btn_notify_mp_reboot">通知MpAPP自重启</string>
<string name="btn_reboot_mp">重启MpAPP</string>
<string name="btn_reboot_mpmst">重启运维APP</string>
<string name="btn_refresh">刷新</string>

Loading…
Cancel
Save