• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2019, 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 #pragma once
18 
19 #include <binder/Parcel.h>
20 #include <binder/Parcelable.h>
21 #include <utils/String16.h>
22 
23 #include <set>
24 #include <vector>
25 
26 namespace android {
27 namespace os {
28 
29 class IncidentManager : public virtual RefBase {
30 public:
31     class IncidentReport : public Parcelable {
32     public:
33         IncidentReport();
34         virtual ~IncidentReport();
35 
36         virtual status_t writeToParcel(Parcel* out) const;
37         virtual status_t readFromParcel(const Parcel* in);
38 
setTimestampNs(int64_t val)39         void setTimestampNs(int64_t val) { mTimestampNs = val; }
getTimestampNs()40         int64_t getTimestampNs() const { return mTimestampNs; }
getTimestampMs()41         int64_t getTimestampMs() const { return mTimestampNs / 1000000; }
42 
setPrivacyPolicy(int32_t val)43         void setPrivacyPolicy(int32_t val) { mPrivacyPolicy = val; }
44         // This was accidentally published as a long in the java api.
getPrivacyPolicy()45         int64_t getPrivacyPolicy() const { return mPrivacyPolicy; }
46         // Dups the fd, so you retain ownership of the original one.  If there is a
47         // previously set fd, closes that, since this object owns its own fd.
48         status_t setFileDescriptor(int fd);
49 
50         // Does not dup the fd, so ownership is passed to this object.  If there is a
51         // previously set fd, closes that, since this object owns its own fd.
52         void takeFileDescriptor(int fd);
53 
54         // Returns the fd, which you don't own.  Call dup if you need a copy.
getFileDescriptor()55         int getFileDescriptor() const { return mFileDescriptor; }
56 
57     private:
58         int64_t mTimestampNs;
59         int32_t mPrivacyPolicy;
60         int mFileDescriptor;
61     };
62 
63 
64 private:
65     // Not implemented for now.
66     IncidentManager();
67     virtual ~IncidentManager();
68 };
69 }
70 }
71 
72