Commits

Joman Chu  committed 57fb467

Update to use custom policy handles method

  • Participants
  • Parent commits b11ef17

Comments (0)

Files changed (2)

File 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();

File 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();