| Christopher Wiley | 16daa08 | 2015-10-01 17:18:40 -0700 | [diff] [blame] | 1 | // | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 2 | // Copyright (C) 2016 The Android Open Source Project | 
| Christopher Wiley | 16daa08 | 2015-10-01 17:18:40 -0700 | [diff] [blame] | 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 |  | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 17 | #ifndef UPDATE_ENGINE_CLIENT_LIBRARY_CLIENT_BINDER_H_ | 
|  | 18 | #define UPDATE_ENGINE_CLIENT_LIBRARY_CLIENT_BINDER_H_ | 
| Christopher Wiley | 16daa08 | 2015-10-01 17:18:40 -0700 | [diff] [blame] | 19 |  | 
|  | 20 | #include <cstdint> | 
|  | 21 | #include <memory> | 
|  | 22 | #include <string> | 
|  | 23 |  | 
|  | 24 | #include <base/macros.h> | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 25 | #include <utils/StrongPointer.h> | 
|  | 26 |  | 
|  | 27 | #include "android/brillo/IUpdateEngine.h" | 
| Christopher Wiley | 16daa08 | 2015-10-01 17:18:40 -0700 | [diff] [blame] | 28 |  | 
| Christopher Wiley | 16daa08 | 2015-10-01 17:18:40 -0700 | [diff] [blame] | 29 | #include "update_engine/client_library/include/update_engine/client.h" | 
| Christopher Wiley | 16daa08 | 2015-10-01 17:18:40 -0700 | [diff] [blame] | 30 |  | 
|  | 31 | namespace update_engine { | 
|  | 32 | namespace internal { | 
|  | 33 |  | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 34 | class BinderUpdateEngineClient : public UpdateEngineClient { | 
| Christopher Wiley | 16daa08 | 2015-10-01 17:18:40 -0700 | [diff] [blame] | 35 | public: | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 36 | BinderUpdateEngineClient() = default; | 
| Casey Dahlin | 1944141 | 2016-01-07 14:56:40 -0800 | [diff] [blame] | 37 | bool Init(); | 
|  | 38 |  | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 39 | virtual ~BinderUpdateEngineClient() = default; | 
| Christopher Wiley | 16daa08 | 2015-10-01 17:18:40 -0700 | [diff] [blame] | 40 |  | 
|  | 41 | bool AttemptUpdate(const std::string& app_version, | 
|  | 42 | const std::string& omaha_url, | 
|  | 43 | bool at_user_request) override; | 
|  | 44 |  | 
|  | 45 | bool GetStatus(int64_t* out_last_checked_time, | 
|  | 46 | double* out_progress, | 
|  | 47 | UpdateStatus* out_update_status, | 
|  | 48 | std::string* out_new_version, | 
| Casey Dahlin | 1944141 | 2016-01-07 14:56:40 -0800 | [diff] [blame] | 49 | int64_t* out_new_size) const override; | 
| Christopher Wiley | 16daa08 | 2015-10-01 17:18:40 -0700 | [diff] [blame] | 50 |  | 
| Casey Dahlin | ef36113 | 2015-12-17 13:02:37 -0800 | [diff] [blame] | 51 | bool SetUpdateOverCellularPermission(bool allowed) override; | 
| Casey Dahlin | 1944141 | 2016-01-07 14:56:40 -0800 | [diff] [blame] | 52 | bool GetUpdateOverCellularPermission(bool* allowed) const override; | 
| Casey Dahlin | ef36113 | 2015-12-17 13:02:37 -0800 | [diff] [blame] | 53 |  | 
|  | 54 | bool SetP2PUpdatePermission(bool enabled) override; | 
| Casey Dahlin | 1944141 | 2016-01-07 14:56:40 -0800 | [diff] [blame] | 55 | bool GetP2PUpdatePermission(bool* enabled) const override; | 
| Casey Dahlin | ef36113 | 2015-12-17 13:02:37 -0800 | [diff] [blame] | 56 |  | 
|  | 57 | bool Rollback(bool powerwash) override; | 
|  | 58 |  | 
| Casey Dahlin | 1944141 | 2016-01-07 14:56:40 -0800 | [diff] [blame] | 59 | bool GetRollbackPartition(std::string* rollback_partition) const override; | 
| Casey Dahlin | ef36113 | 2015-12-17 13:02:37 -0800 | [diff] [blame] | 60 |  | 
|  | 61 | void RebootIfNeeded() override; | 
|  | 62 |  | 
| Casey Dahlin | 1944141 | 2016-01-07 14:56:40 -0800 | [diff] [blame] | 63 | bool GetPrevVersion(std::string* prev_version) const override; | 
| Casey Dahlin | ef36113 | 2015-12-17 13:02:37 -0800 | [diff] [blame] | 64 |  | 
| Casey Dahlin | e844c1a | 2015-12-16 14:30:58 -0800 | [diff] [blame] | 65 | bool ResetStatus() override; | 
|  | 66 |  | 
| Casey Dahlin | 87ab88e | 2015-12-16 17:58:05 -0800 | [diff] [blame] | 67 | bool SetTargetChannel(const std::string& target_channel, | 
|  | 68 | bool allow_powerwash) override; | 
| Christopher Wiley | 16daa08 | 2015-10-01 17:18:40 -0700 | [diff] [blame] | 69 |  | 
| Casey Dahlin | 1944141 | 2016-01-07 14:56:40 -0800 | [diff] [blame] | 70 | bool GetTargetChannel(std::string* out_channel) const override; | 
| Christopher Wiley | 16daa08 | 2015-10-01 17:18:40 -0700 | [diff] [blame] | 71 |  | 
| Casey Dahlin | 1944141 | 2016-01-07 14:56:40 -0800 | [diff] [blame] | 72 | bool GetChannel(std::string* out_channel) const override; | 
| Christopher Wiley | 16daa08 | 2015-10-01 17:18:40 -0700 | [diff] [blame] | 73 |  | 
| Casey Dahlin | 97c8705 | 2016-01-06 14:33:55 -0800 | [diff] [blame] | 74 | void RegisterStatusUpdateHandler(StatusUpdateHandler* handler) override; | 
|  | 75 |  | 
| Christopher Wiley | 16daa08 | 2015-10-01 17:18:40 -0700 | [diff] [blame] | 76 | private: | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 77 | android::sp<android::brillo::IUpdateEngine> service_; | 
| Christopher Wiley | 16daa08 | 2015-10-01 17:18:40 -0700 | [diff] [blame] | 78 |  | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 79 | DISALLOW_COPY_AND_ASSIGN(BinderUpdateEngineClient); | 
|  | 80 | };  // class BinderUpdateEngineClient | 
| Christopher Wiley | 16daa08 | 2015-10-01 17:18:40 -0700 | [diff] [blame] | 81 |  | 
|  | 82 | }  // namespace internal | 
|  | 83 | }  // namespace update_engine | 
|  | 84 |  | 
| Casey Dahlin | a93cd53 | 2016-01-14 16:55:11 -0800 | [diff] [blame] | 85 | #endif  // UPDATE_ENGINE_CLIENT_LIBRARY_CLIENT_BINDER_H_ |