Loading core/res/res/values/config.xml +3 −0 Original line number Original line Diff line number Diff line Loading @@ -1490,6 +1490,9 @@ <!-- default device has recents property --> <!-- default device has recents property --> <bool name="config_hasRecents">true</bool> <bool name="config_hasRecents">true</bool> <!-- default window ShowCircularMask property --> <bool name="config_windowShowCircularMask">false</bool> <!-- Defines the default set of global actions. Actions may still be disabled or hidden based <!-- Defines the default set of global actions. Actions may still be disabled or hidden based on the current state of the device. on the current state of the device. Each item must be one of the following strings: Each item must be one of the following strings: Loading core/res/res/values/dimens.xml +5 −0 Original line number Original line Diff line number Diff line Loading @@ -360,4 +360,9 @@ <!-- width of ImmersiveModeConfirmation (-1 for match_parent) --> <!-- width of ImmersiveModeConfirmation (-1 for match_parent) --> <dimen name="immersive_mode_cling_width">-1px</dimen> <dimen name="immersive_mode_cling_width">-1px</dimen> <!-- Size of the offset applied to the position of the circular mask. This is only used on circular displays. In the case where there is no "chin", this will default to 0 --> <dimen name="circular_display_mask_offset">0px</dimen> </resources> </resources> core/res/res/values/symbols.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -292,6 +292,7 @@ <java-symbol type="bool" name="config_wifi_batched_scan_supported" /> <java-symbol type="bool" name="config_wifi_batched_scan_supported" /> <java-symbol type="bool" name="config_windowIsRound" /> <java-symbol type="bool" name="config_windowIsRound" /> <java-symbol type="bool" name="config_hasRecents" /> <java-symbol type="bool" name="config_hasRecents" /> <java-symbol type="bool" name="config_windowShowCircularMask" /> <java-symbol type="integer" name="config_cursorWindowSize" /> <java-symbol type="integer" name="config_cursorWindowSize" /> <java-symbol type="integer" name="config_extraFreeKbytesAdjust" /> <java-symbol type="integer" name="config_extraFreeKbytesAdjust" /> Loading Loading @@ -356,6 +357,7 @@ <java-symbol type="dimen" name="notification_title_text_size" /> <java-symbol type="dimen" name="notification_title_text_size" /> <java-symbol type="dimen" name="notification_subtext_size" /> <java-symbol type="dimen" name="notification_subtext_size" /> <java-symbol type="dimen" name="immersive_mode_cling_width" /> <java-symbol type="dimen" name="immersive_mode_cling_width" /> <java-symbol type="dimen" name="circular_display_mask_offset" /> <java-symbol type="string" name="add_account_button_label" /> <java-symbol type="string" name="add_account_button_label" /> <java-symbol type="string" name="addToDictionary" /> <java-symbol type="string" name="addToDictionary" /> Loading services/core/java/com/android/server/wm/CircularDisplayMask.java 0 → 100644 +149 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2014 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. */ package com.android.server.wm; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PixelFormat; import android.graphics.Point; import android.graphics.PorterDuff; import android.graphics.Rect; import android.view.Display; import android.view.Surface; import android.view.Surface.OutOfResourcesException; import android.view.SurfaceControl; import android.view.SurfaceSession; import android.util.Slog; class CircularDisplayMask { private static final String TAG = "CircularDisplayMask"; private static final int STROKE_WIDTH = 2; // size of the chin private int mScreenOffset = 0; // Display dimensions private Point mScreenSize; private final SurfaceControl mSurfaceControl; private final Surface mSurface = new Surface(); private int mLastDW; private int mLastDH; private boolean mDrawNeeded; private Paint mPaint; private int mRotation; private boolean mVisible; private boolean mDimensionsUnequal = false; public CircularDisplayMask(Display display, SurfaceSession session, int zOrder, int screenOffset) { mScreenSize = new Point(); display.getSize(mScreenSize); if (mScreenSize.x != mScreenSize.y) { Slog.w(TAG, "Screen dimensions of displayId = " + display.getDisplayId() + "are not equal, circularMask will not be drawn."); mDimensionsUnequal = true; } SurfaceControl ctrl = null; try { ctrl = new SurfaceControl(session, "CircularDisplayMask", mScreenSize.x, mScreenSize.y, PixelFormat.TRANSLUCENT, SurfaceControl.HIDDEN); ctrl.setLayerStack(display.getLayerStack()); ctrl.setLayer(zOrder); ctrl.setPosition(0, 0); ctrl.show(); mSurface.copyFrom(ctrl); } catch (OutOfResourcesException e) { } mSurfaceControl = ctrl; mDrawNeeded = true; mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setStyle(Paint.Style.STROKE); mPaint.setColor(Color.BLACK); mPaint.setStrokeWidth(STROKE_WIDTH); mScreenOffset = screenOffset; } private void drawIfNeeded() { if (!mDrawNeeded || !mVisible || mDimensionsUnequal) { return; } mDrawNeeded = false; Rect dirty = new Rect(0, 0, mScreenSize.x, mScreenSize.y); Canvas c = null; try { c = mSurface.lockCanvas(dirty); } catch (IllegalArgumentException e) { } catch (Surface.OutOfResourcesException e) { } if (c == null) { return; } c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.SRC); switch (mRotation) { case Surface.ROTATION_0: case Surface.ROTATION_90: // chin bottom or right mSurfaceControl.setPosition(0, 0); break; case Surface.ROTATION_180: // chin top mSurfaceControl.setPosition(0, -mScreenOffset); break; case Surface.ROTATION_270: // chin left mSurfaceControl.setPosition(-mScreenOffset, 0); break; } int circleRadius = mScreenSize.x / 2; c.drawCircle(circleRadius, circleRadius, circleRadius, mPaint); mSurface.unlockCanvasAndPost(c); } // Note: caller responsible for being inside // Surface.openTransaction() / closeTransaction() public void setVisibility(boolean on) { if (mSurfaceControl == null) { return; } mVisible = on; drawIfNeeded(); if (on) { mSurfaceControl.show(); } else { mSurfaceControl.hide(); } } void positionSurface(int dw, int dh, int rotation) { if (mLastDW == dw && mLastDH == dh && mRotation == rotation) { return; } mLastDW = dw; mLastDH = dh; mDrawNeeded = true; mRotation = rotation; drawIfNeeded(); } } services/core/java/com/android/server/wm/WindowManagerService.java +51 −1 Original line number Original line Diff line number Diff line Loading @@ -422,6 +422,7 @@ public class WindowManagerService extends IWindowManager.Stub final SurfaceSession mFxSession; final SurfaceSession mFxSession; Watermark mWatermark; Watermark mWatermark; StrictModeFlash mStrictModeFlash; StrictModeFlash mStrictModeFlash; CircularDisplayMask mCircularDisplayMask; FocusedStackFrame mFocusedStackFrame; FocusedStackFrame mFocusedStackFrame; int mFocusedStackLayer; int mFocusedStackLayer; Loading Loading @@ -818,6 +819,8 @@ public class WindowManagerService extends IWindowManager.Stub } finally { } finally { SurfaceControl.closeTransaction(); SurfaceControl.closeTransaction(); } } showCircularDisplayMaskIfNeeded(); } } public InputMonitor getInputMonitor() { public InputMonitor getInputMonitor() { Loading Loading @@ -5550,6 +5553,44 @@ public class WindowManagerService extends IWindowManager.Stub } } } } public void showCircularDisplayMaskIfNeeded() { // we're fullscreen and not hosted in an ActivityView if (mContext.getResources().getBoolean( com.android.internal.R.bool.config_windowIsRound) && mContext.getResources().getBoolean( com.android.internal.R.bool.config_windowShowCircularMask)) { mH.sendMessage(mH.obtainMessage(H.SHOW_DISPLAY_MASK)); } } public void showCircularMask() { synchronized(mWindowMap) { if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION showDisplayMask"); SurfaceControl.openTransaction(); try { // TODO(multi-display): support multiple displays if (mCircularDisplayMask == null) { int screenOffset = (int) mContext.getResources().getDimensionPixelSize( com.android.internal.R.dimen.circular_display_mask_offset); mCircularDisplayMask = new CircularDisplayMask( getDefaultDisplayContentLocked().getDisplay(), mFxSession, mPolicy.windowTypeToLayerLw( WindowManager.LayoutParams.TYPE_POINTER) * TYPE_LAYER_MULTIPLIER + 10, screenOffset); } mCircularDisplayMask.setVisibility(true); } finally { SurfaceControl.closeTransaction(); if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION showDisplayMask"); } } } // TODO: more accounting of which pid(s) turned it on, keep count, // TODO: more accounting of which pid(s) turned it on, keep count, // only allow disables from pids which have count on, etc. // only allow disables from pids which have count on, etc. @Override @Override Loading Loading @@ -7165,7 +7206,8 @@ public class WindowManagerService extends IWindowManager.Stub public static final int REMOVE_STARTING_TIMEOUT = 33; public static final int REMOVE_STARTING_TIMEOUT = 33; public static final int ALL_WINDOWS_DRAWN = 34; public static final int SHOW_DISPLAY_MASK = 34; public static final int ALL_WINDOWS_DRAWN = 35; @Override @Override public void handleMessage(Message msg) { public void handleMessage(Message msg) { Loading Loading @@ -7569,6 +7611,11 @@ public class WindowManagerService extends IWindowManager.Stub break; break; } } case SHOW_DISPLAY_MASK: { showCircularMask(); break; } case DO_ANIMATION_CALLBACK: { case DO_ANIMATION_CALLBACK: { try { try { ((IRemoteCallback)msg.obj).sendResult(null); ((IRemoteCallback)msg.obj).sendResult(null); Loading Loading @@ -9053,6 +9100,9 @@ public class WindowManagerService extends IWindowManager.Stub if (mStrictModeFlash != null) { if (mStrictModeFlash != null) { mStrictModeFlash.positionSurface(defaultDw, defaultDh); mStrictModeFlash.positionSurface(defaultDw, defaultDh); } } if (mCircularDisplayMask != null) { mCircularDisplayMask.positionSurface(defaultDw, defaultDh, mRotation); } boolean focusDisplayed = false; boolean focusDisplayed = false; Loading Loading
core/res/res/values/config.xml +3 −0 Original line number Original line Diff line number Diff line Loading @@ -1490,6 +1490,9 @@ <!-- default device has recents property --> <!-- default device has recents property --> <bool name="config_hasRecents">true</bool> <bool name="config_hasRecents">true</bool> <!-- default window ShowCircularMask property --> <bool name="config_windowShowCircularMask">false</bool> <!-- Defines the default set of global actions. Actions may still be disabled or hidden based <!-- Defines the default set of global actions. Actions may still be disabled or hidden based on the current state of the device. on the current state of the device. Each item must be one of the following strings: Each item must be one of the following strings: Loading
core/res/res/values/dimens.xml +5 −0 Original line number Original line Diff line number Diff line Loading @@ -360,4 +360,9 @@ <!-- width of ImmersiveModeConfirmation (-1 for match_parent) --> <!-- width of ImmersiveModeConfirmation (-1 for match_parent) --> <dimen name="immersive_mode_cling_width">-1px</dimen> <dimen name="immersive_mode_cling_width">-1px</dimen> <!-- Size of the offset applied to the position of the circular mask. This is only used on circular displays. In the case where there is no "chin", this will default to 0 --> <dimen name="circular_display_mask_offset">0px</dimen> </resources> </resources>
core/res/res/values/symbols.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -292,6 +292,7 @@ <java-symbol type="bool" name="config_wifi_batched_scan_supported" /> <java-symbol type="bool" name="config_wifi_batched_scan_supported" /> <java-symbol type="bool" name="config_windowIsRound" /> <java-symbol type="bool" name="config_windowIsRound" /> <java-symbol type="bool" name="config_hasRecents" /> <java-symbol type="bool" name="config_hasRecents" /> <java-symbol type="bool" name="config_windowShowCircularMask" /> <java-symbol type="integer" name="config_cursorWindowSize" /> <java-symbol type="integer" name="config_cursorWindowSize" /> <java-symbol type="integer" name="config_extraFreeKbytesAdjust" /> <java-symbol type="integer" name="config_extraFreeKbytesAdjust" /> Loading Loading @@ -356,6 +357,7 @@ <java-symbol type="dimen" name="notification_title_text_size" /> <java-symbol type="dimen" name="notification_title_text_size" /> <java-symbol type="dimen" name="notification_subtext_size" /> <java-symbol type="dimen" name="notification_subtext_size" /> <java-symbol type="dimen" name="immersive_mode_cling_width" /> <java-symbol type="dimen" name="immersive_mode_cling_width" /> <java-symbol type="dimen" name="circular_display_mask_offset" /> <java-symbol type="string" name="add_account_button_label" /> <java-symbol type="string" name="add_account_button_label" /> <java-symbol type="string" name="addToDictionary" /> <java-symbol type="string" name="addToDictionary" /> Loading
services/core/java/com/android/server/wm/CircularDisplayMask.java 0 → 100644 +149 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2014 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. */ package com.android.server.wm; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PixelFormat; import android.graphics.Point; import android.graphics.PorterDuff; import android.graphics.Rect; import android.view.Display; import android.view.Surface; import android.view.Surface.OutOfResourcesException; import android.view.SurfaceControl; import android.view.SurfaceSession; import android.util.Slog; class CircularDisplayMask { private static final String TAG = "CircularDisplayMask"; private static final int STROKE_WIDTH = 2; // size of the chin private int mScreenOffset = 0; // Display dimensions private Point mScreenSize; private final SurfaceControl mSurfaceControl; private final Surface mSurface = new Surface(); private int mLastDW; private int mLastDH; private boolean mDrawNeeded; private Paint mPaint; private int mRotation; private boolean mVisible; private boolean mDimensionsUnequal = false; public CircularDisplayMask(Display display, SurfaceSession session, int zOrder, int screenOffset) { mScreenSize = new Point(); display.getSize(mScreenSize); if (mScreenSize.x != mScreenSize.y) { Slog.w(TAG, "Screen dimensions of displayId = " + display.getDisplayId() + "are not equal, circularMask will not be drawn."); mDimensionsUnequal = true; } SurfaceControl ctrl = null; try { ctrl = new SurfaceControl(session, "CircularDisplayMask", mScreenSize.x, mScreenSize.y, PixelFormat.TRANSLUCENT, SurfaceControl.HIDDEN); ctrl.setLayerStack(display.getLayerStack()); ctrl.setLayer(zOrder); ctrl.setPosition(0, 0); ctrl.show(); mSurface.copyFrom(ctrl); } catch (OutOfResourcesException e) { } mSurfaceControl = ctrl; mDrawNeeded = true; mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setStyle(Paint.Style.STROKE); mPaint.setColor(Color.BLACK); mPaint.setStrokeWidth(STROKE_WIDTH); mScreenOffset = screenOffset; } private void drawIfNeeded() { if (!mDrawNeeded || !mVisible || mDimensionsUnequal) { return; } mDrawNeeded = false; Rect dirty = new Rect(0, 0, mScreenSize.x, mScreenSize.y); Canvas c = null; try { c = mSurface.lockCanvas(dirty); } catch (IllegalArgumentException e) { } catch (Surface.OutOfResourcesException e) { } if (c == null) { return; } c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.SRC); switch (mRotation) { case Surface.ROTATION_0: case Surface.ROTATION_90: // chin bottom or right mSurfaceControl.setPosition(0, 0); break; case Surface.ROTATION_180: // chin top mSurfaceControl.setPosition(0, -mScreenOffset); break; case Surface.ROTATION_270: // chin left mSurfaceControl.setPosition(-mScreenOffset, 0); break; } int circleRadius = mScreenSize.x / 2; c.drawCircle(circleRadius, circleRadius, circleRadius, mPaint); mSurface.unlockCanvasAndPost(c); } // Note: caller responsible for being inside // Surface.openTransaction() / closeTransaction() public void setVisibility(boolean on) { if (mSurfaceControl == null) { return; } mVisible = on; drawIfNeeded(); if (on) { mSurfaceControl.show(); } else { mSurfaceControl.hide(); } } void positionSurface(int dw, int dh, int rotation) { if (mLastDW == dw && mLastDH == dh && mRotation == rotation) { return; } mLastDW = dw; mLastDH = dh; mDrawNeeded = true; mRotation = rotation; drawIfNeeded(); } }
services/core/java/com/android/server/wm/WindowManagerService.java +51 −1 Original line number Original line Diff line number Diff line Loading @@ -422,6 +422,7 @@ public class WindowManagerService extends IWindowManager.Stub final SurfaceSession mFxSession; final SurfaceSession mFxSession; Watermark mWatermark; Watermark mWatermark; StrictModeFlash mStrictModeFlash; StrictModeFlash mStrictModeFlash; CircularDisplayMask mCircularDisplayMask; FocusedStackFrame mFocusedStackFrame; FocusedStackFrame mFocusedStackFrame; int mFocusedStackLayer; int mFocusedStackLayer; Loading Loading @@ -818,6 +819,8 @@ public class WindowManagerService extends IWindowManager.Stub } finally { } finally { SurfaceControl.closeTransaction(); SurfaceControl.closeTransaction(); } } showCircularDisplayMaskIfNeeded(); } } public InputMonitor getInputMonitor() { public InputMonitor getInputMonitor() { Loading Loading @@ -5550,6 +5553,44 @@ public class WindowManagerService extends IWindowManager.Stub } } } } public void showCircularDisplayMaskIfNeeded() { // we're fullscreen and not hosted in an ActivityView if (mContext.getResources().getBoolean( com.android.internal.R.bool.config_windowIsRound) && mContext.getResources().getBoolean( com.android.internal.R.bool.config_windowShowCircularMask)) { mH.sendMessage(mH.obtainMessage(H.SHOW_DISPLAY_MASK)); } } public void showCircularMask() { synchronized(mWindowMap) { if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION showDisplayMask"); SurfaceControl.openTransaction(); try { // TODO(multi-display): support multiple displays if (mCircularDisplayMask == null) { int screenOffset = (int) mContext.getResources().getDimensionPixelSize( com.android.internal.R.dimen.circular_display_mask_offset); mCircularDisplayMask = new CircularDisplayMask( getDefaultDisplayContentLocked().getDisplay(), mFxSession, mPolicy.windowTypeToLayerLw( WindowManager.LayoutParams.TYPE_POINTER) * TYPE_LAYER_MULTIPLIER + 10, screenOffset); } mCircularDisplayMask.setVisibility(true); } finally { SurfaceControl.closeTransaction(); if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION showDisplayMask"); } } } // TODO: more accounting of which pid(s) turned it on, keep count, // TODO: more accounting of which pid(s) turned it on, keep count, // only allow disables from pids which have count on, etc. // only allow disables from pids which have count on, etc. @Override @Override Loading Loading @@ -7165,7 +7206,8 @@ public class WindowManagerService extends IWindowManager.Stub public static final int REMOVE_STARTING_TIMEOUT = 33; public static final int REMOVE_STARTING_TIMEOUT = 33; public static final int ALL_WINDOWS_DRAWN = 34; public static final int SHOW_DISPLAY_MASK = 34; public static final int ALL_WINDOWS_DRAWN = 35; @Override @Override public void handleMessage(Message msg) { public void handleMessage(Message msg) { Loading Loading @@ -7569,6 +7611,11 @@ public class WindowManagerService extends IWindowManager.Stub break; break; } } case SHOW_DISPLAY_MASK: { showCircularMask(); break; } case DO_ANIMATION_CALLBACK: { case DO_ANIMATION_CALLBACK: { try { try { ((IRemoteCallback)msg.obj).sendResult(null); ((IRemoteCallback)msg.obj).sendResult(null); Loading Loading @@ -9053,6 +9100,9 @@ public class WindowManagerService extends IWindowManager.Stub if (mStrictModeFlash != null) { if (mStrictModeFlash != null) { mStrictModeFlash.positionSurface(defaultDw, defaultDh); mStrictModeFlash.positionSurface(defaultDw, defaultDh); } } if (mCircularDisplayMask != null) { mCircularDisplayMask.positionSurface(defaultDw, defaultDh, mRotation); } boolean focusDisplayed = false; boolean focusDisplayed = false; Loading