Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file |
| 5 | * except in compliance with the License. You may obtain a copy of the License at |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software distributed under the |
| 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 11 | * KIND, either express or implied. See the License for the specific language governing |
| 12 | * permissions and limitations under the License. |
| 13 | */ |
| 14 | |
| 15 | package com.android.systemui.statusbar.phone; |
| 16 | |
| 17 | import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_ALT; |
| 18 | import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SHOWN; |
| 19 | import static android.app.StatusBarManager.WINDOW_STATE_SHOWING; |
| 20 | import static android.app.StatusBarManager.windowStateToString; |
| 21 | |
Winson Chung | 2dbcf09 | 2018-10-24 13:00:41 -0700 | [diff] [blame^] | 22 | import static com.android.systemui.recents.OverviewProxyService.OverviewProxyListener; |
Matthew Ng | 8f25fb96 | 2018-01-16 17:17:24 -0800 | [diff] [blame] | 23 | import static com.android.systemui.shared.system.NavigationBarCompat.InteractionType; |
Tracy Zhou | 1ac592c | 2018-07-25 13:47:37 -0700 | [diff] [blame] | 24 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT_TRANSPARENT; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 25 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_SEMI_TRANSPARENT; |
Tracy Zhou | 1ac592c | 2018-07-25 13:47:37 -0700 | [diff] [blame] | 26 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 27 | import static com.android.systemui.statusbar.phone.StatusBar.DEBUG_WINDOW_STATE; |
| 28 | import static com.android.systemui.statusbar.phone.StatusBar.dumpBarTransitions; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 29 | |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 30 | import android.accessibilityservice.AccessibilityServiceInfo; |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 31 | import android.annotation.IdRes; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 32 | import android.annotation.Nullable; |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 33 | import android.app.ActivityManager; |
Wale Ogunwale | 65ebd95 | 2018-04-25 15:41:44 -0700 | [diff] [blame] | 34 | import android.app.ActivityTaskManager; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 35 | import android.app.Fragment; |
Wale Ogunwale | 04d9cb5 | 2018-04-30 13:55:07 -0700 | [diff] [blame] | 36 | import android.app.IActivityTaskManager; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 37 | import android.app.StatusBarManager; |
| 38 | import android.content.BroadcastReceiver; |
Casey Burkhardt | b9dcd66 | 2017-03-20 15:10:16 -0700 | [diff] [blame] | 39 | import android.content.ContentResolver; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 40 | import android.content.Context; |
| 41 | import android.content.Intent; |
| 42 | import android.content.IntentFilter; |
| 43 | import android.content.res.Configuration; |
Casey Burkhardt | 74922c6 | 2017-02-13 12:43:16 -0800 | [diff] [blame] | 44 | import android.database.ContentObserver; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 45 | import android.graphics.PixelFormat; |
| 46 | import android.graphics.Rect; |
| 47 | import android.inputmethodservice.InputMethodService; |
| 48 | import android.os.Binder; |
| 49 | import android.os.Bundle; |
| 50 | import android.os.Handler; |
| 51 | import android.os.IBinder; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 52 | import android.os.RemoteException; |
| 53 | import android.os.UserHandle; |
Casey Burkhardt | 74922c6 | 2017-02-13 12:43:16 -0800 | [diff] [blame] | 54 | import android.provider.Settings; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 55 | import android.telecom.TelecomManager; |
| 56 | import android.text.TextUtils; |
| 57 | import android.util.Log; |
| 58 | import android.view.IRotationWatcher.Stub; |
| 59 | import android.view.KeyEvent; |
| 60 | import android.view.LayoutInflater; |
| 61 | import android.view.MotionEvent; |
Mike Digman | 85ff7fa | 2018-01-23 14:59:52 -0800 | [diff] [blame] | 62 | import android.view.Surface; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 63 | import android.view.View; |
| 64 | import android.view.ViewGroup; |
| 65 | import android.view.WindowManager; |
| 66 | import android.view.WindowManager.LayoutParams; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 67 | import android.view.accessibility.AccessibilityEvent; |
| 68 | import android.view.accessibility.AccessibilityManager; |
Jason Monk | 91e587e | 2017-04-13 13:41:23 -0400 | [diff] [blame] | 69 | import android.view.accessibility.AccessibilityManager.AccessibilityServicesStateChangeListener; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 70 | |
Matthew Ng | 761562d | 2018-09-17 11:13:21 -0700 | [diff] [blame] | 71 | import androidx.annotation.VisibleForTesting; |
| 72 | |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 73 | import com.android.internal.logging.MetricsLogger; |
| 74 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
Jason Monk | ea03be1 | 2017-12-04 11:08:41 -0500 | [diff] [blame] | 75 | import com.android.internal.util.LatencyTracker; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 76 | import com.android.systemui.Dependency; |
Winson Chung | 2dbcf09 | 2018-10-24 13:00:41 -0700 | [diff] [blame^] | 77 | import com.android.systemui.recents.OverviewProxyService; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 78 | import com.android.systemui.R; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 79 | import com.android.systemui.SysUiServiceProvider; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 80 | import com.android.systemui.assist.AssistManager; |
| 81 | import com.android.systemui.fragments.FragmentHostManager; |
| 82 | import com.android.systemui.fragments.FragmentHostManager.FragmentListener; |
| 83 | import com.android.systemui.recents.Recents; |
Mike Digman | 7d09277 | 2018-01-11 12:10:32 -0800 | [diff] [blame] | 84 | import com.android.systemui.shared.system.ActivityManagerWrapper; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 85 | import com.android.systemui.stackdivider.Divider; |
| 86 | import com.android.systemui.statusbar.CommandQueue; |
| 87 | import com.android.systemui.statusbar.CommandQueue.Callbacks; |
Matthew Ng | 761562d | 2018-09-17 11:13:21 -0700 | [diff] [blame] | 88 | import com.android.systemui.statusbar.notification.stack.StackStateAnimator; |
| 89 | import com.android.systemui.statusbar.phone.ContextualButton.ContextButtonListener; |
Jason Monk | 91e587e | 2017-04-13 13:41:23 -0400 | [diff] [blame] | 90 | import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 91 | import com.android.systemui.statusbar.policy.DeviceProvisionedController; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 92 | import com.android.systemui.statusbar.policy.KeyButtonView; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 93 | |
| 94 | import java.io.FileDescriptor; |
| 95 | import java.io.PrintWriter; |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 96 | import java.util.List; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 97 | import java.util.Locale; |
Matthew Ng | 761562d | 2018-09-17 11:13:21 -0700 | [diff] [blame] | 98 | import java.util.function.Consumer; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 99 | |
| 100 | /** |
| 101 | * Fragment containing the NavigationBarFragment. Contains logic for what happens |
| 102 | * on clicks and view states of the nav bar. |
| 103 | */ |
| 104 | public class NavigationBarFragment extends Fragment implements Callbacks { |
| 105 | |
Jason Monk | d4afe15 | 2017-05-01 15:37:43 -0400 | [diff] [blame] | 106 | public static final String TAG = "NavigationBar"; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 107 | private static final boolean DEBUG = false; |
| 108 | private static final String EXTRA_DISABLE_STATE = "disabled_state"; |
Mike Digman | dd2f49e | 2018-03-16 10:54:22 -0700 | [diff] [blame] | 109 | private static final String EXTRA_DISABLE2_STATE = "disabled2_state"; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 110 | |
| 111 | /** Allow some time inbetween the long press for back and recents. */ |
| 112 | private static final int LOCK_TO_APP_GESTURE_TOLERENCE = 200; |
| 113 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 114 | private final DeviceProvisionedController mDeviceProvisionedController = |
| 115 | Dependency.get(DeviceProvisionedController.class); |
| 116 | |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 117 | protected NavigationBarView mNavigationBarView = null; |
| 118 | protected AssistManager mAssistManager; |
| 119 | |
| 120 | private int mNavigationBarWindowState = WINDOW_STATE_SHOWING; |
| 121 | |
| 122 | private int mNavigationIconHints = 0; |
| 123 | private int mNavigationBarMode; |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 124 | private AccessibilityManager mAccessibilityManager; |
Casey Burkhardt | 74922c6 | 2017-02-13 12:43:16 -0800 | [diff] [blame] | 125 | private MagnificationContentObserver mMagnificationObserver; |
Casey Burkhardt | b9dcd66 | 2017-03-20 15:10:16 -0700 | [diff] [blame] | 126 | private ContentResolver mContentResolver; |
Mike Digman | c94759d | 2018-01-23 11:01:21 -0800 | [diff] [blame] | 127 | private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 128 | |
| 129 | private int mDisabledFlags1; |
Mike Digman | dd2f49e | 2018-03-16 10:54:22 -0700 | [diff] [blame] | 130 | private int mDisabledFlags2; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 131 | private StatusBar mStatusBar; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 132 | private Recents mRecents; |
| 133 | private Divider mDivider; |
| 134 | private WindowManager mWindowManager; |
| 135 | private CommandQueue mCommandQueue; |
| 136 | private long mLastLockToAppLongPress; |
| 137 | |
| 138 | private Locale mLocale; |
| 139 | private int mLayoutDirection; |
| 140 | |
| 141 | private int mSystemUiVisibility; |
| 142 | private LightBarController mLightBarController; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 143 | |
Matthew Ng | dc79e5c | 2017-12-14 17:37:35 -0800 | [diff] [blame] | 144 | private OverviewProxyService mOverviewProxyService; |
| 145 | |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 146 | public boolean mHomeBlockedThisTouch; |
| 147 | |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 148 | private final OverviewProxyListener mOverviewProxyListener = new OverviewProxyListener() { |
| 149 | @Override |
| 150 | public void onConnectionChanged(boolean isConnected) { |
Winson Chung | f9e3027 | 2018-03-26 17:25:36 -0700 | [diff] [blame] | 151 | mNavigationBarView.updateStates(); |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 152 | updateScreenPinningGestures(); |
| 153 | } |
| 154 | |
| 155 | @Override |
Matthew Ng | 2ea93b7 | 2018-03-14 19:43:18 +0000 | [diff] [blame] | 156 | public void onQuickStepStarted() { |
Mike Digman | 85a9bea | 2018-02-23 15:08:53 -0800 | [diff] [blame] | 157 | // Use navbar dragging as a signal to hide the rotate button |
Matthew Ng | 761562d | 2018-09-17 11:13:21 -0700 | [diff] [blame] | 158 | mNavigationBarView.getRotateSuggestionButton().setRotateSuggestionButtonState(false); |
Matthew Ng | 90ef063 | 2018-08-15 13:53:15 -0700 | [diff] [blame] | 159 | |
| 160 | // Hide the notifications panel when quick step starts |
| 161 | mStatusBar.collapsePanel(true /* animate */); |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 162 | } |
Matthew Ng | 8f25fb96 | 2018-01-16 17:17:24 -0800 | [diff] [blame] | 163 | |
| 164 | @Override |
| 165 | public void onInteractionFlagsChanged(@InteractionType int flags) { |
| 166 | mNavigationBarView.updateStates(); |
Winson Chung | f9e3027 | 2018-03-26 17:25:36 -0700 | [diff] [blame] | 167 | updateScreenPinningGestures(); |
Matthew Ng | 8f25fb96 | 2018-01-16 17:17:24 -0800 | [diff] [blame] | 168 | } |
Matthew Ng | 96985e7 | 2018-05-08 15:46:13 -0700 | [diff] [blame] | 169 | |
| 170 | @Override |
| 171 | public void onBackButtonAlphaChanged(float alpha, boolean animate) { |
| 172 | final ButtonDispatcher backButton = mNavigationBarView.getBackButton(); |
Matthew Ng | b687c8a | 2018-10-02 11:31:38 -0700 | [diff] [blame] | 173 | if (QuickStepController.shouldhideBackButton(getContext())) { |
Matthew Ng | c83b989 | 2018-08-21 16:31:13 -0700 | [diff] [blame] | 174 | // If property was changed to hide/show back button, going home will trigger |
| 175 | // launcher to to change the back button alpha to reflect property change |
| 176 | backButton.setVisibility(View.GONE); |
| 177 | } else { |
| 178 | backButton.setVisibility(alpha > 0 ? View.VISIBLE : View.INVISIBLE); |
| 179 | backButton.setAlpha(alpha, animate); |
| 180 | } |
Matthew Ng | 96985e7 | 2018-05-08 15:46:13 -0700 | [diff] [blame] | 181 | } |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 182 | }; |
Mike Digman | 7d09277 | 2018-01-11 12:10:32 -0800 | [diff] [blame] | 183 | |
Matthew Ng | 761562d | 2018-09-17 11:13:21 -0700 | [diff] [blame] | 184 | private final ContextButtonListener mRotationButtonListener = new ContextButtonListener() { |
| 185 | @Override |
| 186 | public void onVisibilityChanged(ContextualButton button, boolean visible) { |
| 187 | if (visible) { |
| 188 | // If the button will actually become visible and the navbar is about to hide, |
| 189 | // tell the statusbar to keep it around for longer |
| 190 | mStatusBar.touchAutoHide(); |
| 191 | } |
| 192 | } |
| 193 | }; |
| 194 | |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 195 | // ----- Fragment Lifecycle Callbacks ----- |
| 196 | |
| 197 | @Override |
| 198 | public void onCreate(@Nullable Bundle savedInstanceState) { |
| 199 | super.onCreate(savedInstanceState); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 200 | mCommandQueue = SysUiServiceProvider.getComponent(getContext(), CommandQueue.class); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 201 | mCommandQueue.addCallbacks(this); |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 202 | mStatusBar = SysUiServiceProvider.getComponent(getContext(), StatusBar.class); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 203 | mRecents = SysUiServiceProvider.getComponent(getContext(), Recents.class); |
| 204 | mDivider = SysUiServiceProvider.getComponent(getContext(), Divider.class); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 205 | mWindowManager = getContext().getSystemService(WindowManager.class); |
| 206 | mAccessibilityManager = getContext().getSystemService(AccessibilityManager.class); |
Jason Monk | 91e587e | 2017-04-13 13:41:23 -0400 | [diff] [blame] | 207 | Dependency.get(AccessibilityManagerWrapper.class).addCallback( |
| 208 | mAccessibilityListener); |
Casey Burkhardt | b9dcd66 | 2017-03-20 15:10:16 -0700 | [diff] [blame] | 209 | mContentResolver = getContext().getContentResolver(); |
Casey Burkhardt | 74922c6 | 2017-02-13 12:43:16 -0800 | [diff] [blame] | 210 | mMagnificationObserver = new MagnificationContentObserver( |
| 211 | getContext().getMainThreadHandler()); |
Casey Burkhardt | b9dcd66 | 2017-03-20 15:10:16 -0700 | [diff] [blame] | 212 | mContentResolver.registerContentObserver(Settings.Secure.getUriFor( |
Casey Burkhardt | 74922c6 | 2017-02-13 12:43:16 -0800 | [diff] [blame] | 213 | Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED), false, |
Casey Burkhardt | 5d61440 | 2017-04-06 13:46:50 -0700 | [diff] [blame] | 214 | mMagnificationObserver, UserHandle.USER_ALL); |
Casey Burkhardt | 74922c6 | 2017-02-13 12:43:16 -0800 | [diff] [blame] | 215 | |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 216 | if (savedInstanceState != null) { |
| 217 | mDisabledFlags1 = savedInstanceState.getInt(EXTRA_DISABLE_STATE, 0); |
Mike Digman | dd2f49e | 2018-03-16 10:54:22 -0700 | [diff] [blame] | 218 | mDisabledFlags2 = savedInstanceState.getInt(EXTRA_DISABLE2_STATE, 0); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 219 | } |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 220 | mAssistManager = Dependency.get(AssistManager.class); |
Matthew Ng | dc79e5c | 2017-12-14 17:37:35 -0800 | [diff] [blame] | 221 | mOverviewProxyService = Dependency.get(OverviewProxyService.class); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | @Override |
| 225 | public void onDestroy() { |
| 226 | super.onDestroy(); |
| 227 | mCommandQueue.removeCallbacks(this); |
Jason Monk | 91e587e | 2017-04-13 13:41:23 -0400 | [diff] [blame] | 228 | Dependency.get(AccessibilityManagerWrapper.class).removeCallback( |
| 229 | mAccessibilityListener); |
Casey Burkhardt | b9dcd66 | 2017-03-20 15:10:16 -0700 | [diff] [blame] | 230 | mContentResolver.unregisterContentObserver(mMagnificationObserver); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | @Override |
| 234 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, |
| 235 | Bundle savedInstanceState) { |
| 236 | return inflater.inflate(R.layout.navigation_bar, container, false); |
| 237 | } |
| 238 | |
| 239 | @Override |
| 240 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { |
| 241 | super.onViewCreated(view, savedInstanceState); |
| 242 | mNavigationBarView = (NavigationBarView) view; |
| 243 | |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 244 | mNavigationBarView.setComponents(mStatusBar.getPanel()); |
Matthew Ng | f0f8454 | 2018-10-15 11:53:22 -0700 | [diff] [blame] | 245 | mNavigationBarView.setDisabledFlags(mDisabledFlags1); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 246 | mNavigationBarView.setOnVerticalChangedListener(this::onVerticalChanged); |
| 247 | mNavigationBarView.setOnTouchListener(this::onNavigationTouch); |
| 248 | if (savedInstanceState != null) { |
| 249 | mNavigationBarView.getLightTransitionsController().restoreState(savedInstanceState); |
| 250 | } |
| 251 | |
| 252 | prepareNavigationBarView(); |
| 253 | checkNavBarModes(); |
| 254 | |
Mike Digman | dd2f49e | 2018-03-16 10:54:22 -0700 | [diff] [blame] | 255 | setDisabled2Flags(mDisabledFlags2); |
| 256 | |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 257 | IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF); |
| 258 | filter.addAction(Intent.ACTION_SCREEN_ON); |
Phil Weaver | a858c5f | 2018-04-26 13:27:30 -0700 | [diff] [blame] | 259 | filter.addAction(Intent.ACTION_USER_SWITCHED); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 260 | getContext().registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null); |
Siarhei Vishniakou | d002a0a | 2017-06-05 22:44:37 +0100 | [diff] [blame] | 261 | notifyNavigationBarScreenOn(); |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 262 | mOverviewProxyService.addCallback(mOverviewProxyListener); |
Matthew Ng | 761562d | 2018-09-17 11:13:21 -0700 | [diff] [blame] | 263 | |
| 264 | RotationContextButton rotationButton = mNavigationBarView.getRotateSuggestionButton(); |
| 265 | rotationButton.setListener(mRotationButtonListener); |
| 266 | rotationButton.addRotationCallback(mRotationWatcher); |
| 267 | |
| 268 | // Reset user rotation pref to match that of the WindowManager if starting in locked mode |
| 269 | // This will automatically happen when switching from auto-rotate to locked mode |
| 270 | if (rotationButton.isRotationLocked()) { |
| 271 | final int winRotation = mWindowManager.getDefaultDisplay().getRotation(); |
| 272 | rotationButton.setRotationLockedAtAngle(winRotation); |
| 273 | } |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | @Override |
| 277 | public void onDestroyView() { |
| 278 | super.onDestroyView(); |
Winson Chung | b03d44d | 2018-09-18 12:42:45 -0700 | [diff] [blame] | 279 | if (mNavigationBarView != null) { |
| 280 | mNavigationBarView.getBarTransitions().destroy(); |
| 281 | mNavigationBarView.getLightTransitionsController().destroy(getContext()); |
| 282 | } |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 283 | mOverviewProxyService.removeCallback(mOverviewProxyListener); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 284 | getContext().unregisterReceiver(mBroadcastReceiver); |
| 285 | } |
| 286 | |
| 287 | @Override |
| 288 | public void onSaveInstanceState(Bundle outState) { |
| 289 | super.onSaveInstanceState(outState); |
| 290 | outState.putInt(EXTRA_DISABLE_STATE, mDisabledFlags1); |
Mike Digman | dd2f49e | 2018-03-16 10:54:22 -0700 | [diff] [blame] | 291 | outState.putInt(EXTRA_DISABLE2_STATE, mDisabledFlags2); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 292 | if (mNavigationBarView != null) { |
| 293 | mNavigationBarView.getLightTransitionsController().saveState(outState); |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | @Override |
| 298 | public void onConfigurationChanged(Configuration newConfig) { |
| 299 | super.onConfigurationChanged(newConfig); |
| 300 | final Locale locale = getContext().getResources().getConfiguration().locale; |
| 301 | final int ld = TextUtils.getLayoutDirectionFromLocale(locale); |
| 302 | if (!locale.equals(mLocale) || ld != mLayoutDirection) { |
| 303 | if (DEBUG) { |
| 304 | Log.v(TAG, String.format( |
| 305 | "config changed locale/LD: %s (%d) -> %s (%d)", mLocale, mLayoutDirection, |
| 306 | locale, ld)); |
| 307 | } |
| 308 | mLocale = locale; |
| 309 | mLayoutDirection = ld; |
| 310 | refreshLayout(ld); |
| 311 | } |
| 312 | repositionNavigationBar(); |
| 313 | } |
| 314 | |
| 315 | @Override |
| 316 | public void dump(String prefix, FileDescriptor fd, PrintWriter pw, String[] args) { |
| 317 | if (mNavigationBarView != null) { |
| 318 | pw.print(" mNavigationBarWindowState="); |
| 319 | pw.println(windowStateToString(mNavigationBarWindowState)); |
| 320 | pw.print(" mNavigationBarMode="); |
| 321 | pw.println(BarTransitions.modeToString(mNavigationBarMode)); |
| 322 | dumpBarTransitions(pw, "mNavigationBarView", mNavigationBarView.getBarTransitions()); |
| 323 | } |
| 324 | |
| 325 | pw.print(" mNavigationBarView="); |
| 326 | if (mNavigationBarView == null) { |
| 327 | pw.println("null"); |
| 328 | } else { |
| 329 | mNavigationBarView.dump(fd, pw, args); |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | // ----- CommandQueue Callbacks ----- |
| 334 | |
| 335 | @Override |
| 336 | public void setImeWindowStatus(IBinder token, int vis, int backDisposition, |
| 337 | boolean showImeSwitcher) { |
| 338 | boolean imeShown = (vis & InputMethodService.IME_VISIBLE) != 0; |
| 339 | int hints = mNavigationIconHints; |
Yohei Yukawa | 386f50e | 2018-03-14 13:03:42 -0700 | [diff] [blame] | 340 | switch (backDisposition) { |
| 341 | case InputMethodService.BACK_DISPOSITION_DEFAULT: |
| 342 | case InputMethodService.BACK_DISPOSITION_WILL_NOT_DISMISS: |
| 343 | case InputMethodService.BACK_DISPOSITION_WILL_DISMISS: |
| 344 | if (imeShown) { |
| 345 | hints |= NAVIGATION_HINT_BACK_ALT; |
| 346 | } else { |
| 347 | hints &= ~NAVIGATION_HINT_BACK_ALT; |
| 348 | } |
| 349 | break; |
| 350 | case InputMethodService.BACK_DISPOSITION_ADJUST_NOTHING: |
| 351 | hints &= ~NAVIGATION_HINT_BACK_ALT; |
| 352 | break; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 353 | } |
| 354 | if (showImeSwitcher) { |
| 355 | hints |= NAVIGATION_HINT_IME_SHOWN; |
| 356 | } else { |
| 357 | hints &= ~NAVIGATION_HINT_IME_SHOWN; |
| 358 | } |
| 359 | if (hints == mNavigationIconHints) return; |
| 360 | |
| 361 | mNavigationIconHints = hints; |
| 362 | |
| 363 | if (mNavigationBarView != null) { |
| 364 | mNavigationBarView.setNavigationIconHints(hints); |
| 365 | } |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 366 | mStatusBar.checkBarModes(); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | @Override |
| 370 | public void topAppWindowChanged(boolean showMenu) { |
| 371 | if (mNavigationBarView != null) { |
| 372 | mNavigationBarView.setMenuVisibility(showMenu); |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | @Override |
| 377 | public void setWindowState(int window, int state) { |
| 378 | if (mNavigationBarView != null |
| 379 | && window == StatusBarManager.WINDOW_NAVIGATION_BAR |
| 380 | && mNavigationBarWindowState != state) { |
| 381 | mNavigationBarWindowState = state; |
| 382 | if (DEBUG_WINDOW_STATE) Log.d(TAG, "Navigation bar " + windowStateToString(state)); |
Mike Digman | 5aeca79 | 2018-03-05 11:14:39 -0800 | [diff] [blame] | 383 | |
Matthew Ng | 761562d | 2018-09-17 11:13:21 -0700 | [diff] [blame] | 384 | mNavigationBarView.getRotateSuggestionButton() |
| 385 | .onNavigationBarWindowVisibilityChange(state == WINDOW_STATE_SHOWING); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 386 | } |
| 387 | } |
| 388 | |
Mike Digman | 7d09277 | 2018-01-11 12:10:32 -0800 | [diff] [blame] | 389 | @Override |
Mike Digman | e077731 | 2018-01-19 12:41:51 -0800 | [diff] [blame] | 390 | public void onRotationProposal(final int rotation, boolean isValid) { |
Mike Digman | 3e33da6 | 2018-03-14 16:25:11 -0700 | [diff] [blame] | 391 | final int winRotation = mWindowManager.getDefaultDisplay().getRotation(); |
Matthew Ng | 761562d | 2018-09-17 11:13:21 -0700 | [diff] [blame] | 392 | final boolean rotateSuggestionsDisabled = RotationContextButton |
| 393 | .hasDisable2RotateSuggestionFlag(mDisabledFlags2); |
| 394 | if (RotationContextButton.DEBUG_ROTATION) { |
Mike Digman | 3e33da6 | 2018-03-14 16:25:11 -0700 | [diff] [blame] | 395 | Log.v(TAG, "onRotationProposal proposedRotation=" + Surface.rotationToString(rotation) |
| 396 | + ", winRotation=" + Surface.rotationToString(winRotation) |
| 397 | + ", isValid=" + isValid + ", mNavBarWindowState=" |
| 398 | + StatusBarManager.windowStateToString(mNavigationBarWindowState) |
Mike Digman | dd2f49e | 2018-03-16 10:54:22 -0700 | [diff] [blame] | 399 | + ", rotateSuggestionsDisabled=" + rotateSuggestionsDisabled |
Mike Digman | 3e33da6 | 2018-03-14 16:25:11 -0700 | [diff] [blame] | 400 | + ", isRotateButtonVisible=" + (mNavigationBarView == null ? "null" : |
Matthew Ng | 761562d | 2018-09-17 11:13:21 -0700 | [diff] [blame] | 401 | mNavigationBarView.getRotateSuggestionButton().isVisible())); |
Mike Digman | 3e33da6 | 2018-03-14 16:25:11 -0700 | [diff] [blame] | 402 | } |
| 403 | |
Mike Digman | dd2f49e | 2018-03-16 10:54:22 -0700 | [diff] [blame] | 404 | // Respect the disabled flag, no need for action as flag change callback will handle hiding |
| 405 | if (rotateSuggestionsDisabled) return; |
| 406 | |
Matthew Ng | 761562d | 2018-09-17 11:13:21 -0700 | [diff] [blame] | 407 | mNavigationBarView.getRotateSuggestionButton() |
| 408 | .onRotationProposal(rotation, winRotation, isValid); |
Mike Digman | 5075264 | 2018-02-15 13:36:09 -0800 | [diff] [blame] | 409 | } |
| 410 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 411 | // Injected from StatusBar at creation. |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 412 | public void setCurrentSysuiVisibility(int systemUiVisibility) { |
| 413 | mSystemUiVisibility = systemUiVisibility; |
Matthew Ng | 5a25020 | 2018-10-09 16:09:27 -0700 | [diff] [blame] | 414 | final int barMode = mStatusBar.computeBarMode(0, mSystemUiVisibility, |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 415 | View.NAVIGATION_BAR_TRANSIENT, View.NAVIGATION_BAR_TRANSLUCENT, |
| 416 | View.NAVIGATION_BAR_TRANSPARENT); |
Matthew Ng | 5a25020 | 2018-10-09 16:09:27 -0700 | [diff] [blame] | 417 | if (barMode != -1) { |
| 418 | mNavigationBarMode = barMode; |
| 419 | } |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 420 | checkNavBarModes(); |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 421 | mStatusBar.touchAutoHide(); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 422 | mLightBarController.onNavigationVisibilityChanged(mSystemUiVisibility, 0 /* mask */, |
| 423 | true /* nbModeChanged */, mNavigationBarMode); |
| 424 | } |
| 425 | |
| 426 | @Override |
| 427 | public void setSystemUiVisibility(int vis, int fullscreenStackVis, int dockedStackVis, |
| 428 | int mask, Rect fullscreenStackBounds, Rect dockedStackBounds) { |
| 429 | final int oldVal = mSystemUiVisibility; |
| 430 | final int newVal = (oldVal & ~mask) | (vis & mask); |
| 431 | final int diff = newVal ^ oldVal; |
| 432 | boolean nbModeChanged = false; |
| 433 | if (diff != 0) { |
| 434 | mSystemUiVisibility = newVal; |
| 435 | |
| 436 | // update navigation bar mode |
| 437 | final int nbMode = getView() == null |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 438 | ? -1 : mStatusBar.computeBarMode(oldVal, newVal, |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 439 | View.NAVIGATION_BAR_TRANSIENT, View.NAVIGATION_BAR_TRANSLUCENT, |
| 440 | View.NAVIGATION_BAR_TRANSPARENT); |
| 441 | nbModeChanged = nbMode != -1; |
| 442 | if (nbModeChanged) { |
| 443 | if (mNavigationBarMode != nbMode) { |
Tracy Zhou | 1ac592c | 2018-07-25 13:47:37 -0700 | [diff] [blame] | 444 | if (mNavigationBarMode == MODE_TRANSPARENT |
| 445 | || mNavigationBarMode == MODE_LIGHTS_OUT_TRANSPARENT) { |
| 446 | mNavigationBarView.hideRecentsOnboarding(); |
| 447 | } |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 448 | mNavigationBarMode = nbMode; |
| 449 | checkNavBarModes(); |
| 450 | } |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 451 | mStatusBar.touchAutoHide(); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 452 | } |
| 453 | } |
| 454 | |
| 455 | mLightBarController.onNavigationVisibilityChanged(vis, mask, nbModeChanged, |
| 456 | mNavigationBarMode); |
| 457 | } |
| 458 | |
| 459 | @Override |
| 460 | public void disable(int state1, int state2, boolean animate) { |
Mike Digman | dd2f49e | 2018-03-16 10:54:22 -0700 | [diff] [blame] | 461 | // Navigation bar flags are in both state1 and state2. |
| 462 | final int masked = state1 & (StatusBarManager.DISABLE_HOME |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 463 | | StatusBarManager.DISABLE_RECENT |
| 464 | | StatusBarManager.DISABLE_BACK |
| 465 | | StatusBarManager.DISABLE_SEARCH); |
| 466 | if (masked != mDisabledFlags1) { |
| 467 | mDisabledFlags1 = masked; |
| 468 | if (mNavigationBarView != null) mNavigationBarView.setDisabledFlags(state1); |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 469 | updateScreenPinningGestures(); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 470 | } |
Mike Digman | dd2f49e | 2018-03-16 10:54:22 -0700 | [diff] [blame] | 471 | |
| 472 | final int masked2 = state2 & (StatusBarManager.DISABLE2_ROTATE_SUGGESTIONS); |
| 473 | if (masked2 != mDisabledFlags2) { |
| 474 | mDisabledFlags2 = masked2; |
| 475 | setDisabled2Flags(masked2); |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | private void setDisabled2Flags(int state2) { |
| 480 | // Method only called on change of disable2 flags |
Evan Laird | b8b717f | 2018-10-25 14:08:32 -0400 | [diff] [blame] | 481 | if (mNavigationBarView != null) { |
| 482 | mNavigationBarView.getRotateSuggestionButton().onDisable2FlagChanged(state2); |
| 483 | } |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | // ----- Internal stuffz ----- |
| 487 | |
| 488 | private void refreshLayout(int layoutDirection) { |
| 489 | if (mNavigationBarView != null) { |
| 490 | mNavigationBarView.setLayoutDirection(layoutDirection); |
| 491 | } |
| 492 | } |
| 493 | |
| 494 | private boolean shouldDisableNavbarGestures() { |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 495 | return !mDeviceProvisionedController.isDeviceProvisioned() |
Matthew Ng | fee0b5b | 2018-02-21 15:38:21 -0800 | [diff] [blame] | 496 | || (mDisabledFlags1 & StatusBarManager.DISABLE_SEARCH) != 0; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | private void repositionNavigationBar() { |
| 500 | if (mNavigationBarView == null || !mNavigationBarView.isAttachedToWindow()) return; |
| 501 | |
| 502 | prepareNavigationBarView(); |
| 503 | |
| 504 | mWindowManager.updateViewLayout((View) mNavigationBarView.getParent(), |
| 505 | ((View) mNavigationBarView.getParent()).getLayoutParams()); |
| 506 | } |
| 507 | |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 508 | private void updateScreenPinningGestures() { |
| 509 | if (mNavigationBarView == null) { |
| 510 | return; |
| 511 | } |
| 512 | |
| 513 | // Change the cancel pin gesture to home and back if recents button is invisible |
| 514 | boolean recentsVisible = mNavigationBarView.isRecentsButtonVisible(); |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 515 | ButtonDispatcher backButton = mNavigationBarView.getBackButton(); |
| 516 | if (recentsVisible) { |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 517 | backButton.setOnLongClickListener(this::onLongPressBackRecents); |
| 518 | } else { |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 519 | backButton.setOnLongClickListener(this::onLongPressBackHome); |
| 520 | } |
| 521 | } |
| 522 | |
Siarhei Vishniakou | d002a0a | 2017-06-05 22:44:37 +0100 | [diff] [blame] | 523 | private void notifyNavigationBarScreenOn() { |
Matthew Ng | d0a73e7 | 2018-03-02 15:16:03 -0800 | [diff] [blame] | 524 | mNavigationBarView.updateNavButtonIcons(); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 525 | } |
| 526 | |
| 527 | private void prepareNavigationBarView() { |
| 528 | mNavigationBarView.reorient(); |
| 529 | |
| 530 | ButtonDispatcher recentsButton = mNavigationBarView.getRecentsButton(); |
| 531 | recentsButton.setOnClickListener(this::onRecentsClick); |
| 532 | recentsButton.setOnTouchListener(this::onRecentsTouch); |
| 533 | recentsButton.setLongClickable(true); |
| 534 | recentsButton.setOnLongClickListener(this::onLongPressBackRecents); |
| 535 | |
| 536 | ButtonDispatcher backButton = mNavigationBarView.getBackButton(); |
| 537 | backButton.setLongClickable(true); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 538 | |
| 539 | ButtonDispatcher homeButton = mNavigationBarView.getHomeButton(); |
| 540 | homeButton.setOnTouchListener(this::onHomeTouch); |
Matthew Ng | fee0b5b | 2018-02-21 15:38:21 -0800 | [diff] [blame] | 541 | homeButton.setOnLongClickListener(this::onHomeLongClick); |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 542 | |
| 543 | ButtonDispatcher accessibilityButton = mNavigationBarView.getAccessibilityButton(); |
| 544 | accessibilityButton.setOnClickListener(this::onAccessibilityClick); |
| 545 | accessibilityButton.setOnLongClickListener(this::onAccessibilityLongClick); |
Phil Weaver | db9a774 | 2017-04-18 08:15:06 -0700 | [diff] [blame] | 546 | updateAccessibilityServicesState(mAccessibilityManager); |
Mike Digman | 7d09277 | 2018-01-11 12:10:32 -0800 | [diff] [blame] | 547 | |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 548 | updateScreenPinningGestures(); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | private boolean onHomeTouch(View v, MotionEvent event) { |
| 552 | if (mHomeBlockedThisTouch && event.getActionMasked() != MotionEvent.ACTION_DOWN) { |
| 553 | return true; |
| 554 | } |
| 555 | // If an incoming call is ringing, HOME is totally disabled. |
| 556 | // (The user is already on the InCallUI at this point, |
| 557 | // and his ONLY options are to answer or reject the call.) |
| 558 | switch (event.getAction()) { |
| 559 | case MotionEvent.ACTION_DOWN: |
| 560 | mHomeBlockedThisTouch = false; |
| 561 | TelecomManager telecomManager = |
| 562 | getContext().getSystemService(TelecomManager.class); |
| 563 | if (telecomManager != null && telecomManager.isRinging()) { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 564 | if (mStatusBar.isKeyguardShowing()) { |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 565 | Log.i(TAG, "Ignoring HOME; there's a ringing incoming call. " + |
| 566 | "No heads up"); |
| 567 | mHomeBlockedThisTouch = true; |
| 568 | return true; |
| 569 | } |
| 570 | } |
| 571 | break; |
| 572 | case MotionEvent.ACTION_UP: |
| 573 | case MotionEvent.ACTION_CANCEL: |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 574 | mStatusBar.awakenDreams(); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 575 | break; |
| 576 | } |
| 577 | return false; |
| 578 | } |
| 579 | |
| 580 | private void onVerticalChanged(boolean isVertical) { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 581 | mStatusBar.setQsScrimEnabled(!isVertical); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 582 | } |
| 583 | |
| 584 | private boolean onNavigationTouch(View v, MotionEvent event) { |
Eliot Courtney | cb5d316 | 2017-08-09 16:53:15 +0900 | [diff] [blame] | 585 | mStatusBar.checkUserAutohide(event); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 586 | return false; |
| 587 | } |
| 588 | |
Jason Monk | 865246d | 2017-01-19 08:27:01 -0500 | [diff] [blame] | 589 | @VisibleForTesting |
| 590 | boolean onHomeLongClick(View v) { |
Matthew Ng | 6ff33b7 | 2018-02-27 13:47:38 -0800 | [diff] [blame] | 591 | if (!mNavigationBarView.isRecentsButtonVisible() |
| 592 | && ActivityManagerWrapper.getInstance().isScreenPinningActive()) { |
Matthew Ng | fee0b5b | 2018-02-21 15:38:21 -0800 | [diff] [blame] | 593 | return onLongPressBackHome(v); |
| 594 | } |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 595 | if (shouldDisableNavbarGestures()) { |
| 596 | return false; |
| 597 | } |
Matthew Ng | 2ea93b7 | 2018-03-14 19:43:18 +0000 | [diff] [blame] | 598 | mNavigationBarView.onNavigationButtonLongPress(v); |
Mike Digman | c94759d | 2018-01-23 11:01:21 -0800 | [diff] [blame] | 599 | mMetricsLogger.action(MetricsEvent.ACTION_ASSIST_LONG_PRESS); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 600 | mAssistManager.startAssist(new Bundle() /* args */); |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 601 | mStatusBar.awakenDreams(); |
Matthew Ng | dc79e5c | 2017-12-14 17:37:35 -0800 | [diff] [blame] | 602 | |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 603 | if (mNavigationBarView != null) { |
| 604 | mNavigationBarView.abortCurrentGesture(); |
| 605 | } |
| 606 | return true; |
| 607 | } |
| 608 | |
| 609 | // additional optimization when we have software system buttons - start loading the recent |
| 610 | // tasks on touch down |
| 611 | private boolean onRecentsTouch(View v, MotionEvent event) { |
| 612 | int action = event.getAction() & MotionEvent.ACTION_MASK; |
| 613 | if (action == MotionEvent.ACTION_DOWN) { |
| 614 | mCommandQueue.preloadRecentApps(); |
| 615 | } else if (action == MotionEvent.ACTION_CANCEL) { |
| 616 | mCommandQueue.cancelPreloadRecentApps(); |
| 617 | } else if (action == MotionEvent.ACTION_UP) { |
| 618 | if (!v.isPressed()) { |
| 619 | mCommandQueue.cancelPreloadRecentApps(); |
| 620 | } |
| 621 | } |
| 622 | return false; |
| 623 | } |
| 624 | |
| 625 | private void onRecentsClick(View v) { |
| 626 | if (LatencyTracker.isEnabled(getContext())) { |
| 627 | LatencyTracker.getInstance(getContext()).onActionStart( |
| 628 | LatencyTracker.ACTION_TOGGLE_RECENTS); |
| 629 | } |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 630 | mStatusBar.awakenDreams(); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 631 | mCommandQueue.toggleRecentApps(); |
| 632 | } |
| 633 | |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 634 | private boolean onLongPressBackHome(View v) { |
Matthew Ng | 2ea93b7 | 2018-03-14 19:43:18 +0000 | [diff] [blame] | 635 | mNavigationBarView.onNavigationButtonLongPress(v); |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 636 | return onLongPressNavigationButtons(v, R.id.back, R.id.home); |
| 637 | } |
| 638 | |
| 639 | private boolean onLongPressBackRecents(View v) { |
Matthew Ng | 2ea93b7 | 2018-03-14 19:43:18 +0000 | [diff] [blame] | 640 | mNavigationBarView.onNavigationButtonLongPress(v); |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 641 | return onLongPressNavigationButtons(v, R.id.back, R.id.recent_apps); |
| 642 | } |
| 643 | |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 644 | /** |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 645 | * This handles long-press of both back and recents/home. Back is the common button with |
| 646 | * combination of recents if it is visible or home if recents is invisible. |
| 647 | * They are handled together to capture them both being long-pressed |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 648 | * at the same time to exit screen pinning (lock task). |
| 649 | * |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 650 | * When accessibility mode is on, only a long-press from recents/home |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 651 | * is required to exit. |
| 652 | * |
| 653 | * In all other circumstances we try to pass through long-press events |
| 654 | * for Back, so that apps can still use it. Which can be from two things. |
| 655 | * 1) Not currently in screen pinning (lock task). |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 656 | * 2) Back is long-pressed without recents/home. |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 657 | */ |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 658 | private boolean onLongPressNavigationButtons(View v, @IdRes int btnId1, @IdRes int btnId2) { |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 659 | try { |
| 660 | boolean sendBackLongPress = false; |
Wale Ogunwale | 04d9cb5 | 2018-04-30 13:55:07 -0700 | [diff] [blame] | 661 | IActivityTaskManager activityManager = ActivityTaskManager.getService(); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 662 | boolean touchExplorationEnabled = mAccessibilityManager.isTouchExplorationEnabled(); |
| 663 | boolean inLockTaskMode = activityManager.isInLockTaskMode(); |
| 664 | if (inLockTaskMode && !touchExplorationEnabled) { |
| 665 | long time = System.currentTimeMillis(); |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 666 | |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 667 | // If we recently long-pressed the other button then they were |
| 668 | // long-pressed 'together' |
| 669 | if ((time - mLastLockToAppLongPress) < LOCK_TO_APP_GESTURE_TOLERENCE) { |
Benjamin Franz | a83859f | 2017-07-03 16:34:14 +0100 | [diff] [blame] | 670 | activityManager.stopSystemLockTaskMode(); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 671 | // When exiting refresh disabled flags. |
Matthew Ng | d0a73e7 | 2018-03-02 15:16:03 -0800 | [diff] [blame] | 672 | mNavigationBarView.updateNavButtonIcons(); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 673 | return true; |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 674 | } else if (v.getId() == btnId1) { |
| 675 | ButtonDispatcher button = btnId2 == R.id.recent_apps |
| 676 | ? mNavigationBarView.getRecentsButton() |
| 677 | : mNavigationBarView.getHomeButton(); |
| 678 | if (!button.getCurrentView().isPressed()) { |
| 679 | // If we aren't pressing recents/home right now then they presses |
| 680 | // won't be together, so send the standard long-press action. |
| 681 | sendBackLongPress = true; |
| 682 | } |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 683 | } |
| 684 | mLastLockToAppLongPress = time; |
| 685 | } else { |
| 686 | // If this is back still need to handle sending the long-press event. |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 687 | if (v.getId() == btnId1) { |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 688 | sendBackLongPress = true; |
| 689 | } else if (touchExplorationEnabled && inLockTaskMode) { |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 690 | // When in accessibility mode a long press that is recents/home (not back) |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 691 | // should stop lock task. |
Benjamin Franz | a83859f | 2017-07-03 16:34:14 +0100 | [diff] [blame] | 692 | activityManager.stopSystemLockTaskMode(); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 693 | // When exiting refresh disabled flags. |
Matthew Ng | d0a73e7 | 2018-03-02 15:16:03 -0800 | [diff] [blame] | 694 | mNavigationBarView.updateNavButtonIcons(); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 695 | return true; |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 696 | } else if (v.getId() == btnId2) { |
| 697 | return btnId2 == R.id.recent_apps |
| 698 | ? onLongPressRecents() |
| 699 | : onHomeLongClick(mNavigationBarView.getHomeButton().getCurrentView()); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 700 | } |
| 701 | } |
| 702 | if (sendBackLongPress) { |
| 703 | KeyButtonView keyButtonView = (KeyButtonView) v; |
| 704 | keyButtonView.sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_LONG_PRESS); |
| 705 | keyButtonView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED); |
| 706 | return true; |
| 707 | } |
| 708 | } catch (RemoteException e) { |
| 709 | Log.d(TAG, "Unable to reach activity manager", e); |
| 710 | } |
| 711 | return false; |
| 712 | } |
| 713 | |
| 714 | private boolean onLongPressRecents() { |
Wale Ogunwale | 65ebd95 | 2018-04-25 15:41:44 -0700 | [diff] [blame] | 715 | if (mRecents == null || !ActivityTaskManager.supportsMultiWindow(getContext()) |
Matthew Ng | 43db6d2 | 2017-06-27 15:29:39 -0700 | [diff] [blame] | 716 | || !mDivider.getView().getSnapAlgorithm().isSplitScreenFeasible() |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 717 | || ActivityManager.isLowRamDeviceStatic() |
Winson Chung | 074c434 | 2018-03-26 17:27:19 -0700 | [diff] [blame] | 718 | // If we are connected to the overview service, then disable the recents button |
| 719 | || mOverviewProxyService.getProxy() != null) { |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 720 | return false; |
| 721 | } |
| 722 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 723 | return mStatusBar.toggleSplitScreenMode(MetricsEvent.ACTION_WINDOW_DOCK_LONGPRESS, |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 724 | MetricsEvent.ACTION_WINDOW_UNDOCK_LONGPRESS); |
| 725 | } |
| 726 | |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 727 | private void onAccessibilityClick(View v) { |
| 728 | mAccessibilityManager.notifyAccessibilityButtonClicked(); |
| 729 | } |
| 730 | |
| 731 | private boolean onAccessibilityLongClick(View v) { |
Casey Burkhardt | 5e8b980 | 2017-03-24 10:07:20 -0700 | [diff] [blame] | 732 | Intent intent = new Intent(AccessibilityManager.ACTION_CHOOSE_ACCESSIBILITY_BUTTON); |
| 733 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); |
Casey Burkhardt | 5d61440 | 2017-04-06 13:46:50 -0700 | [diff] [blame] | 734 | v.getContext().startActivityAsUser(intent, UserHandle.CURRENT); |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 735 | return true; |
| 736 | } |
| 737 | |
Phil Weaver | db9a774 | 2017-04-18 08:15:06 -0700 | [diff] [blame] | 738 | private void updateAccessibilityServicesState(AccessibilityManager accessibilityManager) { |
Casey Burkhardt | 74922c6 | 2017-02-13 12:43:16 -0800 | [diff] [blame] | 739 | int requestingServices = 0; |
| 740 | try { |
Casey Burkhardt | 5d61440 | 2017-04-06 13:46:50 -0700 | [diff] [blame] | 741 | if (Settings.Secure.getIntForUser(mContentResolver, |
| 742 | Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, |
| 743 | UserHandle.USER_CURRENT) == 1) { |
Casey Burkhardt | 74922c6 | 2017-02-13 12:43:16 -0800 | [diff] [blame] | 744 | requestingServices++; |
| 745 | } |
| 746 | } catch (Settings.SettingNotFoundException e) { |
| 747 | } |
| 748 | |
Mike Digman | 9040295 | 2018-01-22 16:05:51 -0800 | [diff] [blame] | 749 | boolean feedbackEnabled = false; |
Casey Burkhardt | 5d61440 | 2017-04-06 13:46:50 -0700 | [diff] [blame] | 750 | // AccessibilityManagerService resolves services for the current user since the local |
| 751 | // AccessibilityManager is created from a Context with the INTERACT_ACROSS_USERS permission |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 752 | final List<AccessibilityServiceInfo> services = |
Phil Weaver | db9a774 | 2017-04-18 08:15:06 -0700 | [diff] [blame] | 753 | accessibilityManager.getEnabledAccessibilityServiceList( |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 754 | AccessibilityServiceInfo.FEEDBACK_ALL_MASK); |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 755 | for (int i = services.size() - 1; i >= 0; --i) { |
| 756 | AccessibilityServiceInfo info = services.get(i); |
| 757 | if ((info.flags & AccessibilityServiceInfo.FLAG_REQUEST_ACCESSIBILITY_BUTTON) != 0) { |
| 758 | requestingServices++; |
| 759 | } |
Mike Digman | 9040295 | 2018-01-22 16:05:51 -0800 | [diff] [blame] | 760 | |
| 761 | if (info.feedbackType != 0 && info.feedbackType != |
| 762 | AccessibilityServiceInfo.FEEDBACK_GENERIC) { |
| 763 | feedbackEnabled = true; |
| 764 | } |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 765 | } |
| 766 | |
Matthew Ng | 761562d | 2018-09-17 11:13:21 -0700 | [diff] [blame] | 767 | mNavigationBarView.getRotateSuggestionButton() |
| 768 | .setAccessibilityFeedbackEnabled(feedbackEnabled); |
Mike Digman | 9040295 | 2018-01-22 16:05:51 -0800 | [diff] [blame] | 769 | |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 770 | final boolean showAccessibilityButton = requestingServices >= 1; |
| 771 | final boolean targetSelection = requestingServices >= 2; |
| 772 | mNavigationBarView.setAccessibilityButtonState(showAccessibilityButton, targetSelection); |
| 773 | } |
| 774 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 775 | // ----- Methods that StatusBar talks to (should be minimized) ----- |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 776 | |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 777 | public void setLightBarController(LightBarController lightBarController) { |
| 778 | mLightBarController = lightBarController; |
| 779 | mLightBarController.setNavigationBar(mNavigationBarView.getLightTransitionsController()); |
| 780 | } |
| 781 | |
| 782 | public boolean isSemiTransparent() { |
| 783 | return mNavigationBarMode == MODE_SEMI_TRANSPARENT; |
| 784 | } |
| 785 | |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 786 | public void disableAnimationsDuringHide(long delay) { |
| 787 | mNavigationBarView.setLayoutTransitionsEnabled(false); |
| 788 | mNavigationBarView.postDelayed(() -> mNavigationBarView.setLayoutTransitionsEnabled(true), |
| 789 | delay + StackStateAnimator.ANIMATION_DURATION_GO_TO_FULL_SHADE); |
| 790 | } |
| 791 | |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 792 | public BarTransitions getBarTransitions() { |
| 793 | return mNavigationBarView.getBarTransitions(); |
| 794 | } |
| 795 | |
| 796 | public void checkNavBarModes() { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 797 | mStatusBar.checkBarMode(mNavigationBarMode, |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 798 | mNavigationBarWindowState, mNavigationBarView.getBarTransitions()); |
| 799 | } |
| 800 | |
| 801 | public void finishBarAnimations() { |
| 802 | mNavigationBarView.getBarTransitions().finishAnimations(); |
| 803 | } |
| 804 | |
Jason Monk | 91e587e | 2017-04-13 13:41:23 -0400 | [diff] [blame] | 805 | private final AccessibilityServicesStateChangeListener mAccessibilityListener = |
| 806 | this::updateAccessibilityServicesState; |
| 807 | |
Casey Burkhardt | 74922c6 | 2017-02-13 12:43:16 -0800 | [diff] [blame] | 808 | private class MagnificationContentObserver extends ContentObserver { |
| 809 | |
| 810 | public MagnificationContentObserver(Handler handler) { |
| 811 | super(handler); |
| 812 | } |
| 813 | |
| 814 | @Override |
| 815 | public void onChange(boolean selfChange) { |
Phil Weaver | db9a774 | 2017-04-18 08:15:06 -0700 | [diff] [blame] | 816 | NavigationBarFragment.this.updateAccessibilityServicesState(mAccessibilityManager); |
Casey Burkhardt | 74922c6 | 2017-02-13 12:43:16 -0800 | [diff] [blame] | 817 | } |
| 818 | } |
| 819 | |
Matthew Ng | 761562d | 2018-09-17 11:13:21 -0700 | [diff] [blame] | 820 | private final Consumer<Integer> mRotationWatcher = rotation -> { |
| 821 | if (mNavigationBarView != null |
| 822 | && mNavigationBarView.needsReorient(rotation)) { |
| 823 | repositionNavigationBar(); |
Mike Digman | 85ff7fa | 2018-01-23 14:59:52 -0800 | [diff] [blame] | 824 | } |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 825 | }; |
| 826 | |
| 827 | private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
| 828 | @Override |
| 829 | public void onReceive(Context context, Intent intent) { |
| 830 | String action = intent.getAction(); |
Siarhei Vishniakou | d002a0a | 2017-06-05 22:44:37 +0100 | [diff] [blame] | 831 | if (Intent.ACTION_SCREEN_OFF.equals(action) |
| 832 | || Intent.ACTION_SCREEN_ON.equals(action)) { |
| 833 | notifyNavigationBarScreenOn(); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 834 | } |
Phil Weaver | a858c5f | 2018-04-26 13:27:30 -0700 | [diff] [blame] | 835 | if (Intent.ACTION_USER_SWITCHED.equals(action)) { |
| 836 | // The accessibility settings may be different for the new user |
| 837 | updateAccessibilityServicesState(mAccessibilityManager); |
| 838 | }; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 839 | } |
| 840 | }; |
| 841 | |
| 842 | public static View create(Context context, FragmentListener listener) { |
| 843 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 844 | LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, |
| 845 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR, |
| 846 | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING |
| 847 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 848 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
| 849 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
| 850 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH |
| 851 | | WindowManager.LayoutParams.FLAG_SLIPPERY, |
| 852 | PixelFormat.TRANSLUCENT); |
| 853 | lp.token = new Binder(); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 854 | lp.setTitle("NavigationBar"); |
Phil Weaver | 8583ae8 | 2018-02-13 11:01:24 -0800 | [diff] [blame] | 855 | lp.accessibilityTitle = context.getString(R.string.nav_bar); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 856 | lp.windowAnimations = 0; |
| 857 | |
| 858 | View navigationBarView = LayoutInflater.from(context).inflate( |
| 859 | R.layout.navigation_bar_window, null); |
| 860 | |
| 861 | if (DEBUG) Log.v(TAG, "addNavigationBar: about to add " + navigationBarView); |
| 862 | if (navigationBarView == null) return null; |
| 863 | |
| 864 | context.getSystemService(WindowManager.class).addView(navigationBarView, lp); |
| 865 | FragmentHostManager fragmentHost = FragmentHostManager.get(navigationBarView); |
| 866 | NavigationBarFragment fragment = new NavigationBarFragment(); |
| 867 | fragmentHost.getFragmentManager().beginTransaction() |
| 868 | .replace(R.id.navigation_bar_frame, fragment, TAG) |
| 869 | .commit(); |
| 870 | fragmentHost.addTagListener(TAG, listener); |
| 871 | return navigationBarView; |
| 872 | } |
| 873 | } |