Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eaaf9a12 authored by Michal Karpinski's avatar Michal Karpinski Committed by android-build-merger
Browse files

DO NOT MERGE [DPM] Minor code fixes in NetworkLoggingHandler

am: 896b9db8

Change-Id: I497a699c3137ef85c0ffd1c887bf8bd60600c182
parents fd4ec313 896b9db8
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -9490,6 +9490,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
     * A maximum of 1200 events are returned, and the total marshalled size is in the order of
     * A maximum of 1200 events are returned, and the total marshalled size is in the order of
     * 100kB, so returning a List instead of ParceledListSlice is acceptable.
     * 100kB, so returning a List instead of ParceledListSlice is acceptable.
     * Ideally this would be done with ParceledList, however it only supports homogeneous types.
     * Ideally this would be done with ParceledList, however it only supports homogeneous types.
     *
     * @see NetworkLoggingHandler#MAX_EVENTS_PER_BATCH
     */
     */
    @Override
    @Override
    public synchronized List<NetworkEvent> retrieveNetworkLogs(ComponentName admin,
    public synchronized List<NetworkEvent> retrieveNetworkLogs(ComponentName admin,
+5 −4
Original line number Original line Diff line number Diff line
@@ -61,8 +61,9 @@ final class NetworkLoggingHandler extends Handler {
    @GuardedBy("this")
    @GuardedBy("this")
    private ArrayList<NetworkEvent> mFullBatch;
    private ArrayList<NetworkEvent> mFullBatch;


    // each full batch is represented by its token, which the DPC has to provide back to revieve it
    @GuardedBy("this")
    @GuardedBy("this")
    private long currentFullBatchToken;
    private long mCurrentFullBatchToken;


    NetworkLoggingHandler(Looper looper, DevicePolicyManagerService dpm) {
    NetworkLoggingHandler(Looper looper, DevicePolicyManagerService dpm) {
        super(looper);
        super(looper);
@@ -101,9 +102,9 @@ final class NetworkLoggingHandler extends Handler {
        scheduleBatchFinalization(BATCH_FINALIZATION_TIMEOUT_MS);
        scheduleBatchFinalization(BATCH_FINALIZATION_TIMEOUT_MS);
        // notify DO that there's a new non-empty batch waiting
        // notify DO that there's a new non-empty batch waiting
        if (mFullBatch.size() > 0) {
        if (mFullBatch.size() > 0) {
            currentFullBatchToken++;
            mCurrentFullBatchToken++;
            Bundle extras = new Bundle();
            Bundle extras = new Bundle();
            extras.putLong(DeviceAdminReceiver.EXTRA_NETWORK_LOGS_TOKEN, currentFullBatchToken);
            extras.putLong(DeviceAdminReceiver.EXTRA_NETWORK_LOGS_TOKEN, mCurrentFullBatchToken);
            extras.putInt(DeviceAdminReceiver.EXTRA_NETWORK_LOGS_COUNT, mFullBatch.size());
            extras.putInt(DeviceAdminReceiver.EXTRA_NETWORK_LOGS_COUNT, mFullBatch.size());
            mDpm.sendDeviceOwnerCommand(DeviceAdminReceiver.ACTION_NETWORK_LOGS_AVAILABLE, extras);
            mDpm.sendDeviceOwnerCommand(DeviceAdminReceiver.ACTION_NETWORK_LOGS_AVAILABLE, extras);
        } else {
        } else {
@@ -112,7 +113,7 @@ final class NetworkLoggingHandler extends Handler {
    }
    }


    synchronized List<NetworkEvent> retrieveFullLogBatch(long batchToken) {
    synchronized List<NetworkEvent> retrieveFullLogBatch(long batchToken) {
        if (batchToken != currentFullBatchToken) {
        if (batchToken != mCurrentFullBatchToken) {
            return null;
            return null;
        }
        }
        return mFullBatch;
        return mFullBatch;