Merging from ub-launcher3-master @ build 6269120

Bug:150504032
Test: manual, presubmit on the source branch
x20/teams/android-launcher/merge/ub-launcher3-master_rvc-dev_6269120.html

Change-Id: I01aa0a42e4d15cb00a723cb6dd50625ad743b722
diff --git a/res/menu/bottom_navigation_menu.xml b/res/menu/bottom_navigation_menu.xml
index d477aaf..b64bf8d 100644
--- a/res/menu/bottom_navigation_menu.xml
+++ b/res/menu/bottom_navigation_menu.xml
@@ -17,19 +17,19 @@
 <menu xmlns:android="http://schemas.android.com/apk/res/android">
     <!-- TODO (santie): replace icons with real ones when available -->
     <item
+        android:id="@+id/nav_wallpaper"
+        android:title="@string/wallpaper_title"
+        android:icon="@drawable/ic_nav_wallpaper" />
+    <item
         android:id="@+id/nav_theme"
         android:title="@string/theme_title"
         android:icon="@drawable/ic_nav_theme" />
     <item
-        android:id="@+id/nav_clock"
-        android:title="@string/clock_title"
-        android:icon="@drawable/ic_nav_clock" />
-    <item
         android:id="@+id/nav_grid"
         android:title="@string/grid_title"
         android:icon="@drawable/ic_nav_grid" />
     <item
-        android:id="@+id/nav_wallpaper"
-        android:title="@string/wallpaper_title"
-        android:icon="@drawable/ic_nav_wallpaper" />
+        android:id="@+id/nav_clock"
+        android:title="@string/clock_title"
+        android:icon="@drawable/ic_nav_clock" />
 </menu>
\ No newline at end of file
diff --git a/src/com/android/customization/module/StatsLogUserEventLogger.java b/src/com/android/customization/module/StatsLogUserEventLogger.java
index bf4d069..5649c5e 100644
--- a/src/com/android/customization/module/StatsLogUserEventLogger.java
+++ b/src/com/android/customization/module/StatsLogUserEventLogger.java
@@ -73,6 +73,25 @@
     }
 
     @Override
+    public void logLiveWallpaperInfoSelected(String collectionId, @Nullable String wallpaperId) {
+        SysUiStatsLog.write(STYLE_UI_CHANGED, StyleEnums.LIVE_WALLPAPER_INFO_SELECT,
+                0, 0, 0, 0, 0,
+                collectionId.hashCode(),
+                wallpaperId != null ? wallpaperId.hashCode() : 0,
+                0, 0);
+    }
+
+    @Override
+    public void logLiveWallpaperCustomizeSelected(String collectionId,
+            @Nullable String wallpaperId) {
+        SysUiStatsLog.write(STYLE_UI_CHANGED, StyleEnums.LIVE_WALLPAPER_CUSTOMIZE_SELECT,
+                0, 0, 0, 0, 0,
+                collectionId.hashCode(),
+                wallpaperId != null ? wallpaperId.hashCode() : 0,
+                0, 0);
+    }
+
+    @Override
     public void logWallpaperSet(String collectionId, @Nullable String wallpaperId) {
         SysUiStatsLog.write(STYLE_UI_CHANGED, StyleEnums.WALLPAPER_APPLIED,
                 0, 0, 0, 0, 0,
diff --git a/src/com/android/customization/picker/CustomizationPickerActivity.java b/src/com/android/customization/picker/CustomizationPickerActivity.java
index 7da0d74..86a0bf6 100644
--- a/src/com/android/customization/picker/CustomizationPickerActivity.java
+++ b/src/com/android/customization/picker/CustomizationPickerActivity.java
@@ -130,10 +130,9 @@
 
                 // Navigate to the Wallpaper tab if we started directly from launcher, otherwise
                 // start at the Styles tab
-                int section = WALLPAPER_FOCUS.equals(getIntent()
-                    .getStringExtra(WALLPAPER_FLAVOR_EXTRA))
-                    ? mBottomNav.getMenu().size() - 1 : 0;
-                navigateToSection(mBottomNav.getMenu().getItem(section).getItemId());
+                navigateToSection(
+                        WALLPAPER_FOCUS.equals(getIntent().getStringExtra(WALLPAPER_FLAVOR_EXTRA))
+                                ? R.id.nav_wallpaper : R.id.nav_theme);
             }
         }
     }
@@ -306,6 +305,11 @@
     }
 
     private void navigateToSection(@IdRes int id) {
+        // Navigate to the first section if the targeted section doesn't exist.
+        if (!mSections.containsKey(id)) {
+            id = mBottomNav.getMenu().getItem(0).getItemId();
+        }
+
         mBottomNav.setSelectedItemId(id);
     }