Ray Essick | 3938dc6 | 2016-11-01 08:56:56 -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_IMEDIAANALYTICSSERVICE_H |
| 18 | #define ANDROID_IMEDIAANALYTICSSERVICE_H |
| 19 | |
| 20 | #include <utils/String8.h> |
| 21 | #include <binder/IInterface.h> |
| 22 | #include <binder/Parcel.h> |
| 23 | |
| 24 | #include <sys/types.h> |
| 25 | #include <utils/Errors.h> |
| 26 | #include <utils/Log.h> |
| 27 | #include <utils/RefBase.h> |
| 28 | #include <utils/List.h> |
| 29 | |
| 30 | #include <binder/IServiceManager.h> |
| 31 | |
Ray Essick | f27e987 | 2019-12-07 06:28:46 -0800 | [diff] [blame] | 32 | #include <media/MediaMetricsItem.h> |
Ray Essick | 3938dc6 | 2016-11-01 08:56:56 -0700 | [diff] [blame] | 33 | |
| 34 | namespace android { |
| 35 | |
Ray Essick | f27e987 | 2019-12-07 06:28:46 -0800 | [diff] [blame] | 36 | class IMediaMetricsService: public IInterface |
Ray Essick | 3938dc6 | 2016-11-01 08:56:56 -0700 | [diff] [blame] | 37 | { |
| 38 | public: |
Ray Essick | f27e987 | 2019-12-07 06:28:46 -0800 | [diff] [blame] | 39 | DECLARE_META_INTERFACE(MediaMetricsService); |
Ray Essick | 3938dc6 | 2016-11-01 08:56:56 -0700 | [diff] [blame] | 40 | |
Andy Hung | c89c8dc | 2019-10-16 17:48:21 -0700 | [diff] [blame] | 41 | /** |
Andy Hung | c89c8dc | 2019-10-16 17:48:21 -0700 | [diff] [blame] | 42 | * Submits the indicated record to the mediaanalytics service, where |
| 43 | * it will be merged (if appropriate) with incomplete records that |
| 44 | * share the same key and sessionID. |
| 45 | * |
| 46 | * \param item the item to submit. |
Andy Hung | a87e69c | 2019-10-18 10:07:40 -0700 | [diff] [blame] | 47 | * \return status which is negative if an error is detected (some errors |
| 48 | may be silent and return 0 - success). |
Andy Hung | c89c8dc | 2019-10-16 17:48:21 -0700 | [diff] [blame] | 49 | */ |
Ray Essick | f27e987 | 2019-12-07 06:28:46 -0800 | [diff] [blame] | 50 | virtual status_t submit(mediametrics::Item *item) = 0; |
Andy Hung | 1efc9c6 | 2019-12-03 13:43:33 -0800 | [diff] [blame] | 51 | |
| 52 | virtual status_t submitBuffer(const char *buffer, size_t length) = 0; |
Ray Essick | 3938dc6 | 2016-11-01 08:56:56 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | // ---------------------------------------------------------------------------- |
| 56 | |
Ray Essick | f27e987 | 2019-12-07 06:28:46 -0800 | [diff] [blame] | 57 | class BnMediaMetricsService: public BnInterface<IMediaMetricsService> |
Ray Essick | 3938dc6 | 2016-11-01 08:56:56 -0700 | [diff] [blame] | 58 | { |
| 59 | public: |
Andy Hung | c89c8dc | 2019-10-16 17:48:21 -0700 | [diff] [blame] | 60 | status_t onTransact(uint32_t code, |
| 61 | const Parcel& data, |
| 62 | Parcel* reply, |
| 63 | uint32_t flags = 0) override; |
Andy Hung | a87e69c | 2019-10-18 10:07:40 -0700 | [diff] [blame] | 64 | |
| 65 | protected: |
| 66 | // Internal call where release is true if the service is to delete the item. |
| 67 | virtual status_t submitInternal( |
Ray Essick | f27e987 | 2019-12-07 06:28:46 -0800 | [diff] [blame] | 68 | mediametrics::Item *item, bool release) = 0; |
Ray Essick | 3938dc6 | 2016-11-01 08:56:56 -0700 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | }; // namespace android |
| 72 | |
| 73 | #endif // ANDROID_IMEDIASTATISTICSSERVICE_H |