• 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 /**
20   * Listener for dumpstate events.
21   *
22   * <p>When bugreport creation is complete one of {@code onError} or {@code onFinished} is called.
23   *
24   * <p>These methods are synchronous by design in order to make dumpstate's lifecycle simpler
25   * to handle.
26   *
27   * {@hide}
28   */
29 interface IDumpstateListener {
30     /**
31      * Called when there is a progress update.
32      *
33      * @param progress the progress in [0, 100]
34      */
onProgress(int progress)35     void onProgress(int progress);
36 
37     // NOTE: If you add to or change these error codes, please also change the corresponding enums
38     // in system server, in BugreportManager.java.
39 
40     /* Options specified are invalid or incompatible */
41     const int BUGREPORT_ERROR_INVALID_INPUT = 1;
42 
43     /* Bugreport encountered a runtime error */
44     const int BUGREPORT_ERROR_RUNTIME_ERROR = 2;
45 
46     /* User denied consent to share the bugreport with the specified app */
47     const int BUGREPORT_ERROR_USER_DENIED_CONSENT = 3;
48 
49     /* The request to get user consent timed out */
50     const int BUGREPORT_ERROR_USER_CONSENT_TIMED_OUT = 4;
51 
52     /* There is currently a bugreport running. The caller should try again later. */
53     const int BUGREPORT_ERROR_ANOTHER_REPORT_IN_PROGRESS = 5;
54 
55     /**
56      * Called on an error condition with one of the error codes listed above.
57      */
onError(int errorCode)58     void onError(int errorCode);
59 
60     /**
61      * Called when taking bugreport finishes successfully.
62      */
onFinished()63     void onFinished();
64 
65     // TODO(b/111441001): Remove old methods when not used anymore.
onProgressUpdated(int progress)66     void onProgressUpdated(int progress);
onMaxProgressUpdated(int maxProgress)67     void onMaxProgressUpdated(int maxProgress);
68 
69     /**
70      * Called after every section is complete.
71      *
72      * @param  name          section name
73      * @param  status        values from status_t
74      *                       {@code OK} section completed successfully
75      *                       {@code TIMEOUT} dump timed out
76      *                       {@code != OK} error
77      * @param  size          size in bytes, may be invalid if status != OK
78      * @param  durationMs    duration in ms
79      */
onSectionComplete(@tf8InCpp String name, int status, int size, int durationMs)80     void onSectionComplete(@utf8InCpp String name, int status, int size, int durationMs);
81 }
82