Add debug logs for WorkTabExists test

Bug: 243688989
Change-Id: Iafec4cae86f1527acac9a25fceb501609ca308f6
This commit is contained in:
Vinit Nayak
2023-02-22 17:04:18 -08:00
parent f1a0bd61f4
commit 7a68378fe4
5 changed files with 36 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ import static com.android.launcher3.allapps.ActivityAllAppsContainerView.Adapter
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_COUNT;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_TAP_ON_PERSONAL_TAB;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_TAP_ON_WORK_TAB;
import static com.android.launcher3.testing.shared.TestProtocol.WORK_TAB_MISSING;
import static com.android.launcher3.util.ScrollableLayoutManager.PREDICTIVE_BACK_MIN_SCALE;
import android.animation.Animator;
@@ -73,6 +74,7 @@ import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.keyboard.FocusedItemDecorator;
import com.android.launcher3.model.StringCache;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.testing.shared.TestProtocol;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ActivityContext;
@@ -183,7 +185,12 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
mNavBarScrimPaint = new Paint();
mNavBarScrimPaint.setColor(Themes.getAttrColor(context, R.attr.allAppsNavBarScrimColor));
mAllAppsStore.addUpdateListener(this::onAppsUpdated);
AllAppsStore.OnUpdateListener onAppsUpdated = this::onAppsUpdated;
if (TestProtocol.sDebugTracing) {
Log.d(WORK_TAB_MISSING, "ActivityAllAppsContainer#init registeringListener: " +
onAppsUpdated);
}
mAllAppsStore.addUpdateListener(onAppsUpdated);
mActivityContext.addOnDeviceProfileChangeListener(this);
// This is a focus listener that proxies focus from a view into the list view. This is to
@@ -809,6 +816,10 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
private void onAppsUpdated() {
mHasWorkApps = Stream.of(mAllAppsStore.getApps()).anyMatch(mWorkManager.getMatcher());
if (TestProtocol.sDebugTracing) {
Log.d(WORK_TAB_MISSING, "ActivityAllAppsContainerView#onAppsUpdated hasWorkApps: " +
mHasWorkApps + " allApps: " + mAllAppsStore.getApps().length);
}
if (!isSearching()) {
rebindAdapters();
if (mHasWorkApps) {

View File

@@ -18,7 +18,9 @@ package com.android.launcher3.allapps;
import static com.android.launcher3.model.data.AppInfo.COMPONENT_KEY_COMPARATOR;
import static com.android.launcher3.model.data.AppInfo.EMPTY_ARRAY;
import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK;
import static com.android.launcher3.testing.shared.TestProtocol.WORK_TAB_MISSING;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
@@ -27,6 +29,7 @@ import androidx.annotation.Nullable;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.testing.shared.TestProtocol;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.PackageUserKey;
@@ -119,6 +122,9 @@ public class AllAppsStore {
return;
}
for (OnUpdateListener listener : mUpdateListeners) {
if (TestProtocol.sDebugTracing) {
Log.d(WORK_TAB_MISSING, "AllAppsStore#notifyUpdate listener: " + listener);
}
listener.onAppsUpdated();
}
}

View File

@@ -25,6 +25,7 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_HAS_SHORTCUT_PERMISSION;
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_QUIET_MODE_CHANGE_PERMISSION;
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_QUIET_MODE_ENABLED;
import static com.android.launcher3.testing.shared.TestProtocol.WORK_TAB_MISSING;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import android.os.Build;
@@ -46,6 +47,7 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.testing.shared.TestProtocol;
import com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip;
import java.lang.annotation.Retention;
@@ -137,6 +139,10 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
}
private void updateCurrentState(@WorkProfileState int currentState) {
if (TestProtocol.sDebugTracing) {
Log.d(WORK_TAB_MISSING, "WorkProfileManager#updateCurrentState: " +
currentState, new Throwable());
}
mCurrentState = currentState;
if (getAH() != null) {
getAH().mAppsList.updateAdapterItems();
@@ -155,6 +161,10 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
* Creates and attaches for profile toggle button to {@link ActivityAllAppsContainerView}
*/
public boolean attachWorkModeSwitch() {
if (TestProtocol.sDebugTracing) {
Log.d(WORK_TAB_MISSING, "ActivityAllAppsContainerView#attachWorkModeSwitch "
+ "mWorkModeSwitch: " + mWorkModeSwitch);
}
if (!mAllApps.getAppsStore().hasModelFlag(
FLAG_HAS_SHORTCUT_PERMISSION | FLAG_QUIET_MODE_CHANGE_PERMISSION)) {
Log.e(TAG, "unable to attach work mode switch; Missing required permissions");

View File

@@ -156,6 +156,7 @@ public final class TestProtocol {
public static final String NPE_TRANSIENT_TASKBAR = "b/257549303";
public static final String FLAKY_BINDING = "b/270216650";
public static final String VIEW_AND_ACTIVITY_LEAKS = "b/260260325";
public static final String WORK_TAB_MISSING = "b/243688989";
public static final String REQUEST_EMULATE_DISPLAY = "emulate-display";
public static final String REQUEST_STOP_EMULATE_DISPLAY = "stop-emulate-display";

View File

@@ -18,6 +18,7 @@ package com.android.launcher3.ui;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.allapps.AllAppsStore.DEFER_UPDATES_TEST;
import static com.android.launcher3.testing.shared.TestProtocol.WORK_TAB_MISSING;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -65,8 +66,13 @@ public class WorkProfileTest extends AbstractLauncherUiTest {
String[] tokens = output.split("\\s+");
mProfileUserId = Integer.parseInt(tokens[tokens.length - 1]);
output = mDevice.executeShellCommand("am start-user " + mProfileUserId);
StringBuilder logStr = new StringBuilder().append("profileId: ").append(mProfileUserId);
for (String str : tokens) {
logStr.append(str).append("\n");
}
updateWorkProfileSetupSuccessful("am start-user", output);
Log.d(WORK_TAB_MISSING, "workProfileSuccessful? " + mWorkProfileSetupSuccessful);
if (!mWorkProfileSetupSuccessful) {
return; // no need to setup launcher since all tests will skip.
}
@@ -99,6 +105,7 @@ public class WorkProfileTest extends AbstractLauncherUiTest {
private void waitForWorkTabSetup() {
waitForLauncherCondition("Work tab not setup", launcher -> {
if (launcher.getAppsView().getContentView() instanceof AllAppsPagedView) {
Log.d(WORK_TAB_MISSING, "Deferring AppsStore updates");
launcher.getAppsView().getAppsStore().enableDeferUpdates(DEFER_UPDATES_TEST);
return true;
}