Use events instead of method invokes for window state updates and others
This commit is contained in:
parent
53c2fac5d4
commit
a40fe51654
14 changed files with 152 additions and 133 deletions
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
|
||||
#include "android/service/platform_service.h"
|
||||
#include "android/service/platform_api_stub.h"
|
||||
#include "anbox/rpc/channel.h"
|
||||
|
||||
#include "anbox_rpc.pb.h"
|
||||
|
|
@ -39,8 +38,8 @@ status_t PlatformService::boot_finished() {
|
|||
return OK;
|
||||
}
|
||||
|
||||
void PlatformService::unpack_window_state(anbox::protobuf::bridge::WindowStateUpdate_WindowState *window, const Parcel &data) {
|
||||
window->set_has_surface(data.readByte() != 0);
|
||||
anbox::PlatformApiStub::WindowStateUpdate::Window PlatformService::unpack_window_state(const Parcel &data) {
|
||||
bool has_surface = data.readByte() != 0;
|
||||
|
||||
String8 package_name(data.readString16());
|
||||
|
||||
|
|
@ -51,38 +50,45 @@ void PlatformService::unpack_window_state(anbox::protobuf::bridge::WindowStateUp
|
|||
auto task_id = data.readInt32();
|
||||
auto stack_id = data.readInt32();
|
||||
|
||||
window->set_package_name(package_name.string());
|
||||
window->set_frame_left(frame_left);
|
||||
window->set_frame_top(frame_top);
|
||||
window->set_frame_right(frame_right);
|
||||
window->set_frame_bottom(frame_bottom);
|
||||
window->set_task_id(task_id);
|
||||
window->set_stack_id(stack_id);
|
||||
ALOGI(" Window: package=%s frame={%d,%d,%d,%d} task=%d stack=%d",
|
||||
package_name.string(), frame_left, frame_top, frame_right, frame_bottom,
|
||||
task_id, stack_id);
|
||||
|
||||
return anbox::PlatformApiStub::WindowStateUpdate::Window{
|
||||
-1, // Display id will be added by the caller
|
||||
has_surface,
|
||||
package_name.string(),
|
||||
{frame_left, frame_top, frame_right, frame_bottom},
|
||||
task_id,
|
||||
stack_id,
|
||||
};
|
||||
}
|
||||
|
||||
status_t PlatformService::update_window_state(const Parcel &data) {
|
||||
anbox::protobuf::bridge::WindowStateUpdate window_state;
|
||||
anbox::PlatformApiStub::WindowStateUpdate state;
|
||||
|
||||
ALOGI("Udated windows:");
|
||||
const auto num_displays = data.readInt32();
|
||||
for (auto n = 0; n < num_displays; n++) {
|
||||
const auto display_id = data.readInt32();
|
||||
const auto num_windows = data.readInt32();
|
||||
ALOGI(" Display: id=%d", display_id);
|
||||
|
||||
for (auto m = 0; m < num_windows; m++) {
|
||||
auto window = window_state.add_windows();
|
||||
window->set_display_id(display_id);
|
||||
unpack_window_state(window, data);
|
||||
auto window = unpack_window_state(data);
|
||||
window.display_id = display_id;
|
||||
state.updated_windows.push_back(window);
|
||||
}
|
||||
}
|
||||
|
||||
ALOGI("Removed windows:");
|
||||
const auto num_removed_windows = data.readInt32();
|
||||
for (auto n = 0; n < num_removed_windows; n++) {
|
||||
auto window = window_state.add_removed_windows();
|
||||
window->set_display_id(0);
|
||||
unpack_window_state(window, data);
|
||||
auto window = unpack_window_state(data);
|
||||
state.removed_windows.push_back(window);
|
||||
}
|
||||
|
||||
platform_api_stub_->update_window_state(window_state);
|
||||
platform_api_stub_->update_window_state(state);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue