• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2016, 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.os;
18 
19 import android.os.IDumpstateListener;
20 
21 /**
22  * Binder interface for the currently running dumpstate process.
23  * {@hide}
24  */
25 interface IDumpstate {
26 
27     // NOTE: If you add to or change these modes, please also change the corresponding enums
28     // in system server, in BugreportParams.java.
29 
30     // These modes encapsulate a set of run time options for generating bugreports.
31     // Takes a bugreport without user interference.
32     const int BUGREPORT_MODE_FULL = 0;
33 
34     // Interactive bugreport, i.e. triggered by the user.
35     const int BUGREPORT_MODE_INTERACTIVE = 1;
36 
37     // Remote bugreport triggered by DevicePolicyManager, for e.g.
38     const int BUGREPORT_MODE_REMOTE = 2;
39 
40     // Bugreport triggered on a wear device.
41     const int BUGREPORT_MODE_WEAR = 3;
42 
43     // Bugreport limited to only telephony info.
44     const int BUGREPORT_MODE_TELEPHONY = 4;
45 
46     // Bugreport limited to only wifi info.
47     const int BUGREPORT_MODE_WIFI = 5;
48 
49     // Default mode.
50     const int BUGREPORT_MODE_DEFAULT = 6;
51 
52     // Use pre-dumped data.
53     const int BUGREPORT_FLAG_USE_PREDUMPED_UI_DATA = 0x1;
54 
55     // Defer user consent.
56     const int BUGREPORT_FLAG_DEFER_CONSENT = 0x2;
57 
58     /**
59      * Speculatively pre-dumps UI data for a bugreport request that might come later.
60      *
61      * <p>Triggers the dump of certain critical UI data, e.g. traces stored in short
62      * ring buffers that might get lost by the time the actual bugreport is requested.
63      *
64      * <p>{@code startBugreport} will then pick the pre-dumped data if:
65      * - {@link BUGREPORT_FLAG_USE_PREDUMPED_UI_DATA} is specified.
66      * - {@code preDumpUiData} and {@code startBugreport} were called by the same UID.
67      *
68      * @param callingPackage package of the original application that requested the report.
69      */
preDumpUiData(@tf8InCpp String callingPackage)70     void preDumpUiData(@utf8InCpp String callingPackage);
71 
72     /**
73      * Starts a bugreport in the background.
74      *
75      * <p>Shows the user a dialog to get consent for sharing the bugreport with the calling
76      * application. If they deny {@link IDumpstateListener#onError} will be called. If they
77      * consent and bugreport generation is successful artifacts will be copied to the given fds and
78      * {@link IDumpstateListener#onFinished} will be called. If there
79      * are errors in bugreport generation {@link IDumpstateListener#onError} will be called.
80      *
81      * @param callingUid UID of the original application that requested the report.
82      * @param callingPackage package of the original application that requested the report.
83      * @param bugreportFd the file to which the zipped bugreport should be written
84      * @param screenshotFd the file to which screenshot should be written
85      * @param bugreportMode the mode that specifies other run time options; must be one of above
86      * @param bugreportFlags flags to customize the bugreport generation
87      * @param listener callback for updates; optional
88      * @param isScreenshotRequested indicates screenshot is requested or not
89      */
startBugreport(int callingUid, @utf8InCpp String callingPackage, FileDescriptor bugreportFd, FileDescriptor screenshotFd, int bugreportMode, int bugreportFlags, IDumpstateListener listener, boolean isScreenshotRequested)90     void startBugreport(int callingUid, @utf8InCpp String callingPackage,
91                         FileDescriptor bugreportFd, FileDescriptor screenshotFd,
92                         int bugreportMode, int bugreportFlags,
93                         IDumpstateListener listener, boolean isScreenshotRequested);
94 
95     /**
96      * Cancels the bugreport currently in progress.
97      *
98      * <p>The caller must match the original caller of {@link #startBugreport} in order for the
99      * report to actually be cancelled. A {@link SecurityException} is reported if a mismatch is
100      * detected.
101      *
102      * @param callingUid UID of the original application that requested the cancellation.
103      * @param callingPackage package of the original application that requested the cancellation.
104      */
cancelBugreport(int callingUid, @utf8InCpp String callingPackage)105     void cancelBugreport(int callingUid, @utf8InCpp String callingPackage);
106 
107     /**
108      * Retrieves a previously generated bugreport.
109      *
110      * <p>The caller must have previously generated a bugreport using
111      * {@link #startBugreport} with the {@link BUGREPORT_FLAG_DEFER_CONSENT}
112      * flag set.
113      *
114      * @param callingUid UID of the original application that requested the report.
115      * @param callingPackage package of the original application that requested the report.
116      * @param bugreportFd the file to which the zipped bugreport should be written
117      * @param bugreportFile the path of the bugreport file
118      * @param listener callback for updates; optional
119      */
retrieveBugreport(int callingUid, @utf8InCpp String callingPackage, FileDescriptor bugreportFd, @utf8InCpp String bugreportFile, IDumpstateListener listener)120     void retrieveBugreport(int callingUid, @utf8InCpp String callingPackage,
121                            FileDescriptor bugreportFd,
122                            @utf8InCpp String bugreportFile,
123                            IDumpstateListener listener);
124 }
125