|
41 | 41 | import android.content.Context;
|
42 | 42 | import android.content.DialogInterface;
|
43 | 43 | import android.content.Intent;
|
| 44 | +import android.content.SharedPreferences; |
44 | 45 | import android.content.pm.ApplicationInfo;
|
45 | 46 | import android.content.pm.PackageManager;
|
46 | 47 | import android.content.pm.ResolveInfo;
|
|
66 | 67 | import android.support.v7.preference.EditTextPreference;
|
67 | 68 | import android.support.v7.preference.ListPreference;
|
68 | 69 | import android.support.v7.preference.Preference;
|
| 70 | +import android.support.v7.preference.PreferenceManager; |
69 | 71 | import android.telephony.TelephonyManager;
|
70 | 72 | import android.text.InputType;
|
71 | 73 | import android.text.TextUtils;
|
@@ -270,6 +272,7 @@ public class PolicyManagementFragment extends BaseSearchablePolicyPreferenceFrag
|
270 | 272 | private static final String DISABLE_SCREEN_CAPTURE_KEY = "disable_screen_capture";
|
271 | 273 | private static final String DISABLE_STATUS_BAR = "disable_status_bar";
|
272 | 274 | private static final String ENABLE_BACKUP_SERVICE = "enable_backup_service";
|
| 275 | + private static final String APP_FEEDBACK_NOTIFICATIONS = "app_feedback_notifications"; |
273 | 276 | private static final String ENABLE_SECURITY_LOGGING = "enable_security_logging";
|
274 | 277 | private static final String ENABLE_NETWORK_LOGGING = "enable_network_logging";
|
275 | 278 | private static final String ENABLE_SYSTEM_APPS_BY_INTENT_KEY = "enable_system_apps_by_intent";
|
@@ -458,6 +461,8 @@ public class PolicyManagementFragment extends BaseSearchablePolicyPreferenceFrag
|
458 | 461 |
|
459 | 462 | private DpcSwitchPreference mAutoBrightnessPreference;
|
460 | 463 |
|
| 464 | + private DpcSwitchPreference mEnableAppFeedbackNotificationsPreference; |
| 465 | + |
461 | 466 | private GetAccessibilityServicesTask mGetAccessibilityServicesTask = null;
|
462 | 467 | private GetInputMethodsTask mGetInputMethodsTask = null;
|
463 | 468 | private GetNotificationListenersTask mGetNotificationListenersTask = null;
|
@@ -600,6 +605,9 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
600 | 605 | findPreference(REMOVE_ACCOUNT_KEY).setOnPreferenceClickListener(this);
|
601 | 606 | findPreference(BLOCK_UNINSTALLATION_BY_PKG_KEY).setOnPreferenceClickListener(this);
|
602 | 607 | findPreference(BLOCK_UNINSTALLATION_LIST_KEY).setOnPreferenceClickListener(this);
|
| 608 | + findPreference(APP_FEEDBACK_NOTIFICATIONS).setOnPreferenceChangeListener(this); |
| 609 | + mEnableAppFeedbackNotificationsPreference = |
| 610 | + (DpcSwitchPreference) findPreference(APP_FEEDBACK_NOTIFICATIONS); |
603 | 611 | findPreference(ENABLE_SYSTEM_APPS_KEY).setOnPreferenceClickListener(this);
|
604 | 612 | findPreference(ENABLE_SYSTEM_APPS_BY_PACKAGE_NAME_KEY).setOnPreferenceClickListener(this);
|
605 | 613 | findPreference(ENABLE_SYSTEM_APPS_BY_INTENT_KEY).setOnPreferenceClickListener(this);
|
@@ -687,6 +695,7 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
687 | 695 | constrainSpecialCasePreferences();
|
688 | 696 |
|
689 | 697 | maybeDisableLockTaskPreferences();
|
| 698 | + loadAppFeedbackNotifications(); |
690 | 699 | loadAppStatus();
|
691 | 700 | loadSecurityPatch();
|
692 | 701 | loadIsEphemeralUserUi();
|
@@ -1331,6 +1340,14 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
|
1331 | 1340 | Integer.parseInt((String) newValue));
|
1332 | 1341 | startActivity(intent);
|
1333 | 1342 | return true;
|
| 1343 | + case APP_FEEDBACK_NOTIFICATIONS: |
| 1344 | + SharedPreferences.Editor editor = |
| 1345 | + PreferenceManager.getDefaultSharedPreferences(getContext()).edit(); |
| 1346 | + editor.putBoolean( |
| 1347 | + getString( |
| 1348 | + R.string.app_feedback_notifications), newValue.equals(true)); |
| 1349 | + editor.commit(); |
| 1350 | + return true; |
1334 | 1351 | }
|
1335 | 1352 | return false;
|
1336 | 1353 | }
|
@@ -2085,6 +2102,13 @@ public void onClick(DialogInterface dialogInterface, int i) {
|
2085 | 2102 | .show();
|
2086 | 2103 | }
|
2087 | 2104 |
|
| 2105 | + @TargetApi(Build.VERSION_CODES.M) |
| 2106 | + private void loadAppFeedbackNotifications() { |
| 2107 | + mEnableAppFeedbackNotificationsPreference.setChecked( |
| 2108 | + PreferenceManager.getDefaultSharedPreferences(getContext()) |
| 2109 | + .getBoolean(getString(R.string.app_feedback_notifications), false)); |
| 2110 | + } |
| 2111 | + |
2088 | 2112 | private void loadAppStatus() {
|
2089 | 2113 | final @StringRes int appStatusStringId;
|
2090 | 2114 | if (mDevicePolicyManager.isProfileOwnerApp(mPackageName)) {
|
|
0 commit comments