break;
+ case static_cast<int>(MethodId::AsyncResultForPkgUpgrade):
+ {
+ char* param1_raw = nullptr;
+ rpc_port_parcel_read_string(p, ¶m1_raw);
+ std::string param1(param1_raw);
+ free(param1_raw);
+ int param2;
+ rpc_port_parcel_read_int32(p, ¶m2);
+ ptr->OnAsyncResultForPkgUpgrade(param1, param2);
+
+ }
+ break;
+
+
default:
_E("Unknown command(%d)", cmd);
throw InvalidIOException();
}
}
+
+void PkgSignal::AsyncResultForPkgUpgrade(std::string signal, int progress) {
+ rpc_port_parcel_h p;
+ rpc_port_parcel_create(&p);
+ std::unique_ptr<std::remove_pointer<rpc_port_parcel_h>::type,
+ decltype(rpc_port_parcel_destroy)*> p_auto(p, rpc_port_parcel_destroy);
+ rpc_port_parcel_header_h header_;
+ rpc_port_parcel_get_header(p, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ int seq_num_ = -1;
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+ rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::AsyncResultForPkgUpgrade));
+ rpc_port_parcel_write_string(p, signal.c_str());
+ rpc_port_parcel_write_int32(p, progress);
+
+
+ // Send
+ bundle* b = bundle_create();
+ std::unique_ptr<bundle, decltype(bundle_free)*> b_auto(b, bundle_free);
+ if (GetBundleFromParcel(p, b) == nullptr) {
+ _E("Failed to make bundle from parcel");
+ throw InvalidIOException();
+ }
+
+ std::lock_guard<std::recursive_mutex> lock(mutex_);
+ int ret = event_publish_app_event(GetEventName().c_str(), b);
+ if (ret != EVENT_ERROR_NONE) {
+ _E("Failed to publish event. result(%d)", ret);
+ throw InvalidIOException();
+ }
+}
} // namespace group
} // namespace PkgSignal
} // namespace rpc_port