Сравнить коммиты
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
4f6571e572 | ||
|
|
d3025b437b | ||
|
|
1e861ef0ac | ||
|
|
43afc57114 | ||
|
|
d47783808f | ||
|
|
3ef2272227 | ||
|
|
3625ee42db | ||
|
|
385826c3c1 | ||
|
|
1426926c8e | ||
|
|
4f680d33c9 | ||
|
|
2dad912da5 | ||
|
|
290a7d80eb | ||
|
|
44228feb2f | ||
|
|
d887bc4119 | ||
|
|
c892a20104 | ||
|
|
2719b57f7c | ||
|
|
cc6c8a23f6 | ||
|
|
1e82cbbbf6 | ||
|
|
4b8fde36d7 | ||
|
|
b8cd56439a | ||
|
|
edb1f696df | ||
|
|
56d2f2ef53 | ||
|
|
59e6a5ae65 | ||
|
|
319fab647b | ||
|
|
42429f3496 | ||
|
|
841d3e581c | ||
|
|
dac43ccbc1 | ||
|
|
3c9ae512bd | ||
|
|
d3e600d81d | ||
|
|
e0296a9c65 | ||
|
|
e51f590e19 | ||
|
|
6e3812320c | ||
|
|
c45c8ea797 | ||
|
|
ed0aa53aa3 | ||
|
|
f88891be2b | ||
|
|
3f83684d02 | ||
|
|
a9d772bfda | ||
|
|
2bc3c78a91 | ||
|
|
8fab55552d | ||
|
|
979963f6a2 | ||
|
|
70d6dfec4e | ||
|
|
43e108de8c | ||
|
|
fedce0e26b | ||
|
|
e24d725feb | ||
|
|
3198bee2f2 |
+13
-17
@@ -1,22 +1,23 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 26
|
compileSdkVersion 27
|
||||||
buildToolsVersion '26.0.1'
|
buildToolsVersion '27.0.3'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "org.traccar.client"
|
applicationId "org.traccar.client"
|
||||||
buildConfigField "boolean", "HIDDEN_APP", "false"
|
buildConfigField "boolean", "HIDDEN_APP", "false"
|
||||||
minSdkVersion 14
|
minSdkVersion 15
|
||||||
targetSdkVersion 26
|
targetSdkVersion 27
|
||||||
versionCode 37
|
versionCode 46
|
||||||
versionName '5.0'
|
versionName '5.9'
|
||||||
}
|
}
|
||||||
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
checkReleaseBuilds false
|
checkReleaseBuilds false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flavorDimensions "default"
|
||||||
productFlavors {
|
productFlavors {
|
||||||
regular
|
regular
|
||||||
google
|
google
|
||||||
@@ -25,25 +26,20 @@ android {
|
|||||||
buildConfigField "boolean", "HIDDEN_APP", "true"
|
buildConfigField "boolean", "HIDDEN_APP", "true"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
|
||||||
release {
|
|
||||||
minifyEnabled false
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.android.support:design:26.0.1'
|
compile 'com.android.support:design:27.1.0'
|
||||||
|
compile 'com.mapzen.android:lost:3.0.4'
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
testCompile 'org.robolectric:robolectric:3.4.2'
|
testCompile 'org.robolectric:robolectric:3.6.1'
|
||||||
googleCompile 'com.google.firebase:firebase-core:11.2.0'
|
googleCompile 'com.google.firebase:firebase-core:11.8.0'
|
||||||
googleCompile 'com.google.firebase:firebase-crash:11.2.0'
|
googleCompile 'com.crashlytics.sdk.android:crashlytics:2.9.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getGradle().getStartParameter().getTaskRequests().toString().contains("Google")) {
|
if (getGradle().getStartParameter().getTaskRequests().toString().contains("Google")) {
|
||||||
apply plugin: 'com.google.gms.google-services'
|
apply plugin: 'com.google.gms.google-services'
|
||||||
|
apply plugin: 'io.fabric'
|
||||||
|
|
||||||
task copyJson(type: Copy) {
|
task copyJson(type: Copy) {
|
||||||
from '../../traccar-shared/google-services'
|
from '../../traccar-shared/google-services'
|
||||||
|
|||||||
@@ -8,6 +8,16 @@
|
|||||||
android:label="@string/hidden_app_name"
|
android:label="@string/hidden_app_name"
|
||||||
tools:replace="android:label">
|
tools:replace="android:label">
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name="org.traccar.client.MainActivity">
|
||||||
|
<intent-filter android:label="@string/app_name">
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data android:scheme="https" android:host="www.traccar.org" android:pathPrefix="/hidden" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<receiver android:name="org.traccar.client.DialLaunchReceiver" >
|
<receiver android:name="org.traccar.client.DialLaunchReceiver" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
|
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:pathData="M12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM19,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.11,0 2,-0.9 2,-2L21,5c0,-1.1 -0.89,-2 -2,-2zM17.25,12c0,0.23 -0.02,0.46 -0.05,0.68l1.48,1.16c0.13,0.11 0.17,0.3 0.08,0.45l-1.4,2.42c-0.09,0.15 -0.27,0.21 -0.43,0.15l-1.74,-0.7c-0.36,0.28 -0.76,0.51 -1.18,0.69l-0.26,1.85c-0.03,0.17 -0.18,0.3 -0.35,0.3h-2.8c-0.17,0 -0.32,-0.13 -0.35,-0.29l-0.26,-1.85c-0.43,-0.18 -0.82,-0.41 -1.18,-0.69l-1.74,0.7c-0.16,0.06 -0.34,0 -0.43,-0.15l-1.4,-2.42c-0.09,-0.15 -0.05,-0.34 0.08,-0.45l1.48,-1.16c-0.03,-0.23 -0.05,-0.46 -0.05,-0.69 0,-0.23 0.02,-0.46 0.05,-0.68l-1.48,-1.16c-0.13,-0.11 -0.17,-0.3 -0.08,-0.45l1.4,-2.42c0.09,-0.15 0.27,-0.21 0.43,-0.15l1.74,0.7c0.36,-0.28 0.76,-0.51 1.18,-0.69l0.26,-1.85c0.03,-0.17 0.18,-0.3 0.35,-0.3h2.8c0.17,0 0.32,0.13 0.35,0.29l0.26,1.85c0.43,0.18 0.82,0.41 1.18,0.69l1.74,-0.7c0.16,-0.06 0.34,0 0.43,0.15l1.4,2.42c0.09,0.15 0.05,0.34 -0.08,0.45l-1.48,1.16c0.03,0.23 0.05,0.46 0.05,0.69z"/>
|
||||||
|
</vector>
|
||||||
@@ -55,6 +55,9 @@
|
|||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||||
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
|
* Copyright 2013 - 2017 Anton Tananaev (anton.tananaev@gmail.com)
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -19,7 +19,6 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.content.WakefulBroadcastReceiver;
|
|
||||||
|
|
||||||
public class AutostartReceiver extends WakefulBroadcastReceiver {
|
public class AutostartReceiver extends WakefulBroadcastReceiver {
|
||||||
|
|
||||||
@@ -27,7 +26,7 @@ public class AutostartReceiver extends WakefulBroadcastReceiver {
|
|||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
if (sharedPreferences.getBoolean(MainFragment.KEY_STATUS, false)) {
|
if (sharedPreferences.getBoolean(MainFragment.KEY_STATUS, false)) {
|
||||||
startWakefulService(context, new Intent(context, TrackingService.class));
|
startWakefulForegroundService(context, new Intent(context, TrackingService.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||||||
values.put("altitude", position.getAltitude());
|
values.put("altitude", position.getAltitude());
|
||||||
values.put("speed", position.getSpeed());
|
values.put("speed", position.getSpeed());
|
||||||
values.put("course", position.getCourse());
|
values.put("course", position.getCourse());
|
||||||
values.put("accuracy", position.getCourse());
|
values.put("accuracy", position.getAccuracy());
|
||||||
values.put("battery", position.getBattery());
|
values.put("battery", position.getBattery());
|
||||||
|
|
||||||
db.insertOrThrow("position", null, values);
|
db.insertOrThrow("position", null, values);
|
||||||
|
|||||||
@@ -21,8 +21,11 @@ import android.app.Notification;
|
|||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
public class MainApplication extends Application {
|
public class MainApplication extends Application {
|
||||||
|
|
||||||
@@ -33,6 +36,8 @@ public class MainApplication extends Application {
|
|||||||
super.onCreate();
|
super.onCreate();
|
||||||
System.setProperty("http.keepAliveDuration", String.valueOf(30 * 60 * 1000));
|
System.setProperty("http.keepAliveDuration", String.valueOf(30 * 60 * 1000));
|
||||||
|
|
||||||
|
migrateLegacyPreferences(PreferenceManager.getDefaultSharedPreferences(this));
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
registerChannel();
|
registerChannel();
|
||||||
}
|
}
|
||||||
@@ -47,4 +52,22 @@ public class MainApplication extends Application {
|
|||||||
((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(channel);
|
((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void migrateLegacyPreferences(SharedPreferences preferences) {
|
||||||
|
String port = preferences.getString("port", null);
|
||||||
|
if (port != null) {
|
||||||
|
String host = preferences.getString("address", getString(R.string.settings_url_default_value));
|
||||||
|
String scheme = preferences.getBoolean("secure", false) ? "https" : "http";
|
||||||
|
|
||||||
|
Uri.Builder builder = new Uri.Builder();
|
||||||
|
builder.scheme(scheme).encodedAuthority(host + ":" + port).build();
|
||||||
|
SharedPreferences.Editor editor = preferences.edit();
|
||||||
|
editor.putString(MainFragment.KEY_URL, builder.toString());
|
||||||
|
|
||||||
|
editor.remove("port");
|
||||||
|
editor.remove("address");
|
||||||
|
editor.remove("secure");
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class MainFragment extends PreferenceFragment implements OnSharedPreferen
|
|||||||
public static final String KEY_INTERVAL = "interval";
|
public static final String KEY_INTERVAL = "interval";
|
||||||
public static final String KEY_DISTANCE = "distance";
|
public static final String KEY_DISTANCE = "distance";
|
||||||
public static final String KEY_ANGLE = "angle";
|
public static final String KEY_ANGLE = "angle";
|
||||||
public static final String KEY_PROVIDER = "provider";
|
public static final String KEY_ACCURACY = "accuracy";
|
||||||
public static final String KEY_STATUS = "status";
|
public static final String KEY_STATUS = "status";
|
||||||
|
|
||||||
private static final int PERMISSIONS_REQUEST_LOCATION = 2;
|
private static final int PERMISSIONS_REQUEST_LOCATION = 2;
|
||||||
@@ -78,7 +78,6 @@ public class MainFragment extends PreferenceFragment implements OnSharedPreferen
|
|||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
migrateLegacyPreferences(sharedPreferences);
|
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
initPreferences();
|
initPreferences();
|
||||||
|
|
||||||
@@ -176,7 +175,7 @@ public class MainFragment extends PreferenceFragment implements OnSharedPreferen
|
|||||||
findPreference(KEY_INTERVAL).setEnabled(enabled);
|
findPreference(KEY_INTERVAL).setEnabled(enabled);
|
||||||
findPreference(KEY_DISTANCE).setEnabled(enabled);
|
findPreference(KEY_DISTANCE).setEnabled(enabled);
|
||||||
findPreference(KEY_ANGLE).setEnabled(enabled);
|
findPreference(KEY_ANGLE).setEnabled(enabled);
|
||||||
findPreference(KEY_PROVIDER).setEnabled(enabled);
|
findPreference(KEY_ACCURACY).setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -248,13 +247,8 @@ public class MainFragment extends PreferenceFragment implements OnSharedPreferen
|
|||||||
ALARM_MANAGER_INTERVAL, ALARM_MANAGER_INTERVAL, alarmIntent);
|
ALARM_MANAGER_INTERVAL, ALARM_MANAGER_INTERVAL, alarmIntent);
|
||||||
} else {
|
} else {
|
||||||
sharedPreferences.edit().putBoolean(KEY_STATUS, false).apply();
|
sharedPreferences.edit().putBoolean(KEY_STATUS, false).apply();
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
TwoStatePreference preference = (TwoStatePreference) findPreference(KEY_STATUS);
|
||||||
TwoStatePreference preference = (TwoStatePreference) findPreference(KEY_STATUS);
|
preference.setChecked(false);
|
||||||
preference.setChecked(false);
|
|
||||||
} else {
|
|
||||||
CheckBoxPreference preference = (CheckBoxPreference) findPreference(KEY_STATUS);
|
|
||||||
preference.setChecked(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,24 +282,4 @@ public class MainFragment extends PreferenceFragment implements OnSharedPreferen
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void migrateLegacyPreferences(SharedPreferences preferences) {
|
|
||||||
String port = preferences.getString("port", null);
|
|
||||||
if (port != null) {
|
|
||||||
Log.d(TAG, "Migrating to URL preference");
|
|
||||||
|
|
||||||
String host = preferences.getString("address", getString(R.string.settings_url_default_value));
|
|
||||||
String scheme = preferences.getBoolean("secure", false) ? "https" : "http";
|
|
||||||
|
|
||||||
Uri.Builder builder = new Uri.Builder();
|
|
||||||
builder.scheme(scheme).encodedAuthority(host + ":" + port).build();
|
|
||||||
SharedPreferences.Editor editor = preferences.edit();
|
|
||||||
editor.putString(KEY_URL, builder.toString());
|
|
||||||
|
|
||||||
editor.remove("port");
|
|
||||||
editor.remove("address");
|
|
||||||
editor.remove("secure");
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,122 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.traccar.client;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.location.GpsStatus;
|
|
||||||
import android.location.Location;
|
|
||||||
import android.location.LocationListener;
|
|
||||||
import android.location.LocationManager;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
@SuppressWarnings("MissingPermission")
|
|
||||||
public class MixedPositionProvider extends PositionProvider implements LocationListener, GpsStatus.Listener {
|
|
||||||
|
|
||||||
private static final int FIX_TIMEOUT = 30 * 1000;
|
|
||||||
|
|
||||||
private LocationListener backupListener;
|
|
||||||
private long lastFixTime;
|
|
||||||
|
|
||||||
public MixedPositionProvider(Context context, PositionListener listener) {
|
|
||||||
super(context, listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startUpdates() {
|
|
||||||
lastFixTime = System.currentTimeMillis();
|
|
||||||
locationManager.addGpsStatusListener(this);
|
|
||||||
try {
|
|
||||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, requestInterval, 0, this);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
Log.w(TAG, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stopUpdates() {
|
|
||||||
locationManager.removeUpdates(this);
|
|
||||||
locationManager.removeGpsStatusListener(this);
|
|
||||||
stopBackupProvider();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startBackupProvider() {
|
|
||||||
Log.i(TAG, "backup provider start");
|
|
||||||
if (backupListener == null) {
|
|
||||||
|
|
||||||
backupListener = new LocationListener() {
|
|
||||||
@Override
|
|
||||||
public void onLocationChanged(Location location) {
|
|
||||||
Log.i(TAG, "backup provider location");
|
|
||||||
updateLocation(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStatusChanged(String s, int i, Bundle bundle) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProviderEnabled(String s) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProviderDisabled(String s) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
locationManager.requestLocationUpdates(
|
|
||||||
LocationManager.NETWORK_PROVIDER, requestInterval, 0, backupListener);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void stopBackupProvider() {
|
|
||||||
Log.i(TAG, "backup provider stop");
|
|
||||||
if (backupListener != null) {
|
|
||||||
locationManager.removeUpdates(backupListener);
|
|
||||||
backupListener = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLocationChanged(Location location) {
|
|
||||||
Log.i(TAG, "provider location");
|
|
||||||
stopBackupProvider();
|
|
||||||
lastFixTime = System.currentTimeMillis();
|
|
||||||
updateLocation(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProviderEnabled(String provider) {
|
|
||||||
Log.i(TAG, "provider enabled");
|
|
||||||
stopBackupProvider();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProviderDisabled(String provider) {
|
|
||||||
Log.i(TAG, "provider disabled");
|
|
||||||
startBackupProvider();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGpsStatusChanged(int event) {
|
|
||||||
if (backupListener == null && System.currentTimeMillis() - lastFixTime - requestInterval > FIX_TIMEOUT) {
|
|
||||||
startBackupProvider();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -15,19 +15,24 @@
|
|||||||
*/
|
*/
|
||||||
package org.traccar.client;
|
package org.traccar.client;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.location.LocationManager;
|
|
||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public abstract class PositionProvider {
|
import com.mapzen.android.lost.api.LocationListener;
|
||||||
|
import com.mapzen.android.lost.api.LocationRequest;
|
||||||
|
import com.mapzen.android.lost.api.LocationServices;
|
||||||
|
import com.mapzen.android.lost.api.LostApiClient;
|
||||||
|
|
||||||
protected static final String TAG = PositionProvider.class.getSimpleName();
|
public class PositionProvider implements LostApiClient.ConnectionCallbacks, LocationListener {
|
||||||
|
|
||||||
|
private static final String TAG = PositionProvider.class.getSimpleName();
|
||||||
|
|
||||||
private static final int MINIMUM_INTERVAL = 1000;
|
private static final int MINIMUM_INTERVAL = 1000;
|
||||||
|
|
||||||
@@ -38,46 +43,65 @@ public abstract class PositionProvider {
|
|||||||
private final PositionListener listener;
|
private final PositionListener listener;
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
protected final LocationManager locationManager;
|
private SharedPreferences preferences;
|
||||||
|
private LostApiClient apiClient;
|
||||||
|
|
||||||
private String deviceId;
|
private String deviceId;
|
||||||
protected String type;
|
private long interval;
|
||||||
protected long requestInterval;
|
private double distance;
|
||||||
protected long interval;
|
private double angle;
|
||||||
protected double distance;
|
|
||||||
protected double angle;
|
|
||||||
|
|
||||||
private Location lastLocation;
|
private Location lastLocation;
|
||||||
|
|
||||||
|
private boolean started;
|
||||||
|
|
||||||
public PositionProvider(Context context, PositionListener listener) {
|
public PositionProvider(Context context, PositionListener listener) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
|
||||||
|
|
||||||
deviceId = preferences.getString(MainFragment.KEY_DEVICE, null);
|
deviceId = preferences.getString(MainFragment.KEY_DEVICE, "undefined");
|
||||||
interval = Long.parseLong(preferences.getString(MainFragment.KEY_INTERVAL, null)) * 1000;
|
interval = Long.parseLong(preferences.getString(MainFragment.KEY_INTERVAL, "600")) * 1000;
|
||||||
distance = Integer.parseInt(preferences.getString(MainFragment.KEY_DISTANCE, null));
|
distance = Integer.parseInt(preferences.getString(MainFragment.KEY_DISTANCE, "0"));
|
||||||
angle = Integer.parseInt(preferences.getString(MainFragment.KEY_ANGLE, null));
|
angle = Integer.parseInt(preferences.getString(MainFragment.KEY_ANGLE, "0"));
|
||||||
|
|
||||||
if (distance > 0 || angle > 0) {
|
|
||||||
requestInterval = MINIMUM_INTERVAL;
|
|
||||||
} else {
|
|
||||||
requestInterval = interval;
|
|
||||||
}
|
|
||||||
|
|
||||||
type = preferences.getString(MainFragment.KEY_PROVIDER, "gps");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void startUpdates();
|
public void startUpdates() {
|
||||||
|
started = true;
|
||||||
|
apiClient = new LostApiClient.Builder(context).addConnectionCallbacks(this).build();
|
||||||
|
apiClient.connect();
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void stopUpdates();
|
private int getPriority(String accuracy) {
|
||||||
|
switch (accuracy) {
|
||||||
|
case "high":
|
||||||
|
return LocationRequest.PRIORITY_HIGH_ACCURACY;
|
||||||
|
case "low":
|
||||||
|
return LocationRequest.PRIORITY_LOW_POWER;
|
||||||
|
default:
|
||||||
|
return LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void updateLocation(Location location) {
|
@SuppressLint("MissingPermission")
|
||||||
|
@Override
|
||||||
|
public void onConnected() {
|
||||||
|
if (started) {
|
||||||
|
LocationRequest request = LocationRequest.create()
|
||||||
|
.setPriority(getPriority(preferences.getString(MainFragment.KEY_ACCURACY, "medium")))
|
||||||
|
.setInterval(distance > 0 || angle > 0 ? MINIMUM_INTERVAL : interval);
|
||||||
|
LocationServices.FusedLocationApi.requestLocationUpdates(apiClient, request, this);
|
||||||
|
} else {
|
||||||
|
apiClient.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLocationChanged(Location location) {
|
||||||
if (location != null && (lastLocation == null
|
if (location != null && (lastLocation == null
|
||||||
|| location.getTime() - lastLocation.getTime() >= interval
|
|| location.getTime() - lastLocation.getTime() >= interval
|
||||||
|| distance > 0 && DistanceCalculator.distance(location.getLatitude(), location.getLongitude(), lastLocation.getLatitude(), location.getLongitude()) >= distance
|
|| distance > 0 && DistanceCalculator.distance(location.getLatitude(), location.getLongitude(), lastLocation.getLatitude(), lastLocation.getLongitude()) >= distance
|
||||||
|| angle > 0 && Math.abs(location.getBearing() - lastLocation.getBearing()) >= angle)) {
|
|| angle > 0 && Math.abs(location.getBearing() - lastLocation.getBearing()) >= angle)) {
|
||||||
Log.i(TAG, "location new");
|
Log.i(TAG, "location new");
|
||||||
lastLocation = location;
|
lastLocation = location;
|
||||||
@@ -87,11 +111,27 @@ public abstract class PositionProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConnectionSuspended() {
|
||||||
|
Log.i(TAG, "lost client suspended");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopUpdates() {
|
||||||
|
if (apiClient.isConnected()) {
|
||||||
|
LocationServices.FusedLocationApi.removeLocationUpdates(apiClient, this);
|
||||||
|
apiClient.disconnect();
|
||||||
|
}
|
||||||
|
started = false;
|
||||||
|
}
|
||||||
|
|
||||||
public static double getBatteryLevel(Context context) {
|
public static double getBatteryLevel(Context context) {
|
||||||
Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||||
int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
|
if (batteryIntent != null) {
|
||||||
int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, 1);
|
int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
|
||||||
return (level * 100.0) / scale;
|
int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, 1);
|
||||||
|
return (level * 100.0) / scale;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public class RequestManager {
|
|||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
connection.setReadTimeout(TIMEOUT);
|
connection.setReadTimeout(TIMEOUT);
|
||||||
connection.setConnectTimeout(TIMEOUT);
|
connection.setConnectTimeout(TIMEOUT);
|
||||||
|
connection.setRequestMethod("POST");
|
||||||
connection.connect();
|
connection.connect();
|
||||||
inputStream = connection.getInputStream();
|
inputStream = connection.getInputStream();
|
||||||
while (inputStream.read() != -1);
|
while (inputStream.read() != -1);
|
||||||
|
|||||||
@@ -15,11 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.traccar.client;
|
package org.traccar.client;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.location.LocationManager;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.DrawableRes;
|
import android.support.annotation.DrawableRes;
|
||||||
@@ -34,7 +32,10 @@ import android.widget.ArrayAdapter;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class ShortcutActivity extends AppCompatActivity {
|
import com.mapzen.android.lost.api.LocationServices;
|
||||||
|
import com.mapzen.android.lost.api.LostApiClient;
|
||||||
|
|
||||||
|
public class ShortcutActivity extends AppCompatActivity implements LostApiClient.ConnectionCallbacks {
|
||||||
|
|
||||||
public static final String EXTRA_ACTION = "action";
|
public static final String EXTRA_ACTION = "action";
|
||||||
public static final String ACTION_START = "start";
|
public static final String ACTION_START = "start";
|
||||||
@@ -43,6 +44,8 @@ public class ShortcutActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private static final String ALARM_SOS = "sos";
|
private static final String ALARM_SOS = "sos";
|
||||||
|
|
||||||
|
private LostApiClient apiClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -99,16 +102,17 @@ public class ShortcutActivity extends AppCompatActivity {
|
|||||||
setResult(RESULT_OK, ShortcutManagerCompat.createShortcutResultIntent(this, shortcut));
|
setResult(RESULT_OK, ShortcutManagerCompat.createShortcutResultIntent(this, shortcut));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("MissingPermission")
|
|
||||||
private void sendAlarm() {
|
private void sendAlarm() {
|
||||||
|
apiClient = new LostApiClient.Builder(this).addConnectionCallbacks(this).build();
|
||||||
|
apiClient.connect();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("MissingPermission")
|
||||||
|
@Override
|
||||||
|
public void onConnected() {
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
Location location = LocationServices.FusedLocationApi.getLastLocation(apiClient);
|
||||||
|
|
||||||
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
|
||||||
if (location == null) {
|
|
||||||
location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
|
|
||||||
@@ -133,6 +137,12 @@ public class ShortcutActivity extends AppCompatActivity {
|
|||||||
} else {
|
} else {
|
||||||
Toast.makeText(this, R.string.status_send_fail, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.status_send_fail, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apiClient.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConnectionSuspended() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean executeAction(Intent intent) {
|
private boolean executeAction(Intent intent) {
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.traccar.client;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.location.Location;
|
|
||||||
import android.location.LocationListener;
|
|
||||||
import android.location.LocationManager;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
@SuppressWarnings("MissingPermission")
|
|
||||||
public class SimplePositionProvider extends PositionProvider implements LocationListener {
|
|
||||||
|
|
||||||
public SimplePositionProvider(Context context, PositionListener listener) {
|
|
||||||
super(context, listener);
|
|
||||||
if (!type.equals(LocationManager.NETWORK_PROVIDER)) {
|
|
||||||
type = LocationManager.GPS_PROVIDER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startUpdates() {
|
|
||||||
try {
|
|
||||||
locationManager.requestLocationUpdates(type, requestInterval, 0, this);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
Log.w(TAG, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stopUpdates() {
|
|
||||||
locationManager.removeUpdates(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLocationChanged(Location location) {
|
|
||||||
updateLocation(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProviderEnabled(String provider) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProviderDisabled(String provider) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -57,16 +57,12 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
handler = new Handler();
|
handler = new Handler();
|
||||||
preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
if (preferences.getString(MainFragment.KEY_PROVIDER, "gps").equals("mixed")) {
|
positionProvider = new PositionProvider(context, this);
|
||||||
positionProvider = new MixedPositionProvider(context, this);
|
|
||||||
} else {
|
|
||||||
positionProvider = new SimplePositionProvider(context, this);
|
|
||||||
}
|
|
||||||
databaseHelper = new DatabaseHelper(context);
|
databaseHelper = new DatabaseHelper(context);
|
||||||
networkManager = new NetworkManager(context, this);
|
networkManager = new NetworkManager(context, this);
|
||||||
isOnline = networkManager.isOnline();
|
isOnline = networkManager.isOnline();
|
||||||
|
|
||||||
url = preferences.getString(MainFragment.KEY_URL, null);
|
url = preferences.getString(MainFragment.KEY_URL, context.getString(R.string.settings_url_default_value));
|
||||||
|
|
||||||
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||||
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
|
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
|
||||||
@@ -104,7 +100,8 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNetworkUpdate(boolean isOnline) {
|
public void onNetworkUpdate(boolean isOnline) {
|
||||||
StatusActivity.addMessage(context.getString(R.string.status_connectivity_change));
|
int message = isOnline ? R.string.status_network_online : R.string.status_network_offline;
|
||||||
|
StatusActivity.addMessage(context.getString(message));
|
||||||
if (!this.isOnline && isOnline) {
|
if (!this.isOnline && isOnline) {
|
||||||
read();
|
read();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,16 +35,24 @@ public class TrackingService extends Service {
|
|||||||
private TrackingController trackingController;
|
private TrackingController trackingController;
|
||||||
|
|
||||||
private static Notification createNotification(Context context) {
|
private static Notification createNotification(Context context) {
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0);
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, MainApplication.PRIMARY_CHANNEL)
|
||||||
return new NotificationCompat.Builder(context, MainApplication.PRIMARY_CHANNEL)
|
.setSmallIcon(R.drawable.ic_stat_notify)
|
||||||
.setContentTitle(context.getString(R.string.app_name))
|
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||||
.setContentText(context.getString(R.string.settings_status_on_summary))
|
.setCategory(Notification.CATEGORY_SERVICE);
|
||||||
.setContentIntent(pendingIntent)
|
Intent intent;
|
||||||
.setPriority(NotificationCompat.PRIORITY_MIN)
|
if (!BuildConfig.HIDDEN_APP) {
|
||||||
.build();
|
intent = new Intent(context, MainActivity.class);
|
||||||
|
builder
|
||||||
|
.setContentTitle(context.getString(R.string.settings_status_on_summary))
|
||||||
|
.setTicker(context.getString(R.string.settings_status_on_summary))
|
||||||
|
.setColor(ContextCompat.getColor(context, R.color.primary_dark));
|
||||||
|
} else {
|
||||||
|
intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
|
||||||
|
}
|
||||||
|
builder.setContentIntent(PendingIntent.getActivity(context, 0, intent, 0));
|
||||||
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.ECLAIR)
|
|
||||||
public static class HideNotificationService extends Service {
|
public static class HideNotificationService extends Service {
|
||||||
@Override
|
@Override
|
||||||
public IBinder onBind(Intent intent) {
|
public IBinder onBind(Intent intent) {
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.traccar.client;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.PowerManager;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.util.SparseArray;
|
||||||
|
|
||||||
|
public abstract class WakefulBroadcastReceiver extends BroadcastReceiver {
|
||||||
|
private static final String EXTRA_WAKE_LOCK_ID = "android.support.content.wakelockid";
|
||||||
|
private static final SparseArray<PowerManager.WakeLock> mActiveWakeLocks = new SparseArray<>();
|
||||||
|
private static int mNextId = 1;
|
||||||
|
|
||||||
|
public static void startWakefulForegroundService(Context context, Intent intent) {
|
||||||
|
synchronized (mActiveWakeLocks) {
|
||||||
|
int id = mNextId;
|
||||||
|
mNextId++;
|
||||||
|
if (mNextId <= 0) {
|
||||||
|
mNextId = 1;
|
||||||
|
}
|
||||||
|
intent.putExtra(EXTRA_WAKE_LOCK_ID, id);
|
||||||
|
ContextCompat.startForegroundService(context, intent);
|
||||||
|
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
|
||||||
|
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
||||||
|
WakefulBroadcastReceiver.class.getSimpleName());
|
||||||
|
wl.setReferenceCounted(false);
|
||||||
|
wl.acquire(60*1000);
|
||||||
|
mActiveWakeLocks.put(id, wl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean completeWakefulIntent(Intent intent) {
|
||||||
|
final int id = intent.getIntExtra(EXTRA_WAKE_LOCK_ID, 0);
|
||||||
|
if (id == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
synchronized (mActiveWakeLocks) {
|
||||||
|
PowerManager.WakeLock wl = mActiveWakeLocks.get(id);
|
||||||
|
if (wl != null) {
|
||||||
|
wl.release();
|
||||||
|
mActiveWakeLocks.remove(id);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<vector
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportHeight="72.0"
|
||||||
|
android:viewportWidth="72.0"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M36,0A36,36 0,0 0,0 36A36,36 0,0 0,36 72A36,36 0,0 0,72 36A36,36 0,0 0,36 0zM50.51,14.66C53.41,16.89 55.93,19.68 57.88,23.05C59.83,26.42 60.99,30 61.46,33.63L55.09,34.55C54.72,31.74 53.87,28.85 52.36,26.24C50.85,23.63 48.78,21.45 46.53,19.72L50.51,14.66zM42.82,24.85C44.4,26.08 45.77,27.58 46.84,29.43C47.91,31.27 48.52,33.21 48.79,35.2L42.42,36.12C42.25,34.95 41.95,33.7 41.32,32.61C40.69,31.53 39.77,30.64 38.84,29.91L42.82,24.85zM18.38,31.13L24.76,42.17L31.13,53.21A12.75,12.75 37.68,0 1,18.38 53.21A12.75,12.75 37.68,0 1,12.01 42.17A12.75,12.75 37.68,0 1,18.38 31.13zM32.96,34.21A3.19,3.19 60,0 1,35.8 35.8A3.19,3.19 60,0 1,34.63 40.15A3.19,3.19 60,0 1,30.28 38.99A3.19,3.19 60,0 1,31.45 34.63A3.19,3.19 60,0 1,32.96 34.21z"/>
|
||||||
|
</vector>
|
||||||
@@ -9,7 +9,6 @@
|
|||||||
<string name="settings_id_title">Device identifier</string>
|
<string name="settings_id_title">Device identifier</string>
|
||||||
<string name="settings_url_title">Server URL</string>
|
<string name="settings_url_title">Server URL</string>
|
||||||
<string name="settings_url_summary">Tracking server URL</string>
|
<string name="settings_url_summary">Tracking server URL</string>
|
||||||
<string name="settings_url_default_value" translatable="false">http://demo.traccar.org:5055</string>
|
|
||||||
<string name="settings_interval_title">Frequency</string>
|
<string name="settings_interval_title">Frequency</string>
|
||||||
<string name="settings_interval_summary">Reporting interval in seconds</string>
|
<string name="settings_interval_summary">Reporting interval in seconds</string>
|
||||||
<string name="settings_distance_title">Distance</string>
|
<string name="settings_distance_title">Distance</string>
|
||||||
@@ -21,11 +20,11 @@
|
|||||||
<string name="settings_status_on">Stop</string>
|
<string name="settings_status_on">Stop</string>
|
||||||
<string name="settings_status_off_summary">Service stopped</string>
|
<string name="settings_status_off_summary">Service stopped</string>
|
||||||
<string name="settings_status_on_summary">Service running</string>
|
<string name="settings_status_on_summary">Service running</string>
|
||||||
<string name="settings_provider_title">Location provider</string>
|
<string name="settings_accuracy_title">Location accuracy</string>
|
||||||
<string name="settings_provider_summary">Source of location data</string>
|
<string name="settings_accuracy_summary">Desired location accuracy</string>
|
||||||
<string name="settings_provider_gps">GPS provider</string>
|
<string name="settings_accuracy_high">High</string>
|
||||||
<string name="settings_provider_network">Network provider</string>
|
<string name="settings_accuracy_medium">Medium</string>
|
||||||
<string name="settings_provider_mixed">Mixed provider</string>
|
<string name="settings_accuracy_low">Low</string>
|
||||||
<string name="settings_foreground_title">Foreground service</string>
|
<string name="settings_foreground_title">Foreground service</string>
|
||||||
<string name="settings_foreground_summary">Increase service priority</string>
|
<string name="settings_foreground_summary">Increase service priority</string>
|
||||||
<string name="menu_status">Status</string>
|
<string name="menu_status">Status</string>
|
||||||
@@ -40,7 +39,8 @@
|
|||||||
<string name="status_send_success">Send successfully</string>
|
<string name="status_send_success">Send successfully</string>
|
||||||
<string name="status_send_fail">Send failed</string>
|
<string name="status_send_fail">Send failed</string>
|
||||||
<string name="status_location_update">Location update</string>
|
<string name="status_location_update">Location update</string>
|
||||||
<string name="status_connectivity_change">Connectivity change</string>
|
<string name="status_network_online">Network online</string>
|
||||||
|
<string name="status_network_offline">Network offline</string>
|
||||||
<string name="hidden_app_name">Device Settings</string>
|
<string name="hidden_app_name">Device Settings</string>
|
||||||
<string name="hidden_alert">The app has been hidden. To open it again please dial 8722227 (TRACCAR).</string>
|
<string name="hidden_alert">The app has been hidden. To open it again please dial 8722227 (TRACCAR).</string>
|
||||||
<string name="error_msg_invalid_url">Please enter a valid http:// or https:// URL</string>
|
<string name="error_msg_invalid_url">Please enter a valid http:// or https:// URL</string>
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<string-array name="settings_provider_values" translatable="false">
|
<string name="settings_url_default_value" translatable="false">http://demo.traccar.org:5055</string>
|
||||||
<item>gps</item>
|
|
||||||
<item>network</item>
|
<string-array name="settings_accuracy_values" translatable="false">
|
||||||
<item>mixed</item>
|
<item>high</item>
|
||||||
|
<item>medium</item>
|
||||||
|
<item>low</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="settings_provider_names">
|
<string-array name="settings_accuracy_names">
|
||||||
<item>@string/settings_provider_gps</item>
|
<item>@string/settings_accuracy_high</item>
|
||||||
<item>@string/settings_provider_network</item>
|
<item>@string/settings_accuracy_medium</item>
|
||||||
<item>@string/settings_provider_mixed</item>
|
<item>@string/settings_accuracy_low</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -20,6 +20,14 @@
|
|||||||
android:summary="@string/settings_url_summary"
|
android:summary="@string/settings_url_summary"
|
||||||
android:title="@string/settings_url_title" />
|
android:title="@string/settings_url_title" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:defaultValue="medium"
|
||||||
|
android:entries="@array/settings_accuracy_names"
|
||||||
|
android:entryValues="@array/settings_accuracy_values"
|
||||||
|
android:key="accuracy"
|
||||||
|
android:summary="@string/settings_accuracy_summary"
|
||||||
|
android:title="@string/settings_accuracy_title" />
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:defaultValue="300"
|
android:defaultValue="300"
|
||||||
android:key="interval"
|
android:key="interval"
|
||||||
@@ -41,12 +49,4 @@
|
|||||||
android:summary="@string/settings_angle_summary"
|
android:summary="@string/settings_angle_summary"
|
||||||
android:title="@string/settings_angle_title" />
|
android:title="@string/settings_angle_title" />
|
||||||
|
|
||||||
<ListPreference
|
|
||||||
android:defaultValue="gps"
|
|
||||||
android:entries="@array/settings_provider_names"
|
|
||||||
android:entryValues="@array/settings_provider_values"
|
|
||||||
android:key="provider"
|
|
||||||
android:summary="@string/settings_provider_summary"
|
|
||||||
android:title="@string/settings_provider_title" />
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
package org.traccar.client;
|
package org.traccar.client;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
@@ -12,6 +13,7 @@ import static org.junit.Assert.assertTrue;
|
|||||||
@Config(constants = BuildConfig.class, sdk = 21)
|
@Config(constants = BuildConfig.class, sdk = 21)
|
||||||
public class RequestManagerTest {
|
public class RequestManagerTest {
|
||||||
|
|
||||||
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testSendRequest() throws Exception {
|
public void testSendRequest() throws Exception {
|
||||||
|
|
||||||
|
|||||||
+7
-3
@@ -1,16 +1,20 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven { url 'https://maven.fabric.io/public' }
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:2.3.3'
|
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||||
classpath 'com.google.gms:google-services:3.1.0'
|
classpath 'com.google.gms:google-services:3.1.1'
|
||||||
|
classpath 'io.fabric.tools:gradle:1.25.1'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
|
||||||
google()
|
google()
|
||||||
|
jcenter()
|
||||||
|
maven { url 'https://maven.fabric.io/public' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -2,4 +2,4 @@ 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.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user