Signed-off-by: hmz007 <hmz007@gmail.com> Change-Id: Ib87fdbe7a0be7dc961af3500fe9ea4589a127f9f
134 lines
5.3 KiB
C++
134 lines
5.3 KiB
C++
//
|
|
// Copyright (C) 2015 The Android Open Source Project
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
//
|
|
|
|
#ifndef UPDATE_ENGINE_CLIENT_LIBRARY_INCLUDE_UPDATE_ENGINE_CLIENT_H_
|
|
#define UPDATE_ENGINE_CLIENT_LIBRARY_INCLUDE_UPDATE_ENGINE_CLIENT_H_
|
|
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "update_engine/status_update_handler.h"
|
|
#include "update_engine/update_status.h"
|
|
|
|
namespace update_engine {
|
|
|
|
class UpdateEngineClient {
|
|
public:
|
|
static std::unique_ptr<UpdateEngineClient> CreateInstance();
|
|
|
|
virtual ~UpdateEngineClient() = default;
|
|
|
|
// Force the update_engine to attempt an update.
|
|
// |app_version|
|
|
// Attempt to update to this version. An empty string indicates that
|
|
// update engine should pick the most recent image on the current channel.
|
|
// |omaha_url|
|
|
// Force update_engine to look for updates from the given server. Passing
|
|
// empty indicates update_engine should get this parameter from its
|
|
// config. Note that update_engine will ignore this parameter in
|
|
// production mode to avoid pulling untrusted updates.
|
|
// |at_user_request|
|
|
// This update was directly requested by the user.
|
|
virtual bool AttemptUpdate(const std::string& app_version,
|
|
const std::string& omaha_url,
|
|
bool at_user_request) = 0;
|
|
|
|
// Request the update_engine to install a list of DLC modules.
|
|
// |omaha_url|
|
|
// Force update_engine to look for updates from the given server. Passing
|
|
// empty indicates update_engine should use its default value. Note that
|
|
// update_engine will ignore this parameter in production mode to avoid
|
|
// pulling untrusted updates.
|
|
// |dlc_ids|
|
|
// A list of DLC module IDs.
|
|
virtual bool AttemptInstall(const std::string& omaha_url,
|
|
const std::vector<std::string>& dlc_ids) = 0;
|
|
|
|
// Same as above but return the entire struct instead.
|
|
virtual bool GetStatus(UpdateEngineStatus* out_status) const = 0;
|
|
|
|
// Sets the DLC as active or inactive. When set to active, the ping metadata
|
|
// for the DLC is updated accordingly. When set to inactive, the metadata
|
|
// for the DLC is deleted.
|
|
virtual bool SetDlcActiveValue(bool is_active, const std::string& dlc_id) = 0;
|
|
|
|
// Getter and setter for the cohort hint.
|
|
virtual bool SetCohortHint(const std::string& cohort_hint) = 0;
|
|
virtual bool GetCohortHint(std::string* cohort_hint) const = 0;
|
|
|
|
// Getter and setter for the updates over cellular connections.
|
|
virtual bool SetUpdateOverCellularPermission(bool allowed) = 0;
|
|
virtual bool GetUpdateOverCellularPermission(bool* allowed) const = 0;
|
|
|
|
// Getter and setter for the updates from P2P permission.
|
|
virtual bool SetP2PUpdatePermission(bool enabled) = 0;
|
|
virtual bool GetP2PUpdatePermission(bool* enabled) const = 0;
|
|
|
|
// Attempt a rollback. Set 'powerwash' to reset the device while rolling
|
|
// back.
|
|
virtual bool Rollback(bool powerwash) = 0;
|
|
|
|
// Get the rollback partition if available. Gives empty string if not.
|
|
virtual bool GetRollbackPartition(std::string* rollback_partition) const = 0;
|
|
|
|
// Reboot the system if needed.
|
|
virtual void RebootIfNeeded() = 0;
|
|
|
|
// Get the previous version
|
|
virtual bool GetPrevVersion(std::string* prev_version) const = 0;
|
|
|
|
// Resets the status of the Update Engine
|
|
virtual bool ResetStatus() = 0;
|
|
|
|
// Changes the current channel of the device to the target channel.
|
|
virtual bool SetTargetChannel(const std::string& target_channel,
|
|
bool allow_powerwash) = 0;
|
|
|
|
// Get the channel the device will switch to on reboot.
|
|
virtual bool GetTargetChannel(std::string* out_channel) const = 0;
|
|
|
|
// Get the channel the device is currently on.
|
|
virtual bool GetChannel(std::string* out_channel) const = 0;
|
|
|
|
// Handle status updates. The handler must exist until the client is
|
|
// destroyed or UnregisterStatusUpdateHandler is called for it. Its IPCError
|
|
// method will be called if the handler could not be registered. Otherwise
|
|
// its HandleStatusUpdate method will be called every time update_engine's
|
|
// status changes. Will always report the status on registration to prevent
|
|
// race conditions.
|
|
virtual bool RegisterStatusUpdateHandler(StatusUpdateHandler* handler) = 0;
|
|
|
|
// Unregister a status update handler
|
|
virtual bool UnregisterStatusUpdateHandler(StatusUpdateHandler* handler) = 0;
|
|
|
|
// Get the last UpdateAttempt error code.
|
|
virtual bool GetLastAttemptError(int32_t* last_attempt_error) const = 0;
|
|
|
|
protected:
|
|
// Use CreateInstance().
|
|
UpdateEngineClient() = default;
|
|
|
|
private:
|
|
UpdateEngineClient(const UpdateEngineClient&) = delete;
|
|
void operator=(const UpdateEngineClient&) = delete;
|
|
}; // class UpdateEngineClient
|
|
|
|
} // namespace update_engine
|
|
|
|
#endif // UPDATE_ENGINE_CLIENT_LIBRARY_INCLUDE_UPDATE_ENGINE_CLIENT_H_
|