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

Commit aafccb30 authored by Jeffrey Huang's avatar Jeffrey Huang
Browse files

Migrate pullBluetoothActivityInfo

Bug: 145565211
Test: No Cts test. Ran adb shell cmd stats pull-source 10007
Change-Id: I6b2f5e01f966407b791ad3516d36402daab6cf8b
parent fa91789b
Loading
Loading
Loading
Loading
+0 −32
Original line number Original line Diff line number Diff line
@@ -910,33 +910,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
        }
        }
    }
    }


    private void pullBluetoothActivityInfo(
            int tagId, long elapsedNanos, long wallClockNanos,
            List<StatsLogEventWrapper> pulledData) {
        BluetoothActivityEnergyInfo info = fetchBluetoothData();
        StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos);
        e.writeLong(info.getTimeStamp());
        e.writeInt(info.getBluetoothStackState());
        e.writeLong(info.getControllerTxTimeMillis());
        e.writeLong(info.getControllerRxTimeMillis());
        e.writeLong(info.getControllerIdleTimeMillis());
        e.writeLong(info.getControllerEnergyUsed());
        pulledData.add(e);
    }

    private synchronized BluetoothActivityEnergyInfo fetchBluetoothData() {
        final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
        if (adapter != null) {
            SynchronousResultReceiver bluetoothReceiver = new SynchronousResultReceiver(
                    "bluetooth");
            adapter.requestControllerActivityEnergyInfo(bluetoothReceiver);
            return awaitControllerInfo(bluetoothReceiver);
        } else {
            Slog.e(TAG, "Failed to get bluetooth adapter!");
            return null;
        }
    }

    private void pullSystemElapsedRealtime(
    private void pullSystemElapsedRealtime(
            int tagId, long elapsedNanos, long wallClockNanos,
            int tagId, long elapsedNanos, long wallClockNanos,
            List<StatsLogEventWrapper> pulledData) {
            List<StatsLogEventWrapper> pulledData) {
@@ -2190,11 +2163,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
                break;
                break;
            }
            }


            case StatsLog.BLUETOOTH_ACTIVITY_INFO: {
                pullBluetoothActivityInfo(tagId, elapsedNanos, wallClockNanos, ret);
                break;
            }

            case StatsLog.SYSTEM_UPTIME: {
            case StatsLog.SYSTEM_UPTIME: {
                pullSystemUpTime(tagId, elapsedNanos, wallClockNanos, ret);
                pullSystemUpTime(tagId, elapsedNanos, wallClockNanos, ret);
                break;
                break;
+0 −4
Original line number Original line Diff line number Diff line
@@ -111,10 +111,6 @@ std::map<PullerKey, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = {
        {{.atomTag = android::util::MODEM_ACTIVITY_INFO},
        {{.atomTag = android::util::MODEM_ACTIVITY_INFO},
         {.puller = new StatsCompanionServicePuller(android::util::MODEM_ACTIVITY_INFO)}},
         {.puller = new StatsCompanionServicePuller(android::util::MODEM_ACTIVITY_INFO)}},


        // bluetooth_activity_info
        {{.atomTag = android::util::BLUETOOTH_ACTIVITY_INFO},
         {.puller = new StatsCompanionServicePuller(android::util::BLUETOOTH_ACTIVITY_INFO)}},

        // system_elapsed_realtime
        // system_elapsed_realtime
        {{.atomTag = android::util::SYSTEM_ELAPSED_REALTIME},
        {{.atomTag = android::util::SYSTEM_ELAPSED_REALTIME},
         {.coolDownNs = NS_PER_SEC,
         {.coolDownNs = NS_PER_SEC,
+23 −3
Original line number Original line Diff line number Diff line
@@ -675,11 +675,31 @@ public class StatsPullAtomService extends SystemService {
    }
    }


    private void registerBluetoothActivityInfo() {
    private void registerBluetoothActivityInfo() {
        // No op.
        int tagId = StatsLog.BLUETOOTH_ACTIVITY_INFO;
        mStatsManager.registerPullAtomCallback(
                tagId,
                /* metadata */ null,
                (atomTag, data) -> pullBluetoothActivityInfo(atomTag, data),
                Executors.newSingleThreadExecutor()
        );
    }
    }


    private void pullBluetoothActivityInfo() {
    private int pullBluetoothActivityInfo(int atomTag, List<StatsEvent> pulledData) {
        // No op.
        BluetoothActivityEnergyInfo info = fetchBluetoothData();
        if (info == null) {
            return StatsManager.PULL_SKIP;
        }
        StatsEvent e = StatsEvent.newBuilder()
                .setAtomId(atomTag)
                .writeLong(info.getTimeStamp())
                .writeInt(info.getBluetoothStackState())
                .writeLong(info.getControllerTxTimeMillis())
                .writeLong(info.getControllerRxTimeMillis())
                .writeLong(info.getControllerIdleTimeMillis())
                .writeLong(info.getControllerEnergyUsed())
                .build();
        pulledData.add(e);
        return StatsManager.PULL_SUCCESS;
    }
    }


    private void registerSystemElapsedRealtime() {
    private void registerSystemElapsedRealtime() {