From 0a2ffa44670d79269354d7b5e57c746cfef2305e Mon Sep 17 00:00:00 2001 From: wangdengjia Date: Wed, 9 Feb 2022 19:33:42 +0800 Subject: [PATCH] IssueNo:#I4SAVU Description:add d.ts Sig:interface Feature or Bugfix:Bugfix Binary Source:No Signed-off-by: wangdengjia Change-Id: Ib0c0ff4463531ffb03dda31267721fa0aca69e47 --- api/@ohos.pasteboard.d.ts | 367 ++++++++++++++++++++++++++++++++++++++ api/@ohos.screenlock.d.ts | 124 +++++++++++++ api/@ohos.wallpaper.d.ts | 156 ++++++++++++++++ 3 files changed, 647 insertions(+) create mode 100644 api/@ohos.pasteboard.d.ts create mode 100644 api/@ohos.screenlock.d.ts create mode 100644 api/@ohos.wallpaper.d.ts diff --git a/api/@ohos.pasteboard.d.ts b/api/@ohos.pasteboard.d.ts new file mode 100644 index 0000000000..89240eef88 --- /dev/null +++ b/api/@ohos.pasteboard.d.ts @@ -0,0 +1,367 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +import { Want } from './ability/want'; + +/** + * systemPasteboard + * @sysCap SystemCapability.Miscservices.Pasteboard + * @devices phone, tablet, tv, wearable, car + * @import import pasteboard from '@ohos.pasteboard'; + */ +declare namespace pasteboard { + /** + * Indicates the maximum number of records allowed in a PasteData object. + * @since 7 + */ + const MAX_RECORD_NUM: number; + /** + * Indicates MIME types of HTML text. + * @since 7 + */ + const MIMETYPE_TEXT_HTML: string; + /** + * Indicates MIME types of wants. + * @since 7 + */ + const MIMETYPE_TEXT_WANT: string; + /** + * Indicates MIME types of plain text. + * @since 7 + */ + const MIMETYPE_TEXT_PLAIN: string; + /** + * Indicates MIME types of URIs. + * @since 7 + */ + const MIMETYPE_TEXT_URI: string; + + /** + * Creates a PasteData object for PasteData#MIMETYPE_TEXT_HTML. + * @param htmlText To save the Html text content. + * @return Containing the contents of the clipboard content object. + * @since 7 + */ + function createHtmlData(htmlText: string): PasteData; + + /** + * Creates a PasteData object for PasteData#MIMETYPE_TEXT_WANT. + * @param want To save the want of content. + * @return Containing the contents of the clipboard content object. + * @since 7 + */ + function createWantData(want: Want): PasteData; + + /** + * Creates a PasteData object for PasteData#MIMETYPE_TEXT_PLAIN. + * @param text To save the text of content. + * @return Containing the contents of the clipboard content object. + * @since 6 + */ + function createPlainTextData(text: string): PasteData; + + /** + * Creates a PasteData object for PasteData#MIMETYPE_TEXT_URI. + * @param uri To save the uri of content. + * @return Containing the contents of the clipboard content object. + * @since 7 + */ + function createUriData(uri: string): PasteData; + + /** + * Creates a Record object for PasteData#MIMETYPE_TEXT_HTML. + * @param htmlText To save the Html text content. + * @return The content of a new record + * @since 7 + */ + function createHtmlTextRecord(htmlText: string): PasteDataRecord; + + /** + * Creates a Record object for PasteData#MIMETYPE_TEXT_WANT. + * @param want To save the want of content. + * @return The content of a new record + * @since 7 + */ + function createWantRecord(want: Want): PasteDataRecord; + + /** + * Creates a Record object for PasteData#MIMETYPE_TEXT_PLAIN. + * @param text To save the text of content. + * @return The content of a new record + * @since 7 + */ + function createPlainTextRecord(text: string): PasteDataRecord; + + /** + * Creates a Record object for PasteData#MIMETYPE_TEXT_URI. + * @param uri To save the uri of content. + * @return The content of a new record + * @since 7 + */ + function createUriRecord(uri: string): PasteDataRecord; + + /** + * get SystemPasteboard + * @return The system clipboard object + * @since 6 + */ + function getSystemPasteboard(): SystemPasteboard; + + interface PasteDataProperty { + /** + * additional property data. key-value pairs. + * @since 7 + */ + additions: { + [key: string]: object + } + /** + * non-repeating MIME types of all records in PasteData. + * @since 7 + */ + mimeTypes: Array; + /** + * the user-defined tag of a PasteData object. + * @since 7 + */ + tag: string; + /** + * a timestamp, which indicates when data is written to the system pasteboard. + * @since 7 + */ + timestamp: number; + /** + * Checks whether PasteData is set for local access only. + * @since 7 + */ + localOnly: boolean; + } + + interface PasteDataRecord { + /** + * HTML text in a record. + * @since 7 + */ + htmlText: string; + /** + * an want in a record. + * @since 7 + */ + want: Want; + /** + * MIME types of a record. + * @since 7 + */ + mimeType: string; + /** + * plain text in a record. + * @since 7 + */ + plainText: string; + /** + * an URI in a record. + * @since 7 + */ + uri: string; + + /** + * Will a PasteData cast to the content of text content + * @return callback Type string callback function + * @since 7 + */ + convertToText(callback: AsyncCallback): void; + convertToText(): Promise; + } + + interface PasteData { + /** + * Adds a Record for HTML text to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_HTML in DataProperty. + * @param htmlText To save the Html text content. + * @since 7 + */ + addHtmlRecord(htmlText: string): void; + + /** + * Adds an want Record to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_WANT in DataProperty. + * @param want To save the want content. + * @since 7 + */ + addWantRecord(want: Want): void; + + /** + * Adds a PasteRecord to a PasteData object and updates MIME types in DataProperty. + * @param record The content of a new record. + * @since 7 + */ + addRecord(record: PasteDataRecord): void; + + /** + * Adds a Record for plain text to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_PLAIN in DataProperty. + * @param text To save the text of content. + * @since 7 + */ + addTextRecord(text: string): void; + + /** + * Adds a URI Record to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_URI in DataProperty. + * @param uri To save the uri of content. + * @since 7 + */ + addUriRecord(uri: string): void; + + /** + * MIME types of all content on the pasteboard. + * @return string type of array + * @since 7 + */ + getMimeTypes(): Array; + + /** + * HTML text of the primary record in a PasteData object. + * @return string type of htmltext + * @since 7 + */ + getPrimaryHtml(): string; + + /** + * the want of the primary record in a PasteData object. + * @return want type of want + * @since 7 + */ + getPrimaryWant(): Want; + + /** + * the MIME type of the primary record in a PasteData object. + * @return string type of mimetype + * @since 7 + */ + getPrimaryMimeType(): string; + + /** + * the plain text of the primary record in a PasteData object. + * @return string type of text + * @since 6 + */ + getPrimaryText(): string; + + /** + * the URI of the primary record in a PasteData object. + * @return string type of uri + * @since 7 + */ + getPrimaryUri(): string; + + /** + * DataProperty of a PasteData object. + * @return PasteDataProperty type of PasteDataProperty + * @since 7 + */ + getProperty(): PasteDataProperty; + + /** + * a Record based on a specified index. + * @param index The index to specify the content item + * @return PasteDataRecord type of PasteDataRecord + * @since 7 + */ + getRecordAt(index: number): PasteDataRecord; + + /** + * the number of records in a PasteData object. + * @return The number of the clipboard contents + * @since 7 + */ + getRecordCount(): number; + + /** + * the user-defined tag of a PasteData object. + * @return string type of tag + * @since 7 + */ + getTag(): string; + + /** + * Checks whether there is a specified MIME type of data in DataProperty. + * @param mimeType To query data types. + * @return The query returns True on success, or False on failure. + * @since 7 + */ + hasMimeType(mimeType: string): boolean; + + /** + * Removes a Record based on a specified index. + * @param index The index to specify the content item. + * @return The query returns True on success, or False on failure. + * @since 7 + */ + removeRecordAt(index: number): boolean; + + /** + * Replaces a specified record with a new one. + * @param index The index to specify the content item. record record The content of a new record. + * @return The query returns True on success, or False on failure. + * @since 7 + */ + replaceRecordAt(index: number, record: PasteDataRecord): boolean; + } + + interface SystemPasteboard { + /** + * Callback invoked when pasteboard content changes. + * @param type 'update' + * @since 7 + */ + on(type: 'update', callback: () => void): void; + /** + * Callback invoked when pasteboard content changes. + * @param type 'update' + * @since 7 + */ + off(type: 'update', callback?: () => void): void; + + /** + * Clears the pasteboard. + * @since 7 + */ + clear(callback: AsyncCallback): void; + clear(): Promise; + + /** + * data in a PasteData object. + * @return PasteData callback data in a PasteData object. + * @since 6 + */ + getPasteData(callback: AsyncCallback): void; + getPasteData(): Promise; + + /** + * Checks whether there is content in the pasteboard. + * @return boolean The callback success to true to false failure + * @since 7 + */ + hasPasteData(callback: AsyncCallback): void; + hasPasteData(): Promise; + + /** + * Writes PasteData to the pasteboard. + * @param data Containing the contents of the clipboard content object. + * @since 6 + */ + setPasteData(data: PasteData, callback: AsyncCallback): void; + setPasteData(data: PasteData): Promise; + } +} + +export default pasteboard; diff --git a/api/@ohos.screenlock.d.ts b/api/@ohos.screenlock.d.ts new file mode 100644 index 0000000000..336fe5179c --- /dev/null +++ b/api/@ohos.screenlock.d.ts @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic'; +import { Callback } from './basic'; + +/** + * systemScreenLock + * @devices phone, tablet, tv, wearable, car + * @since 7 + */ +declare namespace screenLock { + + /** + * Checks whether the screen is currently locked. + * + * @return Returns {@code true} if the screen is currently locked; returns {@code false} + * otherwise. + * @since 7 + */ + function isScreenLocked(callback: AsyncCallback): void; + function isScreenLocked(): Promise; + + /** + * Checks whether the screen lock of the current device is secure. + * + * @return Returns {@code true} if the screen lock of the current device is secure; returns {@code false} + * otherwise. + * @since 7 + */ + function isSecureMode(callback: AsyncCallback): void; + function isSecureMode(): Promise; + + /** + * Unlocks the screen. + * + * @since 7 + */ + function unlockScreen(callback: AsyncCallback): void; + + /** + * Receives {beginWakeUp|endWakeUp|beginScreenOn|endScreenOn|beginScreenOff|endScreenOff|unlockScreen|beginExitAnimation} called. + * This callback is invoked when {beginWakeUp|endWakeUp|beginScreenOn|endScreenOn|beginScreenOff|endScreenOff|unlockScreen|beginExitAnimation} + * is called by runtime + * + * @systemapi Hide this for inner system use. + * @since 8 + */ + function on(type: 'beginWakeUp' | 'endWakeUp' | 'beginScreenOn' | 'endScreenOn' | 'beginScreenOff' | 'endScreenOff' | 'unlockScreen' | 'beginExitAnimation', callback: Callback): void; + + /** + * Receives {beginSleep | endSleep | changeUser} called. This callback is invoked when {beginSleep | endSleep | changeUser} is called by runtime + * + * @systemapi Hide this for inner system use. + * @since 8 + */ + function on(type: 'beginSleep' | 'endSleep' | 'changeUser', callback: Callback): void; + + /** + * Receives screenlockEnabled change. This callback is invoked when screenlockEnabled is called by runtime + * + * @systemapi Hide this for inner system use. + * @since 8 + */ + function on(type: 'screenlockEnabled', callback: Callback): void; + + /** + * Remove the receives of {beginWakeUp | endWakeUp | beginScreenOn | endScreenOn | beginScreenOff | endScreenOff | unlockScreen + * | beginExitAnimation | screenlockEnabled | beginSleep | endSleep | changeUser}. + * + * @systemapi Hide this for inner system use. + * @since 8 + */ + function off(type: 'beginWakeUp' | 'endWakeUp' | 'beginScreenOn' | 'endScreenOn' | 'beginScreenOff' | 'endScreenOff' + | 'unlockScreen' | 'beginExitAnimation' | 'screenlockEnabled' | 'beginSleep' | 'endSleep' | 'changeUser', callback: Callback): void; + + + /** + * screenlockAPP send event to screenlockSA + * + * @systemapi Hide this for inner system use. + * @since 8 + */ + function sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback): void; + function sendScreenLockEvent(event: String, parameter: number): Promise; + + + /** + * api for unit test + * @since 7 + */ + function test_setScreenLocked(isScreenlocked: boolean, callback: AsyncCallback): void; + function test_setScreenLocked(isScreenlocked: boolean): Promise; + + /** + * api for unit test + * @since 7 + */ + function test_runtimeNotify(event: String, parameter: number, callback: AsyncCallback): void; + function test_runtimeNotify(event: String, parameter: number): Promise; + + /** + * api for unit test + * @since 7 + */ + function test_getRuntimeState(event: String, callback: AsyncCallback): void; + function test_getRuntimeState(event: String): Promise; +} + +export default screenLock; + + + diff --git a/api/@ohos.wallpaper.d.ts b/api/@ohos.wallpaper.d.ts new file mode 100644 index 0000000000..1c30cbb303 --- /dev/null +++ b/api/@ohos.wallpaper.d.ts @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {AsyncCallback} from './basic'; +import image from './@ohos.multimedia.image' + +/** + * System wallpaper + * @sysCap SystemCapability.Miscservices.Wallpaper + * @devices phone, tablet, tv, wearable, car + * @import import wallpaper from '@ohos.wallpaper'; + * @since 7 + */ +declare namespace wallpaper { + enum WallpaperType { + /** + * Indicates the home screen wallpaper. + */ + WALLPAPER_SYSTEM, + /** + * Indicates the lock screen wallpaper. + */ + WALLPAPER_LOCKSCREEN + } + + /** + * Obtains the wallpaper colors for the wallpaper of the specified type. + * @param wallpaperType Indicates the wallpaper type. + * @return RgbaColor type of array callback function + */ + function getColors(wallpaperType: WallpaperType, callback: AsyncCallback>): void; + function getColors(wallpaperType: WallpaperType): Promise>; + + /** + * Obtains the ID of the wallpaper of the specified type. + * @param wallpaperType Indicates the wallpaper type. + * @return an integer greater than or equal to {@code 0} representing the wallpaper ID + * if the specified type of wallpaper has been set; returns {@code -1} otherwise. + * The return value is an integer ranging from -1 to 2^31 - 1. + */ + function getId(wallpaperType: WallpaperType, callback: AsyncCallback): void; + function getId(wallpaperType: WallpaperType): Promise; + + /** + * Obtains the minimum height of the wallpaper. + * @return the minimum height, in pixels; returns {@code 0} if no wallpaper has been set. + */ + function getMinHeight(callback: AsyncCallback): void; + function getMinHeight(): Promise; + + /** + * Obtains the minimum width of the wallpaper. + * @return the minimum width, in pixels; returns {@code 0} if no wallpaper has been set. + */ + function getMinWidth(callback: AsyncCallback): void; + function getMinWidth(): Promise; + + /** + * Checks whether to allow the application to change the wallpaper for the current user. + * @return true if the application is allowed to set a wallpaper for the current user; + */ + function isChangePermitted(callback: AsyncCallback): void; + function isChangePermitted(): Promise; + + /** + * Checks whether a user is allowed to set wallpapers. + * @return true if a user is allowed to set wallpapers; returns false otherwise. + */ + function isOperationAllowed(callback: AsyncCallback): void; + function isOperationAllowed(): Promise; + + /** + * Removes a wallpaper of the specified type and restores the default one. + * @param wallpaperType Indicates the wallpaper type. + * @permission ohos.permission.SET_WALLPAPER + */ + function reset(wallpaperType: WallpaperType, callback: AsyncCallback): void; + function reset(wallpaperType: WallpaperType): Promise; + + /** + * Sets a wallpaper of the specified type based on the uri path from a JPEG or PNG file or the pixel map of a PNG file. + * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file. + * @param wallpaperType Indicates the wallpaper type. + * @permission ohos.permission.SET_WALLPAPER + */ + function setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback): void; + function setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise; + + /** + * Obtains the default pixel map of a wallpaper of the specified type. + * @param wallpaperType Indicates the wallpaper type. + * @return the default pixel map. + * @permission ohos.permission.GET_WALLPAPER + * @permission ohos.permission.READ_USER_STORAGE + * @systemapi Hide this for inner system use. + */ + function getPixelMap(wallpaperType: WallpaperType, callback: AsyncCallback): void; + function getPixelMap(wallpaperType: WallpaperType): Promise; + + /** + * Screen shot live wallpaper + * @param scale scale the PixelMap + * @param pixelFormat pixel format + * @return the pixel map of wallpaper. + * @permission ohos.permission.CAPTURE_SCREEN + * @systemapi Hide this for inner system use. + */ + function screenshotLiveWallpaper(scale: number, pixelFormat: image.PixelMapFormat, callback: AsyncCallback): void; + function screenshotLiveWallpaper(scale: number, pixelFormat: image.PixelMapFormat): Promise; + + /** + * Registers a listener for wallpaper color changes to receive notifications about the changes. + * @param type The incoming colorChange table open receiver pick a color change wallpaper wallpaper color changes + * @param callback Provides dominant colors of the wallpaper. + */ + function on(type: 'colorChange', callback: (colors: Array, wallpaperType: WallpaperType) => void): void; + + /** + * Unregisters a listener for wallpaper color changes. + * @param type Incoming 'colorChange' table delete receiver to pick up a color change wallpaper wallpaper color changes + * @param callback Provides dominant colors of the wallpaper. + */ + function off(type: 'colorChange', callback?: (colors: Array, wallpaperType: WallpaperType) => void): void; + + interface RgbaColor { + /** + * Said the red value, the range is 0 to 255. + */ + red: number; + /** + * Said the green value, the range is 0 to 255. + */ + green: number; + /** + * Said the blue value, the range is 0 to 255. + */ + blue: number; + /** + * Said the alpha value, the range is 0 to 255. + */ + alpha: number; + } +} + +export default wallpaper; -- Gitee