Loading core/java/android/content/ContentResolver.java +2 −2 Original line number Diff line number Diff line Loading @@ -2722,10 +2722,10 @@ public abstract class ContentResolver implements ContentInterface { /** @hide - designated user version */ @UnsupportedAppUsage public final void registerContentObserver(Uri uri, boolean notifyForDescendents, public final void registerContentObserver(Uri uri, boolean notifyForDescendants, ContentObserver observer, @UserIdInt int userHandle) { try { getContentService().registerContentObserver(uri, notifyForDescendents, getContentService().registerContentObserver(uri, notifyForDescendants, observer.getContentObserver(), userHandle, mTargetSdkVersion); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); Loading services/accessibility/java/com/android/server/accessibility/AutoclickController.java +40 −33 Original line number Diff line number Diff line Loading @@ -16,7 +16,9 @@ package com.android.server.accessibility; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; import static android.view.MotionEvent.BUTTON_PRIMARY; import static android.view.accessibility.AccessibilityManager.AUTOCLICK_CURSOR_AREA_SIZE_DEFAULT; import static android.view.accessibility.AccessibilityManager.AUTOCLICK_DELAY_DEFAULT; import static com.android.server.accessibility.AutoclickIndicatorView.SHOW_INDICATOR_DELAY_TIME; Loading @@ -26,7 +28,6 @@ import android.annotation.Nullable; import android.content.ContentResolver; import android.content.Context; import android.database.ContentObserver; import android.graphics.PixelFormat; import android.net.Uri; import android.os.Handler; import android.os.SystemClock; Loading @@ -37,7 +38,6 @@ import android.view.MotionEvent; import android.view.MotionEvent.PointerCoords; import android.view.MotionEvent.PointerProperties; import android.view.WindowManager; import android.view.accessibility.AccessibilityManager; import androidx.annotation.VisibleForTesting; Loading Loading @@ -96,8 +96,7 @@ public class AutoclickController extends BaseEventStreamTransformation { initiateAutoclickIndicator(handler); } mClickScheduler = new ClickScheduler(handler, AccessibilityManager.AUTOCLICK_DELAY_DEFAULT); mClickScheduler = new ClickScheduler(handler, AUTOCLICK_DELAY_DEFAULT); mAutoclickSettingsObserver = new AutoclickSettingsObserver(mUserId, handler); mAutoclickSettingsObserver.start( mContext.getContentResolver(), Loading @@ -117,21 +116,8 @@ public class AutoclickController extends BaseEventStreamTransformation { mAutoclickIndicatorScheduler = new AutoclickIndicatorScheduler(handler); mAutoclickIndicatorView = new AutoclickIndicatorView(mContext); final WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); layoutParams.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; layoutParams.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS; layoutParams.setFitInsetsTypes(0); layoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; layoutParams.format = PixelFormat.TRANSLUCENT; layoutParams.setTitle(AutoclickIndicatorView.class.getSimpleName()); layoutParams.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; mWindowManager = mContext.getSystemService(WindowManager.class); mWindowManager.addView(mAutoclickIndicatorView, layoutParams); mWindowManager.addView(mAutoclickIndicatorView, mAutoclickIndicatorView.getLayoutParams()); } @Override Loading Loading @@ -247,18 +233,24 @@ public class AutoclickController extends BaseEventStreamTransformation { mContentResolver = contentResolver; mClickScheduler = clickScheduler; mAutoclickIndicatorScheduler = autoclickIndicatorScheduler; mContentResolver.registerContentObserver(mAutoclickDelaySettingUri, false, this, mContentResolver.registerContentObserver( mAutoclickDelaySettingUri, /* notifyForDescendants= */ false, /* observer= */ this, mUserId); // Initialize mClickScheduler's initial delay value. onChange(true, mAutoclickDelaySettingUri); onChange(/* selfChange= */ true, mAutoclickDelaySettingUri); if (Flags.enableAutoclickIndicator()) { // Register observer to listen to cursor area size setting change. mContentResolver.registerContentObserver( mAutoclickCursorAreaSizeSettingUri, false, this, mUserId); mAutoclickCursorAreaSizeSettingUri, /* notifyForDescendants= */ false, /* observer= */ this, mUserId); // Initialize mAutoclickIndicatorView's initial size. onChange(true, mAutoclickCursorAreaSizeSettingUri); onChange(/* selfChange= */ true, mAutoclickCursorAreaSizeSettingUri); } } Loading @@ -279,9 +271,12 @@ public class AutoclickController extends BaseEventStreamTransformation { @Override public void onChange(boolean selfChange, Uri uri) { if (mAutoclickDelaySettingUri.equals(uri)) { int delay = Settings.Secure.getIntForUser( mContentResolver, Settings.Secure.ACCESSIBILITY_AUTOCLICK_DELAY, AccessibilityManager.AUTOCLICK_DELAY_DEFAULT, mUserId); int delay = Settings.Secure.getIntForUser( mContentResolver, Settings.Secure.ACCESSIBILITY_AUTOCLICK_DELAY, AUTOCLICK_DELAY_DEFAULT, mUserId); mClickScheduler.updateDelay(delay); } if (Flags.enableAutoclickIndicator() Loading @@ -290,7 +285,7 @@ public class AutoclickController extends BaseEventStreamTransformation { Settings.Secure.getIntForUser( mContentResolver, Settings.Secure.ACCESSIBILITY_AUTOCLICK_CURSOR_AREA_SIZE, AccessibilityManager.AUTOCLICK_CURSOR_AREA_SIZE_DEFAULT, AUTOCLICK_CURSOR_AREA_SIZE_DEFAULT, mUserId); if (mAutoclickIndicatorScheduler != null) { mAutoclickIndicatorScheduler.updateCursorAreaSize(size); Loading Loading @@ -581,18 +576,30 @@ public class AutoclickController extends BaseEventStreamTransformation { final long now = SystemClock.uptimeMillis(); MotionEvent downEvent = MotionEvent.obtain(now, now, MotionEvent.ACTION_DOWN, 1, mTempPointerProperties, mTempPointerCoords, mMetaState, MotionEvent.BUTTON_PRIMARY, 1.0f, 1.0f, mLastMotionEvent.getDeviceId(), 0, mLastMotionEvent.getSource(), mLastMotionEvent.getFlags()); MotionEvent downEvent = MotionEvent.obtain( /* downTime= */ now, /* eventTime= */ now, MotionEvent.ACTION_DOWN, /* pointerCount= */ 1, mTempPointerProperties, mTempPointerCoords, mMetaState, BUTTON_PRIMARY, /* xPrecision= */ 1.0f, /* yPrecision= */ 1.0f, mLastMotionEvent.getDeviceId(), /* edgeFlags= */ 0, mLastMotionEvent.getSource(), mLastMotionEvent.getFlags()); MotionEvent pressEvent = MotionEvent.obtain(downEvent); pressEvent.setAction(MotionEvent.ACTION_BUTTON_PRESS); pressEvent.setActionButton(MotionEvent.BUTTON_PRIMARY); pressEvent.setActionButton(BUTTON_PRIMARY); MotionEvent releaseEvent = MotionEvent.obtain(downEvent); releaseEvent.setAction(MotionEvent.ACTION_BUTTON_RELEASE); releaseEvent.setActionButton(MotionEvent.BUTTON_PRIMARY); releaseEvent.setActionButton(BUTTON_PRIMARY); releaseEvent.setButtonState(0); MotionEvent upEvent = MotionEvent.obtain(downEvent); Loading services/accessibility/java/com/android/server/accessibility/AutoclickIndicatorView.java +24 −0 Original line number Diff line number Diff line Loading @@ -16,15 +16,19 @@ package com.android.server.accessibility; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; import static android.view.accessibility.AccessibilityManager.AUTOCLICK_CURSOR_AREA_SIZE_DEFAULT; import android.animation.ValueAnimator; import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.PixelFormat; import android.graphics.RectF; import android.util.DisplayMetrics; import android.view.View; import android.view.WindowInsets; import android.view.WindowManager; import android.view.accessibility.AccessibilityManager; import android.view.animation.LinearInterpolator; Loading Loading @@ -81,6 +85,26 @@ public class AutoclickIndicatorView extends View { mRingRect = new RectF(); } /** * Retrieves the layout params for AutoclickIndicatorView, used when it's added to the Window * Manager. */ public final WindowManager.LayoutParams getLayoutParams() { final WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); layoutParams.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; layoutParams.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS; layoutParams.setFitInsetsTypes(WindowInsets.Type.statusBars()); layoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; layoutParams.format = PixelFormat.TRANSLUCENT; layoutParams.setTitle(AutoclickIndicatorView.class.getSimpleName()); layoutParams.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; return layoutParams; } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Loading Loading
core/java/android/content/ContentResolver.java +2 −2 Original line number Diff line number Diff line Loading @@ -2722,10 +2722,10 @@ public abstract class ContentResolver implements ContentInterface { /** @hide - designated user version */ @UnsupportedAppUsage public final void registerContentObserver(Uri uri, boolean notifyForDescendents, public final void registerContentObserver(Uri uri, boolean notifyForDescendants, ContentObserver observer, @UserIdInt int userHandle) { try { getContentService().registerContentObserver(uri, notifyForDescendents, getContentService().registerContentObserver(uri, notifyForDescendants, observer.getContentObserver(), userHandle, mTargetSdkVersion); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); Loading
services/accessibility/java/com/android/server/accessibility/AutoclickController.java +40 −33 Original line number Diff line number Diff line Loading @@ -16,7 +16,9 @@ package com.android.server.accessibility; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; import static android.view.MotionEvent.BUTTON_PRIMARY; import static android.view.accessibility.AccessibilityManager.AUTOCLICK_CURSOR_AREA_SIZE_DEFAULT; import static android.view.accessibility.AccessibilityManager.AUTOCLICK_DELAY_DEFAULT; import static com.android.server.accessibility.AutoclickIndicatorView.SHOW_INDICATOR_DELAY_TIME; Loading @@ -26,7 +28,6 @@ import android.annotation.Nullable; import android.content.ContentResolver; import android.content.Context; import android.database.ContentObserver; import android.graphics.PixelFormat; import android.net.Uri; import android.os.Handler; import android.os.SystemClock; Loading @@ -37,7 +38,6 @@ import android.view.MotionEvent; import android.view.MotionEvent.PointerCoords; import android.view.MotionEvent.PointerProperties; import android.view.WindowManager; import android.view.accessibility.AccessibilityManager; import androidx.annotation.VisibleForTesting; Loading Loading @@ -96,8 +96,7 @@ public class AutoclickController extends BaseEventStreamTransformation { initiateAutoclickIndicator(handler); } mClickScheduler = new ClickScheduler(handler, AccessibilityManager.AUTOCLICK_DELAY_DEFAULT); mClickScheduler = new ClickScheduler(handler, AUTOCLICK_DELAY_DEFAULT); mAutoclickSettingsObserver = new AutoclickSettingsObserver(mUserId, handler); mAutoclickSettingsObserver.start( mContext.getContentResolver(), Loading @@ -117,21 +116,8 @@ public class AutoclickController extends BaseEventStreamTransformation { mAutoclickIndicatorScheduler = new AutoclickIndicatorScheduler(handler); mAutoclickIndicatorView = new AutoclickIndicatorView(mContext); final WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); layoutParams.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; layoutParams.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS; layoutParams.setFitInsetsTypes(0); layoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; layoutParams.format = PixelFormat.TRANSLUCENT; layoutParams.setTitle(AutoclickIndicatorView.class.getSimpleName()); layoutParams.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; mWindowManager = mContext.getSystemService(WindowManager.class); mWindowManager.addView(mAutoclickIndicatorView, layoutParams); mWindowManager.addView(mAutoclickIndicatorView, mAutoclickIndicatorView.getLayoutParams()); } @Override Loading Loading @@ -247,18 +233,24 @@ public class AutoclickController extends BaseEventStreamTransformation { mContentResolver = contentResolver; mClickScheduler = clickScheduler; mAutoclickIndicatorScheduler = autoclickIndicatorScheduler; mContentResolver.registerContentObserver(mAutoclickDelaySettingUri, false, this, mContentResolver.registerContentObserver( mAutoclickDelaySettingUri, /* notifyForDescendants= */ false, /* observer= */ this, mUserId); // Initialize mClickScheduler's initial delay value. onChange(true, mAutoclickDelaySettingUri); onChange(/* selfChange= */ true, mAutoclickDelaySettingUri); if (Flags.enableAutoclickIndicator()) { // Register observer to listen to cursor area size setting change. mContentResolver.registerContentObserver( mAutoclickCursorAreaSizeSettingUri, false, this, mUserId); mAutoclickCursorAreaSizeSettingUri, /* notifyForDescendants= */ false, /* observer= */ this, mUserId); // Initialize mAutoclickIndicatorView's initial size. onChange(true, mAutoclickCursorAreaSizeSettingUri); onChange(/* selfChange= */ true, mAutoclickCursorAreaSizeSettingUri); } } Loading @@ -279,9 +271,12 @@ public class AutoclickController extends BaseEventStreamTransformation { @Override public void onChange(boolean selfChange, Uri uri) { if (mAutoclickDelaySettingUri.equals(uri)) { int delay = Settings.Secure.getIntForUser( mContentResolver, Settings.Secure.ACCESSIBILITY_AUTOCLICK_DELAY, AccessibilityManager.AUTOCLICK_DELAY_DEFAULT, mUserId); int delay = Settings.Secure.getIntForUser( mContentResolver, Settings.Secure.ACCESSIBILITY_AUTOCLICK_DELAY, AUTOCLICK_DELAY_DEFAULT, mUserId); mClickScheduler.updateDelay(delay); } if (Flags.enableAutoclickIndicator() Loading @@ -290,7 +285,7 @@ public class AutoclickController extends BaseEventStreamTransformation { Settings.Secure.getIntForUser( mContentResolver, Settings.Secure.ACCESSIBILITY_AUTOCLICK_CURSOR_AREA_SIZE, AccessibilityManager.AUTOCLICK_CURSOR_AREA_SIZE_DEFAULT, AUTOCLICK_CURSOR_AREA_SIZE_DEFAULT, mUserId); if (mAutoclickIndicatorScheduler != null) { mAutoclickIndicatorScheduler.updateCursorAreaSize(size); Loading Loading @@ -581,18 +576,30 @@ public class AutoclickController extends BaseEventStreamTransformation { final long now = SystemClock.uptimeMillis(); MotionEvent downEvent = MotionEvent.obtain(now, now, MotionEvent.ACTION_DOWN, 1, mTempPointerProperties, mTempPointerCoords, mMetaState, MotionEvent.BUTTON_PRIMARY, 1.0f, 1.0f, mLastMotionEvent.getDeviceId(), 0, mLastMotionEvent.getSource(), mLastMotionEvent.getFlags()); MotionEvent downEvent = MotionEvent.obtain( /* downTime= */ now, /* eventTime= */ now, MotionEvent.ACTION_DOWN, /* pointerCount= */ 1, mTempPointerProperties, mTempPointerCoords, mMetaState, BUTTON_PRIMARY, /* xPrecision= */ 1.0f, /* yPrecision= */ 1.0f, mLastMotionEvent.getDeviceId(), /* edgeFlags= */ 0, mLastMotionEvent.getSource(), mLastMotionEvent.getFlags()); MotionEvent pressEvent = MotionEvent.obtain(downEvent); pressEvent.setAction(MotionEvent.ACTION_BUTTON_PRESS); pressEvent.setActionButton(MotionEvent.BUTTON_PRIMARY); pressEvent.setActionButton(BUTTON_PRIMARY); MotionEvent releaseEvent = MotionEvent.obtain(downEvent); releaseEvent.setAction(MotionEvent.ACTION_BUTTON_RELEASE); releaseEvent.setActionButton(MotionEvent.BUTTON_PRIMARY); releaseEvent.setActionButton(BUTTON_PRIMARY); releaseEvent.setButtonState(0); MotionEvent upEvent = MotionEvent.obtain(downEvent); Loading
services/accessibility/java/com/android/server/accessibility/AutoclickIndicatorView.java +24 −0 Original line number Diff line number Diff line Loading @@ -16,15 +16,19 @@ package com.android.server.accessibility; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; import static android.view.accessibility.AccessibilityManager.AUTOCLICK_CURSOR_AREA_SIZE_DEFAULT; import android.animation.ValueAnimator; import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.PixelFormat; import android.graphics.RectF; import android.util.DisplayMetrics; import android.view.View; import android.view.WindowInsets; import android.view.WindowManager; import android.view.accessibility.AccessibilityManager; import android.view.animation.LinearInterpolator; Loading Loading @@ -81,6 +85,26 @@ public class AutoclickIndicatorView extends View { mRingRect = new RectF(); } /** * Retrieves the layout params for AutoclickIndicatorView, used when it's added to the Window * Manager. */ public final WindowManager.LayoutParams getLayoutParams() { final WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); layoutParams.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; layoutParams.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS; layoutParams.setFitInsetsTypes(WindowInsets.Type.statusBars()); layoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; layoutParams.format = PixelFormat.TRANSLUCENT; layoutParams.setTitle(AutoclickIndicatorView.class.getSimpleName()); layoutParams.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; return layoutParams; } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Loading