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

Commit 458bbbc1 authored by Jack Yu's avatar Jack Yu Committed by Automerger Merge Worker
Browse files

Enhanced subscription database manager logs am: 3e1e7ed3

parents a4a4dbab 3e1e7ed3
Loading
Loading
Loading
Loading
+25 −9
Original line number Original line Diff line number Diff line
@@ -506,8 +506,8 @@ public class SubscriptionDatabaseManager extends Handler {
            new HashMap<>(16);
            new HashMap<>(16);


    /** Whether database has been initialized after boot up. */
    /** Whether database has been initialized after boot up. */
    @GuardedBy("mDatabaseInitialized")
    @GuardedBy("this")
    private Boolean mDatabaseInitialized = false;
    private boolean mDatabaseInitialized = false;


    /**
    /**
     * This is the callback used for listening events from {@link SubscriptionDatabaseManager}.
     * This is the callback used for listening events from {@link SubscriptionDatabaseManager}.
@@ -759,7 +759,7 @@ public class SubscriptionDatabaseManager extends Handler {
                    + "insert. subInfo=" + subInfo);
                    + "insert. subInfo=" + subInfo);
        }
        }


        synchronized (mDatabaseInitialized) {
        synchronized (this) {
            if (!mDatabaseInitialized) {
            if (!mDatabaseInitialized) {
                throw new IllegalStateException(
                throw new IllegalStateException(
                        "Database has not been initialized. Can't insert new "
                        "Database has not been initialized. Can't insert new "
@@ -831,7 +831,7 @@ public class SubscriptionDatabaseManager extends Handler {
    private int updateDatabase(int subId, @NonNull ContentValues contentValues) {
    private int updateDatabase(int subId, @NonNull ContentValues contentValues) {
        logv("updateDatabase: prepare to update sub " + subId);
        logv("updateDatabase: prepare to update sub " + subId);


        synchronized (mDatabaseInitialized) {
        synchronized (this) {
            if (!mDatabaseInitialized) {
            if (!mDatabaseInitialized) {
                logel("updateDatabase: Database has not been initialized. Can't update database at "
                logel("updateDatabase: Database has not been initialized. Can't update database at "
                        + "this point. contentValues=" + contentValues);
                        + "this point. contentValues=" + contentValues);
@@ -1852,7 +1852,7 @@ public class SubscriptionDatabaseManager extends Handler {
        if (mAsyncMode) {
        if (mAsyncMode) {
            // Load the database asynchronously.
            // Load the database asynchronously.
            post(() -> {
            post(() -> {
                synchronized (mDatabaseInitialized) {
                synchronized (this) {
                    loadDatabaseInternal();
                    loadDatabaseInternal();
                    mDatabaseInitialized = true;
                    mDatabaseInitialized = true;
                    mCallback.invokeFromExecutor(mCallback::onInitialized);
                    mCallback.invokeFromExecutor(mCallback::onInitialized);
@@ -1860,7 +1860,7 @@ public class SubscriptionDatabaseManager extends Handler {
            });
            });
        } else {
        } else {
            // Load the database synchronously.
            // Load the database synchronously.
            synchronized (mDatabaseInitialized) {
            synchronized (this) {
                loadDatabaseInternal();
                loadDatabaseInternal();
                mDatabaseInitialized = true;
                mDatabaseInitialized = true;
                mCallback.invokeFromExecutor(mCallback::onInitialized);
                mCallback.invokeFromExecutor(mCallback::onInitialized);
@@ -2120,7 +2120,7 @@ public class SubscriptionDatabaseManager extends Handler {
    }
    }


    /**
    /**
     * Dump the state of {@link SubscriptionManagerService}.
     * Dump the state of {@link SubscriptionDatabaseManager}.
     *
     *
     * @param fd File descriptor
     * @param fd File descriptor
     * @param printWriter Print writer
     * @param printWriter Print writer
@@ -2129,11 +2129,27 @@ public class SubscriptionDatabaseManager extends Handler {
    public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter printWriter,
    public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter printWriter,
            @NonNull String[] args) {
            @NonNull String[] args) {
        IndentingPrintWriter pw = new IndentingPrintWriter(printWriter, "  ");
        IndentingPrintWriter pw = new IndentingPrintWriter(printWriter, "  ");
        pw.println(SubscriptionManagerService.class.getSimpleName() + ":");
        pw.println(SubscriptionDatabaseManager.class.getSimpleName() + ":");
        pw.increaseIndent();
        pw.increaseIndent();
        pw.println("All subscriptions:");
        pw.println("All subscriptions:");
        pw.increaseIndent();
        pw.increaseIndent();
        mReadWriteLock.readLock().lock();
        try {
            mAllSubscriptionInfoInternalCache.forEach((subId, subInfo) -> pw.println(subInfo));
            mAllSubscriptionInfoInternalCache.forEach((subId, subInfo) -> pw.println(subInfo));
        } finally {
            mReadWriteLock.readLock().unlock();
        }
        pw.decreaseIndent();
        pw.println();
        pw.println("mAsyncMode=" + mAsyncMode);
        synchronized (this) {
            pw.println("mDatabaseInitialized=" + mDatabaseInitialized);
        }
        pw.println("mReadWriteLock=" + mReadWriteLock);
        pw.println();
        pw.println("Local log:");
        pw.increaseIndent();
        mLocalLog.dump(fd, printWriter, args);
        pw.decreaseIndent();
        pw.decreaseIndent();
        pw.decreaseIndent();
        pw.decreaseIndent();
    }
    }
+2 −0
Original line number Original line Diff line number Diff line
@@ -3920,5 +3920,7 @@ public class SubscriptionManagerService extends ISub.Stub {
        mLocalLog.dump(fd, pw, args);
        mLocalLog.dump(fd, pw, args);
        pw.decreaseIndent();
        pw.decreaseIndent();
        pw.decreaseIndent();
        pw.decreaseIndent();
        pw.println();
        mSubscriptionDatabaseManager.dump(fd, pw, args);
    }
    }
}
}