Merge "Add API for services to turn off window animations."
This commit is contained in:
@@ -3074,6 +3074,7 @@ package android.accessibilityservice {
|
||||
method public void onSystemActionsChanged();
|
||||
method public final boolean performGlobalAction(int);
|
||||
method public void setAccessibilityFocusAppearance(int, @ColorInt int);
|
||||
method public void setAnimationScale(float);
|
||||
method public boolean setCacheEnabled(boolean);
|
||||
method public void setGestureDetectionPassthroughRegion(int, @NonNull android.graphics.Region);
|
||||
method public final void setServiceInfo(android.accessibilityservice.AccessibilityServiceInfo);
|
||||
@@ -6949,6 +6950,7 @@ package android.app {
|
||||
method public boolean performGlobalAction(int);
|
||||
method public void revokeRuntimePermission(String, String);
|
||||
method public void revokeRuntimePermissionAsUser(String, String, android.os.UserHandle);
|
||||
method public void setAnimationScale(float);
|
||||
method public void setOnAccessibilityEventListener(android.app.UiAutomation.OnAccessibilityEventListener);
|
||||
method public boolean setRotation(int);
|
||||
method public void setRunAsMonkey(boolean);
|
||||
|
||||
@@ -3120,6 +3120,33 @@ public abstract class AccessibilityService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the system settings values that control the scaling factor for animations. The scale
|
||||
* controls the animation playback speed for animations that respect these settings. Animations
|
||||
* that do not respect the settings values will not be affected by this function. A lower scale
|
||||
* value results in a faster speed. A value of <code>0</code> disables animations entirely. When
|
||||
* animations are disabled services receive window change events more quickly which can reduce
|
||||
* the potential by confusion by reducing the time during which windows are in transition.
|
||||
*
|
||||
* @see AccessibilityEvent#TYPE_WINDOWS_CHANGED
|
||||
* @see AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED
|
||||
* @see android.provider.Settings.Global#WINDOW_ANIMATION_SCALE
|
||||
* @see android.provider.Settings.Global#TRANSITION_ANIMATION_SCALE
|
||||
* @see android.provider.Settings.Global#ANIMATOR_DURATION_SCALE
|
||||
* @param scale The scaling factor for all animations.
|
||||
*/
|
||||
public void setAnimationScale(float scale) {
|
||||
final IAccessibilityServiceConnection connection =
|
||||
AccessibilityInteractionClient.getInstance(this).getConnection(mConnectionId);
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.setAnimationScale(scale);
|
||||
} catch (RemoteException re) {
|
||||
throw new RuntimeException(re);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class AccessibilityContext extends ContextWrapper {
|
||||
private final int mConnectionId;
|
||||
|
||||
|
||||
@@ -144,4 +144,6 @@ interface IAccessibilityServiceConnection {
|
||||
void onDoubleTap(int displayId);
|
||||
|
||||
void onDoubleTapAndHold(int displayId);
|
||||
|
||||
void setAnimationScale(float scale);
|
||||
}
|
||||
|
||||
@@ -779,6 +779,33 @@ public final class UiAutomation {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the system settings values that control the scaling factor for animations. The scale
|
||||
* controls the animation playback speed for animations that respect these settings. Animations
|
||||
* that do not respect the settings values will not be affected by this function. A lower scale
|
||||
* value results in a faster speed. A value of <code>0</code> disables animations entirely. When
|
||||
* animations are disabled services receive window change events more quickly which can reduce
|
||||
* the potential by confusion by reducing the time during which windows are in transition.
|
||||
*
|
||||
* @see AccessibilityEvent#TYPE_WINDOWS_CHANGED
|
||||
* @see AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED
|
||||
* @see android.provider.Settings.Global#WINDOW_ANIMATION_SCALE
|
||||
* @see android.provider.Settings.Global#TRANSITION_ANIMATION_SCALE
|
||||
* @see android.provider.Settings.Global#ANIMATOR_DURATION_SCALE
|
||||
* @param scale The scaling factor for all animations.
|
||||
*/
|
||||
public void setAnimationScale(float scale) {
|
||||
final IAccessibilityServiceConnection connection =
|
||||
AccessibilityInteractionClient.getInstance().getConnection(mConnectionId);
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.setAnimationScale(scale);
|
||||
} catch (RemoteException re) {
|
||||
throw new RuntimeException(re);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A request for WindowManagerService to wait until all animations have completed and input
|
||||
* information has been sent from WindowManager to native InputManager.
|
||||
|
||||
@@ -204,4 +204,6 @@ public class AccessibilityServiceConnectionImpl extends IAccessibilityServiceCon
|
||||
|
||||
public void logTrace(long timestamp, String where, long loggingTypes, String callingParams,
|
||||
int processId, long threadId, int callingUid, Bundle serializedCallingStackInBundle) {}
|
||||
|
||||
public void setAnimationScale(float scale) {}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ import android.os.RemoteCallback;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.SystemClock;
|
||||
import android.provider.Settings;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
import android.view.Display;
|
||||
@@ -269,6 +270,7 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
|
||||
void onDoubleTap(int displayId);
|
||||
|
||||
void onDoubleTapAndHold(int displayId);
|
||||
|
||||
}
|
||||
|
||||
public AbstractAccessibilityServiceConnection(Context context, ComponentName componentName,
|
||||
@@ -2164,4 +2166,23 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
|
||||
public void onDoubleTapAndHold(int displayId) {
|
||||
mSystemSupport.onDoubleTapAndHold(displayId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the scaling factor for animations.
|
||||
*/
|
||||
public void setAnimationScale(float scale) {
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
Settings.Global.putFloat(
|
||||
mContext.getContentResolver(), Settings.Global.WINDOW_ANIMATION_SCALE, scale);
|
||||
Settings.Global.putFloat(
|
||||
mContext.getContentResolver(),
|
||||
Settings.Global.TRANSITION_ANIMATION_SCALE,
|
||||
scale);
|
||||
Settings.Global.putFloat(
|
||||
mContext.getContentResolver(), Settings.Global.ANIMATOR_DURATION_SCALE, scale);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user