Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ typedef NotifyCallback = void Function(String, String);

class _NotifyCallback extends _Delegate {
_NotifyCallback(NotifyCallback callback, {bool once = false})
: super(_DelegateId.notifyCallback.id, once, callback);
: super(_DelegateId.notifyCallback.id, once, callback);

@override
Future<void> onReceivedEvent(Parcel parcel) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ abstract class ServiceBase {

class NotifyCallback extends _Delegate {
NotifyCallback(this._port, this.service, {bool once = false})
: super(_DelegateId.notifyCallback.id, once);
: super(_DelegateId.notifyCallback.id, once);

final Port? _port;

Expand Down Expand Up @@ -110,8 +110,8 @@ typedef _MethodHandler = Future<void> Function(ServiceBase, Port, Parcel);

class Message extends StubBase {
Message({required ServiceBuilder serviceBuilder})
: _serviceBuilder = serviceBuilder,
super('Message') {
: _serviceBuilder = serviceBuilder,
super('Message') {
_methodHandlers[_MethodId.register.id] = _onRegisterMethod;
_methodHandlers[_MethodId.unregister.id] = _onUnregisterMethod;
_methodHandlers[_MethodId.send.id] = _onSendMethod;
Expand Down
105 changes: 103 additions & 2 deletions packages/tizen_rpc_port/lib/src/parcel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ class Parcel {

static final Finalizer<rpc_port_parcel_h> _finalizer =
Finalizer<rpc_port_parcel_h>((rpc_port_parcel_h handle) {
tizen.rpc_port_parcel_destroy(handle);
});
tizen.rpc_port_parcel_destroy(handle);
});

/// Gets a byte array backed by the raw data of this parcel.
Uint8List asRaw() {
Expand Down Expand Up @@ -484,4 +484,105 @@ class Parcel {
return ParcelHeader._fromHandle(pHeader.value);
});
}

/// Gets the reader position of this parcel.
int get reader {
return using((Arena arena) {
final Pointer<Uint32> pValue = arena();
final int ret = _rpcPortParcelGetReader(_handle, pValue);
if (ret != 0) {
throw PlatformException(
code: ret.toString(),
message: tizen.get_error_message(ret).toDartString(),
);
}
return pValue.value;
});
}

/// Sets the reader position of this parcel.
set reader(int value) {
RangeError.checkNotNegative(value, 'value');
final int ret = _rpcPortParcelSetReader(_handle, value);
if (ret != 0) {
throw PlatformException(
code: ret.toString(),
message: tizen.get_error_message(ret).toDartString(),
);
}
}
Comment thread
pjh9216 marked this conversation as resolved.

/// Gets the data size of this parcel.
int get dataSize {
return using((Arena arena) {
final Pointer<Uint32> pValue = arena();
final int ret = _rpcPortParcelGetDataSize(_handle, pValue);
if (ret != 0) {
throw PlatformException(
code: ret.toString(),
message: tizen.get_error_message(ret).toDartString(),
);
}
return pValue.value;
});
}

/// Sets the data size of this parcel.
set dataSize(int value) {
RangeError.checkNotNegative(value, 'value');
final int ret = _rpcPortParcelSetDataSize(_handle, value);
if (ret != 0) {
throw PlatformException(
code: ret.toString(),
message: tizen.get_error_message(ret).toDartString(),
);
}
}
Comment thread
pjh9216 marked this conversation as resolved.

/// Reserves the capacity of this parcel.
void reserve(int size) {
RangeError.checkNotNegative(size, 'size');
final int ret = _rpcPortParcelReserve(_handle, size);
if (ret != 0) {
throw PlatformException(
code: ret.toString(),
message: tizen.get_error_message(ret).toDartString(),
);
}
}
Comment thread
pjh9216 marked this conversation as resolved.
}

final DynamicLibrary _libRpcPort = DynamicLibrary.open('librpc-port.so.1');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these APIs have a dependency on the Tizen version? Are they only used in Tizen 11?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, It is dependent on tizen version. Since Tizen 10

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these APIs public open ACR APIs?
If this API is changed in librpc-port.so in Tizen 11.0 or 10.1, platform compatibility cannot be guaranteed to users.
At the very least, there needs to be a way to verify that these APIs are managed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is internal API but It will not be changed to support backward compatibility.
The native APIs is already working in many apps using TIDL.


final int Function(rpc_port_parcel_h, Pointer<Uint32>)
_rpcPortParcelGetReader = _libRpcPort
.lookup<NativeFunction<Int32 Function(rpc_port_parcel_h, Pointer<Uint32>)>>(
'rpc_port_parcel_get_reader',
)
.asFunction();

final int Function(rpc_port_parcel_h, int) _rpcPortParcelSetReader = _libRpcPort
.lookup<NativeFunction<Int32 Function(rpc_port_parcel_h, Uint32)>>(
'rpc_port_parcel_set_reader',
)
.asFunction();

final int Function(rpc_port_parcel_h, Pointer<Uint32>)
_rpcPortParcelGetDataSize = _libRpcPort
.lookup<NativeFunction<Int32 Function(rpc_port_parcel_h, Pointer<Uint32>)>>(
'rpc_port_parcel_get_data_size',
)
.asFunction();

final int Function(rpc_port_parcel_h, int) _rpcPortParcelSetDataSize =
_libRpcPort
.lookup<NativeFunction<Int32 Function(rpc_port_parcel_h, Uint32)>>(
'rpc_port_parcel_set_data_size',
)
.asFunction();

final int Function(rpc_port_parcel_h, int) _rpcPortParcelReserve = _libRpcPort
.lookup<NativeFunction<Int32 Function(rpc_port_parcel_h, Uint32)>>(
'rpc_port_parcel_reserve',
)
.asFunction();
4 changes: 2 additions & 2 deletions packages/tizen_rpc_port/lib/src/proxy_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ abstract class ProxyBase {

_activeConnections.add(_handle.address);
_streamSubscription = _stream!.listen((dynamic data) async {
final Map<String, dynamic> map =
(data as Map<dynamic, dynamic>).cast<String, dynamic>();
final Map<String, dynamic> map = (data as Map<dynamic, dynamic>)
.cast<String, dynamic>();
final int handle = map['handle'] as int;
if (handle != _handle.address) {
return;
Expand Down
4 changes: 2 additions & 2 deletions packages/tizen_rpc_port/lib/src/stub_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ abstract class StubBase {
<String, Object>{'handle': _handle.address},
);
_streamSubscription = stream.listen((dynamic data) async {
final Map<String, dynamic> map =
(data as Map<dynamic, dynamic>).cast<String, dynamic>();
final Map<String, dynamic> map = (data as Map<dynamic, dynamic>)
.cast<String, dynamic>();
final int handle = map['handle'] as int;
if (handle != _handle.address) {
return;
Expand Down
Loading