增加以太网变化时检测网络是否断连

streaming
Matthew 4 months ago
parent b7f6631672
commit 31954a3f17

@ -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);
@ -1346,7 +1346,12 @@ Java_com_xypower_mpapp_MicroPhotoService_updateEhernet(
CPhoneDevice* device = (CPhoneDevice*)pTerminal->GetDevice();
if (device != NULL)
{
device->UpdateNetwork(static_cast<net_handle_t>(networkHandle), available != JNI_FALSE, false);
bool changed = false;
device->UpdateNetwork(static_cast<net_handle_t>(networkHandle), available != JNI_FALSE, false, changed);
if (changed)
{
pTerminal->ResetNetwork();
}
}
return JNI_TRUE;
@ -1366,7 +1371,8 @@ Java_com_xypower_mpapp_MicroPhotoService_updateActiveNetwork(
CPhoneDevice* device = (CPhoneDevice*)pTerminal->GetDevice();
if (device != NULL)
{
device->UpdateNetwork(static_cast<net_handle_t>(networkHandle), available != JNI_FALSE, true);
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_defNetHandle(NETWORK_UNSPECIFIED), 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,7 +645,6 @@ void CPhoneDevice::SetRecognizationCfg(const IDevice::CFG_RECOGNIZATION* pRecogn
bool CPhoneDevice::BindNetwork(int sock)
{
m_devLocker.lock();
net_handle_t defNetHandle = m_defNetHandle;
m_devLocker.unlock();
@ -3760,13 +3757,16 @@ void CPhoneDevice::UpdateSimcard(const std::string& simcard)
m_simcard = simcard;
}
void CPhoneDevice::UpdateNetwork(net_handle_t nethandle, bool available, bool defaultOrEthernet)
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
@ -3785,7 +3785,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 UpdateNetwork(net_handle_t nethandle, bool available, bool defaultOrEthernet);
void UpdateNetwork(net_handle_t nethandle, bool available, bool defaultOrEthernet, bool& changed);
net_handle_t GetEthnetHandle() const;
@ -384,7 +384,6 @@ protected:
IListener* m_listener;
const CFG_RECOGNIZATION* m_pRecognizationCfg;
bool mAIInitialized;
unsigned int mNetId;
unsigned int mVersionCode;
time_t mBuildTime;

Loading…
Cancel
Save