Сравнить коммиты
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
c45c8ea797 | ||
|
|
ed0aa53aa3 | ||
|
|
f88891be2b | ||
|
|
3f83684d02 | ||
|
|
a9d772bfda | ||
|
|
2bc3c78a91 | ||
|
|
8fab55552d | ||
|
|
979963f6a2 |
@@ -9,8 +9,8 @@ android {
|
||||
buildConfigField "boolean", "HIDDEN_APP", "false"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 26
|
||||
versionCode 39
|
||||
versionName '5.2'
|
||||
versionCode 42
|
||||
versionName '5.5'
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
|
||||
@@ -8,6 +8,16 @@
|
||||
android:label="@string/hidden_app_name"
|
||||
tools:replace="android:label">
|
||||
|
||||
<activity
|
||||
android:name=".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" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
|
||||
|
||||
@@ -55,6 +55,9 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</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");
|
||||
* 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.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.content.WakefulBroadcastReceiver;
|
||||
|
||||
public class AutostartReceiver extends WakefulBroadcastReceiver {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
|
||||
* Copyright 2015 - 2017 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.
|
||||
@@ -75,8 +75,12 @@ public class MixedPositionProvider extends PositionProvider implements LocationL
|
||||
}
|
||||
};
|
||||
|
||||
locationManager.requestLocationUpdates(
|
||||
LocationManager.NETWORK_PROVIDER, requestInterval, 0, backupListener);
|
||||
try {
|
||||
locationManager.requestLocationUpdates(
|
||||
LocationManager.NETWORK_PROVIDER, requestInterval, 0, backupListener);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,9 +89,12 @@ public abstract class PositionProvider {
|
||||
|
||||
public static double getBatteryLevel(Context context) {
|
||||
Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
|
||||
int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, 1);
|
||||
return (level * 100.0) / scale;
|
||||
if (batteryIntent != null) {
|
||||
int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
|
||||
int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, 1);
|
||||
return (level * 100.0) / scale;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 startWakefulService(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user