1 /*
2  * Copyright (C) 2019 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 com.android.server.wm;
18 
19 import android.graphics.Matrix;
20 import android.graphics.Rect;
21 import android.graphics.Region;
22 import android.os.IBinder;
23 import android.os.Parcel;
24 import android.view.InputWindowHandle;
25 import android.view.Surface;
26 import android.view.SurfaceControl;
27 
28 /**
29  * Stubbed {@link android.view.SurfaceControl.Transaction} class that can be used when unit
30  * testing to avoid calls to native code.
31  */
32 public class StubTransaction extends SurfaceControl.Transaction {
33     @Override
apply()34     public void apply() {
35     }
36 
37     @Override
close()38     public void close() {
39     }
40 
41     @Override
apply(boolean sync)42     public void apply(boolean sync) {
43     }
44 
45     @Override
setVisibility(SurfaceControl sc, boolean visible)46     public SurfaceControl.Transaction setVisibility(SurfaceControl sc, boolean visible) {
47         return this;
48     }
49 
50     @Override
show(SurfaceControl sc)51     public SurfaceControl.Transaction show(SurfaceControl sc) {
52         return this;
53     }
54 
55     @Override
hide(SurfaceControl sc)56     public SurfaceControl.Transaction hide(SurfaceControl sc) {
57         return this;
58     }
59 
60     @Override
setPosition(SurfaceControl sc, float x, float y)61     public SurfaceControl.Transaction setPosition(SurfaceControl sc, float x, float y) {
62         return this;
63     }
64 
65     @Override
setBufferSize(SurfaceControl sc, int w, int h)66     public SurfaceControl.Transaction setBufferSize(SurfaceControl sc,
67             int w, int h) {
68         return this;
69     }
70 
71     @Override
setLayer(SurfaceControl sc, int z)72     public SurfaceControl.Transaction setLayer(SurfaceControl sc, int z) {
73         return this;
74     }
75 
76     @Override
setRelativeLayer(SurfaceControl sc, SurfaceControl relativeTo, int z)77     public SurfaceControl.Transaction setRelativeLayer(SurfaceControl sc, SurfaceControl relativeTo,
78             int z) {
79         return this;
80     }
81 
82     @Override
setTransparentRegionHint(SurfaceControl sc, Region transparentRegion)83     public SurfaceControl.Transaction setTransparentRegionHint(SurfaceControl sc,
84             Region transparentRegion) {
85         return this;
86     }
87 
88     @Override
setAlpha(SurfaceControl sc, float alpha)89     public SurfaceControl.Transaction setAlpha(SurfaceControl sc, float alpha) {
90         return this;
91     }
92 
93     @Override
setInputWindowInfo(SurfaceControl sc, InputWindowHandle handle)94     public SurfaceControl.Transaction setInputWindowInfo(SurfaceControl sc,
95             InputWindowHandle handle) {
96         return this;
97     }
98 
99     @Override
setGeometry(SurfaceControl sc, Rect sourceCrop, Rect destFrame, @Surface.Rotation int orientation)100     public SurfaceControl.Transaction setGeometry(SurfaceControl sc, Rect sourceCrop,
101             Rect destFrame, @Surface.Rotation int orientation) {
102         return this;
103     }
104 
105     @Override
setMatrix(SurfaceControl sc, float dsdx, float dtdx, float dtdy, float dsdy)106     public SurfaceControl.Transaction setMatrix(SurfaceControl sc,
107             float dsdx, float dtdx, float dtdy, float dsdy) {
108         return this;
109     }
110 
111     @Override
setMatrix(SurfaceControl sc, Matrix matrix, float[] float9)112     public SurfaceControl.Transaction setMatrix(SurfaceControl sc, Matrix matrix, float[] float9) {
113         return this;
114     }
115 
116     @Override
setColorTransform(SurfaceControl sc, float[] matrix, float[] translation)117     public SurfaceControl.Transaction setColorTransform(SurfaceControl sc, float[] matrix,
118             float[] translation) {
119         return this;
120     }
121 
122     @Override
setWindowCrop(SurfaceControl sc, Rect crop)123     public SurfaceControl.Transaction setWindowCrop(SurfaceControl sc, Rect crop) {
124         return this;
125     }
126 
127     @Override
setWindowCrop(SurfaceControl sc, int width, int height)128     public SurfaceControl.Transaction setWindowCrop(SurfaceControl sc, int width, int height) {
129         return this;
130     }
131 
132     @Override
setCornerRadius(SurfaceControl sc, float cornerRadius)133     public SurfaceControl.Transaction setCornerRadius(SurfaceControl sc, float cornerRadius) {
134         return this;
135     }
136 
137     @Override
setLayerStack(SurfaceControl sc, int layerStack)138     public SurfaceControl.Transaction setLayerStack(SurfaceControl sc, int layerStack) {
139         return this;
140     }
141 
142     @Override
deferTransactionUntil(SurfaceControl sc, IBinder handle, long frameNumber)143     public SurfaceControl.Transaction deferTransactionUntil(SurfaceControl sc, IBinder handle,
144             long frameNumber) {
145         return this;
146     }
147 
148     @Override
deferTransactionUntilSurface(SurfaceControl sc, Surface barrierSurface, long frameNumber)149     public SurfaceControl.Transaction deferTransactionUntilSurface(SurfaceControl sc,
150             Surface barrierSurface,
151             long frameNumber) {
152         return this;
153     }
154 
155     @Override
reparentChildren(SurfaceControl sc, IBinder newParentHandle)156     public SurfaceControl.Transaction reparentChildren(SurfaceControl sc, IBinder newParentHandle) {
157         return this;
158     }
159 
160     @Override
reparent(SurfaceControl sc, SurfaceControl newParent)161     public SurfaceControl.Transaction reparent(SurfaceControl sc, SurfaceControl newParent) {
162         return this;
163     }
164 
165     @Override
detachChildren(SurfaceControl sc)166     public SurfaceControl.Transaction detachChildren(SurfaceControl sc) {
167         return this;
168     }
169 
170     @Override
setOverrideScalingMode(SurfaceControl sc, int overrideScalingMode)171     public SurfaceControl.Transaction setOverrideScalingMode(SurfaceControl sc,
172             int overrideScalingMode) {
173         return this;
174     }
175 
176     @Override
setColor(SurfaceControl sc, float[] color)177     public SurfaceControl.Transaction setColor(SurfaceControl sc, float[] color) {
178         return this;
179     }
180 
181     @Override
setGeometryAppliesWithResize(SurfaceControl sc)182     public SurfaceControl.Transaction setGeometryAppliesWithResize(SurfaceControl sc) {
183         return this;
184     }
185 
186     @Override
setSecure(SurfaceControl sc, boolean isSecure)187     public SurfaceControl.Transaction setSecure(SurfaceControl sc, boolean isSecure) {
188         return this;
189     }
190 
191     @Override
setOpaque(SurfaceControl sc, boolean isOpaque)192     public SurfaceControl.Transaction setOpaque(SurfaceControl sc, boolean isOpaque) {
193         return this;
194     }
195 
196     @Override
setDisplaySurface(IBinder displayToken, Surface surface)197     public SurfaceControl.Transaction setDisplaySurface(IBinder displayToken, Surface surface) {
198         return this;
199     }
200 
201     @Override
setDisplayLayerStack(IBinder displayToken, int layerStack)202     public SurfaceControl.Transaction setDisplayLayerStack(IBinder displayToken, int layerStack) {
203         return this;
204     }
205 
206     @Override
setDisplayProjection(IBinder displayToken, int orientation, Rect layerStackRect, Rect displayRect)207     public SurfaceControl.Transaction setDisplayProjection(IBinder displayToken,
208             int orientation, Rect layerStackRect, Rect displayRect) {
209         return this;
210     }
211 
212     @Override
setDisplaySize(IBinder displayToken, int width, int height)213     public SurfaceControl.Transaction setDisplaySize(IBinder displayToken, int width, int height) {
214         return this;
215     }
216 
217     @Override
setAnimationTransaction()218     public SurfaceControl.Transaction setAnimationTransaction() {
219         return this;
220     }
221 
222     @Override
setEarlyWakeup()223     public SurfaceControl.Transaction setEarlyWakeup() {
224         return this;
225     }
226 
227     @Override
setMetadata(SurfaceControl sc, int key, int data)228     public SurfaceControl.Transaction setMetadata(SurfaceControl sc, int key, int data) {
229         return this;
230     }
231 
232     @Override
setMetadata(SurfaceControl sc, int key, Parcel data)233     public SurfaceControl.Transaction setMetadata(SurfaceControl sc, int key, Parcel data) {
234         return this;
235     }
236 
237     @Override
merge(SurfaceControl.Transaction other)238     public SurfaceControl.Transaction merge(SurfaceControl.Transaction other) {
239         return this;
240     }
241 
242     @Override
remove(SurfaceControl sc)243     public SurfaceControl.Transaction remove(SurfaceControl sc) {
244         return this;
245     }
246 }
247