blob: 6dc0225f02cb8340c329b732ea7cd5b085a54517 [file] [log] [blame]
Felipe Leme75876a22016-10-27 16:31:27 -07001/**
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 Dutt05290ad2019-01-04 15:48:09 +000023#include <android-base/unique_fd.h>
Felipe Leme75876a22016-10-27 16:31:27 -070024#include <binder/BinderService.h>
25
26#include "android/os/BnDumpstate.h"
27#include "dumpstate.h"
28
29namespace android {
30namespace os {
31
32class 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 Leme75876a22016-10-27 16:31:27 -070040
Nandana Dutt5c914202019-01-16 17:45:18 +000041 binder::Status startBugreport(int32_t calling_uid, const std::string& calling_package,
Jiyong Park3b25ae12019-11-25 11:06:16 +090042 android::base::unique_fd bugreport_fd,
43 android::base::unique_fd screenshot_fd, int bugreport_mode,
Nandana Dutt05290ad2019-01-04 15:48:09 +000044 const sp<IDumpstateListener>& listener) override;
Nandana Duttcccbb5f2018-09-27 09:23:36 +010045
Nandana Duttcc4ead82019-01-23 08:29:23 +000046 // No-op
47 binder::Status cancelBugreport();
48
Felipe Leme75876a22016-10-27 16:31:27 -070049 private:
Nandana Duttd9737662019-01-29 15:59:38 +000050 // Dumpstate object which contains all the bugreporting logic.
51 // Note that dumpstate is a oneshot service, so this object is meant to be used at most for
52 // one bugreport.
53 // This service does not own this object.
54 Dumpstate* ds_;
Felipe Leme75876a22016-10-27 16:31:27 -070055 std::mutex lock_;
56};
57
58} // namespace os
59} // namespace android
60
61#endif // ANDROID_OS_DUMPSTATE_H_