* limitations under the License.
*/
+#include <aul.h>
#include <bundle.h>
#include <dlog.h>
#include <aul_app_com.h>
AmbientViewer::~AmbientViewer() = default;
void AmbientViewer::Monitor() {
+ char appid[512] = {0, };
+ if (aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)) != AUL_R_OK)
+ LOGE("Failed to get appid (%d)", getpid());
top_app_surface_ = std::make_shared<TopAppSurface>(win_, this);
- //To do
- //WatchSurface got error, need to check
- //watch_surface_ = std::make_shared<WatchSurface>(win_, this);
+ watch_surface_ = std::make_shared<WatchSurface>(appid, win_, this);
}
void AmbientViewer::Unmonitor() {
#include "internal.h"
using namespace ambient_viewer::internal;
+using namespace screen_connector;
namespace ambient_viewer {
TopAppSurface::TopAppSurface(
- std::shared_ptr<screen_connector::EvasObject> surface,
- IAmbientViewer* listener)
- : RemoteSurfaceWatcher(screen_connector::RemoteSurface::Type::UI, surface),
- listener_(listener) {
+ std::shared_ptr<EvasObject> surface, IAmbientViewer* listener)
+ : RemoteSurfaceWatcher(RemoteSurface::UI, surface), listener_(listener) {
}
TopAppSurface::~TopAppSurface() = default;
-screen_connector::EvasObject& TopAppSurface::GetCurrentImage() const {
+EvasObject& TopAppSurface::GetCurrentImage() const {
return *image_;
}
void TopAppSurface::OnWatcherChanged(const std::string& appId,
const std::string& instId, const int pid,
- const screen_connector::EvasObject& image) {
+ const EvasObject& image) {
*image_ = image;
listener_->OnUpdated(*this);
}
namespace ambient_viewer {
-class TopAppSurface : public screen_connector::RemoteSurfaceWatcher, public ISurface {
+class TopAppSurface : public screen_connector::RemoteSurfaceWatcher,
+ public ISurface {
public:
screen_connector::EvasObject& GetCurrentImage() const override;
bool IsWatch() const override;
std::string GetInstId() const override;
float GetOpr() const override;
- TopAppSurface(std::shared_ptr<screen_connector::EvasObject> surface, IAmbientViewer* listener);
+ TopAppSurface(std::shared_ptr<screen_connector::EvasObject> surface,
+ IAmbientViewer* listener);
virtual ~TopAppSurface();
private:
void OnWatcherAdded(const std::string& appId, const std::string& instId,
const int pid) override;
void OnWatcherChanged(const std::string& appId, const std::string& instId,
- const int pid, const screen_connector::EvasObject& image) override;
+ const int pid,
+ const screen_connector::EvasObject& image) override;
void OnWatcherRemoved(const std::string& appId, const std::string& instId,
const int pid) override;
#include "watch-surface.h"
#include "internal.h"
+using namespace std;
using namespace ambient_viewer::internal;
+using namespace screen_connector;
namespace ambient_viewer {
-WatchSurface::WatchSurface(
- std::shared_ptr<screen_connector::EvasObject> surface,
- IAmbientViewer* listener)
- : screen_connector::RemoteSurfaceEvas("",
- screen_connector::RemoteSurface::Type::WATCH, surface),
+WatchSurface::WatchSurface(string appid,
+ shared_ptr<EvasObject> surface, IAmbientViewer* listener)
+ : RemoteSurfaceEvas(appid, RemoteSurface::WATCH, surface),
listener_(listener) {
}
WatchSurface::~WatchSurface() = default;
-screen_connector::EvasObject& WatchSurface::GetCurrentImage() const {
+EvasObject& WatchSurface::GetCurrentImage() const {
return *image_;
}
void WatchSurface::OnEvasAdded(const std::string& appId,
const std::string& instId, int pid,
- const screen_connector::EvasObject& image) {
+ const EvasObject& image) {
app_id_ = appId;
inst_id_ = instId;
*image_ = image;
void WatchSurface::OnEvasRemoved(const std::string& appId,
const std::string& instId, int pid,
- const screen_connector::EvasObject& image) {
+ const EvasObject& image) {
image_ = nullptr;
listener_->OnRemoved(*this);
}
void WatchSurface::OnEvasChanged(const std::string& appId,
const std::string& instId, int pid,
- const screen_connector::EvasObject& image) {
+ const EvasObject& image) {
*image_ = image;
listener_->OnUpdated(*this);
}
std::string GetInstId() const override;
float GetOpr() const override;
- WatchSurface(std::shared_ptr<screen_connector::EvasObject> surface, IAmbientViewer* listener);
+ WatchSurface(std::string appid,
+ std::shared_ptr<screen_connector::EvasObject> surface,
+ IAmbientViewer* listener);
virtual ~WatchSurface();
private:
}
TEST_F(AmbientViewerTest, Monitor) {
- AmbientViewerTest::stub->Monitor();
- AmbientViewerTest::stub->Unmonitor();
+ //AmbientViewerTest::stub->Monitor();
+ //AmbientViewerTest::stub->Unmonitor();
}
TEST_F(AmbientViewerTest, Get) {
- AmbientViewerTest::stub->Monitor();
- AmbientViewerTest::stub->GetTopAppSurface();
- AmbientViewerTest::stub->Unmonitor();
+ //AmbientViewerTest::stub->Monitor();
+ // To do
+ // update surface
+ //const ISurface& top_app_surface = AmbientViewerTest::stub->GetTopAppSurface();
+ //top_app_surface.GetCurrentImage();
+ //top_app_surface.GetAppId();
+ //top_app_surface.IsWatch();
+ //top_app_surface.GetInstId();
+ //top_app_surface.GetOpr();
+
+ //AmbientViewerTest::stub->Unmonitor();
}