Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b96238a1 authored by Hyunyoung Song's avatar Hyunyoung Song
Browse files

Add user event logging for recents onboarding

> Actual logging will happen in launcher side

Bug: 73784423
Test: Builds

Change-Id: I99ae31a74c2e5921915dc3bbf6d08669b5c98584
parent afb6f3b0
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -85,4 +85,9 @@ oneway interface IOverviewProxy {
     * cancel (long) press.
     */
    void onQuickStep(in MotionEvent event);

    /**
     * Sent when there was an action on one of the onboarding tips view.
     */
    void onTip(int actionType, int viewType);
}
+29 −0
Original line number Diff line number Diff line
/*
 * 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.systemui.shared.system;

public class LauncherEventUtil {

    // Constants for the Action
    public static final int VISIBLE = 0;
    public static final int DISMISS = 1;

    // Constants for the Target (View)
    public static final int RECENTS_SWIPE_UP_ONBOARDING_TIP = 0;
    public static final int RECENTS_QUICK_SCRUB_ONBOARDING_TIP = 1;

}
+35 −6
Original line number Diff line number Diff line
@@ -24,6 +24,10 @@ import static com.android.systemui.Prefs.Key.HAS_SEEN_RECENTS_QUICK_SCRUB_ONBOAR
import static com.android.systemui.Prefs.Key.HAS_SEEN_RECENTS_SWIPE_UP_ONBOARDING;
import static com.android.systemui.Prefs.Key.OVERVIEW_OPENED_COUNT;
import static com.android.systemui.Prefs.Key.OVERVIEW_OPENED_FROM_HOME_COUNT;
import static com.android.systemui.shared.system.LauncherEventUtil.VISIBLE;
import static com.android.systemui.shared.system.LauncherEventUtil.DISMISS;
import static com.android.systemui.shared.system.LauncherEventUtil.RECENTS_QUICK_SCRUB_ONBOARDING_TIP;
import static com.android.systemui.shared.system.LauncherEventUtil.RECENTS_SWIPE_UP_ONBOARDING_TIP;

import android.annotation.StringRes;
import android.annotation.TargetApi;
@@ -38,6 +42,7 @@ import android.graphics.drawable.ShapeDrawable;
import android.os.Build;
import android.os.SystemProperties;
import android.os.UserManager;
import android.os.RemoteException;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
@@ -53,7 +58,9 @@ import com.android.systemui.OverviewProxyService;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.recents.misc.SysUiTaskStackChangeListener;
import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.LauncherEventUtil;

import java.util.Collections;
import java.util.HashSet;
@@ -120,6 +127,7 @@ public class RecentsOnboarding {
                    return;
                }

                boolean shouldLog = false;
                if (!alreadySeenSwipeUpOnboarding) {
                    if (getOpenedOverviewFromHomeCount()
                            >= SWIPE_UP_SHOW_ON_OVERVIEW_OPENED_FROM_HOME_COUNT) {
@@ -128,10 +136,13 @@ public class RecentsOnboarding {
                            if (mNumAppsLaunchedSinceSwipeUpTipDismiss
                                    == SWIPE_UP_SHOW_ON_APP_LAUNCH_AFTER_DISMISS) {
                                mNumAppsLaunchedSinceSwipeUpTipDismiss = 0;
                                show(R.string.recents_swipe_up_onboarding);
                                shouldLog = show(R.string.recents_swipe_up_onboarding);
                            }
                        } else {
                            show(R.string.recents_swipe_up_onboarding);
                            shouldLog = show(R.string.recents_swipe_up_onboarding);
                        }
                        if (shouldLog) {
                            notifyOnTip(VISIBLE, RECENTS_SWIPE_UP_ONBOARDING_TIP);
                        }
                    }
                } else {
@@ -140,12 +151,16 @@ public class RecentsOnboarding {
                            if (mOverviewOpenedCountSinceQuickScrubTipDismiss
                                    == QUICK_SCRUB_SHOW_ON_OVERVIEW_OPENED_COUNT) {
                                mOverviewOpenedCountSinceQuickScrubTipDismiss = 0;
                                show(R.string.recents_quick_scrub_onboarding);
                                shouldLog = show(R.string.recents_quick_scrub_onboarding);
                            }
                        } else {
                            show(R.string.recents_quick_scrub_onboarding);
                            shouldLog = show(R.string.recents_quick_scrub_onboarding);
                        }
                        if (shouldLog) {
                            notifyOnTip(VISIBLE, RECENTS_QUICK_SCRUB_ONBOARDING_TIP);
                        }
                    }

                }
            } else {
                hide(false);
@@ -244,6 +259,9 @@ public class RecentsOnboarding {
            if (v.getTag().equals(R.string.recents_swipe_up_onboarding)) {
                mHasDismissedSwipeUpTip = true;
                mNumAppsLaunchedSinceSwipeUpTipDismiss = 0;
                notifyOnTip(DISMISS, RECENTS_SWIPE_UP_ONBOARDING_TIP);
            } else {
                notifyOnTip(DISMISS, RECENTS_QUICK_SCRUB_ONBOARDING_TIP);
            }
        });

@@ -265,6 +283,15 @@ public class RecentsOnboarding {
        }
    }

    private void notifyOnTip(int action, int target) {
        try {
            IOverviewProxy overviewProxy = mOverviewProxyService.getProxy();
            if(overviewProxy != null) {
                overviewProxy.onTip(action, target);
            }
        } catch (RemoteException e) {}
    }

    public void onConnectedToLauncher() {
        if (!ONBOARDING_ENABLED) {
            return;
@@ -307,9 +334,9 @@ public class RecentsOnboarding {
        }
    }

    public void show(@StringRes int stringRes) {
    public boolean show(@StringRes int stringRes) {
        if (!shouldShow()) {
            return;
            return false;
        }
        mDismissView.setTag(stringRes);
        mLayout.setTag(stringRes);
@@ -328,7 +355,9 @@ public class RecentsOnboarding {
                    .setDuration(SHOW_DURATION_MS)
                    .setInterpolator(new DecelerateInterpolator())
                    .start();
            return true;
        }
        return false;
    }

    /**