Anonymous avatar Anonymous committed 57fb467

Update to use custom policy handles method

Comments (0)

Files changed (2)

src/com/android/seandroid_admin/MMACFragment.java

 package com.android.seandroid_admin;
 
+import android.app.admin.DevicePolicyManager;
 import android.os.Bundle;
 import android.preference.CheckBoxPreference;
 import android.preference.Preference;
                     Log.v(TAG, "Reload of MMAC policy requested");
                     try {
                         byte[] policy = FileUtils.readFileToByteArray(mMMACpolicyFile);
-                        if (!mAdmin.mDPM.setMMACpolicy(mAdmin.mDeviceAdmin, policy)) {
+                        if (!mAdmin.mDPM.setCustomPolicyFile(mAdmin.mDeviceAdmin,
+                                DevicePolicyManager.MMAC_POLICY_FILE, policy)) {
                             Toast.makeText(mActivity, "Unable to set policy", Toast.LENGTH_SHORT).show();
                         } else {
                             Toast.makeText(mActivity, "Success", Toast.LENGTH_SHORT).show();
                 @Override
                 public boolean onPreferenceClick(Preference preference) {
                     Log.v(TAG, "Delete custom MMAC policy requested");
-                    if (!mAdmin.mDPM.setMMACpolicy(mAdmin.mDeviceAdmin, null)) {
+                    if (!mAdmin.mDPM.setCustomPolicyFile(mAdmin.mDeviceAdmin,
+                            DevicePolicyManager.MMAC_POLICY_FILE, null)) {
                         Toast.makeText(mActivity, "Unable to remove custom policy", Toast.LENGTH_SHORT).show();
                     } else {
                         Toast.makeText(mActivity, "Success", Toast.LENGTH_SHORT).show();

src/com/android/seandroid_admin/SELinuxEnforcingFragment.java

 package com.android.seandroid_admin;
 
+import android.app.admin.DevicePolicyManager;
 import android.os.Bundle;
 import android.os.SELinux;
 import android.preference.CheckBoxPreference;
                     Log.v(TAG, "Reload of SELinux policy requested");
                     try {
                         byte[] policy = FileUtils.readFileToByteArray(mSELinuxPolicyFile);
-                        if (!mAdmin.mDPM.setSELinuxPolicy(mAdmin.mDeviceAdmin, policy)) {
+                        if (!mAdmin.mDPM.setCustomPolicyFile(mAdmin.mDeviceAdmin,
+                                DevicePolicyManager.SELINUX_POLICY_FILE, policy)) {
                             Toast.makeText(mActivity, "Unable to set policy", Toast.LENGTH_SHORT).show();
                         } else {
                             Toast.makeText(mActivity, "Success", Toast.LENGTH_SHORT).show();
                 @Override
                 public boolean onPreferenceClick(Preference preference) {
                     Log.v(TAG, "Delete custom SELinux policy requested");
-                    if (!mAdmin.mDPM.setSELinuxPolicy(mAdmin.mDeviceAdmin, null)) {
+                    if (!mAdmin.mDPM.setCustomPolicyFile(mAdmin.mDeviceAdmin,
+                            DevicePolicyManager.SELINUX_POLICY_FILE, null)) {
                         Toast.makeText(mActivity, "Unable to remove custom policy", Toast.LENGTH_SHORT).show();
                     } else {
                         Toast.makeText(mActivity, "Success", Toast.LENGTH_SHORT).show();
                     Log.v(TAG, "Reload of Property Contexts policy requested");
                     try {
                         byte[] policy = FileUtils.readFileToByteArray(mPropertyContextsPolicyFile);
-                        if (!mAdmin.mDPM.setPropertyContexts(mAdmin.mDeviceAdmin, policy)) {
+                        if (!mAdmin.mDPM.setCustomPolicyFile(mAdmin.mDeviceAdmin,
+                                DevicePolicyManager.PROPERTY_CONTEXTS_FILE, policy)) {
                             Toast.makeText(mActivity, "Unable to set policy", Toast.LENGTH_SHORT).show();
                         } else {
                             Toast.makeText(mActivity, "Success", Toast.LENGTH_SHORT).show();
                 @Override
                 public boolean onPreferenceClick(Preference preference) {
                     Log.v(TAG, "Delete custom Property Contexts policy requested");
-                    if (!mAdmin.mDPM.setPropertyContexts(mAdmin.mDeviceAdmin, null)) {
+                    if (!mAdmin.mDPM.setCustomPolicyFile(mAdmin.mDeviceAdmin,
+                            DevicePolicyManager.PROPERTY_CONTEXTS_FILE, null)) {
                         Toast.makeText(mActivity, "Unable to remove custom policy", Toast.LENGTH_SHORT).show();
                     } else {
                         Toast.makeText(mActivity, "Success", Toast.LENGTH_SHORT).show();
                     Log.v(TAG, "Reload of File Contexts policy requested");
                     try {
                         byte[] policy = FileUtils.readFileToByteArray(mFileContextsPolicyFile);
-                        if (!mAdmin.mDPM.setFileContexts(mAdmin.mDeviceAdmin, policy)) {
+                        if (!mAdmin.mDPM.setCustomPolicyFile(mAdmin.mDeviceAdmin,
+                                DevicePolicyManager.FILE_CONTEXTS_FILE, policy)) {
                             Toast.makeText(mActivity, "Unable to set policy", Toast.LENGTH_SHORT).show();
                         } else {
                             Toast.makeText(mActivity, "Success", Toast.LENGTH_SHORT).show();
                 @Override
                 public boolean onPreferenceClick(Preference preference) {
                     Log.v(TAG, "Delete custom File Contexts policy requested");
-                    if (!mAdmin.mDPM.setFileContexts(mAdmin.mDeviceAdmin, null)) {
+                    if (!mAdmin.mDPM.setCustomPolicyFile(mAdmin.mDeviceAdmin,
+                            DevicePolicyManager.FILE_CONTEXTS_FILE, null)) {
                         Toast.makeText(mActivity, "Unable to remove custom policy", Toast.LENGTH_SHORT).show();
                     } else {
                         Toast.makeText(mActivity, "Success", Toast.LENGTH_SHORT).show();
                     Log.v(TAG, "Reload of SEApp Contexts policy requested");
                     try {
                         byte[] policy = FileUtils.readFileToByteArray(mSEAppContextsPolicyFile);
-                        if (!mAdmin.mDPM.setSEappContexts(mAdmin.mDeviceAdmin, policy)) {
+                        if (!mAdmin.mDPM.setCustomPolicyFile(mAdmin.mDeviceAdmin,
+                                DevicePolicyManager.SEAPP_CONTEXTS_FILE, policy)) {
                             Toast.makeText(mActivity, "Unable to set policy", Toast.LENGTH_SHORT).show();
                         } else {
                             Toast.makeText(mActivity, "Success", Toast.LENGTH_SHORT).show();
                 @Override
                 public boolean onPreferenceClick(Preference preference) {
                     Log.v(TAG, "Delete custom SEApp Contexts policy requested");
-                    if (!mAdmin.mDPM.setSEappContexts(mAdmin.mDeviceAdmin, null)) {
+                    if (!mAdmin.mDPM.setCustomPolicyFile(mAdmin.mDeviceAdmin,
+                            DevicePolicyManager.SEAPP_CONTEXTS_FILE, null)) {
                         Toast.makeText(mActivity, "Unable to remove custom policy", Toast.LENGTH_SHORT).show();
                     } else {
                         Toast.makeText(mActivity, "Success", Toast.LENGTH_SHORT).show();
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.