jxjajs 7 months ago
commit 1728e08f7a

@ -5,7 +5,7 @@ plugins {
// 10,00,000 major-minor-build
def AppMajorVersion = 1
def AppMinorVersion = 1
def AppBuildNumber = 5
def AppBuildNumber = 9
def AppVersionName = AppMajorVersion + "." + AppMinorVersion + "." + AppBuildNumber
def AppVersionCode = AppMajorVersion * 100000 + AppMinorVersion * 1000 + AppBuildNumber

@ -39,6 +39,7 @@ add_definitions(-DUSING_NRSEC_VPN)
# add_definitions(-DOUTPUT_CAMERA_DBG_INFO)
add_definitions(-DALIGN_HB_TIMER_TO_PHOTO)
add_definitions(-DENABLE_3V3_ALWAYS)
add_definitions(-DCURL_STATICLIB)
add_definitions(-DUSING_HDRPLUS)
add_definitions(-DUSING_EXEC_HDRP=1)
@ -390,6 +391,8 @@ add_library( # Sets the name of the library.
ncnn/yolov5ncnn.cpp
netcamera/httpclient.cpp
#serial/WeatherComm.cpp
# camera2/OpenCVFont.cpp
@ -468,7 +471,7 @@ target_link_libraries( # Specifies the target library.
# included in the NDK.
${log-lib}
android camera2ndk mediandk z
android camera2ndk mediandk z curl
ncnn ${OpenCV_LIBS} sqlite3 ${HDRPLUS_LIBS_EMBED}

@ -371,7 +371,7 @@ namespace cv {
delete userData;
#if defined(USING_HB)
hb_buffer_destroy(hb_buffer);
#endif 0
#endif // 0
}
// https://freetype.org/freetype2/docs/tutorial/example2.cpp
@ -630,7 +630,7 @@ namespace cv {
#if defined(USING_HB)
hb_buffer_destroy(hb_buffer);
#endif 0
#endif // 0
}
Size FreeType2Impl::getTextSize(

@ -20,86 +20,122 @@
#define IOT_PARAM_WRITE 0xAE
#define IOT_PARAM_READ 0xAF
#define MAX_STRING_LEN 32
typedef struct
{
int cmd;
int value;
int result;
long value2;
char str[MAX_STRING_LEN];
}IOT_PARAM;
std::mutex GpioControl::m_locker;
std::vector<std::pair<int, uint32_t>> GpioControl::m_references;
void GpioControl::setInt(int cmd, int value)
int GpioControl::turnOnImpl(const IOT_PARAM& param)
{
int fd = -1;
IOT_PARAM param = { cmd, value, 0 };
// param.cmd = cmd;
// param.value = value;
uint32_t references = 1;
std::vector<std::pair<int, uint32_t> >::iterator it;
int res = 0;
int fd = -1;
uint32_t references = (value != 0) ? 1 : 0;
fd = open(GPIO_NODE_MP, O_RDONLY);
if( fd > 0 )
{
res = ioctl(fd, IOT_PARAM_WRITE, &param);
close(fd);
// check res???
for (it = m_references.begin(); it != m_references.end(); ++it)
{
if (it->first == param.cmd)
{
it->second++;
references = it->second;
break;
}
}
if (it == m_references.end())
{
m_references.push_back(std::pair<int, uint32_t >(param.cmd, references));
}
}
return references;
}
int GpioControl::turnOffImpl(const IOT_PARAM& param)
{
uint32_t references = 0;
std::vector<std::pair<int, uint32_t> >::iterator it;
int res = 0;
int fd = -1;
if (value)
for (it = m_references.begin(); it != m_references.end(); ++it)
{
if (it->first == param.cmd)
{
if (it->second > 0)
{
it->second--;
}
references = it->second;
break;
}
}
if (references == 0)
{
m_locker.lock();
fd = open(GPIO_NODE_MP, O_RDONLY);
if( fd > 0 )
if (fd > 0)
{
res = ioctl(fd, IOT_PARAM_WRITE, &param);
#ifdef _DEBUG
ALOGI("setInt cmd=%d,value=%d,result=%d\r\n",param.cmd, param.value, param.result);
#endif
close(fd);
// check res???
for (it = m_references.begin(); it != m_references.end(); ++it)
{
if (it->first == cmd)
{
it->second++;
references = it->second;
break;
}
}
if (it == m_references.end())
{
m_references.push_back(std::pair<int, uint32_t >(cmd, references));
}
}
}
return references;
}
void GpioControl::setInt(int cmd, int value)
{
IOT_PARAM param = { cmd, value, 0 };
// param.cmd = cmd;
// param.value = value;
if (value)
{
m_locker.lock();
turnOnImpl(param);
m_locker.unlock();
}
else
{
m_locker.lock();
for (it = m_references.begin(); it != m_references.end(); ++it)
turnOffImpl(param);
m_locker.unlock();
}
}
void GpioControl::setInt(const std::vector<int>& cmds, int value)
{
IOT_PARAM param = { 0, value, 0 };
// param.cmd = cmd;
// param.value = value;
std::vector<int>::const_iterator it;
if (value)
{
m_locker.lock();
for (it = cmds.cbegin(); it != cmds.cend(); ++it)
{
if (it->first == cmd)
{
if (it->second > 0)
{
it->second--;
}
references = it->second;
break;
}
param.cmd = *it;
turnOnImpl(param);
}
if (references == 0)
m_locker.unlock();
}
else
{
m_locker.lock();
for (it = cmds.cbegin(); it != cmds.cend(); ++it)
{
fd = open(GPIO_NODE_MP, O_RDONLY);
if (fd > 0) {
res = ioctl(fd, IOT_PARAM_WRITE, &param);
#ifdef _DEBUG
ALOGI("setInt cmd=%d,value=%d,result=%d\r\n",param.cmd, param.value, param.result);
#endif
close(fd);
}
param.cmd = *it;
turnOffImpl(param);
}
m_locker.unlock();
}

@ -108,6 +108,10 @@
#define CMD_SPI2SERIAL_POWER_EN 368
#define CMD_RS485_3V3_EN 369
// Others
#define CMD_SET_485_EN_STATE 131
#define CMD_SET_OTG_STATE 107
#endif // USING_N938
@ -119,15 +123,30 @@
>>>>>>> 1b0d0f421fe8db524af9afc327dce98899a13e6d
#define GPIO_NODE_MP "/dev/mtkgpioctrl"
#define MAX_STRING_LEN 32
typedef struct
{
int cmd;
int value;
int result;
long value2;
char str[MAX_STRING_LEN];
}IOT_PARAM;
class GpioControl
{
private:
static std::mutex m_locker;
static std::vector<std::pair<int, uint32_t>> m_references;
public:
protected:
static int turnOnImpl(const IOT_PARAM& param);
static int turnOffImpl(const IOT_PARAM& param);
public:
static void setInt(int cmd, int value);
static void setInt(const std::vector<int>& cmds, int value);
static int getInt(int cmd);
static void setLong(int cmd, long value);
static long getLong(int cmd);

@ -44,6 +44,7 @@ bool DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor,
#include <Client/NrsecPort.h>
#endif
#include <curl/curl.h>
static jmethodID mRegisterTimerMid = 0;
static jmethodID mRegisterHeartbeatMid = 0;
@ -225,6 +226,8 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
env->DeleteLocalRef(clazz);
#endif
curl_global_init(CURL_GLOBAL_ALL);
return result;
}
@ -289,13 +292,6 @@ Java_com_xypower_mpapp_MicroPhotoService_init(
NULL, true, -1);
*/
if (netHandle != NETID_UNSET) {
net_handle_t nh = (net_handle_t)netHandle;
android_setprocnetwork(nh);
}
char model[PROP_VALUE_MAX] = { 0 };
__system_property_get("ro.product.model", model);
@ -1388,3 +1384,23 @@ Java_com_xypower_mpapp_MicroPhotoService_exportPrivateFile(
return JNI_FALSE;
#endif
}
extern "C" JNIEXPORT jboolean JNICALL
Java_com_xypower_mpapp_MicroPhotoService_updateEhernet(
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)
{
device->UpdateEthernet(static_cast<net_handle_t>(networkHandle), available != JNI_FALSE);
}
return JNI_TRUE;
}

File diff suppressed because it is too large Load Diff

@ -27,6 +27,8 @@
#include <opencv2/opencv.hpp>
#include <android/bitmap.h>
#include <android/multinetwork.h>
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "error", __VA_ARGS__))
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, "debug", __VA_ARGS__))
@ -153,6 +155,14 @@ class CPhoneDevice : public IDevice
{
public:
struct NETWORK
{
std::string iface;
std::string ip;
std::string netmask;
std::string gateway;
};
class CPhoneCamera : public NdkCamera
{
public:
@ -221,7 +231,12 @@ public:
virtual int GetIceData(ICE_INFO *iceInfo, ICE_TAIL *icetail, SENSOR_PARAM *sensorParam);
virtual bool OpenSensors(int sensortype);
virtual bool CloseSensors(int sensortype);
virtual bool OpenPTZSensors(int sec);
virtual bool ClosePTZSensors();
virtual bool GetPTZSensorsStatus();
virtual bool GetCameraStatus();
bool LoadNetworkInfo();
bool GetNextScheduleItem(uint32_t tsBasedZero, uint32_t scheduleTime, vector<uint32_t>& items);
void UpdatePosition(double lon, double lat, double radius, time_t ts);
@ -238,6 +253,9 @@ public:
mBuildTime = buildTime;
}
void UpdateSimcard(const std::string& simcard);
void UpdateEthernet(net_handle_t nethandle, bool available);
net_handle_t GetNetHandle() const;
static void TurnOnCameraPower(JNIEnv* env);
static void TurnOffCameraPower(JNIEnv* env);
@ -274,6 +292,17 @@ protected:
return false;
}
inline bool TakePTZPhotoCb(int result, const IDevice::PHOTO_INFO& photoInfo) const
{
if (m_listener != NULL)
{
std::vector<IDevice::RECOG_OBJECT> objects;
return m_listener->OnPTZPhotoTaken(result, photoInfo);
}
return false;
}
void QueryPowerInfo(std::map<std::string, std::string>& powerInfo);
std::string QueryCpuTemperature();
@ -284,7 +313,7 @@ protected:
void onError(const std::string& msg);
void onDisconnected(ACameraDevice* device);
void CloseCamera2(CPhoneCamera* camera, unsigned int photoId, bool turnOffOtg);
void CloseCamera2(CPhoneCamera* camera, unsigned int photoId, unsigned char cameraType);
static void handleSignal(int sig, siginfo_t *si, void *uc);
bool RegisterHandlerForSignal(int sig);
@ -298,9 +327,12 @@ protected:
int CallExecv(int rotation, int frontCamera, const std::string& outputPath, const std::vector<std::string>& images);
void SetStaticIp(const std::string& iface, const std::string& ip, const std::string& netmask, const std::string& gateway);
void SetStaticIp();
protected:
std::mutex m_devLocker;
mutable std::mutex m_devLocker;
JavaVM* m_vm;
jobject m_javaService;
@ -308,6 +340,9 @@ protected:
std::string m_tfCardPath;
std::string m_nativeLibraryDir;
NETWORK* m_network;
net_handle_t m_netHandle;
jmethodID mRegisterHeartbeatMid;
jmethodID mUpdateCaptureScheduleMid;
jmethodID mUpdateTimeMid;
@ -323,6 +358,7 @@ protected:
jmethodID mEnableGpsMid;
jmethodID mRequestPositionMid;
jmethodID mExecHdrplusMid;
jmethodID mSetStaticIpMid;
jmethodID mCallSysCameraMid;
@ -356,6 +392,15 @@ protected:
std::string m_simcard;
mutable std::mutex m_cameraLocker;
bool m_cameraStatus;
bool m_sensorsStatus;
time_t m_lastTime;
std::atomic<bool> m_shouldStopWaiting;
IDevice::ICE_TAIL m_tempData;
mutable std::mutex m_dataLocker;
};

File diff suppressed because it is too large Load Diff

@ -2328,6 +2328,8 @@ bool NdkCamera::convertAImageToNv21(AImage* image, uint8_t** nv21, int32_t& widt
}
}
return true;
}
void NdkCamera::EnumCameraResult(ACameraMetadata* result, CAPTURE_RESULT& captureResult)

@ -0,0 +1,242 @@
#include "httpclient.h"
#include "netcamera.h"
#include <errno.h>
static size_t OnWriteData(void* buffer, size_t size, size_t nmemb, void* lpVoid)
{
std::vector<uint8_t>* data = (std::vector<uint8_t>*)lpVoid;
if( NULL == data || NULL == buffer )
{
return -1;
}
uint8_t* begin = (uint8_t *)buffer;
uint8_t* end = begin + size * nmemb;
data->insert(data->end(), begin, end);
return nmemb;
}
static int SockOptCallback(void *clientp, curl_socket_t curlfd, curlsocktype purpose)
{
net_handle_t netHandle = *((net_handle_t *)clientp);
int res = android_setsocknetwork(netHandle, curlfd);
if (res == -1)
{
int errcode = errno;
printf("android_setsocknetwork errno=%d", errcode);
}
return res == 0 ? CURL_SOCKOPT_OK : CURL_SOCKOPT_ERROR;
}
int DoGetRequest(const char* url, const char* userName, const char* password, net_handle_t netHandle, std::vector<uint8_t>& data)
{
CURLcode nRet;
std::string auth;
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(curl, CURLOPT_URL, url);
if (userName != NULL && password != NULL && strlen(userName) > 0)
{
auth = userName;
auth += ":";
auth += password;
curl_easy_setopt(curl, CURLOPT_USERPWD, auth.c_str());
// DIGEST Auth
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
}
if (netHandle != NETWORK_UNSPECIFIED)
{
curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, SockOptCallback);
curl_easy_setopt(curl, CURLOPT_SOCKOPTDATA, &netHandle);
}
//
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
// 设置回调函数的参数,获取反馈信息
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &data);
// 接收数据时超时设置如果5秒内数据未接收完直接退出
#ifndef NDEBUG
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 60);
#else
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 60);
#endif
// 设置重定向次数,防止重定向次数太多
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 4);
// 连接超时,这个数值如果设置太短可能导致数据请求不到就断开了
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10);
nRet = curl_easy_perform(curl);
if (CURLE_OK != nRet)
{
printf("GET err=%d", nRet);
}
curl_easy_cleanup(curl);
return (0 == nRet) ? 0 : 1;
}
int DoPutRequest(const char* url, const char* userName, const char* password, net_handle_t netHandle, const char* contents, std::vector<uint8_t>& data)
{
std::string auth;
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_easy_setopt(curl, CURLOPT_URL, url);
if (userName != NULL && password != NULL && strlen(userName) > 0)
{
auth = userName;
auth += ":";
auth += password;
curl_easy_setopt(curl, CURLOPT_USERPWD, auth.c_str());
// DIGEST Auth
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
}
if (netHandle != NETWORK_UNSPECIFIED)
{
curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, SockOptCallback);
curl_easy_setopt(curl, CURLOPT_SOCKOPTDATA, &netHandle);
}
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
// 设置回调函数的参数,获取反馈信息
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &data);
// 接收数据时超时设置如果5秒内数据未接收完直接退出
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 60);
// 设置重定向次数,防止重定向次数太多
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 4);
// 连接超时,这个数值如果设置太短可能导致数据请求不到就断开了
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10);
CURLcode nRet = curl_easy_perform(curl);
if (CURLE_OK != nRet)
{
printf("GET err=%d", nRet);
}
curl_easy_cleanup(curl);
return (0 == nRet) ? 0 : 1;
}
bool requestCapture(uint8_t channel, uint8_t preset, const NET_PHOTO_INFO& photoInfo)
{
bool res = false;
std::vector<uint8_t> data;
const char* userName = NULL;
const char* password = NULL;
if (photoInfo.authType != 0)
{
userName = photoInfo.userName;
password = photoInfo.password;
}
std::string url = "http://";
url += photoInfo.ip;
url += photoInfo.url;
int nRet = DoGetRequest(url.c_str(), userName, password, photoInfo.netHandle, data);
if (0 == nRet)
{
if (!data.empty())
{
FILE *fp = fopen(photoInfo.outputPath, "wb");
if (fp != NULL)
{
fwrite(&data[0], data.size(), 1, fp);
fclose(fp);
res = true;
}
}
}
return res;
}
bool requestCapture(uint8_t channel, uint8_t preset, const NET_PHOTO_INFO& photoInfo, std::vector<uint8_t>& img)
{
bool res = false;
const char* userName = NULL;
const char* password = NULL;
if (photoInfo.authType != 0)
{
userName = photoInfo.userName;
password = photoInfo.password;
}
std::string url = "http://";
url += photoInfo.ip;
url += photoInfo.url;
int nRet = DoGetRequest(url.c_str(), userName, password, photoInfo.netHandle, img);
return (0 == nRet);
}
namespace nc_hk
{
bool requestCapture(uint8_t channel, uint8_t preset, const NET_PHOTO_INFO& photoInfo, std::vector<uint8_t>& img)
{
bool res = false;
const char* userName = NULL;
const char* password = NULL;
if (photoInfo.authType != 0)
{
userName = photoInfo.userName;
password = photoInfo.password;
}
std::string url = "http://";
url += photoInfo.ip;
url += photoInfo.url;
int nRet = DoGetRequest(url.c_str(), userName, password, photoInfo.netHandle, img);
#ifdef _DEBUG
if (0 == nRet)
{
FILE *fp = fopen("/sdcard/com.xypower.mpapp/tmp/netimg.jpg", "wb");
if (fp != NULL)
{
fwrite(&img[0], img.size(), 1, fp);
fclose(fp);
}
}
#endif
return (0 == nRet);
}
}
namespace nc_ys
{
bool requestCapture(uint8_t channel, uint8_t preset, const NET_PHOTO_INFO& photoInfo, std::vector<uint8_t>& img)
{
bool res = false;
const char* userName = NULL;
const char* password = NULL;
if (photoInfo.authType != 0)
{
userName = photoInfo.userName;
password = photoInfo.password;
}
std::string url = "http://";
url += photoInfo.ip;
url += photoInfo.url;
int nRet = DoGetRequest(url.c_str(), userName, password, photoInfo.netHandle, img);
#ifdef _DEBUG
if (0 == nRet)
{
FILE *fp = fopen("/sdcard/com.xypower.mpapp/tmp/netimg.jpg", "wb");
if (fp != NULL)
{
fwrite(&img[0], img.size(), 1, fp);
fclose(fp);
}
}
#endif
return (0 == nRet);
}
}

@ -0,0 +1,22 @@
#include <string>
#include <vector>
#include <curl/curl.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <bits/ioctl.h>
#include <android/multinetwork.h>
#ifndef __HTTP_CLIENT__
#define __HTTP_CLIENT__
bool setIPAddress(const char *if_name, const char *ip_addr, const char *net_mask, const char *gateway_addr);
int DoGetRequest(const char* url, const char* userName, const char* password, net_handle_t netHandle, std::vector<uint8_t>& data);
int DoPutRequest(const char* url, const char* userName, const char* password, net_handle_t netHandle, const char* contents, std::vector<uint8_t>& data);
#endif // __HTTP_CLIENT__

@ -0,0 +1,50 @@
#include <stdint.h>
#include <vector>
#include <android/multinetwork.h>
#ifndef __NET_CAMERA__
#define __NET_CAMERA__
struct NET_PHOTO_INFO
{
net_handle_t netHandle;
unsigned char authType; // 0, 1
unsigned char reserved[7]; // for memory alignment
char ip[24];
char userName[8];
char password[16];
char url[128];
char outputPath[128];
};
/*
struct NET_PHOTO_INFO
{
std::string ip;
std::string userName;
std::string password;
std::string interface;
std::string url;
std::string outputPath;
unsigned char authType; // 0, 1
unsigned char reserved[7]; // for memory alignment
};
*/
bool requestCapture(uint8_t channel, uint8_t preset, const NET_PHOTO_INFO& photoInfo);
bool requestCapture(uint8_t channel, uint8_t preset, const NET_PHOTO_INFO& photoInfo, std::vector<uint8_t>& img);
namespace nc_hk
{
bool requestCapture(uint8_t channel, uint8_t preset, const NET_PHOTO_INFO& photoInfo, std::vector<uint8_t>& img);
}
namespace nc_ys
{
bool requestCapture(uint8_t channel, uint8_t preset, const NET_PHOTO_INFO& photoInfo, std::vector<uint8_t>& img);
}
#endif // __NET_CAMERA__

@ -25,6 +25,8 @@ import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.net.ConnectivityManager;
import android.net.LinkAddress;
import android.net.LinkProperties;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
@ -161,6 +163,9 @@ public class MicroPhotoService extends Service {
FileOutputStream mAppRunningFile;
FileLock mAppLock;
private ConnectivityManager mConnectivityManager = null;
private ConnectivityManager.NetworkCallback mNetworkCallback = null;
private Runnable delayedSleep = new Runnable() {
@Override
public void run() {
@ -1438,6 +1443,79 @@ public class MicroPhotoService extends Service {
return exitCode;
}
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) {
InetAddress inetAddress = addresses.get(0).getAddress();
if (inetAddress != null) {
ip = inetAddress.getHostAddress();
}
}
}
} 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);
}
}
}
Intent intent = new Intent();
intent.putExtra("cmd", "setnet");
intent.putExtra("staticip", true);
intent.putExtra("iface", iface);
intent.putExtra("ip", ip);
intent.putExtra("netmask", netmask);
if (!TextUtils.isEmpty(gateway)) {
intent.putExtra("gateway", gateway);
}
// intent.putExtra("dns1", "8.8.8.8");
// intent.putExtra("dns2", "192.168.19.1");
sendBroadcast(getApplicationContext(), intent);
}
public static void sendBroadcast(Context context, Intent intent)
{
intent.setAction("com.xy.xsetting.action");
intent.setPackage("com.android.systemui");
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
context.sendBroadcast(intent);
}
/*
TelephonyManager telephonyManager = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
// for example value of first element
@ -1458,10 +1536,12 @@ cellSignalStrengthGsm.getDbm();
protected native boolean sendHeartbeat(long handler, int signalLevel);
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 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);
protected native void burstCaptureFinished(long handler, boolean result, int numberOfCaptures, String pathsJoinedByTab, boolean frontCamera, int rotation, long photoId);
public static native long takePhoto(int channel, int preset, boolean photoOrVideo, String configFilePath, String path);
public static native void releaseDeviceHandle(long deviceHandle);
public static native boolean sendExternalPhoto(long deviceHandle, String path, long photoInfo);
@ -1484,8 +1564,6 @@ cellSignalStrengthGsm.getDbm();
public static native boolean exportPublicKeyFile(int index, String outputPath);
public static native boolean exportPrivateFile(int index, String outputPath);
////////////////////////GPS////////////////////
// private static final String GPS_LOCATION_NAME = android.location.LocationManager.GPS_PROVIDER;
private LocationManager mLocationManager;

Loading…
Cancel
Save