Skip to content

Commit 1721082

Browse files
author
Pavel Grafov
committed
Add TAG_CRYPTO_SELF_TEST_COMPLETED event tag.
Also s/process log/security log/g for consistency. Test:manual Bug:70886042 Change-Id: I9424890d21f44301f5e7d308c65718b1fd5f8d9d
1 parent bd49f01 commit 1721082

File tree

4 files changed

+43
-38
lines changed

4 files changed

+43
-38
lines changed

app/src/main/java/com/afwsamples/testdpc/policy/PolicyManagementFragment.java

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public class PolicyManagementFragment extends BaseSearchablePolicyPreferenceFrag
263263
private static final String DISABLE_SCREEN_CAPTURE_KEY = "disable_screen_capture";
264264
private static final String DISABLE_STATUS_BAR = "disable_status_bar";
265265
private static final String ENABLE_BACKUP_SERVICE = "enable_backup_service";
266-
private static final String ENABLE_PROCESS_LOGGING = "enable_process_logging";
266+
private static final String ENABLE_SECURITY_LOGGING = "enable_security_logging";
267267
private static final String ENABLE_NETWORK_LOGGING = "enable_network_logging";
268268
private static final String ENABLE_SYSTEM_APPS_BY_INTENT_KEY = "enable_system_apps_by_intent";
269269
private static final String ENABLE_SYSTEM_APPS_BY_PACKAGE_NAME_KEY
@@ -314,7 +314,7 @@ public class PolicyManagementFragment extends BaseSearchablePolicyPreferenceFrag
314314
private static final String EPHEMERAL_USER_KEY = "ephemeral_user";
315315
private static final String REQUEST_BUGREPORT_KEY = "request_bugreport";
316316
private static final String REQUEST_NETWORK_LOGS = "request_network_logs";
317-
private static final String REQUEST_PROCESS_LOGS = "request_process_logs";
317+
private static final String REQUEST_SECURITY_LOGS = "request_security_logs";
318318
private static final String RESET_PASSWORD_KEY = "reset_password";
319319
private static final String LOCK_NOW_KEY = "lock_now";
320320
private static final String SET_ACCESSIBILITY_SERVICES_KEY = "set_accessibility_services";
@@ -410,7 +410,7 @@ public class PolicyManagementFragment extends BaseSearchablePolicyPreferenceFrag
410410

411411
private SwitchPreference mEnableBackupServicePreference;
412412
private SwitchPreference mMandatoryBackupsPreference;
413-
private SwitchPreference mEnableProcessLoggingPreference;
413+
private SwitchPreference mEnableSecurityLoggingPreference;
414414
private SwitchPreference mEnableNetworkLoggingPreference;
415415
private SwitchPreference mSetAutoTimeRequiredPreference;
416416
private DpcPreference mLogoutUserPreference;
@@ -421,7 +421,7 @@ public class PolicyManagementFragment extends BaseSearchablePolicyPreferenceFrag
421421
private Preference mAffiliatedUserPreference;
422422
private Preference mEphemeralUserPreference;
423423
private DpcPreference mRequestNetworkLogsPreference;
424-
private DpcPreference mRequestProcessLogsPreference;
424+
private DpcPreference mRequestSecurityLogsPreference;
425425
private Preference mSetDeviceOrganizationNamePreference;
426426

427427
private DpcSwitchPreference mAutoBrightnessPreference;
@@ -530,14 +530,15 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
530530
mMandatoryBackupsPreference = (SwitchPreference) findPreference(MANDATORY_BACKUPS);
531531
mMandatoryBackupsPreference.setOnPreferenceChangeListener(this);
532532
findPreference(REQUEST_BUGREPORT_KEY).setOnPreferenceClickListener(this);
533-
mEnableProcessLoggingPreference = (SwitchPreference) findPreference(ENABLE_PROCESS_LOGGING);
534-
mEnableProcessLoggingPreference.setOnPreferenceChangeListener(this);
535-
mRequestProcessLogsPreference = (DpcPreference) findPreference(REQUEST_PROCESS_LOGS);
536-
mRequestProcessLogsPreference.setOnPreferenceClickListener(this);
537-
mRequestProcessLogsPreference.setCustomConstraint(
533+
mEnableSecurityLoggingPreference =
534+
(SwitchPreference) findPreference(ENABLE_SECURITY_LOGGING);
535+
mEnableSecurityLoggingPreference.setOnPreferenceChangeListener(this);
536+
mRequestSecurityLogsPreference = (DpcPreference) findPreference(REQUEST_SECURITY_LOGS);
537+
mRequestSecurityLogsPreference.setOnPreferenceClickListener(this);
538+
mRequestSecurityLogsPreference.setCustomConstraint(
538539
() -> isSecurityLoggingEnabled()
539540
? NO_CUSTOM_CONSTRIANT
540-
: R.string.requires_process_logs);
541+
: R.string.requires_security_logs);
541542
mEnableNetworkLoggingPreference = (SwitchPreference) findPreference(ENABLE_NETWORK_LOGGING);
542543
mEnableNetworkLoggingPreference.setOnPreferenceChangeListener(this);
543544
mRequestNetworkLogsPreference = (DpcPreference) findPreference(REQUEST_NETWORK_LOGS);
@@ -642,7 +643,7 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
642643
reloadMuteAudioUi();
643644
reloadEnableBackupServiceUi();
644645
reloadMandatoryBackupsUi();
645-
reloadEnableProcessLoggingUi();
646+
reloadEnableSecurityLoggingUi();
646647
reloadEnableNetworkLoggingUi();
647648
reloadSetAutoTimeRequiredUi();
648649
reloadEnableLogoutUi();
@@ -760,8 +761,8 @@ public void onPositiveButtonClicked(String[] lockTaskArray) {
760761
case REQUEST_NETWORK_LOGS:
761762
showFragment(new NetworkLogsFragment());
762763
return true;
763-
case REQUEST_PROCESS_LOGS:
764-
showFragment(new ProcessLogsFragment());
764+
case REQUEST_SECURITY_LOGS:
765+
showFragment(new SecurityLogsFragment());
765766
return true;
766767
case SET_ACCESSIBILITY_SERVICES_KEY:
767768
// Avoid starting the same task twice.
@@ -1155,9 +1156,9 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
11551156
setupMandatoryBackups(null);
11561157
return true;
11571158
}
1158-
case ENABLE_PROCESS_LOGGING:
1159+
case ENABLE_SECURITY_LOGGING:
11591160
setSecurityLoggingEnabled((Boolean) newValue);
1160-
reloadEnableProcessLoggingUi();
1161+
reloadEnableSecurityLoggingUi();
11611162
return true;
11621163
case ENABLE_NETWORK_LOGGING:
11631164
mDevicePolicyManager.setNetworkLoggingEnabled(mAdminComponentName,
@@ -2102,12 +2103,12 @@ private void reloadEnableNetworkLoggingUi() {
21022103
}
21032104

21042105
@TargetApi(Build.VERSION_CODES.N)
2105-
private void reloadEnableProcessLoggingUi() {
2106-
if (mEnableProcessLoggingPreference.isEnabled()) {
2107-
boolean isProcessLoggingEnabled = mDevicePolicyManager.isSecurityLoggingEnabled(
2108-
mAdminComponentName);
2109-
mEnableProcessLoggingPreference.setChecked(isProcessLoggingEnabled);
2110-
mRequestProcessLogsPreference.refreshEnabledState();
2106+
private void reloadEnableSecurityLoggingUi() {
2107+
if (mEnableSecurityLoggingPreference.isEnabled()) {
2108+
boolean securityLoggingEnabled =
2109+
mDevicePolicyManager.isSecurityLoggingEnabled(mAdminComponentName);
2110+
mEnableSecurityLoggingPreference.setChecked(securityLoggingEnabled);
2111+
mRequestSecurityLogsPreference.refreshEnabledState();
21112112
}
21122113
}
21132114

app/src/main/java/com/afwsamples/testdpc/policy/ProcessLogsFragment.java renamed to app/src/main/java/com/afwsamples/testdpc/policy/SecurityLogsFragment.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import java.util.concurrent.TimeUnit;
3939

4040
@TargetApi(Build.VERSION_CODES.N)
41-
public class ProcessLogsFragment extends ListFragment {
41+
public class SecurityLogsFragment extends ListFragment {
4242

4343
private static final String TAG = "ProcessLogsFragment";
4444

@@ -65,6 +65,7 @@ public class ProcessLogsFragment extends ListFragment {
6565
private static final int TAG_USER_RESTRICTION_REMOVED = 210028;
6666
private static final int TAG_CERT_AUTHORITY_INSTALLED = 210029;
6767
private static final int TAG_CERT_AUTHORITY_REMOVED = 210030;
68+
private static final int TAG_CRYPTO_SELF_TEST_COMPLETED = 210031;
6869

6970
private ArrayList<String> mLogs = new ArrayList<String>();
7071
private ArrayAdapter<String> mAdapter;
@@ -86,19 +87,19 @@ public void onCreate(Bundle savedInstanceState) {
8687
@Override
8788
public void onActivityCreated(Bundle savedInstanceState) {
8889
super.onActivityCreated(savedInstanceState);
89-
mAdapter.add(getString(R.string.process_logs_retrieved_message, new Date().toString()));
90+
mAdapter.add(getString(R.string.security_logs_retrieved_message, new Date().toString()));
9091
try {
9192
processEvents(mDevicePolicyManager.retrieveSecurityLogs(mAdminName));
9293
} catch (SecurityException e) {
9394
Log.e(TAG, "Exception thrown when trying to retrieve security logs", e);
94-
mAdapter.add(getString(R.string.exception_retrieving_process_logs));
95+
mAdapter.add(getString(R.string.exception_retrieving_security_logs));
9596
}
9697
}
9798

9899
private void processEvents(List<SecurityEvent> logs) {
99100
if (logs == null) {
100101
Log.w(TAG, "logs == null, are you polling too early?");
101-
mAdapter.add(getString(R.string.failed_to_retrieve_process_logs));
102+
mAdapter.add(getString(R.string.failed_to_retrieve_security_logs));
102103
} else {
103104
Log.d(TAG, "Incoming logs size: " + logs.size());
104105
for (SecurityEvent event : logs) {
@@ -119,13 +120,13 @@ private void processEvents(List<SecurityEvent> logs) {
119120
printData(sb, event.getData());
120121
mAdapter.add(sb.toString());
121122
}
122-
ListView listView = ProcessLogsFragment.this.getListView();
123+
ListView listView = SecurityLogsFragment.this.getListView();
123124
listView.setSelection(listView.getCount() - 1);
124125
}
125126
}
126127

127128
private String getStringEventTagFromId(int eventId) {
128-
String eventTag;
129+
final String eventTag;
129130
switch (eventId) {
130131
case SecurityLog.TAG_ADB_SHELL_INTERACTIVE:
131132
eventTag = "ADB_SHELL_INTERACTIVE";
@@ -217,6 +218,9 @@ private String getStringEventTagFromId(int eventId) {
217218
case TAG_CERT_AUTHORITY_REMOVED:
218219
eventTag = "CERT_AUTHORITY_REMOVED";
219220
break;
221+
case TAG_CRYPTO_SELF_TEST_COMPLETED:
222+
eventTag = "CRYPTO_SELF_TEST_COMPLETED";
223+
break;
220224
default:
221225
eventTag = "UNKNOWN(" + eventId + ")";
222226
}

app/src/main/res/values/strings.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
<string name="not_for_parent_profile">Not applicable to parent profile</string>
110110
<string name="user_restricted">Disallowed by user restriction</string>
111111
<string name="requires_network_logs">Requires network logging to be enabled</string>
112-
<string name="requires_process_logs">Requires process logging to be enabled</string>
112+
<string name="requires_security_logs">Requires security logging to be enabled</string>
113113
<string name="not_for_password_quality">Not applicable to current password quality</string>
114114

115115
<string name="this_is_a_device_owner">This app is the device owner.</string>
@@ -549,12 +549,12 @@
549549
<string name="mandatory_backups">Make backups mandatory</string>
550550
<string name="mandatory_backup_account">Select mandatory backup account</string>
551551

552-
<!-- Enterprise process logging -->
553-
<string name="enable_process_logging">Enable process logging</string>
554-
<string name="request_process_logs">Request process logs</string>
555-
<string name="failed_to_retrieve_process_logs">Failed to retrieve process logs, they were probably accessed less than 2 hours ago</string>
556-
<string name="exception_retrieving_process_logs">Not allowed to retrieve process logs, SecurityException thrown</string>
557-
<string name="process_logs_retrieved_message">---- Logs retrieved %s ----</string>
552+
<!-- Enterprise security logging -->
553+
<string name="enable_security_logging">Enable security logging</string>
554+
<string name="request_security_logs">Request security logs</string>
555+
<string name="failed_to_retrieve_security_logs">Failed to retrieve security logs, they were probably accessed less than 2 hours ago</string>
556+
<string name="exception_retrieving_security_logs">Not allowed to retrieve security logs, SecurityException thrown</string>
557+
<string name="security_logs_retrieved_message">---- Logs retrieved %s ----</string>
558558
<string name="on_security_logs_available">Test DPC: Security logs ready to be retrieved</string>
559559

560560
<!-- Network logging -->

app/src/main/res/xml/device_policy_header.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,13 +573,13 @@
573573
testdpc:admin="deviceOwner"
574574
testdpc:minSdkVersion="L" />
575575
<com.afwsamples.testdpc.common.preference.DpcSwitchPreference
576-
android:key="enable_process_logging"
577-
android:title="@string/enable_process_logging"
576+
android:key="enable_security_logging"
577+
android:title="@string/enable_security_logging"
578578
testdpc:admin="deviceOwner"
579579
testdpc:minSdkVersion="N" />
580580
<com.afwsamples.testdpc.common.preference.DpcPreference
581-
android:key="request_process_logs"
582-
android:title="@string/request_process_logs"
581+
android:key="request_security_logs"
582+
android:title="@string/request_security_logs"
583583
testdpc:admin="deviceOwner"
584584
testdpc:minSdkVersion="N" />
585585
<com.afwsamples.testdpc.common.preference.DpcSwitchPreference

0 commit comments

Comments
 (0)