Giter VIP home page Giter VIP logo

tizen_interop's Introduction

tizen_interop

pub package

Provides Dart bindings for Tizen native APIs, powered by ffigen.

Usage

To use this package, add ffi and tizen_interop as dependencies in your pubspec.yaml file.

dependencies:
  ffi: ^2.0.1
  tizen_interop: ^0.3.0

Then, import package:ffi/ffi.dart and package:tizen_interop/[TIZEN_VERSION]/tizen.dart in your Dart code.

import 'package:ffi/ffi.dart';
import 'package:tizen_interop/5.5/tizen.dart';

Examples

// Getting a string value from the Native API.
// Prefer using `arena` to allocate memory because it frees the memory
// automatically when the `using` block ends.
String appName = using((Arena arena) {
  Pointer<Pointer<Char>> ppStr = arena();
  if (tizen.app_get_name(ppStr) == 0) {
    // The memory allocated by the Native API must be freed by the caller.
    arena.using(ppStr.value, calloc.free);
    return ppStr.value.toDartString();
  }
  return 'unknown';
});

// Passing a string value to the Native API.
// The memory allocated by the `toNativeChar` method must be freed by
// the caller. The `arena` allocator will free it automatically.
using((Arena arena) {
  Pointer<Char> pKey =
      'tizen_interop_test_key_for_int'.toNativeChar(allocator: arena);
  tizen.preference_set_int(pKey, 100);
});

// Getting an integer value from the Native API.
int preferenceValue = using((Arena arena) {
  Pointer<Char> pKey =
      'tizen_interop_test_key_for_int'.toNativeChar(allocator: arena);
  Pointer<Int> pValue = arena();
  if (tizen.preference_get_int(pKey, pValue) == 0) {
    return pValue.value;
  }
  return 0;
});

// Getting a struct value from the Native API.
int freeMemory = using((Arena arena) {
  Pointer<runtime_memory_info_s> pMemInfo = arena();
  if (tizen.runtime_info_get_system_memory_info(pMemInfo) == 0) {
    return pMemInfo.ref.free;
  }
  return 0;
});

// Both sync and async callbacks are supported as long as they are called on
// the same thread.
tizen.storage_foreach_device_supported(
    Pointer.fromFunction(_storageDevice, false), nullptr);

// Callbacks that are called outside the current thread will cause the error:
// "Cannot invoke native callback outside an isolate".
// See the tizen_interop_callbacks package for a solution.

Supported APIs

This package provides bindings for the following APIs of the Tizen IoT-Headed (or Common for Tizen 8.0 and above) profile.

Note: UI and WebView related APIs are not included.

Category Sub category Tizen 5.5 Tizen 6.0 Tizen 6.5 Tizen 7.0 Tizen 8.0
Account Account Manager
FIDO Client
Account Manager
OAuth 2.0
Sync Manager
Application Framework Application
Alarm
App Common
App Control
App Control URI
Event
Internationalization
Job scheduler
Preference
Resource Manager
Application Manager
Attach panel
Badge
Bundle
Cion
Component Based Application
Component Manager
Data Control
Message Port
Notification
Notification EX
Package Manager
RPC Port
Service Application
Shortcut
Widget
Base Common Error
Utils
Content Download
MIME Type
Media Content
Context Activity Recognition
Contextual History
Contextual Trigger
Gesture Recognition
Location Geofence Manager
Location Manager
Maps Service
Machine Learning Pipeline
Service
Single
Trainer
Messaging Email
Messages
Push
Multimedia Audio I/O
Camera
Image Util
Media Codec
Media Controller
Media Demuxer
Media Muxer
Media Streamer
Media Tool
Media Vision
Media Editor
Metadata Editor
Metadata Extractor
Player
Radio
Recorder
Screen Mirroring
Sound Manager
Sound Pool
StreamRecorder
Thumbnail Util
Tone Player
Video Util
WAV Player
WebRTC
Network Application Service Platform
Bluetooth
Connection
DNSSD
HTTP
Intelligent Network Monitoring
IoTCon
MTP
SSDP
Smart Traffic Control
Smartcard
SoftAP
User Awareness
VPN Service
Wi-Fi
Wi-Fi Direct
Security CSR
Device Certificate Manager
Device Policy Manager
Key Manager
Privacy Privilege Manager
Privilege Info
YACA
Social Calendar
Contacts
Phonenumber utils
System Device
Diagnostics
Dlog
Feedback
Media key
Monitor
Peripheral IO
Runtime information
Sensor
Storage
System Information
System Settings
T-trace
USB Host
Update Control
Telephony Telephony Information
UI Clipboard History Manager
DALi
EFL
External Output Manager
Minicontrol
TBM Surface
Tizen WS Shell
UI View Manager
UIX Autofill
Input Method
Input Method Manager
Multi assistant
STT
STT Engine
Sticker
TTS
TTS Engine
Voice control
Voice control elementary
Voice control engine
Voice control manager

tizen_interop's People

Contributors

jsuya avatar swift-kim avatar wiertel avatar wonyoungchoi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tizen_interop's Issues

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to lookup symbol 'TizenInteropCallbacksRegisterSendPort': undefined symbol: TizenInteropCallbacksRegisterSendPort

I am using the
tizen_interop: ^0.2.6
tizen_interop_callbacks: ^0.1.0

E/flutter ( 4668): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to lookup symbol 'TizenInteropCallbacksRegisterSendPort': undefined symbol: TizenInteropCallbacksRegisterSendPort
E/flutter ( 4668): #0 DynamicLibrary.lookup (dart:ffi-patch/ffi_dynamic_library_patch.dart:33:70)
E/flutter ( 4668): #1 new TizenInteropCallbacks._internal (package:tizen_interop_callbacks/tizen_interop_callbacks.dart:105:10)
E/flutter ( 4668): #2 new TizenInteropCallbacks (package:tizen_interop_callbacks/tizen_interop_callbacks.dart:96:41)

static void appconnBwResultCallback(int deviceId, Pointer<Int8> sid, Pointer<AppconnBwResult> result) {

}

static void appconnIperfTest({required TizenInteropCallbacks callbacks, required int deviceId, required String sid, required int targetPort, required int testDurationSec, required int maxBwTest, required int blocking}) {
Pointer _sid = sid.toNativeUtf8().cast();
final callback = callbacks.register('appconnBwResultCallback', Pointer.fromFunction(appconnBwResultCallback));
_appconnIperfTest(deviceId, _sid, targetPort, testDurationSec, maxBwTest, blocking, callback.interopCallback);
}

How to interact with a TV

I have read the readme and looked at the example but I am not sure how to control a Samsung smart TV running TizenOS

Missing parcel apis

Parcel API has been supported since Tizen 6.5.
However, it is not supported in tizen_interop even in version 7.0.
Would it be possible to add the parcel.h APIs? They are included in the platform/core/base/bundle repository.

Can't use async callback

Due to the thread problem, asynchronous callbacks are currently unavailable.

example of a problem situation

  Pointer<NativeFunction<device_changed_cb>> _batteryChangedCallback =
      Pointer.fromFunction<device_changed_cb>(_batteryChanged);

   int ret = tizen.device_add_callback(
        device_callback_e.DEVICE_CALLBACK_BATTERY_CHARGING,
        _batteryChangedCallback,
        Pointer.fromAddress(0));
    if (ret != device_error_e.DEVICE_ERROR_NONE) {
      throw Exception('Failed to register battery callback');
    }
  }

  static void _batteryChanged(
      int type, Pointer<Void> value, Pointer<Void> userData) {
    print('batteryChanged');
  }

If the charging status is changed, following error will be raised.
error: Cannot invoke native callback outside an isolate.

sample code

https://github.com/WonyoungChoi/tizen_interop_async_test

repro with sample code

  1. git clone https://github.com/WonyoungChoi/tizen_interop_async_test
  2. cd tizen_interop_async_test/example
  3. flutter_tizen run (on emulator)
  4. open "Control Panel" of the emulator and choose "Batter".
  5. Change "Charger" state to "on "or "off".
  6. Application will be terminated with following error:
[E] ../../third_party/dart/runtime/vm/runtime_entry.cc: 3621: error: Cannot invoke native callback outside an isolate.
version=2.16.1 (stable) (Tue Feb 8 12:02:33 2022 +0100) on "linux_ia32"
pid=29992, thread=29992, isolate_group=(nil)((nil)), isolate=(nil)((nil))
isolate_instructions=0, vm_instructions=a65d5620
  pc 0xa672441e fp 0xbfbe4c38 /proc/self/fd/24/lib/libflutter_engine.so+0x9c641e
[E]   pc 0xa6a15cd1 fp 0xbfbe4c58 /proc/self/fd/24/lib/libflutter_engine.so+0xcb7cd1
  pc 0xa65d57d6 fp 0xbfbe4c88 /proc/self/fd/24/lib/libflutter_engine.so+0x8777d6
  pc 0xa67730be fp 0xbfbe4cc8 /proc/self/fd/24/lib/libflutter_engine.so+0xa150be
  pc 0xa67730f0 fp 0xbfbe4ce8 /proc/self/fd/24/lib/libflutter_engine.so+0xa150f0

reason

The above code is executed on the Flutter UI thread, but most of the tizen native callbacks come from the main-loop of the main thread. Dart does not support calls between isolates.
See more: dart-lang/sdk#37022

solution?

Static analysis fails on pub.dev

https://pub.dev/packages/tizen_interop/score

image

Unhandled exception:
DocumentationTooBigException: Reached 2462056448 bytes in the output directory.
#0      PubResourceProvider._aboutToWriteBytes (package:pub_dartdoc/src/pub_hook[...]
#1      _File.writeAsBytesSync (package:pub_dartdoc/src/pub_hooks.dart:149:15)
#2      DartdocFileWriter.write (package:dartdoc/src/dartdoc.dart:100:10)
#3      GeneratorBackendBase.write (package:dartdoc/src/generator/generator_back[...]
#4      GeneratorBackendBase.generateTopLevelProperty (package:dartdoc/src/gener[...]
#5      GeneratorBackendBase.generateTopLevelConstant (package:dartdoc/src/gener[...]
#6      GeneratorFrontEnd._generateDocs (package:dartdoc/src/generator/generator[...]
#7      GeneratorFrontEnd.generate (package:dartdoc/src/generator/generator_fron[...]
#8      Dartdoc.generateDocsBase (package:dartdoc/src/dartdoc.dart:211:21)

Maybe this package has too many lines to be analyzed by pub.dev.

  • No dartdoc is generated.
  • Cannot pass static analysis. This affects the pub score.
  • The package cannot be marked "Dart 3 ready".

I opened an issue here: dart-lang/pana#1205

Upgrade Dart version

one of external package is required Dart 2.17.1 but current flutter-tizen dart version is Dart version 2.17.0,

Because flextizen depends on youtube_data_api >=1.0.0+1 which requires SDK version >=2.17.1 <3.0.0, version solving failed.

please let me know how to upgrade Dart SDK..

Provides examples

  • Re-implement existing plugins with tizen_interop to verify the functionality and usability.
  • Add an example app.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.