Fix double logging for wallpaper settings icon activation

Bug: 137957099

Change-Id: Id95fa026c1e6f177ffbb03e99cc18ef03e9a37b5
This commit is contained in:
Hyunyoung Song 2020-06-06 14:44:27 -07:00
parent f6858198b9
commit f26c7930de
6 changed files with 32 additions and 5 deletions

View File

@ -52,6 +52,7 @@ message ContainerInfo {
PredictionContainer prediction_container = 6;
SearchResultContainer search_result_container = 7;
ShortcutsContainer shortcuts_container = 8;
SettingsContainer settings_container = 9;
}
}
@ -75,6 +76,11 @@ message SearchResultContainer {
message ShortcutsContainer {
}
// Container for generic system shortcuts for launcher specific settings.
// Typically shown up as popup window by longpressing on empty space on workspace.
message SettingsContainer {
}
enum Origin {
UNKNOWN = 0;
DEFAULT_LAYOUT = 1; // icon automatically placed in workspace, folder, hotseat

View File

@ -187,8 +187,9 @@ public abstract class BaseDraggingActivity extends BaseActivity
sourceContainer);
}
getUserEventDispatcher().logAppLaunch(v, intent, user);
getStatsLogManager().log(LAUNCHER_APP_LAUNCH_TAP, item == null ? null
: item.buildProto());
if (item != null) {
getStatsLogManager().log(LAUNCHER_APP_LAUNCH_TAP, item.buildProto());
}
return true;
} catch (NullPointerException|ActivityNotFoundException|SecurityException e) {
Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();

View File

@ -162,6 +162,7 @@ public class LauncherSettings {
// Represents search results view.
public static final int CONTAINER_SEARCH_RESULTS = -106;
public static final int CONTAINER_SHORTCUTS = -107;
public static final int CONTAINER_SETTINGS = -108;
public static final String containerToString(int container) {
switch (container) {

View File

@ -38,6 +38,9 @@ public class StatsLogManager implements ResourceBasedOverride {
}
public enum LauncherEvent implements EventEnum {
/* Used to prevent double logging. */
IGNORE(-1),
@UiEvent(doc = "App launched from workspace, hotseat or folder in launcher")
LAUNCHER_APP_LAUNCH_TAP(338),

View File

@ -22,6 +22,7 @@ import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_PREDICTION;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_SEARCH_RESULTS;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_SETTINGS;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_SHORTCUTS;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_TRAY;
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
@ -46,6 +47,7 @@ import com.android.launcher3.logger.LauncherAtom.AllAppsContainer;
import com.android.launcher3.logger.LauncherAtom.ContainerInfo;
import com.android.launcher3.logger.LauncherAtom.PredictionContainer;
import com.android.launcher3.logger.LauncherAtom.SearchResultContainer;
import com.android.launcher3.logger.LauncherAtom.SettingsContainer;
import com.android.launcher3.logger.LauncherAtom.ShortcutsContainer;
import com.android.launcher3.util.ContentWriter;
@ -369,6 +371,10 @@ public class ItemInfo {
return ContainerInfo.newBuilder()
.setShortcutsContainer(ShortcutsContainer.getDefaultInstance())
.build();
case CONTAINER_SETTINGS:
return ContainerInfo.newBuilder()
.setSettingsContainer(SettingsContainer.getDefaultInstance())
.build();
}
return ContainerInfo.getDefaultInstance();
}

View File

@ -17,8 +17,8 @@ package com.android.launcher3.views;
import static com.android.launcher3.Utilities.EXTRA_WALLPAPER_FLAVOR;
import static com.android.launcher3.Utilities.EXTRA_WALLPAPER_OFFSET;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SETTINGS_BUTTON_TAP_OR_LONGPRESS;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WALLPAPER_BUTTON_TAP_OR_LONGPRESS;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WIDGETSTRAY_BUTTON_TAP_OR_LONGPRESS;
import android.content.Context;
@ -38,10 +38,12 @@ import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.logging.StatsLogManager.EventEnum;
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.popup.ArrowPopup;
import com.android.launcher3.shortcuts.DeepShortcutView;
import com.android.launcher3.testing.TestLogging;
@ -157,7 +159,7 @@ public class OptionsPopupView extends ArrowPopup
int resDrawable = Utilities.existsStyleWallpapers(launcher) ?
R.drawable.ic_palette : R.drawable.ic_wallpaper;
options.add(new OptionItem(resString, resDrawable,
LAUNCHER_WALLPAPER_BUTTON_TAP_OR_LONGPRESS,
IGNORE,
OptionsPopupView::startWallpaperPicker));
if (!WidgetsModel.GO_DISABLE_WIDGETS) {
options.add(new OptionItem(R.string.widget_button_text, R.drawable.ic_widget,
@ -218,7 +220,15 @@ public class OptionsPopupView extends ArrowPopup
if (!TextUtils.isEmpty(pickerPackage)) {
intent.setPackage(pickerPackage);
}
return launcher.startActivitySafely(v, intent, null, null);
return launcher.startActivitySafely(v, intent, dummyInfo(intent), null);
}
static WorkspaceItemInfo dummyInfo(Intent intent) {
WorkspaceItemInfo dummyInfo = new WorkspaceItemInfo();
dummyInfo.intent = intent;
dummyInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
dummyInfo.container = LauncherSettings.Favorites.CONTAINER_SETTINGS;
return dummyInfo;
}
public static class OptionItem {