Skip to content

Commit

Permalink
fix start on boot to be more reliable
Browse files Browse the repository at this point in the history
- no need to check if network is available
- no need to check if first time is complete, as on boot won't be sent unless user has run the app once
  • Loading branch information
n8fr8 committed Apr 7, 2023
1 parent a74d551 commit bcc8446
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
7 changes: 2 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,11 @@
android:name=".core.OnBootReceiver"
android:enabled="true"
android:exported="true"
android:directBootAware="true">

android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
android:directBootAware="false">
<intent-filter>
<action android:name="android.net.wifi.STATE_CHANGE" />
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.REBOOT" />
</intent-filter>
</receiver>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import org.torproject.android.service.util.Prefs

class OnBootReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (!Prefs.onboardPending() && Prefs.startOnBoot() && !sReceivedBoot) {
if (isNetworkAvailable(context)) {
if (Prefs.startOnBoot() && !sReceivedBoot) {
// if (isNetworkAvailable(context)) {
startService(OrbotConstants.ACTION_START, context)
sReceivedBoot = true
}
// }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,4 @@ public static boolean isPowerUserMode() {
return prefs.getBoolean(PREF_POWER_USER_MODE, false);
}

public static boolean onboardPending() {
return prefs.getBoolean("connect_first_time", true);
}
}

0 comments on commit bcc8446

Please sign in to comment.