• 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     // Bugreport taken for onboarding related flows.
53     const int BUGREPORT_MODE_ONBOARDING = 7;
54 
55     // Use pre-dumped data.
56     const int BUGREPORT_FLAG_USE_PREDUMPED_UI_DATA = 0x1;
57 
58     // Defer user consent.
59     const int BUGREPORT_FLAG_DEFER_CONSENT = 0x2;
60 
61     // Keep bugreport stored after retrieval.
62     const int BUGREPORT_FLAG_KEEP_BUGREPORT_ON_RETRIEVAL = 0x4;
63 
64     /**
65      * Speculatively pre-dumps UI data for a bugreport request that might come later.
66      *
67      * <p>Triggers the dump of certain critical UI data, e.g. traces stored in short
68      * ring buffers that might get lost by the time the actual bugreport is requested.
69      *
70      * <p>{@code startBugreport} will then pick the pre-dumped data if:
71      * - {@link BUGREPORT_FLAG_USE_PREDUMPED_UI_DATA} is specified.
72      * - {@code preDumpUiData} and {@code startBugreport} were called by the same UID.
73      *
74      * @param callingPackage package of the original application that requested the report.
75      */
preDumpUiData(@tf8InCpp String callingPackage)76     void preDumpUiData(@utf8InCpp String callingPackage);
77 
78     /**
79      * Starts a bugreport in the background.
80      *
81      * <p>Shows the user a dialog to get consent for sharing the bugreport with the calling
82      * application. If they deny {@link IDumpstateListener#onError} will be called. If they
83      * consent and bugreport generation is successful artifacts will be copied to the given fds and
84      * {@link IDumpstateListener#onFinished} will be called. If there
85      * are errors in bugreport generation {@link IDumpstateListener#onError} will be called.
86      *
87      * @param callingUid UID of the original application that requested the report.
88      * @param callingPackage package of the original application that requested the report.
89      * @param bugreportFd the file to which the zipped bugreport should be written
90      * @param screenshotFd the file to which screenshot should be written
91      * @param bugreportMode the mode that specifies other run time options; must be one of above
92      * @param bugreportFlags flags to customize the bugreport generation
93      * @param listener callback for updates; optional
94      * @param isScreenshotRequested indicates screenshot is requested or not
95      */
startBugreport(int callingUid, @utf8InCpp String callingPackage, FileDescriptor bugreportFd, FileDescriptor screenshotFd, int bugreportMode, int bugreportFlags, IDumpstateListener listener, boolean isScreenshotRequested, boolean skipUserConsent)96     void startBugreport(int callingUid, @utf8InCpp String callingPackage,
97                         FileDescriptor bugreportFd, FileDescriptor screenshotFd,
98                         int bugreportMode, int bugreportFlags,
99                         IDumpstateListener listener, boolean isScreenshotRequested,
100                         boolean skipUserConsent);
101 
102     /**
103      * Cancels the bugreport currently in progress.
104      *
105      * <p>The caller must match the original caller of {@link #startBugreport} in order for the
106      * report to actually be cancelled. A {@link SecurityException} is reported if a mismatch is
107      * detected.
108      *
109      * @param callingUid UID of the original application that requested the cancellation.
110      * @param callingPackage package of the original application that requested the cancellation.
111      */
cancelBugreport(int callingUid, @utf8InCpp String callingPackage)112     void cancelBugreport(int callingUid, @utf8InCpp String callingPackage);
113 
114     /**
115      * Retrieves a previously generated bugreport.
116      *
117      * <p>The caller must have previously generated a bugreport using
118      * {@link #startBugreport} with the {@link BUGREPORT_FLAG_DEFER_CONSENT}
119      * flag set.
120      *
121      * @param callingUid UID of the original application that requested the report.
122      * @param callingPackage package of the original application that requested the report.
123      * @param userId user Id of the original package that requested the report.
124      * @param bugreportFd the file to which the zipped bugreport should be written
125      * @param bugreportFile the path of the bugreport file
126      * @param keepBugreportOnRetrieval boolean to indicate if the bugreport should be kept in the
127      * platform after it has been retrieved by the caller.
128      * @param listener callback for updates; optional
129      */
retrieveBugreport(int callingUid, @utf8InCpp String callingPackage, int userId, FileDescriptor bugreportFd, @utf8InCpp String bugreportFile, boolean keepBugreportOnRetrieval, boolean skipUserConsent, IDumpstateListener listener)130     void retrieveBugreport(int callingUid, @utf8InCpp String callingPackage, int userId,
131                            FileDescriptor bugreportFd,
132                            @utf8InCpp String bugreportFile,
133                            boolean keepBugreportOnRetrieval,
134                            boolean skipUserConsent,
135                            IDumpstateListener listener);
136 }
137