Merge "Add debug logs for testPromiseIcon_addedFromEligibleSession"
This commit is contained in:
@@ -2401,6 +2401,10 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
|
||||
} else {
|
||||
Log.d(TAG, desc);
|
||||
getModelWriter().deleteItemFromDatabase(item);
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON,
|
||||
TAG + "bindItems failed for item=" + item);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,12 +24,14 @@ import android.content.pm.PackageInstaller.SessionInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.UserHandle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
import com.android.launcher3.logging.FileLog;
|
||||
import com.android.launcher3.model.ItemInstallQueue;
|
||||
import com.android.launcher3.pm.InstallSessionHelper;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.util.Executors;
|
||||
|
||||
/**
|
||||
@@ -51,6 +53,9 @@ public class SessionCommitReceiver extends BroadcastReceiver {
|
||||
private static void processIntent(Context context, Intent intent) {
|
||||
if (!isEnabled(context)) {
|
||||
// User has decided to not add icons on homescreen.
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON, LOG + " not enabled");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,6 +64,9 @@ public class SessionCommitReceiver extends BroadcastReceiver {
|
||||
if (!PackageInstaller.ACTION_SESSION_COMMITTED.equals(intent.getAction())
|
||||
|| info == null || user == null) {
|
||||
// Invalid intent.
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON, LOG + " invalid intent");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -68,6 +76,15 @@ public class SessionCommitReceiver extends BroadcastReceiver {
|
||||
|| info.getInstallReason() != PackageManager.INSTALL_REASON_USER
|
||||
|| packageInstallerCompat.promiseIconAddedForId(info.getSessionId())) {
|
||||
packageInstallerCompat.removePromiseIconId(info.getSessionId());
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
int id = info.getSessionId();
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON, LOG
|
||||
+ ", TextUtils.isEmpty=" + TextUtils.isEmpty(info.getAppPackageName())
|
||||
+ ", info.getInstallReason()=" + info.getInstallReason()
|
||||
+ ", INSTALL_REASON_USER=" + PackageManager.INSTALL_REASON_USER
|
||||
+ ", icon added=" + packageInstallerCompat.promiseIconAddedForId(id)
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.content.pm.LauncherActivityInfo;
|
||||
import android.content.pm.LauncherApps;
|
||||
import android.content.pm.PackageInstaller.SessionInfo;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
import android.util.LongSparseArray;
|
||||
import android.util.Pair;
|
||||
|
||||
@@ -39,6 +40,7 @@ import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.pm.InstallSessionHelper;
|
||||
import com.android.launcher3.pm.PackageInstallInfo;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.util.GridOccupancy;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.IntSet;
|
||||
@@ -82,11 +84,19 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
|
||||
item.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) {
|
||||
// Short-circuit this logic if the icon exists somewhere on the workspace
|
||||
if (shortcutExists(dataModel, item.getIntent(), item.user)) {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON,
|
||||
LOG + " Item already on workspace.");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// b/139663018 Short-circuit this logic if the icon is a system app
|
||||
if (PackageManagerHelper.isSystemApp(app.getContext(), item.getIntent())) {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON,
|
||||
LOG + " Item is a system app.");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -126,6 +136,9 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
|
||||
String packageName = item.getTargetComponent() != null
|
||||
? item.getTargetComponent().getPackageName() : null;
|
||||
if (packageName == null) {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON, LOG + " Null packageName.");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
SessionInfo sessionInfo = packageInstaller.getActiveSessionInfo(item.user,
|
||||
@@ -134,6 +147,9 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
|
||||
if (!packageInstaller.verifySessionInfo(sessionInfo)) {
|
||||
FileLog.d(LOG, "Item info failed session info verification. "
|
||||
+ "Skipping : " + workspaceInfo);
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON, LOG + "Failed verification.");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -144,6 +160,9 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
|
||||
if (sessionInfo == null) {
|
||||
if (!hasActivity) {
|
||||
// Session was cancelled, do not add.
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON, LOG + "Session cancelled");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
@@ -163,6 +182,9 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
|
||||
// workspace items as promise icons. At this point we now have the
|
||||
// correct intent to compare against existing workspace icons.
|
||||
// Icon already exists on the workspace and should not be auto-added.
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON, LOG + "shortcutExists");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.shortcuts.ShortcutKey;
|
||||
import com.android.launcher3.shortcuts.ShortcutRequest;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
import com.android.launcher3.util.PersistedItemArray;
|
||||
import com.android.launcher3.util.Preconditions;
|
||||
@@ -118,10 +119,18 @@ public class ItemInstallQueue {
|
||||
Launcher launcher = Launcher.ACTIVITY_TRACKER.getCreatedActivity();
|
||||
if (launcher == null) {
|
||||
// Launcher not loaded
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON,
|
||||
LOG + " flushQueueInBackground launcher not loaded");
|
||||
}
|
||||
return;
|
||||
}
|
||||
ensureQueueLoaded();
|
||||
if (mItems.isEmpty()) {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON,
|
||||
LOG + " flushQueueInBackground no items to load");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -131,6 +140,10 @@ public class ItemInstallQueue {
|
||||
|
||||
// Add the items and clear queue
|
||||
if (!installQueue.isEmpty()) {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON,
|
||||
LOG + " flushQueueInBackground launcher addAndBindAddedWorkspaceItems");
|
||||
}
|
||||
// add log
|
||||
launcher.getModel().addAndBindAddedWorkspaceItems(installQueue);
|
||||
}
|
||||
@@ -191,6 +204,10 @@ public class ItemInstallQueue {
|
||||
// Queue the item up for adding if launcher has not loaded properly yet
|
||||
MODEL_EXECUTOR.post(() -> {
|
||||
Pair<ItemInfo, Object> itemInfo = info.getItemInfo(mContext);
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON, LOG + " queuePendingShortcutInfo"
|
||||
+ ", itemInfo=" + itemInfo);
|
||||
}
|
||||
if (itemInfo == null) {
|
||||
FileLog.d(LOG,
|
||||
"Adding PendingInstallShortcutInfo with no attached info to queue.",
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.content.pm.PackageManager;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
@@ -38,6 +39,7 @@ import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.logging.FileLog;
|
||||
import com.android.launcher3.model.ItemInstallQueue;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.IntSet;
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
@@ -142,6 +144,16 @@ public class InstallSessionHelper {
|
||||
if (sessionInfo == null
|
||||
|| sessionInfo.getInstallerPackageName() == null
|
||||
|| TextUtils.isEmpty(sessionInfo.getAppPackageName())) {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON, LOG + " verify"
|
||||
+ ", info=" + (sessionInfo == null)
|
||||
+ ", info install name" + (sessionInfo == null
|
||||
? null
|
||||
: sessionInfo.getInstallerPackageName())
|
||||
+ ", empty pkg name" + TextUtils.isEmpty((sessionInfo == null
|
||||
? null
|
||||
: sessionInfo.getAppPackageName())));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
String pkg = sessionInfo.getInstallerPackageName();
|
||||
@@ -211,6 +223,14 @@ public class InstallSessionHelper {
|
||||
*/
|
||||
@WorkerThread
|
||||
void tryQueuePromiseAppIcon(PackageInstaller.SessionInfo sessionInfo) {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON, LOG + " tryQueuePromiseAppIcon"
|
||||
+ ", FeatureFlags=" + FeatureFlags.PROMISE_APPS_NEW_INSTALLS.get()
|
||||
+ ", SessionCommitReceiveEnabled" + SessionCommitReceiver.isEnabled(mAppContext)
|
||||
+ ", verifySessionInfo(sessionInfo)=" + verifySessionInfo(sessionInfo)
|
||||
+ ", !promiseIconAdded=" + (sessionInfo != null
|
||||
&& !promiseIconAddedForId(sessionInfo.getSessionId())));
|
||||
}
|
||||
if (FeatureFlags.PROMISE_APPS_NEW_INSTALLS.get()
|
||||
&& SessionCommitReceiver.isEnabled(mAppContext)
|
||||
&& verifySessionInfo(sessionInfo)
|
||||
@@ -227,6 +247,20 @@ public class InstallSessionHelper {
|
||||
}
|
||||
|
||||
public boolean verifySessionInfo(PackageInstaller.SessionInfo sessionInfo) {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
boolean appNotInstalled = sessionInfo == null
|
||||
|| !new PackageManagerHelper(mAppContext)
|
||||
.isAppInstalled(sessionInfo.getAppPackageName(), getUserHandle(sessionInfo));
|
||||
boolean labelNotEmpty = sessionInfo != null
|
||||
&& !TextUtils.isEmpty(sessionInfo.getAppLabel());
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON, LOG + " verifySessionInfo"
|
||||
+ ", verify(sessionInfo)=" + verify(sessionInfo)
|
||||
+ ", reason=" + (sessionInfo == null ? null : sessionInfo.getInstallReason())
|
||||
+ ", PackageManager.INSTALL_REASON_USER=" + PackageManager.INSTALL_REASON_USER
|
||||
+ ", hasIcon=" + (sessionInfo != null && sessionInfo.getAppIcon() != null)
|
||||
+ ", label is ! empty=" + labelNotEmpty
|
||||
+ " +, app not installed=" + appNotInstalled);
|
||||
}
|
||||
return verify(sessionInfo) != null
|
||||
&& sessionInfo.getInstallReason() == PackageManager.INSTALL_REASON_USER
|
||||
&& sessionInfo.getAppIcon() != null
|
||||
|
||||
@@ -25,10 +25,12 @@ 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.WorkerThread;
|
||||
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.util.PackageUserKey;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
@@ -57,10 +59,19 @@ public class InstallSessionTracker extends PackageInstaller.SessionCallback {
|
||||
public void onCreated(int sessionId) {
|
||||
InstallSessionHelper helper = mWeakHelper.get();
|
||||
Callback callback = mWeakCallback.get();
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON, "Session created sessionId=" + sessionId
|
||||
+ ", callback=" + callback
|
||||
+ ", helper=" + helper);
|
||||
}
|
||||
if (callback == null || helper == null) {
|
||||
return;
|
||||
}
|
||||
SessionInfo sessionInfo = pushSessionDisplayToLauncher(sessionId, helper, callback);
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON, "Session created sessionId=" + sessionId
|
||||
+ ", sessionInfo=" + sessionInfo);
|
||||
}
|
||||
if (sessionInfo != null) {
|
||||
callback.onInstallSessionCreated(PackageInstallInfo.fromInstallingState(sessionInfo));
|
||||
}
|
||||
|
||||
@@ -126,4 +126,5 @@ public final class TestProtocol {
|
||||
public static final String TASK_VIEW_ID_CRASH = "b/195430732";
|
||||
public static final String NO_DROP_TARGET = "b/195031154";
|
||||
public static final String NULL_INT_SET = "b/200572078";
|
||||
public static final String MISSING_PROMISE_ICON = "b/202985412";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user