Snap for 8228195 from 804056bf42 to udc-release
Change-Id: I24229d9d89a9fe2111d3b76003fc5871601d0cf3
This commit is contained in:
commit
e02e6d698f
19 files changed
+258
-71
No files matched your search
+15
@@ -224,6 +224,21 @@ filegroup {
|
||||
],
|
||||
}
|
||||
|
||||
// Common source files used to build go launcher
|
||||
filegroup {
|
||||
name: "launcher-go-src-no-build-config",
|
||||
srcs: [
|
||||
"src/**/*.java",
|
||||
"src/**/*.kt",
|
||||
"quickstep/src/**/*.java",
|
||||
"quickstep/src/**/*.kt",
|
||||
"go/src/**/*.java",
|
||||
"go/src/**/*.kt",
|
||||
"go/quickstep/src/**/*.java",
|
||||
"go/quickstep/src/**/*.kt",
|
||||
],
|
||||
}
|
||||
|
||||
// Proguard files for Launcher3
|
||||
filegroup {
|
||||
name: "launcher-proguard-rules",
|
||||
|
||||
@@ -7,13 +7,6 @@
|
||||
alexchau@google.com
|
||||
andraskloczl@google.com
|
||||
patmanning@google.com
|
||||
petrcermak@google.com
|
||||
pbdr@google.com
|
||||
kideckel@google.com
|
||||
stevenckng@google.com
|
||||
ydixit@google.com
|
||||
boadway@google.com
|
||||
alinazaidi@google.com
|
||||
adamcohen@google.com
|
||||
hyunyoungs@google.com
|
||||
mrcasey@google.com
|
||||
|
||||
@@ -41,6 +41,7 @@ import android.hardware.SensorManager;
|
||||
import android.hardware.devicestate.DeviceStateManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.IBinder;
|
||||
import android.view.Display;
|
||||
import android.view.View;
|
||||
import android.view.WindowInsets;
|
||||
@@ -548,11 +549,26 @@ public abstract class BaseQuickstepLauncher extends Launcher
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new launch cookie for the activity launch of the given {@param info} if supported.
|
||||
* Adds a new launch cookie for the activity launch if supported.
|
||||
*
|
||||
* @param info the item info for the launch
|
||||
* @param opts the options to set the launchCookie on.
|
||||
*/
|
||||
public void addLaunchCookie(ItemInfo info, ActivityOptions opts) {
|
||||
IBinder launchCookie = getLaunchCookie(info);
|
||||
if (launchCookie != null) {
|
||||
opts.setLaunchCookie(launchCookie);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a new launch cookie for the activity launch if supported.
|
||||
*
|
||||
* @param info the item info for the launch
|
||||
*/
|
||||
public IBinder getLaunchCookie(ItemInfo info) {
|
||||
if (info == null) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
switch (info.container) {
|
||||
case LauncherSettings.Favorites.CONTAINER_DESKTOP:
|
||||
@@ -566,8 +582,7 @@ public abstract class BaseQuickstepLauncher extends Launcher
|
||||
break;
|
||||
}
|
||||
// Reset any existing launch cookies associated with the cookie
|
||||
opts.setLaunchCookie(ObjectWrapper.wrap(NO_MATCHING_ID));
|
||||
return;
|
||||
return ObjectWrapper.wrap(NO_MATCHING_ID);
|
||||
}
|
||||
switch (info.itemType) {
|
||||
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
|
||||
@@ -578,10 +593,9 @@ public abstract class BaseQuickstepLauncher extends Launcher
|
||||
break;
|
||||
default:
|
||||
// Reset any existing launch cookies associated with the cookie
|
||||
opts.setLaunchCookie(ObjectWrapper.wrap(NO_MATCHING_ID));
|
||||
return;
|
||||
return ObjectWrapper.wrap(NO_MATCHING_ID);
|
||||
}
|
||||
opts.setLaunchCookie(ObjectWrapper.wrap(new Integer(info.id)));
|
||||
return ObjectWrapper.wrap(new Integer(info.id));
|
||||
}
|
||||
|
||||
public void setHintUserWillBeActive() {
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.app.ActivityOptions;
|
||||
import android.app.ActivityTaskManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
@@ -58,6 +59,12 @@ class QuickstepInteractionHandler implements RemoteViews.InteractionHandler {
|
||||
Pair<Intent, ActivityOptions> options = remoteResponse.getLaunchOptions(view);
|
||||
ActivityOptionsWrapper activityOptions = mLauncher.getAppTransitionManager()
|
||||
.getActivityLaunchOptions(hostView);
|
||||
Object itemInfo = hostView.getTag();
|
||||
IBinder launchCookie = null;
|
||||
if (itemInfo instanceof ItemInfo) {
|
||||
launchCookie = mLauncher.getLaunchCookie((ItemInfo) itemInfo);
|
||||
activityOptions.options.setLaunchCookie(launchCookie);
|
||||
}
|
||||
if (Utilities.ATLEAST_S && !pendingIntent.isActivity()) {
|
||||
// In the event this pending intent eventually launches an activity, i.e. a trampoline,
|
||||
// use the Quickstep transition animation.
|
||||
@@ -65,17 +72,14 @@ class QuickstepInteractionHandler implements RemoteViews.InteractionHandler {
|
||||
ActivityTaskManager.getService()
|
||||
.registerRemoteAnimationForNextActivityStart(
|
||||
pendingIntent.getCreatorPackage(),
|
||||
activityOptions.options.getRemoteAnimationAdapter());
|
||||
activityOptions.options.getRemoteAnimationAdapter(),
|
||||
launchCookie);
|
||||
} catch (RemoteException e) {
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
activityOptions.options.setPendingIntentLaunchFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
activityOptions.options.setSplashScreenStyle(SplashScreen.SPLASH_SCREEN_STYLE_EMPTY);
|
||||
Object itemInfo = hostView.getTag();
|
||||
if (itemInfo instanceof ItemInfo) {
|
||||
mLauncher.addLaunchCookie((ItemInfo) itemInfo, activityOptions.options);
|
||||
}
|
||||
options = Pair.create(options.first, activityOptions.options);
|
||||
if (pendingIntent.isActivity()) {
|
||||
logAppLaunch(itemInfo);
|
||||
|
||||
@@ -38,7 +38,7 @@ public class AllAppsState extends LauncherState {
|
||||
|
||||
@Override
|
||||
public int getTransitionDuration(Context context) {
|
||||
return 320;
|
||||
return 150;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -816,8 +816,12 @@ public class SystemUiProxy implements ISystemUiProxy,
|
||||
public ArrayList<GroupedRecentTaskInfo> getRecentTasks(int numTasks, int userId) {
|
||||
if (mRecentTasks != null) {
|
||||
try {
|
||||
return new ArrayList<>(Arrays.asList(mRecentTasks.getRecentTasks(numTasks,
|
||||
RECENT_IGNORE_UNAVAILABLE, userId)));
|
||||
final GroupedRecentTaskInfo[] rawTasks = mRecentTasks.getRecentTasks(numTasks,
|
||||
RECENT_IGNORE_UNAVAILABLE, userId);
|
||||
if (rawTasks == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return new ArrayList<>(Arrays.asList(rawTasks));
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Failed call getRecentTasks", e);
|
||||
}
|
||||
|
||||
@@ -959,6 +959,9 @@ public class TouchInteractionService extends Service
|
||||
pw.println("ProtoTrace:");
|
||||
pw.println(" file=" + ProtoTracer.INSTANCE.get(this).getTraceFile());
|
||||
mTaskbarManager.dumpLogs("", pw);
|
||||
if (createdOverviewActivity != null) {
|
||||
createdOverviewActivity.getDeviceProfile().dump("", pw);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -173,9 +173,15 @@ public class Hotseat extends CellLayout implements Insettable {
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
int width = mActivity.getDeviceProfile().isQsbInline
|
||||
? mActivity.getDeviceProfile().qsbWidth
|
||||
: getShortcutsAndWidgets().getMeasuredWidth();
|
||||
int width;
|
||||
if (mActivity.getDeviceProfile().isQsbInline) {
|
||||
width = mActivity.getDeviceProfile().qsbWidth;
|
||||
} else {
|
||||
MarginLayoutParams qsbParams = (MarginLayoutParams) mQsb.getLayoutParams();
|
||||
width = getShortcutsAndWidgets().getMeasuredWidth()
|
||||
- qsbParams.getMarginStart()
|
||||
- qsbParams.getMarginEnd();
|
||||
}
|
||||
|
||||
mQsb.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
||||
MeasureSpec.makeMeasureSpec(mQsbHeight, MeasureSpec.EXACTLY));
|
||||
|
||||
@@ -2173,10 +2173,6 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
|
||||
|
||||
IntSet result = new IntSet();
|
||||
if (visibleIds.isEmpty()) {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.NULL_INT_SET, "getPagesToBindSynchronously (1): "
|
||||
+ result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
for (int id : orderedScreenIds.toArray()) {
|
||||
@@ -2197,10 +2193,6 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
|
||||
// pages being hidden in single panel.
|
||||
result.add(pairId);
|
||||
}
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.NULL_INT_SET, "getPagesToBindSynchronously (2): "
|
||||
+ result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -357,12 +357,6 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
|
||||
public void addCallbacks(Callbacks callbacks) {
|
||||
Preconditions.assertUIThread();
|
||||
synchronized (mCallbacksList) {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.NULL_INT_SET, "addCallbacks pointer: "
|
||||
+ callbacks
|
||||
+ ", name: "
|
||||
+ callbacks.getClass().getName(), new Exception());
|
||||
}
|
||||
mCallbacksList.add(callbacks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2484,21 +2484,27 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
}
|
||||
}
|
||||
|
||||
// Note, centerX represents the center of the object that is being dragged, visually. d.x
|
||||
// represents the location of the finger within the dragged item.
|
||||
float touchX;
|
||||
float touchY = d.y;
|
||||
|
||||
// Go through the pages and check if the dragged item is inside one of them. This block
|
||||
// is responsible for determining whether we need to snap to a different screen.
|
||||
int nextPage = getNextPage();
|
||||
IntSet pageIndexesToVerify = IntSet.wrap(nextPage - 1, nextPage + 1);
|
||||
if (isTwoPanelEnabled()) {
|
||||
// If two panel is enabled, users can also drag items to nextPage + 2
|
||||
pageIndexesToVerify.add(nextPage + 2);
|
||||
}
|
||||
|
||||
int touchX = (int) Math.min(centerX, d.x);
|
||||
int touchY = d.y;
|
||||
|
||||
// Go through the pages and check if the dragged item is inside one of them
|
||||
IntSet pageIndexesToVerify = IntSet.wrap(nextPage - 1, nextPage
|
||||
+ (isTwoPanelEnabled() ? 2 : 1));
|
||||
for (int pageIndex : pageIndexesToVerify) {
|
||||
if (layout != null || isPageInTransition()) {
|
||||
break;
|
||||
}
|
||||
|
||||
// When deciding whether to perform a page switch, we need to consider the most extreme
|
||||
// X coordinate between the finger location and the center of the object being dragged.
|
||||
// This is either the max or the min of the two depending on whether dragging to the
|
||||
// left / right, respectively.
|
||||
touchX = ((((pageIndex < nextPage) && !mIsRtl) || pageIndex > nextPage && mIsRtl)
|
||||
? Math.min(d.x, centerX) : Math.max(d.x, centerX));
|
||||
layout = verifyInsidePage(pageIndex, touchX, touchY);
|
||||
}
|
||||
|
||||
@@ -2507,12 +2513,16 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
// on one panel just choose the current page.
|
||||
if (layout == null && nextPage >= 0 && nextPage < getPageCount()) {
|
||||
if (isTwoPanelEnabled()) {
|
||||
// When determining which panel to use within a single screen, we always use
|
||||
// the centroid of the object rather than the finger.
|
||||
touchX = centerX;
|
||||
nextPage = getScreenCenter(getScrollX()) > touchX
|
||||
? (mIsRtl ? nextPage + 1 : nextPage) // left side
|
||||
: (mIsRtl ? nextPage : nextPage + 1); // right side
|
||||
}
|
||||
layout = (CellLayout) getChildAt(nextPage);
|
||||
}
|
||||
|
||||
if (layout != mDragTargetLayout) {
|
||||
setCurrentDropLayout(layout);
|
||||
setCurrentDragOverlappingLayout(layout);
|
||||
|
||||
@@ -52,7 +52,7 @@ public final class FeatureFlags {
|
||||
* Enable moving the QSB on the 0th screen of the workspace. This is not a configuration feature
|
||||
* and should be modified at a project level.
|
||||
*/
|
||||
public static final boolean QSB_ON_FIRST_SCREEN = true;
|
||||
public static final boolean QSB_ON_FIRST_SCREEN = BuildConfig.QSB_ON_FIRST_SCREEN;
|
||||
|
||||
/**
|
||||
* Feature flag to handle define config changes dynamically instead of killing the process.
|
||||
|
||||
@@ -32,7 +32,6 @@ import com.android.launcher3.model.BgDataModel.FixedContainerItems;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.IntSet;
|
||||
import com.android.launcher3.util.LooperExecutor;
|
||||
@@ -174,20 +173,8 @@ public abstract class BaseLoaderResults {
|
||||
ArrayList<LauncherAppWidgetInfo> currentAppWidgets = new ArrayList<>();
|
||||
ArrayList<LauncherAppWidgetInfo> otherAppWidgets = new ArrayList<>();
|
||||
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.NULL_INT_SET, "bind (1) currentScreenIds: "
|
||||
+ currentScreenIds
|
||||
+ ", pointer: "
|
||||
+ mCallbacks
|
||||
+ ", name: "
|
||||
+ mCallbacks.getClass().getName());
|
||||
}
|
||||
filterCurrentWorkspaceItems(currentScreenIds, mWorkspaceItems, currentWorkspaceItems,
|
||||
otherWorkspaceItems);
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.NULL_INT_SET, "bind (2) currentScreenIds: "
|
||||
+ currentScreenIds);
|
||||
}
|
||||
filterCurrentWorkspaceItems(currentScreenIds, mAppWidgets, currentAppWidgets,
|
||||
otherAppWidgets);
|
||||
final InvariantDeviceProfile idp = mApp.getInvariantDeviceProfile();
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.android.launcher3.icons.BitmapInfo;
|
||||
import com.android.launcher3.icons.LauncherIcons;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.IntSet;
|
||||
|
||||
@@ -67,10 +66,6 @@ public class ModelUtils {
|
||||
(lhs, rhs) -> Integer.compare(lhs.container, rhs.container));
|
||||
for (T info : allWorkspaceItems) {
|
||||
if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.NULL_INT_SET, "filterCurrentWorkspaceItems: "
|
||||
+ currentScreenIds);
|
||||
}
|
||||
if (currentScreenIds.contains(info.screenId)) {
|
||||
currentScreenItems.add(info);
|
||||
itemsOnScreen.add(info.id);
|
||||
|
||||
@@ -127,7 +127,6 @@ public final class TestProtocol {
|
||||
public static final String PERMANENT_DIAG_TAG = "TaplTarget";
|
||||
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";
|
||||
public static final String LAUNCHER_NOT_INITIALIZED = "b/215233405";
|
||||
}
|
||||
@@ -17,6 +17,11 @@
|
||||
package com.android.launcher3;
|
||||
|
||||
public final class BuildConfig {
|
||||
public static final String APPLICATION_ID = "com.android.launcher3";
|
||||
public static final boolean DEBUG = false;
|
||||
public static final String APPLICATION_ID = "com.android.launcher3";
|
||||
public static final boolean DEBUG = false;
|
||||
/**
|
||||
* Flag to state if the QSB is on the first screen and placed on the top,
|
||||
* this can be overwritten in other launchers with a different value, if needed.
|
||||
*/
|
||||
public static final boolean QSB_ON_FIRST_SCREEN = true;
|
||||
}
|
||||
@@ -267,6 +267,15 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
<activity-alias android:name="Activity15" android:exported="true"
|
||||
android:label="ThemeIconTestActivity"
|
||||
android:icon="@drawable/test_theme_icon"
|
||||
android:targetActivity="com.android.launcher3.testcomponent.OtherBaseTestingActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
<!-- [b/197780098] Disable eager initialization of Jetpack libraries. -->
|
||||
<provider
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2021 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@android:color/white"/>
|
||||
<foreground>
|
||||
<color android:color="#FFFF0000" />
|
||||
</foreground>
|
||||
<monochrome>
|
||||
<vector android:width="48dp" android:height="48dp" android:viewportWidth="48.0" android:viewportHeight="48.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M0,24L48,24 48,48, 0,48 Z"/>
|
||||
</vector>
|
||||
</monochrome>
|
||||
</adaptive-icon>
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.launcher3.ui.workspace;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.content.ContentProviderClient;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.net.Uri;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.test.filters.LargeTest;
|
||||
|
||||
import com.android.launcher3.BubbleTextView;
|
||||
import com.android.launcher3.icons.ThemedIconDrawable;
|
||||
import com.android.launcher3.tapl.HomeAllApps;
|
||||
import com.android.launcher3.tapl.HomeAppIcon;
|
||||
import com.android.launcher3.ui.AbstractLauncherUiTest;
|
||||
import com.android.launcher3.ui.TaplTestsLauncher3;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Queue;
|
||||
|
||||
/**
|
||||
* Tests for theme icon support in Launcher
|
||||
*
|
||||
* Note running these tests will clear the workspace on the device.
|
||||
*/
|
||||
@LargeTest
|
||||
public class ThemeIconsTest extends AbstractLauncherUiTest {
|
||||
|
||||
private static final String APP_NAME = "ThemeIconTestActivity";
|
||||
|
||||
@Test
|
||||
public void testIconWithoutTheme() throws Exception {
|
||||
setThemeEnabled(false);
|
||||
TaplTestsLauncher3.initialize(this);
|
||||
|
||||
HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
|
||||
allApps.freeze();
|
||||
|
||||
try {
|
||||
HomeAppIcon icon = allApps.getAppIcon(APP_NAME);
|
||||
executeOnLauncher(l -> verifyIconTheme(l.getAppsView(), false));
|
||||
icon.dragToWorkspace(false, false);
|
||||
executeOnLauncher(l -> verifyIconTheme(l.getWorkspace(), false));
|
||||
} finally {
|
||||
allApps.unfreeze();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIconWithTheme() throws Exception {
|
||||
setThemeEnabled(true);
|
||||
TaplTestsLauncher3.initialize(this);
|
||||
|
||||
HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
|
||||
allApps.freeze();
|
||||
|
||||
try {
|
||||
HomeAppIcon icon = allApps.getAppIcon(APP_NAME);
|
||||
executeOnLauncher(l -> verifyIconTheme(l.getAppsView(), false));
|
||||
icon.dragToWorkspace(false, false);
|
||||
executeOnLauncher(l -> verifyIconTheme(l.getWorkspace(), true));
|
||||
} finally {
|
||||
allApps.unfreeze();
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyIconTheme(ViewGroup parent, boolean isThemed) {
|
||||
// Find the app icon
|
||||
Queue<View> viewQueue = new ArrayDeque<>();
|
||||
viewQueue.add(parent);
|
||||
BubbleTextView icon = null;
|
||||
while (!viewQueue.isEmpty()) {
|
||||
View view = viewQueue.poll();
|
||||
if (view instanceof ViewGroup) {
|
||||
parent = (ViewGroup) view;
|
||||
for (int i = parent.getChildCount() - 1; i >= 0; i--) {
|
||||
viewQueue.add(parent.getChildAt(i));
|
||||
}
|
||||
} else if (view instanceof BubbleTextView) {
|
||||
BubbleTextView btv = (BubbleTextView) view;
|
||||
if (APP_NAME.equals(btv.getText())) {
|
||||
icon = btv;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assertNotNull(icon.getIcon());
|
||||
assertEquals(isThemed, icon.getIcon() instanceof ThemedIconDrawable);
|
||||
}
|
||||
|
||||
private void setThemeEnabled(boolean isEnabled) throws Exception {
|
||||
Uri uri = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(mTargetPackage + ".grid_control")
|
||||
.appendPath("set_icon_themed")
|
||||
.build();
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("boolean_value", isEnabled);
|
||||
try (ContentProviderClient client = mTargetContext.getContentResolver()
|
||||
.acquireContentProviderClient(uri)) {
|
||||
int result = client.update(uri, values, null);
|
||||
assertTrue(result > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user