Merge "Guard retrievePreRebootSecurityLogs with config flag" into nyc-dev
This commit is contained in:
@@ -6150,23 +6150,28 @@ public class DevicePolicyManager {
|
|||||||
/**
|
/**
|
||||||
* Called by device owners to retrieve device logs from before the device's last reboot.
|
* Called by device owners to retrieve device logs from before the device's last reboot.
|
||||||
* <p>
|
* <p>
|
||||||
* <strong> The device logs are retrieved from a RAM region which is not guaranteed to be
|
* <strong> This API is not supported on all devices. Calling this API on unsupported devices
|
||||||
* corruption-free during power cycles, due to hardware variations and limitations. As a result,
|
* will result in {@code null} being returned. The device logs are retrieved from a RAM region
|
||||||
* this API is provided as best-effort and the returned logs may be empty or contain corrupted
|
* which is not guaranteed to be corruption-free during power cycles, as a result be cautious
|
||||||
* data. </strong>
|
* about data corruption when parsing. </strong>
|
||||||
* <p>
|
* <p>
|
||||||
* There must be only one user on the device, managed by the device owner. Otherwise a
|
* There must be only one user on the device, managed by the device owner. Otherwise a
|
||||||
* {@link SecurityException} will be thrown.
|
* {@link SecurityException} will be thrown.
|
||||||
*
|
*
|
||||||
* @param admin Which device owner this request is associated with.
|
* @param admin Which device owner this request is associated with.
|
||||||
* @return Device logs from before the latest reboot of the system.
|
* @return Device logs from before the latest reboot of the system, or {@code null} if this API
|
||||||
|
* is not supported on the device.
|
||||||
* @throws SecurityException if {@code admin} is not a device owner.
|
* @throws SecurityException if {@code admin} is not a device owner.
|
||||||
*/
|
*/
|
||||||
public List<SecurityEvent> retrievePreRebootSecurityLogs(@NonNull ComponentName admin) {
|
public List<SecurityEvent> retrievePreRebootSecurityLogs(@NonNull ComponentName admin) {
|
||||||
throwIfParentInstance("retrievePreRebootSecurityLogs");
|
throwIfParentInstance("retrievePreRebootSecurityLogs");
|
||||||
try {
|
try {
|
||||||
ParceledListSlice<SecurityEvent> list = mService.retrievePreRebootSecurityLogs(admin);
|
ParceledListSlice<SecurityEvent> list = mService.retrievePreRebootSecurityLogs(admin);
|
||||||
return list.getList();
|
if (list != null) {
|
||||||
|
return list.getList();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
} catch (RemoteException re) {
|
} catch (RemoteException re) {
|
||||||
throw re.rethrowFromSystemServer();
|
throw re.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2474,4 +2474,6 @@
|
|||||||
remote provider -->
|
remote provider -->
|
||||||
<string name="config_tvRemoteServicePackage" translatable="false"></string>
|
<string name="config_tvRemoteServicePackage" translatable="false"></string>
|
||||||
|
|
||||||
|
<!-- True if the device supports persisting security logs across reboots. -->
|
||||||
|
<bool name="config_supportPreRebootSecurityLogs">false</bool>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -2586,4 +2586,6 @@
|
|||||||
|
|
||||||
<!-- TV Remote Service package -->
|
<!-- TV Remote Service package -->
|
||||||
<java-symbol type="string" name="config_tvRemoteServicePackage" />
|
<java-symbol type="string" name="config_tvRemoteServicePackage" />
|
||||||
|
|
||||||
|
<java-symbol type="bool" name="config_supportPreRebootSecurityLogs" />
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -8871,6 +8871,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
|||||||
Preconditions.checkNotNull(admin);
|
Preconditions.checkNotNull(admin);
|
||||||
ensureDeviceOwnerManagingSingleUser(admin);
|
ensureDeviceOwnerManagingSingleUser(admin);
|
||||||
|
|
||||||
|
if (!mContext.getResources().getBoolean(R.bool.config_supportPreRebootSecurityLogs)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
ArrayList<SecurityEvent> output = new ArrayList<SecurityEvent>();
|
ArrayList<SecurityEvent> output = new ArrayList<SecurityEvent>();
|
||||||
try {
|
try {
|
||||||
SecurityLog.readPreviousEvents(output);
|
SecurityLog.readPreviousEvents(output);
|
||||||
|
|||||||
Reference in New Issue
Block a user