-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To make sure the messages keep getting sent while the app is in doze, remove foreground service and instead use alarm manager to explicitly schedule publishing messages. Also, request disabling of battery optimization in Android 6+. Due to Android policy, less than 15 minutes schedule is not allowed, so adapted allowed schedule range.
- Loading branch information
ostrya
committed
Oct 30, 2019
1 parent
a38431a
commit 9e71e35
Showing
15 changed files
with
325 additions
and
323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
app/src/main/java/org/ostrya/presencepublisher/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,44 @@ | ||
package org.ostrya.presencepublisher; | ||
|
||
import android.content.IntentFilter; | ||
import android.net.ConnectivityManager; | ||
import android.os.Build; | ||
import android.util.Log; | ||
import com.hypertrack.hyperlog.HyperLog; | ||
import org.ostrya.presencepublisher.log.CustomLogFormat; | ||
import org.ostrya.presencepublisher.receiver.SystemBroadcastReceiver; | ||
import org.ostrya.presencepublisher.ui.notification.NotificationFactory; | ||
|
||
public class Application extends android.app.Application { | ||
public static final int PERMISSION_REQUEST_CODE = 1; | ||
public static final int LOCATION_REQUEST_CODE = 2; | ||
public static final int BATTERY_OPTIMIZATION_REQUEST_CODE = 3; | ||
public static final int ALARM_REQUEST_CODE = 4; | ||
public static final int MAIN_ACTIVITY_REQUEST_CODE = 5; | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
initLogger(); | ||
initNetworkReceiver(); | ||
NotificationFactory.createNotificationChannel(this); | ||
} | ||
|
||
private void initLogger() { | ||
HyperLog.initialize(this, new CustomLogFormat(this)); | ||
if (BuildConfig.DEBUG) { | ||
HyperLog.setLogLevel(Log.VERBOSE); | ||
} else { | ||
HyperLog.setLogLevel(Log.INFO); | ||
} | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
private void initNetworkReceiver() { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | ||
SystemBroadcastReceiver receiver = new SystemBroadcastReceiver(); | ||
IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); | ||
registerReceiver(receiver, filter); | ||
} | ||
} | ||
} |
264 changes: 0 additions & 264 deletions
264
app/src/main/java/org/ostrya/presencepublisher/ForegroundService.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.