Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
石璀亮
/
agenew_a16_sos
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e8c962e0
authored
Mar 22, 2019
by
cuiliang.shi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新自动处理gps 和网络开启功能
1 parent
660f0b35
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
29 deletions
app/release/LocationServer.apk
app/src/main/java/com/agenew/location_server/application/AlarmReceiver.java
app/src/main/java/com/agenew/location_server/application/BirdService.java
app/src/main/java/com/agenew/location_server/application/LocationReceiver.java
app/src/main/java/com/agenew/location_server/application/MainActivity.java
app/release/LocationServer.apk
View file @
e8c962e
No preview for this file type
app/src/main/java/com/agenew/location_server/application/AlarmReceiver.java
View file @
e8c962e
...
...
@@ -11,6 +11,7 @@ public class AlarmReceiver extends BroadcastReceiver {
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
Log
.
d
(
"BirdService"
,
"receiver--"
+
System
.
currentTimeMillis
());
Intent
i
=
new
Intent
(
context
,
BirdService
.
class
);
context
.
startForegroundService
(
i
);
DevicePreferences
.
getInstance
(
context
).
putBoolean
(
"is_need_notification"
,
false
);
context
.
startService
(
i
);
}
}
app/src/main/java/com/agenew/location_server/application/BirdService.java
View file @
e8c962e
...
...
@@ -51,7 +51,6 @@ public class BirdService extends Service {
private
SubscriptionManager
mSubscriptionManager
;
private
List
<
SubscriptionInfo
>
mSubList
;
private
String
mStartTime
;
private
long
mInterval
;
public
AMapLocationClient
mLocationClient
=
null
;
private
String
TAG
=
"BirdService"
;
private
Context
mContext
;
...
...
@@ -82,6 +81,13 @@ public class BirdService extends Service {
mContext
=
getApplicationContext
();
// open gps & network.
// close gps & network.
Intent
intent2
=
new
Intent
(
"com.bird.open_gps_switch"
);
intent2
.
addFlags
(
0x01000000
);
sendBroadcast
(
intent2
);
if
(
DevicePreferences
.
getInstance
(
this
).
getBoolean
(
"is_need_notification"
,
true
)){
String
CHANNEL_ONE_ID
=
"com.primedu.cn"
;
String
CHANNEL_ONE_NAME
=
"Channel One"
;
NotificationChannel
notificationChannel
=
null
;
...
...
@@ -105,16 +111,7 @@ public class BirdService extends Service {
}
notification
.
flags
|=
Notification
.
FLAG_NO_CLEAR
;
startForeground
(
1
,
notification
);
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
stopForeground
(
true
);
Log
.
d
(
TAG
,
"time:"
+
new
Date
().
toString
());
stopSelf
();
}
}).
start
();
ret_cfgv
=
DevicePreferences
.
getInstance
(
getApplicationContext
()).
getString
(
"bird_ret_cfgv"
,
"0"
);
mPath
=
DevicePreferences
.
getInstance
(
mContext
).
getString
(
"bird_location_upload_url"
,
DEFAULTPATH
);
...
...
@@ -148,15 +145,14 @@ public class BirdService extends Service {
mLocationClient
.
stopLocation
();
}
}
else
{
setAlarm
();
// setAlarm();
Log
.
e
(
TAG
,
"location Error, ErrCode:"
+
amapLocation
.
getErrorCode
()
+
", errInfo:"
+
amapLocation
.
getErrorInfo
());
if
(
mLocationClient
!=
null
)
{
/*
if (mLocationClient != null) {
mLocationClient.stopLocation();
}
}
*/
}
}
else
{
Log
.
d
(
TAG
,
"location Error"
);
...
...
@@ -173,7 +169,7 @@ public class BirdService extends Service {
Log
.
d
(
TAG
,
"ALARM - CONFIG - PARAM, time minutes: "
+
temp
+
", cfgv: "
+
ret_cfgv
+
", path: "
+
mPath
);
mInterval
=
temp
*
60
*
1000
;
long
mInterval
=
temp
*
60
*
1000
;
if
(
mInterval
!=
0
)
{
AlarmManager
manger
=
(
AlarmManager
)
getSystemService
(
Context
.
ALARM_SERVICE
);
Intent
i
=
new
Intent
(
this
,
AlarmReceiver
.
class
);
...
...
@@ -182,6 +178,10 @@ public class BirdService extends Service {
triggerAtTime
=
triggerAtTime
+
mInterval
+
10
;
manger
.
setExactAndAllowWhileIdle
(
AlarmManager
.
ELAPSED_REALTIME_WAKEUP
,
triggerAtTime
,
pendingIntent2
);
}
stopForeground
(
true
);
Log
.
d
(
TAG
,
"time:"
+
new
Date
().
toString
());
stopSelf
();
}
...
...
@@ -267,7 +267,6 @@ public class BirdService extends Service {
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
setAlarm
();
httpURLConnection
.
disconnect
();
Log
.
d
(
TAG
,
"close connect"
);
if
(
os
!=
null
)
{
...
...
@@ -278,6 +277,13 @@ public class BirdService extends Service {
}
}
}
setAlarm
();
// close gps & network.
Intent
intent
=
new
Intent
(
"com.bird.close_gps_switch"
);
intent
.
addFlags
(
0x01000000
);
getApplicationContext
().
sendBroadcast
(
intent
);
}
}).
start
();
}
...
...
app/src/main/java/com/agenew/location_server/application/LocationReceiver.java
View file @
e8c962e
...
...
@@ -8,7 +8,8 @@ import android.support.annotation.RequiresApi;
import
android.util.Log
;
public
class
LocationReceiver
extends
BroadcastReceiver
{
private
String
TAG
=
"qqh"
;
private
String
TAG
=
"LocationReceiver"
;
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
O
)
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
...
...
@@ -18,6 +19,7 @@ public class LocationReceiver extends BroadcastReceiver{
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
;
}
...
...
app/src/main/java/com/agenew/location_server/application/MainActivity.java
View file @
e8c962e
...
...
@@ -3,17 +3,11 @@ package com.agenew.location_server.application;
import
android.Manifest
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.content.SharedPreferences
;
import
android.os.AsyncTask
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.widget.ArrayAdapter
;
import
android.widget.AutoCompleteTextView
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.Toast
;
...
...
@@ -23,14 +17,10 @@ import com.agenew.location_server.application.permission.annotation.OnMPermissio
import
com.agenew.location_server.application.permission.annotation.OnMPermissionGranted
;
import
com.agenew.location_server.application.permission.annotation.OnMPermissionNeverAskAgain
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
public
class
MainActivity
extends
Activity
implements
View
.
OnClickListener
{
private
String
TAG
=
"BirdService"
;
private
static
final
String
TAG
=
"BirdService"
;
private
SharedPreferences
sp
;
private
LocationReceiver
locationRecevier
;
private
Context
mContext
;
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment