Commit dc63c5e4 authored by Bartek Fabiszewski's avatar Bartek Fabiszewski
Browse files

Prepare for Android 11

parent 7cfb68da
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -10,13 +10,13 @@
apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion '29.0.2'
    compileSdkVersion 30
    buildToolsVersion '30.0.0'

    defaultConfig {
        applicationId 'net.fabiszewski.ulogger'
        minSdkVersion 19
        targetSdkVersion 29
        targetSdkVersion 30
        versionCode 301
        versionName '3.1'
    }
+4 −4
Original line number Diff line number Diff line
@@ -200,7 +200,7 @@ class LocationHelper {
     * @return True if location accuracy within limit
     */
    @SuppressWarnings("BooleanMethodIsAlwaysInverted")
    boolean hasRequiredAccuracy(Location location) {
    boolean hasRequiredAccuracy(@NonNull Location location) {
        boolean ret = location.hasAccuracy() && location.getAccuracy() <= maxAccuracy;
        if (Logger.DEBUG) { Log.d(TAG, "[hasRequiredAccuracy: " + ret + "]"); }
        return ret;
@@ -211,7 +211,7 @@ class LocationHelper {
     * @param location Location
     * @return True if location time within limit
     */
    boolean hasRequiredTime(Location location) {
    boolean hasRequiredTime(@NonNull Location location) {
        long elapsedMillis = SystemClock.elapsedRealtime() - location.getElapsedRealtimeNanos() / 1000000;
        boolean ret = elapsedMillis <= maxTimeMillis;
        if (Logger.DEBUG) { Log.d(TAG, "[hasRequiredTime: " + ret + "]"); }
@@ -223,7 +223,7 @@ class LocationHelper {
     * @param location Location
     * @return True if is from GPS
     */
    static boolean isGps(Location location) {
    static boolean isGps(@NonNull Location location) {
        boolean ret = location.getProvider().equals(LocationManager.GPS_PROVIDER);
        if (Logger.DEBUG) { Log.d(TAG, "[isGps: " + ret + "]"); }
        return ret;
@@ -234,7 +234,7 @@ class LocationHelper {
     * @param location Location
     * @return True if is from Network
     */
    static boolean isNetwork(Location location) {
    static boolean isNetwork(@NonNull Location location) {
        boolean ret = location.getProvider().equals(LocationManager.NETWORK_PROVIDER);
        if (Logger.DEBUG) { Log.d(TAG, "[isNetwork: " + ret + "]"); }
        return ret;
+4 −3
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.os.IBinder;
import android.os.Looper;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;
import androidx.core.app.TaskStackBuilder;
@@ -297,7 +298,7 @@ public class LoggerService extends Service {
         * @param location Location
         */
        @Override
        public void onLocationChanged(Location location) {
        public void onLocationChanged(@NonNull Location location) {
            if (Logger.DEBUG) { Log.d(TAG, "[location changed: " + location + "]"); }

            if (meetsCriteria(location)) {
@@ -346,7 +347,7 @@ public class LoggerService extends Service {
         * @param provider Provider
         */
        @Override
        public void onProviderDisabled(String provider) {
        public void onProviderDisabled(@NonNull String provider) {
            if (Logger.DEBUG) { Log.d(TAG, "[location provider " + provider + " disabled]"); }
            if (provider.equals(LocationManager.GPS_PROVIDER)) {
                sendBroadcast(BROADCAST_LOCATION_GPS_DISABLED);
@@ -360,7 +361,7 @@ public class LoggerService extends Service {
         * @param provider Provider
         */
        @Override
        public void onProviderEnabled(String provider) {
        public void onProviderEnabled(@NonNull String provider) {
            if (Logger.DEBUG) { Log.d(TAG, "[location provider " + provider + " enabled]"); }
            if (provider.equals(LocationManager.GPS_PROVIDER)) {
                sendBroadcast(BROADCAST_LOCATION_GPS_ENABLED);
+4 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ import android.os.Bundle;
import android.os.Looper;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.lang.ref.WeakReference;
@@ -133,7 +134,7 @@ class LoggerTask extends AsyncTask<Void, Void, Location> implements LocationList


    @Override
    public void onLocationChanged(Location location) {
    public void onLocationChanged(@NonNull Location location) {
        if (Logger.DEBUG) { Log.d(TAG, "[location changed: " + location + "]"); }
        if (hasRequiredAccuracy(location)) {
            this.location = location;
@@ -165,7 +166,7 @@ class LoggerTask extends AsyncTask<Void, Void, Location> implements LocationList
    public void onStatusChanged(String provider, int status, Bundle extras) { }

    @Override
    public void onProviderEnabled(String provider) {
    public void onProviderEnabled(@NonNull String provider) {
        if (Logger.DEBUG) { Log.d(TAG, "[onProviderEnabled: " + provider + "]"); }
        try {
            restartUpdates();
@@ -175,7 +176,7 @@ class LoggerTask extends AsyncTask<Void, Void, Location> implements LocationList
    }

    @Override
    public void onProviderDisabled(String provider) {
    public void onProviderDisabled(@NonNull String provider) {
        if (Logger.DEBUG) { Log.d(TAG, "[onProviderDisabled: " + provider + "]"); }
        try {
            restartUpdates();