diff options
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/WindowManager/Shell/res/values/strings.xml | 4 | ||||
| -rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedTutorialHandler.java | 31 | ||||
| -rw-r--r-- | libs/hwui/SkiaCanvas.cpp | 3 | ||||
| -rw-r--r-- | libs/hwui/SkiaCanvas.h | 3 | ||||
| -rw-r--r-- | libs/hwui/hwui/Canvas.cpp | 18 | ||||
| -rw-r--r-- | libs/hwui/hwui/Canvas.h | 3 | ||||
| -rw-r--r-- | libs/hwui/renderthread/CanvasContext.cpp | 9 |
7 files changed, 47 insertions, 24 deletions
diff --git a/libs/WindowManager/Shell/res/values/strings.xml b/libs/WindowManager/Shell/res/values/strings.xml index b6668fbe4872..da5965dab71a 100644 --- a/libs/WindowManager/Shell/res/values/strings.xml +++ b/libs/WindowManager/Shell/res/values/strings.xml @@ -93,4 +93,8 @@ <string name="one_handed_tutorial_title">Using one-handed mode</string> <!-- One-Handed Tutorial description [CHAR LIMIT=NONE] --> <string name="one_handed_tutorial_description">To exit, swipe up from the bottom of the screen or tap anywhere above the app</string> + <!-- Accessibility description for start one-handed mode [CHAR LIMIT=NONE] --> + <string name="accessibility_action_start_one_handed">Start one-handed mode</string> + <!-- Accessibility description for stop one-handed mode [CHAR LIMIT=NONE] --> + <string name="accessibility_action_stop_one_handed">Exit one-handed mode</string> </resources> diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedTutorialHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedTutorialHandler.java index b15b5154c2a4..7c0c738644b7 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedTutorialHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedTutorialHandler.java @@ -29,6 +29,8 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; +import android.view.accessibility.AccessibilityEvent; +import android.view.accessibility.AccessibilityManager; import android.widget.FrameLayout; import androidx.annotation.NonNull; @@ -50,12 +52,16 @@ public class OneHandedTutorialHandler implements OneHandedTransitionCallback { private static final int MAX_TUTORIAL_SHOW_COUNT = 2; private final Rect mLastUpdatedBounds = new Rect(); private final WindowManager mWindowManager; + private final AccessibilityManager mAccessibilityManager; + private final String mPackageName; private View mTutorialView; private Point mDisplaySize = new Point(); private Handler mUpdateHandler; private ContentResolver mContentResolver; private boolean mCanShowTutorial; + private String mStartOneHandedDescription; + private String mStopOneHandedDescription; /** * Container of the tutorial panel showing at outside region when one handed starting @@ -72,9 +78,12 @@ public class OneHandedTutorialHandler implements OneHandedTransitionCallback { public OneHandedTutorialHandler(Context context) { context.getDisplay().getRealSize(mDisplaySize); + mPackageName = context.getPackageName(); mContentResolver = context.getContentResolver(); mUpdateHandler = new Handler(); mWindowManager = context.getSystemService(WindowManager.class); + mAccessibilityManager = (AccessibilityManager) + context.getSystemService(Context.ACCESSIBILITY_SERVICE); mTargetViewContainer = new FrameLayout(context); mTargetViewContainer.setClipChildren(false); mTutorialAreaHeight = Math.round(mDisplaySize.y @@ -84,6 +93,10 @@ public class OneHandedTutorialHandler implements OneHandedTransitionCallback { mCanShowTutorial = (Settings.Secure.getInt(mContentResolver, Settings.Secure.ONE_HANDED_TUTORIAL_SHOW_COUNT, 0) >= MAX_TUTORIAL_SHOW_COUNT) ? false : true; + mStartOneHandedDescription = context.getResources().getString( + R.string.accessibility_action_start_one_handed); + mStopOneHandedDescription = context.getResources().getString( + R.string.accessibility_action_stop_one_handed); if (mCanShowTutorial) { createOrUpdateTutorialTarget(); } @@ -94,13 +107,16 @@ public class OneHandedTutorialHandler implements OneHandedTransitionCallback { mUpdateHandler.post(() -> { updateFinished(View.VISIBLE, 0f); updateTutorialCount(); + announcementForScreenReader(true); }); } @Override public void onStopFinished(Rect bounds) { - mUpdateHandler.post(() -> updateFinished( - View.INVISIBLE, -mTargetViewContainer.getHeight())); + mUpdateHandler.post(() -> { + updateFinished(View.INVISIBLE, -mTargetViewContainer.getHeight()); + announcementForScreenReader(false); + }); } private void updateFinished(int visible, float finalPosition) { @@ -121,6 +137,17 @@ public class OneHandedTutorialHandler implements OneHandedTransitionCallback { Settings.Secure.ONE_HANDED_TUTORIAL_SHOW_COUNT, showCount); } + private void announcementForScreenReader(boolean isStartOneHanded) { + if (mAccessibilityManager.isTouchExplorationEnabled()) { + final AccessibilityEvent event = AccessibilityEvent.obtain(); + event.setPackageName(mPackageName); + event.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT); + event.getText().add(isStartOneHanded + ? mStartOneHandedDescription : mStopOneHandedDescription); + mAccessibilityManager.sendAccessibilityEvent(event); + } + } + /** * Adds the tutorial target view to the WindowManager and update its layout, so it's ready * to be animated in. diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp index cfba5d4f6aa2..a690840e91a9 100644 --- a/libs/hwui/SkiaCanvas.cpp +++ b/libs/hwui/SkiaCanvas.cpp @@ -735,8 +735,7 @@ void SkiaCanvas::drawVectorDrawable(VectorDrawableRoot* vectorDrawable) { // ---------------------------------------------------------------------------- void SkiaCanvas::drawGlyphs(ReadGlyphFunc glyphFunc, int count, const Paint& paint, float x, - float y, float boundsLeft, float boundsTop, float boundsRight, - float boundsBottom, float totalAdvance) { + float y, float totalAdvance) { if (count <= 0 || paint.nothingToDraw()) return; Paint paintCopy(paint); if (mPaintFilter) { diff --git a/libs/hwui/SkiaCanvas.h b/libs/hwui/SkiaCanvas.h index 1df2b2671659..2cb850c83934 100644 --- a/libs/hwui/SkiaCanvas.h +++ b/libs/hwui/SkiaCanvas.h @@ -161,8 +161,7 @@ protected: void drawDrawable(SkDrawable* drawable) { mCanvas->drawDrawable(drawable); } virtual void drawGlyphs(ReadGlyphFunc glyphFunc, int count, const Paint& paint, float x, - float y, float boundsLeft, float boundsTop, float boundsRight, - float boundsBottom, float totalAdvance) override; + float y, float totalAdvance) override; virtual void drawLayoutOnPath(const minikin::Layout& layout, float hOffset, float vOffset, const Paint& paint, const SkPath& path, size_t start, size_t end) override; diff --git a/libs/hwui/hwui/Canvas.cpp b/libs/hwui/hwui/Canvas.cpp index 2a377bbb83f2..2001b5620f84 100644 --- a/libs/hwui/hwui/Canvas.cpp +++ b/libs/hwui/hwui/Canvas.cpp @@ -84,13 +84,12 @@ static void simplifyPaint(int color, Paint* paint) { class DrawTextFunctor { public: DrawTextFunctor(const minikin::Layout& layout, Canvas* canvas, const Paint& paint, float x, - float y, minikin::MinikinRect& bounds, float totalAdvance) + float y, float totalAdvance) : layout(layout) , canvas(canvas) , paint(paint) , x(x) , y(y) - , bounds(bounds) , totalAdvance(totalAdvance) {} void operator()(size_t start, size_t end) { @@ -114,19 +113,16 @@ public: Paint outlinePaint(paint); simplifyPaint(darken ? SK_ColorWHITE : SK_ColorBLACK, &outlinePaint); outlinePaint.setStyle(SkPaint::kStrokeAndFill_Style); - canvas->drawGlyphs(glyphFunc, glyphCount, outlinePaint, x, y, bounds.mLeft, bounds.mTop, - bounds.mRight, bounds.mBottom, totalAdvance); + canvas->drawGlyphs(glyphFunc, glyphCount, outlinePaint, x, y, totalAdvance); // inner Paint innerPaint(paint); simplifyPaint(darken ? SK_ColorBLACK : SK_ColorWHITE, &innerPaint); innerPaint.setStyle(SkPaint::kFill_Style); - canvas->drawGlyphs(glyphFunc, glyphCount, innerPaint, x, y, bounds.mLeft, bounds.mTop, - bounds.mRight, bounds.mBottom, totalAdvance); + canvas->drawGlyphs(glyphFunc, glyphCount, innerPaint, x, y, totalAdvance); } else { // standard draw path - canvas->drawGlyphs(glyphFunc, glyphCount, paint, x, y, bounds.mLeft, bounds.mTop, - bounds.mRight, bounds.mBottom, totalAdvance); + canvas->drawGlyphs(glyphFunc, glyphCount, paint, x, y, totalAdvance); } } @@ -136,7 +132,6 @@ private: const Paint& paint; float x; float y; - minikin::MinikinRect& bounds; float totalAdvance; }; @@ -156,15 +151,12 @@ void Canvas::drawText(const uint16_t* text, int textSize, int start, int count, x += MinikinUtils::xOffsetForTextAlign(&paint, layout); - minikin::MinikinRect bounds; - layout.getBounds(&bounds); - // Set align to left for drawing, as we don't want individual // glyphs centered or right-aligned; the offset above takes // care of all alignment. paint.setTextAlign(Paint::kLeft_Align); - DrawTextFunctor f(layout, this, paint, x, y, bounds, layout.getAdvance()); + DrawTextFunctor f(layout, this, paint, x, y, layout.getAdvance()); MinikinUtils::forFontRun(layout, &paint, f); } diff --git a/libs/hwui/hwui/Canvas.h b/libs/hwui/hwui/Canvas.h index 333567b0cf91..817c7ee9077f 100644 --- a/libs/hwui/hwui/Canvas.h +++ b/libs/hwui/hwui/Canvas.h @@ -288,8 +288,7 @@ protected: * totalAdvance: used to define width of text decorations (underlines, strikethroughs). */ virtual void drawGlyphs(ReadGlyphFunc glyphFunc, int count, const Paint& paint, float x, - float y, float boundsLeft, float boundsTop, float boundsRight, - float boundsBottom, float totalAdvance) = 0; + float y,float totalAdvance) = 0; virtual void drawLayoutOnPath(const minikin::Layout& layout, float hOffset, float vOffset, const Paint& paint, const SkPath& path, size_t start, size_t end) = 0; diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index c7560b2496ef..04359818e1b7 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -139,7 +139,7 @@ void CanvasContext::destroy() { mAnimationContext->destroy(); } -static void setBufferCount(ANativeWindow* window, uint32_t extraBuffers) { +static void setBufferCount(ANativeWindow* window) { int query_value; int err = window->query(window, NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, &query_value); if (err != 0 || query_value < 0) { @@ -148,7 +148,9 @@ static void setBufferCount(ANativeWindow* window, uint32_t extraBuffers) { } auto min_undequeued_buffers = static_cast<uint32_t>(query_value); - int bufferCount = min_undequeued_buffers + 2 + extraBuffers; + // We only need to set min_undequeued + 2 because the renderahead amount was already factored into the + // query for min_undequeued + int bufferCount = min_undequeued_buffers + 2; native_window_set_buffer_count(window, bufferCount); } @@ -182,7 +184,8 @@ void CanvasContext::setupPipelineSurface() { mNativeSurface ? mNativeSurface->getNativeWindow() : nullptr, mSwapBehavior); if (mNativeSurface && !mNativeSurface->didSetExtraBuffers()) { - setBufferCount(mNativeSurface->getNativeWindow(), mRenderAheadCapacity); + setBufferCount(mNativeSurface->getNativeWindow()); + } mFrameNumber = -1; |