1 /**
2  * Copyright (c) 2018, 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.IIncidentAuthListener;
20 import android.os.IncidentManager;
21 
22 /**
23  * Helper service for incidentd and dumpstated to provide user feedback
24  * and authorization for bug and inicdent reports to be taken.
25  *
26  * @hide
27  */
28 interface IIncidentCompanion {
29     /**
30      * Request an authorization for an incident or bug report.
31      * // TODO(b/111441001): Add the permission
32      * <p>
33      * This function requires the ___ permission.
34      *
35      * @param callingUid The original application that requested the report.  This function
36      *      returns via the callback whether the application should be trusted.  It is up
37      *      to the caller to actually implement the restriction to take or not take
38      *      the incident or bug report.
39      * @param receiverClass The class that will be the eventual broacast receiver for the
40      *      INCIDENT_REPORT_READY message. Used as part of the id in incidentd.
41      * @param reportId The incident report ID.  Incidentd should call with this parameter, but
42      *     everyone else should pass null or empty string.
43      * @param flags FLAG_CONFIRMATION_DIALOG (0x1) - to show this as a dialog.  Otherwise
44      *      a dialog will be shown as a notification.
45      * @param callback Interface to receive results.  The results may not come back for
46      *      a long (user's choice) time, or ever (if they never respond to the notification).
47      *      Authorization requests are not persisted across reboot.  It is up to the calling
48      *      service to request another authorization after reboot if they still would like
49      *      to send their report.
50      */
authorizeReport(int callingUid, String callingPackage, String receiverClass, String reportId, int flags, IIncidentAuthListener callback)51     oneway void authorizeReport(int callingUid, String callingPackage,
52             String receiverClass, String reportId,
53             int flags, IIncidentAuthListener callback);
54 
55     /**
56      * Cancel an authorization.
57      */
cancelAuthorization(IIncidentAuthListener callback)58     oneway void cancelAuthorization(IIncidentAuthListener callback);
59 
60     /**
61      * Send the report ready broadcast on behalf of incidentd.
62      */
sendReportReadyBroadcast(String pkg, String cls)63     oneway void sendReportReadyBroadcast(String pkg, String cls);
64 
65     /**
66      * Return the list of pending approvals.
67      */
getPendingReports()68     List<String> getPendingReports();
69 
70     /**
71      * The user has authorized the report to be shared.
72      *
73      * @param uri the report.
74      */
approveReport(String uri)75     void approveReport(String uri);
76 
77     /**
78      * The user has denied the report from being shared.
79      *
80      * @param uri the report.
81      */
denyReport(String uri)82     void denyReport(String uri);
83 
84     /**
85      * List the incident reports for the given ComponentName.  The receiver
86      * must be for a package inside the caller.
87      */
getIncidentReportList(String pkg, String cls)88     List<String> getIncidentReportList(String pkg, String cls);
89 
90     /**
91      * Get the IncidentReport object.
92      */
getIncidentReport(String pkg, String cls, String id)93     IncidentManager.IncidentReport getIncidentReport(String pkg, String cls, String id);
94 
95     /**
96      * Signal that the client is done with this incident report and it can be deleted.
97      */
deleteIncidentReports(String pkg, String cls, String id)98     void deleteIncidentReports(String pkg, String cls, String id);
99 
100     /**
101      * Signal that the client is done with all incident reports from this package.
102      * Especially useful for testing.
103      */
deleteAllIncidentReports(String pkg)104     void deleteAllIncidentReports(String pkg);
105 }
106