Do not show assist affordance when no assistant is available
This also tells launcher that there is no assistant so it will not consume input events. Bug: 112934365 Test: manual Change-Id: I5690cf2fffe45c955a9f165a0fdeac1db8641601
This commit is contained in:
25
packages/SystemUI/res/layout/assistant_handle.xml
Normal file
25
packages/SystemUI/res/layout/assistant_handle.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2019 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
|
||||
-->
|
||||
|
||||
<com.android.systemui.statusbar.phone.NavigationHandle
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/assistant_handle"
|
||||
android:layout_width="@dimen/navigation_assistant_handle_width"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
/>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<com.android.systemui.statusbar.phone.NavigationHandle
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/home_handle"
|
||||
android:layout_width="@dimen/navigation_handle_width"
|
||||
android:layout_width="@dimen/navigation_home_handle_width"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
/>
|
||||
|
||||
@@ -325,7 +325,7 @@
|
||||
<!-- Nav bar button default ordering/layout -->
|
||||
<string name="config_navBarLayout" translatable="false">left[.5W],back[1WC];home;recent[1WC],right[.5W]</string>
|
||||
<string name="config_navBarLayoutQuickstep" translatable="false">back[1.7WC];home;contextual[1.7WC]</string>
|
||||
<string name="config_navBarLayoutHandle" translatable="false">";home_handle;"</string>
|
||||
<string name="config_navBarLayoutHandle" translatable="false">";home_handle;assistant_handle[.18WC]"</string>
|
||||
|
||||
<bool name="quick_settings_show_full_alarm">false</bool>
|
||||
|
||||
|
||||
@@ -34,9 +34,11 @@
|
||||
<dimen name="navigation_bar_deadzone_size_max">32dp</dimen>
|
||||
|
||||
<!-- dimensions for the navigation bar handle -->
|
||||
<dimen name="navigation_handle_width">180dp</dimen>
|
||||
<dimen name="navigation_handle_radius">2dp</dimen>
|
||||
<dimen name="navigation_handle_bottom">8dp</dimen>
|
||||
<dimen name="navigation_handle_horizontal_margin">30dp</dimen>
|
||||
<dimen name="navigation_home_handle_width">180dp</dimen>
|
||||
<dimen name="navigation_assistant_handle_width">36dp</dimen>
|
||||
|
||||
<!-- Height of notification icons in the status bar -->
|
||||
<dimen name="status_bar_icon_size">@*android:dimen/status_bar_icon_size</dimen>
|
||||
|
||||
@@ -113,4 +113,10 @@ oneway interface IOverviewProxy {
|
||||
* Sent when there was an action on one of the onboarding tips view.
|
||||
*/
|
||||
void onTip(int actionType, int viewType) = 10;
|
||||
|
||||
/**
|
||||
* Sent when device assistant changes its default assistant whether it is available or not.
|
||||
*/
|
||||
void onAssistantAvailable(boolean available) = 13;
|
||||
|
||||
}
|
||||
|
||||
@@ -314,9 +314,14 @@ public class AssistManager implements ConfigurationChangedReceiver {
|
||||
v.setImageDrawable(null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ComponentName getAssistInfoForUser(int userId) {
|
||||
return mAssistUtils.getAssistComponentForUser(userId);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ComponentName getAssistInfo() {
|
||||
return mAssistUtils.getAssistComponentForUser(KeyguardUpdateMonitor.getCurrentUser());
|
||||
return getAssistInfoForUser(KeyguardUpdateMonitor.getCurrentUser());
|
||||
}
|
||||
|
||||
public void showDisclosure() {
|
||||
|
||||
@@ -51,10 +51,12 @@ import android.database.ContentObserver;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Rect;
|
||||
import android.inputmethodservice.InputMethodService;
|
||||
import android.net.Uri;
|
||||
import android.os.Binder;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
@@ -137,6 +139,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
||||
private AccessibilityManager mAccessibilityManager;
|
||||
private MagnificationContentObserver mMagnificationObserver;
|
||||
private ContentResolver mContentResolver;
|
||||
private boolean mAssistantAvailable;
|
||||
|
||||
private int mDisabledFlags1;
|
||||
private int mDisabledFlags2;
|
||||
@@ -167,6 +170,11 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
||||
public void onConnectionChanged(boolean isConnected) {
|
||||
mNavigationBarView.updateStates();
|
||||
updateScreenPinningGestures();
|
||||
|
||||
// Send the assistant availability upon connection
|
||||
if (isConnected) {
|
||||
mNavigationBarView.setAssistantAvailable(mAssistantAvailable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -213,6 +221,19 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
||||
|
||||
private final Runnable mAutoDim = () -> getBarTransitions().setAutoDim(true);
|
||||
|
||||
private final ContentObserver mAssistContentObserver = new ContentObserver(
|
||||
new Handler(Looper.getMainLooper())) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
boolean available = mAssistManager
|
||||
.getAssistInfoForUser(UserHandle.USER_CURRENT) != null;
|
||||
if (mAssistantAvailable != available) {
|
||||
mNavigationBarView.setAssistantAvailable(available);
|
||||
mAssistantAvailable = available;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Inject
|
||||
public NavigationBarFragment(AccessibilityManagerWrapper accessibilityManagerWrapper,
|
||||
DeviceProvisionedController deviceProvisionedController, MetricsLogger metricsLogger,
|
||||
@@ -221,6 +242,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
||||
mDeviceProvisionedController = deviceProvisionedController;
|
||||
mMetricsLogger = metricsLogger;
|
||||
mAssistManager = assistManager;
|
||||
mAssistantAvailable = mAssistManager.getAssistInfoForUser(UserHandle.USER_CURRENT) != null;
|
||||
mOverviewProxyService = overviewProxyService;
|
||||
}
|
||||
|
||||
@@ -242,6 +264,9 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
||||
mContentResolver.registerContentObserver(Settings.Secure.getUriFor(
|
||||
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED), false,
|
||||
mMagnificationObserver, UserHandle.USER_ALL);
|
||||
mContentResolver.registerContentObserver(
|
||||
Settings.Secure.getUriFor(Settings.Secure.ASSISTANT),
|
||||
false /* notifyForDescendants */, mAssistContentObserver, UserHandle.USER_ALL);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mDisabledFlags1 = savedInstanceState.getInt(EXTRA_DISABLE_STATE, 0);
|
||||
@@ -258,6 +283,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
||||
super.onDestroy();
|
||||
mAccessibilityManagerWrapper.removeCallback(mAccessibilityListener);
|
||||
mContentResolver.unregisterContentObserver(mMagnificationObserver);
|
||||
mContentResolver.unregisterContentObserver(mAssistContentObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -63,6 +63,7 @@ public class NavigationBarInflaterView extends FrameLayout
|
||||
public static final String NAVSPACE = "space";
|
||||
public static final String CLIPBOARD = "clipboard";
|
||||
public static final String HOME_HANDLE = "home_handle";
|
||||
public static final String ASSISTANT_HANDLE = "assistant_handle";
|
||||
public static final String KEY = "key";
|
||||
public static final String LEFT = "left";
|
||||
public static final String RIGHT = "right";
|
||||
@@ -398,6 +399,8 @@ public class NavigationBarInflaterView extends FrameLayout
|
||||
v = inflater.inflate(R.layout.contextual, parent, false);
|
||||
} else if (HOME_HANDLE.equals(button)) {
|
||||
v = inflater.inflate(R.layout.home_handle, parent, false);
|
||||
} else if (ASSISTANT_HANDLE.equals(button)) {
|
||||
v = inflater.inflate(R.layout.assistant_handle, parent, false);
|
||||
} else if (button.startsWith(KEY)) {
|
||||
String uri = extractImage(button);
|
||||
int code = extractKeycode(button);
|
||||
|
||||
@@ -171,6 +171,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
private NotificationPanelView mPanelView;
|
||||
|
||||
private NavBarTintController mColorAdaptionController;
|
||||
private boolean mAssistantAvailable;
|
||||
private NavigationPrototypeController mPrototypeController;
|
||||
private NavigationGestureAction[] mDefaultGestureMap;
|
||||
private QuickScrubAction mQuickScrubAction;
|
||||
@@ -347,6 +348,11 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
public void onHomeHandleVisiblilityChanged(boolean visible) {
|
||||
showHomeHandle(visible);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAssistantGestureEnabled(boolean enabled) {
|
||||
updateAssistantAvailability();
|
||||
}
|
||||
};
|
||||
|
||||
public NavigationBarView(Context context, AttributeSet attrs) {
|
||||
@@ -385,6 +391,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
mButtonDispatchers.put(R.id.back, new ButtonDispatcher(R.id.back));
|
||||
mButtonDispatchers.put(R.id.home, new ButtonDispatcher(R.id.home));
|
||||
mButtonDispatchers.put(R.id.home_handle, new ButtonDispatcher(R.id.home_handle));
|
||||
mButtonDispatchers.put(R.id.assistant_handle, new ButtonDispatcher(R.id.assistant_handle));
|
||||
mButtonDispatchers.put(R.id.recent_apps, new ButtonDispatcher(R.id.recent_apps));
|
||||
mButtonDispatchers.put(R.id.menu, menuButton);
|
||||
mButtonDispatchers.put(R.id.ime_switcher, imeSwitcherButton);
|
||||
@@ -582,6 +589,10 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
return mButtonDispatchers.get(R.id.home_handle);
|
||||
}
|
||||
|
||||
public ButtonDispatcher getAssistantHandle() {
|
||||
return mButtonDispatchers.get(R.id.assistant_handle);
|
||||
}
|
||||
|
||||
public SparseArray<ButtonDispatcher> getButtonDispatchers() {
|
||||
return mButtonDispatchers;
|
||||
}
|
||||
@@ -940,6 +951,24 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
}
|
||||
}
|
||||
|
||||
public void setAssistantAvailable(boolean available) {
|
||||
mAssistantAvailable = available;
|
||||
updateAssistantAvailability();
|
||||
}
|
||||
|
||||
// TODO(b/112934365): move this back to NavigationBarFragment when prototype is removed
|
||||
private void updateAssistantAvailability() {
|
||||
boolean available = mAssistantAvailable && mPrototypeController.isAssistantGestureEnabled();
|
||||
getAssistantHandle().setVisibility(available ? View.VISIBLE : View.GONE);
|
||||
if (mOverviewProxyService.getProxy() != null) {
|
||||
try {
|
||||
mOverviewProxyService.getProxy().onAssistantAvailable(available);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Unable to send assistant availability data to launcher");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setMenuVisibility(final boolean show) {
|
||||
mContextualButtonGroup.setButtonVisiblity(R.id.menu, show);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ public class NavigationPrototypeController extends ContentObserver {
|
||||
private final String GESTURE_MATCH_SETTING = "quickstepcontroller_gesture_match_map";
|
||||
public static final String NAV_COLOR_ADAPT_ENABLE_SETTING = "navbar_color_adapt_enable";
|
||||
public static final String SHOW_HOME_HANDLE_SETTING = "quickstepcontroller_showhandle";
|
||||
public static final String ENABLE_ASSISTANT_GESTURE = "ENABLE_ASSISTANT_GESTURE";
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({ACTION_DEFAULT, ACTION_QUICKSTEP, ACTION_QUICKSCRUB, ACTION_BACK,
|
||||
@@ -87,6 +88,7 @@ public class NavigationPrototypeController extends ContentObserver {
|
||||
registerObserver(NAV_COLOR_ADAPT_ENABLE_SETTING);
|
||||
registerObserver(EDGE_SENSITIVITY_WIDTH_SETTING);
|
||||
registerObserver(SHOW_HOME_HANDLE_SETTING);
|
||||
registerObserver(ENABLE_ASSISTANT_GESTURE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,6 +121,8 @@ public class NavigationPrototypeController extends ContentObserver {
|
||||
getEdgeSensitivityHeight());
|
||||
} else if (path.endsWith(SHOW_HOME_HANDLE_SETTING)) {
|
||||
mListener.onHomeHandleVisiblilityChanged(showHomeHandle());
|
||||
} else if (path.endsWith(ENABLE_ASSISTANT_GESTURE)) {
|
||||
mListener.onAssistantGestureEnabled(isAssistantGestureEnabled());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -162,6 +166,11 @@ public class NavigationPrototypeController extends ContentObserver {
|
||||
return getGlobalBool(SHOW_HOME_HANDLE_SETTING, false /* default */);
|
||||
}
|
||||
|
||||
boolean isAssistantGestureEnabled() {
|
||||
return getGlobalBool(ENABLE_ASSISTANT_GESTURE, false /* default */);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Since Settings.Global cannot pass arrays, use a string to represent each character as a
|
||||
* gesture map to actions corresponding to {@see GestureAction}. The number is represented as:
|
||||
@@ -201,5 +210,6 @@ public class NavigationPrototypeController extends ContentObserver {
|
||||
void onHomeHandleVisiblilityChanged(boolean visible);
|
||||
void onColorAdaptChanged(boolean enabled);
|
||||
void onEdgeSensitivityChanged(int width, int height);
|
||||
void onAssistantGestureEnabled(boolean enabled);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user