Merge "Security logging broadcast work profile" into sc-dev am: e9614f06c4
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14543674 Change-Id: I9b663a119266fe0c9b070d594cfcec380967fcab
This commit is contained in:
@@ -226,7 +226,7 @@ class SecurityLogMonitor implements Runnable {
|
|||||||
|
|
||||||
Slog.i(TAG, "Resumed.");
|
Slog.i(TAG, "Resumed.");
|
||||||
try {
|
try {
|
||||||
notifyDeviceOwnerIfNeeded(false /* force */);
|
notifyDeviceOwnerOrProfileOwnerIfNeeded(false /* force */);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Log.w(TAG, "Thread interrupted.", e);
|
Log.w(TAG, "Thread interrupted.", e);
|
||||||
}
|
}
|
||||||
@@ -439,7 +439,7 @@ class SecurityLogMonitor implements Runnable {
|
|||||||
|
|
||||||
saveLastEvents(newLogs);
|
saveLastEvents(newLogs);
|
||||||
newLogs.clear();
|
newLogs.clear();
|
||||||
notifyDeviceOwnerIfNeeded(force);
|
notifyDeviceOwnerOrProfileOwnerIfNeeded(force);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "Failed to read security log", e);
|
Log.e(TAG, "Failed to read security log", e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -460,8 +460,9 @@ class SecurityLogMonitor implements Runnable {
|
|||||||
Slog.i(TAG, "MonitorThread exit.");
|
Slog.i(TAG, "MonitorThread exit.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyDeviceOwnerIfNeeded(boolean force) throws InterruptedException {
|
private void notifyDeviceOwnerOrProfileOwnerIfNeeded(boolean force)
|
||||||
boolean allowRetrievalAndNotifyDO = false;
|
throws InterruptedException {
|
||||||
|
boolean allowRetrievalAndNotifyDOOrPO = false;
|
||||||
mLock.lockInterruptibly();
|
mLock.lockInterruptibly();
|
||||||
try {
|
try {
|
||||||
if (mPaused) {
|
if (mPaused) {
|
||||||
@@ -471,16 +472,16 @@ class SecurityLogMonitor implements Runnable {
|
|||||||
if (logSize >= BUFFER_ENTRIES_NOTIFICATION_LEVEL || (force && logSize > 0)) {
|
if (logSize >= BUFFER_ENTRIES_NOTIFICATION_LEVEL || (force && logSize > 0)) {
|
||||||
// Allow DO to retrieve logs if too many pending logs or if forced.
|
// Allow DO to retrieve logs if too many pending logs or if forced.
|
||||||
if (!mAllowedToRetrieve) {
|
if (!mAllowedToRetrieve) {
|
||||||
allowRetrievalAndNotifyDO = true;
|
allowRetrievalAndNotifyDOOrPO = true;
|
||||||
}
|
}
|
||||||
if (DEBUG) Slog.d(TAG, "Number of log entries over threshold: " + logSize);
|
if (DEBUG) Slog.d(TAG, "Number of log entries over threshold: " + logSize);
|
||||||
}
|
}
|
||||||
if (logSize > 0 && SystemClock.elapsedRealtime() >= mNextAllowedRetrievalTimeMillis) {
|
if (logSize > 0 && SystemClock.elapsedRealtime() >= mNextAllowedRetrievalTimeMillis) {
|
||||||
// Rate limit reset
|
// Rate limit reset
|
||||||
allowRetrievalAndNotifyDO = true;
|
allowRetrievalAndNotifyDOOrPO = true;
|
||||||
if (DEBUG) Slog.d(TAG, "Timeout reached");
|
if (DEBUG) Slog.d(TAG, "Timeout reached");
|
||||||
}
|
}
|
||||||
if (allowRetrievalAndNotifyDO) {
|
if (allowRetrievalAndNotifyDOOrPO) {
|
||||||
mAllowedToRetrieve = true;
|
mAllowedToRetrieve = true;
|
||||||
// Set the timeout to retry the notification if the DO misses it.
|
// Set the timeout to retry the notification if the DO misses it.
|
||||||
mNextAllowedRetrievalTimeMillis = SystemClock.elapsedRealtime()
|
mNextAllowedRetrievalTimeMillis = SystemClock.elapsedRealtime()
|
||||||
@@ -489,10 +490,10 @@ class SecurityLogMonitor implements Runnable {
|
|||||||
} finally {
|
} finally {
|
||||||
mLock.unlock();
|
mLock.unlock();
|
||||||
}
|
}
|
||||||
if (allowRetrievalAndNotifyDO) {
|
if (allowRetrievalAndNotifyDOOrPO) {
|
||||||
Slog.i(TAG, "notify DO");
|
Slog.i(TAG, "notify DO or PO");
|
||||||
mService.sendDeviceOwnerCommand(DeviceAdminReceiver.ACTION_SECURITY_LOGS_AVAILABLE,
|
mService.sendDeviceOwnerOrProfileOwnerCommand(
|
||||||
null);
|
DeviceAdminReceiver.ACTION_SECURITY_LOGS_AVAILABLE, null, mEnabledUser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user