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

Commit 4c6d13ef authored by Kiwon Park's avatar Kiwon Park
Browse files

Add dumpsys command to save atoms to disks immediately

Test: build
Change-Id: I95f3156ba2f76543124feadf12c04c6d62c5d2d0
Bug: 213234843
parent 1f52cc02
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.internal.telephony;

import android.text.TextUtils;

import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.telephony.Rlog;

@@ -44,13 +42,17 @@ public class DebugService {
     */
    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        if (args != null && args.length > 0) {
            if (TextUtils.equals(args[0], "--metrics")
                    || TextUtils.equals(args[0], "--metricsproto")
                    || TextUtils.equals(args[0], "--metricsprototext"))
            {
            switch (args[0]) {
                case "--metrics":
                case "--metricsproto":
                case "--metricsprototext":
                    log("Collecting telephony metrics..");
                    TelephonyMetrics.getInstance().dump(fd, pw, args);
                    return;
                case "--saveatoms":
                    log("Saving atoms..");
                    PhoneFactory.getMetricsCollector().getAtomsStorage().flushAtoms();
                    return;
            }
        }
        log("Dump telephony.");
+8 −0
Original line number Diff line number Diff line
@@ -998,6 +998,14 @@ public class PersistAtomsStorage {
        }
    }

    /** Saves a pending {@link PersistAtoms} to a file in private storage immediately. */
    public void flushAtoms() {
        if (mHandler.hasCallbacks(mSaveRunnable)) {
            mHandler.removeCallbacks(mSaveRunnable);
            saveAtomsToFileNow();
        }
    }

    /** Loads {@link PersistAtoms} from a file in private storage. */
    private PersistAtoms loadAtomsFromFile() {
        try {