Loading cmds/dpm/src/com/android/commands/dpm/Dpm.java +19 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ public final class Dpm extends BaseCommand { private static final String COMMAND_SET_PROFILE_OWNER = "set-profile-owner"; private static final String COMMAND_REMOVE_ACTIVE_ADMIN = "remove-active-admin"; private static final String COMMAND_CLEAR_FREEZE_PERIOD_RECORD = "clear-freeze-period-record"; private static final String COMMAND_FORCE_NETWORK_LOGS = "force-network-logs"; private static final String COMMAND_FORCE_SECURITY_LOGS = "force-security-logs"; private IDevicePolicyManager mDevicePolicyManager; Loading Loading @@ -84,6 +85,9 @@ public final class Dpm extends BaseCommand { "feature development to prevent triggering restriction on setting freeze " + "periods.\n" + "\n" + "dpm " + COMMAND_FORCE_NETWORK_LOGS + ": makes all network logs available to " + "the DPC and triggers DeviceAdminReceiver.onNetworkLogsAvailable() if needed.\n" + "\n" + "dpm " + COMMAND_FORCE_SECURITY_LOGS + ": makes all security logs available to " + "the DPC and triggers DeviceAdminReceiver.onSecurityLogsAvailable() if needed."); } Loading Loading @@ -114,6 +118,9 @@ public final class Dpm extends BaseCommand { case COMMAND_CLEAR_FREEZE_PERIOD_RECORD: runClearFreezePeriodRecord(); break; case COMMAND_FORCE_NETWORK_LOGS: runForceNetworkLogs(); break; case COMMAND_FORCE_SECURITY_LOGS: runForceSecurityLogs(); break; Loading @@ -122,6 +129,18 @@ public final class Dpm extends BaseCommand { } } private void runForceNetworkLogs() throws RemoteException, InterruptedException { while (true) { final long toWait = mDevicePolicyManager.forceNetworkLogs(); if (toWait == 0) { break; } System.out.println("We have to wait for " + toWait + " milliseconds..."); Thread.sleep(toWait); } System.out.println("Success"); } private void runForceSecurityLogs() throws RemoteException, InterruptedException { while (true) { final long toWait = mDevicePolicyManager.forceSecurityLogs(); Loading core/java/android/app/admin/DevicePolicyManager.java +16 −0 Original line number Diff line number Diff line Loading @@ -8299,6 +8299,22 @@ public class DevicePolicyManager { } } /** * Makes all accumulated network logs available to DPC in a new batch. * Only callable by ADB. If throttled, returns time to wait in milliseconds, otherwise 0. * @hide */ public long forceNetworkLogs() { if (mService == null) { return -1; } try { return mService.forceNetworkLogs(); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } /** * Forces a batch of security logs to be fetched from logd and makes it available for DPC. * Only callable by ADB. If throttled, returns time to wait in milliseconds, otherwise 0. Loading core/java/android/app/admin/IDevicePolicyManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -347,6 +347,7 @@ interface IDevicePolicyManager { boolean isSecurityLoggingEnabled(in ComponentName admin); ParceledListSlice retrieveSecurityLogs(in ComponentName admin); ParceledListSlice retrievePreRebootSecurityLogs(in ComponentName admin); long forceNetworkLogs(); long forceSecurityLogs(); boolean isUninstallInQueue(String packageName); Loading services/devicepolicy/java/com/android/server/devicepolicy/BaseIDevicePolicyManager.java +5 −0 Original line number Diff line number Diff line Loading @@ -151,6 +151,11 @@ abstract class BaseIDevicePolicyManager extends IDevicePolicyManager.Stub { return false; } @Override public long forceNetworkLogs() { return 0; } @Override public long forceSecurityLogs() { return 0; Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +14 −1 Original line number Diff line number Diff line Loading @@ -10694,7 +10694,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return false; } } return false; } Loading Loading @@ -12282,6 +12281,20 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } } @Override public long forceNetworkLogs() { enforceShell("forceNetworkLogs"); synchronized (getLockObject()) { if (!isNetworkLoggingEnabledInternalLocked()) { throw new IllegalStateException("logging is not available"); } if (mNetworkLogger != null) { return mNetworkLogger.forceBatchFinalization(); } return 0; } } /** Pauses security and network logging if there are unaffiliated users on the device */ private void maybePauseDeviceWideLoggingLocked() { if (!areAllUsersAffiliatedWithDeviceLocked()) { Loading
cmds/dpm/src/com/android/commands/dpm/Dpm.java +19 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ public final class Dpm extends BaseCommand { private static final String COMMAND_SET_PROFILE_OWNER = "set-profile-owner"; private static final String COMMAND_REMOVE_ACTIVE_ADMIN = "remove-active-admin"; private static final String COMMAND_CLEAR_FREEZE_PERIOD_RECORD = "clear-freeze-period-record"; private static final String COMMAND_FORCE_NETWORK_LOGS = "force-network-logs"; private static final String COMMAND_FORCE_SECURITY_LOGS = "force-security-logs"; private IDevicePolicyManager mDevicePolicyManager; Loading Loading @@ -84,6 +85,9 @@ public final class Dpm extends BaseCommand { "feature development to prevent triggering restriction on setting freeze " + "periods.\n" + "\n" + "dpm " + COMMAND_FORCE_NETWORK_LOGS + ": makes all network logs available to " + "the DPC and triggers DeviceAdminReceiver.onNetworkLogsAvailable() if needed.\n" + "\n" + "dpm " + COMMAND_FORCE_SECURITY_LOGS + ": makes all security logs available to " + "the DPC and triggers DeviceAdminReceiver.onSecurityLogsAvailable() if needed."); } Loading Loading @@ -114,6 +118,9 @@ public final class Dpm extends BaseCommand { case COMMAND_CLEAR_FREEZE_PERIOD_RECORD: runClearFreezePeriodRecord(); break; case COMMAND_FORCE_NETWORK_LOGS: runForceNetworkLogs(); break; case COMMAND_FORCE_SECURITY_LOGS: runForceSecurityLogs(); break; Loading @@ -122,6 +129,18 @@ public final class Dpm extends BaseCommand { } } private void runForceNetworkLogs() throws RemoteException, InterruptedException { while (true) { final long toWait = mDevicePolicyManager.forceNetworkLogs(); if (toWait == 0) { break; } System.out.println("We have to wait for " + toWait + " milliseconds..."); Thread.sleep(toWait); } System.out.println("Success"); } private void runForceSecurityLogs() throws RemoteException, InterruptedException { while (true) { final long toWait = mDevicePolicyManager.forceSecurityLogs(); Loading
core/java/android/app/admin/DevicePolicyManager.java +16 −0 Original line number Diff line number Diff line Loading @@ -8299,6 +8299,22 @@ public class DevicePolicyManager { } } /** * Makes all accumulated network logs available to DPC in a new batch. * Only callable by ADB. If throttled, returns time to wait in milliseconds, otherwise 0. * @hide */ public long forceNetworkLogs() { if (mService == null) { return -1; } try { return mService.forceNetworkLogs(); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } /** * Forces a batch of security logs to be fetched from logd and makes it available for DPC. * Only callable by ADB. If throttled, returns time to wait in milliseconds, otherwise 0. Loading
core/java/android/app/admin/IDevicePolicyManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -347,6 +347,7 @@ interface IDevicePolicyManager { boolean isSecurityLoggingEnabled(in ComponentName admin); ParceledListSlice retrieveSecurityLogs(in ComponentName admin); ParceledListSlice retrievePreRebootSecurityLogs(in ComponentName admin); long forceNetworkLogs(); long forceSecurityLogs(); boolean isUninstallInQueue(String packageName); Loading
services/devicepolicy/java/com/android/server/devicepolicy/BaseIDevicePolicyManager.java +5 −0 Original line number Diff line number Diff line Loading @@ -151,6 +151,11 @@ abstract class BaseIDevicePolicyManager extends IDevicePolicyManager.Stub { return false; } @Override public long forceNetworkLogs() { return 0; } @Override public long forceSecurityLogs() { return 0; Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +14 −1 Original line number Diff line number Diff line Loading @@ -10694,7 +10694,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return false; } } return false; } Loading Loading @@ -12282,6 +12281,20 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } } @Override public long forceNetworkLogs() { enforceShell("forceNetworkLogs"); synchronized (getLockObject()) { if (!isNetworkLoggingEnabledInternalLocked()) { throw new IllegalStateException("logging is not available"); } if (mNetworkLogger != null) { return mNetworkLogger.forceBatchFinalization(); } return 0; } } /** Pauses security and network logging if there are unaffiliated users on the device */ private void maybePauseDeviceWideLoggingLocked() { if (!areAllUsersAffiliatedWithDeviceLocked()) {