summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Pavel Grafov <pgrafov@google.com> 2021-06-16 19:23:51 +0100
committer Pavel Grafov <pgrafov@google.com> 2021-06-16 19:30:48 +0100
commit25f228087f4ba1411de7064b8b3462663a59c314 (patch)
tree88cceeaecbf7367effd02c5968e71dfdd634b670
parenta2d7f961542c212a62e4dadfa096ca80906ba482 (diff)
More debug for security loggin broadcast
Bug: 185004808 Test: atest MixedDeviceOwnerTest#testSecurityLoggingDelegate Change-Id: I1a56a6384f5cb4e2dcab633f7e3819e4713a4dff
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java2
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/SecurityLogMonitor.java11
2 files changed, 11 insertions, 2 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index fa24e5238820..c374f84781dd 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -8027,6 +8027,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
inForeground = true;
receiverComponent = resolveDelegateReceiver(
DELEGATION_SECURITY_LOGGING, action, userId);
+ // STOPSHIP(b/185004808): remove excessive log.
+ Slogf.d(LOG_TAG, "Delegate for security logs broadcast: " + receiverComponent);
}
if (receiverComponent == null) {
receiverComponent = getOwnerComponent(userId);
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/SecurityLogMonitor.java b/services/devicepolicy/java/com/android/server/devicepolicy/SecurityLogMonitor.java
index c29de905d370..0741c81bb528 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/SecurityLogMonitor.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/SecurityLogMonitor.java
@@ -64,7 +64,7 @@ class SecurityLogMonitor implements Runnable {
mLastForceNanos = System.nanoTime();
}
- private static final boolean DEBUG = false; // STOPSHIP if true.
+ private static final boolean DEBUG = true; // STOPSHIP if true.
private static final String TAG = "SecurityLogMonitor";
/**
* Each log entry can hold up to 4K bytes (but as of {@link android.os.Build.VERSION_CODES#N}
@@ -427,7 +427,7 @@ class SecurityLogMonitor implements Runnable {
while (!Thread.currentThread().isInterrupted()) {
try {
final boolean force = mForceSemaphore.tryAcquire(POLLING_INTERVAL_MS, MILLISECONDS);
-
+ if (DEBUG) Slog.d(TAG, "Retrieving next batch, force=" + force);
getNextBatch(newLogs);
mLock.lockInterruptibly();
@@ -469,6 +469,11 @@ class SecurityLogMonitor implements Runnable {
return;
}
final int logSize = mPendingLogs.size();
+ if (DEBUG) {
+ Slog.d(TAG, String.format(
+ "notifyDeviceOwnerOrProfileOwnerIfNeeded, size: %d now: %d next: %d",
+ logSize, SystemClock.elapsedRealtime(), mNextAllowedRetrievalTimeMillis));
+ }
if (logSize >= BUFFER_ENTRIES_NOTIFICATION_LEVEL || (force && logSize > 0)) {
// Allow DO to retrieve logs if too many pending logs or if forced.
if (!mAllowedToRetrieve) {
@@ -507,6 +512,7 @@ class SecurityLogMonitor implements Runnable {
synchronized (mForceSemaphore) {
final long toWaitNanos = mLastForceNanos + FORCE_FETCH_THROTTLE_NS - nowNanos;
if (toWaitNanos > 0) {
+ if (DEBUG) Slog.d(TAG, "Forcing security logs throttled");
return NANOSECONDS.toMillis(toWaitNanos) + 1; // Round up.
}
mLastForceNanos = nowNanos;
@@ -515,6 +521,7 @@ class SecurityLogMonitor implements Runnable {
if (mForceSemaphore.availablePermits() == 0) {
mForceSemaphore.release();
}
+ if (DEBUG) Slog.d(TAG, "Forcing security logs semaphore released");
return 0;
}
}