diff options
Diffstat (limited to 'src')
5 files changed, 33 insertions, 12 deletions
diff --git a/src/com/android/launcher3/logging/LoggerUtils.java b/src/com/android/launcher3/logging/LoggerUtils.java index 9b75b43b4..ed08c026b 100644 --- a/src/com/android/launcher3/logging/LoggerUtils.java +++ b/src/com/android/launcher3/logging/LoggerUtils.java @@ -44,6 +44,7 @@ import java.lang.reflect.Modifier; public class LoggerUtils { private static final ArrayMap<Class, SparseArray<String>> sNameCache = new ArrayMap<>(); private static final String UNKNOWN = "UNKNOWN"; + private static final int DEFAULT_PREDICTED_RANK = -100; public static String getFieldName(int value, Class c) { SparseArray<String> cache; @@ -168,17 +169,17 @@ public class LoggerUtils { public static Target newItemTarget(ItemInfo info, InstantAppResolver instantAppResolver) { Target t = newTarget(Target.Type.ITEM); - switch (info.itemType) { case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION: t.itemType = (instantAppResolver != null && info instanceof AppInfo && instantAppResolver.isInstantApp(((AppInfo) info)) ) ? ItemType.WEB_APP : ItemType.APP_ICON; - t.predictedRank = -100; // Never assigned + t.predictedRank = DEFAULT_PREDICTED_RANK; break; case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT: t.itemType = ItemType.SHORTCUT; + t.predictedRank = DEFAULT_PREDICTED_RANK; break; case LauncherSettings.Favorites.ITEM_TYPE_FOLDER: t.itemType = ItemType.FOLDER_ICON; @@ -188,6 +189,7 @@ public class LoggerUtils { break; case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT: t.itemType = ItemType.DEEPSHORTCUT; + t.predictedRank = DEFAULT_PREDICTED_RANK; break; } return t; diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java index 21ca74e12..7b06d3ba9 100644 --- a/src/com/android/launcher3/logging/UserEventDispatcher.java +++ b/src/com/android/launcher3/logging/UserEventDispatcher.java @@ -35,6 +35,7 @@ import android.os.SystemClock; import android.util.Log; import android.view.View; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.launcher3.DropTarget; @@ -96,17 +97,23 @@ public class UserEventDispatcher implements ResourceBasedOverride { * Fills in the container data on the given event if the given view is not null. * @return whether container data was added. */ - public static boolean fillInLogContainerData(LauncherLogProto.LauncherEvent event, @Nullable View v) { + public boolean fillInLogContainerData(LauncherLogProto.LauncherEvent event, @Nullable View v) { // Fill in grid(x,y), pageIndex of the child and container type of the parent LogContainerProvider provider = StatsLogUtils.getLaunchProviderRecursive(v); if (v == null || !(v.getTag() instanceof ItemInfo) || provider == null) { return false; } - ItemInfo itemInfo = (ItemInfo) v.getTag(); - provider.fillInLogContainerData(v, itemInfo, event.srcTarget[0], event.srcTarget[1]); + final ItemInfo itemInfo = (ItemInfo) v.getTag(); + final Target target = event.srcTarget[0]; + final Target targetParent = event.srcTarget[1]; + onFillInLogContainerData(itemInfo, target, targetParent); + provider.fillInLogContainerData(v, itemInfo, target, targetParent); return true; } + protected void onFillInLogContainerData( + @NonNull ItemInfo itemInfo, @NonNull Target target, @NonNull Target targetParent) { } + private boolean mSessionStarted; private long mElapsedContainerMillis; private long mElapsedSessionMillis; diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index cc2d586e2..c6de9ca90 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -151,6 +151,12 @@ public class TestInformationHandler implements ResourceBasedOverride { mLeaks.add(bitmap); break; } + + case TestProtocol.REQUEST_ICON_HEIGHT: { + response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, + mDeviceProfile.allAppsCellHeightPx); + break; + } } return response; } diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java index 62bb56404..07ddbdc4e 100644 --- a/src/com/android/launcher3/testing/TestProtocol.java +++ b/src/com/android/launcher3/testing/TestProtocol.java @@ -66,6 +66,8 @@ public final class TestProtocol { "all-apps-to-overview-swipe-height"; public static final String REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT = "home-to-all-apps-swipe-height"; + public static final String REQUEST_ICON_HEIGHT = + "icon-height"; public static final String REQUEST_HOTSEAT_TOP = "hotseat-top"; public static final String REQUEST_IS_LAUNCHER_INITIALIZED = "is-launcher-initialized"; public static final String REQUEST_FREEZE_APP_LIST = "freeze-app-list"; diff --git a/src/com/android/launcher3/util/ViewPool.java b/src/com/android/launcher3/util/ViewPool.java index 8af048d9d..5b33f1849 100644 --- a/src/com/android/launcher3/util/ViewPool.java +++ b/src/com/android/launcher3/util/ViewPool.java @@ -21,12 +21,12 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import com.android.launcher3.util.ViewPool.Reusable; - import androidx.annotation.AnyThread; import androidx.annotation.Nullable; import androidx.annotation.UiThread; +import com.android.launcher3.util.ViewPool.Reusable; + /** * Utility class to maintain a pool of reusable views. * During initialization, views are inflated on the background thread. @@ -58,14 +58,18 @@ public class ViewPool<T extends View & Reusable> { Preconditions.assertUIThread(); Handler handler = new Handler(); + // LayoutInflater is not thread save as it maintains a global variable 'mConstructorArgs'. + // Create a different copy to use on the background thread. + LayoutInflater inflater = mInflater.cloneInContext(mInflater.getContext()); + // Inflate views on a non looper thread. This allows us to catch errors like calling // "new Handler()" in constructor easily. new Thread(() -> { for (int i = 0; i < initialSize; i++) { - T view = inflateNewView(); + T view = inflateNewView(inflater); handler.post(() -> addToPool(view)); } - }).start(); + }, "ViewPool-init").start(); } @UiThread @@ -94,12 +98,12 @@ public class ViewPool<T extends View & Reusable> { mCurrentSize--; return (T) mPool[mCurrentSize]; } - return inflateNewView(); + return inflateNewView(mInflater); } @AnyThread - private T inflateNewView() { - return (T) mInflater.inflate(mLayoutId, mParent, false); + private T inflateNewView(LayoutInflater inflater) { + return (T) inflater.inflate(mLayoutId, mParent, false); } /** |