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