diff options
| author | 2018-01-17 10:02:21 -0800 | |
|---|---|---|
| committer | 2018-01-17 10:02:21 -0800 | |
| commit | e8a7568bbdbe58d1528fafdf93c79c78487fd7de (patch) | |
| tree | 7b7bd47741bab2a5d020c933227f3d7f1133084d | |
| parent | 1507c3ef69f19761548d98edd30520c9d5589092 (diff) | |
Fix NPE when registering gesture support
Car implementation does no support gestures thus this installs a null
object pattern version of the gesture plug in.
This is a temp solution while the class hierarchy is being refactored.
Bug: 72094006
Test: deploy and check
Change-Id: I7cbca3d77546d62e3e78d8c73faa8ef5cd8803f0
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarView.java | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarView.java index 6cbbd6cd1f18..e5a311d099d5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarView.java @@ -17,11 +17,15 @@ package com.android.systemui.statusbar.car; import android.content.Context; +import android.graphics.Canvas; import android.util.AttributeSet; +import android.view.MotionEvent; import android.view.View; import android.widget.LinearLayout; import com.android.systemui.R; +import com.android.systemui.plugins.statusbar.phone.NavGesture; +import com.android.systemui.statusbar.phone.NavigationBarGestureHelper; import com.android.systemui.statusbar.phone.NavigationBarView; /** @@ -72,4 +76,68 @@ class CarNavigationBarView extends NavigationBarView { // Calling setNavigationIconHints in the base class will result in a NPE as the car // navigation bar does not have a back button. } + + @Override + public void onPluginConnected(NavGesture plugin, Context context) { + // set to null version of the plugin ignoring incoming arg. + super.onPluginConnected(new NullNavGesture(), context); + } + + @Override + public void onPluginDisconnected(NavGesture plugin) { + // reinstall the null nav gesture plugin + super.onPluginConnected(new NullNavGesture(), getContext()); + } + + /** + * Null object pattern to work around expectations of the base class. + * This is a temporary solution to have the car system ui working. + * Already underway is a refactor of they car sys ui as to not use this class + * hierarchy. + */ + private static class NullNavGesture implements NavGesture { + @Override + public GestureHelper getGestureHelper() { + return new GestureHelper() { + @Override + public boolean onTouchEvent(MotionEvent event) { + return false; + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent event) { + return false; + } + + @Override + public void setBarState(boolean vertical, boolean isRtl) { + } + + @Override + public void onDraw(Canvas canvas) { + } + + @Override + public void onDarkIntensityChange(float intensity) { + } + + @Override + public void onLayout(boolean changed, int left, int top, int right, int bottom) { + } + }; + } + + @Override + public int getVersion() { + return 0; + } + + @Override + public void onCreate(Context sysuiContext, Context pluginContext) { + } + + @Override + public void onDestroy() { + } + } } |