• 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 #ifndef ANDROID_OS_INCIDENT_REPORT_ARGS_H
18 #define ANDROID_OS_INCIDENT_REPORT_ARGS_H
19 
20 #include <binder/IServiceManager.h>
21 #include <binder/Parcel.h>
22 #include <binder/Parcelable.h>
23 #include <utils/String16.h>
24 
25 #include <set>
26 #include <vector>
27 
28 namespace android {
29 namespace os {
30 
31 using namespace std;
32 
33 // DESTINATION enum value, sync with frameworks/base/core/proto/android/privacy.proto,
34 // incident/incident_report.h and IncidentReportArgs.java
35 const uint8_t PRIVACY_POLICY_LOCAL = 0;
36 const uint8_t PRIVACY_POLICY_EXPLICIT = 100;
37 const uint8_t PRIVACY_POLICY_AUTOMATIC = 200;
38 const uint8_t PRIVACY_POLICY_UNSET = 255;
39 
40 
41 class IncidentReportArgs : public Parcelable {
42 public:
43     IncidentReportArgs();
44     IncidentReportArgs(const IncidentReportArgs& that);
45     virtual ~IncidentReportArgs();
46 
47     virtual status_t writeToParcel(Parcel* out) const;
48     virtual status_t readFromParcel(const Parcel* in);
49 
50     void setAll(bool all);
51     void setPrivacyPolicy(int privacyPolicy);
52     void addSection(int section);
53     void setReceiverPkg(const string& pkg);
54     void setReceiverCls(const string& cls);
55     void addHeader(const vector<uint8_t>& headerProto);
56     void setGzip(bool gzip);
57 
all()58     inline bool all() const { return mAll; }
59     bool containsSection(int section, bool specific) const;
getPrivacyPolicy()60     inline int getPrivacyPolicy() const { return mPrivacyPolicy; }
sections()61     inline const set<int>& sections() const { return mSections; }
receiverPkg()62     inline const string& receiverPkg() const { return mReceiverPkg; }
receiverCls()63     inline const string& receiverCls() const { return mReceiverCls; }
headers()64     inline const vector<vector<uint8_t>>& headers() const { return mHeaders; }
gzip()65     inline bool gzip() const {return mGzip; }
66 
67     void merge(const IncidentReportArgs& that);
68 
69 private:
70     set<int> mSections;
71     vector<vector<uint8_t>> mHeaders;
72     bool mAll;
73     int mPrivacyPolicy;
74     string mReceiverPkg;
75     string mReceiverCls;
76     bool mGzip;
77 };
78 
79 }
80 }
81 
82 #endif // ANDROID_OS_INCIDENT_REPORT_ARGS_H
83