Introduction to Basic Service Kit

Basic Service Kit provides basic capabilities for application developers, from pasteboard read/write, file upload/download, file compression, file printing, inter-process/inter-thread communication, to device and application account management.

When to Use

Among the various use cases, Basic Services Kit is typically used in the following:

  • Pasteboard read/write

    • Intra-device copy and paste: For example, copy a piece of text in application A and paste it to another application.
    • Cross-device copy and paste: For example, copy a piece of text in a browser on device A and paste it to a notes application on device B.
  • File upload and download

    • Upload and download in the foreground: usually involves small data volume and real-time feedback. Examples: send social media posts (such as images and short videos), share files with friends, and save images to the local device.
    • Upload and download in the background: usually involves large data volume and resumable transfers. Examples: cloud-device data synchronization and movie download.
  • Inter-process/Inter-thread communication

    • Inter-process communication: For example, an ExtensionAbility sends events to the main process.
    • Inter-thread communication: For example, after processing a network request, the worker thread transfers the event back to the UI main thread.

Capability Scope

Depending on different use cases, this Kit provides the following capabilities:

  • Data file processing

    • Pasteboard: provides the copy and paste support. You can use the provided APIs to operate pasteboard content of the plain text, HTML, URI, pixel map, and other types.
    • Compression: provides APIs for file compression and decompression.
    • Print: provides APIs for basic print operations, for example, transferring files for printing and setting printing parameters.
    • Upload and download: provides basic upload, download, and background transmission agent capabilities.
  • Inter-process/Inter-thread communication

    • Common event: provides inter-process communication capabilities, including the capabilities to publish, subscribe to, and unsubscribe from common events. For details about the development guide, see Introduction to Common Events.
    • Emitter: provides intra-thread communication capabilities, including the capabilities to publish, subscribe to, and unsubscribe from custom events. For details about the development guide, see Using Emitter for Inter-Thread Communication.
  • Device management

    • Device information: provides APIs for querying product information, such as the device type, device brand, product series, and product version.
    • Data item settings: provides APIs for setting data items, such as airplane mode and explore by touch.
    • Battery information: provides APIs for querying the battery information.
    • Power management: provides system power management capabilities, such as querying the screen status.
    • Running lock: provides APIs for creating, querying, holding, and releasing running locks.
    • Thermal management: provides thermal management capabilities, such as thermal level query.
    • USB management: provides USB device management functions, including USB device list query, bulk data transfer, control transfer, and permission control. For details about the development guide, see USB Service Development Overview.
  • Others:

Relationship with Other Kits

  • ArkTS Kit: Multithreaded concurrency (TaskPool and Worker) in ArkTS Kit needs to use Emitter in this Kit for inter-thread communication.

  • Ability Kit: Common events in this Kit are required for inter-process communication in Ability Kit.

  • Core File Kit: Core File Kit provides file access and management capabilities. You use Core File Kit for application file access, file sharing, and data backup and restore, and use this Kit to implement file compression, file upload and download, and file printing.