1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.view.accessibility; 18 19 import com.android.layoutlib.bridge.android.BridgeContext; 20 import com.android.tools.layoutlib.annotations.LayoutlibDelegate; 21 22 import android.content.Context; 23 import android.graphics.Matrix; 24 import android.view.MagnificationSpec; 25 import android.view.accessibility.IAccessibilityManager.WindowTransformationSpec; 26 27 public class AccessibilityManager_Delegate { 28 private static WindowTransformationSpec sInstance; 29 30 @LayoutlibDelegate getWindowTransformationSpec( AccessibilityManager thisManager, int windowId)31 public static IAccessibilityManager.WindowTransformationSpec getWindowTransformationSpec( 32 AccessibilityManager thisManager, int windowId) { 33 if (sInstance == null) { 34 WindowTransformationSpec spec = new WindowTransformationSpec(); 35 spec.magnificationSpec = new MagnificationSpec(); 36 float[] matrix = new float[9]; 37 Matrix.IDENTITY_MATRIX.getValues(matrix); 38 spec.transformationMatrix = matrix; 39 sInstance = spec; 40 } 41 return sInstance; 42 } 43 44 @LayoutlibDelegate getInstance(Context context)45 public static AccessibilityManager getInstance(Context context) { 46 Context baseContext = BridgeContext.getBaseContext(context); 47 return ((BridgeContext)baseContext).getAccessibilityManager(); 48 } 49 } 50