Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
<string name="ng_device_admin">Device Administration</string>
<string name="admin_enabled">The device admin has been enabled</string>
<string name="admin_disabled">The device admin has been disabled</string>
<string name="ng_admin_permission_message">NodeGrid will be a device administrator to fullfil features of this application.</string>

</resources>
6 changes: 3 additions & 3 deletions res/xml/ng_device_admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
the device administrator, as parsed by the DeviceAdminInfo class -->
<device-admin xmlns:android="http://schemas.android.com/apk/res/android">
<uses-policies>
<limit-password />
<!-- limit-password />
<watch-login />
<reset-password />
<force-lock />
<wipe-data />
<expire-password />
<encrypted-storage />
<disable-camera />
<disable-camera /-->
<force-lock />
</uses-policies>
</device-admin>
21 changes: 20 additions & 1 deletion src/com/nodegrid/android/manager/Main.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
package com.nodegrid.android.manager;

import android.support.v7.app.ActionBarActivity;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;

public class Main extends ActionBarActivity {

private static final int REQUEST_CODE_ENABLE_ADMIN = 1;

DevicePolicyManager mDPM;
ComponentName mDeviceAdmin;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

//The DeviceAdminReceiver should receive the intent below to administer the device.
mDeviceAdmin = new ComponentName(this, PolicyHandler.NGDeviceAdminReceiver.class);

//this intent prompts the user to allow the app to administer the device
//the user has the choice to accept or decline.
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mDeviceAdmin);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, R.string.ng_admin_permission_message);
startActivityForResult(intent, REQUEST_CODE_ENABLE_ADMIN);

}

@Override
Expand Down