Snap for 9048965 from f5582a668d to udc-release
Change-Id: Iee9fec73af0c6d8028e21265864f84d6329896aa
This commit is contained in:
commit
caf8539fa7
28 files changed
+265
-68
No files matched your search
@@ -41,8 +41,10 @@ import java.util.Set;
|
||||
*/
|
||||
public class WidgetsModel {
|
||||
|
||||
// True is the widget support is disabled.
|
||||
// True if the widget support is disabled.
|
||||
public static final boolean GO_DISABLE_WIDGETS = true;
|
||||
// True if the shortcut support is disabled.
|
||||
public static final boolean GO_DISABLE_SHORTCUTS = true;
|
||||
public static final boolean GO_DISABLE_NOTIFICATION_DOTS = true;
|
||||
|
||||
private static final ArrayList<WidgetsListBaseEntry> EMPTY_WIDGET_LIST = new ArrayList<>();
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.android.launcher3;
|
||||
|
||||
import static com.android.launcher3.logging.KeyboardStateManager.KeyboardState.SHOW;
|
||||
import static com.android.launcher3.util.UiThreadHelper.hideKeyboardAsync;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -33,8 +34,6 @@ import com.android.launcher3.views.ActivityContext;
|
||||
* Note: AppCompatEditText doesn't fully support #displayCompletions and #onCommitCompletion
|
||||
*/
|
||||
public class ExtendedEditText extends EditText {
|
||||
|
||||
private boolean mShowImeAfterFirstLayout;
|
||||
private boolean mForceDisableSuggestions = false;
|
||||
|
||||
/**
|
||||
@@ -85,21 +84,9 @@ public class ExtendedEditText extends EditText {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
if (mShowImeAfterFirstLayout) {
|
||||
// soft input only shows one frame after the layout of the EditText happens,
|
||||
post(() -> {
|
||||
showSoftInput();
|
||||
mShowImeAfterFirstLayout = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void showKeyboard() {
|
||||
mShowImeAfterFirstLayout = !showSoftInput();
|
||||
onKeyboardShown();
|
||||
showSoftInput();
|
||||
}
|
||||
|
||||
public void hideKeyboard() {
|
||||
@@ -107,6 +94,11 @@ public class ExtendedEditText extends EditText {
|
||||
clearFocus();
|
||||
}
|
||||
|
||||
protected void onKeyboardShown() {
|
||||
ActivityContext.lookupContext(getContext()).getStatsLogManager()
|
||||
.keyboardStateManager().setKeyboardState(SHOW);
|
||||
}
|
||||
|
||||
private boolean showSoftInput() {
|
||||
return requestFocus() &&
|
||||
getContext().getSystemService(InputMethodManager.class)
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.launcher3;
|
||||
|
||||
import android.content.ComponentName;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
@@ -43,6 +44,7 @@ public class PendingAddItemInfo extends ItemInfo {
|
||||
/**
|
||||
* Returns shallow copy of the object.
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
public ItemInfo makeShallowCopy() {
|
||||
PendingAddItemInfo itemInfo = new PendingAddItemInfo();
|
||||
|
||||
@@ -227,7 +227,7 @@ public class AllAppsTransitionController
|
||||
@Override
|
||||
public void setStateWithAnimation(LauncherState toState,
|
||||
StateAnimationConfig config, PendingAnimation builder) {
|
||||
if (NORMAL.equals(toState) && mLauncher.isInState(ALL_APPS)) {
|
||||
if (mLauncher.isInState(ALL_APPS) && !ALL_APPS.equals(toState)) {
|
||||
builder.addEndListener(success -> {
|
||||
// Reset pull back progress and alpha after switching states.
|
||||
ALL_APPS_PULL_BACK_TRANSLATION.set(this, 0f);
|
||||
|
||||
@@ -19,6 +19,8 @@ package com.android.launcher3.anim;
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
|
||||
/**
|
||||
* Extension of {@link AnimatorListenerAdapter} for listening for non-cancelled animations
|
||||
*/
|
||||
@@ -27,6 +29,7 @@ public abstract class AnimationSuccessListener extends AnimatorListenerAdapter {
|
||||
protected boolean mCancelled = false;
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
mCancelled = true;
|
||||
}
|
||||
|
||||
@@ -297,6 +297,11 @@ public final class FeatureFlags {
|
||||
public static final BooleanFlag SHOW_SEARCH_EDUCARD_QSB = new DeviceFlag(
|
||||
"SHOW_SEARCH_EDUCARD_QSB", false, "Shows Search Educard for QSB entry in OneSearch.");
|
||||
|
||||
public static final BooleanFlag ENABLE_IME_LATENCY_LOGGER = getDebugFlag(
|
||||
"ENABLE_IME_LATENCY_LOGGER", false,
|
||||
"Enable option to log the keyboard latency for both atomic and controlled keyboard "
|
||||
+ "animations on an EditText");
|
||||
|
||||
public static void initialize(Context context) {
|
||||
synchronized (sDebugFlags) {
|
||||
for (DebugFlag flag : sDebugFlags) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.launcher3.icons;
|
||||
|
||||
import static com.android.launcher3.model.WidgetsModel.GO_DISABLE_WIDGETS;
|
||||
import static com.android.launcher3.model.WidgetsModel.GO_DISABLE_SHORTCUTS;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
@@ -100,7 +100,7 @@ public class ShortcutCachingLogic implements CachingLogic<ShortcutInfo> {
|
||||
* Launcher specific checks
|
||||
*/
|
||||
public static Drawable getIcon(Context context, ShortcutInfo shortcutInfo, int density) {
|
||||
if (GO_DISABLE_WIDGETS) {
|
||||
if (GO_DISABLE_SHORTCUTS) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.logging;
|
||||
|
||||
import static com.android.launcher3.logging.KeyboardStateManager.KeyboardState.NO_IME_ACTION;
|
||||
|
||||
import android.os.SystemClock;
|
||||
|
||||
/**
|
||||
* Class to maintain keyboard states.
|
||||
*/
|
||||
public class KeyboardStateManager {
|
||||
private long mUpdatedTime;
|
||||
|
||||
public enum KeyboardState {
|
||||
NO_IME_ACTION,
|
||||
SHOW,
|
||||
HIDE,
|
||||
}
|
||||
|
||||
private KeyboardState mKeyboardState;
|
||||
|
||||
public KeyboardStateManager() {
|
||||
mKeyboardState = NO_IME_ACTION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns time when keyboard state was updated.
|
||||
*/
|
||||
public long getLastUpdatedTime() {
|
||||
return mUpdatedTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current keyboard state.
|
||||
*/
|
||||
public KeyboardState getKeyboardState() {
|
||||
return mKeyboardState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter method to set keyboard state.
|
||||
*/
|
||||
public void setKeyboardState(KeyboardState keyboardState) {
|
||||
mUpdatedTime = SystemClock.elapsedRealtime();
|
||||
mKeyboardState = keyboardState;
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,7 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||
private InstanceId mInstanceId;
|
||||
|
||||
protected @Nullable ActivityContext mActivityContext = null;
|
||||
private KeyboardStateManager mKeyboardStateManager;
|
||||
|
||||
/**
|
||||
* Returns event enum based on the two state transition information when swipe
|
||||
@@ -816,6 +817,16 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||
return logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a singleton KeyboardStateManager.
|
||||
*/
|
||||
public KeyboardStateManager keyboardStateManager() {
|
||||
if (mKeyboardStateManager == null) {
|
||||
mKeyboardStateManager = new KeyboardStateManager();
|
||||
}
|
||||
return mKeyboardStateManager;
|
||||
}
|
||||
|
||||
protected StatsLogger createLogger() {
|
||||
return new StatsLogger() {
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ package com.android.launcher3.model;
|
||||
|
||||
import static android.content.pm.LauncherApps.ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY;
|
||||
|
||||
import static com.android.launcher3.model.WidgetsModel.GO_DISABLE_WIDGETS;
|
||||
import static com.android.launcher3.model.WidgetsModel.GO_DISABLE_SHORTCUTS;
|
||||
import static com.android.launcher3.shortcuts.ShortcutRequest.PINNED;
|
||||
|
||||
import static java.util.stream.Collectors.groupingBy;
|
||||
@@ -286,7 +286,7 @@ public class BgDataModel {
|
||||
* shortcuts and unpinning any extra shortcuts.
|
||||
*/
|
||||
public synchronized void updateShortcutPinnedState(Context context, UserHandle user) {
|
||||
if (GO_DISABLE_WIDGETS) {
|
||||
if (GO_DISABLE_SHORTCUTS) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import android.graphics.Point;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.launcher3.InvariantDeviceProfile;
|
||||
@@ -47,6 +48,7 @@ import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.widget.LauncherAppWidgetProviderInfo;
|
||||
import com.android.launcher3.widget.WidgetManagerHelper;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -776,17 +778,6 @@ public class GridSizeMigrationTaskV2 {
|
||||
values.put(LauncherSettings.Favorites.SPANY, spanY);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should return an id that should be the same for two folders containing the
|
||||
* same elements.
|
||||
*/
|
||||
private String getFolderMigrationId() {
|
||||
return mFolderItems.keySet().stream()
|
||||
.map(intentString -> mFolderItems.get(intentString).size() + intentString)
|
||||
.sorted()
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
/** This id is not used in the DB is only used while doing the migration and it identifies
|
||||
* an entry on each workspace. For example two calculator icons would have the same
|
||||
* migration id even thought they have different database ids.
|
||||
@@ -797,9 +788,47 @@ public class GridSizeMigrationTaskV2 {
|
||||
return getFolderMigrationId();
|
||||
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
|
||||
return mProvider;
|
||||
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
|
||||
final String intentStr = cleanIntentString(mIntent);
|
||||
try {
|
||||
Intent i = Intent.parseUri(intentStr, 0);
|
||||
return Objects.requireNonNull(i.getComponent()).toString();
|
||||
} catch (Exception e) {
|
||||
return intentStr;
|
||||
}
|
||||
default:
|
||||
return mIntent;
|
||||
return cleanIntentString(mIntent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should return an id that should be the same for two folders containing the
|
||||
* same elements.
|
||||
*/
|
||||
@NonNull
|
||||
private String getFolderMigrationId() {
|
||||
return mFolderItems.keySet().stream()
|
||||
.map(intentString -> mFolderItems.get(intentString).size()
|
||||
+ cleanIntentString(intentString))
|
||||
.sorted()
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
/**
|
||||
* This is needed because sourceBounds can change and make the id of two equal items
|
||||
* different.
|
||||
*/
|
||||
@NonNull
|
||||
private String cleanIntentString(@NonNull String intentStr) {
|
||||
try {
|
||||
Intent i = Intent.parseUri(intentStr, 0);
|
||||
i.setSourceBounds(null);
|
||||
return i.toURI();
|
||||
} catch (URISyntaxException e) {
|
||||
Log.e(TAG, "Unable to parse Intent string", e);
|
||||
return intentStr;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,6 +288,7 @@ public class ItemInstallQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Intent getIntent() {
|
||||
return intent;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
@@ -65,6 +66,7 @@ public class AppInfo extends ItemInfoWithIcon implements WorkspaceItemFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Intent getIntent() {
|
||||
return intent;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import static com.android.launcher3.logger.LauncherAtom.Attribute.SUGGESTED_LABE
|
||||
|
||||
import android.os.Process;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
@@ -154,7 +155,7 @@ public class FolderInfo extends ItemInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddToDatabase(ContentWriter writer) {
|
||||
public void onAddToDatabase(@NonNull ContentWriter writer) {
|
||||
super.onAddToDatabase(writer);
|
||||
writer.put(LauncherSettings.Favorites.TITLE, title)
|
||||
.put(LauncherSettings.Favorites.OPTIONS, options);
|
||||
@@ -206,8 +207,9 @@ public class FolderInfo extends ItemInfo {
|
||||
return String.format("%s; labelState=%s", super.dumpProperties(), getLabelState());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public LauncherAtom.ItemInfo buildProto(FolderInfo fInfo) {
|
||||
public LauncherAtom.ItemInfo buildProto(@Nullable FolderInfo fInfo) {
|
||||
FolderIcon.Builder folderIcon = FolderIcon.newBuilder()
|
||||
.setCardinality(contents.size());
|
||||
if (LabelState.SUGGESTED.equals(getLabelState())) {
|
||||
@@ -261,6 +263,7 @@ public class FolderInfo extends ItemInfo {
|
||||
: LabelState.SUGGESTED;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ItemInfo makeShallowCopy() {
|
||||
FolderInfo folderInfo = new FolderInfo();
|
||||
@@ -272,6 +275,7 @@ public class FolderInfo extends ItemInfo {
|
||||
/**
|
||||
* Returns {@link LauncherAtom.FolderIcon} wrapped as {@link LauncherAtom.ItemInfo} for logging.
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
public LauncherAtom.ItemInfo buildProto() {
|
||||
return buildProto(null);
|
||||
|
||||
@@ -42,6 +42,7 @@ import android.content.Intent;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
@@ -141,30 +142,34 @@ public class ItemInfo {
|
||||
/**
|
||||
* Title of the item
|
||||
*/
|
||||
@Nullable
|
||||
public CharSequence title;
|
||||
|
||||
/**
|
||||
* Content description of the item.
|
||||
*/
|
||||
@Nullable
|
||||
public CharSequence contentDescription;
|
||||
|
||||
/**
|
||||
* When the instance is created using {@link #copyFrom}, this field is used to keep track of
|
||||
* original {@link ComponentName}.
|
||||
*/
|
||||
@Nullable
|
||||
private ComponentName mComponentName;
|
||||
|
||||
@NonNull
|
||||
public UserHandle user;
|
||||
|
||||
public ItemInfo() {
|
||||
user = Process.myUserHandle();
|
||||
}
|
||||
|
||||
protected ItemInfo(ItemInfo info) {
|
||||
protected ItemInfo(@NonNull final ItemInfo info) {
|
||||
copyFrom(info);
|
||||
}
|
||||
|
||||
public void copyFrom(ItemInfo info) {
|
||||
public void copyFrom(@NonNull final ItemInfo info) {
|
||||
id = info.id;
|
||||
title = info.title;
|
||||
cellX = info.cellX;
|
||||
@@ -182,6 +187,7 @@ public class ItemInfo {
|
||||
mComponentName = info.getTargetComponent();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Intent getIntent() {
|
||||
return null;
|
||||
}
|
||||
@@ -209,7 +215,7 @@ public class ItemInfo {
|
||||
: null;
|
||||
}
|
||||
|
||||
public void writeToValues(ContentWriter writer) {
|
||||
public void writeToValues(@NonNull final ContentWriter writer) {
|
||||
writer.put(LauncherSettings.Favorites.ITEM_TYPE, itemType)
|
||||
.put(LauncherSettings.Favorites.CONTAINER, container)
|
||||
.put(LauncherSettings.Favorites.SCREEN, screenId)
|
||||
@@ -220,7 +226,7 @@ public class ItemInfo {
|
||||
.put(LauncherSettings.Favorites.RANK, rank);
|
||||
}
|
||||
|
||||
public void readFromValues(ContentValues values) {
|
||||
public void readFromValues(@NonNull final ContentValues values) {
|
||||
itemType = values.getAsInteger(LauncherSettings.Favorites.ITEM_TYPE);
|
||||
container = values.getAsInteger(LauncherSettings.Favorites.CONTAINER);
|
||||
screenId = values.getAsInteger(LauncherSettings.Favorites.SCREEN);
|
||||
@@ -234,7 +240,7 @@ public class ItemInfo {
|
||||
/**
|
||||
* Write the fields of this item to the DB
|
||||
*/
|
||||
public void onAddToDatabase(ContentWriter writer) {
|
||||
public void onAddToDatabase(@NonNull final ContentWriter writer) {
|
||||
if (Workspace.EXTRA_EMPTY_SCREEN_IDS.contains(screenId)) {
|
||||
// We should never persist an item on the extra empty screen.
|
||||
throw new RuntimeException("Screen id should not be extra empty screen: " + screenId);
|
||||
@@ -245,10 +251,12 @@ public class ItemInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public final String toString() {
|
||||
return getClass().getSimpleName() + "(" + dumpProperties() + ")";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
protected String dumpProperties() {
|
||||
return "id=" + id
|
||||
+ " type=" + LauncherSettings.Favorites.itemTypeToString(itemType)
|
||||
@@ -288,14 +296,17 @@ public class ItemInfo {
|
||||
/**
|
||||
* Creates {@link LauncherAtom.ItemInfo} with important fields and parent container info.
|
||||
*/
|
||||
@NonNull
|
||||
public LauncherAtom.ItemInfo buildProto() {
|
||||
return buildProto(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates {@link LauncherAtom.ItemInfo} with important fields and parent container info.
|
||||
* @param fInfo
|
||||
*/
|
||||
public LauncherAtom.ItemInfo buildProto(FolderInfo fInfo) {
|
||||
@NonNull
|
||||
public LauncherAtom.ItemInfo buildProto(@Nullable final FolderInfo fInfo) {
|
||||
LauncherAtom.ItemInfo.Builder itemBuilder = getDefaultItemInfoBuilder();
|
||||
Optional<ComponentName> nullableComponent = Optional.ofNullable(getTargetComponent());
|
||||
switch (itemType) {
|
||||
@@ -373,6 +384,7 @@ public class ItemInfo {
|
||||
return itemBuilder.build();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
protected LauncherAtom.ItemInfo.Builder getDefaultItemInfoBuilder() {
|
||||
LauncherAtom.ItemInfo.Builder itemBuilder = LauncherAtom.ItemInfo.newBuilder();
|
||||
itemBuilder.setIsWork(!Process.myUserHandle().equals(user));
|
||||
@@ -383,6 +395,7 @@ public class ItemInfo {
|
||||
/**
|
||||
* Returns {@link ContainerInfo} used when logging this item.
|
||||
*/
|
||||
@NonNull
|
||||
public ContainerInfo getContainerInfo() {
|
||||
switch (container) {
|
||||
case CONTAINER_HOTSEAT:
|
||||
@@ -447,6 +460,7 @@ public class ItemInfo {
|
||||
* Returns non-AOSP container wrapped by {@link ExtendedContainers} object. Should be overridden
|
||||
* by build variants.
|
||||
*/
|
||||
@NonNull
|
||||
protected ExtendedContainers getExtendedContainer() {
|
||||
return ExtendedContainers.getDefaultInstance();
|
||||
}
|
||||
@@ -454,6 +468,7 @@ public class ItemInfo {
|
||||
/**
|
||||
* Returns shallow copy of the object.
|
||||
*/
|
||||
@NonNull
|
||||
public ItemInfo makeShallowCopy() {
|
||||
ItemInfo itemInfo = new ItemInfo();
|
||||
itemInfo.copyFrom(this);
|
||||
@@ -463,7 +478,8 @@ public class ItemInfo {
|
||||
/**
|
||||
* Sets the title of the item and writes to DB model if needed.
|
||||
*/
|
||||
public void setTitle(CharSequence title, ModelWriter modelWriter) {
|
||||
public void setTitle(@Nullable final CharSequence title,
|
||||
@Nullable final ModelWriter modelWriter) {
|
||||
this.title = title;
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Process;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
@@ -191,7 +192,7 @@ public class LauncherAppWidgetInfo extends ItemInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddToDatabase(ContentWriter writer) {
|
||||
public void onAddToDatabase(@NonNull ContentWriter writer) {
|
||||
super.onAddToDatabase(writer);
|
||||
writer.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId)
|
||||
.put(LauncherSettings.Favorites.APPWIDGET_PROVIDER, providerName.flattenToString())
|
||||
@@ -283,8 +284,9 @@ public class LauncherAppWidgetInfo extends ItemInfo {
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public LauncherAtom.ItemInfo buildProto(FolderInfo folderInfo) {
|
||||
public LauncherAtom.ItemInfo buildProto(@Nullable FolderInfo folderInfo) {
|
||||
LauncherAtom.ItemInfo info = super.buildProto(folderInfo);
|
||||
return info.toBuilder()
|
||||
.setWidget(info.getWidget().toBuilder().setWidgetFeatures(widgetFeatures))
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.graphics.drawable.Icon;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
@@ -70,7 +71,7 @@ public class SearchActionItemInfo extends ItemInfoWithIcon implements WorkspaceI
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(com.android.launcher3.model.data.ItemInfo info) {
|
||||
public void copyFrom(@NonNull com.android.launcher3.model.data.ItemInfo info) {
|
||||
super.copyFrom(info);
|
||||
SearchActionItemInfo itemInfo = (SearchActionItemInfo) info;
|
||||
this.mFallbackPackageName = itemInfo.mFallbackPackageName;
|
||||
@@ -91,6 +92,7 @@ public class SearchActionItemInfo extends ItemInfoWithIcon implements WorkspaceI
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Intent getIntent() {
|
||||
return mIntent;
|
||||
}
|
||||
@@ -131,8 +133,9 @@ public class SearchActionItemInfo extends ItemInfoWithIcon implements WorkspaceI
|
||||
return new SearchActionItemInfo(this);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ItemInfo buildProto(FolderInfo fInfo) {
|
||||
public ItemInfo buildProto(@Nullable FolderInfo fInfo) {
|
||||
SearchActionItem.Builder itemBuilder = SearchActionItem.newBuilder()
|
||||
.setPackageName(mFallbackPackageName);
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.content.pm.ShortcutInfo;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
import com.android.launcher3.LauncherSettings.Favorites;
|
||||
@@ -130,7 +131,7 @@ public class WorkspaceItemInfo extends ItemInfoWithIcon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddToDatabase(ContentWriter writer) {
|
||||
public void onAddToDatabase(@NonNull ContentWriter writer) {
|
||||
super.onAddToDatabase(writer);
|
||||
writer.put(Favorites.TITLE, title)
|
||||
.put(Favorites.INTENT, getIntent())
|
||||
@@ -147,6 +148,7 @@ public class WorkspaceItemInfo extends ItemInfoWithIcon {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Intent getIntent() {
|
||||
return intent;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.launcher3.shortcuts;
|
||||
|
||||
import static com.android.launcher3.model.WidgetsModel.GO_DISABLE_WIDGETS;
|
||||
import static com.android.launcher3.model.WidgetsModel.GO_DISABLE_SHORTCUTS;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
@@ -46,7 +46,7 @@ public class ShortcutRequest {
|
||||
| ShortcutQuery.FLAG_MATCH_MANIFEST;
|
||||
public static final int PINNED = ShortcutQuery.FLAG_MATCH_PINNED;
|
||||
|
||||
private final ShortcutQuery mQuery = GO_DISABLE_WIDGETS ? null : new ShortcutQuery();
|
||||
private final ShortcutQuery mQuery = GO_DISABLE_SHORTCUTS ? null : new ShortcutQuery();
|
||||
|
||||
private final Context mContext;
|
||||
private final UserHandle mUserHandle;
|
||||
@@ -73,7 +73,7 @@ public class ShortcutRequest {
|
||||
* @return A list of ShortcutInfo's associated with the given package.
|
||||
*/
|
||||
public ShortcutRequest forPackage(String packageName, @Nullable List<String> shortcutIds) {
|
||||
if (!GO_DISABLE_WIDGETS && packageName != null) {
|
||||
if (!GO_DISABLE_SHORTCUTS && packageName != null) {
|
||||
mQuery.setPackage(packageName);
|
||||
mQuery.setShortcutIds(shortcutIds);
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class ShortcutRequest {
|
||||
}
|
||||
|
||||
public ShortcutRequest withContainer(@Nullable ComponentName activity) {
|
||||
if (!GO_DISABLE_WIDGETS) {
|
||||
if (!GO_DISABLE_SHORTCUTS) {
|
||||
if (activity == null) {
|
||||
mFailed = true;
|
||||
} else {
|
||||
@@ -92,7 +92,7 @@ public class ShortcutRequest {
|
||||
}
|
||||
|
||||
public QueryResult query(int flags) {
|
||||
if (GO_DISABLE_WIDGETS || mFailed) {
|
||||
if (GO_DISABLE_SHORTCUTS || mFailed) {
|
||||
return QueryResult.DEFAULT;
|
||||
}
|
||||
mQuery.setQueryFlags(flags);
|
||||
@@ -108,7 +108,7 @@ public class ShortcutRequest {
|
||||
|
||||
public static class QueryResult extends ArrayList<ShortcutInfo> {
|
||||
|
||||
static final QueryResult DEFAULT = new QueryResult(GO_DISABLE_WIDGETS);
|
||||
static final QueryResult DEFAULT = new QueryResult(GO_DISABLE_SHORTCUTS);
|
||||
|
||||
private final boolean mWasSuccess;
|
||||
|
||||
|
||||
@@ -345,6 +345,7 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
super.onAnimationCancel(animation);
|
||||
onStateTransitionFailed(state);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -40,4 +40,9 @@ public class LogConfig {
|
||||
* When turned on, we enable suggest related logging.
|
||||
*/
|
||||
public static final String SEARCH_LOGGING = "SearchLogging";
|
||||
|
||||
/**
|
||||
* When turned on, we enable IME related latency related logging.
|
||||
*/
|
||||
public static final String IME_LATENCY_LOGGING = "ImeLatencyLogging";
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class ShortcutUtil {
|
||||
* Returns true when we should show depp shortcuts in shortcut menu for the item.
|
||||
*/
|
||||
public static boolean supportsDeepShortcuts(ItemInfo info) {
|
||||
return isActive(info) && isApp(info) && !WidgetsModel.GO_DISABLE_WIDGETS;
|
||||
return isActive(info) && isApp(info) && !WidgetsModel.GO_DISABLE_SHORTCUTS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.android.launcher3.util;
|
||||
|
||||
import static com.android.launcher3.logging.KeyboardStateManager.KeyboardState.HIDE;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_KEYBOARD_CLOSED;
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
|
||||
@@ -25,7 +26,6 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowInsetsController;
|
||||
@@ -64,6 +64,7 @@ public class UiThreadHelper {
|
||||
WindowInsets insets = root.getRootWindowInsets();
|
||||
boolean isImeShown = insets != null && insets.isVisible(WindowInsets.Type.ime());
|
||||
if (wic != null && isImeShown) {
|
||||
activityContext.getStatsLogManager().keyboardStateManager().setKeyboardState(HIDE);
|
||||
// this method cannot be called cross threads
|
||||
wic.hide(WindowInsets.Type.ime());
|
||||
activityContext.getStatsLogManager().logger()
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
package com.android.launcher3.views;
|
||||
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP;
|
||||
import static com.android.launcher3.model.WidgetsModel.GO_DISABLE_WIDGETS;
|
||||
import static com.android.launcher3.model.WidgetsModel.GO_DISABLE_SHORTCUTS;
|
||||
|
||||
import android.app.ActivityOptions;
|
||||
import android.content.ActivityNotFoundException;
|
||||
@@ -190,7 +190,7 @@ public interface AppLauncher extends ActivityContext {
|
||||
*/
|
||||
default void startShortcut(String packageName, String id, Rect sourceBounds,
|
||||
Bundle startActivityOptions, UserHandle user) {
|
||||
if (GO_DISABLE_WIDGETS) {
|
||||
if (GO_DISABLE_SHORTCUTS) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -19,6 +19,9 @@ import android.appwidget.AppWidgetHostView;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
import com.android.launcher3.PendingAddItemInfo;
|
||||
import com.android.launcher3.logger.LauncherAtom;
|
||||
@@ -66,8 +69,9 @@ public class PendingAddWidgetInfo extends PendingAddItemInfo {
|
||||
return WidgetSizes.getWidgetSizeOptions(context, componentName, spanX, spanY);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public LauncherAtom.ItemInfo buildProto(FolderInfo folderInfo) {
|
||||
public LauncherAtom.ItemInfo buildProto(@Nullable FolderInfo folderInfo) {
|
||||
LauncherAtom.ItemInfo info = super.buildProto(folderInfo);
|
||||
return info.toBuilder()
|
||||
.addItemAttributes(LauncherAppWidgetInfo.getAttribute(sourceContainer))
|
||||
|
||||
@@ -62,6 +62,8 @@ public class WidgetsModel {
|
||||
|
||||
// True is the widget support is disabled.
|
||||
public static final boolean GO_DISABLE_WIDGETS = false;
|
||||
// True is the shortcut support is disabled.
|
||||
public static final boolean GO_DISABLE_SHORTCUTS = false;
|
||||
public static final boolean GO_DISABLE_NOTIFICATION_DOTS = false;
|
||||
|
||||
private static final String TAG = "WidgetsModel";
|
||||
|
||||
@@ -49,6 +49,7 @@ public class WorkProfileTest extends AbstractLauncherUiTest {
|
||||
|
||||
private int mProfileUserId;
|
||||
private boolean mWorkProfileSetupSuccessful;
|
||||
private final String TAG = "WorkProfileTest";
|
||||
|
||||
@Before
|
||||
@Override
|
||||
@@ -57,18 +58,17 @@ public class WorkProfileTest extends AbstractLauncherUiTest {
|
||||
String output =
|
||||
mDevice.executeShellCommand(
|
||||
"pm create-user --profileOf 0 --managed TestProfile");
|
||||
Log.d("b/203817455", "pm create-user; output: " + output);
|
||||
|
||||
if (output.startsWith("Success")){
|
||||
assertTrue("Failed to create work profile", output.startsWith("Success"));
|
||||
mWorkProfileSetupSuccessful = true;
|
||||
} else {
|
||||
return; // no need to setup launcher since all tests will skip.
|
||||
}
|
||||
// b/203817455
|
||||
updateWorkProfileSetupSuccessful("pm create-user", output);
|
||||
|
||||
String[] tokens = output.split("\\s+");
|
||||
mProfileUserId = Integer.parseInt(tokens[tokens.length - 1]);
|
||||
mDevice.executeShellCommand("am start-user " + mProfileUserId);
|
||||
output = mDevice.executeShellCommand("am start-user " + mProfileUserId);
|
||||
updateWorkProfileSetupSuccessful("am start-user", output);
|
||||
|
||||
if (!mWorkProfileSetupSuccessful) {
|
||||
return; // no need to setup launcher since all tests will skip.
|
||||
}
|
||||
|
||||
mDevice.pressHome();
|
||||
waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
|
||||
@@ -109,6 +109,7 @@ public class WorkProfileTest extends AbstractLauncherUiTest {
|
||||
@ScreenRecord // b/242163855
|
||||
public void workTabExists() {
|
||||
assumeTrue(mWorkProfileSetupSuccessful);
|
||||
waitForWorkTabSetup();
|
||||
waitForLauncherCondition("Personal tab is missing",
|
||||
launcher -> launcher.getAppsView().isPersonalTabVisible(),
|
||||
LauncherInstrumentation.WAIT_TIME_MS);
|
||||
@@ -185,4 +186,14 @@ public class WorkProfileTest extends AbstractLauncherUiTest {
|
||||
}
|
||||
}, LauncherInstrumentation.WAIT_TIME_MS);
|
||||
}
|
||||
|
||||
private void updateWorkProfileSetupSuccessful(String cli, String output) {
|
||||
Log.d(TAG, "updateWorkProfileSetupSuccessful, cli=" + cli + " " + "output=" + output);
|
||||
if (output.startsWith("Success")) {
|
||||
assertTrue(output, output.startsWith("Success"));
|
||||
mWorkProfileSetupSuccessful = true;
|
||||
} else {
|
||||
mWorkProfileSetupSuccessful = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,18 +15,56 @@
|
||||
*/
|
||||
package com.android.launcher3.tapl;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.test.uiautomator.By;
|
||||
import androidx.test.uiautomator.BySelector;
|
||||
import androidx.test.uiautomator.UiObject2;
|
||||
import androidx.test.uiautomator.Until;
|
||||
|
||||
/**
|
||||
* Operations on home screen qsb.
|
||||
*/
|
||||
public class HomeQsb {
|
||||
|
||||
private final LauncherInstrumentation mLauncher;
|
||||
private static final String ASSISTANT_APP_PACKAGE = "com.google.android.googlequicksearchbox";
|
||||
private static final String ASSISTANT_ICON_RES_ID = "mic_icon";
|
||||
|
||||
|
||||
HomeQsb(LauncherInstrumentation launcher) {
|
||||
mLauncher = launcher;
|
||||
mLauncher.waitForLauncherObject("search_container_hotseat");
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch assistant app by tapping mic icon on qsb.
|
||||
*/
|
||||
@NonNull
|
||||
public LaunchedAppState launchAssistant() {
|
||||
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
|
||||
"want to click assistant mic icon button");
|
||||
LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
|
||||
UiObject2 assistantIcon = mLauncher.waitForLauncherObject(ASSISTANT_ICON_RES_ID);
|
||||
|
||||
LauncherInstrumentation.log("HomeQsb.launchAssistant before click "
|
||||
+ assistantIcon.getVisibleCenter() + " in "
|
||||
+ mLauncher.getVisibleBounds(assistantIcon));
|
||||
|
||||
mLauncher.clickLauncherObject(assistantIcon);
|
||||
|
||||
try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("clicked")) {
|
||||
// assert Assistant App Launched
|
||||
BySelector selector = By.pkg(ASSISTANT_APP_PACKAGE);
|
||||
mLauncher.assertTrue(
|
||||
"assistant app didn't start: (" + selector + ")",
|
||||
mLauncher.getDevice().wait(Until.hasObject(selector),
|
||||
LauncherInstrumentation.WAIT_TIME_MS)
|
||||
);
|
||||
return new LaunchedAppState(mLauncher);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show search result page from tapping qsb.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user