Parcourir la source

ProfileService: Add a listener to start it on boot

This will allow automatically starting profiles on boot.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
master
Samuel Holland il y a 7 ans
Parent
révision
773190f57d
2 fichiers modifiés avec 24 ajouts et 1 suppressions
  1. +10
    -1
      app/src/main/AndroidManifest.xml
  2. +14
    -0
      app/src/main/java/com/wireguard/android/BootCompletedReceiver.java

+ 10
- 1
app/src/main/AndroidManifest.xml Voir le fichier

@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wireguard.android">
package="com.wireguard.android"
android:installLocation="internalOnly">

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<application
android:allowBackup="false"
@@ -17,6 +20,12 @@
</intent-filter>
</activity>

<receiver android:name=".BootCompletedReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>

<service
android:name=".ProfileService"
android:exported="false" />


+ 14
- 0
app/src/main/java/com/wireguard/android/BootCompletedReceiver.java Voir le fichier

@@ -0,0 +1,14 @@
package com.wireguard.android;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class BootCompletedReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
Intent startServiceIntent = new Intent(context, ProfileService.class);
context.startService(startServiceIntent);
}
}

Chargement…
Annuler
Enregistrer