Commit 4576f45f by cuiliang.shi

恒锋信息 定位

1 parent ff327440
Showing with 1722 additions and 1113 deletions
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
</component>
\ No newline at end of file
<component name="ProjectDictionaryState">
<dictionary name="Administrator">
<words>
<w>feng</w>
<w>heng</w>
<w>hengfeng</w>
<w>imsi</w>
<w>meid</w>
</words>
</dictionary>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>
\ No newline at end of file
...@@ -3,7 +3,7 @@ apply plugin: 'com.android.application' ...@@ -3,7 +3,7 @@ apply plugin: 'com.android.application'
android { android {
compileSdkVersion 28 compileSdkVersion 28
defaultConfig { defaultConfig {
applicationId "com.agenew.location_server.application" applicationId "com.toscl.location.hengfeng"
minSdkVersion 23 minSdkVersion 23
targetSdkVersion 28 targetSdkVersion 28
versionCode 11 versionCode 11
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":7,"versionName":"1.7","enabled":true,"outputFile":"LocationServer.apk","fullName":"release","baseName":"release"},"path":"LocationServer.apk","properties":{}}] [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":11,"versionName":"2.1","enabled":true,"outputFile":"LocationServer_2.1.apk","fullName":"release","baseName":"release"},"path":"LocationServer_2.1.apk","properties":{}}]
\ No newline at end of file \ No newline at end of file
package com.agenew.location_server.application; package com.toscl.location.hengfeng;
import android.content.Context; import android.content.Context;
import android.support.test.InstrumentationRegistry; import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4; import android.support.test.runner.AndroidJUnit4;
import android.util.Log;
import com.amap.api.maps2d.AMapUtils; import com.amap.api.maps2d.AMapUtils;
import com.amap.api.maps2d.model.LatLng; import com.amap.api.maps2d.model.LatLng;
...@@ -10,8 +11,6 @@ import com.amap.api.maps2d.model.LatLng; ...@@ -10,8 +11,6 @@ import com.amap.api.maps2d.model.LatLng;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/** /**
* Instrumented test, which will execute on an Android device. * Instrumented test, which will execute on an Android device.
* *
...@@ -19,18 +18,25 @@ import static org.junit.Assert.*; ...@@ -19,18 +18,25 @@ import static org.junit.Assert.*;
*/ */
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest { public class ExampleInstrumentedTest {
private String TAG = "ExampleInstrumentedTest" ;
@Test @Test
public void useAppContext() { public void useAppContext() {
// Context of the app under test. // Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext(); Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.john.myapplication", appContext.getPackageName()); // assertEquals("com.example.john.myapplication", appContext.getPackageName());
//
// LatLng wifiLatLng = new LatLng(mWifiLatitude, mWifiLongitude); LatLng wifiLatLng = new LatLng(29.673439, 121.431411);
// LatLng gpsLatLng = new LatLng(mGpsLatitude, mGpsLongitude); LatLng gpsLatLng = new LatLng(29.67364583333333, 121.43255967881944);
//
// float distance = AMapUtils.calculateLineDistance(wifiLatLng, gpsLatLng); float distance = AMapUtils.calculateLineDistance(wifiLatLng, gpsLatLng);
Log.d(TAG, "distance: " + distance);
} }
} }
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.agenew.location_server.application"> xmlns:tools="http://schemas.android.com/tools"
package="com.toscl.location.hengfeng">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
...@@ -15,7 +16,6 @@ ...@@ -15,7 +16,6 @@
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.SEND_SMS" /> <uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_CONTACTS"/> <uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
...@@ -26,16 +26,14 @@ ...@@ -26,16 +26,14 @@
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme"
android:name="com.toscl.location.hengfeng.AppApplication"
tools:ignore="GoogleAppIndexingWarning">
<meta-data android:name="com.amap.api.v2.apikey" android:value="2e40c8d145f8a0d4f9bb1cc7590594e7"> <meta-data android:name="com.amap.api.v2.apikey" android:value="2e40c8d145f8a0d4f9bb1cc7590594e7">
</meta-data> </meta-data>
<activity android:name="com.agenew.location_server.application.MainActivity" <activity android:name="com.toscl.location.hengfeng.activity.ServiceSettingActivity"
android:exported="true"> android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!--<category android:name="android.intent.category.LAUNCHER" />-->
</intent-filter>
<!--<intent-filter>--> <!--<intent-filter>-->
<!--<action android:name="com.android.settings.action.EXTRA_SETTINGS" />--> <!--<action android:name="com.android.settings.action.EXTRA_SETTINGS" />-->
...@@ -47,29 +45,34 @@ ...@@ -47,29 +45,34 @@
<!--<meta-data android:name="com.android.settings.title"--> <!--<meta-data android:name="com.android.settings.title"-->
<!--android:resource="@string/app_name" />--> <!--android:resource="@string/app_name" />-->
</activity> </activity>
<activity android:name="com.toscl.location.hengfeng.activity.NavActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.toscl.location.hengfeng.activity.ServiceInfoActivity">
</activity>
<activity android:name="com.toscl.location.hengfeng.activity.ServiceApplyActivity" />
<activity android:name="com.toscl.location.hengfeng.activity.ServiceStopActivity" />
<service android:name="com.amap.api.location.APSService" /> <service android:name="com.amap.api.location.APSService" />
<receiver android:name="com.agenew.location_server.application.LocationReceiver" <receiver android:name="com.toscl.location.hengfeng.recevier.LocationReceiver"
android:permission="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"> android:permission="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS">
<intent-filter> <intent-filter>
<action android:name="com.bird.send_sos" /> <action android:name="com.bird.send_sos" />
<action android:name="com.bird.close_sos" /> <action android:name="com.bird.close_sos" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<service android:name="com.agenew.location_server.application.BirdService" <service android:name="com.toscl.location.hengfeng.LocationService"
android:enabled="true" android:enabled="true"
android:exported="true"> android:exported="true">
</service> </service>
<receiver android:name="com.agenew.location_server.application.AlarmReceiver"></receiver> <receiver android:name="com.toscl.location.hengfeng.recevier.AlarmReceiver" />
<!-- <receiver android:name=".BirdService$NetWorkChangReceiver" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
<action android:name="android.net.wifi.STATE_CHANGE" />
</intent-filter>
</receiver>-->
</application> </application>
</manifest> </manifest>
\ No newline at end of file
package com.agenew.location_server.application;
import android.annotation.SuppressLint;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
import android.location.GpsSatellite;
import android.location.GpsStatus;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.SystemClock;
import android.provider.Settings;
import android.support.annotation.RequiresApi;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.agenew.location_server.application.api.IotApi;
import com.agenew.location_server.application.api.IotNetApiCallback;
import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.location.AMapLocationListener;
import com.amap.api.maps2d.AMapUtils;
import com.amap.api.maps2d.model.LatLng;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
public class BirdService extends Service {
public static int status = 0;
private final String DEFAULTPATH = "http://202.100.190.58:8090/api/cstmzPosition";
private final long DEFAULTINTERVAL = 30;
private String mMobile;
private String mIMEIStr;
private String mICCIDStr;
private String mIMSIStr;
private String mLongitude;
private String mLatitude;
private String mModel;
public AMapLocationClientOption mLocationOption = null;
private SubscriptionManager mSubscriptionManager;
private List<SubscriptionInfo> mSubList;
private String mStartTime;
public AMapLocationClient mLocationClient = null;
private String TAG = "BirdService";
private Context mContext;
private String mPath = "";
private int ret_code = 0;
private String ret_cfgv = "2019031512";
private LocationManager mLocationManager;
private int mNewMsgCount = 0;
private double mWifiLatitude = 0;
private double mWifiLongitude = 0;
private double mGpsLatitude = 0;
private double mGpsLongitude = 0;
private boolean mHasSendTheLocationInfo = false;
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
}
private NetWorkChangReceiver netWorkChangReceiver;
private boolean isRegistered = false;
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(TAG, "onStartCommand");
if (netWorkChangReceiver !=null){
unregisterReceiver(netWorkChangReceiver);
}
mHasSendTheLocationInfo = false;
mWifiAvailableErrorCount = 0;
mNetworkAvailableErrorCount = 0;
mLocationCount = 0;
mErrorCount = 0;
mContext = getApplicationContext();
// open gps & network.
Intent intent2 = new Intent("com.bird.open_gps_switch");
intent2.addFlags(0x01000000);
sendBroadcast(intent2);
ret_cfgv = DevicePreferences.getInstance(getApplicationContext()).getString("bird_ret_cfgv", "2019031512");
mPath = DevicePreferences.getInstance(mContext).getString("bird_location_upload_url", DEFAULTPATH);
long temp = DevicePreferences.getInstance(mContext).getLong("bird_location_upload_interval", DEFAULTINTERVAL);
Log.d(TAG, "CONFIG - PARAM, time minutes: " + temp
+ ", cfgv: " + ret_cfgv + ", path: " + mPath);
searchGPS();
// IotApi.init();
mHandler.sendEmptyMessageDelayed(0, 1000);
return super.onStartCommand(intent, flags, startId);
}
@SuppressLint("HandlerLeak")
private Handler mHandler = new Handler(){
@Override
public void handleMessage(Message msg) {
initLocation(mContext);
}
};
private int mLocationCount = 0;
private float mAccuracy = 10000;
private float mWifiAccuracy = 1000;
private float mGpsAccuracy = 1000;
private int mWifiAvailableErrorCount = 0;
private int mNetworkAvailableErrorCount = 0;
public AMapLocationListener mLocationListener = new AMapLocationListener() {
@Override
public void onLocationChanged(AMapLocation amapLocation) {
Log.d(TAG, "onLocationChanged");
if (!PhoneUtils.isWifiAvailable(getApplicationContext()) && mWifiAvailableErrorCount < 4){
mWifiAvailableErrorCount++;
Log.d(TAG, "wifi not available");
return;
}
if (!PhoneUtils.isNetwork(getApplicationContext()) && mNetworkAvailableErrorCount < 4){
mNetworkAvailableErrorCount++;
Log.d(TAG, "network not available");
return;
}
if (amapLocation != null) {
if (amapLocation.getErrorCode() == 0) {
mLocationCount++;
Log.d(TAG, "amapLocation.getLatitude(): " + amapLocation.getLatitude()
+ ", amapLocation.getLongitude(): " + amapLocation.getLongitude()
+ ", amapLocation.getAccuracy():"+amapLocation.getAccuracy()
+"amapLocation.getLocationType()" + amapLocation.getLocationType());
if (amapLocation.getAccuracy() < mAccuracy){
mAccuracy = amapLocation.getAccuracy();
mLatitude = String.valueOf(amapLocation.getLatitude());
mLongitude = String.valueOf(amapLocation.getLongitude());
}
if (amapLocation.getLocationType() == 5){
if (amapLocation.getAccuracy() < mWifiAccuracy){
mWifiAccuracy = amapLocation.getAccuracy();
mWifiLatitude = amapLocation.getLatitude();
mWifiLongitude = amapLocation.getLongitude();
}
}
if (amapLocation.getLocationType() == 1){
if (amapLocation.getAccuracy() < mGpsAccuracy){
mGpsAccuracy = amapLocation.getAccuracy();
mGpsLatitude = amapLocation.getLatitude();
mGpsLongitude = amapLocation.getLongitude();
}
}
if (mLocationCount > 15){
if (mWifiLatitude != 0 && mWifiLongitude != 0
&& mGpsLatitude != 0 && mGpsLongitude !=0){
LatLng wifiLatLng = new LatLng(mWifiLatitude, mWifiLongitude);
LatLng gpsLatLng = new LatLng(mGpsLatitude, mGpsLongitude);
float distance = AMapUtils.calculateLineDistance(wifiLatLng, gpsLatLng);
Log.d(TAG, "distance: " + distance +
", mWifiAccuracy:" + mWifiAccuracy +
", mGpsAccuracy: " + mGpsAccuracy);
if (distance > mWifiAccuracy + 60){
mLatitude = String.valueOf(mWifiLatitude);
mLongitude = String.valueOf(mWifiLongitude);
mAccuracy = mWifiAccuracy;
}else{
mLatitude = String.valueOf(mGpsLatitude);
mLongitude = String.valueOf(mGpsLongitude);
mAccuracy = mGpsAccuracy;
}
}
Log.d(TAG, "LAST PERFECT INFO amapLocation.getLatitude(): " + mLatitude
+ ", amapLocation.getLongitude(): " + mLongitude
+ ", amapLocation.getAccuracy():" + mAccuracy);
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
mStartTime = dateformat.format(System.currentTimeMillis());
// mStartTime = mStartTime.replace(" ", "%");
if (mLocationClient != null) {
mLocationClient.stopLocation();
}
handleGpsRelease();
mLocationCount = 0;
getPhoneInfo();
postLocationInfo();
}
} else {
Log.e(TAG, "location Error, ErrCode:"
+ amapLocation.getErrorCode() + ", errInfo:"
+ amapLocation.getErrorInfo());
handlerGpsError();
}
} else {
Log.d(TAG, "location Error");
handlerGpsError();
}
}
};
private void handleGpsRelease() {
if (mLocationClient != null) {
mLocationClient.stopLocation();
}
// Android 7.0 GnssStatusListenerTransport Message. eg: https://www.jianshu.com/p/1b6a66020555
if (mLocListener != null){
mLocationManager.removeUpdates(mLocListener);
mLocListener = null;
}
if (mGpsListener != null){
mLocationManager.removeGpsStatusListener(mGpsListener);
mGpsListener = null;
}
mLocationManager = null;
}
private void handlerGpsError() {
Log.d(TAG, "handlerGpsError");
mErrorCount++;
if (mErrorCount > 6){
handleGpsRelease();
setAlarm();
}
}
public void setAlarm(){
Log.d(TAG, "setAlarm");
ret_cfgv = DevicePreferences.getInstance(getApplicationContext()).getString("bird_ret_cfgv", "2019031512");
mPath = DevicePreferences.getInstance(mContext).getString("bird_location_upload_url", DEFAULTPATH);
long temp = DevicePreferences.getInstance(mContext).getLong("bird_location_upload_interval", DEFAULTINTERVAL);
Log.d(TAG, "ALARM - CONFIG - PARAM, time minutes: " + temp
+ ", cfgv: " + ret_cfgv + ", path: " + mPath);
long mInterval = temp * 60 * 1000;
if (mInterval != 0) {
AlarmManager manger = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(this, AlarmReceiver.class);
PendingIntent pendingIntent2 = PendingIntent.getBroadcast(getApplicationContext(), 0, i, 0);
long triggerAtTime = SystemClock.elapsedRealtime();
triggerAtTime = triggerAtTime + mInterval + 10;
manger.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggerAtTime, pendingIntent2);
}
/* if (!mHasSendTheLocationInfo){
mNetworkListenerHandler.sendEmptyMessageDelayed(0, 10000);
return;
}*/
stopForeground(true);
Log.d(TAG, "time:" + new Date().toString());
stopSelf();
}
private void setNetworkListener() {
mLocationManager.removeUpdates(mLocListener);
mLocationManager.removeGpsStatusListener(mGpsListener);
mLocationClient.stopLocation();
// network listener
netWorkChangReceiver = new NetWorkChangReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
registerReceiver(netWorkChangReceiver, filter);
isRegistered = true;
}
private int mErrorCount = 0;
@SuppressLint("HandlerLeak")
private Handler mErrorHandler = new Handler(){
@Override
public void handleMessage(Message msg) {
postLocationInfo();
}
};
private void postLocationInfo() {
new Thread(new Runnable() {
@Override
public void run() {
final StringBuffer strbuf = new StringBuffer();
strbuf.append("longitude=" + mLongitude);
strbuf.append("&latitude=" + mLatitude);
strbuf.append("&time=" + mStartTime);
strbuf.append("&meid=" + mIMEIStr);
strbuf.append("&tel=" + mMobile);
strbuf.append("&iccid=" + mICCIDStr);
strbuf.append("&imsi=" + mIMSIStr);
strbuf.append("&model=" + mModel);
strbuf.append("&cfgv=" + ret_cfgv);
strbuf.append("&gcs=" + "GCJ02");
Log.d(TAG, "REQUEST: URL: " + mPath + ", BODY:" + strbuf);
URL url = null;
HttpURLConnection httpURLConnection = null;
OutputStream os = null;
try {
url = new URL(mPath);
} catch (Exception e) {
e.printStackTrace();
}
try {
httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setReadTimeout(15000);
httpURLConnection.setDoOutput(true);
httpURLConnection.setRequestProperty("Charset", "UTF-8");
httpURLConnection.setRequestProperty("Content-Length", strbuf.toString().length() + "");
os = httpURLConnection.getOutputStream();
os.write(strbuf.toString().getBytes());
os.flush();
int responseCode = httpURLConnection.getResponseCode();
Log.d(TAG, "responseCode--" + responseCode);
if (responseCode == HttpURLConnection.HTTP_OK) {
InputStreamReader is = new InputStreamReader(httpURLConnection.getInputStream());
StringBuffer sb = new StringBuffer();
int i = 0;
while ((i = is.read()) != -1) {
sb.append((char) i);
}
is.close();
Log.d(TAG, "server response: " + sb);
JSONObject jsonObject = new JSONObject(sb.toString());
ret_code = jsonObject.getInt("ret_code");
if (ret_code == 1){
ret_cfgv = jsonObject.getString("cfgv");
mPath = jsonObject.getString("url");
Log.d(TAG, "new path: " + mPath);
if (!mPath.equals("0")){
DevicePreferences.getInstance(mContext).putString("bird_location_upload_url", mPath);
}
int timeSpanMinutes = jsonObject.getInt("time_span");
if (timeSpanMinutes == 999999){
DevicePreferences.getInstance(mContext).putLong("bird_location_upload_interval", 0);
}else if (timeSpanMinutes == 0){
Log.d(TAG, "time span not change");
}else{
DevicePreferences.getInstance(mContext).putLong("bird_location_upload_interval", timeSpanMinutes);
}
DevicePreferences.getInstance(mContext).putString("bird_ret_cfgv", ret_cfgv);
}else if (ret_code == 0){
Log.d(TAG, "upload success");
}else{
Log.d(TAG, "upload failed");
}
mHasSendTheLocationInfo = true;
} else if (responseCode != 200) {
Log.d(TAG, "request failed");
}
setAlarm();
} catch (Exception e) {
Log.d(TAG, "Exception:" + e.toString());
mErrorCount++;
if (mErrorCount > 5){
handleGpsRelease();
setAlarm();
}else{
long temp = DevicePreferences.getInstance(mContext).getLong("bird_location_upload_interval", DEFAULTINTERVAL);
mErrorHandler.sendEmptyMessageDelayed(0, temp);
}
} finally {
httpURLConnection.disconnect();
Log.d(TAG, "close connect");
if (os != null) {
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}).start();
}
private void initLocation(Context context) {
Log.d(TAG, "initLocation");
if (mLocationClient != null) {
mLocationClient.stopLocation();
}
//init
mLocationClient = new AMapLocationClient(context);
//use callback
mLocationClient.setLocationListener(mLocationListener);
//init AMapLocationClientOption
mLocationOption = new AMapLocationClientOption();
//set model is AMapLocationMode.Battery_Saving
mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
mLocationOption.setInterval(1000);
mLocationOption.setLocationCacheEnable(false);
mLocationOption.setSensorEnable(false);
/* mLocationOption.setGpsFirst(true);
mLocationOption.setGpsFirstTimeout(10*1000);*/
AMapLocationClientOption.setOpenAlwaysScanWifi(true);
mLocationClient.setLocationOption(mLocationOption);
mLocationClient.startLocation();
}
private void getPhoneInfo() {
Log.d(TAG, "getPhoneInfo");
String temp_imie = Settings.System.getString(getContentResolver(), "bird_loc_imei");
String temp_mobile = Settings.System.getString(getContentResolver(), "bird_loc_mobile");
String temp_iccid = Settings.System.getString(getContentResolver(), "bird_loc_iccid");
String temp_imsi = Settings.System.getString(getContentResolver(), "bird_loc_imsi");
mIMEIStr = temp_imie.substring(0, temp_imie.length() - 1);
mMobile = temp_mobile.substring(0, temp_mobile.length() - 1);
mIMSIStr = temp_imsi.substring(0, temp_imsi.length() - 1);
mICCIDStr = temp_iccid.substring(0, temp_iccid.length() - 1);
// String temp_model = Build.MODEL;
String temp_model = PhoneUtils.getProperty("ro.qiku.custom.model", "undefined");
if (temp_model.equals("undefined")){
temp_model = Build.MODEL;
}
mModel = temp_model.trim().replaceAll(" ", "");
}
@Override
public void onDestroy() {
if (isRegistered) {
unregisterReceiver(netWorkChangReceiver);
}
// close gps & network.
Intent intent = new Intent("com.bird.close_gps_switch");
intent.addFlags(0x01000000);
getApplicationContext().sendBroadcast(intent);
super.onDestroy();
Log.d(TAG, "onDestory");
}
public LocationListener mLocListener = new LocationListener() {
public void onLocationChanged(Location location) {
Log.v(TAG, "Enter onLocationChanged function");
}
public void onProviderDisabled(String provider) {
Log.v(TAG, "Enter onProviderDisabled function");
}
public void onProviderEnabled(String provider) {
Log.v(TAG, "Enter onProviderEnabled function");
}
public void onStatusChanged(String provider, int status, Bundle extras) {
Log.v(TAG, "Enter onStatusChanged function");
}
};
private void showGpsStatus(CharSequence txt, int duration) {
Log.v(TAG, "Enter showGpsStatus function");
}
public GpsStatus.Listener mGpsListener = new GpsStatus.Listener() {
private void onFirstFix(int ttff) {
Log.v(TAG, "Enter onFirstFix function: ttff = " + ttff);
CharSequence txt = new String("GPS Fix after " + ttff + "ms");
showGpsStatus(txt, Toast.LENGTH_LONG);
}
private void onGpsStarted() {
Log.v(TAG, "Enter onGpsStarted function");
CharSequence txt = new String("GPS started");
showGpsStatus(txt, Toast.LENGTH_SHORT);
}
private void onGpsStopped() {
Log.v(TAG, "Enter onGpsStopped function");
CharSequence txt = new String("GPS stopped");
showGpsStatus(txt, Toast.LENGTH_SHORT);
}
private boolean isLocationFixed(Iterable<GpsSatellite> list) {
boolean fixed = false;
synchronized (this) {
int index = 0;
for (GpsSatellite sate : list) {
if (sate.usedInFix()) {
fixed = true;
break;
}
index++;
}
}
return fixed;
}
public void onGpsStatusChanged(int event) {
Log.v(TAG, "Enter onGpsStatusChanged function");
if (mLocationManager != null){
GpsStatus sta = mLocationManager.getGpsStatus(null);
if (event == GpsStatus.GPS_EVENT_STARTED) {
onGpsStarted();
Log.d(TAG, "STARTED");
} else if (event == GpsStatus.GPS_EVENT_STOPPED) {
onGpsStopped();
Log.d(TAG, "STOPPED");
} else if (event == GpsStatus.GPS_EVENT_FIRST_FIX) {
onFirstFix(sta.getTimeToFirstFix());
Log.d(TAG, "FIRST_FIX");
} else if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) {
if (isLocationFixed(sta.getSatellites()) == false) {
Log.d(TAG, "UNAVAILABLE");
} else {
Log.d(TAG, "AVAILABLE");
}
}
}
}
};
private void searchGPS() {
try {
mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if (mLocationManager != null) {
mLocationManager.requestLocationUpdates("gps", 0, 0,
mLocListener);
mLocationManager.addGpsStatusListener(mGpsListener);
if (mLocationManager.isProviderEnabled("gps")) {
Log.d(TAG, "gps" + " enabled");
} else {
Log.d(TAG, "gps" + " disabled");
}
Log.d(TAG, "UNKNOWN");
} else {
Log.w(TAG, "new mLocationManager failed");
}
} catch (SecurityException e) {
Toast.makeText(this, "security exception", Toast.LENGTH_LONG)
.show();
Log.w(TAG, "Exception: " + e.getMessage());
} catch (IllegalArgumentException e) {
Log.w(TAG, "Exception: " + e.getMessage());
}
}
public class NetWorkChangReceiver extends BroadcastReceiver {
private String getConnectionType(int type) {
String connType = "";
if (type == ConnectivityManager.TYPE_MOBILE) {
connType = "3G NETWORK";
} else if (type == ConnectivityManager.TYPE_WIFI) {
connType = "WIFI NETWORK";
}
return connType;
}
@Override
public void onReceive(Context context, Intent intent) {
if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())) {
int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0);
Log.e("TAG", "wifiState:" + wifiState);
switch (wifiState) {
case WifiManager.WIFI_STATE_DISABLED:
break;
case WifiManager.WIFI_STATE_DISABLING:
break;
}
}
if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) {
NetworkInfo info = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
if (info != null) {
//
if (NetworkInfo.State.CONNECTED == info.getState() && info.isAvailable()) {
if (info.getType() == ConnectivityManager.TYPE_WIFI || info.getType() == ConnectivityManager.TYPE_MOBILE) {
Log.i("TAG", getConnectionType(info.getType()) + " CONNECTED");
startTheLocationTask();
}
} else {
Log.i("TAG", getConnectionType(info.getType()) + " DISCONNECTED");
}
}
}
}
}
private void startTheLocationTask() {
// open gps & network.
Intent intent2 = new Intent("com.bird.open_gps_switch");
intent2.addFlags(0x01000000);
sendBroadcast(intent2);
ret_cfgv = DevicePreferences.getInstance(getApplicationContext()).getString("bird_ret_cfgv", "2019031512");
mPath = DevicePreferences.getInstance(mContext).getString("bird_location_upload_url", DEFAULTPATH);
long temp = DevicePreferences.getInstance(mContext).getLong("bird_location_upload_interval", DEFAULTINTERVAL);
Log.d(TAG, "CONFIG - PARAM, time minutes: " + temp
+ ", cfgv: " + ret_cfgv + ", path: " + mPath);
searchGPS();
// IotApi.init();
mHandler.sendEmptyMessageDelayed(0, 1000);
}
}
package com.agenew.location_server.application;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.support.v4.content.SharedPreferencesCompat;
import java.util.Set;
public class DevicePreferences {
private static DevicePreferences sDevicePreferences;
private final SharedPreferences mShareferences;
private final SharedPreferences.Editor mEditor;
private DevicePreferences(Context context) {
mShareferences = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE);
mEditor = mShareferences.edit();
}
public static synchronized DevicePreferences getInstance(Context context) {
if (null == sDevicePreferences) {
sDevicePreferences = new DevicePreferences(context.getApplicationContext());
}
return sDevicePreferences;
}
public void putInt(final String key, final int value) {
mEditor.putInt(key, value);
SharedPreferencesCompat.EditorCompat.getInstance().apply(mEditor);
}
public void putLong(final String key, final long value) {
mEditor.putLong(key, value);
SharedPreferencesCompat.EditorCompat.getInstance().apply(mEditor);
}
public void putString(final String key, final String value) {
mEditor.putString(key, value);
SharedPreferencesCompat.EditorCompat.getInstance().apply(mEditor);
}
public void putFloat(final String key, final float value) {
mEditor.putFloat(key, value);
SharedPreferencesCompat.EditorCompat.getInstance().apply(mEditor);
}
public void putBoolean(final String key, final boolean value) {
mEditor.putBoolean(key, value);
SharedPreferencesCompat.EditorCompat.getInstance().apply(mEditor);
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void putStringSet(final String key, final Set<String> values) {
mEditor.putStringSet(key, values);
SharedPreferencesCompat.EditorCompat.getInstance().apply(mEditor);
}
public int getInt(final String key, final int defaultValue) {
return mShareferences.getInt(key, defaultValue);
}
public long getLong(final String key, final long defaultValue) {
return mShareferences.getLong(key, defaultValue);
}
public String getString(final String key, final String defaultValue) {
return mShareferences.getString(key, defaultValue);
}
public float getFloat(final String key, final float defaultValue) {
return mShareferences.getFloat(key, defaultValue);
}
public boolean getBoolean(final String key, final boolean defaultValue) {
return mShareferences.getBoolean(key, defaultValue);
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public Set<String> getStringSet(final String key) {
return mShareferences.getStringSet(key, null);
}
}
package com.agenew.location_server.application;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.util.Log;
public class LocationReceiver extends BroadcastReceiver{
private String TAG = "LocationReceiver";
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.d(TAG, "action:" + action);
if (action.equals("com.bird.send_sos")){
if (BirdService.status != 1){
Log.d("qqh","bird_sos_open");
Intent intentThree = new Intent(context, BirdService.class);
DevicePreferences.getInstance(context).putBoolean("is_need_notification", true);
context.startForegroundService(intentThree);
BirdService.status = 1;
}
}else if (action.equals("com.bird.close_sos")){
Intent intentThree = new Intent(context, BirdService.class);
context.stopService(intentThree);
BirdService.status = -1;
}
}
}
package com.agenew.location_server.application;
import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.agenew.location_server.application.permission.MPermission;
import com.agenew.location_server.application.permission.annotation.OnMPermissionDenied;
import com.agenew.location_server.application.permission.annotation.OnMPermissionGranted;
import com.agenew.location_server.application.permission.annotation.OnMPermissionNeverAskAgain;
public class MainActivity extends Activity implements View.OnClickListener {
private static final String TAG="BirdService";
private SharedPreferences sp;
private LocationReceiver locationRecevier;
private Context mContext;
private final static String DEFAULTPATH = "http://202.100.190.58:8090/api/cstmzPosition";
private final static long DEFAULTINTERVAL = 30;
private EditText url_et;
private EditText interval_et;
private Button btnCannel;
private Button btnSave;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location_msg);
mContext = this;
String url = DevicePreferences.getInstance(mContext).getString("bird_location_upload_url", DEFAULTPATH);
Long interval = DevicePreferences.getInstance(mContext).getLong("bird_location_upload_interval",DEFAULTINTERVAL);
Log.d("qqh","interval"+interval);
url_et = findViewById(R.id.url_value);
interval_et =findViewById(R.id.interval_value);
url_et.setText(url);
interval_et.setText(String.valueOf(interval));
btnCannel = findViewById(R.id.bt_cancel);
btnSave = findViewById(R.id.bt_save);
btnCannel.setOnClickListener(this);
btnSave.setOnClickListener(this);
sp = getSharedPreferences("config", MODE_PRIVATE);
requestBasicPermission();
// locationRecevier = new LocationReceiver();
// IntentFilter filter = new IntentFilter();
// filter.addAction("com.bird.send_sos");
// filter.addAction("com.bird.close_sos");
// registerReceiver(locationRecevier, filter);
Log.d("qqh","main___start");
//sendBroadcast(new Intent("com.bird.send_sos"));
// Intent intentThree = new Intent(this, BirdService.class);
// startForegroundService(intentThree);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
break;
}
return true;
}
@Override
public void onClick(View v) {
Log.d("qqh","click"+v.getId());
switch (v.getId()) {
case R.id.bt_cancel:
Toast.makeText(mContext, R.string.save_cacel, Toast.LENGTH_SHORT).show();
finish();
break;
case R.id.bt_save:
String url_temp =url_et.getText().toString().trim();
String interval_temp =interval_et.getText().toString();
if(url_temp == null || "".equals(url_temp)|| url_temp.isEmpty()){
Toast.makeText(this, getString(R.string.server_prompt), Toast.LENGTH_SHORT).show();
break;
}
if(interval_temp == null || "".equals(interval_temp)|| interval_temp.isEmpty()){
Toast.makeText(this, getString(R.string.interval_prompt), Toast.LENGTH_SHORT).show();
break;
}
Long t=Long.valueOf(interval_temp);
Log.d(TAG,"time---"+t);
DevicePreferences.getInstance(MainActivity.this).putString("bird_location_upload_url",url_temp );
DevicePreferences.getInstance(MainActivity.this).putLong("bird_location_upload_interval",t);
Toast.makeText(mContext, R.string.save_tips, Toast.LENGTH_SHORT).show();
finish();
break;
}
}
@Override
protected void onDestroy() {
super.onDestroy();
// unregisterReceiver(locationRecevier);
}
private static final int BASIC_PERMISSION_REQUEST_CODE = 100;
private static final String[] BASIC_PERMISSIONS = new String[]{
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.CAMERA,
Manifest.permission.READ_PHONE_STATE,
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.SEND_SMS
};
private void requestBasicPermission() {
MPermission.printMPermissionResult(true, this, BASIC_PERMISSIONS);
MPermission.with(MainActivity.this)
.setRequestCode(BASIC_PERMISSION_REQUEST_CODE)
.permissions(BASIC_PERMISSIONS)
.request();
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
MPermission.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
}
@OnMPermissionGranted(BASIC_PERMISSION_REQUEST_CODE)
public void onBasicPermissionSuccess() {
// Toast.makeText(this, "success to get permission", Toast.LENGTH_SHORT).show();
}
@OnMPermissionDenied(BASIC_PERMISSION_REQUEST_CODE)
@OnMPermissionNeverAskAgain(BASIC_PERMISSION_REQUEST_CODE)
public void onBasicPermissionFailed() {
// Toast.makeText(this, "fail to get permission", Toast.LENGTH_SHORT).show();
}
}
package com.toscl.location.hengfeng;
import android.app.Application;
import com.toscl.location.hengfeng.api.IotApi;
public class AppApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
IotApi.init();
}
}
package com.toscl.location.hengfeng;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.IBinder;
import android.os.SystemClock;
import android.util.Log;
import android.widget.Toast;
import com.toscl.location.hengfeng.api.IotApi;
import com.toscl.location.hengfeng.api.IotNetApiCallback;
import com.toscl.location.hengfeng.recevier.AlarmReceiver;
import com.toscl.location.hengfeng.util.PreferencesUtil;
import com.toscl.location.hengfeng.util.PhoneUtils;
import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.location.AMapLocationListener;
import com.amap.api.maps2d.AMapUtils;
import com.amap.api.maps2d.model.LatLng;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.json.JSONException;
import org.json.JSONObject;
public class LocationService extends Service {
private String TAG = "LocationService";
private String mLongitude;
private String mLatitude;
private double mWifiLatitude = 0;
private double mWifiLongitude = 0;
private double mGpsLatitude = 0;
private double mGpsLongitude = 0;
private float mAccuracy = 10000;
private float mWifiAccuracy = 1000;
private float mGpsAccuracy = 1000;
private int mErrorCount = 0;
private int mRequestLocationCount = 0;
private int mWifiAvailableErrorCount = 0;
private int mNetworkAvailableErrorCount = 0;
private LocationManager mLocationManager;
public AMapLocationClientOption mLocationOption = null;
public AMapLocationClient mLocationClient = null;
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(TAG, "onStartCommand");
resetTheCounts();
sendOpenGpsBroadcast();
requestLocationUpdates();
initLocation(this);
return super.onStartCommand(intent, flags, startId);
}
public AMapLocationListener mLocationListener = new AMapLocationListener() {
@Override
public void onLocationChanged(AMapLocation amapLocation) {
Log.d(TAG, "onLocationChanged");
/*
if (!PhoneUtils.isWifiAvailable(getApplicationContext()) && mWifiAvailableErrorCount < 4){
mWifiAvailableErrorCount++;
Log.d(TAG, "wifi not available");
return;
}
*/
if (!PhoneUtils.isNetwork(getApplicationContext()) && mNetworkAvailableErrorCount < 4) {
mNetworkAvailableErrorCount++;
Log.d(TAG, "network not available");
return;
}
if (amapLocation != null) {
if (amapLocation.getErrorCode() == 0) {
mRequestLocationCount++;
Log.d(TAG, "amapLocation.getLatitude(): " + amapLocation.getLatitude()
+ ", amapLocation.getLongitude(): " + amapLocation.getLongitude()
+ ", amapLocation.getAccuracy():" + amapLocation.getAccuracy()
+ "amapLocation.getLocationType()" + amapLocation.getLocationType());
if (amapLocation.getAccuracy() < mAccuracy) {
mAccuracy = amapLocation.getAccuracy();
mLatitude = String.valueOf(amapLocation.getLatitude());
mLongitude = String.valueOf(amapLocation.getLongitude());
}
if (amapLocation.getLocationType() == 5) {
if (amapLocation.getAccuracy() < mWifiAccuracy) {
mWifiAccuracy = amapLocation.getAccuracy();
mWifiLatitude = amapLocation.getLatitude();
mWifiLongitude = amapLocation.getLongitude();
}
}
if (amapLocation.getLocationType() == 1) {
if (amapLocation.getAccuracy() < mGpsAccuracy) {
mGpsAccuracy = amapLocation.getAccuracy();
mGpsLatitude = amapLocation.getLatitude();
mGpsLongitude = amapLocation.getLongitude();
}
}
if (mRequestLocationCount > 15) {
if (mWifiLatitude != 0 && mWifiLongitude != 0
&& mGpsLatitude != 0 && mGpsLongitude != 0) {
LatLng wifiLatLng = new LatLng(mWifiLatitude, mWifiLongitude);
LatLng gpsLatLng = new LatLng(mGpsLatitude, mGpsLongitude);
float distance = AMapUtils.calculateLineDistance(wifiLatLng, gpsLatLng);
Log.d(TAG, "distance: " + distance +
", mWifiAccuracy:" + mWifiAccuracy +
", mGpsAccuracy: " + mGpsAccuracy);
if (distance > mWifiAccuracy + 60) {
mLatitude = String.valueOf(mWifiLatitude);
mLongitude = String.valueOf(mWifiLongitude);
mAccuracy = mWifiAccuracy;
} else {
mLatitude = String.valueOf(mGpsLatitude);
mLongitude = String.valueOf(mGpsLongitude);
mAccuracy = mGpsAccuracy;
}
}
Log.d(TAG, "LAST PERFECT INFO amapLocation.getLatitude(): " + mLatitude
+ ", amapLocation.getLongitude(): " + mLongitude
+ ", amapLocation.getAccuracy():" + mAccuracy);
if (mLocationClient != null) {
mLocationClient.stopLocation();
}
handleGpsRelease();
mRequestLocationCount = 0;
postLocationInfo();
}
} else {
Log.e(TAG, "location Error, ErrCode:"
+ amapLocation.getErrorCode() + ", errInfo:"
+ amapLocation.getErrorInfo());
handlerGpsError();
}
} else {
Log.d(TAG, "location Error");
handlerGpsError();
}
}
};
private void handleGpsRelease() {
if (mLocationClient != null) {
mLocationClient.stopLocation();
}
// Android 7.0 GnssStatusListenerTransport Message. eg: https://www.jianshu.com/p/1b6a66020555
if (mLocListener != null) {
mLocationManager.removeUpdates(mLocListener);
mLocListener = null;
}
mLocationManager = null;
}
private void handlerGpsError() {
Log.d(TAG, "handlerGpsError");
mErrorCount++;
if (mErrorCount > 6) {
handleGpsRelease();
alarmToSendBroadcastForNextStartService();
}
}
public void alarmToSendBroadcastForNextStartService() {
Log.d(TAG, "alarmToSendBroadcastForNextStartService");
int frequency = PreferencesUtil.getInstance(this)
.getInt(PreferencesUtil.HENG_FENG_FREQUENCY, PreferencesUtil.HENG_FENG_DEFAULT_FREQUENCY);
if (frequency != 9999) {
AlarmManager manger = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Intent alarmReceiverIntent = new Intent(this, AlarmReceiver.class);
PendingIntent alarmReceiverPendingIntent =
PendingIntent.getBroadcast(getApplicationContext(), 0, alarmReceiverIntent, 0);
manger.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime() + frequency * 60 * 1000 + 10,
alarmReceiverPendingIntent);
}
stopForeground(true);
stopSelf();
}
private void postLocationInfo() {
JSONObject jsonBody = new JSONObject();
try {
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_MEID, PhoneUtils.getPhoneMEID(getApplicationContext()));
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_TEL, PreferencesUtil.getInstance(this).getString(PreferencesUtil.HENG_FENG_PHONE, ""));
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_TIME, System.currentTimeMillis());
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_IMSI, PhoneUtils.getSubId(getApplicationContext(), PreferencesUtil.HENG_FENG_DEFAULT_SLOT));
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_LONGITUDE, mLongitude);
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_LATITUDE, mLatitude);
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_GCS, 1);
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_SIGN, PhoneUtils.getHengdaSign(jsonBody));
} catch (JSONException x) {
x.printStackTrace();
}
IotApi.hengfeng_service_post(jsonBody, new IotNetApiCallback() {
@Override
public void onSuccess(String response) {
JsonObject resp = new JsonParser().parse(response).getAsJsonObject();
int code = resp.get(PreferencesUtil.HENG_FENG_SERVER_CODE).getAsInt();
String msg = resp.get(PreferencesUtil.HENG_FENG_SERVER_MSG).getAsString();
JsonObject data = resp.get(PreferencesUtil.HENG_FENG_SERVER_RESPONSE_DATA).getAsJsonObject();
/*
* server data response
* */
String begin = data.get(PreferencesUtil.HENG_FENG_SERVER_BEGIN).getAsString();
int beginIndex = Integer.parseInt(begin.split(":")[0]);
String end = data.get(PreferencesUtil.HENG_FENG_SERVER_END).getAsString();
int endIndex = Integer.parseInt(end.split(":")[0]);
int frequency = data.get(PreferencesUtil.HENG_FENG_SERVER_FREQUENCY).getAsInt();
String url = data.get(PreferencesUtil.HENG_FENG_SERVER_URL).getAsString();
String dataStart = data.get(PreferencesUtil.HENG_FENG_SERVER_DATA_START).getAsString();
String dataEnd = data.get(PreferencesUtil.HENG_FENG_SERVER_DATA_END).getAsString();
if (code == 0 || code == 1) {
if (code == 1) {
PreferencesUtil.getInstance(getApplicationContext())
.putInt(PreferencesUtil.HENG_FENG_BEGIN, beginIndex);
PreferencesUtil.getInstance(getApplicationContext())
.putInt(PreferencesUtil.HENG_FENG_END, endIndex);
if (frequency != 0) {
PreferencesUtil.getInstance(getApplicationContext())
.putInt(PreferencesUtil.HENG_FENG_FREQUENCY, frequency);
}
PreferencesUtil.getInstance(getApplicationContext())
.putString(PreferencesUtil.HENG_FENG_URL, url);
PreferencesUtil.getInstance(getApplicationContext())
.putString(PreferencesUtil.HENG_FENG_DATA_START, dataStart);
PreferencesUtil.getInstance(getApplicationContext())
.putString(PreferencesUtil.HENG_FENG_DATA_END, dataEnd);
}
alarmToSendBroadcastForNextStartService();
} else {
Toast.makeText(LocationService.this, msg, Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailed(Exception e) {
}
});
}
private void initLocation(Context context) {
Log.d(TAG, "initLocation");
if (mLocationClient != null) {
mLocationClient.stopLocation();
}
//init
mLocationClient = new AMapLocationClient(context);
//use callback
mLocationClient.setLocationListener(mLocationListener);
//init AMapLocationClientOption
mLocationOption = new AMapLocationClientOption();
//set model is AMapLocationMode.Battery_Saving
mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
mLocationOption.setInterval(1000);
mLocationOption.setLocationCacheEnable(false);
mLocationOption.setSensorEnable(false);
/* mLocationOption.setGpsFirst(true);
mLocationOption.setGpsFirstTimeout(10*1000);*/
AMapLocationClientOption.setOpenAlwaysScanWifi(true);
mLocationClient.setLocationOption(mLocationOption);
mLocationClient.startLocation();
}
@Override
public void onDestroy() {
sendCloseGpsBroadcast();
super.onDestroy();
}
public LocationListener mLocListener = new LocationListener() {
public void onLocationChanged(Location location) {
Log.v(TAG, "Enter onLocationChanged function");
}
public void onProviderDisabled(String provider) {
Log.v(TAG, "Enter onProviderDisabled function");
}
public void onProviderEnabled(String provider) {
Log.v(TAG, "Enter onProviderEnabled function");
}
public void onStatusChanged(String provider, int status, Bundle extras) {
Log.v(TAG, "Enter onStatusChanged function");
}
};
private final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
private void sendOpenGpsBroadcast() {
/*Intent intent = new Intent(PhoneUtils.HENFENG_BROADCAST_OPEN_GPS);
intent.addFlags(FLAG_RECEIVER_INCLUDE_BACKGROUND);
sendBroadcast(intent);*/
}
private void sendCloseGpsBroadcast() {
/*Intent intent = new Intent(PhoneUtils.HENFENG_BROADCAST_CLOSE_GPS);
intent.addFlags(FLAG_RECEIVER_INCLUDE_BACKGROUND);
getApplicationContext().sendBroadcast(intent);*/
}
private void resetTheCounts() {
mErrorCount = 0;
mRequestLocationCount = 0;
mWifiAvailableErrorCount = 0;
mNetworkAvailableErrorCount = 0;
}
private void requestLocationUpdates() {
try {
mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if (mLocationManager != null) {
mLocationManager.requestLocationUpdates("gps", 0, 0,
mLocListener);
}
} catch (SecurityException e) {
Log.w(TAG, "Exception: " + e.getMessage());
} catch (IllegalArgumentException e) {
Log.w(TAG, "Exception: " + e.getMessage());
}
}
}
package com.toscl.location.hengfeng.activity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import com.toscl.location.hengfeng.R;
import com.toscl.location.hengfeng.util.PhoneUtils;
import com.toscl.location.hengfeng.util.PreferencesUtil;
public class NavActivity extends Activity implements View.OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location_nav);
setTitle(getString(R.string.title_nav));
findViewById(R.id.service_info).setOnClickListener(this);
findViewById(R.id.service_setting).setOnClickListener(this);
findViewById(R.id.service_apply).setOnClickListener(this);
findViewById(R.id.service_stop).setOnClickListener(this);
}
@Override
public void onClick(View v) {
int id = v.getId();
switch (id) {
case R.id.service_info:
startActivity(new Intent(this, ServiceInfoActivity.class));
break;
case R.id.service_setting:
if (PreferencesUtil.getInstance(this).getBoolean(PreferencesUtil.HENG_FENG_IS_OEPN, false)
&& PhoneUtils.hengdaServiceAvailable()) {
startActivity(new Intent(this, ServiceSettingActivity.class));
} else {
Toast.makeText(this, getString(R.string.toast_tips_unavailable), Toast.LENGTH_SHORT).show();
}
break;
case R.id.service_stop:
if (PreferencesUtil.getInstance(this).getBoolean(PreferencesUtil.HENG_FENG_IS_OEPN, false)
&& PhoneUtils.hengdaServiceAvailable()) {
startActivity(new Intent(this, ServiceStopActivity.class));
} else {
Toast.makeText(this, getString(R.string.toast_tips_unavailable), Toast.LENGTH_SHORT).show();
}
break;
case R.id.service_apply:
startActivity(new Intent(this, ServiceApplyActivity.class));
break;
}
}
}
package com.toscl.location.hengfeng.activity;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.toscl.location.hengfeng.R;
import com.toscl.location.hengfeng.api.IotApi;
import com.toscl.location.hengfeng.api.IotNetApiCallback;
import com.toscl.location.hengfeng.util.PreferencesUtil;
import com.toscl.location.hengfeng.util.PhoneUtils;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.json.JSONException;
import org.json.JSONObject;
public class ServiceApplyActivity extends Activity implements View.OnClickListener {
private EditText mPhoneNumber;
private final String TAG = getClass().getName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.service_apply);
setTitle(getString(R.string.title_apply));
mPhoneNumber = findViewById(R.id.phone_number);
mPhoneNumber.setText(PhoneUtils.getLocalNumber(this, PreferencesUtil.HENG_FENG_DEFAULT_SLOT));
findViewById(R.id.bt_cancel).setOnClickListener(this);
findViewById(R.id.bt_save).setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.bt_cancel:
finish();
break;
case R.id.bt_save:
String phoneNumber = mPhoneNumber.getText().toString();
apiPostServiceApply(phoneNumber);
break;
}
}
private void apiPostServiceApply(String phoneNumber) {
JSONObject jsonBody = new JSONObject();
try {
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_MEID, PhoneUtils.getPhoneMEID(getApplicationContext()));
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_IMSI, PhoneUtils.getSubId(getApplicationContext(), PreferencesUtil.HENG_FENG_DEFAULT_SLOT));
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_TEL, phoneNumber);
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_TIME, System.currentTimeMillis());
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_SIGN, PhoneUtils.getHengdaSign(jsonBody));
} catch (JSONException x) {
x.printStackTrace();
}
IotApi.hengfeng_service_apply(jsonBody, new IotNetApiCallback() {
@Override
public void onSuccess(String response) {
JsonObject resp = new JsonParser().parse(response).getAsJsonObject();
int code = resp.get(PreferencesUtil.HENG_FENG_SERVER_CODE).getAsInt();
String msg = resp.get(PreferencesUtil.HENG_FENG_SERVER_MSG).getAsString();
Toast.makeText(ServiceApplyActivity.this, msg, Toast.LENGTH_SHORT).show();
if (code == 0) {
JsonObject data = resp.get(PreferencesUtil.HENG_FENG_SERVER_RESPONSE_DATA).getAsJsonObject();
/*
* server data response
* */
String url = data.get(PreferencesUtil.HENG_FENG_SERVER_URL).getAsString();
String dataStart = data.get(PreferencesUtil.HENG_FENG_SERVER_DATA_START).getAsString();
String dataEnd = data.get(PreferencesUtil.HENG_FENG_SERVER_DATA_END).getAsString();
PreferencesUtil.getInstance(getApplicationContext())
.putString(PreferencesUtil.HENG_FENG_PHONE, phoneNumber);
PreferencesUtil.getInstance(getApplicationContext())
.putString(PreferencesUtil.HENG_FENG_URL, url);
PreferencesUtil.getInstance(getApplicationContext())
.putString(PreferencesUtil.HENG_FENG_DATA_START, dataStart);
PreferencesUtil.getInstance(getApplicationContext())
.putString(PreferencesUtil.HENG_FENG_DATA_END, dataEnd);
PreferencesUtil.getInstance(getApplicationContext())
.putBoolean(PreferencesUtil.HENG_FENG_IS_OEPN, true);
}
}
@Override
public void onFailed(Exception e) {
PreferencesUtil.getInstance(getApplicationContext())
.putBoolean(PreferencesUtil.HENG_FENG_IS_OEPN, false);
Toast.makeText(ServiceApplyActivity.this,
getResources().getString(R.string.toast_tips_server_unavailable), Toast.LENGTH_SHORT).show();
}
});
}
}
package com.toscl.location.hengfeng.activity;
import android.app.Activity;
import android.os.Bundle;
import com.toscl.location.hengfeng.R;
public class ServiceInfoActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.service_info);
setTitle(getString(R.string.title_server_info));
}
}
package com.toscl.location.hengfeng.activity;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.toscl.location.hengfeng.R;
import com.toscl.location.hengfeng.api.IotApi;
import com.toscl.location.hengfeng.api.IotNetApiCallback;
import com.toscl.location.hengfeng.util.PhoneUtils;
import com.toscl.location.hengfeng.util.PreferencesUtil;
import org.json.JSONException;
import org.json.JSONObject;
public class ServiceSettingActivity extends Activity implements View.OnClickListener {
private static final String TAG = "ServiceSettingActivity";
private Spinner mSpinnerForStartDate;
private Spinner mSpinnerForEndDate;
private EditText mEtFrequency;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.service_settting);
setTitle(getString(R.string.title_service_setting));
findViewById(R.id.bt_cancel).setOnClickListener(this);
findViewById(R.id.bt_save).setOnClickListener(this);
ArrayAdapter<CharSequence> adapter =
ArrayAdapter.createFromResource(this,
R.array.date,
android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource
(android.R.layout.simple_spinner_dropdown_item);
EditText etServiceStatus = findViewById(R.id.service_available_status);
if (PreferencesUtil.getInstance(this).getBoolean(PreferencesUtil.HENG_FENG_IS_OEPN, false)) {
etServiceStatus.setText(getString(R.string.service_status_available));
} else {
etServiceStatus.setText(getString(R.string.service_status_unavailable));
}
String dateStart = PreferencesUtil.getInstance(this)
.getString(PreferencesUtil.HENG_FENG_DATA_START, "");
String dateEnd = PreferencesUtil.getInstance(this)
.getString(PreferencesUtil.HENG_FENG_DATA_END, "");
EditText etServiceAvailableDate = findViewById(R.id.service_available_date);
if (dateStart.equals("")) {
etServiceAvailableDate.setText(getString(R.string.server_status_unavailable));
} else {
etServiceAvailableDate.setText(String.format(getResources().getString(R.string.service_available_date), dateStart, dateEnd));
}
EditText etPhoneNumber = findViewById(R.id.phone_number);
etPhoneNumber.setText(PreferencesUtil.getInstance(this)
.getString(PreferencesUtil.HENG_FENG_PHONE, ""));
mEtFrequency = findViewById(R.id.service_frequency);
mEtFrequency.setText(String.valueOf(PreferencesUtil.getInstance(this)
.getInt(PreferencesUtil.HENG_FENG_FREQUENCY, PreferencesUtil.HENG_FENG_DEFAULT_FREQUENCY)));
mSpinnerForStartDate = findViewById(R.id.service_upload_start);
mSpinnerForStartDate.setAdapter(adapter);
mSpinnerForEndDate = findViewById(R.id.service_upload_end);
mSpinnerForEndDate.setAdapter(adapter);
mSpinnerForEndDate.setSelection(PreferencesUtil.getInstance(this)
.getInt(PreferencesUtil.HENG_FENG_BEGIN, PreferencesUtil.HENG_FENG_DEFAULT_BEGIN));
mSpinnerForEndDate.setSelection(PreferencesUtil.getInstance(this)
.getInt(PreferencesUtil.HENG_FENG_END, PreferencesUtil.HENG_FENG_DEFAULT_END));
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.bt_cancel:
finish();
break;
case R.id.bt_save:
saveSetting();
break;
}
}
private void saveSetting() {
int startIndex = mSpinnerForStartDate.getSelectedItemPosition();
int endIndex = mSpinnerForEndDate.getSelectedItemPosition();
int frequency = Integer.parseInt(mEtFrequency.getText().toString());
String begin = startIndex + ":00";
String end = endIndex + ":00";
JSONObject jsonBody = new JSONObject();
try {
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_MEID, PhoneUtils.getPhoneMEID(getApplicationContext()));
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_TEL, PreferencesUtil.getInstance(this).getString(PreferencesUtil.HENG_FENG_PHONE, ""));
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_TIME, System.currentTimeMillis());
jsonBody.put(PreferencesUtil.HENG_FENG_SERVER_BEGIN, begin);
jsonBody.put(PreferencesUtil.HENG_FENG_SERVER_END, end);
jsonBody.put(PreferencesUtil.HENG_FENG_SERVER_FREQUENCY, frequency);
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_SIGN, PhoneUtils.getHengdaSign(jsonBody));
} catch (JSONException x) {
x.printStackTrace();
}
IotApi.hengfeng_service_setting(jsonBody, new IotNetApiCallback() {
@Override
public void onSuccess(String response) {
JsonObject resp = new JsonParser().parse(response).getAsJsonObject();
int code = resp.get(PreferencesUtil.HENG_FENG_SERVER_CODE).getAsInt();
String msg = resp.get(PreferencesUtil.HENG_FENG_SERVER_MSG).getAsString();
if (code == 0){
PreferencesUtil.getInstance(getApplicationContext())
.putInt(PreferencesUtil.HENG_FENG_BEGIN, startIndex);
PreferencesUtil.getInstance(getApplicationContext())
.putInt(PreferencesUtil.HENG_FENG_END, endIndex);
PreferencesUtil.getInstance(getApplicationContext())
.putInt(PreferencesUtil.HENG_FENG_FREQUENCY, frequency);
}
Toast.makeText(ServiceSettingActivity.this, msg, Toast.LENGTH_SHORT).show();
}
@Override
public void onFailed(Exception e) {
Toast.makeText(ServiceSettingActivity.this,
getResources().getString(R.string.toast_tips_server_unavailable), Toast.LENGTH_SHORT).show();
}
});
}
}
package com.toscl.location.hengfeng.activity;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.toscl.location.hengfeng.R;
import com.toscl.location.hengfeng.api.IotApi;
import com.toscl.location.hengfeng.api.IotNetApiCallback;
import com.toscl.location.hengfeng.util.PhoneUtils;
import com.toscl.location.hengfeng.util.PreferencesUtil;
import org.json.JSONException;
import org.json.JSONObject;
public class ServiceStopActivity extends Activity implements View.OnClickListener {
private EditText mEtPhoneNumber;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.service_stop);
setTitle(getResources().getString(R.string.title_server_stop));
findViewById(R.id.bt_cancel).setOnClickListener(this);
findViewById(R.id.bt_save).setOnClickListener(this);
mEtPhoneNumber = findViewById(R.id.phone_number);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.bt_cancel:
finish();
break;
case R.id.bt_save:
if (mEtPhoneNumber.getText().toString()
.equals(PreferencesUtil.getInstance(this).getString(PreferencesUtil.HENG_FENG_PHONE, ""))) {
apiStopService();
}else{
Toast.makeText(this, getResources().getString(R.string.tips_phone_unvalid), Toast.LENGTH_SHORT).show();
}
break;
}
}
private void apiStopService() {
JSONObject jsonBody = new JSONObject();
try {
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_MEID, PhoneUtils.getPhoneMEID(getApplicationContext()));
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_TEL, PreferencesUtil.getInstance(this).getString(PreferencesUtil.HENG_FENG_PHONE, ""));
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_TIME, System.currentTimeMillis());
jsonBody.put(PreferencesUtil.HENG_FENG_SERVER_BEGIN, "06:00");
jsonBody.put(PreferencesUtil.HENG_FENG_SERVER_END, "22:00");
jsonBody.put(PreferencesUtil.HENG_FENG_SERVER_FREQUENCY, 9999);
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_SIGN, PhoneUtils.getHengdaSign(jsonBody));
} catch (JSONException x) {
x.printStackTrace();
}
IotApi.hengfeng_service_setting(jsonBody, new IotNetApiCallback() {
@Override
public void onSuccess(String response) {
JsonObject resp = new JsonParser().parse(response).getAsJsonObject();
int code = resp.get(PreferencesUtil.HENG_FENG_SERVER_CODE).getAsInt();
String msg = resp.get(PreferencesUtil.HENG_FENG_SERVER_MSG).getAsString();
if (code == 0){
PreferencesUtil.getInstance(getApplicationContext()).putBoolean(PreferencesUtil.HENG_FENG_IS_OEPN, false);
}
Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
}
@Override
public void onFailed(Exception e) {
Toast.makeText(getApplicationContext(),
getResources().getString(R.string.toast_tips_server_unavailable), Toast.LENGTH_SHORT).show();
}
});
}
}
package com.agenew.location_server.application.api; package com.toscl.location.hengfeng.api;
import okhttp3.Call; import okhttp3.Call;
import okhttp3.Callback; import okhttp3.Callback;
......
package com.agenew.location_server.application.api; package com.toscl.location.hengfeng.api;
import android.util.Log; import android.util.Log;
...@@ -40,15 +40,15 @@ public class IotApi { ...@@ -40,15 +40,15 @@ public class IotApi {
.writeTimeout(TIME_OUT_WRITE, TimeUnit.SECONDS) .writeTimeout(TIME_OUT_WRITE, TimeUnit.SECONDS)
.connectTimeout(TIME_OUT_CONNECT, TimeUnit.SECONDS); .connectTimeout(TIME_OUT_CONNECT, TimeUnit.SECONDS);
/* try{ try {
MyOkHttpRetryInterceptor myOkHttpRetryInterceptor = new MyOkHttpRetryInterceptor.Builder() MyOkHttpRetryInterceptor myOkHttpRetryInterceptor = new MyOkHttpRetryInterceptor.Builder()
.executionCount(3) .executionCount(3)
.retryInterval(1000) .retryInterval(1000)
.build(); .build();
okHttpClientBuilder.addInterceptor(myOkHttpRetryInterceptor); okHttpClientBuilder.addInterceptor(myOkHttpRetryInterceptor);
}catch (Exception e){ } catch (Exception e) {
Log.d(TAG, e.toString()); Log.d(TAG, e.toString());
}*/ }
sHttpExecutor = new HttpExecutor(okHttpClientBuilder.build()); sHttpExecutor = new HttpExecutor(okHttpClientBuilder.build());
} }
...@@ -59,8 +59,11 @@ public class IotApi { ...@@ -59,8 +59,11 @@ public class IotApi {
* @param requestBodyString the request body string * @param requestBodyString the request body string
* @param callback the callback * @param callback the callback
*/ */
public static void post(String url, String requestBodyString, IotNetApiCallback callback){ public static void post(String url, String requestBodyString, IotNetApiCallback callback) {
RequestBody requestBody = RequestBody.create(JSON, requestBodyString); RequestBody requestBody = RequestBody.create(JSON, requestBodyString);
if (IotApi.sDebug) {
Log.d(TAG, "url: " + url + ", requestBody: " + requestBodyString);
}
sHttpExecutor.post(url, requestBody, new IotApiCallbackAdapter(callback)); sHttpExecutor.post(url, requestBody, new IotApiCallbackAdapter(callback));
} }
...@@ -75,8 +78,16 @@ public class IotApi { ...@@ -75,8 +78,16 @@ public class IotApi {
Log.d(TAG, "get:" + url); Log.d(TAG, "get:" + url);
} }
public static void postLocationInfo(String url, JSONObject requestContent, IotNetApiCallback callback) { public static void hengfeng_service_apply(JSONObject requestContent, IotNetApiCallback callback) {
post(url, requestContent.toString() , callback); post("https://api.vserve365.com/phone_baihe/open", requestContent.toString(), callback);
}
public static void hengfeng_service_post(JSONObject requestContent, IotNetApiCallback callback) {
post("https://api.vserve365.com/phone_baihe/position", requestContent.toString(), callback);
}
public static void hengfeng_service_setting(JSONObject requestContent, IotNetApiCallback callback) {
post("https://api.vserve365.com/phone_baihe/config", requestContent.toString(), callback);
} }
......
package com.agenew.location_server.application.api; package com.toscl.location.hengfeng.api;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
...@@ -32,7 +32,14 @@ class IotApiCallbackAdapter implements Callback { ...@@ -32,7 +32,14 @@ class IotApiCallbackAdapter implements Callback {
if (mIotNetApiCallback != null) { if (mIotNetApiCallback != null) {
Bundle b = msg.getData(); Bundle b = msg.getData();
String response = b.getString("response"); String response = b.getString("response");
if (IotApi.sDebug) {
Log.d("Iot", "response: " + response);
}
try{
mIotNetApiCallback.onSuccess(response); mIotNetApiCallback.onSuccess(response);
}catch (Exception e){
Log.d("Iot", e.toString());
}
} }
break; break;
...@@ -41,6 +48,9 @@ class IotApiCallbackAdapter implements Callback { ...@@ -41,6 +48,9 @@ class IotApiCallbackAdapter implements Callback {
Bundle b = msg.getData(); Bundle b = msg.getData();
Exception e = (Exception) b.getSerializable("exception"); Exception e = (Exception) b.getSerializable("exception");
mIotNetApiCallback.onFailed(e); mIotNetApiCallback.onFailed(e);
if (IotApi.sDebug) {
Log.d("Iot", "response failed exception: " + e.toString());
}
} }
break; break;
} }
......
package com.agenew.location_server.application.api; package com.toscl.location.hengfeng.api;
public interface IotNetApiCallback { public interface IotNetApiCallback {
......
package com.agenew.location_server.application.api; package com.toscl.location.hengfeng.api;
import java.io.IOException; import java.io.IOException;
...@@ -12,6 +12,7 @@ import okhttp3.Response; ...@@ -12,6 +12,7 @@ import okhttp3.Response;
public class MyOkHttpRetryInterceptor implements Interceptor { public class MyOkHttpRetryInterceptor implements Interceptor {
public int executionCount;//最大重试次数 public int executionCount;//最大重试次数
private long retryInterval;//重试的间隔 private long retryInterval;//重试的间隔
MyOkHttpRetryInterceptor(Builder builder) { MyOkHttpRetryInterceptor(Builder builder) {
this.executionCount = builder.executionCount; this.executionCount = builder.executionCount;
this.retryInterval = builder.retryInterval; this.retryInterval = builder.retryInterval;
...@@ -34,7 +35,7 @@ public class MyOkHttpRetryInterceptor implements Interceptor { ...@@ -34,7 +35,7 @@ public class MyOkHttpRetryInterceptor implements Interceptor {
// retry the request // retry the request
response = doRequest(chain, request); response = doRequest(chain, request);
} }
if (response == null){ if (response == null) {
return chain.proceed(request); return chain.proceed(request);
} }
return response; return response;
...@@ -59,20 +60,22 @@ public class MyOkHttpRetryInterceptor implements Interceptor { ...@@ -59,20 +60,22 @@ public class MyOkHttpRetryInterceptor implements Interceptor {
public static final class Builder { public static final class Builder {
private int executionCount; private int executionCount;
private long retryInterval; private long retryInterval;
public Builder() { public Builder() {
executionCount = 3; executionCount = 3;
retryInterval = 1000; retryInterval = 1000;
} }
public MyOkHttpRetryInterceptor.Builder executionCount(int executionCount){ public MyOkHttpRetryInterceptor.Builder executionCount(int executionCount) {
this.executionCount =executionCount; this.executionCount = executionCount;
return this; return this;
} }
public MyOkHttpRetryInterceptor.Builder retryInterval(long retryInterval){ public MyOkHttpRetryInterceptor.Builder retryInterval(long retryInterval) {
this.retryInterval =retryInterval; this.retryInterval = retryInterval;
return this; return this;
} }
public MyOkHttpRetryInterceptor build() { public MyOkHttpRetryInterceptor build() {
return new MyOkHttpRetryInterceptor(this); return new MyOkHttpRetryInterceptor(this);
} }
......
package com.agenew.location_server.application.permission; package com.toscl.location.hengfeng.permission;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
......
package com.agenew.location_server.application.permission; package com.toscl.location.hengfeng.permission;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
...@@ -7,9 +7,9 @@ import android.os.Build; ...@@ -7,9 +7,9 @@ import android.os.Build;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import com.agenew.location_server.application.permission.annotation.OnMPermissionDenied; import com.toscl.location.hengfeng.permission.annotation.OnMPermissionDenied;
import com.agenew.location_server.application.permission.annotation.OnMPermissionGranted; import com.toscl.location.hengfeng.permission.annotation.OnMPermissionGranted;
import com.agenew.location_server.application.permission.annotation.OnMPermissionNeverAskAgain; import com.toscl.location.hengfeng.permission.annotation.OnMPermissionNeverAskAgain;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
......
package com.agenew.location_server.application.permission.annotation; package com.toscl.location.hengfeng.permission.annotation;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
......
package com.agenew.location_server.application.permission.annotation; package com.toscl.location.hengfeng.permission.annotation;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
......
package com.agenew.location_server.application.permission.annotation; package com.toscl.location.hengfeng.permission.annotation;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
......
package com.agenew.location_server.application; package com.toscl.location.hengfeng.recevier;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
...@@ -9,10 +9,7 @@ public class AlarmReceiver extends BroadcastReceiver { ...@@ -9,10 +9,7 @@ public class AlarmReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
Log.d("BirdService","receiver--"+System.currentTimeMillis()); Log.d("AlarmReceiver", "sendBroadcast com.bird.open_gps_alarm");
/* Intent i = new Intent(context,BirdService.class);
DevicePreferences.getInstance(context).putBoolean("is_need_notification", false);
context.startService(i);*/
Intent intent2 = new Intent("com.bird.open_gps_alarm"); Intent intent2 = new Intent("com.bird.open_gps_alarm");
intent2.addFlags(0x01000000); intent2.addFlags(0x01000000);
......
package com.toscl.location.hengfeng.recevier;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.util.Log;
import com.toscl.location.hengfeng.LocationService;
import com.toscl.location.hengfeng.util.PhoneUtils;
import com.toscl.location.hengfeng.util.PreferencesUtil;
public class LocationReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String TAG = "LocationReceiver";
String action = intent.getAction();
Log.d(TAG, "action:" + action);
if (action != null && action.equals("com.bird.send_sos")) {
if (PreferencesUtil.getInstance(context)
.getBoolean(PreferencesUtil.HENG_FENG_PREFIX + "is_open", false)) {
if (PhoneUtils.hengdaServiceAvailable()) {
Intent intentForService = new Intent(context, LocationService.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(intentForService);
} else {
context.startService(intentForService);
}
PreferencesUtil.getInstance(context)
.putBoolean(PreferencesUtil.HENG_FENG_PREFIX + "is_open", true);
} else {
PreferencesUtil.getInstance(context)
.putBoolean(PreferencesUtil.HENG_FENG_PREFIX + "is_open", false);
Intent intentThree = new Intent(context, LocationService.class);
context.stopService(intentThree);
}
}
} else if (action != null && action.equals("com.bird.close_sos")) {
PreferencesUtil.getInstance(context)
.putBoolean(PreferencesUtil.HENG_FENG_PREFIX + "is_open", false);
Intent intentThree = new Intent(context, LocationService.class);
context.stopService(intentThree);
}
}
}
package com.agenew.location_server.application; package com.toscl.location.hengfeng.util;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
...@@ -14,8 +14,15 @@ import android.text.TextUtils; ...@@ -14,8 +14,15 @@ import android.text.TextUtils;
import android.util.ArrayMap; import android.util.ArrayMap;
import android.util.Log; import android.util.Log;
import org.json.JSONException;
import org.json.JSONObject;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -27,8 +34,14 @@ public class PhoneUtils { ...@@ -27,8 +34,14 @@ public class PhoneUtils {
public static final long VAL_USER_REFRESH_INTERVAL = 10 * 60 * 1000; // 10min public static final long VAL_USER_REFRESH_INTERVAL = 10 * 60 * 1000; // 10min
public static final long VAL_AUTO_REFRESH_INTERVAL = 6 * 60 * 60 * 1000; // 6 hours public static final long VAL_AUTO_REFRESH_INTERVAL = 6 * 60 * 60 * 1000; // 6 hours
public static final long VAL_AUTO_RELOAD_INTERVAL = 1 * 60 * 1000; //1min public static final long VAL_AUTO_RELOAD_INTERVAL = 1 * 60 * 1000; //1min
public static final String HENFENG_BROADCAST_OPEN_GPS = "com.bird.open_gps_switch";
public static final String HENFENG_BROADCAST_CLOSE_GPS = "com.bird.close_gps_switch";
private static final String TAG = PhoneUtils.class.getSimpleName(); private static final String TAG = PhoneUtils.class.getSimpleName();
private static final ArrayMap<String, String> mobileAlias = new ArrayMap<>(); private static final ArrayMap<String, String> mobileAlias = new ArrayMap<>();
private static boolean mDebugTest = true;
public static int getSimState(int slot) { public static int getSimState(int slot) {
int state = -1; int state = -1;
...@@ -157,7 +170,7 @@ public class PhoneUtils { ...@@ -157,7 +170,7 @@ public class PhoneUtils {
return false; return false;
} }
static boolean isWifiAvailable(Context contxt) { public static boolean isWifiAvailable(Context contxt) {
WifiManager wifiManager = (WifiManager) contxt.getSystemService(Context.WIFI_SERVICE); WifiManager wifiManager = (WifiManager) contxt.getSystemService(Context.WIFI_SERVICE);
return wifiManager.isWifiEnabled(); return wifiManager.isWifiEnabled();
/* ConnectivityManager connectivityManager = (ConnectivityManager) contxt.getSystemService(Context.CONNECTIVITY_SERVICE); /* ConnectivityManager connectivityManager = (ConnectivityManager) contxt.getSystemService(Context.CONNECTIVITY_SERVICE);
...@@ -200,7 +213,7 @@ public class PhoneUtils { ...@@ -200,7 +213,7 @@ public class PhoneUtils {
try { try {
Method getDataSubId = subscriptionManager.getClass().getDeclaredMethod("getDefaultDataSubId"); Method getDataSubId = subscriptionManager.getClass().getDeclaredMethod("getDefaultDataSubId");
if (null != getDataSubId) { if (null != getDataSubId) {
dataSubId= (int)getDataSubId.invoke(subscriptionManager); dataSubId = (int) getDataSubId.invoke(subscriptionManager);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -229,6 +242,10 @@ public class PhoneUtils { ...@@ -229,6 +242,10 @@ public class PhoneUtils {
} }
public static boolean hengdaServiceAvailable() {
return true;
}
public boolean isAirplaneModeOn(Context context) { public boolean isAirplaneModeOn(Context context) {
return (Settings.System.getInt(context.getContentResolver(), return (Settings.System.getInt(context.getContentResolver(),
Settings.System.AIRPLANE_MODE_ON, 0) != 0); Settings.System.AIRPLANE_MODE_ON, 0) != 0);
...@@ -397,10 +414,10 @@ public class PhoneUtils { ...@@ -397,10 +414,10 @@ public class PhoneUtils {
try { try {
Class<?> c = Class.forName("android.os.SystemProperties"); Class<?> c = Class.forName("android.os.SystemProperties");
Method get = c.getMethod("get", String.class, String.class); Method get = c.getMethod("get", String.class, String.class);
value = (String)(get.invoke(c, key, "" )); value = (String) (get.invoke(c, key, ""));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
}finally { } finally {
return value; return value;
} }
} }
...@@ -413,6 +430,7 @@ public class PhoneUtils { ...@@ -413,6 +430,7 @@ public class PhoneUtils {
" vendor.ril.data.gsm_imsi1", " vendor.ril.data.gsm_imsi1",
" vendor.ril.data.gsm_imsi2", " vendor.ril.data.gsm_imsi2",
}; };
/** /**
* @param slotId 0 or 1 * @param slotId 0 or 1
* @return * @return
...@@ -421,19 +439,22 @@ public class PhoneUtils { ...@@ -421,19 +439,22 @@ public class PhoneUtils {
// int[] subIds = SubscriptionManager.getSubId(slotId); // int[] subIds = SubscriptionManager.getSubId(slotId);
// return null != subIds && subIds.length > 0 ? subIds[0] : SubscriptionManager.INVALID_SUBSCRIPTION_ID; // return null != subIds && subIds.length > 0 ? subIds[0] : SubscriptionManager.INVALID_SUBSCRIPTION_ID;
// } // }
public static String getSubId(Context context, int slotId) {
public static int getSubId(Context context, int slotId) { if (mDebugTest){
return "111111111";
}
final SubscriptionManager subscriptionManager = SubscriptionManager.from(context); final SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
final SubscriptionInfo sir = subscriptionManager.getActiveSubscriptionInfoForSimSlotIndex(slotId); final SubscriptionInfo sir = subscriptionManager.getActiveSubscriptionInfoForSimSlotIndex(slotId);
int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
if (sir != null) { if (sir != null) {
subId = sir.getSubscriptionId(); subId = sir.getSubscriptionId();
} }
return subId; return String.valueOf(subId);
} }
public static String getMccMnc(Context context, int subId) { public static String getMccMnc(Context context, int subId) {
String imsi = ""; String imsi = "";
if(subId < 0){ if (subId < 0) {
return ""; return "";
} }
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(TELEPHONY_SERVICE); TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(TELEPHONY_SERVICE);
...@@ -441,11 +462,11 @@ public class PhoneUtils { ...@@ -441,11 +462,11 @@ public class PhoneUtils {
Class<?> telephonyManagerClazz = telephonyManager.getClass(); Class<?> telephonyManagerClazz = telephonyManager.getClass();
Method getSubscriberId = telephonyManagerClazz.getMethod("getSubscriberId", int.class); Method getSubscriberId = telephonyManagerClazz.getMethod("getSubscriberId", int.class);
imsi = (String) getSubscriberId.invoke(telephonyManager, subId); imsi = (String) getSubscriberId.invoke(telephonyManager, subId);
if(imsi==null ||imsi.isEmpty()) { if (imsi == null || imsi.isEmpty()) {
imsi=""+ getProperty(PROPERTY_UIM_SUBSCRIBER_ID[subId], ""); imsi = "" + getProperty(PROPERTY_UIM_SUBSCRIBER_ID[subId], "");
} }
if(imsi==null ||imsi.isEmpty()) { if (imsi == null || imsi.isEmpty()) {
imsi=""+ getProperty(PROPERTY_GSM_SUBSCRIBER_ID[subId], ""); imsi = "" + getProperty(PROPERTY_GSM_SUBSCRIBER_ID[subId], "");
} }
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -461,7 +482,10 @@ public class PhoneUtils { ...@@ -461,7 +482,10 @@ public class PhoneUtils {
} }
} }
public static String getPhoneMEID(Context context){ public static String getPhoneMEID(Context context) {
if (mDebugTest){
return "A1000064110C89";
}
//实例化TelephonyManager对象 //实例化TelephonyManager对象
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String meid = ""; String meid = "";
...@@ -469,10 +493,10 @@ public class PhoneUtils { ...@@ -469,10 +493,10 @@ public class PhoneUtils {
Method method = telephonyManager.getClass().getMethod("getDeviceId", int.class); Method method = telephonyManager.getClass().getMethod("getDeviceId", int.class);
meid = getProperty("gsm.mtk.meid", ""); meid = getProperty("gsm.mtk.meid", "");
if (TextUtils.isEmpty(meid))meid = getProperty("persist.radio.us.meid",""); if (TextUtils.isEmpty(meid)) meid = getProperty("persist.radio.us.meid", "");
if (TextUtils.isEmpty(meid))meid = getProperty("sys.tt.meid",""); if (TextUtils.isEmpty(meid)) meid = getProperty("sys.tt.meid", "");
int phoneCount = telephonyManager.getPhoneCount(); int phoneCount = telephonyManager.getPhoneCount();
if (TextUtils.isEmpty(meid)){ if (TextUtils.isEmpty(meid)) {
for (int slot = 0; slot < phoneCount; slot++) { for (int slot = 0; slot < phoneCount; slot++) {
String deviceId = (String) method.invoke(telephonyManager, slot); String deviceId = (String) method.invoke(telephonyManager, slot);
if (deviceId != null && deviceId.length() == 14) { if (deviceId != null && deviceId.length() == 14) {
...@@ -481,18 +505,18 @@ public class PhoneUtils { ...@@ -481,18 +505,18 @@ public class PhoneUtils {
} }
} }
if (TextUtils.isEmpty(meid)){ if (TextUtils.isEmpty(meid)) {
for (int slot = 0; slot < phoneCount; slot++) { for (int slot = 0; slot < phoneCount; slot++) {
if (TextUtils.isEmpty(meid) || meid.startsWith("00000")) { if (TextUtils.isEmpty(meid) || meid.startsWith("00000")) {
Method getMeid = telephonyManager.getClass().getMethod("getMeid", int.class); Method getMeid = telephonyManager.getClass().getMethod("getMeid", int.class);
Object r = getMeid.invoke(telephonyManager, slot); Object r = getMeid.invoke(telephonyManager, slot);
if (r instanceof String) { if (r instanceof String) {
String tmp = (String) r; String tmp = (String) r;
if (!TextUtils.isEmpty(tmp) && tmp.trim().length() == 14 && !tmp.startsWith("00000")){ if (!TextUtils.isEmpty(tmp) && tmp.trim().length() == 14 && !tmp.startsWith("00000")) {
meid = tmp; meid = tmp;
} }
} else { } else {
Log.w(TAG,"getMeid: slot="+slot+" meid return null! "); Log.w(TAG, "getMeid: slot=" + slot + " meid return null! ");
} }
} }
} }
...@@ -526,4 +550,60 @@ public class PhoneUtils { ...@@ -526,4 +550,60 @@ public class PhoneUtils {
return versionCode; return versionCode;
} }
static char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; //HEX_DIGITS为16进制字符
/*
* md5
*/
public static String MD5(String s) {
try {
byte[] btInput = s.getBytes();
// 获得MD5摘要算法的 MessageDigest 对象
MessageDigest mdInst = MessageDigest.getInstance("MD5");
// 使用指定的字节更新摘要
mdInst.update(btInput);
// 获得密文
byte[] md = mdInst.digest();
// 把密文转换成十六进制的字符串形式
int j = md.length;
char str[] = new char[j * 2];
int k = 0;
for (int i = 0; i < j; i++) {
byte byte0 = md[i];
str[k++] = HEX_DIGITS[byte0 >>> 4 & 0xf];
str[k++] = HEX_DIGITS[byte0 & 0xf];
}
return new String(str);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static String getHengdaSign(JSONObject jsonBody) {
//1、参数排序
Iterator<?> it = jsonBody.keys();
List<String> keyList = new ArrayList<String>();
while (it.hasNext()) {
String key = it.next().toString();
if (!"sign".equals(key)) {
keyList.add(key);
}
}
Collections.sort(keyList);
//2、拼装参数
StringBuilder paramString = new StringBuilder();
for (String key : keyList) {
try {
paramString.append(jsonBody.get(key));
} catch (JSONException e) {
e.printStackTrace();
}
}
paramString.append("hengfeng");
return MD5(paramString.toString().trim());
}
} }
\ No newline at end of file
package com.toscl.location.hengfeng.util;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import java.util.Set;
public class PreferencesUtil {
public final static String HENG_FENG_PREFIX = "hengfeng_sos_";
/*
* server request key
* */
public final static String HENG_FENG_REQ_SERVER_MEID = "meid";
public final static String HENG_FENG_REQ_SERVER_IMSI = "imsi";
public final static String HENG_FENG_REQ_SERVER_TEL = "tel";
public final static String HENG_FENG_REQ_SERVER_TIME = "time";
public final static String HENG_FENG_REQ_SERVER_LONGITUDE = "lng";
public final static String HENG_FENG_REQ_SERVER_LATITUDE = "lat";
// Geographical coordinate system
public final static String HENG_FENG_REQ_SERVER_GCS = "gcs";
public final static String HENG_FENG_REQ_SERVER_SIGN = "sign";
/*
* Server response
* */
public final static String HENG_FENG_SERVER_DATA_START = "dateStart";
public final static String HENG_FENG_SERVER_DATA_END = "dateEnd";
public final static String HENG_FENG_SERVER_URL = "url";
public final static String HENG_FENG_SERVER_BEGIN = "begin";
public final static String HENG_FENG_SERVER_END = "end";
public final static String HENG_FENG_SERVER_FREQUENCY = "frequency";
public final static String HENG_FENG_SERVER_CODE = "code";
public final static String HENG_FENG_SERVER_MSG = "msg";
public final static String HENG_FENG_SERVER_RESPONSE_DATA = "data";
/*
* Local sharedPreference storage key.
* */
public final static String HENG_FENG_DATA_START = HENG_FENG_PREFIX + HENG_FENG_SERVER_DATA_START;
public final static String HENG_FENG_DATA_END = HENG_FENG_PREFIX + HENG_FENG_SERVER_DATA_END;
public final static String HENG_FENG_URL = HENG_FENG_PREFIX + HENG_FENG_SERVER_URL;
public final static String HENG_FENG_BEGIN = HENG_FENG_PREFIX + HENG_FENG_SERVER_BEGIN;
public final static String HENG_FENG_END = HENG_FENG_PREFIX + HENG_FENG_SERVER_END;
public final static String HENG_FENG_FREQUENCY = HENG_FENG_PREFIX + HENG_FENG_SERVER_FREQUENCY;
public final static String HENG_FENG_PHONE = HENG_FENG_PREFIX + "phone";
public final static String HENG_FENG_IS_OEPN = HENG_FENG_PREFIX + "is_open";
/*
* For default value
* */
public final static int HENG_FENG_DEFAULT_FREQUENCY = 10;
public final static int HENG_FENG_DEFAULT_BEGIN = 6;
public final static int HENG_FENG_DEFAULT_END = 22;
public final static int HENG_FENG_DEFAULT_SLOT = 0;
private static PreferencesUtil sDevicePreferences;
private final SharedPreferences mSharePferences;
private final SharedPreferences.Editor mEditor;
private PreferencesUtil(Context context) {
mSharePferences = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE);
mEditor = mSharePferences.edit();
}
public static synchronized PreferencesUtil getInstance(Context context) {
if (null == sDevicePreferences) {
sDevicePreferences = new PreferencesUtil(context.getApplicationContext());
}
return sDevicePreferences;
}
public void putInt(final String key, final int value) {
mEditor.putInt(key, value);
mEditor.commit();
}
public void putLong(final String key, final long value) {
mEditor.putLong(key, value);
mEditor.commit();
}
public void putString(final String key, final String value) {
mEditor.putString(key, value);
mEditor.commit();
}
public void putFloat(final String key, final float value) {
mEditor.putFloat(key, value);
mEditor.commit();
}
public void putBoolean(final String key, final boolean value) {
mEditor.putBoolean(key, value);
mEditor.commit();
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void putStringSet(final String key, final Set<String> values) {
mEditor.putStringSet(key, values);
mEditor.commit();
}
public int getInt(final String key, final int defaultValue) {
return mSharePferences.getInt(key, defaultValue);
}
public long getLong(final String key, final long defaultValue) {
return mSharePferences.getLong(key, defaultValue);
}
public String getString(final String key, final String defaultValue) {
return mSharePferences.getString(key, defaultValue);
}
public float getFloat(final String key, final float defaultValue) {
return mSharePferences.getFloat(key, defaultValue);
}
public boolean getBoolean(final String key, final boolean defaultValue) {
return mSharePferences.getBoolean(key, defaultValue);
}
public Set<String> getStringSet(final String key) {
return mSharePferences.getStringSet(key, null);
}
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF" />
<corners
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
<stroke
android:width="1dp"
android:color="#B9B8B8" />
</shape>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:padding="5px">
<Button
android:layout_gravity="center_vertical"
android:focusable="true"
android:id="@+id/service_apply"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/title_apply"
android:textSize="25px"/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:padding="5px">
<Button
android:layout_gravity="center_vertical"
android:focusable="true"
android:id="@+id/service_stop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/title_server_stop"
android:textSize="25px"/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:padding="5px">
<Button
android:layout_gravity="center_vertical"
android:focusable="true"
android:id="@+id/service_setting"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/title_service_setting"
android:textSize="25px"/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:padding="5px">
<Button
android:layout_gravity="center_vertical"
android:focusable="true"
android:id="@+id/service_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/title_server_info"
android:textSize="25px"/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
...@@ -4,87 +4,71 @@ ...@@ -4,87 +4,71 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="10dp"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/interval" android:layout_gravity="center"
android:layout_width="wrap_content" android:textSize="24px"
android:layout_height="wrap_content" android:padding="10px"
android:text="@string/interval"
android:textSize="18dp"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="0dp" />
<EditText
android:id="@+id/interval_value"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/time_inter_tips" android:text="请输入在营业厅申请的套餐手机号"
android:inputType="number" tools:ignore="MissingConstraints" />
/>
<TextView <LinearLayout
android:id="@+id/url" style="@style/InputBoxStyle"
android:layout_marginTop="20px"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:text="@string/url"
android:textSize="18dp" />
<EditText <EditText
android:hint="@string/server_tips" android:id="@+id/phone_number"
android:id="@+id/url_value" android:cursorVisible="true"
android:layout_width="match_parent" android:hint="输入手机号码"
android:layout_height="wrap_content" android:textCursorDrawable="@color/colorPrimary"
/> android:text="0"
android:focusable="true"
<!--<TextView--> android:focusableInTouchMode="true"
<!--android:layout_marginTop="20dp"--> android:minWidth="330px"
<!--android:layout_width="match_parent"--> android:textSize="28px"
<!--android:layout_height="wrap_content"--> style="@style/EditTextStyle"
<!--android:text="@string/user_tips_title"/>--> android:inputType="number"
<TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content" />
android:text="@string/user_tips_content"/> </LinearLayout>
<!--<EditText-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="@string/other_tips"/>-->
<LinearLayout <LinearLayout
android:layout_marginTop="50dp" android:layout_marginTop="50dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:orientation="horizontal"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom"> android:layout_gravity="bottom">
<Button <Button
android:layout_gravity="center_vertical"
android:focusable="true" android:focusable="true"
android:id="@+id/bt_cancel" android:id="@+id/bt_save"
android:layout_gravity="center_vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/dialog_cancel" android:text="@string/dialog_save"
android:textSize="25sp"/> android:textSize="25sp" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:orientation="horizontal"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom"> android:layout_gravity="bottom">
<Button <Button
android:focusable="true"
android:id="@+id/bt_save"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:focusable="true"
android:id="@+id/bt_cancel"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/dialog_save" android:text="@string/dialog_cancel"
android:textSize="25sp" /> android:textSize="25sp"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:padding="10px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="24px"
android:text="@string/service_info"/>
</ScrollView>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="套餐手机号:"
android:textSize="18px" />
<LinearLayout
style="@style/InputBoxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/phone_number"
android:text="17895507717"
android:focusable="false"
android:focusableInTouchMode="false"
android:minWidth="330px"
android:textSize="18px"
style="@style/EditTextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:layout_marginTop="10px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/interval"
android:textSize="18px" />
<LinearLayout
style="@style/InputBoxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/service_frequency"
android:cursorVisible="true"
android:hint="@string/time_inter_tips"
android:textCursorDrawable="@color/colorPrimary"
android:text="0"
android:focusable="true"
android:focusableInTouchMode="true"
android:minWidth="330px"
android:textSize="14px"
style="@style/EditTextStyle"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:layout_marginTop="10px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="每天上传时间:"
android:textSize="18px" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18px"
android:text="从 "/>
<Spinner
android:focusable="true"
android:nextFocusRight="@id/service_upload_end"
android:nextFocusDown="@id/service_upload_end"
android:id="@+id/service_upload_start"
android:layout_width="wrap_content"
android:textSize="25px"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18px"
android:text=" 到 "/>
<Spinner
android:nextFocusLeft="@id/service_upload_start"
android:nextFocusUp="@id/service_upload_start"
android:id="@+id/service_upload_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25px"/>
</LinearLayout>
<TextView
android:layout_marginTop="10px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="状态:"
android:textSize="18px" />
<LinearLayout
style="@style/InputBoxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/service_available_status"
android:cursorVisible="true"
android:hint="@string/time_inter_tips"
android:textCursorDrawable="@color/colorPrimary"
android:text="开通"
android:textStyle="bold"
android:focusable="false"
android:focusableInTouchMode="false"
android:minWidth="330px"
android:textSize="18px"
style="@style/EditTextStyle"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:layout_marginTop="10px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="有效日期:"
android:textSize="18px" />
<LinearLayout
style="@style/InputBoxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/service_available_date"
android:cursorVisible="true"
android:hint="@string/time_inter_tips"
android:textCursorDrawable="@color/colorPrimary"
android:text="从 2019.10.1 到 2021.9.30"
android:textStyle="bold"
android:focusable="false"
android:focusableInTouchMode="false"
android:minWidth="330px"
android:textSize="14px"
style="@style/EditTextStyle"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15px">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1">
<Button
android:id="@+id/bt_save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:focusable="true"
android:text="@string/dialog_save"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="@+id/bt_cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:focusable="true"
android:text="@string/dialog_cancel"
android:textSize="25sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_gravity="center"
android:textSize="22px"
android:padding="10px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="您在营业厅申请的套餐手机号为0,请再次输入该号码以确认停止定位服务"
tools:ignore="MissingConstraints" />
<LinearLayout
style="@style/InputBoxStyle"
android:layout_marginTop="5px"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<EditText
android:cursorVisible="true"
android:hint="输入手机号码"
android:textCursorDrawable="@color/colorPrimary"
android:text="0"
android:focusable="true"
android:focusableInTouchMode="true"
android:minWidth="330px"
android:textSize="28px"
style="@style/EditTextStyle"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<Button
android:focusable="true"
android:id="@+id/bt_save"
android:layout_gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dialog_save"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<Button
android:layout_gravity="center_vertical"
android:focusable="true"
android:id="@+id/bt_cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dialog_cancel"
android:textSize="25sp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">设置</string> <string name="app_name">定位服务</string>
<string name="dialog_cancel">取消</string> <string name="dialog_cancel">返回</string>
<string name="url">"上传地址:"</string>> <string name="url">"上传地址:"</string>>
<string name="interval">"时间间隔(分钟):"</string> <string name="interval">"上传频率(分钟):"</string>
<string name="dialog_save">"保存"</string> <string name="dialog_save">"确定"</string>
<string name="interval_prompt">"请设置间隔时长"</string> <string name="interval_prompt">"请设置间隔时长"</string>
<string name="server_prompt">"请设置服务器地址"</string> <string name="server_prompt">"请设置服务器地址"</string>
<string name="error_msg_1">"经纬度信息无效"</string> <string name="error_msg_1">"经纬度信息无效"</string>
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="date">
<item>1点</item>
<item>2点</item>
<item>3点</item>
<item>4点</item>
<item>5点</item>
<item>6点</item>
<item>7点</item>
<item>8点</item>
<item>9点</item>
<item>10点</item>
<item>11点</item>
<item>12点</item>
<item>13点</item>
<item>14点</item>
<item>15点</item>
<item>16点</item>
<item>17点</item>
<item>18点</item>
<item>19点</item>
<item>20点</item>
<item>21点</item>
<item>22点</item>
<item>23点</item>
<item>24点</item>
</string-array>
</resources>
\ No newline at end of file
<resources> <resources>
<string name="app_name">Setting</string> <string name="app_name">Location Service</string>
<string name="dialog_cancel">Cancel</string> <string name="dialog_cancel">Cancel</string>
<string name="url">"Upload address:"</string>> <string name="url">"Upload address:"</string>>
...@@ -10,11 +10,28 @@ ...@@ -10,11 +10,28 @@
<string name="error_msg_1">"Latitude and longitude information is invalid"</string> <string name="error_msg_1">"Latitude and longitude information is invalid"</string>
<string name="error_msg_2">"Invalid MEID"</string> <string name="error_msg_2">"Invalid MEID"</string>
<string name="error_msg_3">"Internal processing error"</string> <string name="error_msg_3">"Internal processing error"</string>
<string name="save_tips">保存成功</string> <string name="save_tips" translatable="false">保存成功</string>
<string name="save_cacel">取消</string> <string name="save_cacel">取消</string>
<string name="time_inter_tips">请输入时间间隔</string> <string name="time_inter_tips">请输入时间间隔</string>
<string name="server_tips">请输入当前服务器接口地址</string> <string name="server_tips">请输入当前服务器接口地址</string>
<string name="user_tips_title">使用说明:</string> <string name="user_tips_title">使用说明:</string>
<string name="user_tips_content">每次重启开机后均会发送定位信息,可保存后重启手机测试。</string> <string name="user_tips_content">每次重启开机后均会发送定位信息,可保存后重启手机测试。</string>
<string name="other_tips">测试接口: http://202.100.179.139:8088/api 正式接口: http://202.100.190.58:8090/api/cstmzPosition</string> <string name="other_tips">测试接口: http://202.100.179.139:8088/api 正式接口: http://202.100.190.58:8090/api/cstmzPosition</string>
<string name="service_info">\t本定位服务面向在通信运营商处申请开通了特定套餐的用户。\n\t当您进行了“申请开通”的操作后,即表示您在套餐服务有效的时间段内授权本服务获取您的位置。\n\t请您下载“颐关爱”APP查看本手机的定位信息、设置电子围栏范围、收取跨越电子围栏的报警信息。\t本定位的准确性和及时性与手机性能、定位信号强度、信息上传频率、网络情况等诸多因素有关,故本定位服务只起到辅助监护作用,不承担因定位不准确或不及时导致的任何责任,特此声明。</string>
<string name="title_nav">定位服务</string>
<string name="toast_tips_unavailable">未开通定位服务</string>
<string name="title_server_info">服务说明</string>
<string name="title_apply">申请开通</string>
<string name="server_status_unavailable">服务未开通</string>
<string name="service_available_date">从 %s 到 %s</string>
<string name="service_status_available">开通</string>
<string name="service_status_unavailable">停止</string>
<string name="title_service_setting" translatable="false">定位设置</string>
<string name="tips_input_unvaild">输入不合法</string>
<string name="tips_frequency_unvalid">上传频率请设置 1-1440 之间</string>
<string name="tips_save_success">保存成功</string>
<string name="tips_phone_unvalid">套餐手机号输入错误,请重新输入</string>
<string name="tips_service_stop">定位服务已停止</string>
<string name="title_server_stop">停止服务</string>
<string name="toast_tips_server_unavailable">服务器连接错误,请重试</string>
</resources> </resources>
<resources> <resources>
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <style name="AppTheme" parent="@style/ThemeOverlay.AppCompat.ActionBar">
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
</style> </style>
<style name="InputBoxStyle">
<item name="android:layout_centerHorizontal">true</item>
<item name="android:layout_marginLeft">18dp</item>
<item name="android:layout_marginRight">18dp</item>
<item name="android:background">@drawable/border_input_box</item>
<item name="android:gravity">center</item>
<item name="android:orientation">horizontal</item>
</style>
<style name="EditTextStyle">
<item name="android:layout_marginTop">5dp</item>
<item name="android:layout_marginRight">10dp</item>
<item name="android:layout_marginBottom">5dp</item>
<item name="android:layout_marginLeft">10dp</item>
<item name="android:background">@null</item>
</style>
</resources> </resources>
package com.agenew.location_server.application; package com.toscl.location.hengfeng;
import org.junit.Test; import org.junit.Test;
......
...@@ -7,7 +7,7 @@ buildscript { ...@@ -7,7 +7,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.3.2' classpath 'com.android.tools.build:gradle:3.4.1'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
......
#Thu Apr 04 16:04:06 CST 2019 #Wed Jun 26 09:18:27 CST 2019
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
No preview for this file type
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!