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

Commit fe4cb0de authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add logging around InstallSessionTracker to verify PackageInstaller is...

Merge "Add logging around InstallSessionTracker to verify PackageInstaller is communicating with Launcher." into main
parents 4d2091e8 e745aa87
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -192,22 +192,18 @@ public class ItemInstallQueue implements SafeCloseable {
    }

    private void queuePendingShortcutInfo(PendingInstallShortcutInfo info) {
        final Exception stackTrace = new Exception();

        // Queue the item up for adding if launcher has not loaded properly yet
        MODEL_EXECUTOR.post(() -> {
            Pair<ItemInfo, Object> itemInfo = info.getItemInfo(mContext);
            if (itemInfo == null) {
                FileLog.d(LOG,
                        "Adding PendingInstallShortcutInfo with no attached info to queue.",
                        stackTrace);
                        "Adding PendingInstallShortcutInfo with no attached info to queue.");
            } else {
                FileLog.d(LOG,
                        "Adding PendingInstallShortcutInfo to queue. Attached info: "
                                + itemInfo.first,
                        stackTrace);
                        "Adding PendingInstallShortcutInfo to queue."
                                + " Attached info: " + itemInfo.first);
            }

            addToQueue(info);
        });
        flushInstallQueue();
+18 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.pm.PackageInstaller;
import android.content.pm.PackageInstaller.SessionInfo;
import android.os.Build;
import android.os.UserHandle;
import android.util.Log;
import android.util.SparseArray;

import androidx.annotation.NonNull;
@@ -32,6 +33,7 @@ import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;

import com.android.launcher3.Flags;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.util.PackageUserKey;

import java.lang.ref.WeakReference;
@@ -41,6 +43,8 @@ import java.util.Objects;
@WorkerThread
public class InstallSessionTracker extends PackageInstaller.SessionCallback {

    public static final String TAG = "InstallSessionTracker";

    // Lazily initialized
    private SparseArray<PackageUserKey> mActiveSessions = null;

@@ -75,6 +79,11 @@ public class InstallSessionTracker extends PackageInstaller.SessionCallback {
        }
        SessionInfo sessionInfo = pushSessionDisplayToLauncher(sessionId, helper, callback);
        if (sessionInfo != null) {
            FileLog.d(TAG, "onCreated: Install session created for"
                    + " appPackageName=" + sessionInfo.getAppPackageName()
                    + ", sessionId=" + sessionInfo.getSessionId()
                    + ", appIcon=" + sessionInfo.getAppIcon()
                    + ", appLabel=" + sessionInfo.getAppLabel());
            callback.onInstallSessionCreated(PackageInstallInfo.fromInstallingState(sessionInfo));
        }

@@ -102,6 +111,10 @@ public class InstallSessionTracker extends PackageInstaller.SessionCallback {
        activeSessions.remove(sessionId);

        if (key != null && key.mPackageName != null) {
            FileLog.d(TAG, "onFinished: active install session finished for"
                    + " appPackageName=" + key.mPackageName
                    + ", sessionId=" + sessionId
                    + ", success=" + success);
            String packageName = key.mPackageName;
            PackageInstallInfo info = PackageInstallInfo.fromState(
                    success ? STATUS_INSTALLED : STATUS_FAILED,
@@ -141,6 +154,11 @@ public class InstallSessionTracker extends PackageInstaller.SessionCallback {
        }
        SessionInfo sessionInfo = pushSessionDisplayToLauncher(sessionId, helper, callback);
        if (sessionInfo != null) {
            Log.d(TAG, "onBadgingChanged: badging info changed for"
                    + " appPackageName=" + sessionInfo.getAppPackageName()
                    + ", sessionId=" + sessionInfo.getSessionId()
                    + ", appIcon=" + sessionInfo.getAppIcon()
                    + ", appLabel=" + sessionInfo.getAppLabel());
            helper.tryQueuePromiseAppIcon(sessionInfo);
        }
    }