Device admin to prevent uninstall

Refs #92
This commit is contained in:
M66B 2015-11-09 11:18:37 +01:00
parent 79779dceae
commit c056d7db93
3 changed files with 56 additions and 0 deletions

View File

@ -59,5 +59,17 @@
android:name="android.appwidget.provider" android:name="android.appwidget.provider"
android:resource="@xml/widget" /> android:resource="@xml/widget" />
</receiver> </receiver>
<receiver
android:name=".DeviceAdministratorReceiver"
android:permission="android.permission.BIND_DEVICE_ADMIN">
<meta-data
android:name="android.app.device_admin"
android:resource="@xml/admin" />
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
<action android:name="android.app.action.ACTION_DEVICE_ADMIN_DISABLED" />
</intent-filter>
</receiver>
</application> </application>
</manifest> </manifest>

View File

@ -0,0 +1,41 @@
package eu.faircode.netguard;
/*
This file is part of NetGuard.
NetGuard is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
NetGuard is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with NetGuard. If not, see <http://www.gnu.org/licenses/>.
Copyright 2015 by Marcel Bokhorst (M66B)
*/
import android.app.admin.DeviceAdminReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class DeviceAdministratorReceiver extends DeviceAdminReceiver {
private static final String TAG = "NetGuard.Admin";
@Override
public void onEnabled(Context context, Intent intent) {
super.onEnabled(context, intent);
Log.i(TAG, "Device admin enabled");
}
@Override
public void onDisabled(Context context, Intent intent) {
super.onDisabled(context, intent);
Log.i(TAG, "Device admin disabled");
}
}

View File

@ -0,0 +1,3 @@
<device-admin xmlns:android="http://schemas.android.com/apk/res/android" >
<uses-policies />
</device-admin>