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>
This commit is contained in:
Samuel Holland 2017-07-30 02:01:38 -05:00
parent d8a5ec3f19
commit 773190f57d
2 changed files with 24 additions and 1 deletions

View File

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <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 <application
android:allowBackup="false" android:allowBackup="false"
@ -17,6 +20,12 @@
</intent-filter> </intent-filter>
</activity> </activity>
<receiver android:name=".BootCompletedReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service <service
android:name=".ProfileService" android:name=".ProfileService"
android:exported="false" /> android:exported="false" />

View File

@ -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);
}
}