Skip to content

Commit 165b681

Browse files
author
ostrya
committed
handle more connection events
react to newly connected network even when network type is VPN or ethernet also remove unneeded foreground service permission and add store listing data to repository
1 parent 9e71e35 commit 165b681

File tree

30 files changed

+38
-9
lines changed

30 files changed

+38
-9
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ certificate via:
2828
* ACCESS_NETWORK_STATE: necessary to register network change listener
2929
* ACCESS_WIFI_STATE: necessary to retrieve SSID of connected WiFi
3030
* INTERNET: only necessary if your MQTT server is not running locally
31-
* FOREGROUND_SERVICE: necessary to send notifications
3231
* RECEIVE_BOOT_COMPLETED: necessary to start service on start-up
3332
* REQUEST_IGNORE_BATTERY_OPTIMIZATIONS: on Android 6+, necessary to request disabling battery optimization
3433
* WRITE_EXTERNAL_STORAGE: only necessary if you want to export log files in Android 4.0 - 4.3

app/build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import org.apache.tools.ant.taskdefs.condition.Os
22

33
plugins {
4+
id 'com.github.triplet.play' version '2.4.2'
45
id 'com.jaredsburrows.license' version '0.8.42'
5-
id 'pl.allegro.tech.build.axion-release' version '1.10.2'
66
id 'org.ajoberstar.grgit' version '4.0.0-rc.1'
7+
id 'pl.allegro.tech.build.axion-release' version '1.10.2'
78
}
89

910
apply plugin: 'com.android.application'
@@ -79,6 +80,11 @@ task generateLicenseFile(type: Exec) {
7980
}
8081
}
8182

83+
84+
play {
85+
serviceAccountCredentials = file("../../google-key.json")
86+
}
87+
8288
dependencies {
8389
implementation 'androidx.appcompat:appcompat:1.1.0'
8490
implementation 'androidx.preference:preference:1.1.0'

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<uses-permission-sdk-23 android:name="android.permission.ACCESS_COARSE_LOCATION" />
88
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
99
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
10-
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
1110
<uses-permission android:name="android.permission.INTERNET" />
1211
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
1312
<uses-permission-sdk-23 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />

app/src/main/ic_launcher-web.png

-41.2 KB
Binary file not shown.

app/src/main/java/org/ostrya/presencepublisher/receiver/SystemBroadcastReceiver.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ public void onReceive(final Context context, final Intent intent) {
2626
NetworkInfo networkInfo = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
2727
boolean useMobile = sharedPreferences.getBoolean(SEND_OFFLINE_MESSAGE, false)
2828
&& sharedPreferences.getBoolean(SEND_VIA_MOBILE_NETWORK, false);
29-
if (networkInfo.isConnected() && (networkInfo.getType() == ConnectivityManager.TYPE_WIFI || useMobile)) {
29+
if (networkInfo.isConnected() && (networkInfo.getType() == ConnectivityManager.TYPE_WIFI
30+
|| networkInfo.getType() == ConnectivityManager.TYPE_VPN
31+
|| networkInfo.getType() == ConnectivityManager.TYPE_ETHERNET || useMobile)) {
3032
HyperLog.i(TAG, "Reacting to network change");
3133
new Publisher(context).scheduleNow();
3234
}

app/src/main/play/contact-email.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ostrya@mailbox.org

app/src/main/play/contact-website.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/ostrya/PresencePublisher
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
en-US
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
This app regularly publishes to a configurable MQTT topic whenever
2+
connected to a given WiFi network. It can be used to integrate the presence
3+
of your phone in home automation.
4+
5+
The app uses the built-in Android alarm manager, so notifications are sent
6+
even if the phone is in stand-by. In addition to regularly scheduled checks,
7+
the app also reacts to changes in the network connection.
8+
9+
<b>Permissions</b>
10+
11+
• ACCESS_COARSE_LOCATION: on Android 9+, necessary to retrieve SSID of connected WiFi (you do not need to grant the permission in Android 6.0 - 8.1 for the app to work)
12+
• ACCESS_NETWORK_STATE: necessary to register network change listener
13+
• ACCESS_WIFI_STATE: necessary to retrieve SSID of connected WiFi
14+
• INTERNET: only necessary if your MQTT server is not running locally
15+
• RECEIVE_BOOT_COMPLETED: necessary to start service on start-up
16+
• REQUEST_IGNORE_BATTERY_OPTIMIZATIONS: on Android 6+, necessary to request disabling battery optimization
17+
• WRITE_EXTERNAL_STORAGE: only necessary if you want to export log files in Android 4.0 - 4.3
Loading
Loading
Loading
Loading
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Regularly publish to an MQTT topic
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Presence Publisher
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Minor bugfix related to handling of VPN connections.

app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
33
<background android:drawable="@drawable/ic_launcher_background" />
44
<foreground android:drawable="@drawable/ic_launcher_foreground" />
5-
</adaptive-icon>
5+
</adaptive-icon>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3-
<background android:drawable="@drawable/ic_launcher_background" />
4-
<foreground android:drawable="@drawable/ic_launcher_foreground" />
5-
</adaptive-icon>
3+
<background android:drawable="@drawable/ic_launcher_background"/>
4+
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
5+
</adaptive-icon>
518 Bytes
Loading
535 Bytes
Loading
318 Bytes
Loading
323 Bytes
Loading
696 Bytes
Loading
787 Bytes
Loading
991 Bytes
Loading
Loading
1.32 KB
Loading
Loading

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-all.zip

0 commit comments

Comments
 (0)