Loading core/java/android/os/RemoteCallbackList.java +19 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package android.os; import android.util.ArrayMap; import java.util.function.Consumer; /** * Takes care of the grunt work of maintaining a list of remote interfaces, * typically for the use of performing callbacks from a Loading Loading @@ -307,6 +309,23 @@ public class RemoteCallbackList<E extends IInterface> { } } /** * Performs {@code action} on each callback, calling * {@link #beginBroadcast()}/{@link #finishBroadcast()} before/after looping * * @hide */ public void broadcast(Consumer<E> action) { int itemCount = beginBroadcast(); try { for (int i = 0; i < itemCount; i++) { action.accept(getBroadcastItem(i)); } } finally { finishBroadcast(); } } /** * Returns the number of registered callbacks. Note that the number of registered * callbacks may differ from the value returned by {@link #beginBroadcast()} since Loading core/java/android/view/accessibility/AccessibilityManager.java +20 −2 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ import android.util.Log; import android.view.IWindow; import android.view.View; import com.android.internal.util.IntPair; import java.util.ArrayList; import java.util.Collections; import java.util.List; Loading Loading @@ -109,6 +111,8 @@ public final class AccessibilityManager { boolean mIsEnabled; int mRelevantEventTypes = AccessibilityEvent.TYPES_ALL_MASK; boolean mIsTouchExplorationEnabled; boolean mIsHighTextContrastEnabled; Loading Loading @@ -203,6 +207,11 @@ public final class AccessibilityManager { public void notifyServicesStateChanged() { mHandler.obtainMessage(MyHandler.MSG_NOTIFY_SERVICES_STATE_CHANGED).sendToTarget(); } @Override public void setRelevantEventTypes(int eventTypes) { mRelevantEventTypes = eventTypes; } }; /** Loading Loading @@ -362,6 +371,14 @@ public final class AccessibilityManager { return; } } if ((event.getEventType() & mRelevantEventTypes) == 0) { if (DEBUG) { Log.i(LOG_TAG, "Not dispatching irrelevant event: " + event + " that is not among " + AccessibilityEvent.eventTypeToString(mRelevantEventTypes)); } return; } userId = mUserId; } try { Loading Loading @@ -865,8 +882,9 @@ public final class AccessibilityManager { } try { final int stateFlags = service.addClient(mClient, mUserId); setStateLocked(stateFlags); final long userStateAndRelevantEvents = service.addClient(mClient, mUserId); setStateLocked(IntPair.first(userStateAndRelevantEvents)); mRelevantEventTypes = IntPair.second(userStateAndRelevantEvents); mService = service; } catch (RemoteException re) { Log.e(LOG_TAG, "AccessibilityManagerService is dead", re); Loading core/java/android/view/accessibility/IAccessibilityManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ interface IAccessibilityManager { oneway void sendAccessibilityEvent(in AccessibilityEvent uiEvent, int userId); int addClient(IAccessibilityManagerClient client, int userId); long addClient(IAccessibilityManagerClient client, int userId); List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList(int userId); Loading core/java/android/view/accessibility/IAccessibilityManagerClient.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -25,5 +25,8 @@ package android.view.accessibility; oneway interface IAccessibilityManagerClient { void setState(int stateFlags); void notifyServicesStateChanged(); void setRelevantEventTypes(int eventTypes); } core/java/com/android/internal/util/IntPair.java 0 → 100644 +38 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.internal.util; /** * Utilities for treating a {@code long} as a pair of {@code int}s * * @hide */ public class IntPair { private IntPair() {} public static long of(int first, int second) { return (((long)first) << 32) | ((long)second & 0xffffffffL); } public static int first(long intPair) { return (int)(intPair >> 32); } public static int second(long intPair) { return (int)intPair; } } Loading
core/java/android/os/RemoteCallbackList.java +19 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package android.os; import android.util.ArrayMap; import java.util.function.Consumer; /** * Takes care of the grunt work of maintaining a list of remote interfaces, * typically for the use of performing callbacks from a Loading Loading @@ -307,6 +309,23 @@ public class RemoteCallbackList<E extends IInterface> { } } /** * Performs {@code action} on each callback, calling * {@link #beginBroadcast()}/{@link #finishBroadcast()} before/after looping * * @hide */ public void broadcast(Consumer<E> action) { int itemCount = beginBroadcast(); try { for (int i = 0; i < itemCount; i++) { action.accept(getBroadcastItem(i)); } } finally { finishBroadcast(); } } /** * Returns the number of registered callbacks. Note that the number of registered * callbacks may differ from the value returned by {@link #beginBroadcast()} since Loading
core/java/android/view/accessibility/AccessibilityManager.java +20 −2 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ import android.util.Log; import android.view.IWindow; import android.view.View; import com.android.internal.util.IntPair; import java.util.ArrayList; import java.util.Collections; import java.util.List; Loading Loading @@ -109,6 +111,8 @@ public final class AccessibilityManager { boolean mIsEnabled; int mRelevantEventTypes = AccessibilityEvent.TYPES_ALL_MASK; boolean mIsTouchExplorationEnabled; boolean mIsHighTextContrastEnabled; Loading Loading @@ -203,6 +207,11 @@ public final class AccessibilityManager { public void notifyServicesStateChanged() { mHandler.obtainMessage(MyHandler.MSG_NOTIFY_SERVICES_STATE_CHANGED).sendToTarget(); } @Override public void setRelevantEventTypes(int eventTypes) { mRelevantEventTypes = eventTypes; } }; /** Loading Loading @@ -362,6 +371,14 @@ public final class AccessibilityManager { return; } } if ((event.getEventType() & mRelevantEventTypes) == 0) { if (DEBUG) { Log.i(LOG_TAG, "Not dispatching irrelevant event: " + event + " that is not among " + AccessibilityEvent.eventTypeToString(mRelevantEventTypes)); } return; } userId = mUserId; } try { Loading Loading @@ -865,8 +882,9 @@ public final class AccessibilityManager { } try { final int stateFlags = service.addClient(mClient, mUserId); setStateLocked(stateFlags); final long userStateAndRelevantEvents = service.addClient(mClient, mUserId); setStateLocked(IntPair.first(userStateAndRelevantEvents)); mRelevantEventTypes = IntPair.second(userStateAndRelevantEvents); mService = service; } catch (RemoteException re) { Log.e(LOG_TAG, "AccessibilityManagerService is dead", re); Loading
core/java/android/view/accessibility/IAccessibilityManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ interface IAccessibilityManager { oneway void sendAccessibilityEvent(in AccessibilityEvent uiEvent, int userId); int addClient(IAccessibilityManagerClient client, int userId); long addClient(IAccessibilityManagerClient client, int userId); List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList(int userId); Loading
core/java/android/view/accessibility/IAccessibilityManagerClient.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -25,5 +25,8 @@ package android.view.accessibility; oneway interface IAccessibilityManagerClient { void setState(int stateFlags); void notifyServicesStateChanged(); void setRelevantEventTypes(int eventTypes); }
core/java/com/android/internal/util/IntPair.java 0 → 100644 +38 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.internal.util; /** * Utilities for treating a {@code long} as a pair of {@code int}s * * @hide */ public class IntPair { private IntPair() {} public static long of(int first, int second) { return (((long)first) << 32) | ((long)second & 0xffffffffL); } public static int first(long intPair) { return (int)(intPair >> 32); } public static int second(long intPair) { return (int)intPair; } }