[4/4] Move new picker logic to AOSP

- Remove activity overriden for CustomizationPickerActivity, and use
the activity in WallpaperPicker2.

Bug: 190354625
Test: Build and run the app
Change-Id: I080737f0ec30a6090b1180eba98b3aa8087f50a1
Merged-In: I080737f0ec30a6090b1180eba98b3aa8087f50a1
diff --git a/Android.bp b/Android.bp
index 69b0ab2..8f02388 100644
--- a/Android.bp
+++ b/Android.bp
@@ -64,8 +64,6 @@
         ":ThemePicker_srcs",
         "src_override/**/*.java",
         "src_override/**/*.kt",
-        "src_overridecustom/**/*.java",
-        "src_overridecustom/**/*.kt",
     ],
 
     use_embedded_native_libs: true,
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 68eb4be..4f62429 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -9,6 +9,8 @@
     <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
     <uses-permission android:name="android.permission.SET_WALLPAPER_COMPONENT" />
 
+    <uses-permission android:name="android.permission.MODIFY_DAY_NIGHT_MODE" />
+
     <queries>
         <!-- Specific intents Wallpaper picker query for -->
         <!-- Intent filter with action SET_WALLPAPER -->
@@ -46,17 +48,23 @@
         android:name="com.android.customization.picker.CustomizationPickerApplication"
         android:theme="@style/CustomizationTheme">
         <activity
-            android:name="com.android.customization.picker.CustomizationPickerActivity"
+            android:name="com.android.wallpaper.picker.CustomizationPickerActivity"
             android:label="@string/app_name"
             android:resizeableActivity="false"
-            android:exported="true"
-            android:theme="@style/CustomizationTheme.NoActionBar">
-            <intent-filter>
-                <action android:name="android.intent.action.SET_WALLPAPER"/>
+            android:theme="@style/CustomizationTheme.NoActionBar"
+            android:exported="false"/>
 
-                <category android:name="android.intent.category.DEFAULT"/>
-            </intent-filter>
-        </activity>
+        <activity-alias
+            android:name="com.android.customization.picker.CustomizationPickerActivity"
+            android:targetActivity="com.android.wallpaper.picker.CustomizationPickerActivity"
+            android:label="@string/app_name"
+            android:exported="true">
+             <intent-filter>
+                 <action android:name="android.intent.action.SET_WALLPAPER"/>
+                 <category android:name="android.intent.category.DEFAULT"/>
+             </intent-filter>
+        </activity-alias>
+
         <activity android:name="com.android.customization.picker.theme.CustomThemeActivity"
                   android:resizeableActivity="false"
                   android:theme="@style/CustomizationTheme.NoActionBar"/>
diff --git a/res/layout/activity_customization_picker_main.xml b/res/layout/activity_customization_picker_main.xml
deleted file mode 100755
index bec49fb..0000000
--- a/res/layout/activity_customization_picker_main.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     Copyright (C) 2018 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.
--->
-<FrameLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical">
-
-    <FrameLayout
-        android:id="@+id/fragment_container"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_marginBottom="@dimen/bottom_actions_height"/>
-
-    <com.google.android.material.bottomnavigation.BottomNavigationView
-        android:id="@+id/main_bottom_nav"
-        style="@style/BottomNavStyle"
-        android:layout_width="match_parent"
-        android:layout_height="@dimen/bottom_actions_height"
-        android:layout_gravity="bottom"
-        app:labelVisibilityMode="labeled"
-        app:menu="@menu/bottom_navigation_menu"/>
-
-    <include layout="@layout/bottom_action_bar" />
-
-</FrameLayout>
diff --git a/src/com/android/customization/module/DefaultCustomizationInjector.java b/src/com/android/customization/module/DefaultCustomizationInjector.java
index 969f22f..5b5c11e 100644
--- a/src/com/android/customization/module/DefaultCustomizationInjector.java
+++ b/src/com/android/customization/module/DefaultCustomizationInjector.java
@@ -15,8 +15,8 @@
  */
 package com.android.customization.module;
 
-import static com.android.customization.picker.CustomizationPickerActivity.WALLPAPER_FLAVOR_EXTRA;
-import static com.android.customization.picker.CustomizationPickerActivity.WALLPAPER_FOCUS;
+import static com.android.wallpaper.picker.CustomizationPickerActivity.WALLPAPER_FLAVOR_EXTRA;
+import static com.android.wallpaper.picker.CustomizationPickerActivity.WALLPAPER_FOCUS;
 
 import android.content.Context;
 import android.content.Intent;
@@ -28,7 +28,6 @@
 import com.android.customization.model.theme.OverlayManagerCompat;
 import com.android.customization.model.theme.ThemeBundleProvider;
 import com.android.customization.model.theme.ThemeManager;
-import com.android.customization.picker.CustomizationPickerActivity;
 import com.android.wallpaper.model.CategoryProvider;
 import com.android.wallpaper.model.WallpaperInfo;
 import com.android.wallpaper.module.BaseWallpaperInjector;
@@ -38,6 +37,7 @@
 import com.android.wallpaper.module.WallpaperPreferences;
 import com.android.wallpaper.module.WallpaperRotationRefresher;
 import com.android.wallpaper.monitor.PerformanceMonitor;
+import com.android.wallpaper.picker.CustomizationPickerActivity;
 import com.android.wallpaper.picker.PreviewFragment;
 
 public class DefaultCustomizationInjector extends BaseWallpaperInjector
diff --git a/src/com/android/customization/picker/CustomizationFragmentHost.java b/src/com/android/customization/picker/CustomizationFragmentHost.java
deleted file mode 100644
index d700ec6..0000000
--- a/src/com/android/customization/picker/CustomizationFragmentHost.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.
- */
-package com.android.customization.picker;
-
-import com.android.customization.model.CustomizationManager;
-
-/**
- * Interface to be implemented by an Activity hosting any Customization Fragment
- */
-public interface CustomizationFragmentHost {
-
-    /**
-     * Gets the CustomizationManager manager for the given section
-     * @return the {@link CustomizationManager}
-     */
-    CustomizationManager<?> getCustomizationManager(int sectionId);
-}
diff --git a/src/com/android/customization/picker/grid/GridFragment.java b/src/com/android/customization/picker/grid/GridFragment.java
index 2aeb348..8bddc22 100644
--- a/src/com/android/customization/picker/grid/GridFragment.java
+++ b/src/com/android/customization/picker/grid/GridFragment.java
@@ -44,7 +44,6 @@
 import com.android.customization.module.ThemesUserEventLogger;
 import com.android.customization.picker.ViewOnlyFullPreviewActivity;
 import com.android.customization.picker.WallpaperPreviewer;
-import com.android.customization.util.LaunchUtils;
 import com.android.customization.widget.OptionSelectorController;
 import com.android.customization.widget.OptionSelectorController.CheckmarkStyle;
 import com.android.wallpaper.R;
@@ -52,6 +51,7 @@
 import com.android.wallpaper.module.CurrentWallpaperInfoFactory;
 import com.android.wallpaper.module.InjectorProvider;
 import com.android.wallpaper.picker.AppbarFragment;
+import com.android.wallpaper.util.LaunchUtils;
 import com.android.wallpaper.widget.BottomActionBar;
 
 import com.bumptech.glide.Glide;
diff --git a/src/com/android/customization/util/LaunchUtils.java b/src/com/android/customization/util/LaunchUtils.java
deleted file mode 100644
index 5779168..0000000
--- a/src/com/android/customization/util/LaunchUtils.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.
- */
-package com.android.customization.util;
-
-import android.content.Context;
-import android.content.Intent;
-
-/** Util class for launching activity. */
-public class LaunchUtils {
-
-    /** Goes to Launcher's Home. */
-    public static void launchHome(Context context) {
-        Intent launcherIntent = new Intent(Intent.ACTION_MAIN);
-        launcherIntent.addCategory(Intent.CATEGORY_HOME);
-        launcherIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
-        context.startActivity(launcherIntent);
-    }
-}
diff --git a/src_overridecustom/com/android/customization/picker/CustomizationPickerActivity.java b/src_overridecustom/com/android/customization/picker/CustomizationPickerActivity.java
deleted file mode 100644
index e352879..0000000
--- a/src_overridecustom/com/android/customization/picker/CustomizationPickerActivity.java
+++ /dev/null
@@ -1,601 +0,0 @@
-/*
- * Copyright (C) 2018 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.customization.picker;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.LayerDrawable;
-import android.os.Bundle;
-import android.provider.Settings;
-import android.util.Log;
-import android.view.Gravity;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-
-import androidx.annotation.IdRes;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.annotation.VisibleForTesting;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentActivity;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-
-import com.android.customization.model.CustomizationManager;
-import com.android.customization.model.CustomizationSection;
-import com.android.customization.model.clock.ClockManager;
-import com.android.customization.model.clock.Clockface;
-import com.android.customization.model.clock.ContentProviderClockProvider;
-import com.android.customization.model.grid.GridOption;
-import com.android.customization.model.grid.GridOptionsManager;
-import com.android.customization.model.theme.DefaultThemeProvider;
-import com.android.customization.model.theme.OverlayManagerCompat;
-import com.android.customization.model.theme.ThemeBundle;
-import com.android.customization.model.theme.ThemeManager;
-import com.android.customization.module.CustomizationInjector;
-import com.android.customization.module.DefaultCustomizationPreferences;
-import com.android.customization.module.ThemesUserEventLogger;
-import com.android.customization.picker.clock.ClockFragment;
-import com.android.customization.picker.clock.ClockFragment.ClockFragmentHost;
-import com.android.customization.picker.grid.GridFragment;
-import com.android.customization.picker.theme.ThemeFragment;
-import com.android.customization.picker.theme.ThemeFragment.ThemeFragmentHost;
-import com.android.customization.widget.NoTintDrawableWrapper;
-import com.android.wallpaper.R;
-import com.android.wallpaper.compat.BuildCompat;
-import com.android.wallpaper.model.WallpaperInfo;
-import com.android.wallpaper.module.DailyLoggingAlarmScheduler;
-import com.android.wallpaper.module.FormFactorChecker;
-import com.android.wallpaper.module.Injector;
-import com.android.wallpaper.module.InjectorProvider;
-import com.android.wallpaper.module.UserEventLogger;
-import com.android.wallpaper.module.WallpaperPreferences;
-import com.android.wallpaper.picker.AppbarFragment.AppbarFragmentHost;
-import com.android.wallpaper.picker.BottomActionBarFragment;
-import com.android.wallpaper.picker.CategoryFragment;
-import com.android.wallpaper.picker.CategoryFragment.CategoryFragmentHost;
-import com.android.wallpaper.picker.CategorySelectorFragment;
-import com.android.wallpaper.picker.FragmentTransactionChecker;
-import com.android.wallpaper.picker.MyPhotosStarter;
-import com.android.wallpaper.picker.MyPhotosStarter.PermissionChangedListener;
-import com.android.wallpaper.picker.TopLevelPickerActivity;
-import com.android.wallpaper.picker.WallpaperPickerDelegate;
-import com.android.wallpaper.picker.WallpapersUiContainer;
-import com.android.wallpaper.util.ActivityUtils;
-import com.android.wallpaper.util.DeepLinkUtils;
-import com.android.wallpaper.widget.BottomActionBar;
-import com.android.wallpaper.widget.BottomActionBar.BottomActionBarHost;
-
-import com.google.android.material.bottomnavigation.BottomNavigationView;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *  Main Activity allowing containing a bottom nav bar for the user to switch between the different
- *  Fragments providing customization options.
- */
-public class CustomizationPickerActivity extends FragmentActivity implements WallpapersUiContainer,
-        AppbarFragmentHost, CategoryFragmentHost, CustomizationFragmentHost, ThemeFragmentHost,
-        ClockFragmentHost, BottomActionBarHost, FragmentTransactionChecker {
-
-    public static final String WALLPAPER_FLAVOR_EXTRA =
-            "com.android.launcher3.WALLPAPER_FLAVOR";
-    public static final String WALLPAPER_FOCUS = "focus_wallpaper";
-    private static final String TAG = "CustomizationPickerActivity";
-    @VisibleForTesting static final String WALLPAPER_ONLY = "wallpaper_only";
-
-    private WallpaperPickerDelegate mDelegate;
-    private UserEventLogger mUserEventLogger;
-    private BottomNavigationView mBottomNav;
-
-    private static final Map<Integer, CustomizationSection> mSections = new HashMap<>();
-    private CategoryFragment mWallpaperCategoryFragment;
-    private BottomActionBar mBottomActionBar;
-    private boolean mIsSafeToCommitFragmentTransaction;
-
-    @Override
-    protected void onCreate(@Nullable Bundle savedInstanceState) {
-        Injector injector = InjectorProvider.getInjector();
-        mDelegate = new WallpaperPickerDelegate(this, this, injector);
-        mUserEventLogger = injector.getUserEventLogger(this);
-        initSections();
-
-        // Restore this Activity's state before restoring contained Fragments state.
-        super.onCreate(savedInstanceState);
-
-        if (supportsCustomizationExtended()) {
-            Log.d(TAG, "Customization picker extended");
-            skipToCustomizationExtPicker();
-            return;
-        }
-        if (!supportsCustomization()) {
-            Log.w(TAG, "Themes not supported, reverting to Wallpaper Picker");
-            skipToWallpaperPicker();
-            return;
-        }
-
-        mDelegate.getCategoryProvider().resetIfNeeded();
-
-        setContentView(R.layout.activity_customization_picker_main);
-        setUpBottomNavView();
-        mBottomActionBar = findViewById(R.id.bottom_actionbar);
-        mBottomActionBar.addVisibilityChangeListener(
-                isBottomActionBarVisible -> {
-                    boolean isBottomNavVisible = mBottomNav.getVisibility() == View.VISIBLE;
-                    // Switch the visibility of BottomNav if visibility of BottomActionBar and
-                    // BottomNav are same.
-                    if (isBottomActionBarVisible == isBottomNavVisible) {
-                        mBottomNav.setVisibility(isBottomActionBarVisible
-                                ? View.GONE : View.VISIBLE);
-                    }
-                });
-
-        Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
-        if (fragment == null) {
-            // App launch specific logic: log the "app launch source" event.
-            if (getIntent() != null) {
-                mUserEventLogger.logAppLaunched(getIntent());
-            }
-            WallpaperPreferences preferences = injector.getPreferences(this);
-            preferences.incrementAppLaunched();
-            DailyLoggingAlarmScheduler.setAlarm(getApplicationContext());
-
-            // Navigate to the Wallpaper tab if we started directly from launcher, otherwise
-            // start at the Styles tab
-            navigateToSection(
-                    WALLPAPER_FOCUS.equals(getIntent().getStringExtra(WALLPAPER_FLAVOR_EXTRA))
-                            ? R.id.nav_wallpaper : R.id.nav_theme);
-        }
-    }
-
-    @Override
-    protected void onResume() {
-        super.onResume();
-        mIsSafeToCommitFragmentTransaction = true;
-        boolean wallpaperOnly =
-                WALLPAPER_ONLY.equals(getIntent().getStringExtra(WALLPAPER_FLAVOR_EXTRA));
-        boolean provisioned = Settings.Global.getInt(getContentResolver(),
-                Settings.Global.DEVICE_PROVISIONED, 0) != 0;
-
-        mUserEventLogger.logResumed(provisioned, wallpaperOnly);
-        // refresh the sections as the preview may have changed
-        initSections();
-        if (mBottomNav == null) {
-            return;
-        }
-        CustomizationSection section = mSections.get(mBottomNav.getSelectedItemId());
-        if (section == null) {
-            return;
-        }
-        // Keep CategoryFragment's design to load category within its fragment
-        if (section instanceof WallpaperSection) {
-            switchFragment(section);
-        }
-    }
-
-    @Override
-    protected void onPause() {
-        super.onPause();
-        mIsSafeToCommitFragmentTransaction = false;
-    }
-
-    @Override
-    protected void onNewIntent(Intent intent) {
-        super.onNewIntent(intent);
-        if (WALLPAPER_ONLY.equals(intent.getStringExtra(WALLPAPER_FLAVOR_EXTRA))) {
-            Log.d(TAG, "WALLPAPER_ONLY intent, reverting to Wallpaper Picker");
-            skipToWallpaperPicker();
-        }
-    }
-
-    private void skipToWallpaperPicker() {
-        Intent intent = new Intent(this, TopLevelPickerActivity.class);
-
-        if (getIntent() != null && getIntent().getExtras() != null) {
-            intent.putExtras(getIntent().getExtras());
-        }
-
-        if (DeepLinkUtils.isDeepLink(getIntent())) {
-            intent.setData(getIntent().getData());
-        }
-        startActivity(intent);
-        finish();
-    }
-
-    private void skipToCustomizationExtPicker() {
-        CustomizationInjector injector = (CustomizationInjector) InjectorProvider.getInjector();
-        Intent intent = injector.getCustomizeExtIntent(getApplicationContext());
-        if (getIntent() != null && getIntent().getExtras() != null) {
-            intent.putExtras(getIntent().getExtras());
-        }
-        if (DeepLinkUtils.isDeepLink(getIntent())) {
-            intent.setData(getIntent().getData());
-        }
-        startActivity(intent);
-        finish();
-    }
-
-    private boolean supportsCustomization() {
-        return mDelegate.getFormFactor() == FormFactorChecker.FORM_FACTOR_MOBILE
-                && mSections.size() > 1;
-    }
-
-    private boolean supportsCustomizationExtended() {
-        CustomizationInjector injector = (CustomizationInjector) InjectorProvider.getInjector();
-        return injector.supportsCustomizationExtended(this);
-    }
-
-    private void initSections() {
-        mSections.clear();
-        if (!BuildCompat.isAtLeastQ()) {
-            Log.d(TAG, "Build version < Q detected");
-            return;
-        }
-        if (WALLPAPER_ONLY.equals(getIntent().getStringExtra(WALLPAPER_FLAVOR_EXTRA))) {
-            Log.d(TAG, "WALLPAPER_ONLY intent");
-            return;
-        }
-        //Theme
-        CustomizationInjector injector = (CustomizationInjector) InjectorProvider.getInjector();
-        ThemesUserEventLogger eventLogger = (ThemesUserEventLogger) injector.getUserEventLogger(
-                this);
-        CustomizationManager<?> extraManager = injector.getExtraManager(
-                this, new OverlayManagerCompat(this), eventLogger);
-        if (extraManager != null && extraManager.isAvailable()) {
-            mSections.put(extraManager.getNavId(), extraManager.createSection());
-        }
-        ThemeManager themeManager = injector.getThemeManager(
-                new DefaultThemeProvider(this, injector.getCustomizationPreferences(this)),
-                this, new OverlayManagerCompat(this), eventLogger);
-        if (themeManager.isAvailable()) {
-            mSections.put(R.id.nav_theme, new ThemeSection(R.id.nav_theme, themeManager));
-        } else {
-            Log.d(TAG, "ThemeManager not available, removing Style section");
-        }
-        //Clock
-        ClockManager clockManager = new ClockManager(getContentResolver(),
-                new ContentProviderClockProvider(this), eventLogger);
-        if (clockManager.isAvailable()) {
-            mSections.put(R.id.nav_clock, new ClockSection(R.id.nav_clock, clockManager));
-        } else {
-            Log.d(TAG, "ClockManager not available, removing Clock section");
-        }
-        //Grid
-        GridOptionsManager gridManager = GridOptionsManager.get(this);
-        if (gridManager.isAvailable()) {
-            mSections.put(R.id.nav_grid, new GridSection(R.id.nav_grid, gridManager));
-        } else {
-            Log.d(TAG, "GridOptionsManager not available, removing Grid section");
-        }
-        mSections.put(R.id.nav_wallpaper, new WallpaperSection(R.id.nav_wallpaper));
-    }
-
-    private void setUpBottomNavView() {
-        mBottomNav = findViewById(R.id.main_bottom_nav);
-        Menu menu = mBottomNav.getMenu();
-        DefaultCustomizationPreferences prefs =
-                new DefaultCustomizationPreferences(getApplicationContext());
-        for (int i = menu.size() - 1; i >= 0; i--) {
-            MenuItem item = menu.getItem(i);
-            int id = item.getItemId();
-            if (!mSections.containsKey(id)) {
-                menu.removeItem(id);
-            }  else if (!prefs.getTabVisited(getResources().getResourceName(id))) {
-                showTipDot(item);
-            }
-        }
-
-        mBottomNav.setOnNavigationItemSelectedListener(item -> {
-            int id = item.getItemId();
-            CustomizationSection section = mSections.get(id);
-            switchFragment(section);
-            String name = getResources().getResourceName(id);
-            if (!prefs.getTabVisited(name)) {
-                prefs.setTabVisited(name);
-                hideTipDot(item);
-
-                if (id == R.id.nav_theme) {
-                    getThemeManager().storeEmptyTheme();
-                }
-            }
-            return true;
-        });
-    }
-
-    private void showTipDot(MenuItem item) {
-        Drawable icon = item.getIcon();
-        Drawable dot = new NoTintDrawableWrapper(getResources().getDrawable(R.drawable.tip_dot));
-        Drawable[] layers = {icon, dot};
-        LayerDrawable iconWithDot = new LayerDrawable(layers);
-
-        // Position dot in the upper-right corner
-        int dotSize = (int) getResources().getDimension(R.dimen.tip_dot_size)
-                + (int) getResources().getDimension(R.dimen.tip_dot_line_width) * 2;
-        int linewidth = (int) getResources().getDimension(R.dimen.tip_dot_line_width);
-        iconWithDot.setLayerGravity(1, Gravity.TOP | Gravity.RIGHT);
-        iconWithDot.setLayerWidth(1, dotSize);
-        iconWithDot.setLayerHeight(1, dotSize);
-        iconWithDot.setLayerInsetTop(1, -linewidth);
-        iconWithDot.setLayerInsetRight(1, -linewidth);
-
-        item.setIcon(iconWithDot);
-    }
-
-
-    private void hideTipDot(MenuItem item) {
-        Drawable iconWithDot = item.getIcon();
-        if (iconWithDot instanceof LayerDrawable) {
-            LayerDrawable layers = (LayerDrawable) iconWithDot;
-            Drawable icon = layers.getDrawable(0);
-            item.setIcon(icon);
-        }
-    }
-
-    @Override
-    public void onBackPressed() {
-        Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
-        if (fragment instanceof BottomActionBarFragment
-                && ((BottomActionBarFragment) fragment).onBackPressed()) {
-            return;
-        }
-
-        // For wallpaper tab, since it had child fragment.
-        if (mWallpaperCategoryFragment != null && mWallpaperCategoryFragment.popChildFragment()) {
-            return;
-        }
-
-        if (getSupportFragmentManager().popBackStackImmediate()) {
-            return;
-        }
-        if (moveTaskToBack(false)) {
-            return;
-        }
-        super.onBackPressed();
-    }
-
-    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);
-    }
-
-    private void switchFragment(CustomizationSection section) {
-        final FragmentManager fragmentManager = getSupportFragmentManager();
-
-        Fragment fragment = section.getFragment(this);
-
-        final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
-        fragmentTransaction.replace(R.id.fragment_container, fragment);
-        fragmentTransaction.commitNow();
-    }
-
-
-    @Override
-    public void requestExternalStoragePermission(PermissionChangedListener listener) {
-        mDelegate.requestExternalStoragePermission(listener);
-    }
-
-    @Override
-    public boolean isReadExternalStoragePermissionGranted() {
-        return mDelegate.isReadExternalStoragePermissionGranted();
-    }
-
-    @Override
-    public void showViewOnlyPreview(WallpaperInfo wallpaperInfo, boolean isViewAsHome) {
-        mDelegate.showViewOnlyPreview(wallpaperInfo, isViewAsHome);
-    }
-
-    @Override
-    public void show(String collectionId) {
-        mDelegate.show(collectionId);
-    }
-
-    @Override
-    public void fetchCategories() {
-        mDelegate.initialize(!mDelegate.getCategoryProvider().isCategoriesFetched());
-    }
-
-    @Override
-    public void cleanUp() {
-        mDelegate.cleanUp();
-    }
-
-    @Override
-    public void onWallpapersReady() {
-
-    }
-
-    @Nullable
-    @Override
-    public CategorySelectorFragment getCategorySelectorFragment() {
-        if (mWallpaperCategoryFragment == null) {
-            return null;
-        }
-        return mWallpaperCategoryFragment.getCategorySelectorFragment();
-    }
-
-    @Override
-    public void doneFetchingCategories() {
-
-    }
-
-    @Override
-    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
-            @NonNull int[] grantResults) {
-        mDelegate.onRequestPermissionsResult(requestCode, permissions, grantResults);
-    }
-
-    @Override
-    public MyPhotosStarter getMyPhotosStarter() {
-        return mDelegate;
-    }
-
-
-    @Override
-    public CustomizationManager<?> getCustomizationManager(int id) {
-        CustomizationSection<?> section = mSections.get(id);
-        return section == null ? null : section.getCustomizationManager();
-    }
-
-    @Override
-    public ClockManager getClockManager() {
-        CustomizationSection section = mSections.get(R.id.nav_clock);
-        return section == null ? null : (ClockManager) section.getCustomizationManager();
-    }
-
-    @Override
-    public ThemeManager getThemeManager() {
-        CustomizationSection section = mSections.get(R.id.nav_theme);
-        return section == null ? null : (ThemeManager) section.getCustomizationManager();
-    }
-
-    @Override
-    protected void onStop() {
-        mUserEventLogger.logStopped();
-        super.onStop();
-    }
-
-    @Override
-    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
-        super.onActivityResult(requestCode, resultCode, data);
-        if (mDelegate.handleActivityResult(requestCode, resultCode, data)) {
-            finishActivityWithResultOk();
-        }
-    }
-
-    private void finishActivityWithResultOk() {
-        overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
-        setResult(Activity.RESULT_OK);
-        finish();
-    }
-
-    @Override
-    public BottomActionBar getBottomActionBar() {
-        return mBottomActionBar;
-    }
-
-    @Override
-    public boolean isSafeToCommitFragmentTransaction() {
-        return mIsSafeToCommitFragmentTransaction;
-    }
-
-    @Override
-    public void onUpArrowPressed() {
-        Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
-        if (fragment instanceof BottomActionBarFragment
-                && ((BottomActionBarFragment) fragment).onBackPressed()) {
-            return;
-        }
-
-        // For wallpaper tab, since it had child fragment.
-        if (mWallpaperCategoryFragment != null && mWallpaperCategoryFragment.popChildFragment()) {
-            return;
-        }
-
-        if (getSupportFragmentManager().popBackStackImmediate()) {
-            return;
-        }
-
-        if (!ActivityUtils.isLaunchedFromSettingsRelated(getIntent())) {
-            Intent intent = new Intent(Settings.ACTION_SETTINGS);
-            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
-            startActivity(intent);
-        }
-        finish();
-    }
-
-    @Override
-    public boolean isUpArrowSupported() {
-        return true;
-    }
-
-    /**
-     * {@link CustomizationSection} corresponding to the "Wallpaper" section of the Picker.
-     */
-    private class WallpaperSection extends CustomizationSection {
-
-        private WallpaperSection(int id) {
-            super(id, null);
-        }
-
-        @Override
-        public Fragment getFragment(Context c) {
-            if (mWallpaperCategoryFragment == null) {
-                mWallpaperCategoryFragment = CategoryFragment.newInstance(
-                        getString(R.string.wallpaper_title));
-            }
-            return mWallpaperCategoryFragment;
-        }
-    }
-
-    private class ThemeSection extends CustomizationSection<ThemeBundle> {
-
-        private ThemeFragment mFragment;
-
-        private ThemeSection(int id, ThemeManager manager) {
-            super(id, manager);
-        }
-
-        @Override
-        public Fragment getFragment(Context c) {
-            if (mFragment == null) {
-                mFragment = ThemeFragment.newInstance(getString(R.string.theme_title));
-            }
-            return mFragment;
-        }
-    }
-
-    private class GridSection extends CustomizationSection<GridOption> {
-
-        private GridFragment mFragment;
-
-        private GridSection(int id, GridOptionsManager manager) {
-            super(id, manager);
-        }
-
-        @Override
-        public Fragment getFragment(Context c) {
-            if (mFragment == null) {
-                mFragment = GridFragment.newInstance(getString(R.string.grid_title));
-            }
-            return mFragment;
-        }
-    }
-
-    private class ClockSection extends CustomizationSection<Clockface> {
-
-        private ClockFragment mFragment;
-
-        private ClockSection(int id, ClockManager manager) {
-            super(id, manager);
-        }
-
-        @Override
-        public Fragment getFragment(Context c) {
-            if (mFragment == null) {
-                mFragment = ClockFragment.newInstance(getString(R.string.clock_title));
-            }
-            return mFragment;
-        }
-    }
-}
diff --git a/tests/src/com/android/customization/picker/CustomizationPickerActivityTest.java b/tests/src/com/android/customization/picker/CustomizationPickerActivityTest.java
deleted file mode 100644
index dd1581a..0000000
--- a/tests/src/com/android/customization/picker/CustomizationPickerActivityTest.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package com.android.customization.picker;
-
-import static android.content.Intent.ACTION_SET_WALLPAPER;
-
-import static androidx.test.espresso.Espresso.onView;
-import static androidx.test.espresso.action.ViewActions.click;
-import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist;
-import static androidx.test.espresso.assertion.ViewAssertions.matches;
-import static androidx.test.espresso.intent.matcher.IntentMatchers.filterEquals;
-import static androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed;
-import static androidx.test.espresso.matcher.ViewMatchers.isSelected;
-import static androidx.test.espresso.matcher.ViewMatchers.withId;
-
-import static com.android.customization.picker.CustomizationPickerActivity.WALLPAPER_FLAVOR_EXTRA;
-import static com.android.customization.picker.CustomizationPickerActivity.WALLPAPER_FOCUS;
-import static com.android.customization.picker.CustomizationPickerActivity.WALLPAPER_ONLY;
-
-import static org.junit.Assert.assertTrue;
-
-import android.content.Intent;
-import android.text.TextUtils;
-
-import androidx.fragment.app.Fragment;
-import androidx.test.espresso.intent.Intents;
-import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
-import androidx.test.rule.ActivityTestRule;
-
-import com.android.customization.picker.theme.ThemeFragment;
-import com.android.customization.testing.TestCustomizationInjector;
-import com.android.customization.testing.TestThemeManager;
-import com.android.wallpaper.R;
-import com.android.wallpaper.module.InjectorProvider;
-import com.android.wallpaper.picker.CategoryFragment;
-import com.android.wallpaper.picker.TopLevelPickerActivity;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests for {@link CustomizationPickerActivity}.
- */
-@RunWith(AndroidJUnit4ClassRunner.class)
-public class CustomizationPickerActivityTest {
-
-    @Rule
-    public ActivityTestRule<CustomizationPickerActivity> mActivityRule =
-            new ActivityTestRule<>(CustomizationPickerActivity.class, false, false);
-
-    @Before
-    public void setUp() {
-        Intents.init();
-    }
-
-    @After
-    public void tearDown() {
-        mActivityRule.finishActivity();
-        Intents.release();
-    }
-
-    @Test
-    public void launchActivity_doesNotSupportCustomization_launchesTopLevelPickerActivity() {
-        TestThemeManager.setAvailable(false);
-
-        launchActivity();
-
-        Intents.intended(filterEquals(new Intent(mActivityRule.getActivity(),
-                TopLevelPickerActivity.class)));
-    }
-
-    // ----------------------------------------------------------------------
-    // Tests for customization supports.
-    // ----------------------------------------------------------------------
-
-    @Test
-    public void launchActivity_themeManagerIsAvailable_NavBarShowsStyleAndWallpaperItem() {
-        TestThemeManager.setAvailable(true);
-
-        launchActivity();
-
-        onView(withId(R.id.nav_theme)).check(matches(isCompletelyDisplayed()));
-        onView(withId(R.id.nav_wallpaper)).check(matches(isCompletelyDisplayed()));
-        onView(withId(R.id.nav_clock)).check(doesNotExist());
-        onView(withId(R.id.nav_grid)).check(doesNotExist());
-    }
-
-    @Test
-    public void launchActivity_navigateToTheStyleTabByDefault() {
-        TestThemeManager.setAvailable(true);
-
-        launchActivity();
-
-        onView(withId(R.id.nav_theme)).check(matches(isSelected()));
-        assertTrue(getCurrentShowingFragment() instanceof ThemeFragment);
-    }
-
-    @Test
-    public void launchActivity_withExtraWallpaperOnly_launchesTopLevelPickerActivity() {
-        TestThemeManager.setAvailable(true);
-
-        launchActivityWithFlavorExtra(WALLPAPER_ONLY);
-
-        // While receiving WALLPAPER_ONLY extra, it should launch TopLevelPickerActivity whatever it
-        // supports customization.
-        Intents.intended(filterEquals(new Intent(mActivityRule.getActivity(),
-                TopLevelPickerActivity.class)));
-    }
-
-    @Test
-    public void clickStyleButton_showsThemeFragment() {
-        TestThemeManager.setAvailable(true);
-        launchActivity();
-
-        onView(withId(R.id.nav_theme)).perform(click());
-
-        onView(withId(R.id.nav_theme)).check(matches(isSelected()));
-        assertTrue(getCurrentShowingFragment() instanceof ThemeFragment);
-    }
-
-    @Test
-    public void clickWallpaperButton_showsCategoryFragment() {
-        TestThemeManager.setAvailable(true);
-        launchActivity();
-
-        onView(withId(R.id.nav_wallpaper)).perform(click());
-
-        onView(withId(R.id.nav_wallpaper)).check(matches(isSelected()));
-        assertTrue(getCurrentShowingFragment() instanceof CategoryFragment);
-    }
-
-    @Test
-    public void launchActivity_withExtraWallpaperFocus_navigateToTheWallpaperTab() {
-        TestThemeManager.setAvailable(true);
-
-        launchActivityWithFlavorExtra(WALLPAPER_FOCUS);
-
-        onView(withId(R.id.nav_wallpaper)).check(matches(isSelected()));
-        assertTrue(getCurrentShowingFragment() instanceof CategoryFragment);
-    }
-
-    private void launchActivity() {
-        launchActivityWithFlavorExtra("");
-    }
-
-    private void launchActivityWithFlavorExtra(String extra) {
-        InjectorProvider.setInjector(new TestCustomizationInjector());
-        Intent intent = new Intent(ACTION_SET_WALLPAPER);
-        if (!TextUtils.isEmpty(extra)) {
-            intent.putExtra(WALLPAPER_FLAVOR_EXTRA, extra);
-        }
-        mActivityRule.launchActivity(intent);
-    }
-
-    private Fragment getCurrentShowingFragment() {
-        return mActivityRule.getActivity().getSupportFragmentManager()
-                .findFragmentById(R.id.fragment_container);
-    }
-}