70
70
import com .afwsamples .testdpc .DeviceAdminReceiver ;
71
71
import com .afwsamples .testdpc .R ;
72
72
import com .afwsamples .testdpc .common .AppInfoArrayAdapter ;
73
+ import com .afwsamples .testdpc .common .BaseSearchablePolicyPreferenceFragment ;
73
74
import com .afwsamples .testdpc .common .CertificateUtil ;
74
75
import com .afwsamples .testdpc .common .MediaDisplayFragment ;
75
- import com .afwsamples .testdpc .common .BaseSearchablePolicyPreferenceFragment ;
76
76
import com .afwsamples .testdpc .common .Util ;
77
77
import com .afwsamples .testdpc .policy .blockuninstallation .BlockUninstallationInfoArrayAdapter ;
78
78
import com .afwsamples .testdpc .policy .certificate .DelegatedCertInstallerFragment ;
@@ -1097,8 +1097,12 @@ private void updateStayOnWhilePluggedInPreference() {
1097
1097
* </p>
1098
1098
*/
1099
1099
public void updateInstallNonMarketAppsPreference () {
1100
- mInstallNonMarketAppsPreference .setEnabled (
1101
- mUserManager .hasUserRestriction (DISALLOW_INSTALL_UNKNOWN_SOURCES ) ? false : true );
1100
+ if (mUserManager .hasUserRestriction (DISALLOW_INSTALL_UNKNOWN_SOURCES )) {
1101
+ Util .disablePreference (mInstallNonMarketAppsPreference , R .string .user_restricted );
1102
+ } else {
1103
+ mInstallNonMarketAppsPreference .setEnabled (true );
1104
+ mInstallNonMarketAppsPreference .setSummary (null );
1105
+ }
1102
1106
int isInstallNonMarketAppsAllowed = Settings .Secure .getInt (
1103
1107
getActivity ().getContentResolver (), Settings .Secure .INSTALL_NON_MARKET_APPS , 0 );
1104
1108
mInstallNonMarketAppsPreference .setChecked (
@@ -1116,11 +1120,11 @@ private void disableIncompatibleManagementOptionsInCurrentProfile() {
1116
1120
if (isProfileOwner ) {
1117
1121
// Some of the management options can only be applied in a primary profile.
1118
1122
for (String preference : PRIMARY_USER_ONLY_PREFERENCES ) {
1119
- findPreference (preference ). setEnabled ( false );
1123
+ Util . disablePreference ( findPreference (preference ), R . string . primary_user_only );
1120
1124
}
1121
1125
if (Util .isBeforeN ()) {
1122
1126
for (String preference : PROFILE_OWNER_NYC_PLUS_PREFERENCES ) {
1123
- findPreference (preference ). setEnabled ( false );
1127
+ Util . disablePreference ( findPreference (preference ), R . string . requires_android_n );
1124
1128
}
1125
1129
}
1126
1130
deviceOwnerStatusStringId = R .string .this_is_a_profile_owner ;
@@ -1130,26 +1134,27 @@ private void disableIncompatibleManagementOptionsInCurrentProfile() {
1130
1134
}
1131
1135
findPreference (DEVICE_OWNER_STATUS_KEY ).setSummary (deviceOwnerStatusStringId );
1132
1136
if (!isDeviceOwner ) {
1133
- findPreference (WIFI_CONFIG_LOCKDOWN_ENABLE_KEY ).setEnabled (false );
1137
+ Util .disablePreference (findPreference (WIFI_CONFIG_LOCKDOWN_ENABLE_KEY ),
1138
+ R .string .device_owner_only );
1134
1139
}
1135
1140
// Disable managed profile specific options if we are not running in managed profile.
1136
1141
if (!Util .isManagedProfile (getActivity (), mAdminComponentName )) {
1137
1142
for (String managedProfileSpecificOption : MANAGED_PROFILE_SPECIFIC_OPTIONS ) {
1138
- findPreference (managedProfileSpecificOption ).setEnabled (false );
1143
+ Util .disablePreference (findPreference (managedProfileSpecificOption ),
1144
+ R .string .managed_profile_only );
1139
1145
}
1140
1146
}
1141
1147
}
1142
1148
1143
1149
private void disableIncompatibleManagementOptionsByApiLevel () {
1144
1150
if (Util .isBeforeM ()) {
1145
- // The following options depend on MNC APIs.
1146
1151
for (String preference : MNC_PLUS_PREFERENCES ) {
1147
- findPreference (preference ). setEnabled ( false );
1152
+ Util . disablePreference ( findPreference (preference ), R . string . requires_android_m );
1148
1153
}
1149
1154
}
1150
1155
if (Util .isBeforeN ()) {
1151
1156
for (String preference : NYC_PLUS_PREFERENCES ) {
1152
- findPreference (preference ). setEnabled ( false );
1157
+ Util . disablePreference ( findPreference (preference ), R . string . requires_android_n );
1153
1158
}
1154
1159
}
1155
1160
}
@@ -1441,7 +1446,13 @@ private void reloadEnableProcessLoggingUi() {
1441
1446
boolean isProcessLoggingEnabled = mDevicePolicyManager .isSecurityLoggingEnabled (
1442
1447
mAdminComponentName );
1443
1448
mEnableProcessLoggingPreference .setChecked (isProcessLoggingEnabled );
1444
- findPreference (REQUEST_PROCESS_LOGS ).setEnabled (isProcessLoggingEnabled );
1449
+ Preference requestLogsPreference = findPreference ((REQUEST_PROCESS_LOGS ));
1450
+ if (isProcessLoggingEnabled ) {
1451
+ requestLogsPreference .setEnabled (true );
1452
+ requestLogsPreference .setSummary (null );
1453
+ } else {
1454
+ Util .disablePreference (requestLogsPreference , R .string .requires_process_logs );
1455
+ }
1445
1456
}
1446
1457
}
1447
1458
0 commit comments