• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.graphics.Rect;
22 import android.os.Parcelable;
23 import android.os.RemoteException;
24 
25 import com.android.internal.util.DataClass;
26 
27 import java.util.ArrayList;
28 
29 /** @hide */
30 @DataClass(genToString = true, genGetters = true)
31 public class ScrollCaptureResponse implements Parcelable {
32 
33     /** Developer-facing human readable description of the result. */
34     @NonNull
35     private String mDescription = "";
36 
37     // Remaining fields are non-null when isConnected() == true
38 
39     /** The active connection for a successful result. */
40     @Nullable
41     @DataClass.MaySetToNull
42     private IScrollCaptureConnection mConnection = null;
43 
44     /** The bounds of the window within the display */
45     @Nullable
46     private Rect mWindowBounds = null;
47 
48     /** The bounds of the scrolling content, in window space. */
49     @Nullable
50     private Rect mBoundsInWindow = null;
51 
52     /** The current window title. */
53     @Nullable
54     private String mWindowTitle = null;
55 
56     /** Carries additional logging and debugging information when enabled. */
57     @NonNull
58     @DataClass.PluralOf("message")
59     private ArrayList<String> mMessages = new ArrayList<>();
60 
61     /** Whether an active connection is present. */
isConnected()62     public boolean isConnected() {
63         return mConnection != null && mConnection.asBinder().isBinderAlive();
64     }
65 
66     /** Closes a connection returned with this response. */
close()67     public void close() {
68         if (mConnection != null) {
69             try {
70                 mConnection.close();
71             } catch (RemoteException e) {
72                 // Ignore
73             }
74             mConnection = null;
75         }
76     }
77 
78 
79 
80     // Code below generated by codegen v1.0.22.
81     //
82     // DO NOT MODIFY!
83     // CHECKSTYLE:OFF Generated code
84     //
85     // To regenerate run:
86     // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/view/ScrollCaptureResponse.java
87     //
88     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
89     //   Settings > Editor > Code Style > Formatter Control
90     //@formatter:off
91 
92 
93     @DataClass.Generated.Member
ScrollCaptureResponse( @onNull String description, @Nullable IScrollCaptureConnection connection, @Nullable Rect windowBounds, @Nullable Rect boundsInWindow, @Nullable String windowTitle, @NonNull ArrayList<String> messages)94     /* package-private */ ScrollCaptureResponse(
95             @NonNull String description,
96             @Nullable IScrollCaptureConnection connection,
97             @Nullable Rect windowBounds,
98             @Nullable Rect boundsInWindow,
99             @Nullable String windowTitle,
100             @NonNull ArrayList<String> messages) {
101         this.mDescription = description;
102         com.android.internal.util.AnnotationValidations.validate(
103                 NonNull.class, null, mDescription);
104         this.mConnection = connection;
105         this.mWindowBounds = windowBounds;
106         this.mBoundsInWindow = boundsInWindow;
107         this.mWindowTitle = windowTitle;
108         this.mMessages = messages;
109         com.android.internal.util.AnnotationValidations.validate(
110                 NonNull.class, null, mMessages);
111 
112         // onConstructed(); // You can define this method to get a callback
113     }
114 
115     /**
116      * Developer-facing human readable description of the result.
117      */
118     @DataClass.Generated.Member
getDescription()119     public @NonNull String getDescription() {
120         return mDescription;
121     }
122 
123     /**
124      * The active connection for a successful result.
125      */
126     @DataClass.Generated.Member
getConnection()127     public @Nullable IScrollCaptureConnection getConnection() {
128         return mConnection;
129     }
130 
131     /**
132      * The bounds of the window within the display
133      */
134     @DataClass.Generated.Member
getWindowBounds()135     public @Nullable Rect getWindowBounds() {
136         return mWindowBounds;
137     }
138 
139     /**
140      * The bounds of the scrolling content, in window space.
141      */
142     @DataClass.Generated.Member
getBoundsInWindow()143     public @Nullable Rect getBoundsInWindow() {
144         return mBoundsInWindow;
145     }
146 
147     /**
148      * The current window title.
149      */
150     @DataClass.Generated.Member
getWindowTitle()151     public @Nullable String getWindowTitle() {
152         return mWindowTitle;
153     }
154 
155     /**
156      * Carries additional logging and debugging information when enabled.
157      */
158     @DataClass.Generated.Member
getMessages()159     public @NonNull ArrayList<String> getMessages() {
160         return mMessages;
161     }
162 
163     @Override
164     @DataClass.Generated.Member
toString()165     public String toString() {
166         // You can override field toString logic by defining methods like:
167         // String fieldNameToString() { ... }
168 
169         return "ScrollCaptureResponse { " +
170                 "description = " + mDescription + ", " +
171                 "connection = " + mConnection + ", " +
172                 "windowBounds = " + mWindowBounds + ", " +
173                 "boundsInWindow = " + mBoundsInWindow + ", " +
174                 "windowTitle = " + mWindowTitle + ", " +
175                 "messages = " + mMessages +
176         " }";
177     }
178 
179     @Override
180     @DataClass.Generated.Member
writeToParcel(@onNull android.os.Parcel dest, int flags)181     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
182         // You can override field parcelling by defining methods like:
183         // void parcelFieldName(Parcel dest, int flags) { ... }
184 
185         byte flg = 0;
186         if (mConnection != null) flg |= 0x2;
187         if (mWindowBounds != null) flg |= 0x4;
188         if (mBoundsInWindow != null) flg |= 0x8;
189         if (mWindowTitle != null) flg |= 0x10;
190         dest.writeByte(flg);
191         dest.writeString(mDescription);
192         if (mConnection != null) dest.writeStrongInterface(mConnection);
193         if (mWindowBounds != null) dest.writeTypedObject(mWindowBounds, flags);
194         if (mBoundsInWindow != null) dest.writeTypedObject(mBoundsInWindow, flags);
195         if (mWindowTitle != null) dest.writeString(mWindowTitle);
196         dest.writeStringList(mMessages);
197     }
198 
199     @Override
200     @DataClass.Generated.Member
describeContents()201     public int describeContents() { return 0; }
202 
203     /** @hide */
204     @SuppressWarnings({"unchecked", "RedundantCast"})
205     @DataClass.Generated.Member
ScrollCaptureResponse(@onNull android.os.Parcel in)206     protected ScrollCaptureResponse(@NonNull android.os.Parcel in) {
207         // You can override field unparcelling by defining methods like:
208         // static FieldType unparcelFieldName(Parcel in) { ... }
209 
210         byte flg = in.readByte();
211         String description = in.readString();
212         IScrollCaptureConnection connection = (flg & 0x2) == 0 ? null : IScrollCaptureConnection.Stub.asInterface(in.readStrongBinder());
213         Rect windowBounds = (flg & 0x4) == 0 ? null : (Rect) in.readTypedObject(Rect.CREATOR);
214         Rect boundsInWindow = (flg & 0x8) == 0 ? null : (Rect) in.readTypedObject(Rect.CREATOR);
215         String windowTitle = (flg & 0x10) == 0 ? null : in.readString();
216         ArrayList<String> messages = new ArrayList<>();
217         in.readStringList(messages);
218 
219         this.mDescription = description;
220         com.android.internal.util.AnnotationValidations.validate(
221                 NonNull.class, null, mDescription);
222         this.mConnection = connection;
223         this.mWindowBounds = windowBounds;
224         this.mBoundsInWindow = boundsInWindow;
225         this.mWindowTitle = windowTitle;
226         this.mMessages = messages;
227         com.android.internal.util.AnnotationValidations.validate(
228                 NonNull.class, null, mMessages);
229 
230         // onConstructed(); // You can define this method to get a callback
231     }
232 
233     @DataClass.Generated.Member
234     public static final @NonNull Parcelable.Creator<ScrollCaptureResponse> CREATOR
235             = new Parcelable.Creator<ScrollCaptureResponse>() {
236         @Override
237         public ScrollCaptureResponse[] newArray(int size) {
238             return new ScrollCaptureResponse[size];
239         }
240 
241         @Override
242         public ScrollCaptureResponse createFromParcel(@NonNull android.os.Parcel in) {
243             return new ScrollCaptureResponse(in);
244         }
245     };
246 
247     /**
248      * A builder for {@link ScrollCaptureResponse}
249      */
250     @SuppressWarnings("WeakerAccess")
251     @DataClass.Generated.Member
252     public static class Builder {
253 
254         private @NonNull String mDescription;
255         private @Nullable IScrollCaptureConnection mConnection;
256         private @Nullable Rect mWindowBounds;
257         private @Nullable Rect mBoundsInWindow;
258         private @Nullable String mWindowTitle;
259         private @NonNull ArrayList<String> mMessages;
260 
261         private long mBuilderFieldsSet = 0L;
262 
Builder()263         public Builder() {
264         }
265 
266         /**
267          * Developer-facing human readable description of the result.
268          */
269         @DataClass.Generated.Member
setDescription(@onNull String value)270         public @NonNull Builder setDescription(@NonNull String value) {
271             checkNotUsed();
272             mBuilderFieldsSet |= 0x1;
273             mDescription = value;
274             return this;
275         }
276 
277         /**
278          * The active connection for a successful result.
279          */
280         @DataClass.Generated.Member
setConnection(@ullable IScrollCaptureConnection value)281         public @NonNull Builder setConnection(@Nullable IScrollCaptureConnection value) {
282             checkNotUsed();
283             mBuilderFieldsSet |= 0x2;
284             mConnection = value;
285             return this;
286         }
287 
288         /**
289          * The bounds of the window within the display
290          */
291         @DataClass.Generated.Member
setWindowBounds(@onNull Rect value)292         public @NonNull Builder setWindowBounds(@NonNull Rect value) {
293             checkNotUsed();
294             mBuilderFieldsSet |= 0x4;
295             mWindowBounds = value;
296             return this;
297         }
298 
299         /**
300          * The bounds of the scrolling content, in window space.
301          */
302         @DataClass.Generated.Member
setBoundsInWindow(@onNull Rect value)303         public @NonNull Builder setBoundsInWindow(@NonNull Rect value) {
304             checkNotUsed();
305             mBuilderFieldsSet |= 0x8;
306             mBoundsInWindow = value;
307             return this;
308         }
309 
310         /**
311          * The current window title.
312          */
313         @DataClass.Generated.Member
setWindowTitle(@onNull String value)314         public @NonNull Builder setWindowTitle(@NonNull String value) {
315             checkNotUsed();
316             mBuilderFieldsSet |= 0x10;
317             mWindowTitle = value;
318             return this;
319         }
320 
321         /**
322          * Carries additional logging and debugging information when enabled.
323          */
324         @DataClass.Generated.Member
setMessages(@onNull ArrayList<String> value)325         public @NonNull Builder setMessages(@NonNull ArrayList<String> value) {
326             checkNotUsed();
327             mBuilderFieldsSet |= 0x20;
328             mMessages = value;
329             return this;
330         }
331 
332         /** @see #setMessages */
333         @DataClass.Generated.Member
addMessage(@onNull String value)334         public @NonNull Builder addMessage(@NonNull String value) {
335             if (mMessages == null) setMessages(new ArrayList<>());
336             mMessages.add(value);
337             return this;
338         }
339 
340         /** Builds the instance. This builder should not be touched after calling this! */
build()341         public @NonNull ScrollCaptureResponse build() {
342             checkNotUsed();
343             mBuilderFieldsSet |= 0x40; // Mark builder used
344 
345             if ((mBuilderFieldsSet & 0x1) == 0) {
346                 mDescription = "";
347             }
348             if ((mBuilderFieldsSet & 0x2) == 0) {
349                 mConnection = null;
350             }
351             if ((mBuilderFieldsSet & 0x4) == 0) {
352                 mWindowBounds = null;
353             }
354             if ((mBuilderFieldsSet & 0x8) == 0) {
355                 mBoundsInWindow = null;
356             }
357             if ((mBuilderFieldsSet & 0x10) == 0) {
358                 mWindowTitle = null;
359             }
360             if ((mBuilderFieldsSet & 0x20) == 0) {
361                 mMessages = new ArrayList<>();
362             }
363             ScrollCaptureResponse o = new ScrollCaptureResponse(
364                     mDescription,
365                     mConnection,
366                     mWindowBounds,
367                     mBoundsInWindow,
368                     mWindowTitle,
369                     mMessages);
370             return o;
371         }
372 
checkNotUsed()373         private void checkNotUsed() {
374             if ((mBuilderFieldsSet & 0x40) != 0) {
375                 throw new IllegalStateException(
376                         "This Builder should not be reused. Use a new Builder instance instead");
377             }
378         }
379     }
380 
381     @DataClass.Generated(
382             time = 1614833185795L,
383             codegenVersion = "1.0.22",
384             sourceFile = "frameworks/base/core/java/android/view/ScrollCaptureResponse.java",
385             inputSignatures = "private @android.annotation.NonNull java.lang.String mDescription\nprivate @android.annotation.Nullable @com.android.internal.util.DataClass.MaySetToNull android.view.IScrollCaptureConnection mConnection\nprivate @android.annotation.Nullable android.graphics.Rect mWindowBounds\nprivate @android.annotation.Nullable android.graphics.Rect mBoundsInWindow\nprivate @android.annotation.Nullable java.lang.String mWindowTitle\nprivate @android.annotation.NonNull @com.android.internal.util.DataClass.PluralOf(\"message\") java.util.ArrayList<java.lang.String> mMessages\npublic  boolean isConnected()\npublic  void close()\nclass ScrollCaptureResponse extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genGetters=true)")
386     @Deprecated
__metadata()387     private void __metadata() {}
388 
389 
390     //@formatter:on
391     // End of generated code
392 
393 }
394