Merge "add uievent logs for nav assistant longpress" into rvc-dev am: d6b9d5a608 am: c8ccd1a28f am: 821622fd35 am: 655373ba0a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11795062 Change-Id: I36dcfacd5bb76e6c4d2ab3bab37c9cacf37e55db
This commit is contained in:
@@ -96,6 +96,8 @@ import androidx.annotation.VisibleForTesting;
|
|||||||
|
|
||||||
import com.android.internal.accessibility.dialog.AccessibilityButtonChooserActivity;
|
import com.android.internal.accessibility.dialog.AccessibilityButtonChooserActivity;
|
||||||
import com.android.internal.logging.MetricsLogger;
|
import com.android.internal.logging.MetricsLogger;
|
||||||
|
import com.android.internal.logging.UiEvent;
|
||||||
|
import com.android.internal.logging.UiEventLogger;
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
import com.android.internal.util.LatencyTracker;
|
import com.android.internal.util.LatencyTracker;
|
||||||
import com.android.internal.view.AppearanceRegion;
|
import com.android.internal.view.AppearanceRegion;
|
||||||
@@ -225,6 +227,25 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
|||||||
private int mCurrentRotation;
|
private int mCurrentRotation;
|
||||||
private boolean mFixedRotationEnabled;
|
private boolean mFixedRotationEnabled;
|
||||||
private ViewTreeObserver.OnGlobalLayoutListener mOrientationHandleGlobalLayoutListener;
|
private ViewTreeObserver.OnGlobalLayoutListener mOrientationHandleGlobalLayoutListener;
|
||||||
|
private UiEventLogger mUiEventLogger;
|
||||||
|
|
||||||
|
@com.android.internal.annotations.VisibleForTesting
|
||||||
|
public enum NavBarActionEvent implements UiEventLogger.UiEventEnum {
|
||||||
|
|
||||||
|
@UiEvent(doc = "Assistant invoked via home button long press.")
|
||||||
|
NAVBAR_ASSIST_LONGPRESS(550);
|
||||||
|
|
||||||
|
private final int mId;
|
||||||
|
|
||||||
|
NavBarActionEvent(int id) {
|
||||||
|
mId = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getId() {
|
||||||
|
return mId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Only for default display */
|
/** Only for default display */
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -367,7 +388,8 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
|||||||
ShadeController shadeController,
|
ShadeController shadeController,
|
||||||
NotificationRemoteInputManager notificationRemoteInputManager,
|
NotificationRemoteInputManager notificationRemoteInputManager,
|
||||||
SystemActions systemActions,
|
SystemActions systemActions,
|
||||||
@Main Handler mainHandler) {
|
@Main Handler mainHandler,
|
||||||
|
UiEventLogger uiEventLogger) {
|
||||||
mAccessibilityManagerWrapper = accessibilityManagerWrapper;
|
mAccessibilityManagerWrapper = accessibilityManagerWrapper;
|
||||||
mDeviceProvisionedController = deviceProvisionedController;
|
mDeviceProvisionedController = deviceProvisionedController;
|
||||||
mStatusBarStateController = statusBarStateController;
|
mStatusBarStateController = statusBarStateController;
|
||||||
@@ -387,6 +409,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
|||||||
mRecentsOptional = recentsOptional;
|
mRecentsOptional = recentsOptional;
|
||||||
mSystemActions = systemActions;
|
mSystemActions = systemActions;
|
||||||
mHandler = mainHandler;
|
mHandler = mainHandler;
|
||||||
|
mUiEventLogger = uiEventLogger;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----- Fragment Lifecycle Callbacks -----
|
// ----- Fragment Lifecycle Callbacks -----
|
||||||
@@ -1008,6 +1031,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mMetricsLogger.action(MetricsEvent.ACTION_ASSIST_LONG_PRESS);
|
mMetricsLogger.action(MetricsEvent.ACTION_ASSIST_LONG_PRESS);
|
||||||
|
mUiEventLogger.log(NavBarActionEvent.NAVBAR_ASSIST_LONGPRESS);
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt(
|
args.putInt(
|
||||||
AssistManager.INVOCATION_TYPE_KEY, AssistManager.INVOCATION_HOME_BUTTON_LONG_PRESS);
|
AssistManager.INVOCATION_TYPE_KEY, AssistManager.INVOCATION_HOME_BUTTON_LONG_PRESS);
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class KeyButtonView extends ImageView implements ButtonInterface {
|
|||||||
private boolean mHasOvalBg = false;
|
private boolean mHasOvalBg = false;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public enum NavBarActionsEvent implements UiEventLogger.UiEventEnum {
|
public enum NavBarButtonEvent implements UiEventLogger.UiEventEnum {
|
||||||
|
|
||||||
@UiEvent(doc = "The home button was pressed in the navigation bar.")
|
@UiEvent(doc = "The home button was pressed in the navigation bar.")
|
||||||
NAVBAR_HOME_BUTTON_TAP(533),
|
NAVBAR_HOME_BUTTON_TAP(533),
|
||||||
@@ -111,7 +111,7 @@ public class KeyButtonView extends ImageView implements ButtonInterface {
|
|||||||
|
|
||||||
private final int mId;
|
private final int mId;
|
||||||
|
|
||||||
NavBarActionsEvent(int id) {
|
NavBarButtonEvent(int id) {
|
||||||
mId = id;
|
mId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,7 +368,7 @@ public class KeyButtonView extends ImageView implements ButtonInterface {
|
|||||||
|
|
||||||
private void logSomePresses(int action, int flags) {
|
private void logSomePresses(int action, int flags) {
|
||||||
boolean longPressSet = (flags & KeyEvent.FLAG_LONG_PRESS) != 0;
|
boolean longPressSet = (flags & KeyEvent.FLAG_LONG_PRESS) != 0;
|
||||||
NavBarActionsEvent uiEvent = NavBarActionsEvent.NONE;
|
NavBarButtonEvent uiEvent = NavBarButtonEvent.NONE;
|
||||||
if (action == MotionEvent.ACTION_UP && mLongClicked) {
|
if (action == MotionEvent.ACTION_UP && mLongClicked) {
|
||||||
return; // don't log the up after a long press
|
return; // don't log the up after a long press
|
||||||
}
|
}
|
||||||
@@ -382,21 +382,21 @@ public class KeyButtonView extends ImageView implements ButtonInterface {
|
|||||||
switch(mCode) {
|
switch(mCode) {
|
||||||
case KeyEvent.KEYCODE_BACK:
|
case KeyEvent.KEYCODE_BACK:
|
||||||
uiEvent = longPressSet
|
uiEvent = longPressSet
|
||||||
? NavBarActionsEvent.NAVBAR_BACK_BUTTON_LONGPRESS
|
? NavBarButtonEvent.NAVBAR_BACK_BUTTON_LONGPRESS
|
||||||
: NavBarActionsEvent.NAVBAR_BACK_BUTTON_TAP;
|
: NavBarButtonEvent.NAVBAR_BACK_BUTTON_TAP;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.KEYCODE_HOME:
|
case KeyEvent.KEYCODE_HOME:
|
||||||
uiEvent = longPressSet
|
uiEvent = longPressSet
|
||||||
? NavBarActionsEvent.NAVBAR_HOME_BUTTON_LONGPRESS
|
? NavBarButtonEvent.NAVBAR_HOME_BUTTON_LONGPRESS
|
||||||
: NavBarActionsEvent.NAVBAR_HOME_BUTTON_TAP;
|
: NavBarButtonEvent.NAVBAR_HOME_BUTTON_TAP;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.KEYCODE_APP_SWITCH:
|
case KeyEvent.KEYCODE_APP_SWITCH:
|
||||||
uiEvent = longPressSet
|
uiEvent = longPressSet
|
||||||
? NavBarActionsEvent.NAVBAR_OVERVIEW_BUTTON_LONGPRESS
|
? NavBarButtonEvent.NAVBAR_OVERVIEW_BUTTON_LONGPRESS
|
||||||
: NavBarActionsEvent.NAVBAR_OVERVIEW_BUTTON_TAP;
|
: NavBarButtonEvent.NAVBAR_OVERVIEW_BUTTON_TAP;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (uiEvent != NavBarActionsEvent.NONE) {
|
if (uiEvent != NavBarButtonEvent.NONE) {
|
||||||
mUiEventLogger.log(uiEvent);
|
mUiEventLogger.log(uiEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import static android.inputmethodservice.InputMethodService.IME_VISIBLE;
|
|||||||
import static android.view.Display.DEFAULT_DISPLAY;
|
import static android.view.Display.DEFAULT_DISPLAY;
|
||||||
import static android.view.DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS;
|
import static android.view.DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS;
|
||||||
|
|
||||||
|
import static com.android.systemui.statusbar.phone.NavigationBarFragment.NavBarActionEvent.NAVBAR_ASSIST_LONGPRESS;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
@@ -28,6 +30,7 @@ import static org.mockito.ArgumentMatchers.any;
|
|||||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@@ -59,6 +62,7 @@ import android.view.accessibility.AccessibilityManager.AccessibilityServicesStat
|
|||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
|
|
||||||
import com.android.internal.logging.MetricsLogger;
|
import com.android.internal.logging.MetricsLogger;
|
||||||
|
import com.android.internal.logging.UiEventLogger;
|
||||||
import com.android.systemui.Dependency;
|
import com.android.systemui.Dependency;
|
||||||
import com.android.systemui.SysuiBaseFragmentTest;
|
import com.android.systemui.SysuiBaseFragmentTest;
|
||||||
import com.android.systemui.SysuiTestableContext;
|
import com.android.systemui.SysuiTestableContext;
|
||||||
@@ -105,6 +109,8 @@ public class NavigationBarFragmentTest extends SysuiBaseFragmentTest {
|
|||||||
private Recents mRecents;
|
private Recents mRecents;
|
||||||
@Mock
|
@Mock
|
||||||
private SystemActions mSystemActions;
|
private SystemActions mSystemActions;
|
||||||
|
@Mock
|
||||||
|
private UiEventLogger mUiEventLogger;
|
||||||
|
|
||||||
private AccessibilityManagerWrapper mAccessibilityWrapper =
|
private AccessibilityManagerWrapper mAccessibilityWrapper =
|
||||||
new AccessibilityManagerWrapper(mContext) {
|
new AccessibilityManagerWrapper(mContext) {
|
||||||
@@ -187,6 +193,8 @@ public class NavigationBarFragmentTest extends SysuiBaseFragmentTest {
|
|||||||
mFragments.dispatchResume();
|
mFragments.dispatchResume();
|
||||||
processAllMessages();
|
processAllMessages();
|
||||||
navigationBarFragment.onHomeLongClick(navigationBarFragment.getView());
|
navigationBarFragment.onHomeLongClick(navigationBarFragment.getView());
|
||||||
|
|
||||||
|
verify(mUiEventLogger, times(1)).log(NAVBAR_ASSIST_LONGPRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -242,6 +250,7 @@ public class NavigationBarFragmentTest extends SysuiBaseFragmentTest {
|
|||||||
protected Fragment instantiate(Context context, String className, Bundle arguments) {
|
protected Fragment instantiate(Context context, String className, Bundle arguments) {
|
||||||
DeviceProvisionedController deviceProvisionedController =
|
DeviceProvisionedController deviceProvisionedController =
|
||||||
mock(DeviceProvisionedController.class);
|
mock(DeviceProvisionedController.class);
|
||||||
|
when(deviceProvisionedController.isDeviceProvisioned()).thenReturn(true);
|
||||||
assertNotNull(mAccessibilityWrapper);
|
assertNotNull(mAccessibilityWrapper);
|
||||||
return new NavigationBarFragment(
|
return new NavigationBarFragment(
|
||||||
context.getDisplayId() == DEFAULT_DISPLAY ? mAccessibilityWrapper
|
context.getDisplayId() == DEFAULT_DISPLAY ? mAccessibilityWrapper
|
||||||
@@ -261,7 +270,8 @@ public class NavigationBarFragmentTest extends SysuiBaseFragmentTest {
|
|||||||
mock(ShadeController.class),
|
mock(ShadeController.class),
|
||||||
mock(NotificationRemoteInputManager.class),
|
mock(NotificationRemoteInputManager.class),
|
||||||
mock(SystemActions.class),
|
mock(SystemActions.class),
|
||||||
mHandler);
|
mHandler,
|
||||||
|
mUiEventLogger);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class HostCallbacksForExternalDisplay extends
|
private class HostCallbacksForExternalDisplay extends
|
||||||
@@ -319,6 +329,7 @@ public class NavigationBarFragmentTest extends SysuiBaseFragmentTest {
|
|||||||
mock(LightBarTransitionsController.class));
|
mock(LightBarTransitionsController.class));
|
||||||
when(view.getRotationButtonController()).thenReturn(
|
when(view.getRotationButtonController()).thenReturn(
|
||||||
mock(RotationButtonController.class));
|
mock(RotationButtonController.class));
|
||||||
|
when(view.isRecentsButtonVisible()).thenReturn(true);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ import static android.view.KeyEvent.KEYCODE_APP_SWITCH;
|
|||||||
import static android.view.KeyEvent.KEYCODE_BACK;
|
import static android.view.KeyEvent.KEYCODE_BACK;
|
||||||
import static android.view.KeyEvent.KEYCODE_HOME;
|
import static android.view.KeyEvent.KEYCODE_HOME;
|
||||||
|
|
||||||
import static com.android.systemui.statusbar.policy.KeyButtonView.NavBarActionsEvent.NAVBAR_BACK_BUTTON_LONGPRESS;
|
import static com.android.systemui.statusbar.policy.KeyButtonView.NavBarButtonEvent.NAVBAR_BACK_BUTTON_LONGPRESS;
|
||||||
import static com.android.systemui.statusbar.policy.KeyButtonView.NavBarActionsEvent.NAVBAR_BACK_BUTTON_TAP;
|
import static com.android.systemui.statusbar.policy.KeyButtonView.NavBarButtonEvent.NAVBAR_BACK_BUTTON_TAP;
|
||||||
import static com.android.systemui.statusbar.policy.KeyButtonView.NavBarActionsEvent.NAVBAR_HOME_BUTTON_LONGPRESS;
|
import static com.android.systemui.statusbar.policy.KeyButtonView.NavBarButtonEvent.NAVBAR_HOME_BUTTON_LONGPRESS;
|
||||||
import static com.android.systemui.statusbar.policy.KeyButtonView.NavBarActionsEvent.NAVBAR_HOME_BUTTON_TAP;
|
import static com.android.systemui.statusbar.policy.KeyButtonView.NavBarButtonEvent.NAVBAR_HOME_BUTTON_TAP;
|
||||||
import static com.android.systemui.statusbar.policy.KeyButtonView.NavBarActionsEvent.NAVBAR_OVERVIEW_BUTTON_LONGPRESS;
|
import static com.android.systemui.statusbar.policy.KeyButtonView.NavBarButtonEvent.NAVBAR_OVERVIEW_BUTTON_LONGPRESS;
|
||||||
import static com.android.systemui.statusbar.policy.KeyButtonView.NavBarActionsEvent.NAVBAR_OVERVIEW_BUTTON_TAP;
|
import static com.android.systemui.statusbar.policy.KeyButtonView.NavBarButtonEvent.NAVBAR_OVERVIEW_BUTTON_TAP;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertEquals;
|
import static junit.framework.Assert.assertEquals;
|
||||||
|
|
||||||
@@ -140,11 +140,11 @@ public class KeyButtonViewTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkmetrics(int code, int action, int flag,
|
private void checkmetrics(int code, int action, int flag,
|
||||||
KeyButtonView.NavBarActionsEvent expected) {
|
KeyButtonView.NavBarButtonEvent expected) {
|
||||||
mKeyButtonView.setCode(code);
|
mKeyButtonView.setCode(code);
|
||||||
mKeyButtonView.sendEvent(action, flag);
|
mKeyButtonView.sendEvent(action, flag);
|
||||||
if (expected == null) {
|
if (expected == null) {
|
||||||
verify(mUiEventLogger, never()).log(any(KeyButtonView.NavBarActionsEvent.class));
|
verify(mUiEventLogger, never()).log(any(KeyButtonView.NavBarButtonEvent.class));
|
||||||
} else {
|
} else {
|
||||||
verify(mUiEventLogger, times(1)).log(expected);
|
verify(mUiEventLogger, times(1)).log(expected);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user