Felipe Leme | 75876a2 | 2016-10-27 16:31:27 -0700 | [diff] [blame] | 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_DUMPSTATE_H_ |
| 18 | #define ANDROID_OS_DUMPSTATE_H_ |
| 19 | |
| 20 | #include <mutex> |
| 21 | #include <vector> |
| 22 | |
Nandana Dutt | 05290ad | 2019-01-04 15:48:09 +0000 | [diff] [blame] | 23 | #include <android-base/unique_fd.h> |
Felipe Leme | 75876a2 | 2016-10-27 16:31:27 -0700 | [diff] [blame] | 24 | #include <binder/BinderService.h> |
| 25 | |
| 26 | #include "android/os/BnDumpstate.h" |
| 27 | #include "dumpstate.h" |
| 28 | |
| 29 | namespace android { |
| 30 | namespace os { |
| 31 | |
| 32 | class DumpstateService : public BinderService<DumpstateService>, public BnDumpstate { |
| 33 | public: |
| 34 | DumpstateService(); |
| 35 | |
| 36 | static status_t Start(); |
| 37 | static char const* getServiceName(); |
| 38 | |
| 39 | status_t dump(int fd, const Vector<String16>& args) override; |
Felipe Leme | 75876a2 | 2016-10-27 16:31:27 -0700 | [diff] [blame] | 40 | |
Kean Mariotti | 306633e | 2022-09-05 16:30:47 +0000 | [diff] [blame] | 41 | binder::Status preDumpUiData(const std::string& callingPackage) override; |
| 42 | |
Nandana Dutt | 5c91420 | 2019-01-16 17:45:18 +0000 | [diff] [blame] | 43 | binder::Status startBugreport(int32_t calling_uid, const std::string& calling_package, |
Jiyong Park | 3b25ae1 | 2019-11-25 11:06:16 +0900 | [diff] [blame] | 44 | android::base::unique_fd bugreport_fd, |
| 45 | android::base::unique_fd screenshot_fd, int bugreport_mode, |
Kean Mariotti | 306633e | 2022-09-05 16:30:47 +0000 | [diff] [blame] | 46 | int bugreport_flags, const sp<IDumpstateListener>& listener, |
Kholoud Mohamed | def4e43 | 2024-05-15 12:47:46 +0000 | [diff] [blame] | 47 | bool is_screenshot_requested, bool skip_user_consent) override; |
Nandana Dutt | cccbb5f | 2018-09-27 09:23:36 +0100 | [diff] [blame] | 48 | |
Gavin Corkery | a44686c | 2022-11-23 18:16:51 +0000 | [diff] [blame] | 49 | binder::Status retrieveBugreport(int32_t calling_uid, |
| 50 | const std::string& calling_package, |
Kholoud Mohamed | 7c3fb7c | 2023-10-18 12:56:22 +0000 | [diff] [blame] | 51 | int32_t user_id, |
Gavin Corkery | a44686c | 2022-11-23 18:16:51 +0000 | [diff] [blame] | 52 | android::base::unique_fd bugreport_fd, |
| 53 | const std::string& bugreport_file, |
Kholoud Mohamed | 7c3fb7c | 2023-10-18 12:56:22 +0000 | [diff] [blame] | 54 | const bool keep_bugreport_on_retrieval, |
Kholoud Mohamed | def4e43 | 2024-05-15 12:47:46 +0000 | [diff] [blame] | 55 | const bool skip_user_consent, |
Gavin Corkery | a44686c | 2022-11-23 18:16:51 +0000 | [diff] [blame] | 56 | const sp<IDumpstateListener>& listener) |
| 57 | override; |
| 58 | |
Kean Mariotti | 306633e | 2022-09-05 16:30:47 +0000 | [diff] [blame] | 59 | binder::Status cancelBugreport(int32_t calling_uid, |
| 60 | const std::string& calling_package) override; |
Nandana Dutt | cc4ead8 | 2019-01-23 08:29:23 +0000 | [diff] [blame] | 61 | |
Felipe Leme | 75876a2 | 2016-10-27 16:31:27 -0700 | [diff] [blame] | 62 | private: |
Nandana Dutt | d973766 | 2019-01-29 15:59:38 +0000 | [diff] [blame] | 63 | // Dumpstate object which contains all the bugreporting logic. |
| 64 | // Note that dumpstate is a oneshot service, so this object is meant to be used at most for |
| 65 | // one bugreport. |
| 66 | // This service does not own this object. |
| 67 | Dumpstate* ds_; |
Hunter Knepshield | 00c2a75 | 2020-12-21 18:08:17 -0800 | [diff] [blame] | 68 | int32_t calling_uid_; |
| 69 | std::string calling_package_; |
Felipe Leme | 75876a2 | 2016-10-27 16:31:27 -0700 | [diff] [blame] | 70 | std::mutex lock_; |
| 71 | }; |
| 72 | |
| 73 | } // namespace os |
| 74 | } // namespace android |
| 75 | |
| 76 | #endif // ANDROID_OS_DUMPSTATE_H_ |