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

Commit bf875493 authored by mrulhania's avatar mrulhania Committed by Manjeet Rulhania
Browse files

Add trace for discrete ops sqlite write

Bug: 406544634
Test: build
Flag: EXEMPT bug fix
Change-Id: Ia5f48fdb047c9104e122e35af343f6eaf8901336
parent 367e0608
Loading
Loading
Loading
Loading
+45 −35
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteRawStatement;
import android.os.Environment;
import android.os.SystemClock;
import android.os.Trace;
import android.permission.flags.Flags;
import android.util.IntArray;
import android.util.Slog;
@@ -86,6 +87,8 @@ class DiscreteOpsDbHelper extends SQLiteOpenHelper {
            startTime = SystemClock.elapsedRealtime();
        }

        Trace.traceBegin(Trace.TRACE_TAG_SYSTEM_SERVER, "DiscreteOpsWrite");
        try {
            SQLiteDatabase db = getWritableDatabase();
            // TODO (b/383157289) what if database is busy and can't start a transaction? will read
            //  more about it and can be done in a follow up cl.
@@ -102,7 +105,8 @@ class DiscreteOpsDbHelper extends SQLiteOpenHelper {
                        statement.bindInt(DiscreteOpsTable.OP_CODE_INDEX, event.getOpCode());
                        bindTextOrNull(statement, DiscreteOpsTable.ATTRIBUTION_TAG_INDEX,
                                event.getAttributionTag());
                    statement.bindLong(DiscreteOpsTable.ACCESS_TIME_INDEX, event.getAccessTime());
                        statement.bindLong(DiscreteOpsTable.ACCESS_TIME_INDEX,
                                event.getAccessTime());
                        statement.bindLong(
                                DiscreteOpsTable.ACCESS_DURATION_INDEX, event.getDuration());
                        statement.bindInt(DiscreteOpsTable.UID_STATE_INDEX, event.getUidState());
@@ -122,9 +126,15 @@ class DiscreteOpsDbHelper extends SQLiteOpenHelper {
                try {
                    db.endTransaction();
                } catch (SQLiteException exception) {
                Slog.e(LOG_TAG, "Couldn't commit transaction when inserting discrete ops, database"
                        + " file size (bytes) : " + getDatabaseFile().length(), exception);
                    Slog.e(LOG_TAG,
                            "Couldn't commit transaction when inserting discrete ops, database"
                                    + " file size (bytes) : " + getDatabaseFile().length(),
                            exception);
                }

            }
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
        }
        if (Flags.sqliteDiscreteOpEventLoggingEnabled()) {
            long timeTaken = SystemClock.elapsedRealtime() - startTime;