提交 00a70482 编写于 作者: S sienna1128 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/docs into docs/0927

Signed-off-by: Nsienna1128 <lixiaoyan45@huawei.com>
...@@ -2,17 +2,19 @@ ...@@ -2,17 +2,19 @@
## Overview<a name="section3986195420436"></a> ## Overview<a name="section3986195420436"></a>
HiTrace tracks the call chain with the same **traceid** throughout the inter-device, inter-process, and inter-thread service processes. It associates and displays the call relationship and various output information during the entire process, helping you analyze and locate faults and optimize the system. HiTraceChain tracks the call chain with the same **traceid** throughout the inter-device, inter-process, and inter-thread service processes. It associates and displays the call relationship and various output information during the entire process, helping you analyze and locate faults and optimize the system.
## Use Cases<a name="section134561822574"></a> ## Use Cases<a name="section134561822574"></a>
HiTrace can be used for the following purposes: HiTraceChain can be used for the following purposes:
- Associates and reports service process information \(such as logs and events\) on the device. - Associates and reports service process information \(such as logs and events\) on the device.
- Displays and analyzes reported information on the cloud to facilitate fault location. - Displays and analyzes reported information on the cloud to facilitate fault location.
- Works with the IDE to debug the detailed service process and time consumption distribution for system optimization. - Works with the IDE to debug the detailed service process and time consumption distribution for system optimization.
**Figure 1** Use cases of HiTrace<a name="fig179241023125715"></a> **Figure 1** Use cases of HiTraceChain<a name="fig179241023125715"></a>
![](figure/use-cases-of-hitrace.png "use-cases-of-hitrace") ![](figure/use-cases-of-hitrace.png "use-cases-of-hitrace")
...@@ -33,9 +35,9 @@ HiTrace can be used for the following purposes: ...@@ -33,9 +35,9 @@ HiTrace can be used for the following purposes:
## Available APIs<a name="section1517945334617"></a> ## Available APIs<a name="section1517945334617"></a>
HiTrace provides C++ and C APIs. The upper-layer services mainly use HiTrace to start and stop call chain tracing. HiTraceChain provides C++ and C APIs. The upper-layer services mainly use HiTraceChain to start and stop call chain tracing.
HiTrace is implemented at layer C. It works by transferring **traceid** throughout the service calling process. Before service processing, HiTrace sets **traceid** in the thread local storage \(TLS\) of the calling thread. During service processing, HiTrace obtains **traceid** from the contextual TLS of the calling thread and automatically adds it to the log and event information. After service processing is complete, HiTrace clears **traceid** from the TLS of the calling thread. HiTraceChain is implemented at layer C. It works by transferring **traceid** throughout the service calling process. Before service processing, HiTraceChain sets **traceid** in the thread local storage \(TLS\) of the calling thread. During service processing, HiTraceChain obtains **traceid** from the contextual TLS of the calling thread and automatically adds it to the log and event information. After service processing is complete, HiTraceChain clears **traceid** from the TLS of the calling thread.
### Java, C++, and C APIs<a name="section932504474"></a> ### Java, C++, and C APIs<a name="section932504474"></a>
...@@ -56,7 +58,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug ...@@ -56,7 +58,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug
<td class="cellrowborder" valign="top" width="46.04%" headers="mcps1.2.4.1.3 "><p id="p19219151413589"><a name="p19219151413589"></a><a name="p19219151413589"></a><strong id="b989888034"><a name="b989888034"></a><a name="b989888034"></a>API</strong></p> <td class="cellrowborder" valign="top" width="46.04%" headers="mcps1.2.4.1.3 "><p id="p19219151413589"><a name="p19219151413589"></a><a name="p19219151413589"></a><strong id="b989888034"><a name="b989888034"></a><a name="b989888034"></a>API</strong></p>
</td> </td>
</tr> </tr>
<tr id="row1219111415585"><td class="cellrowborder" rowspan="8" valign="top" width="12.540000000000001%" headers="mcps1.2.4.1.1 "><p id="p15219101455812"><a name="p15219101455812"></a><a name="p15219101455812"></a>HiTrace</p> <tr id="row1219111415585"><td class="cellrowborder" rowspan="8" valign="top" width="12.540000000000001%" headers="mcps1.2.4.1.1 "><p id="p15219101455812"><a name="p15219101455812"></a><a name="p15219101455812"></a>HiTraceChain</p>
<p id="p1945616211310"><a name="p1945616211310"></a><a name="p1945616211310"></a></p> <p id="p1945616211310"><a name="p1945616211310"></a><a name="p1945616211310"></a></p>
<p id="p1645619231317"><a name="p1645619231317"></a><a name="p1645619231317"></a></p> <p id="p1645619231317"><a name="p1645619231317"></a><a name="p1645619231317"></a></p>
<p id="p94562024134"><a name="p94562024134"></a><a name="p94562024134"></a></p> <p id="p94562024134"><a name="p94562024134"></a><a name="p94562024134"></a></p>
...@@ -67,42 +69,42 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug ...@@ -67,42 +69,42 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug
</td> </td>
<td class="cellrowborder" valign="top" width="41.42%" headers="mcps1.2.4.1.2 "><p id="p821971495820"><a name="p821971495820"></a><a name="p821971495820"></a>HiTraceId Begin(const std::string&amp; name, int flags)</p> <td class="cellrowborder" valign="top" width="41.42%" headers="mcps1.2.4.1.2 "><p id="p821971495820"><a name="p821971495820"></a><a name="p821971495820"></a>HiTraceId Begin(const std::string&amp; name, int flags)</p>
</td> </td>
<td class="cellrowborder" valign="top" width="46.04%" headers="mcps1.2.4.1.3 "><p id="p2219914195817"><a name="p2219914195817"></a><a name="p2219914195817"></a>HiTraceIdStruct HiTraceBegin(const char* name, int flags)</p> <td class="cellrowborder" valign="top" width="46.04%" headers="mcps1.2.4.1.3 "><p id="p2219914195817"><a name="p2219914195817"></a><a name="p2219914195817"></a>HiTraceIdStruct HiTraceChainBegin(const char* name, int flags)</p>
</td> </td>
</tr> </tr>
<tr id="row16219171417584"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p021971414588"><a name="p021971414588"></a><a name="p021971414588"></a>void End(const HiTraceId&amp; id)</p> <tr id="row16219171417584"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p021971414588"><a name="p021971414588"></a><a name="p021971414588"></a>void End(const HiTraceId&amp; id)</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p16219191435814"><a name="p16219191435814"></a><a name="p16219191435814"></a>void HiTraceEnd(const HiTraceIdStruct* pId)</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p16219191435814"><a name="p16219191435814"></a><a name="p16219191435814"></a>void HiTraceChainEnd(const HiTraceIdStruct* pId)</p>
</td> </td>
</tr> </tr>
<tr id="row02191414115819"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p42191143585"><a name="p42191143585"></a><a name="p42191143585"></a>HiTraceId GetId();</p> <tr id="row02191414115819"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p42191143585"><a name="p42191143585"></a><a name="p42191143585"></a>HiTraceId GetId();</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1221901419588"><a name="p1221901419588"></a><a name="p1221901419588"></a>HiTraceIdStruct HiTraceGetId()</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1221901419588"><a name="p1221901419588"></a><a name="p1221901419588"></a>HiTraceIdStruct HiTraceChainGetId()</p>
</td> </td>
</tr> </tr>
<tr id="row11219131415582"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p6219111415812"><a name="p6219111415812"></a><a name="p6219111415812"></a>void SetId(const HiTraceId&amp; id)</p> <tr id="row11219131415582"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p6219111415812"><a name="p6219111415812"></a><a name="p6219111415812"></a>void SetId(const HiTraceId&amp; id)</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p221971465818"><a name="p221971465818"></a><a name="p221971465818"></a>void HiTraceSetId(const HiTraceIdStruct* pId)</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p221971465818"><a name="p221971465818"></a><a name="p221971465818"></a>void HiTraceChainSetId(const HiTraceIdStruct* pId)</p>
</td> </td>
</tr> </tr>
<tr id="row162191814105815"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p12191147586"><a name="p12191147586"></a><a name="p12191147586"></a>void ClearId()</p> <tr id="row162191814105815"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p12191147586"><a name="p12191147586"></a><a name="p12191147586"></a>void ClearId()</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p18219181445813"><a name="p18219181445813"></a><a name="p18219181445813"></a>void HiTraceClearId()</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p18219181445813"><a name="p18219181445813"></a><a name="p18219181445813"></a>void HiTraceChainClearId()</p>
</td> </td>
</tr> </tr>
<tr id="row12219151475812"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1721981418580"><a name="p1721981418580"></a><a name="p1721981418580"></a>HiTraceId CreateSpan()</p> <tr id="row12219151475812"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1721981418580"><a name="p1721981418580"></a><a name="p1721981418580"></a>HiTraceId CreateSpan()</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1121981420584"><a name="p1121981420584"></a><a name="p1121981420584"></a>HiTraceIdStruct HiTraceCreateSpan()</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1121981420584"><a name="p1121981420584"></a><a name="p1121981420584"></a>HiTraceIdStruct HiTraceChainCreateSpan()</p>
</td> </td>
</tr> </tr>
<tr id="row1721911140582"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p18219514195814"><a name="p18219514195814"></a><a name="p18219514195814"></a>void Tracepoint(HiTraceTracepointType type, const HiTraceId&amp; id, const char* fmt, ...)</p> <tr id="row1721911140582"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p18219514195814"><a name="p18219514195814"></a><a name="p18219514195814"></a>void Tracepoint(HiTraceTracepointType type, const HiTraceId&amp; id, const char* fmt, ...)</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p3219914175813"><a name="p3219914175813"></a><a name="p3219914175813"></a>void HiTraceTracepoint(HiTraceTracepointType type, const HiTraceIdStruct* pId, const char* fmt, ...)</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p3219914175813"><a name="p3219914175813"></a><a name="p3219914175813"></a>void HiTraceChainTracepoint(HiTraceTracepointType type, const HiTraceIdStruct* pId, const char* fmt, ...)</p>
</td> </td>
</tr> </tr>
<tr id="row521911410582"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p2219101415814"><a name="p2219101415814"></a><a name="p2219101415814"></a>void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId&amp; id, const char* fmt, ...)</p> <tr id="row521911410582"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p2219101415814"><a name="p2219101415814"></a><a name="p2219101415814"></a>void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId&amp; id, const char* fmt, ...)</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p2220141413584"><a name="p2220141413584"></a><a name="p2220141413584"></a>void HiTraceTracepointEx(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceIdStruct* pId, const char* fmt, ...)</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p2220141413584"><a name="p2220141413584"></a><a name="p2220141413584"></a>void HiTraceChainTracepointEx(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceIdStruct* pId, const char* fmt, ...)</p>
</td> </td>
</tr> </tr>
<tr id="row8220181411586"><td class="cellrowborder" rowspan="14" valign="top" width="12.540000000000001%" headers="mcps1.2.4.1.1 "><p id="p522018149588"><a name="p522018149588"></a><a name="p522018149588"></a>HiTraceId</p> <tr id="row8220181411586"><td class="cellrowborder" rowspan="14" valign="top" width="12.540000000000001%" headers="mcps1.2.4.1.1 "><p id="p522018149588"><a name="p522018149588"></a><a name="p522018149588"></a>HiTraceId</p>
...@@ -122,72 +124,72 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug ...@@ -122,72 +124,72 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug
</td> </td>
<td class="cellrowborder" valign="top" width="41.42%" headers="mcps1.2.4.1.2 "><p id="p102201914105811"><a name="p102201914105811"></a><a name="p102201914105811"></a>HiTraceId();</p> <td class="cellrowborder" valign="top" width="41.42%" headers="mcps1.2.4.1.2 "><p id="p102201914105811"><a name="p102201914105811"></a><a name="p102201914105811"></a>HiTraceId();</p>
</td> </td>
<td class="cellrowborder" valign="top" width="46.04%" headers="mcps1.2.4.1.3 "><p id="p16220161419581"><a name="p16220161419581"></a><a name="p16220161419581"></a>void HiTraceInitId(HiTraceIdStruct* pId)</p> <td class="cellrowborder" valign="top" width="46.04%" headers="mcps1.2.4.1.3 "><p id="p16220161419581"><a name="p16220161419581"></a><a name="p16220161419581"></a>void HiTraceChainInitId(HiTraceIdStruct* pId)</p>
</td> </td>
</tr> </tr>
<tr id="row8220191405817"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p162201314155813"><a name="p162201314155813"></a><a name="p162201314155813"></a>HiTraceId(const uint8_t* pIdArray, int len)</p> <tr id="row8220191405817"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p162201314155813"><a name="p162201314155813"></a><a name="p162201314155813"></a>HiTraceId(const uint8_t* pIdArray, int len)</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p122011425814"><a name="p122011425814"></a><a name="p122011425814"></a>HiTraceIdStruct HiTraceBytesToId(const uint8_t* pIdArray, int len)</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p122011425814"><a name="p122011425814"></a><a name="p122011425814"></a>HiTraceIdStruct HiTraceChainBytesToId(const uint8_t* pIdArray, int len)</p>
</td> </td>
</tr> </tr>
<tr id="row1522041435820"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1422012146587"><a name="p1422012146587"></a><a name="p1422012146587"></a>bool IsValid()</p> <tr id="row1522041435820"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1422012146587"><a name="p1422012146587"></a><a name="p1422012146587"></a>bool IsValid()</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1322016149586"><a name="p1322016149586"></a><a name="p1322016149586"></a>int HiTraceIsValid(const HiTraceIdStruct* pId)</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1322016149586"><a name="p1322016149586"></a><a name="p1322016149586"></a>int HiTraceChainIsValid(const HiTraceIdStruct* pId)</p>
</td> </td>
</tr> </tr>
<tr id="row8220714155810"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p322021485814"><a name="p322021485814"></a><a name="p322021485814"></a>bool IsFlagEnabled(HiTraceFlag flag)</p> <tr id="row8220714155810"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p322021485814"><a name="p322021485814"></a><a name="p322021485814"></a>bool IsFlagEnabled(HiTraceFlag flag)</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p922010148583"><a name="p922010148583"></a><a name="p922010148583"></a>int HiTraceIsFlagEnabled(const HiTraceIdStruct* pId, HiTraceFlag flag)</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p922010148583"><a name="p922010148583"></a><a name="p922010148583"></a>int HiTraceChainIsFlagEnabled(const HiTraceIdStruct* pId, HiTraceFlag flag)</p>
</td> </td>
</tr> </tr>
<tr id="row12220161485814"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1122011140588"><a name="p1122011140588"></a><a name="p1122011140588"></a>void EnableFlag(HiTraceFlag flag)</p> <tr id="row12220161485814"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1122011140588"><a name="p1122011140588"></a><a name="p1122011140588"></a>void EnableFlag(HiTraceFlag flag)</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p152201146583"><a name="p152201146583"></a><a name="p152201146583"></a>void HiTraceEnableFlag(HiTraceIdStruct* pId, HiTraceFlag flag)</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p152201146583"><a name="p152201146583"></a><a name="p152201146583"></a>void HiTraceChainEnableFlag(HiTraceIdStruct* pId, HiTraceFlag flag)</p>
</td> </td>
</tr> </tr>
<tr id="row922061411589"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p202208143588"><a name="p202208143588"></a><a name="p202208143588"></a>int GetFlags()</p> <tr id="row922061411589"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p202208143588"><a name="p202208143588"></a><a name="p202208143588"></a>int GetFlags()</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p182206142587"><a name="p182206142587"></a><a name="p182206142587"></a>int HiTraceGetFlags(const HiTraceIdStruct* pId)</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p182206142587"><a name="p182206142587"></a><a name="p182206142587"></a>int HiTraceChainGetFlags(const HiTraceIdStruct* pId)</p>
</td> </td>
</tr> </tr>
<tr id="row82204145589"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p12201414205815"><a name="p12201414205815"></a><a name="p12201414205815"></a>void SetFlags(int flags)</p> <tr id="row82204145589"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p12201414205815"><a name="p12201414205815"></a><a name="p12201414205815"></a>void SetFlags(int flags)</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p162201514175813"><a name="p162201514175813"></a><a name="p162201514175813"></a>void HiTraceSetFlags(HiTraceIdStruct* pId, int flags)</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p162201514175813"><a name="p162201514175813"></a><a name="p162201514175813"></a>void HiTraceChainSetFlags(HiTraceIdStruct* pId, int flags)</p>
</td> </td>
</tr> </tr>
<tr id="row152204143585"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p722113147580"><a name="p722113147580"></a><a name="p722113147580"></a>uint64_t GetChainId()</p> <tr id="row152204143585"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p722113147580"><a name="p722113147580"></a><a name="p722113147580"></a>uint64_t GetChainId()</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p322119149584"><a name="p322119149584"></a><a name="p322119149584"></a>uint64_t HiTraceGetChainId(const HiTraceIdStruct* pId)</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p322119149584"><a name="p322119149584"></a><a name="p322119149584"></a>uint64_t HiTraceChainGetChainId(const HiTraceIdStruct* pId)</p>
</td> </td>
</tr> </tr>
<tr id="row1221214175815"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p922131445815"><a name="p922131445815"></a><a name="p922131445815"></a>void SetChainId(uint64_t chainId)</p> <tr id="row1221214175815"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p922131445815"><a name="p922131445815"></a><a name="p922131445815"></a>void SetChainId(uint64_t chainId)</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p922101411588"><a name="p922101411588"></a><a name="p922101411588"></a>void HiTraceSetChainId(HiTraceIdStruct* pId, uint64_t chainId)</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p922101411588"><a name="p922101411588"></a><a name="p922101411588"></a>void HiTraceChainSetChainId(HiTraceIdStruct* pId, uint64_t chainId)</p>
</td> </td>
</tr> </tr>
<tr id="row1922115142588"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1122141414588"><a name="p1122141414588"></a><a name="p1122141414588"></a>uint64_t GetSpanId()</p> <tr id="row1922115142588"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1122141414588"><a name="p1122141414588"></a><a name="p1122141414588"></a>uint64_t GetSpanId()</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p32211145584"><a name="p32211145584"></a><a name="p32211145584"></a>uint64_t HiTraceGetSpanId(const HiTraceIdStruct* pId)</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p32211145584"><a name="p32211145584"></a><a name="p32211145584"></a>uint64_t HiTraceChainGetSpanId(const HiTraceIdStruct* pId)</p>
</td> </td>
</tr> </tr>
<tr id="row4221171414587"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p10221191412588"><a name="p10221191412588"></a><a name="p10221191412588"></a>void SetSpanId(uint64_t spanId)</p> <tr id="row4221171414587"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p10221191412588"><a name="p10221191412588"></a><a name="p10221191412588"></a>void SetSpanId(uint64_t spanId)</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p42211614105810"><a name="p42211614105810"></a><a name="p42211614105810"></a>void HiTraceSetSpanId(HiTraceIdStruct* pId, uint64_t spanId)</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p42211614105810"><a name="p42211614105810"></a><a name="p42211614105810"></a>void HiTraceChainSetSpanId(HiTraceIdStruct* pId, uint64_t spanId)</p>
</td> </td>
</tr> </tr>
<tr id="row322171425818"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1722111418582"><a name="p1722111418582"></a><a name="p1722111418582"></a>uint64_t GetParentSpanId()</p> <tr id="row322171425818"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1722111418582"><a name="p1722111418582"></a><a name="p1722111418582"></a>uint64_t GetParentSpanId()</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p8221314195817"><a name="p8221314195817"></a><a name="p8221314195817"></a>uint64_t HiTraceGetParentSpanId(const HiTraceIdStruct* pId)</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p8221314195817"><a name="p8221314195817"></a><a name="p8221314195817"></a>uint64_t HiTraceChainGetParentSpanId(const HiTraceIdStruct* pId)</p>
</td> </td>
</tr> </tr>
<tr id="row622114147589"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p92219145589"><a name="p92219145589"></a><a name="p92219145589"></a>void SetParentSpanId(uint64_t parentSpanId)</p> <tr id="row622114147589"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p92219145589"><a name="p92219145589"></a><a name="p92219145589"></a>void SetParentSpanId(uint64_t parentSpanId)</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p922191435813"><a name="p922191435813"></a><a name="p922191435813"></a>void HiTraceSetParentSpanId(HiTraceIdStruct* pId, uint64_t parentSpanId)</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p922191435813"><a name="p922191435813"></a><a name="p922191435813"></a>void HiTraceChainSetParentSpanId(HiTraceIdStruct* pId, uint64_t parentSpanId)</p>
</td> </td>
</tr> </tr>
<tr id="row5221614135814"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p11221121435820"><a name="p11221121435820"></a><a name="p11221121435820"></a>int ToBytes(uint8_t* pIdArray, int len)</p> <tr id="row5221614135814"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p11221121435820"><a name="p11221121435820"></a><a name="p11221121435820"></a>int ToBytes(uint8_t* pIdArray, int len)</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1122131415814"><a name="p1122131415814"></a><a name="p1122131415814"></a>int HiTraceIdToBytes(const HiTraceIdStruct* pId, uint8_t* pIdArray, int len)</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1122131415814"><a name="p1122131415814"></a><a name="p1122131415814"></a>int HiTraceChainIdToBytes(const HiTraceIdStruct* pId, uint8_t* pIdArray, int len)</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
...@@ -206,7 +208,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug ...@@ -206,7 +208,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody><tr id="row383911183378"><td class="cellrowborder" rowspan="8" valign="top" width="9.8%" headers="mcps1.2.4.1.1 "><p id="p10839318133713"><a name="p10839318133713"></a><a name="p10839318133713"></a>HiTrace</p> <tbody><tr id="row383911183378"><td class="cellrowborder" rowspan="8" valign="top" width="9.8%" headers="mcps1.2.4.1.1 "><p id="p10839318133713"><a name="p10839318133713"></a><a name="p10839318133713"></a>HiTraceChain</p>
<p id="p1544019164131"><a name="p1544019164131"></a><a name="p1544019164131"></a></p> <p id="p1544019164131"><a name="p1544019164131"></a><a name="p1544019164131"></a></p>
<p id="p14440191615134"><a name="p14440191615134"></a><a name="p14440191615134"></a></p> <p id="p14440191615134"><a name="p14440191615134"></a><a name="p14440191615134"></a></p>
<p id="p6440161631310"><a name="p6440161631310"></a><a name="p6440161631310"></a></p> <p id="p6440161631310"><a name="p6440161631310"></a><a name="p6440161631310"></a></p>
...@@ -217,7 +219,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug ...@@ -217,7 +219,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug
</td> </td>
<td class="cellrowborder" valign="top" width="31.430000000000003%" headers="mcps1.2.4.1.2 "><p id="p198391118193717"><a name="p198391118193717"></a><a name="p198391118193717"></a>HiTraceId Begin(const std::string&amp; name, int flags)</p> <td class="cellrowborder" valign="top" width="31.430000000000003%" headers="mcps1.2.4.1.2 "><p id="p198391118193717"><a name="p198391118193717"></a><a name="p198391118193717"></a>HiTraceId Begin(const std::string&amp; name, int flags)</p>
</td> </td>
<td class="cellrowborder" valign="top" width="58.77%" headers="mcps1.2.4.1.3 "><p id="p684013182375"><a name="p684013182375"></a><a name="p684013182375"></a>Starts HiTrace, generates a <strong id="b2063619462230"><a name="b2063619462230"></a><a name="b2063619462230"></a>HiTraceId</strong> object, and sets it in the TLS of the calling thread.</p> <td class="cellrowborder" valign="top" width="58.77%" headers="mcps1.2.4.1.3 "><p id="p684013182375"><a name="p684013182375"></a><a name="p684013182375"></a>Starts HiTraceChain, generates a <strong id="b2063619462230"><a name="b2063619462230"></a><a name="b2063619462230"></a>HiTraceId</strong> object, and sets it in the TLS of the calling thread.</p>
<p id="p1384081812377"><a name="p1384081812377"></a><a name="p1384081812377"></a>Input arguments:</p> <p id="p1384081812377"><a name="p1384081812377"></a><a name="p1384081812377"></a>Input arguments:</p>
<a name="ul1537854218177"></a><a name="ul1537854218177"></a><ul id="ul1537854218177"><li><strong id="b1566312131676"><a name="b1566312131676"></a><a name="b1566312131676"></a>name</strong>: Indicates the name of the service process.</li><li><strong id="b75512128711"><a name="b75512128711"></a><a name="b75512128711"></a>flags</strong>: Indicates tracing flags, which can be used in combination. <a name="ul18842248101915"></a><a name="ul18842248101915"></a><ul id="ul18842248101915"><li>HITRACE_FLAG_INCLUDE_ASYNC: Traces both synchronous and asynchronous calls. By default, only synchronous calls are traced.</li><li><strong id="b724616241477"><a name="b724616241477"></a><a name="b724616241477"></a>HITRACE_FLAG_DONOT_CREATE_SPAN</strong>: Do not create a span. By default, a span is created.</li><li><strong id="b136181926479"><a name="b136181926479"></a><a name="b136181926479"></a>HITRACE_FLAG_TP_INFO</strong>: Outputs the tracepoint information. By default, the information is not output.</li><li><strong id="b358818291777"><a name="b358818291777"></a><a name="b358818291777"></a>HITRACE_FLAG_NO_BE_INFO</strong>: Do not output the start and end information. By default, the information is output.</li><li><strong id="b38571331974"><a name="b38571331974"></a><a name="b38571331974"></a>HITRACE_FLAG_DONOT_ENABLE_LOG</strong>: Do not associate logs for output. By default, logs are associated for output.</li><li><strong id="b17320371870"><a name="b17320371870"></a><a name="b17320371870"></a>HITRACE_FLAG_FAULT_TRIGGER</strong>: Triggers tracing by fault. By default, tracing is triggered normally.</li><li><strong id="b876915381711"><a name="b876915381711"></a><a name="b876915381711"></a>HITRACE_FLAG_D2D_TP_INFO</strong>: Outputs the device-to-device tracepoint information. By default, the information is not output.</li><li><strong id="b66510421776"><a name="b66510421776"></a><a name="b66510421776"></a>HITRCE_FLAG_DEFAULT</strong>: Indicates the default flag.</li></ul> <a name="ul1537854218177"></a><a name="ul1537854218177"></a><ul id="ul1537854218177"><li><strong id="b1566312131676"><a name="b1566312131676"></a><a name="b1566312131676"></a>name</strong>: Indicates the name of the service process.</li><li><strong id="b75512128711"><a name="b75512128711"></a><a name="b75512128711"></a>flags</strong>: Indicates tracing flags, which can be used in combination. <a name="ul18842248101915"></a><a name="ul18842248101915"></a><ul id="ul18842248101915"><li>HITRACE_FLAG_INCLUDE_ASYNC: Traces both synchronous and asynchronous calls. By default, only synchronous calls are traced.</li><li><strong id="b724616241477"><a name="b724616241477"></a><a name="b724616241477"></a>HITRACE_FLAG_DONOT_CREATE_SPAN</strong>: Do not create a span. By default, a span is created.</li><li><strong id="b136181926479"><a name="b136181926479"></a><a name="b136181926479"></a>HITRACE_FLAG_TP_INFO</strong>: Outputs the tracepoint information. By default, the information is not output.</li><li><strong id="b358818291777"><a name="b358818291777"></a><a name="b358818291777"></a>HITRACE_FLAG_NO_BE_INFO</strong>: Do not output the start and end information. By default, the information is output.</li><li><strong id="b38571331974"><a name="b38571331974"></a><a name="b38571331974"></a>HITRACE_FLAG_DONOT_ENABLE_LOG</strong>: Do not associate logs for output. By default, logs are associated for output.</li><li><strong id="b17320371870"><a name="b17320371870"></a><a name="b17320371870"></a>HITRACE_FLAG_FAULT_TRIGGER</strong>: Triggers tracing by fault. By default, tracing is triggered normally.</li><li><strong id="b876915381711"><a name="b876915381711"></a><a name="b876915381711"></a>HITRACE_FLAG_D2D_TP_INFO</strong>: Outputs the device-to-device tracepoint information. By default, the information is not output.</li><li><strong id="b66510421776"><a name="b66510421776"></a><a name="b66510421776"></a>HITRCE_FLAG_DEFAULT</strong>: Indicates the default flag.</li></ul>
</li><li>Output arguments: none</li><li>Return value: Returns a valid <strong id="b7411101522917"><a name="b7411101522917"></a><a name="b7411101522917"></a>HiTraceId</strong> object if call chain tracing is triggered successfully; returns an invalid object otherwise.</li></ul> </li><li>Output arguments: none</li><li>Return value: Returns a valid <strong id="b7411101522917"><a name="b7411101522917"></a><a name="b7411101522917"></a>HiTraceId</strong> object if call chain tracing is triggered successfully; returns an invalid object otherwise.</li></ul>
...@@ -226,7 +228,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug ...@@ -226,7 +228,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug
</tr> </tr>
<tr id="row16840101803720"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p13840191893718"><a name="p13840191893718"></a><a name="p13840191893718"></a>void End(const HiTraceId&amp; id)</p> <tr id="row16840101803720"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p13840191893718"><a name="p13840191893718"></a><a name="p13840191893718"></a>void End(const HiTraceId&amp; id)</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p3840181820372"><a name="p3840181820372"></a><a name="p3840181820372"></a>Stops HiTrace based on the <strong id="b1605239122415"><a name="b1605239122415"></a><a name="b1605239122415"></a>HiTraceId</strong> object returned by the <strong id="b7610183992419"><a name="b7610183992419"></a><a name="b7610183992419"></a>Begin</strong> API, and clears the <strong id="b1610173918241"><a name="b1610173918241"></a><a name="b1610173918241"></a>HiTraceId</strong> object in the TLS of the calling thread.</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p3840181820372"><a name="p3840181820372"></a><a name="p3840181820372"></a>Stops HiTraceChain based on the <strong id="b1605239122415"><a name="b1605239122415"></a><a name="b1605239122415"></a>HiTraceId</strong> object returned by the <strong id="b7610183992419"><a name="b7610183992419"></a><a name="b7610183992419"></a>Begin</strong> API, and clears the <strong id="b1610173918241"><a name="b1610173918241"></a><a name="b1610173918241"></a>HiTraceId</strong> object in the TLS of the calling thread.</p>
<p id="p9840718103720"><a name="p9840718103720"></a><a name="p9840718103720"></a>Input arguments:</p> <p id="p9840718103720"><a name="p9840718103720"></a><a name="p9840718103720"></a>Input arguments:</p>
<a name="ul2917140133015"></a><a name="ul2917140133015"></a><ul id="ul2917140133015"><li><strong id="b8201185118711"><a name="b8201185118711"></a><a name="b8201185118711"></a>id</strong>: Indicates the <strong id="b2071183114331"><a name="b2071183114331"></a><a name="b2071183114331"></a>HiTraceId</strong> object.</li></ul> <a name="ul2917140133015"></a><a name="ul2917140133015"></a><ul id="ul2917140133015"><li><strong id="b8201185118711"><a name="b8201185118711"></a><a name="b8201185118711"></a>id</strong>: Indicates the <strong id="b2071183114331"><a name="b2071183114331"></a><a name="b2071183114331"></a>HiTraceId</strong> object.</li></ul>
<p id="p14840151803718"><a name="p14840151803718"></a><a name="p14840151803718"></a>Output arguments: none</p> <p id="p14840151803718"><a name="p14840151803718"></a><a name="p14840151803718"></a>Output arguments: none</p>
...@@ -268,7 +270,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug ...@@ -268,7 +270,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug
</tr> </tr>
<tr id="row198401118123714"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p178411618183711"><a name="p178411618183711"></a><a name="p178411618183711"></a>void Tracepoint(HiTraceTracepointType type, const HiTraceId&amp; id, const char* fmt, ...)</p> <tr id="row198401118123714"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p178411618183711"><a name="p178411618183711"></a><a name="p178411618183711"></a>void Tracepoint(HiTraceTracepointType type, const HiTraceId&amp; id, const char* fmt, ...)</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p88419184373"><a name="p88419184373"></a><a name="p88419184373"></a>Outputs HiTrace call chain information based on the information type. The information includes the timestamp and <strong id="b185817437323"><a name="b185817437323"></a><a name="b185817437323"></a>HiTraceId</strong> object information of the span.</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p88419184373"><a name="p88419184373"></a><a name="p88419184373"></a>Outputs HiTraceChain call chain information based on the information type. The information includes the timestamp and <strong id="b185817437323"><a name="b185817437323"></a><a name="b185817437323"></a>HiTraceId</strong> object information of the span.</p>
<p id="p1984116184376"><a name="p1984116184376"></a><a name="p1984116184376"></a>Input arguments:</p> <p id="p1984116184376"><a name="p1984116184376"></a><a name="p1984116184376"></a>Input arguments:</p>
<a name="ul18619103153812"></a><a name="ul18619103153812"></a><ul id="ul18619103153812"><li><strong id="b7818831083"><a name="b7818831083"></a><a name="b7818831083"></a>type</strong>: Indicates the information type. The options are as follows:<a name="ul1941510328297"></a><a name="ul1941510328297"></a><ul id="ul1941510328297"><li><strong id="b18809161180"><a name="b18809161180"></a><a name="b18809161180"></a>HITRACE_TP_CS</strong>: Client Send, which indicates the messages sent by the synchronous/asynchronous communication client.</li><li><strong id="b327281271319"><a name="b327281271319"></a><a name="b327281271319"></a>HITRACE_TP_SR</strong>: Server Receive, which indicates the messages received by the server in synchronous/asynchronous communication.</li><li><strong id="b10154742682"><a name="b10154742682"></a><a name="b10154742682"></a>HITRACE_TP_SS</strong>: Server Send, which indicates the response messages sent by the server in synchronous communication.</li><li><strong id="b152598127810"><a name="b152598127810"></a><a name="b152598127810"></a>HITRACE_TP_CR</strong>: Client Receive, which indicates the response messages received by the synchronous communication client.</li><li><strong id="b82631512817"><a name="b82631512817"></a><a name="b82631512817"></a>HITRACE_TP_GENERAL</strong>: Indicates the common output information.</li></ul> <a name="ul18619103153812"></a><a name="ul18619103153812"></a><ul id="ul18619103153812"><li><strong id="b7818831083"><a name="b7818831083"></a><a name="b7818831083"></a>type</strong>: Indicates the information type. The options are as follows:<a name="ul1941510328297"></a><a name="ul1941510328297"></a><ul id="ul1941510328297"><li><strong id="b18809161180"><a name="b18809161180"></a><a name="b18809161180"></a>HITRACE_TP_CS</strong>: Client Send, which indicates the messages sent by the synchronous/asynchronous communication client.</li><li><strong id="b327281271319"><a name="b327281271319"></a><a name="b327281271319"></a>HITRACE_TP_SR</strong>: Server Receive, which indicates the messages received by the server in synchronous/asynchronous communication.</li><li><strong id="b10154742682"><a name="b10154742682"></a><a name="b10154742682"></a>HITRACE_TP_SS</strong>: Server Send, which indicates the response messages sent by the server in synchronous communication.</li><li><strong id="b152598127810"><a name="b152598127810"></a><a name="b152598127810"></a>HITRACE_TP_CR</strong>: Client Receive, which indicates the response messages received by the synchronous communication client.</li><li><strong id="b82631512817"><a name="b82631512817"></a><a name="b82631512817"></a>HITRACE_TP_GENERAL</strong>: Indicates the common output information.</li></ul>
</li><li><strong id="b117401716584"><a name="b117401716584"></a><a name="b117401716584"></a>id</strong>: Indicates the ID of the current span.</li><li><strong id="b392172019813"><a name="b392172019813"></a><a name="b392172019813"></a>fmt</strong>: Indicates the string describing the format variable parameter.</li><li><strong id="b986771717818"><a name="b986771717818"></a><a name="b986771717818"></a>args</strong>: Indicates the variable parameter.</li></ul> </li><li><strong id="b117401716584"><a name="b117401716584"></a><a name="b117401716584"></a>id</strong>: Indicates the ID of the current span.</li><li><strong id="b392172019813"><a name="b392172019813"></a><a name="b392172019813"></a>fmt</strong>: Indicates the string describing the format variable parameter.</li><li><strong id="b986771717818"><a name="b986771717818"></a><a name="b986771717818"></a>args</strong>: Indicates the variable parameter.</li></ul>
...@@ -278,7 +280,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug ...@@ -278,7 +280,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug
</tr> </tr>
<tr id="row11841191811379"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p08411318163716"><a name="p08411318163716"></a><a name="p08411318163716"></a>void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId&amp; id, const char* fmt, ...)</p> <tr id="row11841191811379"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p08411318163716"><a name="p08411318163716"></a><a name="p08411318163716"></a>void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId&amp; id, const char* fmt, ...)</p>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p68411618153713"><a name="p68411618153713"></a><a name="p68411618153713"></a>Outputs HiTrace call chain information based on the communication mode and information type. The information includes the timestamp and <strong id="b8151210123912"><a name="b8151210123912"></a><a name="b8151210123912"></a>HiTraceId</strong> object information of the span.</p> <td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p68411618153713"><a name="p68411618153713"></a><a name="p68411618153713"></a>Outputs HiTraceChain call chain information based on the communication mode and information type. The information includes the timestamp and <strong id="b8151210123912"><a name="b8151210123912"></a><a name="b8151210123912"></a>HiTraceId</strong> object information of the span.</p>
<p id="p98418189375"><a name="p98418189375"></a><a name="p98418189375"></a>Input arguments:</p> <p id="p98418189375"><a name="p98418189375"></a><a name="p98418189375"></a>Input arguments:</p>
<a name="ul914264413811"></a><a name="ul914264413811"></a><ul id="ul914264413811"><li><strong id="b76471824183"><a name="b76471824183"></a><a name="b76471824183"></a>mode</strong>: Indicates the communication mode. The options are as follows:<a name="ul137382469451"></a><a name="ul137382469451"></a><ul id="ul137382469451"><li><strong id="b13732297812"><a name="b13732297812"></a><a name="b13732297812"></a>HITRACE_CM_DEFAULT</strong>: default communication mode used when no communication mode is specified</li><li><strong id="b1820115271789"><a name="b1820115271789"></a><a name="b1820115271789"></a>HITRACE_CM_THREAD</strong>: inter-thread communication</li><li><strong id="b27781831488"><a name="b27781831488"></a><a name="b27781831488"></a>HITRACE_CM_PROCESS</strong>: inter-process communication</li><li><strong id="b15657113313819"><a name="b15657113313819"></a><a name="b15657113313819"></a>HITRACE_CM_DEVICE</strong>: inter-device communication</li></ul> <a name="ul914264413811"></a><a name="ul914264413811"></a><ul id="ul914264413811"><li><strong id="b76471824183"><a name="b76471824183"></a><a name="b76471824183"></a>mode</strong>: Indicates the communication mode. The options are as follows:<a name="ul137382469451"></a><a name="ul137382469451"></a><ul id="ul137382469451"><li><strong id="b13732297812"><a name="b13732297812"></a><a name="b13732297812"></a>HITRACE_CM_DEFAULT</strong>: default communication mode used when no communication mode is specified</li><li><strong id="b1820115271789"><a name="b1820115271789"></a><a name="b1820115271789"></a>HITRACE_CM_THREAD</strong>: inter-thread communication</li><li><strong id="b27781831488"><a name="b27781831488"></a><a name="b27781831488"></a>HITRACE_CM_PROCESS</strong>: inter-process communication</li><li><strong id="b15657113313819"><a name="b15657113313819"></a><a name="b15657113313819"></a>HITRACE_CM_DEVICE</strong>: inter-device communication</li></ul>
</li><li><strong id="b172723513812"><a name="b172723513812"></a><a name="b172723513812"></a>type</strong>: Indicates the information type. The options are as follows:<a name="ul19648426458"></a><a name="ul19648426458"></a><ul id="ul19648426458"><li><strong id="b26421037382"><a name="b26421037382"></a><a name="b26421037382"></a>HITRACE_TP_CS</strong>: Client Send, which indicates the messages sent by the synchronous/asynchronous communication client.</li><li><strong id="b66504018818"><a name="b66504018818"></a><a name="b66504018818"></a>HITRACE_TP_SR</strong>: Server Receive, which indicates the messages received by the server in synchronous/asynchronous communication.</li><li><strong id="b285283761"><a name="b285283761"></a><a name="b285283761"></a>HITRACE_TP_SS</strong>: Server Send, which indicates the response messages sent by the server in synchronous communication.</li><li><strong id="b148684447814"><a name="b148684447814"></a><a name="b148684447814"></a>HITRACE_TP_CR</strong>: Client Receive, which indicates the response messages received by the synchronous communication client.</li><li><strong id="b17875164618816"><a name="b17875164618816"></a><a name="b17875164618816"></a>HITRACE_TP_GENERAL</strong>: Indicates the common output information.</li></ul> </li><li><strong id="b172723513812"><a name="b172723513812"></a><a name="b172723513812"></a>type</strong>: Indicates the information type. The options are as follows:<a name="ul19648426458"></a><a name="ul19648426458"></a><ul id="ul19648426458"><li><strong id="b26421037382"><a name="b26421037382"></a><a name="b26421037382"></a>HITRACE_TP_CS</strong>: Client Send, which indicates the messages sent by the synchronous/asynchronous communication client.</li><li><strong id="b66504018818"><a name="b66504018818"></a><a name="b66504018818"></a>HITRACE_TP_SR</strong>: Server Receive, which indicates the messages received by the server in synchronous/asynchronous communication.</li><li><strong id="b285283761"><a name="b285283761"></a><a name="b285283761"></a>HITRACE_TP_SS</strong>: Server Send, which indicates the response messages sent by the server in synchronous communication.</li><li><strong id="b148684447814"><a name="b148684447814"></a><a name="b148684447814"></a>HITRACE_TP_CR</strong>: Client Receive, which indicates the response messages received by the synchronous communication client.</li><li><strong id="b17875164618816"><a name="b17875164618816"></a><a name="b17875164618816"></a>HITRACE_TP_GENERAL</strong>: Indicates the common output information.</li></ul>
...@@ -428,7 +430,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug ...@@ -428,7 +430,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug
## Call Chain Processing<a name="section11257133933"></a> ## Call Chain Processing<a name="section11257133933"></a>
Inter-device, inter-process, and inter-thread calls are implemented through the communication mechanism. **HiTrace** requires transfer of **traceid** in the communication mechanism. Inter-device, inter-process, and inter-thread calls are implemented through the communication mechanism. **HiTraceChain** requires transfer of **traceid** in the communication mechanism.
Some built-in communication mechanisms \(such as ZIDL\) of OpenHarmony already support the transfer of **traceid**. Some built-in communication mechanisms \(such as ZIDL\) of OpenHarmony already support the transfer of **traceid**.
...@@ -475,25 +477,25 @@ The process is as follows: ...@@ -475,25 +477,25 @@ The process is as follows:
1. Develop the source code. 1. Develop the source code.
Include the **hitrace** header file in the class definition header file or class implementation source file. For example: Include the **hitracechain** header file in the class definition header file or class implementation source file. For example:
``` ```
#include "hitrace/trace.h" #include "hitrace/tracechain.h"
``` ```
Add the code to start and stop call chain tracing in the class implementation source file. Add the code to start and stop call chain tracing in the class implementation source file.
``` ```
using namespace OHOS::HiviewDFX; using namespace OHOS::HiviewDFX;
HiTraceId traceId = HiTrace::Begin("MyServiceFlow", HITRACE_FLAG_DEFAULT); auto traceId = HiTraceChain::Begin("MyServiceFlow", HITRACE_FLAG_DEFAULT);
... ...
HiTrace::End(traceId); HiTraceChain::End(traceId);
``` ```
2. Configure compilation information. Specifically, add the subsystem SDK dependency to **BUILD.gn**. 2. Configure compilation information. Specifically, add the subsystem SDK dependency to **BUILD.gn**.
``` ```
external_deps = [ "hiviewdfx:libhitrace" ] external_deps = [ "hiviewdfx:libhitracechain" ]
``` ```
...@@ -501,24 +503,24 @@ The process is as follows: ...@@ -501,24 +503,24 @@ The process is as follows:
1. Develop the source code. 1. Develop the source code.
Include the **hitrace** header file in the source file. Include the **hitracechain** header file in the source file.
``` ```
#include "hitrace/trace.h" #include "hitrace/tracechain.h"
``` ```
Add the code to start and stop call chain tracing in the class implementation source file. Add the code to start and stop call chain tracing in the class implementation source file.
``` ```
HiTraceIdStruct traceId = HiTraceBegin("MyServiceFlow", HITRACE_FLAG_DEFAULT); HiTraceIdStruct traceId = HiTraceChainBegin("MyServiceFlow", HITRACE_FLAG_DEFAULT);
... ...
HiTraceEnd(traceId); HiTraceChainEnd(traceId);
``` ```
2. Configure compilation information. Specifically, add the subsystem SDK dependency to **BUILD.gn**. 2. Configure compilation information. Specifically, add the subsystem SDK dependency to **BUILD.gn**.
``` ```
external_deps = [ "hiviewdfx:libhitrace" ] external_deps = [ "hiviewdfx:libhitracechain" ]
``` ```
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
只有app/Context中的方法属于FA模型对应的Context。该模式下,应用级别的Context和Ability级别的Context都是该类型的实例,如果在应用级别的Context里面调用了Ability级别的方法,会产生错误。所以开发者需要注意Context实例所代表的实际含义。 只有app/Context中的方法属于FA模型对应的Context。该模式下,应用级别的Context和Ability级别的Context都是该类型的实例,如果在应用级别的Context里面调用了Ability级别的方法,会产生错误。所以开发者需要注意Context实例所代表的实际含义。
- Stage模型 - Stage模型
除了app/Context之外的Context都属于Stage模型,分别有application/Context、application/ApplicationContext、application/AbilityStageContext、application/ExtensionContext、application/AbilityContext、application/FormExtensionContext等Context。这些Context的介绍及使用方式将会在[Stage模型和Context详细介绍](#stage模型和context详细介绍)中进行说明。 除了app/Context之外的Context都属于Stage模型,分别有application/Context、application/ApplicationContext、application/AbilityStageContext、application/ExtensionContext、application/AbilityContext、application/FormExtensionContext等Context。这些Context的介绍及使用方式将会在[Stage模型的Context详细介绍](#stage模型的context详细介绍)中进行说明。
![contextIntroduction](figures/contextIntroduction.png) ![contextIntroduction](figures/contextIntroduction.png)
...@@ -54,7 +54,7 @@ setDisplayOrientation(orientation: bundle.DisplayOrientation): Promise<void>; ...@@ -54,7 +54,7 @@ setDisplayOrientation(orientation: bundle.DisplayOrientation): Promise<void>;
示例: 示例:
```javascript ```javascript
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import bundle from '../@ohos.bundle'; import bundle from '@ohos.bundle';
export default { export default {
onCreate() { onCreate() {
...@@ -71,13 +71,13 @@ export default { ...@@ -71,13 +71,13 @@ export default {
} }
``` ```
## Stage模型Context详细介绍 ## Stage模型Context详细介绍
​ Stage模型有如下几类Context: ​ Stage模型有如下几类Context:
### application/Context ### application/Context
​ application/Context类型的Context是基类Context,里面提供了应用的一些基础信息:resourceManager、applicationInfo、cacheDir、area等,还有应用的一些基本方法:createBundleContext等。 ​ application/Context是基类Context。里面提供了应用的一些基础信息:resourceManager、applicationInfo、cacheDir、area等,还有应用的一些基本方法:createModuleContext等。
**d.ts声明** **d.ts声明**
......
...@@ -12,20 +12,20 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的 ...@@ -12,20 +12,20 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的
## 接口说明 ## 接口说明
| 接口名 | 接口描述 | | 接口名 | 接口描述 |
| ---------------------------------------------------------------------------------------------- | ----------- | | ---------------------------------------------------------------------------------------------- | ----------- |
| register(callback: AsyncCallback\<number>): void | 注册流转管理服务,并获取对应的注册token,无过滤条件(AsyncCallback)。 | | registerContinuation(callback: AsyncCallback\<number>): void | 注册流转管理服务,并获取对应的注册token,无过滤条件(AsyncCallback)。 |
| register(options: ContinuationExtraParams, callback: AsyncCallback\<number>): void | 注册流转管理服务,并获取对应的注册token(AsyncCallback)。 | | registerContinuation(options: ContinuationExtraParams, callback: AsyncCallback\<number>): void | 注册流转管理服务,并获取对应的注册token(AsyncCallback)。 |
| register(options?: ContinuationExtraParams): Promise\<number> | 连接流转管理服务,并获取对应的注册token(Promise)。 | | registerContinuation(options?: ContinuationExtraParams): Promise\<number> | 连接流转管理服务,并获取对应的注册token(Promise)。 |
| on(type: "deviceConnect", token: number, callback: Callback\<Array\<ContinuationResult>>): void | 监听设备连接状态(Callback)。 | | on(type: "deviceConnect", token: number, callback: Callback\<Array\<ContinuationResult>>): void | 监听设备连接状态(Callback)。 |
| on(type: "deviceDisconnect", token: number, callback: Callback\<Array\<string>>): void | 监听设备断开状态(Callback)。 | | on(type: "deviceDisconnect", token: number, callback: Callback\<Array\<string>>): void | 监听设备断开状态(Callback)。 |
| off(type: "deviceConnect", token: number): void | 取消监听设备连接状态。 | | off(type: "deviceConnect", token: number): void | 取消监听设备连接状态。 |
| off(type: "deviceDisconnect", token: number): void | 取消监听设备断开状态。 | | off(type: "deviceDisconnect", token: number): void | 取消监听设备断开状态。 |
| startDeviceManager(token: number, callback: AsyncCallback\<void>): void | 拉起设备选择模块,可显示组网内可选择设备列表信息,无过滤条件(AsyncCallback)。 | | startContinuationDeviceManager(token: number, callback: AsyncCallback\<void>): void | 拉起设备选择模块,可显示组网内可选择设备列表信息,无过滤条件(AsyncCallback)。 |
| startDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\<void>): void | 拉起设备选择模块,可显示组网内可选择设备列表信息(AsyncCallback)。 | | startContinuationDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\<void>): void | 拉起设备选择模块,可显示组网内可选择设备列表信息(AsyncCallback)。 |
| startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<void> | 拉起设备选择模块,可显示组网内可选择设备列表信息(Promise)。 | | startContinuationDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<void> | 拉起设备选择模块,可显示组网内可选择设备列表信息(Promise)。 |
| updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\<void>): void | 通知设备选择模块,更新当前的流转状态(AsyncCallback)。 | | updateContinuationState(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\<void>): void | 通知设备选择模块,更新当前的流转状态(AsyncCallback)。 |
| updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState): Promise\<void> | 通知设备选择模块,更新当前的流转状态(Promise)。 | | updateContinuationState(token: number, deviceId: string, status: DeviceConnectState): Promise\<void> | 通知设备选择模块,更新当前的流转状态(Promise)。 |
| unregister(token: number, callback: AsyncCallback\<void>): void | 取消注册流转管理服务,传入注册时获取的token进行取消注册(AsyncCallback)。 | | unregisterContinuation(token: number, callback: AsyncCallback\<void>): void | 取消注册流转管理服务,传入注册时获取的token进行取消注册(AsyncCallback)。 |
| unregister(token: number): Promise\<void> | 取消注册流转管理服务,传入注册时获取的token进行取消注册(Promise)。 | | unregisterContinuation(token: number): Promise\<void> | 取消注册流转管理服务,传入注册时获取的token进行取消注册(Promise)。 |
## 开发步骤 ## 开发步骤
1. 导入continuationManager模块。 1. 导入continuationManager模块。
...@@ -138,13 +138,16 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的 ...@@ -138,13 +138,16 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的
```ts ```ts
let token: number = -1; // 用于保存注册成功并返回的token,后续使用其完成监听设备连接/断开状态、拉起设备选择模块以及更新流转状态的动作 let token: number = -1; // 用于保存注册成功并返回的token,后续使用其完成监听设备连接/断开状态、拉起设备选择模块以及更新流转状态的动作
try {
continuationManager.register().then((data) => { continuationManager.registerContinuation().then((data) => {
console.info('register finished, ' + JSON.stringify(data)); console.info('registerContinuation finished, ' + JSON.stringify(data));
token = data; // 获取到对应的注册token,并赋值给token变量 token = data; // 获取到对应的注册token,并赋值给token变量
}).catch((err) => { }).catch((err) => {
console.error('register failed, cause: ' + JSON.stringify(err)); console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
}); });
} catch (err) {
console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
}
``` ```
4. 监听设备状态。 4. 监听设备状态。
...@@ -154,6 +157,7 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的 ...@@ -154,6 +157,7 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的
```ts ```ts
let remoteDeviceId: string = ""; // 用于保存用户选择的远端设备信息,后续使用其完成跨端迁移或多端协同操作 let remoteDeviceId: string = ""; // 用于保存用户选择的远端设备信息,后续使用其完成跨端迁移或多端协同操作
try {
// 参数token为注册token // 参数token为注册token
continuationManager.on("deviceConnect", token, (continuationResults) => { continuationManager.on("deviceConnect", token, (continuationResults) => {
console.info('registerDeviceConnectCallback len: ' + continuationResults.length); console.info('registerDeviceConnectCallback len: ' + continuationResults.length);
...@@ -176,6 +180,9 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的 ...@@ -176,6 +180,9 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的
console.error('StartRemoteAbility failed, cause: ' + JSON.stringify(err)); console.error('StartRemoteAbility failed, cause: ' + JSON.stringify(err));
}); });
}); });
} catch (err) {
console.error('on failed, cause: ' + JSON.stringify(err));
}
``` ```
上述多端协同操作为Stage平台的跨设备拉起,FA平台详情见[PageAbility开发指导](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ability/fa-pageability.md) 上述多端协同操作为Stage平台的跨设备拉起,FA平台详情见[PageAbility开发指导](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ability/fa-pageability.md)
...@@ -187,16 +194,21 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的 ...@@ -187,16 +194,21 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的
let deviceConnectStatus: continuationManager.DeviceConnectState = continuationManager.DeviceConnectState.CONNECTED; let deviceConnectStatus: continuationManager.DeviceConnectState = continuationManager.DeviceConnectState.CONNECTED;
// 参数token为注册token,参数remoteDeviceId为获取到的remoteDeviceId // 参数token为注册token,参数remoteDeviceId为获取到的remoteDeviceId
continuationManager.updateConnectStatus(token, remoteDeviceId, deviceConnectStatus).then((data) => { try {
console.info('updateConnectStatus finished, ' + JSON.stringify(data)); continuationManager.updateContinuationState(token, remoteDeviceId, deviceConnectStatus).then((data) => {
console.info('updateContinuationState finished, ' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.error('updateConnectStatus failed, cause: ' + JSON.stringify(err)); console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
}); });
} catch (err) {
console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
}
``` ```
监听设备断开状态,方便用户终止跨端迁移或多端协同操作,代码示例如下: 监听设备断开状态,方便用户终止跨端迁移或多端协同操作,代码示例如下:
```ts ```ts
try {
// 参数token为注册token // 参数token为注册token
continuationManager.on("deviceDisconnect", token, (deviceIds) => { continuationManager.on("deviceDisconnect", token, (deviceIds) => {
console.info('onDeviceDisconnect len: ' + deviceIds.length); console.info('onDeviceDisconnect len: ' + deviceIds.length);
...@@ -210,12 +222,15 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的 ...@@ -210,12 +222,15 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的
let deviceConnectStatus: continuationManager.DeviceConnectState = continuationManager.DeviceConnectState.DISCONNECTING; // 设备断开状态 let deviceConnectStatus: continuationManager.DeviceConnectState = continuationManager.DeviceConnectState.DISCONNECTING; // 设备断开状态
// 参数token为注册token,参数unselectedDeviceId为获取到的unselectedDeviceId // 参数token为注册token,参数unselectedDeviceId为获取到的unselectedDeviceId
continuationManager.updateConnectStatus(token, unselectedDeviceId, deviceConnectStatus).then((data) => { continuationManager.updateContinuationState(token, unselectedDeviceId, deviceConnectStatus).then((data) => {
console.info('updateConnectStatus finished, ' + JSON.stringify(data)); console.info('updateContinuationState finished, ' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.error('updateConnectStatus failed, cause: ' + JSON.stringify(err)); console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
}); });
}); });
} catch (err) {
console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
}
``` ```
5. 拉起设备选择模块,可显示组网内可选择设备列表信息,供用户选择。 5. 拉起设备选择模块,可显示组网内可选择设备列表信息,供用户选择。
...@@ -229,12 +244,16 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的 ...@@ -229,12 +244,16 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的
continuationMode: continuationManager.ContinuationMode.COLLABORATION_SINGLE // 设备选择模块单选模式 continuationMode: continuationManager.ContinuationMode.COLLABORATION_SINGLE // 设备选择模块单选模式
}; };
try {
// 参数token为注册token // 参数token为注册token
continuationManager.startDeviceManager(token, continuationExtraParams).then((data) => { continuationManager.startContinuationDeviceManager(token, continuationExtraParams).then((data) => {
console.info('startDeviceManager finished, ' + JSON.stringify(data)); console.info('startContinuationDeviceManager finished, ' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.error('startDeviceManager failed, cause: ' + JSON.stringify(err)); console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
}); });
} catch (err) {
console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
}
``` ```
6. 当用户不打算再进行跨端迁移或多端协同操作时,可以传入注册时获取的token进行取消注册。 6. 当用户不打算再进行跨端迁移或多端协同操作时,可以传入注册时获取的token进行取消注册。
...@@ -242,10 +261,14 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的 ...@@ -242,10 +261,14 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的
取消注册流转管理服务的代码示例如下: 取消注册流转管理服务的代码示例如下:
```ts ```ts
try {
// 参数token为注册token // 参数token为注册token
continuationManager.unregister(token).then((data) => { continuationManager.unregisterContinuation(token).then((data) => {
console.info('unregister finished, ' + JSON.stringify(data)); console.info('unregisterContinuation finished, ' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.error('unregister failed, cause: ' + JSON.stringify(err)); console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err));
}); });
} catch (err) {
console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err));
}
``` ```
\ No newline at end of file
...@@ -12,9 +12,9 @@ Ability支持单实例、多实例和指定实例3种启动模式,在module.js ...@@ -12,9 +12,9 @@ Ability支持单实例、多实例和指定实例3种启动模式,在module.js
| 启动模式 | 描述 |说明 | | 启动模式 | 描述 |说明 |
| ----------- | ------- |---------------- | | ----------- | ------- |---------------- |
| standard | 多实例 | 每次startAbility都会启动一个新的实例 | | standard | 标准模式 | 每次startAbility都会启动一个新的实例。 |
| singleton | 单实例 | 系统中只存在唯一一个实例,startAbility时,如果已存在,则复用系统中的唯一一个实例 | | singleton | 单实例模式 | 系统中只存在唯一一个实例,startAbility时,如果已存在,则复用系统中的唯一一个实例。 |
| specified | 指定实例 | 运行时由Ability内部业务决定是否创建多实例 | | specified | 指定实例 | 运行时由Ability内部业务决定是否创建多实例 |
缺省情况下是singleton模式,module.json5示例如下: 缺省情况下是singleton模式,module.json5示例如下:
```json ```json
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
+ **Standard**:每次startAbility调用,都会在应用进程中创建一个该类型的实例,如下图Ability2的两个实例; + **Standard**:每次startAbility调用,都会在应用进程中创建一个该类型的实例,如下图Ability2的两个实例;
+ **Specified**:允许开发者在系统创建AbilityRecord之前,为该实例创建一个key,后续每次创建该类型的Ability实例都会询问应用使用哪个key对应的Ability实例,来响应startAbility请求,如下图Ability3。 + **Specified**:允许开发者在系统创建Ability实例之前,为该实例创建一个key,后续每次创建该类型的Ability实例都会询问应用使用哪个key对应的Ability实例,来响应startAbility请求,如下图Ability3。
​ 每个Ability实例都对应了一个Launcher Recent中看到的Mission(任务)。 ​ 每个Ability实例都对应了一个Launcher Recent中看到的Mission(任务)。
......
...@@ -16,7 +16,7 @@ import ElementName from '@ohos.bundle'; ...@@ -16,7 +16,7 @@ import ElementName from '@ohos.bundle';
import image from '@ohos.multimedia.image'; import image from '@ohos.multimedia.image';
import missionManager from '@ohos.application.missionManager'; import missionManager from '@ohos.application.missionManager';
missionManager.getMissionInfos("", 10, (error, missions) => { missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code); console.log("getMissionInfos is called, error.code = " + error.code);
console.log("size = " + missions.length); console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions)); console.log("missions = " + JSON.stringify(missions));
...@@ -26,7 +26,7 @@ import missionManager from '@ohos.application.missionManager'; ...@@ -26,7 +26,7 @@ import missionManager from '@ohos.application.missionManager';
console.log("getMissionSnapShot is called, error.code = " + error.code); console.log("getMissionSnapShot is called, error.code = " + error.code);
console.log("bundleName = " + snapshot.ability.bundleName); console.log("bundleName = " + snapshot.ability.bundleName);
}) })
}) })
``` ```
## MissionSnapshot ## MissionSnapshot
......
...@@ -52,7 +52,7 @@ onAcceptWant(want: Want): string; ...@@ -52,7 +52,7 @@ onAcceptWant(want: Want): string;
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| string | 用户返回一个ability标识,如果之前启动过标识的ability,不创建新的实例并拉回栈顶,否则创建新的实例并启动。 | | string | 用户返回一个ability标识,如果之前启动过标识的ability,不创建新的实例并拉回栈顶,否则创建新的实例并启动。 |
**示例:** **示例:**
......
...@@ -10,16 +10,18 @@ continuationManager模块提供了流转/协同入口管理服务能力,包括 ...@@ -10,16 +10,18 @@ continuationManager模块提供了流转/协同入口管理服务能力,包括
## 导入模块 ## 导入模块
```js ```ts
import continuationManager from '@ohos.continuation.continuationManager' import continuationManager from '@ohos.continuation.continuationManager'
``` ```
## continuationManager.register ## continuationManager.register<sup>(deprecated)</sup>
register(callback: AsyncCallback\<number>): void; register(callback: AsyncCallback\<number>): void;
注册流转管理服务,并获取对应的注册token,无过滤条件,使用AsyncCallback方式作为异步方法。 注册流转管理服务,并获取对应的注册token,无过滤条件,使用AsyncCallback方式作为异步方法。
> 从API Version 9开始不再维护,建议使用[registerContinuation](#continuationmanagerregistercontinuation9)替代。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager **系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:** **参数:**
...@@ -30,7 +32,7 @@ register(callback: AsyncCallback\<number>): void; ...@@ -30,7 +32,7 @@ register(callback: AsyncCallback\<number>): void;
**示例:** **示例:**
```js ```ts
let token = -1; let token = -1;
continuationManager.register((err, data) => { continuationManager.register((err, data) => {
if (err.code != 0) { if (err.code != 0) {
...@@ -42,12 +44,14 @@ register(callback: AsyncCallback\<number>): void; ...@@ -42,12 +44,14 @@ register(callback: AsyncCallback\<number>): void;
}); });
``` ```
## continuationManager.register ## continuationManager.register<sup>(deprecated)</sup>
register(options: ContinuationExtraParams, callback: AsyncCallback\<number>): void; register(options: ContinuationExtraParams, callback: AsyncCallback\<number>): void;
连接流转管理服务,并获取对应的注册token,使用AsyncCallback方式作为异步方法。 连接流转管理服务,并获取对应的注册token,使用AsyncCallback方式作为异步方法。
> 从API Version 9开始不再维护,建议使用[registerContinuation](#continuationmanagerregistercontinuation9)替代。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager **系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:** **参数:**
...@@ -59,7 +63,7 @@ register(options: ContinuationExtraParams, callback: AsyncCallback\<number>): vo ...@@ -59,7 +63,7 @@ register(options: ContinuationExtraParams, callback: AsyncCallback\<number>): vo
**示例:** **示例:**
```js ```ts
let token = -1; let token = -1;
let continuationExtraParams = { let continuationExtraParams = {
deviceType: ["00E"] deviceType: ["00E"]
...@@ -74,12 +78,14 @@ register(options: ContinuationExtraParams, callback: AsyncCallback\<number>): vo ...@@ -74,12 +78,14 @@ register(options: ContinuationExtraParams, callback: AsyncCallback\<number>): vo
}); });
``` ```
## continuationManager.register ## continuationManager.register<sup>(deprecated)</sup>
register(options?: ContinuationExtraParams): Promise\<number>; register(options?: ContinuationExtraParams): Promise\<number>;
连接流转管理服务,并获取对应的注册token,使用Promise方式作为异步方法。 连接流转管理服务,并获取对应的注册token,使用Promise方式作为异步方法。
> 从API Version 9开始不再维护,建议使用[registerContinuation](#continuationmanagerregistercontinuation9)替代。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager **系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:** **参数:**
...@@ -96,7 +102,7 @@ register(options?: ContinuationExtraParams): Promise\<number>; ...@@ -96,7 +102,7 @@ register(options?: ContinuationExtraParams): Promise\<number>;
**示例:** **示例:**
```js ```ts
let token = -1; let token = -1;
let continuationExtraParams = { let continuationExtraParams = {
deviceType: ["00E"] deviceType: ["00E"]
...@@ -111,6 +117,116 @@ register(options?: ContinuationExtraParams): Promise\<number>; ...@@ -111,6 +117,116 @@ register(options?: ContinuationExtraParams): Promise\<number>;
}); });
``` ```
## continuationManager.registerContinuation<sup>9+</sup>
registerContinuation(callback: AsyncCallback\<number>): void;
注册流转管理服务,并获取对应的注册token,无过滤条件,使用AsyncCallback方式作为异步方法。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<number> | 是 | AsyncCallback形式返回流转管理服务连接后生成的token。 |
**示例:**
```ts
let token = -1;
try {
continuationManager.registerContinuation((err, data) => {
if (err.code != 0) {
console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
return;
}
console.info('registerContinuation finished, ' + JSON.stringify(data));
token = data;
});
} catch (err) {
console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
}
```
## continuationManager.registerContinuation<sup>9+</sup>
registerContinuation(options: ContinuationExtraParams, callback: AsyncCallback\<number>): void;
连接流转管理服务,并获取对应的注册token,使用AsyncCallback方式作为异步方法。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | 是 | 过滤可选择设备列表的额外参数。 |
| callback | AsyncCallback\<number> | 是 | AsyncCallback形式返回流转管理服务连接后生成的token。 |
**示例:**
```ts
let token = -1;
let continuationExtraParams = {
deviceType: ["00E"]
};
try {
continuationManager.registerContinuation(continuationExtraParams, (err, data) => {
if (err.code != 0) {
console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
return;
}
console.info('registerContinuation finished, ' + JSON.stringify(data));
token = data;
});
} catch (err) {
console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
}
```
## continuationManager.registerContinuation<sup>9+</sup>
registerContinuation(options?: ContinuationExtraParams): Promise\<number>;
连接流转管理服务,并获取对应的注册token,使用Promise方式作为异步方法。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | 否 | 过滤可选择设备列表的额外参数,该参数可缺省|
**返回值:**
| 类型 | 说明 |
| ------------------------- | ------------------ |
| Promise\<number> | Promise形式返回流转管理服务连接后生成的token。 |
**示例:**
```ts
let token = -1;
let continuationExtraParams = {
deviceType: ["00E"]
};
try {
continuationManager.register(continuationExtraParams)
.then((data) => {
console.info('registerContinuation finished, ' + JSON.stringify(data));
token = data;
})
.catch((err) => {
console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
});
} catch (err) {
console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
}
```
## continuationManager.on("deviceConnect")<sup>(deprecated)</sup> ## continuationManager.on("deviceConnect")<sup>(deprecated)</sup>
on(type: "deviceConnect", callback: Callback\<ContinuationResult>): void; on(type: "deviceConnect", callback: Callback\<ContinuationResult>): void;
...@@ -130,7 +246,7 @@ on(type: "deviceConnect", callback: Callback\<ContinuationResult>): void; ...@@ -130,7 +246,7 @@ on(type: "deviceConnect", callback: Callback\<ContinuationResult>): void;
**示例:** **示例:**
```js ```ts
continuationManager.on("deviceConnect", (data) => { continuationManager.on("deviceConnect", (data) => {
console.info('onDeviceConnect deviceId: ' + JSON.stringify(data.id)); console.info('onDeviceConnect deviceId: ' + JSON.stringify(data.id));
console.info('onDeviceConnect deviceType: ' + JSON.stringify(data.type)); console.info('onDeviceConnect deviceType: ' + JSON.stringify(data.type));
...@@ -157,7 +273,7 @@ on(type: "deviceDisconnect", callback: Callback\<string>): void; ...@@ -157,7 +273,7 @@ on(type: "deviceDisconnect", callback: Callback\<string>): void;
**示例:** **示例:**
```js ```ts
continuationManager.on("deviceDisconnect", (data) => { continuationManager.on("deviceDisconnect", (data) => {
console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data)); console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data));
}); });
...@@ -182,7 +298,7 @@ off(type: "deviceConnect", callback?: Callback\<ContinuationResult>): void; ...@@ -182,7 +298,7 @@ off(type: "deviceConnect", callback?: Callback\<ContinuationResult>): void;
**示例:** **示例:**
```js ```ts
continuationManager.off("deviceConnect", (data) => { continuationManager.off("deviceConnect", (data) => {
console.info('onDeviceConnect deviceId: ' + JSON.stringify(data.id)); console.info('onDeviceConnect deviceId: ' + JSON.stringify(data.id));
console.info('onDeviceConnect deviceType: ' + JSON.stringify(data.type)); console.info('onDeviceConnect deviceType: ' + JSON.stringify(data.type));
...@@ -209,7 +325,7 @@ off(type: "deviceDisconnect", callback?: Callback\<string>): void; ...@@ -209,7 +325,7 @@ off(type: "deviceDisconnect", callback?: Callback\<string>): void;
**示例:** **示例:**
```js ```ts
continuationManager.off("deviceDisconnect", (data) => { continuationManager.off("deviceDisconnect", (data) => {
console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data)); console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data));
}); });
...@@ -233,8 +349,9 @@ on(type: "deviceConnect", token: number, callback: Callback\<Array\<Continuation ...@@ -233,8 +349,9 @@ on(type: "deviceConnect", token: number, callback: Callback\<Array\<Continuation
**示例:** **示例:**
```js ```ts
let token = 1; let token = 1;
try {
continuationManager.on("deviceConnect", token, (data) => { continuationManager.on("deviceConnect", token, (data) => {
console.info('onDeviceConnect len: ' + data.length); console.info('onDeviceConnect len: ' + data.length);
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
...@@ -243,6 +360,9 @@ on(type: "deviceConnect", token: number, callback: Callback\<Array\<Continuation ...@@ -243,6 +360,9 @@ on(type: "deviceConnect", token: number, callback: Callback\<Array\<Continuation
console.info('onDeviceConnect deviceName: ' + JSON.stringify(data[i].name)); console.info('onDeviceConnect deviceName: ' + JSON.stringify(data[i].name));
} }
}); });
} catch (err) {
console.error('on failed, cause: ' + JSON.stringify(err));
}
``` ```
## continuationManager.on("deviceDisconnect")<sup>9+</sup> ## continuationManager.on("deviceDisconnect")<sup>9+</sup>
...@@ -263,8 +383,9 @@ on(type: "deviceDisconnect", token: number, callback: Callback\<Array\<string>>) ...@@ -263,8 +383,9 @@ on(type: "deviceDisconnect", token: number, callback: Callback\<Array\<string>>)
**示例:** **示例:**
```js ```ts
let token = 1; let token = 1;
try {
continuationManager.on("deviceDisconnect", token, (data) => { continuationManager.on("deviceDisconnect", token, (data) => {
console.info('onDeviceDisconnect len: ' + data.length); console.info('onDeviceDisconnect len: ' + data.length);
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
...@@ -272,6 +393,9 @@ on(type: "deviceDisconnect", token: number, callback: Callback\<Array\<string>>) ...@@ -272,6 +393,9 @@ on(type: "deviceDisconnect", token: number, callback: Callback\<Array\<string>>)
} }
console.info('onDeviceDisconnect finished.'); console.info('onDeviceDisconnect finished.');
}); });
} catch (err) {
console.error('on failed, cause: ' + JSON.stringify(err));
}
``` ```
## continuationManager.off("deviceConnect")<sup>9+</sup> ## continuationManager.off("deviceConnect")<sup>9+</sup>
...@@ -291,9 +415,13 @@ off(type: "deviceConnect", token: number): void; ...@@ -291,9 +415,13 @@ off(type: "deviceConnect", token: number): void;
**示例:** **示例:**
```js ```ts
let token = 1; let token = 1;
try {
continuationManager.off("deviceConnect", token); continuationManager.off("deviceConnect", token);
} catch (err) {
console.error('off failed, cause: ' + JSON.stringify(err));
}
``` ```
## continuationManager.off("deviceDisconnect")<sup>9+</sup> ## continuationManager.off("deviceDisconnect")<sup>9+</sup>
...@@ -313,17 +441,23 @@ off(type: "deviceDisconnect", token: number): void; ...@@ -313,17 +441,23 @@ off(type: "deviceDisconnect", token: number): void;
**示例:** **示例:**
```js ```ts
let token = 1; let token = 1;
try {
continuationManager.off("deviceDisconnect", token); continuationManager.off("deviceDisconnect", token);
} catch (err) {
console.error('off failed, cause: ' + JSON.stringify(err));
}
``` ```
## continuationManager.startDeviceManager ## continuationManager.startDeviceManager<sup>(deprecated)</sup>
startDeviceManager(token: number, callback: AsyncCallback\<void>): void; startDeviceManager(token: number, callback: AsyncCallback\<void>): void;
拉起设备选择模块,可显示组网内可选择设备列表信息,无过滤条件,使用AsyncCallback方式作为异步方法。 拉起设备选择模块,可显示组网内可选择设备列表信息,无过滤条件,使用AsyncCallback方式作为异步方法。
> 从API Version 9开始不再维护,建议使用[startContinuationDeviceManager](#continuationmanagerondeviceconnect9)替代。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager **系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:** **参数:**
...@@ -335,7 +469,7 @@ startDeviceManager(token: number, callback: AsyncCallback\<void>): void; ...@@ -335,7 +469,7 @@ startDeviceManager(token: number, callback: AsyncCallback\<void>): void;
**示例:** **示例:**
```js ```ts
let token = 1; let token = 1;
continuationManager.startDeviceManager(token, (err, data) => { continuationManager.startDeviceManager(token, (err, data) => {
if (err.code != 0) { if (err.code != 0) {
...@@ -346,12 +480,14 @@ startDeviceManager(token: number, callback: AsyncCallback\<void>): void; ...@@ -346,12 +480,14 @@ startDeviceManager(token: number, callback: AsyncCallback\<void>): void;
}); });
``` ```
## continuationManager.startDeviceManager ## continuationManager.startDeviceManager<sup>(deprecated)</sup>
startDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\<void>): void; startDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\<void>): void;
拉起设备选择模块,可显示组网内可选择设备列表信息,使用AsyncCallback方式作为异步方法。 拉起设备选择模块,可显示组网内可选择设备列表信息,使用AsyncCallback方式作为异步方法。
> 从API Version 9开始不再维护,建议使用[startContinuationDeviceManager](#continuationmanagerstartcontinuationdevicemanager9)替代。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager **系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:** **参数:**
...@@ -364,7 +500,7 @@ startDeviceManager(token: number, options: ContinuationExtraParams, callback: As ...@@ -364,7 +500,7 @@ startDeviceManager(token: number, options: ContinuationExtraParams, callback: As
**示例:** **示例:**
```js ```ts
let token = 1; let token = 1;
let continuationExtraParams = { let continuationExtraParams = {
deviceType: ["00E"] deviceType: ["00E"]
...@@ -378,12 +514,14 @@ startDeviceManager(token: number, options: ContinuationExtraParams, callback: As ...@@ -378,12 +514,14 @@ startDeviceManager(token: number, options: ContinuationExtraParams, callback: As
}); });
``` ```
## continuationManager.startDeviceManager ## continuationManager.startDeviceManager<sup>(deprecated)</sup>
startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<void>; startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<void>;
拉起设备选择模块,可显示组网内可选择设备列表信息,使用Promise方式作为异步方法。 拉起设备选择模块,可显示组网内可选择设备列表信息,使用Promise方式作为异步方法。
> 从API Version 9开始不再维护,建议使用[startContinuationDeviceManager](#continuationmanagerstartcontinuationdevicemanager9)替代。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager **系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:** **参数:**
...@@ -401,7 +539,7 @@ startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<v ...@@ -401,7 +539,7 @@ startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<v
**示例:** **示例:**
```js ```ts
let token = 1; let token = 1;
let continuationExtraParams = { let continuationExtraParams = {
deviceType: ["00E"] deviceType: ["00E"]
...@@ -415,12 +553,123 @@ startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<v ...@@ -415,12 +553,123 @@ startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<v
}); });
``` ```
## continuationManager.updateConnectStatus ## continuationManager.startContinuationDeviceManager<sup>9+</sup>
startContinuationDeviceManager(token: number, callback: AsyncCallback\<void>): void;
拉起设备选择模块,可显示组网内可选择设备列表信息,无过滤条件,使用AsyncCallback方式作为异步方法。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| token | number | 是 | 注册后的token。 |
| callback | AsyncCallback\<void> | 是 | AsyncCallback形式返回接口调用结果。 |
**示例:**
```ts
let token = 1;
try {
continuationManager.startContinuationDeviceManager(token, (err, data) => {
if (err.code != 0) {
console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
return;
}
console.info('startContinuationDeviceManager finished, ' + JSON.stringify(data));
});
} catch (err) {
console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
}
```
## continuationManager.startContinuationDeviceManager<sup>9+</sup>
startContinuationDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\<void>): void;
拉起设备选择模块,可显示组网内可选择设备列表信息,使用AsyncCallback方式作为异步方法。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| token | number | 是 | 注册后的token。 |
| options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | 是 | 过滤可选择设备列表的额外参数。 |
| callback | AsyncCallback\<void> | 是 | AsyncCallback形式返回接口调用结果。 |
**示例:**
```ts
let token = 1;
let continuationExtraParams = {
deviceType: ["00E"]
};
try {
continuationManager.startContinuationDeviceManager(token, continuationExtraParams, (err, data) => {
if (err.code != 0) {
console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
return;
}
console.info('startContinuationDeviceManager finished, ' + JSON.stringify(data));
});
} catch (err) {
console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
}
```
## continuationManager.startContinuationDeviceManager<sup>9+</sup>
startContinuationDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<void>;
拉起设备选择模块,可显示组网内可选择设备列表信息,使用Promise方式作为异步方法。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| token | number | 是 | 注册后的token。 |
| options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | 否 | 过滤可选择设备列表的额外参数,该参数可缺省|
**返回值:**
| 类型 | 说明 |
| ------------------------- | ------------------ |
| Promise\<void> | Promise形式返回接口调用结果。 |
**示例:**
```ts
let token = 1;
let continuationExtraParams = {
deviceType: ["00E"]
};
try {
continuationManager.startContinuationDeviceManager(token, continuationExtraParams)
.then((data) => {
console.info('startContinuationDeviceManager finished, ' + JSON.stringify(data));
})
.catch((err) => {
console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
});
} catch (err) {
console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
}
```
## continuationManager.updateConnectStatus<sup>(deprecated)</sup>
updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\<void>): void; updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\<void>): void;
通知设备选择模块,更新当前的连接状态,使用AsyncCallback方式作为异步方法。 通知设备选择模块,更新当前的连接状态,使用AsyncCallback方式作为异步方法。
> 从API Version 9开始不再维护,建议使用[updateContinuationState](#continuationmanagerupdatecontinuationstate9)替代。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager **系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:** **参数:**
...@@ -434,7 +683,7 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, ...@@ -434,7 +683,7 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState,
**示例:** **示例:**
```js ```ts
let token = 1; let token = 1;
let deviceId: string = "test deviceId"; let deviceId: string = "test deviceId";
continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED, (err, data) => { continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED, (err, data) => {
...@@ -446,12 +695,14 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, ...@@ -446,12 +695,14 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState,
}); });
``` ```
## continuationManager.updateConnectStatus ## continuationManager.updateConnectStatus<sup>(deprecated)</sup>
updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState): Promise\<void>; updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState): Promise\<void>;
通知设备选择模块,更新当前的连接状态,使用Promise方式作为异步方法。 通知设备选择模块,更新当前的连接状态,使用Promise方式作为异步方法。
> 从API Version 9开始不再维护,建议使用[updateContinuationState](#continuationmanagerupdatecontinuationstate9)替代。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager **系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:** **参数:**
...@@ -470,7 +721,7 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState) ...@@ -470,7 +721,7 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState)
**示例:** **示例:**
```js ```ts
let token = 1; let token = 1;
let deviceId: string = "test deviceId"; let deviceId: string = "test deviceId";
continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED) continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED)
...@@ -482,12 +733,90 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState) ...@@ -482,12 +733,90 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState)
}); });
``` ```
## continuationManager.unregister ## continuationManager.updateContinuationState<sup>9+</sup>
updateContinuationState(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\<void>): void;
通知设备选择模块,更新当前的连接状态,使用AsyncCallback方式作为异步方法。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| token | number | 是 | 注册后的token。 |
| deviceId | string | 是 | 设备ID。 |
| status | [DeviceConnectState](#deviceconnectstate) | 是 | 设备连接状态。 |
| callback | AsyncCallback\<void> | 是 | AsyncCallback形式返回接口调用结果。 |
**示例:**
```ts
let token = 1;
let deviceId: string = "test deviceId";
try {
continuationManager.updateContinuationState(token, deviceId, continuationManager.DeviceConnectState.CONNECTED, (err, data) => {
if (err.code != 0) {
console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
return;
}
console.info('updateContinuationState finished, ' + JSON.stringify(data));
});
} catch (err) {
console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
}
```
## continuationManager.updateContinuationState<sup>9+</sup>
updateContinuationState(token: number, deviceId: string, status: DeviceConnectState): Promise\<void>;
通知设备选择模块,更新当前的连接状态,使用Promise方式作为异步方法。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| token | number | 是 | 注册后的token。 |
| deviceId | string | 是 | 设备ID。 |
| status | [DeviceConnectState](#deviceconnectstate) | 是 | 设备连接状态。 |
**返回值:**
| 类型 | 说明 |
| ------------------------- | ------------------ |
| Promise\<void> | Promise形式返回接口调用结果。 |
**示例:**
```ts
let token = 1;
let deviceId: string = "test deviceId";
try {
continuationManager.updateContinuationState(token, deviceId, continuationManager.DeviceConnectState.CONNECTED)
.then((data) => {
console.info('updateContinuationState finished, ' + JSON.stringify(data));
})
.catch((err) => {
console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
});
} catch (err) {
console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
}
```
## continuationManager.unregister<sup>(deprecated)</sup>
unregister(token: number, callback: AsyncCallback\<void>): void; unregister(token: number, callback: AsyncCallback\<void>): void;
解注册流转管理服务,传入注册时获取的token进行解注册,使用AsyncCallback方式作为异步方法。 解注册流转管理服务,传入注册时获取的token进行解注册,使用AsyncCallback方式作为异步方法。
> 从API Version 9开始不再维护,建议使用[unregisterContinuation](#continuationmanagerunregistercontinuation9)替代。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager **系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:** **参数:**
...@@ -499,7 +828,7 @@ unregister(token: number, callback: AsyncCallback\<void>): void; ...@@ -499,7 +828,7 @@ unregister(token: number, callback: AsyncCallback\<void>): void;
**示例:** **示例:**
```js ```ts
let token = 1; let token = 1;
continuationManager.unregister(token, (err, data) => { continuationManager.unregister(token, (err, data) => {
if (err.code != 0) { if (err.code != 0) {
...@@ -510,12 +839,14 @@ unregister(token: number, callback: AsyncCallback\<void>): void; ...@@ -510,12 +839,14 @@ unregister(token: number, callback: AsyncCallback\<void>): void;
}); });
``` ```
## continuationManager.unregister ## continuationManager.unregister<sup>(deprecated)</sup>
unregister(token: number): Promise\<void>; unregister(token: number): Promise\<void>;
解注册流转管理服务,传入注册时获取的token进行解注册,使用Promise方式作为异步方法。 解注册流转管理服务,传入注册时获取的token进行解注册,使用Promise方式作为异步方法。
> 从API Version 9开始不再维护,建议使用[unregisterContinuation](#continuationmanagerunregistercontinuation9)替代。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager **系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:** **参数:**
...@@ -532,7 +863,7 @@ unregister(token: number): Promise\<void>; ...@@ -532,7 +863,7 @@ unregister(token: number): Promise\<void>;
**示例:** **示例:**
```js ```ts
let token = 1; let token = 1;
continuationManager.unregister(token) continuationManager.unregister(token)
.then((data) => { .then((data) => {
...@@ -543,6 +874,76 @@ unregister(token: number): Promise\<void>; ...@@ -543,6 +874,76 @@ unregister(token: number): Promise\<void>;
}); });
``` ```
## continuationManager.unregisterContinuation<sup>9+</sup>
unregisterContinuation(token: number, callback: AsyncCallback\<void>): void;
解注册流转管理服务,传入注册时获取的token进行解注册,使用AsyncCallback方式作为异步方法。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| token | number | 是 | 注册后的token。 |
| callback | AsyncCallback\<void> | 是 | AsyncCallback形式返回接口调用结果。 |
**示例:**
```ts
let token = 1;
try {
continuationManager.unregisterContinuation(token, (err, data) => {
if (err.code != 0) {
console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err));
return;
}
console.info('unregisterContinuation finished, ' + JSON.stringify(data));
});
} catch (err) {
console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err));
}
```
## continuationManager.unregisterContinuation<sup>9+</sup>
unregisterContinuation(token: number): Promise\<void>;
解注册流转管理服务,传入注册时获取的token进行解注册,使用Promise方式作为异步方法。
**系统能力**:SystemCapability.Ability.DistributedAbilityManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| token | number | 是 | 注册后的token。 |
**返回值:**
| 类型 | 说明 |
| ------------------------- | ------------------ |
| Promise\<void> | Promise形式返回接口调用结果。 |
**示例:**
```ts
let token = 1;
try {
continuationManager.unregisterContinuation(token)
.then((data) => {
console.info('unregisterContinuation finished, ' + JSON.stringify(data));
})
.catch((err) => {
console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err));
});
} catch (err) {
console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err));
}
```
## DeviceConnectState ## DeviceConnectState
设备连接状态。 设备连接状态。
......
# 分布式任务管理 # 分布式任务管理
分布式任务管理模块提供跨设备系统任务管理能力,包括注册系统任务状态监听、取消系统任务状态监听、开始同步远端任务列表、停止同步远端任务列表操作。 分布式任务管理模块提供跨设备系统任务管理能力,包括注册系统任务状态监听、取消系统任务状态监听、开始同步远端任务列表、停止同步远端任务列表、迁移任务操作。
> **说明:** > **说明:**
> >
...@@ -55,9 +55,16 @@ registerMissionListener(parameter: MissionDeviceInfo, options: MissionCallback, ...@@ -55,9 +55,16 @@ registerMissionListener(parameter: MissionDeviceInfo, options: MissionCallback,
notifySnapshot: NotifySnapshot, notifySnapshot: NotifySnapshot,
notifyNetDisconnect: NotifyNetDisconnect notifyNetDisconnect: NotifyNetDisconnect
} }
try {
distributedMissionManager.registerMissionListener(parameter, options, (error) => { distributedMissionManager.registerMissionListener(parameter, options, (error) => {
console.log("error.code = " + error.code) if (error.code != 0) {
console.error('registerMissionListener failed, cause: ' + JSON.stringify(error))
}
console.info('registerMissionListener finished')
}) })
} catch (error) {
console.error('registerMissionListener failed, cause: ' + JSON.stringify(error))
}
``` ```
## distributedMissionManager.registerMissionListener ## distributedMissionManager.registerMissionListener
...@@ -104,12 +111,16 @@ registerMissionListener(parameter: MissionDeviceInfo, options: MissionCallback): ...@@ -104,12 +111,16 @@ registerMissionListener(parameter: MissionDeviceInfo, options: MissionCallback):
notifySnapshot: NotifySnapshot, notifySnapshot: NotifySnapshot,
notifyNetDisconnect: NotifyNetDisconnect notifyNetDisconnect: NotifyNetDisconnect
} }
try {
distributedMissionManager.registerMissionListener(parameter, options) distributedMissionManager.registerMissionListener(parameter, options)
.then(data => { .then(data => {
console.info('success data is ' + data); console.info('registerMissionListener finished, ' + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.info('error error is ' + error); console.error('registerMissionListener failed, cause: ' + JSON.stringify(error));
}) })
} catch (error) {
console.error('registerMissionListener failed, cause: ' + JSON.stringify(error))
}
``` ```
...@@ -136,9 +147,16 @@ unRegisterMissionListener(parameter: MissionDeviceInfo, callback: AsyncCallback& ...@@ -136,9 +147,16 @@ unRegisterMissionListener(parameter: MissionDeviceInfo, callback: AsyncCallback&
var parameter = { var parameter = {
deviceId: remoteDeviceId deviceId: remoteDeviceId
}; };
try {
distributedMissionManager.unRegisterMissionListener(parameter, (error) => { distributedMissionManager.unRegisterMissionListener(parameter, (error) => {
console.log("error.code = " + error.code) if (error.code != 0) {
console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error))
}
console.info('unRegisterMissionListener finished')
}) })
} catch (error) {
console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error))
}
``` ```
...@@ -170,12 +188,16 @@ unRegisterMissionListener(parameter: MissionDeviceInfo): Promise&lt;void&gt; ...@@ -170,12 +188,16 @@ unRegisterMissionListener(parameter: MissionDeviceInfo): Promise&lt;void&gt;
var parameter = { var parameter = {
deviceId: remoteDeviceId deviceId: remoteDeviceId
}; };
try {
distributedMissionManager.unRegisterMissionListener(parameter) distributedMissionManager.unRegisterMissionListener(parameter)
.then(data => { .then(data => {
console.info('success data is ' + data); console.info('unRegisterMissionListener finished, ' + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.info('error error is ' + error); console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error));
}) })
} catch (error) {
console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error))
}
``` ```
## distributedMissionManager.startSyncRemoteMissions ## distributedMissionManager.startSyncRemoteMissions
...@@ -203,9 +225,16 @@ startSyncRemoteMissions(parameter: MissionParameter, callback: AsyncCallback&lt; ...@@ -203,9 +225,16 @@ startSyncRemoteMissions(parameter: MissionParameter, callback: AsyncCallback&lt;
fixConflict: false, fixConflict: false,
tag: 0 tag: 0
}; };
try {
distributedMissionManager.startSyncRemoteMissions(parameter, (error) => { distributedMissionManager.startSyncRemoteMissions(parameter, (error) => {
console.log("error.code = " + error.code) if (error.code != 0) {
console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error))
}
console.info('startSyncRemoteMissions finished')
}) })
} catch (error) {
console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error))
}
``` ```
## distributedMissionManager.startSyncRemoteMissions ## distributedMissionManager.startSyncRemoteMissions
...@@ -238,12 +267,16 @@ startSyncRemoteMissions(parameter: MissionParameter): Promise&lt;void&gt; ...@@ -238,12 +267,16 @@ startSyncRemoteMissions(parameter: MissionParameter): Promise&lt;void&gt;
fixConflict: false, fixConflict: false,
tag: 0 tag: 0
}; };
try {
distributedMissionManager.startSyncRemoteMissions(parameter) distributedMissionManager.startSyncRemoteMissions(parameter)
.then(data => { .then(data => {
console.info('success data is ' + data); console.info('startSyncRemoteMissions finished, ' + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.info('error error is ' + error); console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error));
}) })
} catch (error) {
console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error))
}
``` ```
## distributedMissionManager.stopSyncRemoteMissions ## distributedMissionManager.stopSyncRemoteMissions
...@@ -269,9 +302,16 @@ stopSyncRemoteMissions(parameter: MissionDeviceInfo, callback: AsyncCallback&lt; ...@@ -269,9 +302,16 @@ stopSyncRemoteMissions(parameter: MissionDeviceInfo, callback: AsyncCallback&lt;
var parameter = { var parameter = {
deviceId: remoteDeviceId deviceId: remoteDeviceId
}; };
try {
distributedMissionManager.stopSyncRemoteMissions(parameter, (error) => { distributedMissionManager.stopSyncRemoteMissions(parameter, (error) => {
console.log("error.code = " + error.code) if (error.code != 0) {
console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error))
}
console.info('stopSyncRemoteMissions finished')
}) })
} catch (error) {
console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error))
}
``` ```
## distributedMissionManager.stopSyncRemoteMissions ## distributedMissionManager.stopSyncRemoteMissions
...@@ -302,12 +342,111 @@ stopSyncRemoteMissions(parameter: MissionDeviceInfo): Promise&lt;void&gt; ...@@ -302,12 +342,111 @@ stopSyncRemoteMissions(parameter: MissionDeviceInfo): Promise&lt;void&gt;
var parameter = { var parameter = {
deviceId: remoteDeviceId deviceId: remoteDeviceId
}; };
try {
distributedMissionManager.stopSyncRemoteMissions(parameter) distributedMissionManager.stopSyncRemoteMissions(parameter)
.then(data => { .then(data => {
console.info('success data is ' + data); console.info('stopSyncRemoteMissions finished, ' + JSON.stringify(data));
}).catch(error => {
console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error));
})
} catch (error) {
console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error))
}
```
## distributedMissionManager.continueMission
continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback, callback: AsyncCallback&lt;void&gt;): void;
迁移任务,以回调函数的方式返回。
**需要权限**:ohos.permission.MANAGE_MISSIONS, ohos.permission.DISTRIBUTED_DATASYNC
**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | --------------------------------------- | ---- | ----- |
| parameter | [ContinueDeviceInfo](#continuedeviceinfo) | 是 | 迁移信息。 |
| options | [ContinueCallback](#continuecallback) | 是 | 迁移任务完成回调函数。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 执行结果回调函数。 |
**示例:**
```ts
var parameter = {
srcDeviceId: localDeviceId
dstDeviceId: remoteDeviceId
missionId: remoteMissionId
wantParams: {"key": "value"}
};
function OnContinueDone(resultCode) {
console.log('OnContinueDone resultCode: ' + JSON.stringify(resultCode));
};
var options = {
OnContinueDone: OnContinueDone
};
try {
distributedMissionManager.continueMission(parameter, options, (error) => {
if (error.code != 0) {
console.error('continueMission failed, cause: ' + JSON.stringify(error))
}
console.info('continueMission finished')
})
} catch (error) {
console.error('continueMission failed, cause: ' + JSON.stringify(error))
}
```
## distributedMissionManager.continueMission
continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback): Promise&lt;void&gt;
迁移任务,以promise方式返回执行结果。
**需要权限**:ohos.permission.MANAGE_MISSIONS, ohos.permission.DISTRIBUTED_DATASYNC
**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | --------------------------------------- | ---- | ----- |
| parameter | [ContinueDeviceInfo](#continuedeviceinfo) | 是 | 迁移信息。 |
| options | [ContinueCallback](#continuecallback) | 是 | 迁移任务完成回调函数。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------- |
| Promise&lt;void&gt; | promise方式返回执行结果。 |
**示例:**
```ts
var parameter = {
srcDeviceId: localDeviceId
dstDeviceId: remoteDeviceId
missionId: remoteMissionId
wantParams: {"key": "value"}
};
function OnContinueDone(resultCode) {
console.log('OnContinueDone resultCode: ' + JSON.stringify(resultCode));
};
var options = {
OnContinueDone: OnContinueDone
};
try {
distributedMissionManager.continueMission(parameter, options)
.then(data => {
console.info('continueMission finished, ' + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.info('error error is ' + error); console.error('continueMission failed, cause: ' + JSON.stringify(error));
}) })
} catch (error) {
console.error('continueMission failed, cause: ' + JSON.stringify(error))
}
``` ```
## MissionCallback ## MissionCallback
...@@ -349,3 +488,30 @@ stopSyncRemoteMissions(parameter: MissionDeviceInfo): Promise&lt;void&gt; ...@@ -349,3 +488,30 @@ stopSyncRemoteMissions(parameter: MissionDeviceInfo): Promise&lt;void&gt;
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | ------ | ---- | ---- | ------- | | -------- | ------ | ---- | ---- | ------- |
| deviceId | string | 是 | 是 | 表示设备ID。 | | deviceId | string | 是 | 是 | 表示设备ID。 |
## ContinueDeviceInfo
表示发起任务迁移时所需参数的枚举。
**需要权限**:ohos.permission.MANAGE_MISSIONS
**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | ------ | ---- | ---- | ------- |
| srcDeviceId | string | 是 | 是 | 表示任务迁移源设备ID。 |
| dstDeviceId | string | 是 | 是 | 表示任务迁移目标设备ID。 |
| missionId | string | 是 | 是 | 表示任务ID。 |
| wantParams | {[key: string]: any} | 是 | 是 | 表示扩展参数。 |
## ContinueCallback
表示迁移完成后,返回迁移结果回调函数。
**需要权限**:ohos.permission.MANAGE_MISSIONS
**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
| 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------------- | -------- | ---- | ---- | ------------------ |
| onContinueDone | function | 是 | 否 | 通知迁移完成,返回迁移结果。 |
\ No newline at end of file
因为 它太大了无法显示 source diff 。你可以改为 查看blob
...@@ -64,5 +64,4 @@ export default { ...@@ -64,5 +64,4 @@ export default {
}); });
}, },
} }
;
``` ```
\ No newline at end of file
...@@ -40,15 +40,15 @@ text(txt: string, pattern?: MatchPattern): By ...@@ -40,15 +40,15 @@ text(txt: string, pattern?: MatchPattern): By
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------ | ---- | ------------------------------------------------- | | ------- | ------------ | ---- | --------------------------------------------------- |
| txt | string | 是 | 指定控件文本,用于匹配目标控件文本。 | | txt | string | 是 | 指定控件文本,用于匹配目标控件文本。 |
| pattern | MatchPattern | 否 | 指定的文本匹配模式,默认为[EQUALS](#matchpattern) | | pattern | MatchPattern | 否 | 指定的文本匹配模式,默认为[EQUALS](#matchpattern) |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---- | -------------- | | --------- | ---------------------------------- |
| By | 返回By对象自身 | | [By](#by) | 返回指定目标控件文本属性的By对象。 |
**示例:** **示例:**
...@@ -74,8 +74,8 @@ key(key: string): By ...@@ -74,8 +74,8 @@ key(key: string): By
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---- | ---------------- | | --------- | ----------------------------------- |
| By | 返回By对象自身。 | | [By](#by) | 返回指定目标控件key值属性的By对象。 |
**示例:** **示例:**
...@@ -101,8 +101,8 @@ id(id: number): By ...@@ -101,8 +101,8 @@ id(id: number): By
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---- | ---------------- | | --------- | -------------------------------- |
| By | 返回By对象自身。 | | [By](#by) | 返回指定目标控件id属性的By对象。 |
**示例:** **示例:**
...@@ -128,8 +128,8 @@ type(tp: string): By ...@@ -128,8 +128,8 @@ type(tp: string): By
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---- | ---------------- | | --------- | ---------------------------------------- |
| By | 返回By对象自身。 | | [By](#by) | 返回指定目标控件的控件类型属性的By对象。 |
**示例:** **示例:**
...@@ -150,13 +150,13 @@ clickable(b?: boolean): By ...@@ -150,13 +150,13 @@ clickable(b?: boolean): By
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---- | ---- | -------------------------------- | | ------ | ---- | ---- | -------------------------------- |
| b | boolean | 否 | 指定控件可点击状态,默认为true。 | | b | boolean | 否 | 指定控件可点击状态,true:可点击,false:不可点击。默认为true。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---- | ---------------- | | --------- | ------------------------------------------ |
| By | 返回By对象自身。 | | [By](#by) | 返回指定目标控件的可点击状态属性的By对象。 |
**示例:** **示例:**
...@@ -176,13 +176,13 @@ longClickable(b?: boolean): By ...@@ -176,13 +176,13 @@ longClickable(b?: boolean): By
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---- | ---- | ------------------------------------ | | ------ | ---- | ---- | ------------------------------------ |
| b | boolean | 否 | 指定控件可长按点击状态,默认为true。 | | b | boolean | 否 | 指定控件可长按点击状态,true:可长按点击,false:不可长按点击。默认为true。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---- | ---------------- | | --------- | ---------------------------------------------- |
| By | 返回By对象自身。 | | [By](#by) | 返回指定目标控件的可长按点击状态属性的By对象。 |
**示例:** **示例:**
...@@ -203,13 +203,13 @@ scrollable(b?: boolean): By ...@@ -203,13 +203,13 @@ scrollable(b?: boolean): By
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---- | ---- | ---------------------------- | | ------ | ---- | ---- | ---------------------------- |
| b | boolean | 否 | 控件可滑动状态,默认为true。 | | b | boolean | 否 | 控件可滑动状态,true:可滑动,false:不可滑动。默认为true。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---- | ---------------- | | --------- | ------------------------------------------ |
| By | 返回By对象自身。 | | [By](#by) | 返回指定目标控件的可滑动状态属性的By对象。 |
**示例:** **示例:**
...@@ -229,13 +229,13 @@ enabled(b?: boolean): By ...@@ -229,13 +229,13 @@ enabled(b?: boolean): By
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---- | ---- | ------------------------------ | | ------ | ---- | ---- | ------------------------------ |
| b | boolean | 否 | 指定控件使能状态,默认为true。 | | b | boolean | 否 | 指定控件使能状态,true:使能,false:未使能。默认为true。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---- | ---------------- | | --------- | ---------------------------------------- |
| By | 返回By对象自身。 | | [By](#by) | 返回指定目标控件的使能状态属性的By对象。 |
**示例:** **示例:**
...@@ -255,13 +255,13 @@ focused(b?: boolean): By ...@@ -255,13 +255,13 @@ focused(b?: boolean): By
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---- | ---- | -------------------------- | | ------ | ---- | ---- | -------------------------- |
| b | boolean | 否 | 控件获焦状态,默认为true。 | | b | boolean | 否 | 控件获焦状态,true:获焦,false:未获焦。默认为true。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---- | ---------------- | | --------- | ---------------------------------------- |
| By | 返回By对象自身。 | | [By](#by) | 返回指定目标控件的获焦状态属性的By对象。 |
**示例:** **示例:**
...@@ -281,13 +281,13 @@ selected(b?: boolean): By ...@@ -281,13 +281,13 @@ selected(b?: boolean): By
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---- | ---- | -------------------------------- | | ------ | ---- | ---- | -------------------------------- |
| b | boolean | 否 | 指定控件被选中状态,默认为true。 | | b | boolean | 否 | 指定控件被选中状态,true:被选中,false:未被选中。默认为true。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---- | ---------------- | | --------- | ------------------------------------------ |
| By | 返回By对象自身。 | | [By](#by) | 返回指定目标控件的被选中状态属性的By对象。 |
**示例:** **示例:**
...@@ -307,13 +307,13 @@ checked(b?: boolean): By ...@@ -307,13 +307,13 @@ checked(b?: boolean): By
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---- | ---- | --------------------------------- | | ------ | ---- | ---- | --------------------------------- |
| b | boolean | 否 | 指定控件被勾选状态,默认为false。 | | b | boolean | 否 | 指定控件被勾选状态,true:被勾选,false:未被勾选。默认为false。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---- | -------------- | | --------- | ------------------------------------------ |
| By | 返回By对象自身 | | [By](#by) | 返回指定目标控件的被勾选状态属性的By对象。 |
**示例:** **示例:**
...@@ -333,13 +333,13 @@ checkable(b?: boolean): By ...@@ -333,13 +333,13 @@ checkable(b?: boolean): By
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---- | ---- | ------------------------------------- | | ------ | ---- | ---- | ------------------------------------- |
| b | boolean | 否 | 指定控件能否被勾选状态,默认为false。 | | b | boolean | 否 | 指定控件能否被勾选状态,true:能被勾选,false:不能被勾选。默认为false。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---- | ---------------- | | --------- | -------------------------------------------- |
| By | 返回By对象自身。 | | [By](#by) | 返回指定目标控件能否被勾选状态属性的By对象。 |
**示例:** **示例:**
...@@ -358,14 +358,14 @@ isBefore(by: By): By ...@@ -358,14 +358,14 @@ isBefore(by: By): By
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---- | ---- | ---------------- | | ------ | --------- | ---- | ---------------- |
| by | By | 是 | 特征控件的属性。 | | by | [By](#by) | 是 | 特征控件的属性。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---- | ---------------- | | --------- | ---------------------------------------------------- |
| By | 返回By对象自身。 | | [By](#by) | 返回指定目标控件位于给出的特征属性控件之前的By对象。 |
**示例:** **示例:**
...@@ -384,14 +384,14 @@ isAfter(by: By): By ...@@ -384,14 +384,14 @@ isAfter(by: By): By
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---- | ---- | ---------------- | | ------ | --------- | ---- | ---------------- |
| by | By | 是 | 特征控件的属性。 | | by | [By](#by) | 是 | 特征控件的属性。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---- | ---------------- | | --------- | ---------------------------------------------------- |
| By | 返回By对象自身。 | | [By](#by) | 返回指定目标控件位于给出的特征属性控件之后的By对象。 |
**示例:** **示例:**
...@@ -589,8 +589,8 @@ getBounds(): Promise\<Rect> ...@@ -589,8 +589,8 @@ getBounds(): Promise\<Rect>
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | ------------------------------------- | | ------------------------ | ------------------------------------- |
| Promise\<Rect> | 以Promise形式返回控件对象的边框信息。 | | Promise\<[Rect](#rect9)> | 以Promise形式返回控件对象的边框信息。 |
**示例:** **示例:**
...@@ -613,8 +613,8 @@ getBoundsCenter(): Promise\<Point> ...@@ -613,8 +613,8 @@ getBoundsCenter(): Promise\<Point>
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| --------------- | --------------------------------------- | | -------------------------- | --------------------------------------- |
| Promise\<Point> | 以Promise形式返回控件对象的中心点信息。 | | Promise\<[Point](#point9)> | 以Promise形式返回控件对象的中心点信息。 |
**示例:** **示例:**
...@@ -638,7 +638,7 @@ isClickable(): Promise\<boolean> ...@@ -638,7 +638,7 @@ isClickable(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | ------------------------------------- | | -------------- | ------------------------------------- |
| Promise\<boolean> | 以Promise形式返回控件对象可点击状态。 | | Promise\<boolean> | 以Promise形式返回控件对象可点击状态,true:可点击,false:不可点击。 |
**示例:** **示例:**
...@@ -667,7 +667,7 @@ isLongClickable(): Promise\<boolean> ...@@ -667,7 +667,7 @@ isLongClickable(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | ------------------------------------------- | | -------------- | ------------------------------------------- |
| Promise\<boolean> | 以Promise形式返回控件对象能否长按点击状态。 | | Promise\<boolean> | 以Promise形式返回控件对象能否长按点击状态,true:可长按点击,false:不可长按点击。 |
**示例:** **示例:**
...@@ -696,7 +696,7 @@ isChecked(): Promise\<boolean> ...@@ -696,7 +696,7 @@ isChecked(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | ------------------------------------- | | -------------- | ------------------------------------- |
| Promise\<boolean> | 以Promise形式返回控件对象被勾选状态。 | | Promise\<boolean> | 以Promise形式返回控件对象被勾选状态,true:被勾选,false:未被勾选。 |
**示例:** **示例:**
...@@ -725,7 +725,7 @@ isCheckable(): Promise\<boolean> ...@@ -725,7 +725,7 @@ isCheckable(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | ------------------------------------------- | | -------------- | ------------------------------------------- |
| Promise\<boolean> | 以Promise形式返回控件对象能否被勾选的属性。 | | Promise\<boolean> | 以Promise形式返回控件对象能否被勾选的属性,true:可被勾选,false:不可被勾选。 |
**示例:** **示例:**
...@@ -754,7 +754,7 @@ isScrollable(): Promise\<boolean> ...@@ -754,7 +754,7 @@ isScrollable(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | ------------------------------------- | | -------------- | ------------------------------------- |
| Promise\<boolean> | 以Promise形式返回控件对象可滑动状态。 | | Promise\<boolean> | 以Promise形式返回控件对象可滑动状态,true:可滑动,false:不可滑动。 |
**示例:** **示例:**
...@@ -784,7 +784,7 @@ isEnabled(): Promise\<boolean> ...@@ -784,7 +784,7 @@ isEnabled(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | ------------------------------- | | -------------- | ------------------------------- |
| Promise\<boolean> | 以Promise形式返回控件使能状态。 | | Promise\<boolean> | 以Promise形式返回控件使能状态,true:使能,false:未使能。 |
**示例:** **示例:**
...@@ -814,7 +814,7 @@ isFocused(): Promise\<boolean> ...@@ -814,7 +814,7 @@ isFocused(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | ----------------------------------- | | -------------- | ----------------------------------- |
| Promise\<boolean> | 以Promise形式返回控件对象是否获焦。 | | Promise\<boolean> | 以Promise形式返回控件对象是否获焦,true:获焦,false:未获焦。 |
**示例:** **示例:**
...@@ -843,7 +843,7 @@ isSelected(): Promise\<boolean> ...@@ -843,7 +843,7 @@ isSelected(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | -------------------- | | -------------- | -------------------- |
| Promise\<boolean> | 控件对象被选中的状态 | | Promise\<boolean> | 控件对象被选中的状态,true:被选中,false:未被选中。 |
**示例:** **示例:**
...@@ -913,14 +913,14 @@ scrollSearch(by: By): Promise\<UiComponent> ...@@ -913,14 +913,14 @@ scrollSearch(by: By): Promise\<UiComponent>
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---- | ---- | -------------------- | | ------ | --------- | ---- | -------------------- |
| by | By | 是 | 目标控件的属性要求。 | | by | [By](#by) | 是 | 目标控件的属性要求。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| --------------------- | ------------------------------------- | | ------------------------------------- | ------------------------------------- |
| Promise\<UiComponent> | 以Promise形式返回找到的目标控件对象。 | | Promise\<[UiComponent](#uicomponent)> | 以Promise形式返回找到的目标控件对象。 |
**示例:** **示例:**
...@@ -991,8 +991,8 @@ dragTo(target: UiComponent): Promise\<void> ...@@ -991,8 +991,8 @@ dragTo(target: UiComponent): Promise\<void>
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------- | ---- | ---------- | | ------ | --------------------------- | ---- | ---------- |
| target | UiComponent | 是 | 目标控件。 | | target | [UiComponent](#uicomponent) | 是 | 目标控件。 |
**示例:** **示例:**
...@@ -1016,8 +1016,8 @@ pinchOut(scale: number): Promise\<void> ...@@ -1016,8 +1016,8 @@ pinchOut(scale: number): Promise\<void>
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------- | ---- | ---------- | | ------ | ------ | ---- | ---------------- |
| scale | number | 是 | 指定比例 | | scale | number | 是 | 指定放大的比例。 |
**示例:** **示例:**
...@@ -1040,8 +1040,8 @@ pinchIn(scale: number): Promise\<void> ...@@ -1040,8 +1040,8 @@ pinchIn(scale: number): Promise\<void>
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------- | ---- | ---------- | | ------ | ------ | ---- | ---------------- |
| scale | number | 是 | 指定比例 | | scale | number | 是 | 指定缩小的比例。 |
**示例:** **示例:**
...@@ -1114,14 +1114,14 @@ findComponent(by: By): Promise\<UiComponent> ...@@ -1114,14 +1114,14 @@ findComponent(by: By): Promise\<UiComponent>
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---- | ---- | -------------------- | | ------ | --------- | ---- | -------------------- |
| by | By | 是 | 目标控件的属性要求。 | | by | [By](#by) | 是 | 目标控件的属性要求。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| --------------------- | --------------------------------- | | ------------------------------------- | --------------------------------- |
| Promise\<UiComponent> | 以Promise形式返回找到的控件对象。 | | Promise\<[UiComponent](#uicomponent)> | 以Promise形式返回找到的控件对象。 |
**示例:** **示例:**
...@@ -1143,14 +1143,14 @@ findComponents(by: By): Promise\<Array\<UiComponent>> ...@@ -1143,14 +1143,14 @@ findComponents(by: By): Promise\<Array\<UiComponent>>
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---- | ---- | -------------------- | | ------ | --------- | ---- | -------------------- |
| by | By | 是 | 目标控件的属性要求。 | | by | [By](#by) | 是 | 目标控件的属性要求。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------- | --------------------------------------- | | --------------------------------------------- | --------------------------------------- |
| Promise\<Array\<UiComponent>> | 以Promise形式返回找到的控件对象的列表。 | | Promise\<Array\<[UiComponent](#uicomponent)>> | 以Promise形式返回找到的控件对象的列表。 |
**示例:** **示例:**
...@@ -1201,15 +1201,15 @@ waitForComponent(by: By, time: number): Promise\<UiComponent> ...@@ -1201,15 +1201,15 @@ waitForComponent(by: By, time: number): Promise\<UiComponent>
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------------------------- | | ------ | --------- | ---- | -------------------------------- |
| by | By | 是 | 目标控件的属性要求。 | | by | [By](#by) | 是 | 目标控件的属性要求。 |
| time | number | 是 | 查找目标控件的持续时间。单位ms。 | | time | number | 是 | 查找目标控件的持续时间。单位ms。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| --------------------- | --------------------------------- | | ------------------------------------- | --------------------------------- |
| Promise\<UiComponent> | 以Promise形式返回找到的控件对象。 | | Promise\<[UiComponent](#uicomponent)> | 以Promise形式返回找到的控件对象。 |
**示例:** **示例:**
...@@ -1231,8 +1231,8 @@ assertComponentExist(by: By): Promise\<void> ...@@ -1231,8 +1231,8 @@ assertComponentExist(by: By): Promise\<void>
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---- | ---- | -------------------- | | ------ | --------- | ---- | -------------------- |
| by | By | 是 | 目标控件的属性要求。 | | by | [By](#by) | 是 | 目标控件的属性要求。 |
**示例:** **示例:**
...@@ -1522,7 +1522,7 @@ setDisplayRotationEnabled(enabled: boolean): Promise\<void> ...@@ -1522,7 +1522,7 @@ setDisplayRotationEnabled(enabled: boolean): Promise\<void>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------- | ---- | ---- | -------------------- | | ------- | ---- | ---- | -------------------- |
| enabled | boolean | 是 | 能否旋转屏幕的标识。 | | enabled | boolean | 是 | 能否旋转屏幕的标识,true:可以旋转,false:不可以旋转。 |
**示例:** **示例:**
...@@ -1758,8 +1758,8 @@ getBounds(): Promise\<Rect> ...@@ -1758,8 +1758,8 @@ getBounds(): Promise\<Rect>
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | --------------------------------- | | ------------------------ | --------------------------------- |
| Promise\<Rect> | 以Promise形式返回窗口的边框信息。 | | Promise\<[Rect](#rect9)> | 以Promise形式返回窗口的边框信息。 |
**示例:** **示例:**
...@@ -1831,7 +1831,7 @@ isFocused(): Promise\<boolean> ...@@ -1831,7 +1831,7 @@ isFocused(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | ----------------------------------- | | -------------- | ----------------------------------- |
| Promise\<boolean> | 以Promise形式返回窗口对象是否获焦。 | | Promise\<boolean> | 以Promise形式返回窗口对象是否获焦,true:获焦,false:未获焦。 |
**示例:** **示例:**
...@@ -1855,7 +1855,7 @@ isActived(): Promise\<boolean> ...@@ -1855,7 +1855,7 @@ isActived(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | --------------------------------------------- | | -------------- | --------------------------------------------- |
| Promise\<boolean> | 以Promise形式返回窗口对象是否为用户交互窗口。 | | Promise\<boolean> | 以Promise形式返回窗口对象是否为用户交互窗口,true:交互窗口,false:非交互窗口。 |
**示例:** **示例:**
...@@ -1879,7 +1879,7 @@ focus(): Promise\<boolean> ...@@ -1879,7 +1879,7 @@ focus(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | ----------------------------------- | | -------------- | ----------------------------------- |
| Promise\<boolean> | 以Promise形式返回操作是否成功完成。 | | Promise\<boolean> | 以Promise形式返回操作是否成功完成,true:操作已完成,false:操作未完成。 |
**示例:** **示例:**
...@@ -1910,7 +1910,7 @@ moveTo(x: number, y: number): Promise\<boolean> ...@@ -1910,7 +1910,7 @@ moveTo(x: number, y: number): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | ----------------------------------- | | -------------- | ----------------------------------- |
| Promise\<boolean> | 以Promise形式返回操作是否成功完成。 | | Promise\<boolean> | 以Promise形式返回操作是否成功完成,true:操作已完成,false:操作未完成。 |
**示例:** **示例:**
...@@ -1942,7 +1942,7 @@ resize(wide: number, height: number, direction: ResizeDirection): Promise\<boole ...@@ -1942,7 +1942,7 @@ resize(wide: number, height: number, direction: ResizeDirection): Promise\<boole
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | ----------------------------------- | | -------------- | ----------------------------------- |
| Promise\<boolean> | 以Promise形式返回操作是否成功完成。 | | Promise\<boolean> | 以Promise形式返回操作是否成功完成,true:操作已完成,false:操作未完成。 |
**示例:** **示例:**
...@@ -1966,7 +1966,7 @@ split(): Promise\<boolean> ...@@ -1966,7 +1966,7 @@ split(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | ----------------------------------- | | -------------- | ----------------------------------- |
| Promise\<boolean> | 以Promise形式返回操作是否成功完成。 | | Promise\<boolean> | 以Promise形式返回操作是否成功完成,true:操作已完成,false:操作未完成。 |
**示例:** **示例:**
...@@ -1990,7 +1990,7 @@ maximize(): Promise\<boolean> ...@@ -1990,7 +1990,7 @@ maximize(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | ----------------------------------- | | -------------- | ----------------------------------- |
| Promise\<boolean> | 以Promise形式返回操作是否成功完成。 | | Promise\<boolean> | 以Promise形式返回操作是否成功完成,true:操作已完成,false:操作未完成。 |
**示例:** **示例:**
...@@ -2014,7 +2014,7 @@ minimize(): Promise\<boolean> ...@@ -2014,7 +2014,7 @@ minimize(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | ----------------------------------- | | -------------- | ----------------------------------- |
| Promise\<boolean> | 以Promise形式返回操作是否成功完成。 | | Promise\<boolean> | 以Promise形式返回操作是否成功完成,true:操作已完成,false:操作未完成。 |
**示例:** **示例:**
...@@ -2038,7 +2038,7 @@ resume(): Promise\<boolean> ...@@ -2038,7 +2038,7 @@ resume(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | ----------------------------------- | | -------------- | ----------------------------------- |
| Promise\<boolean> | 以Promise形式返回操作是否成功完成。 | | Promise\<boolean> | 以Promise形式返回操作是否成功完成,true:操作已完成,false:操作未完成。 |
**示例:** **示例:**
...@@ -2062,7 +2062,7 @@ close(): Promise\<boolean> ...@@ -2062,7 +2062,7 @@ close(): Promise\<boolean>
| 类型 | 说明 | | 类型 | 说明 |
| -------------- | ----------------------------------- | | -------------- | ----------------------------------- |
| Promise\<boolean> | 以Promise形式返回操作是否成功完成。 | | Promise\<boolean> | 以Promise形式返回操作是否成功完成,true:操作已完成,false:操作未完成。 |
**示例:** **示例:**
...@@ -2096,8 +2096,8 @@ static create(fingers: number, steps: number): PointerMatrix ...@@ -2096,8 +2096,8 @@ static create(fingers: number, steps: number): PointerMatrix
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------- | ----------------------------- | | -------------------------------- | ----------------------------- |
| PointerMatrix | 返回构造的PointerMatrix对象。 | | [PointerMatrix](#pointermatrix9) | 返回构造的PointerMatrix对象。 |
**示例:** **示例:**
...@@ -2189,8 +2189,8 @@ async function demo() { ...@@ -2189,8 +2189,8 @@ async function demo() {
设备显示器的显示方向。 设备显示器的显示方向。
| 名称 | 说明 | | 名称 | 说明 |
| ------------ | ------------------------------------ | | ------------ | ---------------------------------------- |
| ROTATION_0 | 设备显示器不旋转,初始形态垂直显示。 | | ROTATION_0 | 设备显示器不旋转,初始形态垂直显示。 |
| ROTATION_90 | 设备显顺时针旋转90°,水平显示。 | | ROTATION_90 | 设备显示器顺时针旋转90°,水平显示。 |
| ROTATION_180 | 设备显顺时针旋转180°,逆向垂直显示。 | | ROTATION_180 | 设备显示器顺时针旋转180°,逆向垂直显示。 |
| ROTATION_270 | 设备显顺时针旋转270°,逆向水平显示。 | | ROTATION_270 | 设备显示器顺时针旋转270°,逆向水平显示。 |
...@@ -13,11 +13,11 @@ vibrator模块提供控制马达振动的能力,如通过接口控制马达启 ...@@ -13,11 +13,11 @@ vibrator模块提供控制马达振动的能力,如通过接口控制马达启
import vibrator from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
``` ```
## vibrator.vibrate ## vibrator.startVibration<sup>9+</sup>
vibrate(duration: number): Promise&lt;void&gt; startVibration(effect: VibrateEffect, attribute: VibrateAttribute, callback: AsyncCallback&lt;void&gt;): void
按照指定持续时间触发马达振动。 按照指定振动效果和振动属性触发马达振动。
**需要权限**:ohos.permission.VIBRATE **需要权限**:ohos.permission.VIBRATE
...@@ -26,28 +26,36 @@ vibrate(duration: number): Promise&lt;void&gt; ...@@ -26,28 +26,36 @@ vibrate(duration: number): Promise&lt;void&gt;
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---------------------- | | --------- | -------------------------------------- | ---- | :--------------------------------------------------------- |
| duration | number | 是 | 马达振动时长, 单位ms。 | | effect | [VibrateEffect](#vibrateeffect9) | 是 | 马达振动效果。 |
| attribute | [VibrateAttribute](#vibrateattribute9) | 是 | 马达振动属性。 |
**返回值:** | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当马达振动成功,err为undefined,否则为错误对象。 |
| 类型 | 说明 |
| ------------------- | -------------------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回结果的Promise对象。 |
**示例:** 示例:
```js ```js
vibrator.vibrate(1000).then(()=>{ try {
console.log("Promise returned to indicate a successful vibration."); vibrator.startVibration({
type:'time',
duration:1000,
},{
id:0,
usage: 'alarm'
}, (error)=>{ }, (error)=>{
console.log("error.code"+error.code+"error.message"+error.message); if(error){
console.log('vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message);
}else{
console.log('Callback returned to indicate a successful vibration.');
}
}); });
``` } catch(err) {
console.info('errCode: ' + err.code + ' ,msg: ' + err.message);
}
```
## vibrator.vibrate<sup>9+</sup> ## vibrator.startVibration<sup>9+</sup>
vibrate(effect: VibrateEffect, attribute: VibrateAttribute): Promise&lt;void&gt; startVibration(effect: VibrateEffect, attribute: VibrateAttribute): Promise&lt;void&gt;
按照指定振动效果和振动属性触发马达振动。 按照指定振动效果和振动属性触发马达振动。
...@@ -58,7 +66,7 @@ vibrate(effect: VibrateEffect, attribute: VibrateAttribute): Promise&lt;void&gt; ...@@ -58,7 +66,7 @@ vibrate(effect: VibrateEffect, attribute: VibrateAttribute): Promise&lt;void&gt;
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | -------------------------------------- | ---- | :------------- | | --------- | -------------------------------------- | ---- | -------------- |
| effect | [VibrateEffect](#vibrateeffect9) | 是 | 马达振动效果。 | | effect | [VibrateEffect](#vibrateeffect9) | 是 | 马达振动效果。 |
| attribute | [VibrateAttribute](#vibrateattribute9) | 是 | 马达振动属性。 | | attribute | [VibrateAttribute](#vibrateattribute9) | 是 | 马达振动属性。 |
...@@ -70,112 +78,219 @@ vibrate(effect: VibrateEffect, attribute: VibrateAttribute): Promise&lt;void&gt; ...@@ -70,112 +78,219 @@ vibrate(effect: VibrateEffect, attribute: VibrateAttribute): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
vibrator.vibrate({ try {
vibrator.startVibration({
type: 'time', type: 'time',
duration: 1000 duration: 1000
}, { }, {
id: 0, id: 0,
usage: 'alarm' usage: 'alarm'
}).then(()=>{ }).then(()=>{
console.log("Promise returned to indicate a successful vibration"); console.log('Promise returned to indicate a successful vibration');
}).catch((error)=>{ }).catch((error)=>{
console.log("error.code" + error.code + "error.message" + error.message); console.log('error.code' + error.code + 'error.message' + error.message);
}) })
``` } catch(err) {
console.info('errCode: ' + err.code + ' ,msg: ' + err.message);
}
```
## vibrator.vibrate ## vibrator.stopVibration<sup>9+</sup>
vibrate(duration: number, callback?: AsyncCallback&lt;void&gt;): void stopVibration(stopMode: VibratorStopMode, callback: AsyncCallback&lt;void&gt;): void
按照指定持续时间触发马达振动 按照要停止指定的振动模式来停止马达的振动。如果要停止的振动模式与触发马达振动时的模式不相同,则调用本接口会失败
**需要权限**:ohos.permission.VIBRATE **需要权限**:ohos.permission.VIBRATE
**系统能力**:SystemCapability.Sensors.MiscDevice **系统能力**:SystemCapability.Sensors.MiscDevice
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------------------------------------------------------- | | -------- | ------------------------------------- | ---- | ------------------------------------------------------------ |
| duration | number | 是 | 马达振动时长, 单位ms。 | | stopMode | [VibratorStopMode](#vibratorstopmode) | 是 | 马达停止指定的振动模式。 |
| callback | AsyncCallback&lt;void&gt; | 否 | 回调函数。当马达振动成功,err为undefined,否则为错误对象。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当马达停止振动成功,err为undefined,否则为错误对象。 |
**示例:** **示例:**
```js ```js
vibrator.vibrate(1000,function(error){ try {
vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error){
if(error){ if(error){
console.log("error.code" + error.code + "error.message" + error.message); console.log('error.code' + error.code + 'error.message' + error.message);
}else{ }else{
console.log("Callback returned to indicate a successful vibration."); console.log('Callback returned to indicate successful.');
} }
}) })
} catch(err) {
console.info('errCode: ' + err.code + ' ,msg: ' + err.message);
}
``` ```
## vibrator.stopVibration<sup>9+</sup>
## vibrator.vibrate stopVibration(stopMode: VibratorStopMode): Promise&lt;void&gt;
vibrate(effectId: EffectId): Promise&lt;void&gt;
按照预置振动效果触发马达振动 按照要停止指定的振动模式来停止马达的振动。如果要停止的振动模式与触发马达振动时的模式不相同,则调用本接口会失败
**需要权限**:ohos.permission.VIBRATE **需要权限**:ohos.permission.VIBRATE
**系统能力**:SystemCapability.Sensors.MiscDevice **系统能力**:SystemCapability.Sensors.MiscDevice
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------ | | -------- | ------------------------------------- | ---- | ------------------------ |
| effectId | [EffectId](#effectid) | 是 | 预置的振动效果ID。 | | stopMode | [VibratorStopMode](#vibratorstopmode) | 是 | 马达停止指定的振动模式。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------- | -------------------------------------- | | ------------------- | -------------------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回结果的Promise对象。 | | Promise&lt;void&gt; | Promise对象。无返回结果的Promise对象。 |
**示例:** **示例:**
```js ```js
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(()=>{ try {
console.log("Promise returned to indicate a successful vibration."); vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{
console.log('Promise returned to indicate a successful vibration.');
}, (error)=>{ }, (error)=>{
console.log("error.code" + error.code + "error.message" + error.message); console.log('error.code' + error.code + 'error.message' + error.message);
}); });
} catch(err) {
console.info('errCode: ' + err.code + ' ,msg: ' + err.message);
}
``` ```
## EffectId
## vibrator.vibrate 马达振动效果的字符串。
vibrate(effectId: EffectId, callback?: AsyncCallback&lt;void&gt;): void **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice
按照指定振动效果触发马达振动。 | 名称 | 默认值 | 说明 |
| ------------------ | -------------------- | ------------------ |
| EFFECT_CLOCK_TIMER | "haptic.clock.timer" | 预置的振动效果ID。 |
## VibratorStopMode
马达要停止指定的振动模式。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice
| 名称 | 默认值 | 说明 |
| ------------------------- | -------- | ------------------------------------------------------------ |
| VIBRATOR_STOP_MODE_TIME | "time" | 停止模式为duration模式的振动。即触发振动时参数类型为number,参数本身为振动持续时间的触发方式。 |
| VIBRATOR_STOP_MODE_PRESET | "preset" | 停止模式为预置EffectId的振动。即触发振动时参数类型为EffectId,参数本身为马达振动效果的字符串的触发方式。 |
## VibrateEffect<sup>9+</sup>
马达振动效果。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice
| 类型 | 说明 |
| -------------------------------- | ------------------------------ |
| [VibrateTime](#vibratetime9) | 按照指定持续时间触发马达振动。 |
| [VibratePreset](#vibratepreset9) | 按照预置振动类型触发马达振动。 |
## VibrateTime<sup>9+</sup>
马达振动时长。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice
| 名称 | 默认值 | 说明 |
| -------- | ------ | ------------------------------ |
| type | "time" | 按照指定持续时间触发马达振动。 |
| duration | - | 马达振动时长, 单位ms。 |
## VibratePreset<sup>9+</sup>
马达预置振动类型。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice
| 名称 | 默认值 | 说明 |
| -------- | -------- | ------------------------------ |
| type | "preset" | 按照预置振动效果触发马达振动。 |
| effectId | - | 预置的振动效果ID。 |
| count | - | 重复振动的次数。 |
## VibrateAttribute<sup>9+</sup>
马达振动属性。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice
| 名称 | 默认值 | 说明 |
| ----- | ------ | -------------- |
| id | 0 | 振动器id。 |
| usage | - | 马达振动场景。 |
## Usage<sup>9+</sup>
振动使用场景。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice
| 名称 | 类型 | 说明 |
| ---------------- | ------ | ------------------------------ |
| unknown | string | 没有明确使用场景,最低优先级。 |
| alarm | string | 用于警报振动的场景。 |
| ring | string | 用于铃声振动的场景。 |
| notification | string | 用于通知振动的场景。 |
| communication | string | 用于通信振动的场景。 |
| touch | string | 用于触摸振动的场景。 |
| media | string | 用于多媒体振动的场景。 |
| physicalFeedback | string | 用于物理反馈振动的场景。 |
| simulateReality | string | 用于模拟现实振动的场景。 |
## vibrator.vibrate<sup>(deprecated)</sup>
vibrate(duration: number): Promise&lt;void&gt;
按照指定持续时间触发马达振动。
从API version 9 开始不再维护,建议使用 [vibrator.startVibration](#vibratorstartvibration9-1) 代替。
**需要权限**:ohos.permission.VIBRATE **需要权限**:ohos.permission.VIBRATE
**系统能力**:SystemCapability.Sensors.MiscDevice **系统能力**:SystemCapability.Sensors.MiscDevice
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------------------------------------------------------- | | -------- | ------ | ---- | ---------------------- |
| effectId | [EffectId](#effectid) | 是 | 预置的振动效果ID。 | | duration | number | 是 | 马达振动时长, 单位ms。 |
| callback | AsyncCallback&lt;void&gt; | 否 | 回调函数。当马达振动成功,err为undefined,否则为错误对象。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | -------------------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回结果的Promise对象。 |
**示例:** **示例:**
```js ```js
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function(error){ vibrator.vibrate(1000).then(()=>{
if(error){ console.log('Promise returned to indicate a successful vibration.');
console.log("error.code" + error.code + "error.message" + error.message); }, (error)=>{
}else{ console.log('error.code' + error.code + 'error.message' + error.message);
console.log("Callback returned to indicate a successful vibration."); });
}
})
``` ```
## vibrator.vibrate<sup>9+</sup> ## vibrator.vibrate<sup>(deprecated)</sup>
vibrate(effect: VibrateEffect, attribute: VibrateAttribute, callback: AsyncCallback&lt;void&gt;): void vibrate(duration: number, callback?: AsyncCallback&lt;void&gt;): void
按照指定振动效果和振动属性触发马达振动。 按照指定持续时间触发马达振动。
从API version 9 开始不再维护,建议使用 [vibrator.startVibration](#vibratorstartvibration9) 代替。
**需要权限**:ohos.permission.VIBRATE **需要权限**:ohos.permission.VIBRATE
...@@ -184,43 +299,40 @@ vibrate(effect: VibrateEffect, attribute: VibrateAttribute, callback: AsyncCallb ...@@ -184,43 +299,40 @@ vibrate(effect: VibrateEffect, attribute: VibrateAttribute, callback: AsyncCallb
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | -------------------------------------- | ---- | :--------------------------------------------------------- | | -------- | ------------------------- | ---- | ---------------------------------------------------------- |
| effect | [VibrateEffect](#vibrateeffect9) | 是 | 马达振动效果。 | | duration | number | 是 | 马达振动时长, 单位ms。 |
| attribute | [VibrateAttribute](#vibrateattribute9) | 是 | 马达振动属性。 | | callback | AsyncCallback&lt;void&gt; | 否 | 回调函数。当马达振动成功,err为undefined,否则为错误对象。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当马达振动成功,err为undefined,否则为错误对象。 |
示例: **示例:**
```js ```js
vibrator.vibrate({ vibrator.vibrate(1000,function(error){
type:'time',
duration:1000,
},{
id:0,
usage: 'alarm'
}, (error)=>{
if(error){ if(error){
console.log("vibrate fail, error.code:" + error.code + ",error.message:" + error.message); console.log('error.code' + error.code + 'error.message' + error.message);
}else{ }else{
console.log("Callback returned to indicate a successful vibration."); console.log('Callback returned to indicate a successful vibration.');
} }
}); })
``` ```
## vibrator.stop
stop(stopMode: VibratorStopMode): Promise&lt;void&gt; ## vibrator.vibrate<sup>(deprecated)</sup>
按照要停止指定的振动模式来停止马达的振动。如果要停止的振动模式与触发马达振动时的模式不相同,则调用本接口会失败。 vibrate(effectId: EffectId): Promise&lt;void&gt;
按照预置振动效果触发马达振动。
从API version 9 开始不再维护,建议使用 [vibrator.startVibration](#vibratorstartvibration9-1) 代替。
**需要权限**:ohos.permission.VIBRATE **需要权限**:ohos.permission.VIBRATE
**系统能力**:SystemCapability.Sensors.MiscDevice **系统能力**:SystemCapability.Sensors.MiscDevice
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------- | ---- | ------------------------ | | -------- | --------------------- | ---- | ------------------ |
| stopMode | [VibratorStopMode](#vibratorstopmode) | 是 | 马达停止指定的振动模式。 | | effectId | [EffectId](#effectid) | 是 | 预置的振动效果ID。 |
**返回值:** **返回值:**
...@@ -231,125 +343,107 @@ stop(stopMode: VibratorStopMode): Promise&lt;void&gt; ...@@ -231,125 +343,107 @@ stop(stopMode: VibratorStopMode): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{ vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(()=>{
console.log("Promise returned to indicate a successful vibration."); console.log('Promise returned to indicate a successful vibration.');
}, (error)=>{ }, (error)=>{
console.log("error.code" + error.code + "error.message" + error.message); console.log('error.code' + error.code + 'error.message' + error.message);
}); });
``` ```
## vibrator.stop ## vibrator.vibrate<sup>(deprecated)</sup>
stop(stopMode: VibratorStopMode, callback?: AsyncCallback&lt;void&gt;): void; vibrate(effectId: EffectId, callback?: AsyncCallback&lt;void&gt;): void
按照要停止指定的振动模式来停止马达的振动。如果要停止的振动模式与触发马达振动时的模式不相同,则调用本接口会失败。 按照指定振动效果触发马达振动。
从API version 9 开始不再维护,建议使用 [vibrator.startVibration](#vibratorstartvibration9) 代替。
**需要权限**:ohos.permission.VIBRATE **需要权限**:ohos.permission.VIBRATE
**系统能力**:SystemCapability.Sensors.MiscDevice **系统能力**:SystemCapability.Sensors.MiscDevice
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------- | ---- | ---------------------------------------------------------- |
| stopMode | [VibratorStopMode](#vibratorstopmode) | 是 | 马达停止指定的振动模式。 | | effectId | [EffectId](#effectid) | 是 | 预置的振动效果ID。 |
| callback | AsyncCallback&lt;void&gt; | 否 | 回调函数。当马达停止振动成功,err为undefined,否则为错误对象。 | | callback | AsyncCallback&lt;void&gt; | 否 | 回调函数。当马达振动成功,err为undefined,否则为错误对象。 |
**示例:** **示例:**
```js ```js
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error){ vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function(error){
if(error){ if(error){
console.log("error.code" + error.code + "error.message" + error.message); console.log('error.code' + error.code + 'error.message' + error.message);
}else{ }else{
console.log("Callback returned to indicate successful."); console.log('Callback returned to indicate a successful vibration.');
} }
}) })
``` ```
## vibrator.stop<sup>(deprecated)</sup>
## EffectId stop(stopMode: VibratorStopMode): Promise&lt;void&gt;
马达振动效果的字符串。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice
| 名称 | 默认值 | 说明 |
| ------------------ | -------------------- | ------------------ |
| EFFECT_CLOCK_TIMER | "haptic.clock.timer" | 预置的振动效果ID。 |
## VibratorStopMode 按照要停止指定的振动模式来停止马达的振动。如果要停止的振动模式与触发马达振动时的模式不相同,则调用本接口会失败。
马达要停止指定的振动模式 从API version 9 开始不再维护,建议使用 [vibrator.stopVibration](#vibratorstopvibration9-1) 代替
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice **需要权限**:ohos.permission.VIBRATE
| 名称 | 默认值 | 说明 | **系统能力**:SystemCapability.Sensors.MiscDevice
| ------------------------- | -------- | ------------------------------------------------------------ |
| VIBRATOR_STOP_MODE_TIME | "time" | 停止模式为duration模式的振动。即触发振动时参数类型为number,参数本身为振动持续时间的触发方式。 |
| VIBRATOR_STOP_MODE_PRESET | "preset" | 停止模式为预置EffectId的振动。即触发振动时参数类型为EffectId,参数本身为马达振动效果的字符串的触发方式。 |
## VibrateEffect<sup>9+</sup> **参数:**
马达振动效果。 | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------- | ---- | ------------------------ |
| stopMode | [VibratorStopMode](#vibratorstopmode) | 是 | 马达停止指定的振动模式。 |
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------------------------------- | ------------------------------ | | ------------------- | -------------------------------------- |
| [VibrateTime](#vibratetime9) | 按照指定持续时间触发马达振动。 | | Promise&lt;void&gt; | Promise对象。无返回结果的Promise对象。 |
| [VibratePreset](#vibratepreset9) | 按照预置振动类型触发马达振动。 |
## VibrateTime<sup>9+</sup>
马达振动时长。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice
| 名称 | 默认值 | 说明 |
| -------- | ------ | ------------------------------ |
| type | "time" | 按照指定持续时间触发马达振动。 |
| duration | - | 马达振动时长, 单位ms。 |
## VibratePreset<sup>9+</sup> **示例:**
马达预置振动类型。 ```js
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{
console.log('Promise returned to indicate a successful vibration.');
}, (error)=>{
console.log('error.code' + error.code + 'error.message' + error.message);
});
```
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice
| 名称 | 默认值 | 说明 | ## vibrator.stop<sup>(deprecated)</sup>
| -------- | -------- | ------------------------------ |
| type | "preset" | 按照预置振动效果触发马达振动。 |
| effectId | - | 预置的振动效果ID。 |
| count | - | 重复振动的次数。 |
## VibrateAttribute<sup>9+</sup> stop(stopMode: VibratorStopMode, callback?: AsyncCallback&lt;void&gt;): void
马达振动属性。 按照要停止指定的振动模式来停止马达的振动。如果要停止的振动模式与触发马达振动时的模式不相同,则调用本接口会失败。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice 从API version 9 开始不再维护,建议使用 [vibrator.stopVibration](#vibratorstopvibration9) 代替。
| 名称 | 默认值 | 说明 | **需要权限**:ohos.permission.VIBRATE
| ----- | ------ | -------------- |
| id | 0 | 振动器id。 |
| usage | - | 马达振动场景。 |
## Usage<sup>9+</sup> **系统能力**:SystemCapability.Sensors.MiscDevice
振动使用场景。 **参数:**
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------- | ---- | ------------------------------------------------------------ |
| stopMode | [VibratorStopMode](#vibratorstopmode) | 是 | 马达停止指定的振动模式。 |
| callback | AsyncCallback&lt;void&gt; | 否 | 回调函数。当马达停止振动成功,err为undefined,否则为错误对象。 |
| 名称 | 类型 | 说明 | **示例:**
| ---------------- | ------ | ------------------------------ |
| unknown | string | 没有明确使用场景,最低优先级。 |
| alarm | string | 用于警报振动的场景。 |
| ring | string | 用于铃声振动的场景。 |
| notification | string | 用于通知振动的场景。 |
| communication | string | 用于通信振动的场景。 |
| touch | string | 用于触摸振动的场景。 |
| media | string | 用于多媒体振动的场景。 |
| physicalFeedback | string | 用于物理反馈振动的场景。 |
| simulateReality | string | 用于模拟现实振动的场景。 |
```js
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error){
if(error){
console.log('error.code' + error.code + 'error.message' + error.message);
}else{
console.log('Callback returned to indicate successful.');
}
})
```
...@@ -52,6 +52,7 @@ Image(src: string | PixelMap | Resource) ...@@ -52,6 +52,7 @@ Image(src: string | PixelMap | Resource)
> **说明:** > **说明:**
> >
> 使用快捷组合键对Image组件复制的前提是,该组件必须处于获焦状态。将Image组件的属性focusable设置为true,即可使用TAB键将焦点切换到Image组件上,再将Image组件的focusOnTouch属性设置为true,即可实现点击获焦。 > 使用快捷组合键对Image组件复制的前提是,该组件必须处于获焦状态。将Image组件的属性focusable设置为true,即可使用TAB键将焦点切换到Image组件上,再将Image组件的focusOnTouch属性设置为true,即可实现点击获焦。
> 图片设置svg图源时,支持的标签范围有限,目前支持的svg标签包括svg、rect、circle、ellipse、path、line、polyline、polygon、animate、animateMotion、animateTransform。
### ImageInterpolation ### ImageInterpolation
......
...@@ -21,6 +21,21 @@ TextClock(options?: { timeZoneOffset?: number, controller?: TextClockController ...@@ -21,6 +21,21 @@ TextClock(options?: { timeZoneOffset?: number, controller?: TextClockController
| timeZoneOffset | number | 否 | 设置时区偏移量。<br>取值范围为[-14, 12],表示东十二区到西十二区,其中负值表示东时区,正值表示西时区,比如东八区为-8。<br>对横跨国际日界线的国家或地区,用-13(UTC+13)和-14(UTC+14)来保证整个国家或者区域处在相同的时间,当设置的值不在取值范围内时,将使用当前系统的时区偏移量。<br/>默认值:当前系统的时区偏移量 | | timeZoneOffset | number | 否 | 设置时区偏移量。<br>取值范围为[-14, 12],表示东十二区到西十二区,其中负值表示东时区,正值表示西时区,比如东八区为-8。<br>对横跨国际日界线的国家或地区,用-13(UTC+13)和-14(UTC+14)来保证整个国家或者区域处在相同的时间,当设置的值不在取值范围内时,将使用当前系统的时区偏移量。<br/>默认值:当前系统的时区偏移量 |
| controller | [TextClockController](#textclockcontroller) | 否 | 绑定一个控制器,用来控制文本时钟的状态。| | controller | [TextClockController](#textclockcontroller) | 否 | 绑定一个控制器,用来控制文本时钟的状态。|
## 属性
除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性:
| 名称 | 参数类型 | 描述 |
| ------ | --------------- | ------------------------------------------------------------ |
| format | string | 设置显示时间格式。<br/>日期间隔符固定为"/",时间间隔符为":"。<br/>如yyyyMMdd,yyyy-MM-dd显示为yyyy/MM/dd,<br/>hhmmss显示为hh:mm:ss。 <br/>时间格式只用写一位即可,如"hhmmss"等同于"hms"。<br/>支持的时间格式化字符串:<br/>- YYYY/yyyy:完整年份。<br/>- YY/yy:年份后两位。<br/>- M:月份(若想使用01月则使用MM)。<br/>- d:日期(若想使用01日则使用dd)。<br/>- D:年中日(一年中的第几天)。<br/>- H:24小时制。<br/>- h:12小时制。<br/>- m:分钟。<br/>- s:秒。<br/>- SSS:毫秒。<br/>若格式未匹配,则使用默认值。<br/>默认值: 'hms'|
## 事件
除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件:
| 名称 | 功能描述 |
| -------------------------------------------- | ------------------------------------------------------------ |
| onDateChange(event: (value: number) => void) | 提供时间变化回调,该事件最小回调间隔为秒。<br/>- value: Unix Time Stamp,即自1970年1月1日(UTC)起经过的毫秒数。 |
## TextClockController ## TextClockController
...@@ -44,24 +59,6 @@ stop() ...@@ -44,24 +59,6 @@ stop()
停止文本时钟。 停止文本时钟。
## 属性
除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性:
| 名称 | 参数类型 | 描述 |
| ------ | --------------- | ------------------------------------------------------------ |
| format | string | 设置显示时间格式。<br/>日期间隔符固定为"/",时间间隔符为":"。<br/>如yyyyMMdd,yyyy-MM-dd显示为yyyy/MM/dd,<br/>hhmmss显示为hh:mm:ss。 <br/>时间格式只用写一位即可,如"hhmmss"等同于"hms"。<br/>支持的时间格式化字符串:<br/>- YYYY/yyyy:完整年份。<br/>- YY/yy:年份后两位。<br/>- M:月份(若想使用01月则使用MM)。<br/>- d:日期(若想使用01日则使用dd)。<br/>- D:年中日(一年中的第几天)。<br/>- H:24小时制。<br/>- h:12小时制。<br/>- m:分钟。<br/>- s:秒。<br/>- SSS:毫秒。<br/>默认值: 'hms'|
## 事件
除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件:
| 名称 | 功能描述 |
| -------------------------------------------- | ------------------------------------------------------------ |
| onDateChange(event: (value: number) => void) | 提供时间变化回调,该事件最小回调间隔为秒。<br /> value: Unix Time Stamp,即自1970年1月1日(UTC)起经过的毫秒数。 |
## 示例 ## 示例
```ts ```ts
...@@ -101,4 +98,3 @@ struct Second { ...@@ -101,4 +98,3 @@ struct Second {
} }
``` ```
![text_clock](figures/text_clock.gif) ![text_clock](figures/text_clock.gif)
...@@ -6,40 +6,33 @@ ...@@ -6,40 +6,33 @@
> >
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 > 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件 ## 子组件
## 接口 ## 接口
TextTimer(options?: { isCountDown?: boolean, count?: number, controller?: TextTimerController }) TextTimer(options?: { isCountDown?: boolean, count?: number, controller?: TextTimerController })
**参数:** **参数**
| 参数名 | 参数类型 | 必填 | 参数描述 | | 参数名 | 参数类型 | 必填 | 参数描述 |
| ----------- | -------- | -------- | -------- | -------- | | ----------- | -------- | -------- | -------- |
| isCountDown | boolean | 否 | 是否倒计时。<br/>默认值:false | | isCountDown | boolean | 否 | 是否倒计时。<br/>默认值:false |
| count | number | 否 | 倒计时时间(isCountDown为true时生效),单位为毫秒。<br/>-&nbsp;count&lt;=0时,使用默认值为倒计时初始值。<br/>-&nbsp;count&gt;0时,count值为倒计时初始值。<br/>默认值:60000 | | count | number | 否 | 倒计时时间(isCountDown为true时生效),单位为毫秒。最长不超过86400000毫秒(24小时)。&nbsp;0&lt;count&lt;86400000时,count值为倒计时初始值。否则,使用默认值为倒计时初始值。<br/>默认值:60000 |
| controller | [TextTimerController](#texttimercontroller) | 否 | TextTimer控制器。 | | controller | [TextTimerController](#texttimercontroller) | 否 | TextTimer控制器。 |
## 属性 ## 属性
| 名称 | 参数类型 | 描述 | | 名称 | 参数类型 | 描述 |
| -------- | ---------------------- | ---------------------- | | -------- | ---------------------- | ---------------------- |
| format | string | 自定义格式,需至少包含一个hh、mm、ss、ms中的关键字。<br/>默认值:'hh:mm:ss.ms' | | format | string | 自定义格式,需至少包含一个HH、mm、ss、SS中的关键字。如使用yy、MM、dd等日期格式,则使用默认值。<br/>默认值:'HH:mm:ss.SS' |
## 事件 ## 事件
| 名称 | 功能描述 | | 名称 | 功能描述 |
| -------- | -------- | | ---------------------------------------- | ---------------------------------------- |
| onTimer(event:&nbsp;(utc:&nbsp;number,&nbsp;elapsedTime:&nbsp;number)&nbsp;=&gt;&nbsp;void) | 时间文本发生变化时触发。<br/>utc:当前显示的时间,单位为毫秒。<br/>elapsedTime:计时器经过的时间,单位为毫秒。 | | onTimer(event:&nbsp;(utc:&nbsp;number,&nbsp;elapsedTime:&nbsp;number)&nbsp;=&gt;&nbsp;void) | 时间文本发生变化时触发。<br/>utc:Linux时间戳,即自1970年1月1日起经过的毫秒数。<br/>elapsedTime:计时器经过的时间,单位为毫秒。 |
## TextTimerController ## TextTimerController
...@@ -70,7 +63,6 @@ reset() ...@@ -70,7 +63,6 @@ reset()
重置计时器。 重置计时器。
## 示例 ## 示例
```ts ```ts
...@@ -79,7 +71,7 @@ reset() ...@@ -79,7 +71,7 @@ reset()
@Component @Component
struct TextTimerExample { struct TextTimerExample {
textTimerController: TextTimerController = new TextTimerController() textTimerController: TextTimerController = new TextTimerController()
@State format: string = 'hh:mm:ss.ms' @State format: string = 'HH:mm:ss.SS'
build() { build() {
Column() { Column() {
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
| 名称 | 参数类型 | 描述 | | 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| backgroundColor | [ResourceColor](ts-types.md) | 设置组件的背景色。 | | backgroundColor | [ResourceColor](ts-types.md#resourcecolor) | 设置组件的背景色。 |
| backgroundImage | src:&nbsp;[ResourceStr](ts-types.md#resourcestr),<br/>repeat?:&nbsp;[ImageRepeat](ts-appendix-enums.md#imagerepeat) | src:图片地址,支持网络图片资源和本地图片资源地址(不支持svg类型的图片)。<br/>repeat:设置背景图片的重复样式,默认不重复。 | | backgroundImage | src:&nbsp;[ResourceStr](ts-types.md#resourcestr),<br/>repeat?:&nbsp;[ImageRepeat](ts-appendix-enums.md#imagerepeat) | src:图片地址,支持网络图片资源和本地图片资源地址(不支持svg类型的图片)。<br/>repeat:设置背景图片的重复样式,默认不重复。 |
| backgroundImageSize | {<br/>width?:&nbsp;[Length](ts-types.md#length),<br/>height?:&nbsp;[Length](ts-types.md#length)<br/>}&nbsp;\|&nbsp;[ImageSize](ts-appendix-enums.md#imagesize) | 设置背景图像的高度和宽度。当输入为{width:&nbsp;Length,&nbsp;height:&nbsp;Length}对象时,如果只设置一个属性,则第二个属性保持图片原始宽高比进行调整。默认保持原图的比例不变。<br/>默认值:ImageSize.Auto | | backgroundImageSize | {<br/>width?:&nbsp;[Length](ts-types.md#length),<br/>height?:&nbsp;[Length](ts-types.md#length)<br/>}&nbsp;\|&nbsp;[ImageSize](ts-appendix-enums.md#imagesize) | 设置背景图像的高度和宽度。当输入为{width:&nbsp;Length,&nbsp;height:&nbsp;Length}对象时,如果只设置一个属性,则第二个属性保持图片原始宽高比进行调整。默认保持原图的比例不变。<br/>默认值:ImageSize.Auto |
| backgroundImagePosition | [Position](ts-types.md#position8)&nbsp;\|&nbsp;[Alignment](ts-appendix-enums.md#alignment) | 设置背景图在组件中显示位置。<br/>默认值:<br/>{<br/>x:&nbsp;0,<br/>y:&nbsp;0<br/>} | | backgroundImagePosition | [Position](ts-types.md#position8)&nbsp;\|&nbsp;[Alignment](ts-appendix-enums.md#alignment) | 设置背景图在组件中显示位置。<br/>默认值:<br/>{<br/>x:&nbsp;0,<br/>y:&nbsp;0<br/>} |
......
...@@ -10,17 +10,17 @@ ...@@ -10,17 +10,17 @@
| 名称 | 参数类型 | 描述 | | 名称 | 参数类型 | 描述 |
| ---------- | ---------------------------------------- | --------------------------------------- | | ---------- | ---------------------------------------- | --------------------------------------- |
| borderImage | BorderImageOption | 图片边框或者渐变色边框设置接口。 | | borderImage | [BorderImageOption](#borderimageoption对象说明) | 图片边框或者渐变色边框设置接口。 |
## BorderImageOption对象说明 ## BorderImageOption对象说明
| 名称 | 类型 | 描述 | | 名称 | 类型 | 描述 |
| ---------- | ---------------------------------------- | --------------------------------------- | | ---------- | ---------------------------------------- | --------------------------------------- |
| source | string \| [Resource](ts-types.md#resource) \| [linearGradient](ts-universal-attributes-gradient-color.md) | 边框图源或者渐变色设置。 | | source | string \| [Resource](ts-types.md#resource) \| [linearGradient](ts-universal-attributes-gradient-color.md) | 边框图源或者渐变色设置。 |
| slice | [Length](ts-types.md#length)\| [EdgeWidths](ts-types.md#edgewidths9) | 设置图片边框切割宽度。<br/>默认值:0 | | slice | [Length](ts-types.md#length) \| [EdgeWidths](ts-types.md#edgewidths9) | 设置图片边框切割宽度。<br/>默认值:0 |
| width | [Length](ts-types.md#length)\| [EdgeWidths](ts-types.md#edgewidths9) | 设置图片边框宽度。<br/>默认值:0 | | width | [Length](ts-types.md#length) \| [EdgeWidths](ts-types.md#edgewidths9) | 设置图片边框宽度。<br/>默认值:0 |
| outset | [Length](ts-types.md#length)\| [EdgeWidths](ts-types.md#edgewidths9) | 设置边框图片向外延伸距离。<br/>默认值:0 | | outset | [Length](ts-types.md#length) \| [EdgeWidths](ts-types.md#edgewidths9) | 设置边框图片向外延伸距离。<br/>默认值:0 |
| RepeatMode | RepeatMode | 设置边框图片的重复方式。<br/>默认值:RepeatMode.Stretch | | repeat | [RepeatMode](#repeatmode枚举说明) | 设置边框图片的重复方式。<br/>默认值:RepeatMode.Stretch |
| fill | boolean | 设置边框图片中心填充。<br/>默认值:false | | fill | boolean | 设置边框图片中心填充。<br/>默认值:false |
...@@ -45,7 +45,7 @@ struct Index { ...@@ -45,7 +45,7 @@ struct Index {
build() { build() {
Row() { Row() {
Column() { Column() {
Text('This is\nborderImage.').textAlign(TextAlign.Center) Text('This is borderImage.').textAlign(TextAlign.Center)
.borderImage({ .borderImage({
source: "borderOrigin.png", source: "borderOrigin.png",
slice: {top:"31%", bottom:"31%", left:"31%", right:"31%"}, slice: {top:"31%", bottom:"31%", left:"31%", right:"31%"},
...@@ -53,7 +53,7 @@ struct Index { ...@@ -53,7 +53,7 @@ struct Index {
outset: {top:"5px", bottom:"5px", left:"5px", right:"5px"}, outset: {top:"5px", bottom:"5px", left:"5px", right:"5px"},
repeat: RepeatMode.Repeat, repeat: RepeatMode.Repeat,
fill: false fill: false
}); })
} }
.width('100%') .width('100%')
} }
...@@ -70,20 +70,21 @@ struct Index { ...@@ -70,20 +70,21 @@ struct Index {
@Entry @Entry
@Component @Component
struct Index { struct Index {
build() { build() {
Row() { Row() {
Column() { Column() {
Text('This is\ngradient color.').textAlign(TextAlign.Center) Text('This is gradient color.').textAlign(TextAlign.Center)
.borderImage({ .borderImage({
source: {angle:90, source: {
angle: 90,
direction: GradientDirection.Left, direction: GradientDirection.Left,
colors: [[0xAEE1E1, 0.0], [0xD3E0DC, 0.3], [0xFCD1D1, 1.0]]}, colors: [[0xAEE1E1, 0.0], [0xD3E0DC, 0.3], [0xFCD1D1, 1.0]]
slice: {top:10, bottom:10, left:10, right:10}, },
width: {top:"10px", bottom:"10px", left: "10px", right:"10px"}, slice: { top: 10, bottom: 10, left: 10, right: 10 },
width: { top: "10px", bottom: "10px", left: "10px", right: "10px" },
repeat: RepeatMode.Stretch, repeat: RepeatMode.Stretch,
fill: false fill: false
}); })
} }
.width('100%') .width('100%')
} }
......
...@@ -13,11 +13,11 @@ ...@@ -13,11 +13,11 @@
| 名称 | 参数类型 | 描述 | | 名称 | 参数类型 | 描述 |
| ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| border | {<br/>width?:&nbsp;[Length](ts-types.md#length)&nbsp;\|&nbsp;EdgeWidths<sup>9+</sup>,<br/>color?: &nbsp;[ResourceColor](ts-types.md#resourcecolor)&nbsp;\|&nbsp;EdgeColors<sup>9+</sup>,<br/>radius?: &nbsp;[Length](ts-types.md#length)&nbsp;\|&nbsp;BorderRadiuses<sup>9+</sup>,<br/>style?:&nbsp;[BorderStyle](ts-appendix-enums.md#borderstyle)&nbsp;\|&nbsp;EdgeStyles<sup>9+</sup><br/>} | 统一边框样式设置接口。<br/>-&nbsp;width:设置边框宽度。<br/>-&nbsp;color:设置边框颜色。<br/>-&nbsp;radius:设置边框圆角半径。<br/>-&nbsp;style:设置边框样式。 | | border | {<br/>width?:&nbsp;[Length](ts-types.md#length)&nbsp;\|&nbsp;[EdgeWidths](#edgewidths9对象说明)<sup>9+</sup>,<br/>color?: &nbsp;[ResourceColor](ts-types.md#resourcecolor)&nbsp;\|&nbsp;[EdgeColors](#edgecolors9对象说明)<sup>9+</sup>,<br/>radius?: &nbsp;[Length](ts-types.md#length)&nbsp;\|&nbsp;[BorderRadiuses](#borderradiuses9对象说明)<sup>9+</sup>,<br/>style?:&nbsp;[BorderStyle](ts-appendix-enums.md#borderstyle)&nbsp;\|&nbsp;[EdgeStyles](#edgestyles9对象说明)<sup>9+</sup><br/>} | 统一边框样式设置接口。<br/>-&nbsp;width:设置边框宽度。<br/>-&nbsp;color:设置边框颜色。<br/>-&nbsp;radius:设置边框圆角半径。<br/>-&nbsp;style:设置边框样式。 |
| borderStyle | [BorderStyle](ts-appendix-enums.md#borderstyle) \| EdgeStyles<sup>9+</sup> | 设置元素的边框样式。<br/>默认值:BorderStyle.Solid | | borderStyle | [BorderStyle](ts-appendix-enums.md#borderstyle) \| [EdgeStyles](#edgestyles9对象说明)<sup>9+</sup> | 设置元素的边框样式。<br/>默认值:BorderStyle.Solid |
| borderWidth | [Length](ts-types.md#length) \| EdgeWidths<sup>9+</sup> | 设置元素的边框宽度,不支持百分比。 | | borderWidth | [Length](ts-types.md#length) \| [EdgeWidths](#edgewidths9对象说明)<sup>9+</sup> | 设置元素的边框宽度,不支持百分比。 |
| borderColor | [ResourceColor](ts-types.md#resourcecolor) \| EdgeColors<sup>9+</sup> | 设置元素的边框颜色。 | | borderColor | [ResourceColor](ts-types.md#resourcecolor) \| [EdgeColors](#edgecolors9对象说明)<sup>9+</sup> | 设置元素的边框颜色。 |
| borderRadius | [Length](ts-types.md#length) \| BorderRadiuses<sup>9+</sup> | 设置元素的边框圆角半径,不支持百分比。 | | borderRadius | [Length](ts-types.md#length) \| [BorderRadiuses](#borderradiuses9对象说明)<sup>9+</sup> | 设置元素的边框圆角半径,不支持百分比。 |
## EdgeWidths<sup>9+</sup>对象说明 ## EdgeWidths<sup>9+</sup>对象说明
...@@ -70,7 +70,6 @@ ...@@ -70,7 +70,6 @@
@Entry @Entry
@Component @Component
struct BorderExample { struct BorderExample {
build() { build() {
Column() { Column() {
Flex({ justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center }) { Flex({ justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center }) {
...@@ -83,6 +82,7 @@ struct BorderExample { ...@@ -83,6 +82,7 @@ struct BorderExample {
.border({ width: 5, color: 0x317AF7, radius: 10, style: BorderStyle.Dotted }) .border({ width: 5, color: 0x317AF7, radius: 10, style: BorderStyle.Dotted })
.width(120).height(120).textAlign(TextAlign.Center).fontSize(16) .width(120).height(120).textAlign(TextAlign.Center).fontSize(16)
}.width('100%').height(150) }.width('100%').height(150)
Text('.border') Text('.border')
.fontSize(50) .fontSize(50)
.width(300) .width(300)
......
...@@ -77,7 +77,7 @@ sendTouchEvent(event: TouchObject): boolean ...@@ -77,7 +77,7 @@ sendTouchEvent(event: TouchObject): boolean
| 参数 | 类型 | 必填 | 描述 | | 参数 | 类型 | 必填 | 描述 |
| ----- | ----------- | ---- | ------------------------------------------------------------ | | ----- | ----------- | ---- | ------------------------------------------------------------ |
| event | TouchObject | 是 | 触发触摸事件的位置,event参数见[TouchEvent](ts-universal-events-touch.md#touchevent对象说明)中TouchObject的介绍。 | | event | [TouchObject](ts-universal-events-touch.md#touchobject对象说明) | 是 | 触发触摸事件的位置,event参数见[TouchEvent](ts-universal-events-touch.md#touchevent对象说明)中TouchObject的介绍。 |
**返回值:** **返回值:**
...@@ -95,7 +95,7 @@ sendKeyEvent(event: KeyEvent): boolean ...@@ -95,7 +95,7 @@ sendKeyEvent(event: KeyEvent): boolean
| 参数 | 类型 | 必填 | 描述 | | 参数 | 类型 | 必填 | 描述 |
| ----- | -------- | ---- | ------------------------------------------------------------ | | ----- | -------- | ---- | ------------------------------------------------------------ |
| event | KeyEvent | 是 | 按键事件,event参数见[KeyEvent](ts-universal-events-key.md#keyevent对象说明)介绍。 | | event | [KeyEvent](ts-universal-events-key.md#keyevent对象说明) | 是 | 按键事件,event参数见[KeyEvent](ts-universal-events-key.md#keyevent对象说明)介绍。 |
**返回值:** **返回值:**
...@@ -113,7 +113,7 @@ sendMouseEvent(event: MouseEvent): boolean ...@@ -113,7 +113,7 @@ sendMouseEvent(event: MouseEvent): boolean
| 参数 | 类型 | 必填 | 描述 | | 参数 | 类型 | 必填 | 描述 |
| ----- | ---------- | ---- | --------------------------------------- | | ----- | ---------- | ---- | --------------------------------------- |
| event | MouseEvent | 是 | 鼠标事件,event参数见[MouseEvent](ts-universal-mouse-key.md#mouseevent对象说明)介绍。 | | event | [MouseEvent](ts-universal-mouse-key.md#mouseevent对象说明) | 是 | 鼠标事件,event参数见[MouseEvent](ts-universal-mouse-key.md#mouseevent对象说明)介绍。 |
**返回值:** **返回值:**
...@@ -132,6 +132,7 @@ class Utils { ...@@ -132,6 +132,7 @@ class Utils {
static rect_bottom; static rect_bottom;
static rect_value; static rect_value;
//获取组件所占矩形区域坐标
static getComponentRect(key) { static getComponentRect(key) {
let strJson = getInspectorByKey(key); let strJson = getInspectorByKey(key);
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
...@@ -171,7 +172,7 @@ struct IdExample { ...@@ -171,7 +172,7 @@ struct IdExample {
console.info(getInspectorTree()) console.info(getInspectorTree())
this.text = "Button 'click to start' is clicked" this.text = "Button 'click to start' is clicked"
setTimeout(() => { setTimeout(() => {
sendEventByKey("longClick", 11, "") sendEventByKey("longClick", 11, "") // 向id为"longClick"的组件发送长按事件
}, 2000) }, 2000)
}).id('click') }).id('click')
...@@ -183,18 +184,18 @@ struct IdExample { ...@@ -183,18 +184,18 @@ struct IdExample {
console.info('long clicked') console.info('long clicked')
this.text = "Button 'longClick' is longclicked" this.text = "Button 'longClick' is longclicked"
setTimeout(() => { setTimeout(() => {
let rect = Utils.getComponentRect('onTouch') let rect = Utils.getComponentRect('onTouch') // 获取id为"onTouch"组件的矩形区域坐标
let touchPoint: TouchObject = { let touchPoint: TouchObject = {
id: 1, id: 1,
x: rect.left + (rect.right - rect.left) / 2, x: rect.left + (rect.right - rect.left) / 2, // 组件中心点x坐标
y: rect.top + (rect.bottom - rect.top) / 2, y: rect.top + (rect.bottom - rect.top) / 2, // 组件中心点y坐标
type: TouchType.Down, type: TouchType.Down,
screenX: rect.left + (rect.right - rect.left) / 2, screenX: rect.left + (rect.right - rect.left) / 2, // 组件中心点x坐标
screenY: rect.left + (rect.right - rect.left) / 2, screenY: rect.left + (rect.right - rect.left) / 2, // 组件中心点y坐标
} }
sendTouchEvent(touchPoint) sendTouchEvent(touchPoint) // 发送触摸事件
touchPoint.type = TouchType.Up touchPoint.type = TouchType.Up
sendTouchEvent(touchPoint) sendTouchEvent(touchPoint) // 发送触摸事件
}, 2000) }, 2000)
})).id('longClick') })).id('longClick')
...@@ -205,14 +206,14 @@ struct IdExample { ...@@ -205,14 +206,14 @@ struct IdExample {
console.info('onTouch is clicked') console.info('onTouch is clicked')
this.text = "Button 'onTouch' is clicked" this.text = "Button 'onTouch' is clicked"
setTimeout(() => { setTimeout(() => {
let rect = Utils.getComponentRect('onMouse') let rect = Utils.getComponentRect('onMouse') // 获取id为"onMouse"组件的矩形区域坐标
let mouseEvent: MouseEvent = { let mouseEvent: MouseEvent = {
button: MouseButton.Left, button: MouseButton.Left,
action: MouseAction.Press, action: MouseAction.Press,
x: rect.left + (rect.right - rect.left) / 2, x: rect.left + (rect.right - rect.left) / 2, // 组件中心点x坐标
y: rect.top + (rect.bottom - rect.top) / 2, y: rect.top + (rect.bottom - rect.top) / 2, // 组件中心点y坐标
screenX: rect.left + (rect.right - rect.left) / 2, screenX: rect.left + (rect.right - rect.left) / 2, // 组件中心点x坐标
screenY: rect.top + (rect.bottom - rect.top) / 2, screenY: rect.top + (rect.bottom - rect.top) / 2, // 组件中心点y坐标
timestamp: 1, timestamp: 1,
target: { target: {
area: { area: {
...@@ -230,7 +231,7 @@ struct IdExample { ...@@ -230,7 +231,7 @@ struct IdExample {
}, },
source: SourceType.Mouse source: SourceType.Mouse
} }
sendMouseEvent(mouseEvent) sendMouseEvent(mouseEvent) // 发送鼠标事件
}, 2000) }, 2000)
}).id('onTouch') }).id('onTouch')
...@@ -250,7 +251,7 @@ struct IdExample { ...@@ -250,7 +251,7 @@ struct IdExample {
metaKey: 0, metaKey: 0,
timestamp: 0 timestamp: 0
} }
sendKeyEvent(keyEvent) sendKeyEvent(keyEvent) // 发送按键事件
}, 2000) }, 2000)
}).id('onMouse') }).id('onMouse')
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
| **名称** | **参数类型** | **描述** | | **名称** | **参数类型** | **描述** |
| -------------------- | -------- | ---------------------------------------- | | -------------------- | -------- | ---------------------------------------- |
| focusable | boolean | 设置当前组件是否可以获焦。<br/>**说明:**<br/>存在默认交互逻辑的组件例如Button、TextInput等,默认即为可获焦,Text、Image等组件则默认状态为不可获焦。 | | focusable | boolean | 设置当前组件是否可以获焦。<br/>**说明:**<br/>存在默认交互逻辑的组件例如Button、TextInput等,默认即为可获焦,Text、Image等组件则默认状态为不可获焦。 |
| tabIndex<sup>9+<sup> | number | 自定义组件tab键走焦能力,走焦顺序为:tabIndex大于0的组件依次递增走焦, tabIndex等于0的组件按组件树先后顺序走焦。<br />- tabIndex >= 0:表示元素是可聚焦的,并且可以通过tab键走焦来访问到该元素,按照tabIndex的数值递增而先后获焦。如果多个元素拥有相同的tabIndex,按照元素在当前组件树中的先后顺序获焦<br />- tabIndex < 0(通常是tabIndex = -1):表示元素是可聚焦的,但是不能通过tab键走焦来访问到该元素。<br/>默认值:0 | | tabIndex<sup>9+<sup> | number | 自定义组件tab键走焦能力,走焦顺序为:tabIndex大于0的组件依次递增走焦, tabIndex等于0的组件按组件树先后顺序走焦。<br />- tabIndex >= 0:表示元素是可聚焦的,并且可以通过tab键走焦来访问到该元素,tabIndex值越小,则优先获焦;反之,则后获焦。如果多个元素拥有相同的tabIndex,按照元素在当前组件树中的先后顺序获焦<br />- tabIndex < 0(通常是tabIndex = -1):表示元素是可聚焦的,但是不能通过tab键走焦来访问到该元素。<br/>默认值:0 |
| defaultFocus<sup>9+<sup> | boolean | 设置当前组件是否为当前页面上的默认焦点,仅在初次创建的页面第一次进入时生效。<br/>默认值:false | | defaultFocus<sup>9+<sup> | boolean | 设置当前组件是否为当前页面上的默认焦点,仅在初次创建的页面第一次进入时生效。<br/>默认值:false |
| groupDefaultFocus<sup>9+<sup> | boolean | 设置当前组件是否为当前组件所在容器获焦时的默认焦点,仅在初次创建容器节点第一次获焦时生效。<br/>默认值:false<br/>**说明:** 必须与tabIndex联合使用,当某个容器设置了tabIndex,且容器内某子组件设置了groupDefaultFocus,当该容器首次获焦时,会自动将焦点转移至该组件上。<br/> | | groupDefaultFocus<sup>9+<sup> | boolean | 设置当前组件是否为当前组件所在容器获焦时的默认焦点,仅在初次创建容器节点第一次获焦时生效。<br/>默认值:false<br/>**说明:** 必须与tabIndex联合使用,当某个容器设置了tabIndex,且容器内某子组件设置了groupDefaultFocus,当该容器首次获焦时,会自动将焦点转移至该组件上。<br/> |
| focusOnTouch<sup>9+<sup> | boolean | 设置当前组件是否支持点击获焦能力。<br/>默认值:false<br/>**说明:** 仅在组件可点击时才能正常获取焦点。 | | focusOnTouch<sup>9+<sup> | boolean | 设置当前组件是否支持点击获焦能力。<br/>默认值:false<br/>**说明:** 仅在组件可点击时才能正常获取焦点。 |
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
| 名称 | 参数类型 | 描述 | | 名称 | 参数类型 | 描述 |
| -------------- | -------------------------------------------- | ----------------------------------- | | -------------- | -------------------------------------------- | ----------------------------------- |
| linearGradient | {<br/>angle?:&nbsp;number \| string,<br/>direction?:&nbsp;[GradientDirection](ts-appendix-enums.md#gradientdirection),<br/>colors:&nbsp;Array&lt;[ColorStop](ts-basic-components-gauge.md#colorstop)&gt;,<br/>repeating?:&nbsp;boolean<br/>} | 线性渐变。<br/>- angle:&nbsp;线性渐变的角度。<br/>- direction:&nbsp;线性渐变的方向,设置angle后不生效。<br/>- colors:&nbsp;为渐变的颜色描述。<br/>- repeating:&nbsp;为渐变的颜色重复着色。 | | linearGradient | {<br/>angle?:&nbsp;number \| string,<br/>direction?:&nbsp;[GradientDirection](ts-appendix-enums.md#gradientdirection),<br/>colors:&nbsp;Array&lt;[ColorStop](ts-basic-components-gauge.md#colorstop)&gt;,<br/>repeating?:&nbsp;boolean<br/>} | 线性渐变。<br/>- angle:&nbsp;线性渐变的起始角度。0点方向顺时针旋转为正向角度。<br/> 默认值:180<br/>- direction:&nbsp;线性渐变的方向,设置angle后不生效。<br/> 默认值:GradientDirection.Bottom <br/>- colors:&nbsp;为渐变的颜色描述。<br/>- repeating:&nbsp;为渐变的颜色重复着色。 <br/> 默认值:false |
| sweepGradient | {<br/>center:&nbsp;Point,<br/>start?:&nbsp;number \| string,<br/>end?:&nbsp;number \| string,<br/>rotation?:&nbsp;number\|string,<br/>colors:&nbsp;Array&lt;[ColorStop](ts-basic-components-gauge.md#colorstop)&gt;,<br/>repeating?:&nbsp;boolean<br/>} | 角度渐变。<br/>- center:为角度渐变的中心点<br/>- start:角度渐变的起点。<br/>- end:角度渐变的终点。<br/>- rotation:&nbsp;角度渐变的旋转角度。<br/>- colors:&nbsp;为渐变的颜色描述。<br/>- repeating:&nbsp;为渐变的颜色重复着色。 | | sweepGradient | {<br/>center:&nbsp;Point,<br/>start?:&nbsp;number \| string,<br/>end?:&nbsp;number \| string,<br/>rotation?:&nbsp;number\|string,<br/>colors:&nbsp;Array&lt;[ColorStop](ts-basic-components-gauge.md#colorstop)&gt;,<br/>repeating?:&nbsp;boolean<br/>} | 角度渐变。<br/>- center:为角度渐变的中心点,即相对于当前组件左上角的坐标。<br/>- start:角度渐变的起点。<br/> 默认值:0<br/>- end:角度渐变的终点。<br/> 默认值:0<br/>- rotation:&nbsp;角度渐变的旋转角度。<br/> 默认值:0<br/>- colors:&nbsp;为渐变的颜色描述。<br/>- repeating:&nbsp;为渐变的颜色重复着色。<br/> 默认值:false |
| radialGradient | {<br/>center:&nbsp;Point,<br/>radius:&nbsp;number \| string,<br/>colors:&nbsp;Array&lt;[ColorStop](ts-basic-components-gauge.md#colorstop)&gt;,<br/>repeating?:&nbsp;boolean<br/>} | 径向渐变。<br/>- center:径向渐变的中心点。<br/>- radius:径向渐变的半径。<br/>- colors:&nbsp;为渐变的颜色描述。<br/>- repeating:&nbsp;为渐变的颜色重复着色。 | | radialGradient | {<br/>center:&nbsp;Point,<br/> radius:&nbsp;number \| string,<br/>colors:&nbsp;Array&lt;[ColorStop](ts-basic-components-gauge.md#colorstop)&gt;,<br/>repeating?:&nbsp;boolean<br/>} | 径向渐变。<br/>- center:径向渐变的中心点,即相对于当前组件左上角的坐标。<br/>- radius:径向渐变的半径。<br/>- colors:&nbsp;为渐变的颜色描述。<br/>- repeating:&nbsp;为渐变的颜色重复着色。<br/> 默认值:false |
## 示例 ## 示例
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
@Entry @Entry
@Component @Component
struct ColorGradientExample { struct ColorGradientExample {
build() { build() {
Column({ space: 5 }) { Column({ space: 5 }) {
Text('linearGradient').fontSize(12).width('90%').fontColor(0xCCCCCC) Text('linearGradient').fontSize(12).width('90%').fontColor(0xCCCCCC)
...@@ -33,8 +32,32 @@ struct ColorGradientExample { ...@@ -33,8 +32,32 @@ struct ColorGradientExample {
.height(50) .height(50)
.linearGradient({ .linearGradient({
angle: 90, angle: 90,
colors: [[0xAEE1E1, 0.0], [0xD3E0DC, 0.3], [0xFCD1D1, 1.0]] colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 1.0]]
}) })
Text('linearGradient Repeat').fontSize(12).width('90%').fontColor(0xCCCCCC)
Row()
.width('90%')
.height(50)
.linearGradient({
direction: GradientDirection.Left, // 渐变方向
repeating: true, // 渐变颜色是否重复
colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 0.5]] // 数组末尾元素占比小于1时满足重复着色效果
})
}
.width('100%')
.padding({ top: 5 })
}
}
```
![zh-cn_image_0000001219864149](figures/gradientColor1.png)
```ts
@Entry
@Component
struct ColorGradientExample {
build() {
Column({ space: 5 }) {
Text('sweepGradient').fontSize(12).width('90%').fontColor(0xCCCCCC) Text('sweepGradient').fontSize(12).width('90%').fontColor(0xCCCCCC)
Row() Row()
.width(100) .width(100)
...@@ -43,8 +66,37 @@ struct ColorGradientExample { ...@@ -43,8 +66,37 @@ struct ColorGradientExample {
center: [50, 50], center: [50, 50],
start: 0, start: 0,
end: 359, end: 359,
colors: [[0xAEE1E1, 0.0], [0xD3E0DC, 0.3], [0xFCD1D1, 1.0]] colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 1.0]]
}) })
Text('sweepGradient Reapeat').fontSize(12).width('90%').fontColor(0xCCCCCC)
Row()
.width(100)
.height(100)
.sweepGradient({
center: [50, 50],
start: 0,
end: 359,
rotation: 45, // 旋转角度
repeating: true, // 渐变颜色是否重复
colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 0.5]] // 数组末尾元素占比小于1时满足重复着色效果
})
}
.width('100%')
.padding({ top: 5 })
}
}
```
![zh-cn_image_0000001219864149](figures/gradientColor2.png)
```ts
// xxx.ets
@Entry
@Component
struct ColorGradientExample {
build() {
Column({ space: 5 }) {
Text('radialGradient').fontSize(12).width('90%').fontColor(0xCCCCCC) Text('radialGradient').fontSize(12).width('90%').fontColor(0xCCCCCC)
Row() Row()
.width(100) .width(100)
...@@ -52,7 +104,17 @@ struct ColorGradientExample { ...@@ -52,7 +104,17 @@ struct ColorGradientExample {
.radialGradient({ .radialGradient({
center: [50, 50], center: [50, 50],
radius: 60, radius: 60,
colors:[[0xAEE1E1, 0.0], [0xD3E0DC, 0.3], [0xFCD1D1, 1.0]] colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 1.0]]
})
Text('radialGradient Repeat').fontSize(12).width('90%').fontColor(0xCCCCCC)
Row()
.width(100)
.height(100)
.radialGradient({
center: [50, 50],
radius: 60,
repeating: true,
colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 0.5]] // 数组末尾元素占比小于1时满足重复着色效果
}) })
} }
.width('100%') .width('100%')
...@@ -61,4 +123,4 @@ struct ColorGradientExample { ...@@ -61,4 +123,4 @@ struct ColorGradientExample {
} }
``` ```
![zh-cn_image_0000001219864149](figures/zh-cn_image_0000001219864149.png) ![zh-cn_image_0000001219864149](figures/gradientColor3.png)
# 触摸测试控制 # 触摸测试控制
设置组件的触摸测试类型。ArkUI开发框架在处理触屏事件时,会在触屏事件触发前,进行按压点和组件区域的触摸测试来收集需要响应触屏事件的组件,然后基于触摸测试结果分发相应的触屏事件。hitTestBehavior属性可以设置不同的触摸测试响应模式,影响组件的触摸测试收集结果,最终影响后续的触屏事件分发,具体影响参考HitTestMode枚举说明。 设置组件的触摸测试类型。ArkUI开发框架在处理触屏事件时,会在触屏事件触发前,进行按压点和组件区域的触摸测试来收集需要响应触屏事件的组件,然后基于触摸测试结果分发相应的触屏事件。hitTestBehavior属性可以设置不同的触摸测试响应模式,影响组件的触摸测试收集结果,最终影响后续的触屏事件分发,具体影响参考[HitTestMode](#hittestmode枚举说明)枚举说明。
> **说明:** > **说明:**
> - 从API Version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 > - 从API Version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
| **名称** | **参数类型** | **描述** | | **名称** | **参数类型** | **描述** |
| -------------------- | -------- | ---------------------------------------- | | -------------------- | -------- | ---------------------------------------- |
| hitTestBehavior | HitTestMode | 设置当前组件的触摸测试类型。<br>默认值: HitTestMode.Default | | hitTestBehavior | [HitTestMode](#hittestmode枚举说明) | 设置当前组件的触摸测试类型。<br>默认值: HitTestMode.Default |
## HitTestMode 枚举说明 ## HitTestMode枚举说明
| 名称 | 描述 | | 名称 | 描述 |
| ------------| ----------------------------------------- | | ------------| ----------------------------------------- |
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
| message | string | 是 | 弹窗信息内容。 | | message | string | 是 | 弹窗信息内容。 |
| placementOnTop | boolean | 否 | 是否在组件上方显示,默认值为false。 | | placementOnTop | boolean | 否 | 是否在组件上方显示,默认值为false。 |
| arrowOffset<sup>9+</sup> | [Length](ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧时,默认居上。 | | arrowOffset<sup>9+</sup> | [Length](ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧时,默认居上。 |
| showInSubWindow<sup>9+</sup> | boolean | 否 | 是否在子窗口显示气泡,默认值为false。 |
| primaryButton | {<br/>value:&nbsp;string,<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void<br/>} | 否 | 第一个按钮。<br/>value:&nbsp;弹窗里主按钮的文本。<br/>action:&nbsp;点击主按钮的回调函数。 | | primaryButton | {<br/>value:&nbsp;string,<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void<br/>} | 否 | 第一个按钮。<br/>value:&nbsp;弹窗里主按钮的文本。<br/>action:&nbsp;点击主按钮的回调函数。 |
| secondaryButton | {<br/>value:&nbsp;string,<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void<br/>} | 否 | 第二个按钮。<br/>value:&nbsp;弹窗里辅助按钮的文本。<br/>action:&nbsp;点击辅助按钮的回调函数。 | | secondaryButton | {<br/>value:&nbsp;string,<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void<br/>} | 否 | 第二个按钮。<br/>value:&nbsp;弹窗里辅助按钮的文本。<br/>action:&nbsp;点击辅助按钮的回调函数。 |
| onStateChange | (event:&nbsp;{&nbsp;isVisible:&nbsp;boolean&nbsp;})&nbsp;=&gt;&nbsp;void | 否 | 弹窗状态变化事件回调,参数isVisible为弹窗当前的显示状态。 | | onStateChange | (event:&nbsp;{&nbsp;isVisible:&nbsp;boolean&nbsp;})&nbsp;=&gt;&nbsp;void | 否 | 弹窗状态变化事件回调,参数isVisible为弹窗当前的显示状态。 |
...@@ -32,6 +33,7 @@ ...@@ -32,6 +33,7 @@
| builder | [CustomBuilder](ts-types.md#custombuilder8) | 是 | 提示气泡内容的构造器。 | | builder | [CustomBuilder](ts-types.md#custombuilder8) | 是 | 提示气泡内容的构造器。 |
| placement | [Placement](ts-appendix-enums.md#placement8) | 否 | 气泡组件优先显示的位置,当前位置显示不下时,会自动调整位置。<br/>默认值:Placement.Bottom | | placement | [Placement](ts-appendix-enums.md#placement8) | 否 | 气泡组件优先显示的位置,当前位置显示不下时,会自动调整位置。<br/>默认值:Placement.Bottom |
| arrowOffset<sup>9+</sup> | [Length](ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧时,默认居上。 | | arrowOffset<sup>9+</sup> | [Length](ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧时,默认居上。 |
| showInSubWindow<sup>9+</sup> | boolean | 否 | 是否在子窗口显示气泡,默认值为false。 |
| maskColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 提示气泡遮障层的颜色。 | | maskColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 提示气泡遮障层的颜色。 |
| popupColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 提示气泡的颜色。 | | popupColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 提示气泡的颜色。 |
| enableArrow | boolean | 否 | 是否显示箭头。<br/>从API Version 9开始,如果箭头所在方位侧的气泡长度不足以显示下箭头,则会默认不显示箭头。比如:placement设置为Left,但气泡高度小于箭头的宽度(32vp),则实际不会显示箭头。<br/>默认值:true | | enableArrow | boolean | 否 | 是否显示箭头。<br/>从API Version 9开始,如果箭头所在方位侧的气泡长度不足以显示下箭头,则会默认不显示箭头。比如:placement设置为Left,但气泡高度小于箭头的宽度(32vp),则实际不会显示箭头。<br/>默认值:true |
...@@ -61,16 +63,33 @@ struct PopupExample { ...@@ -61,16 +63,33 @@ struct PopupExample {
// PopupOptions 类型设置弹框内容 // PopupOptions 类型设置弹框内容
Button('PopupOptions') Button('PopupOptions')
.onClick(() => { .onClick(() => {
this.handlePopup = !this.handlePopup //点击展示弹框 this.noHandlePopup = !this.noHandlePopup;
}) })
.bindPopup(this.handlePopup, { .bindPopup(this.noHandlePopup, {
message: 'This is a popup with PopupOptions', message: 'content1 content1',
placementOnTop: false, placementOnTop: false,
// 第一个按钮 showInSubWindow:true,
onStateChange: (e) => {
console.info(e.isVisible.toString())
if (!e.isVisible) {
this.noHandlePopup = false;
}
}
})
.position({ x: 100, y: 50 })
Button('with handle popup')
.onClick(() => {
this.handlePopup = !this.handlePopup;
})
.bindPopup(this.handlePopup, {
message: 'content2 content2',
placementOnTop: true,
showInSubWindow:false,
primaryButton: { primaryButton: {
value: 'confirm', value: 'confirm',
action: () => { action: () => {
this.handlePopup = !this.handlePopup this.handlePopup = !this.handlePopup;
console.info('ok Button click') console.info('ok Button click')
} }
}, },
...@@ -78,14 +97,14 @@ struct PopupExample { ...@@ -78,14 +97,14 @@ struct PopupExample {
secondaryButton: { secondaryButton: {
value: 'cancle', value: 'cancle',
action: () => { action: () => {
this.handlePopup = !this.handlePopup this.handlePopup = !this.handlePopup;
console.info('cancle Button click') console.info('cancle Button click')
} }
}, },
onStateChange: (e) => { onStateChange: (e) => {
console.info(e.isVisible.toString()) console.info(e.isVisible.toString())
if (!e.isVisible) { if (!e.isVisible) {
this.handlePopup = false this.handlePopup = false;
} }
} }
}) })
...@@ -95,7 +114,7 @@ struct PopupExample { ...@@ -95,7 +114,7 @@ struct PopupExample {
// CustomPopupOptions 类型设置弹框内容 // CustomPopupOptions 类型设置弹框内容
Button('CustomPopupOptions') Button('CustomPopupOptions')
.onClick(() => { .onClick(() => {
this.customPopup = !this.customPopup this.customPopup = !this.customPopup;
}) })
.bindPopup(this.customPopup, { .bindPopup(this.customPopup, {
builder: this.popupBuilder, builder: this.popupBuilder,
...@@ -103,10 +122,10 @@ struct PopupExample { ...@@ -103,10 +122,10 @@ struct PopupExample {
maskColor: 0x33000000, maskColor: 0x33000000,
popupColor: Color.Yellow, popupColor: Color.Yellow,
enableArrow: true, enableArrow: true,
autoCancel: true, showInSubWindow:false,
onStateChange: (e) => { onStateChange: (e) => {
if (!e.isVisible) { if (!e.isVisible) {
this.customPopup = false this.customPopup = false;
} }
} }
}) })
......
# DistributedSchedule错误码
## 201 权限校验失败
### 错误信息
Permission denied.
### 可能原因
该错误码表示权限校验失败,可能原因是未配置对应权限。
### 处理步骤
配置权限ohos.permission.MANAGER_MISSIONS或ohos.permission.DISTRIBUTED_DATASYNC。
## 401 参数检查错误
### 错误信息
The parameter check failed.
### 可能原因
该错误码表示入参检查错误,可能原因是callback入参检查错误。
### 处理步骤
检查入参callback是否为合法值。
## 16600001 系统服务工作异常
### 错误信息
The system ability work abnormally.
### 可能原因
该错误码表示系统服务工作异常,可能原因如下。
1. DMS服务没有正常启动。
2. DMS的binder对象无法正常获取。
3. 流转依赖的其他服务没有正常启动或者binder对象无法获取。
### 处理步骤
系统服务内部工作异常,请稍后重试,或者重启设备尝试。
## 16600002 指定的token或callback未注册
### 错误信息
The specified token or callback has not registered.
### 可能原因
该错误码可能原因是指定的token或callback未注册。
### 处理步骤
请先注册token或callback。
## 16600003 应用注册token已达到最大次数限制
### 错误信息
The number of token registration times has reached the upper limit.
### 可能原因
该错误码可能原因是应用注册token已达到最大次数限制。
### 处理步骤
请勿频繁注册,请使用已注册的token。
## 16600004 指定的callback已注册
### 错误信息
The specified callback has been registered.
### 可能原因
该错误码表示指定的callback已注册,可能原因是使用相同的callback重复注册。
### 处理步骤
请勿使用相同的callback重复注册。
## 16300501 系统服务工作异常
### 错误信息
The system ability work abnormally.
### 可能原因
该错误码表示系统服务工作异常,可能原因如下。
1. DMS服务没有正常启动。
2. DMS的binder对象无法正常获取。
3. 流转依赖的其他服务没有正常启动或者binder对象无法获取。
### 处理步骤
系统服务内部工作异常,请稍后重试,或者重启设备尝试。
## 16300502 获取指定的missionId的missionInfo失败
### 错误信息
Failed to get the missionInfo of the specified missionId.
### 可能原因
该错误码表示获取指定的missionId的missionInfo失败,可能原因如下。
1. missionId输入错误。
2. missionId对应的missionInfo确实不存在。
### 处理步骤
请检查输入的missionId是否正确。
## 16300503 远端未安装应用且不支持免安装
### 错误信息
The application is not installed on the remote end and installation-free is not supported.
### 可能原因
该错误码可能原因是远端未安装迁移应用并且不支持免安装。
### 处理步骤
1. 请检查远端是否已安装需要迁移的应用。
2. 请检查远端是否支持免安装。
## 16300504 远端未安装应用但支持免安装,需使用免安装标识重试
### 错误信息
The application is not installed on the remote end but installation-free is supported, try again with freeInstall flag.
### 可能原因
该错误码可能原因是远端未安装应用但支持免安装,使用时未使用免安装的标识。
### 处理步骤
请使用免安装的标识重试。
## 16300505 操作设备必须是迁移的应用所在的设备或需迁移到的目标设备
### 错误信息
The operation device must be the device where the application to be continued is located or the target device to be continued.
### 可能原因
该错误码可能原因是操作设备不是迁移的应用所在的设备或需迁移到的目标设备。
### 处理步骤
请检查操作设备是否是迁移的应用所在的设备或需迁移到的目标设备。
## 16300506 本地迁移任务已在进行中
### 错误信息
The local continuation task is already in progress.
### 可能原因
该错误码表示本地迁移任务已在进行中,可能原因是已经发起了迁移任务还未结束。
### 处理步骤
请检查是否已经发起了迁移并未结束。
## 3 序列化对象失败
### 错误信息
Failed to flatten the object.
### 可能原因
该错误码表示对象序列化过程中出现错误,可能原因是系统参数DMS_PROXY_INTERFACE_TOKEN序列化写失败。
### 处理步骤
请检查系统功能是否正常或者重启。
## 7 空对象
### 错误信息
The object is null.
### 可能原因
该错误码表示接口依赖的服务对象或参数对象为空,可能原因如下。
1. 入参序列化读失败。
2. DMS服务没有正常启动或binder对象无法正常获取。
3. DMS依赖的其他服务没有正常启动或者binder对象无法获取。
### 处理步骤
1. 检查入参是否为有效合法值。
2. 检查DMS服务是否正常启动,重新启动服务或重启设备。
3. 检查DMS依赖的其他服务是否正常启动,重新启动服务或重启设备。
## 29360207 注册超出最大次数
### 错误信息
The maximum number of registrations exceeded.
### 可能原因
该错误码可能原因是设备频繁注册,次数超出最大次数限制。
### 处理步骤
重启服务并且避免频繁注册。
## 29360208 token未注册
### 错误信息
The token has not registered.
### 可能原因
该错误码可能原因是未注册token。
### 处理步骤
注册token并使用已注册的token。
## 29360209 callback已注册
### 错误信息
Callback has been registered.
### 可能原因
该错误码能原因是指定的callback已经注册过。
### 处理步骤
请勿使用相同的callback重复注册。
## 29360210 callback未注册
### 错误信息
Callback has not been registered.
### 可能原因
该错误码可能原因是指定的callback未注册。
### 处理步骤
注册callback并使用已注册的callback。
## 29360211 连接ability失败
### 错误信息
Failed to connect ability.
### 可能原因
该错误码可能原因是指定token连接ability失败。
### 处理步骤
检查token是否有效以及相应ability是否正常服务,重新启动服务或重启设备。
## 29360214 callback类型错误
### 错误信息
The type of callback is not supported.
### 可能原因
该错误码表示callback类型错误,可能原因是不支持传入的callback类型。
### 处理步骤
请使用系统支持的callback类型并传入。
## 29360215 无效的连接状态
### 错误信息
Invalid continuation mode.
### 可能原因
该错误码表示无效的连接状态,可能原因是入参DeviceConnectState为非指定值。
### 处理步骤
设置指定合法的DeviceConnectState值。
## 29360216 无效的流转模式
### 错误信息
Invalid continuation mode.
### 可能原因
该错误码可能原因是入参ContinuationExtraParams.continuationMode为非指定值。
### 处理步骤
设置指定合法的ContinuationExtraParams.continuationMode值。
# 泛sensor子系统错误码
## 14500101 传感器服务异常
### 错误信息
Service exception.
### 错误描述
当调用sensor模块on、once、off接口时,若hdi服务异常,会报此错误码。
### 可能原因
访问hdi服务状态异常。
### 处理步骤
1. 定时重试操作,如间隔1s或者按照指数增长间隔重试。
2. 连续重试3次不可用则停止尝试,期间可优先尝试获取器件列表方式进一步获取设备可用性。
## 14600101 操作设备失败
### 错误信息
Device operation failed.
### 错误描述
当调用vibrator模块startVibration接口时,若hdi服务异常或者设备被占用,会报此错误码。
### 可能原因
1. 访问hdi服务状态异常。
2. 当前设备被占用。
### 处理步骤
1. 间隔一段时间重试操作,或按指数增长间隔重试;连续重试3次不可用则停止尝试,期间可优先尝试获取器件列表方式进一步获取设备可用性。
2. 设置振动优先级较低,尝试设置更高优先级。
\ No newline at end of file
...@@ -143,5 +143,7 @@ ...@@ -143,5 +143,7 @@
| ohos.permission.securityguard.REPORT_SECURITY_INFO | system_basic | system_grant | FALSE | 允许应用上报风险数据至设备风险管理平台。 | | ohos.permission.securityguard.REPORT_SECURITY_INFO | system_basic | system_grant | FALSE | 允许应用上报风险数据至设备风险管理平台。 |
| ohos.permission.securityguard.REQUEST_SECURITY_MODEL_RESULT | system_basic | system_grant | TRUE | 允许应用获取设备风险状态。 | | ohos.permission.securityguard.REQUEST_SECURITY_MODEL_RESULT | system_basic | system_grant | TRUE | 允许应用获取设备风险状态。 |
| ohos.permission.securityguard.REQUEST_SECURITY_EVENT_INFO | system_core | system_grant | FALSE | 允许应用获取风险详细数据。 | | ohos.permission.securityguard.REQUEST_SECURITY_EVENT_INFO | system_core | system_grant | FALSE | 允许应用获取风险详细数据。 |
| ohos.permission.READ_ACCESSIBILITY_CONFIG | system_basic | system_grant | FALSE | 允许应用读取无障碍配置信息。 |
| ohos.permission.WRITE_ACCESSIBILITY_CONFIG | system_basic | system_grant | FALSE | 允许应用设置无障碍配置信息。 |
| ohos.permission.ACCESS_CERT_MANAGER_INTERNAL | system_basic | system_grant | FALSE | 允许应用进行证书及凭据的安装、卸载、启用、禁用等操作。 | | ohos.permission.ACCESS_CERT_MANAGER_INTERNAL | system_basic | system_grant | FALSE | 允许应用进行证书及凭据的安装、卸载、启用、禁用等操作。 |
| ohos.permission.ACCESS_CERT_MANAGER | normal | system_grant | FALSE | 允许应用进行私有凭据的相关操作、查询证书状态等操作。 | | ohos.permission.ACCESS_CERT_MANAGER | normal | system_grant | FALSE | 允许应用进行私有凭据的相关操作、查询证书状态等操作。 |
...@@ -46,15 +46,25 @@ ...@@ -46,15 +46,25 @@
- 校验输入只包含可接受的字符(“白名单”形式),尤其需要注意一些特殊情况下的特殊字符。 - 校验输入只包含可接受的字符(“白名单”形式),尤其需要注意一些特殊情况下的特殊字符。
**外部数据校验原则** **外部数据校验原则**
**1.信任边界** **1.信任边界**
由于外部数据不可信,因此系统在运行过程中,如果数据传输与处理跨越不同的信任边界,为了防止攻击蔓延,必须对来自信任边界外的其他模块的数据进行合法性校验。 由于外部数据不可信,因此系统在运行过程中,如果数据传输与处理跨越不同的信任边界,为了防止攻击蔓延,必须对来自信任边界外的其他模块的数据进行合法性校验。
(a)so(或者dll)之间 (a)so(或者dll)之间
so或dll作为独立的第三方模块,用于对外导出公共的api函数,供其他模块进行函数调用。so/dll无法确定上层调用者是否传递了合法参数,因此so/dll的公共函数需要检查调用者提供参数的合法性。so/dll应该设计成低耦合、高复用性,尽管有些软件的so/dll当前设计成只在本软件中使用,但仍然应该将不同的so/dll模块视为不同的信任边界。 so或dll作为独立的第三方模块,用于对外导出公共的api函数,供其他模块进行函数调用。so/dll无法确定上层调用者是否传递了合法参数,因此so/dll的公共函数需要检查调用者提供参数的合法性。so/dll应该设计成低耦合、高复用性,尽管有些软件的so/dll当前设计成只在本软件中使用,但仍然应该将不同的so/dll模块视为不同的信任边界。
(b)进程与进程之间 (b)进程与进程之间
为防止通过高权限进程提权,进程与进程之间的IPC通信(包括单板之间的IPC通信、不同主机间的网络通信),应视为不同信任边界。 为防止通过高权限进程提权,进程与进程之间的IPC通信(包括单板之间的IPC通信、不同主机间的网络通信),应视为不同信任边界。
(c)应用层进程与操作系统内核 (c)应用层进程与操作系统内核
操作系统内核具有比应用层更高的权限,内核向应用层提供的接口,应该将来自应用层的数据作为不可信数据处理。 操作系统内核具有比应用层更高的权限,内核向应用层提供的接口,应该将来自应用层的数据作为不可信数据处理。
(d)可信执行环境内外环境 (d)可信执行环境内外环境
为防止攻击蔓延至可信执行环境,TEE、SGX等对外提供的接口,应该将来自外部的数据作为不可信数据处理。 为防止攻击蔓延至可信执行环境,TEE、SGX等对外提供的接口,应该将来自外部的数据作为不可信数据处理。
**2.外部数据校验** **2.外部数据校验**
...@@ -2746,7 +2756,7 @@ int Encode(unsigned char *in, size_t inSize, unsigned char *out, size_t maxSize) ...@@ -2746,7 +2756,7 @@ int Encode(unsigned char *in, size_t inSize, unsigned char *out, size_t maxSize)
**【描述】** **【描述】**
**说明:**内核 mmap接口中,经常使用remap_pfn_range()函数将设备物理内存映射到用户进程空间。如果映射起始地址等参数由用户态控制并缺少合法性校验,将导致用户态可通过映射读写任意内核地址。如果攻击者精心构造传入参数,甚至可在内核中执行任意代码。 **说明**内核 mmap接口中,经常使用remap_pfn_range()函数将设备物理内存映射到用户进程空间。如果映射起始地址等参数由用户态控制并缺少合法性校验,将导致用户态可通过映射读写任意内核地址。如果攻击者精心构造传入参数,甚至可在内核中执行任意代码。
**【错误代码示例】** **【错误代码示例】**
...@@ -2876,7 +2886,7 @@ ssize_t correct_write(struct file *file, const char __user *user_buf, size_t cou ...@@ -2876,7 +2886,7 @@ ssize_t correct_write(struct file *file, const char __user *user_buf, size_t cou
## 必须对copy_from_user()拷贝长度进行校验,防止缓冲区溢出 ## 必须对copy_from_user()拷贝长度进行校验,防止缓冲区溢出
**说明:**内核态从用户态拷贝数据时通常使用copy_from_user()函数,如果未对拷贝长度做校验或者校验不当,会造成内核缓冲区溢出,导致内核panic或提权。 **说明**内核态从用户态拷贝数据时通常使用copy_from_user()函数,如果未对拷贝长度做校验或者校验不当,会造成内核缓冲区溢出,导致内核panic或提权。
**【错误代码示例】** **【错误代码示例】**
...@@ -2921,7 +2931,7 @@ static long gser_ioctl(struct file *fp, unsigned cmd, unsigned long arg) ...@@ -2921,7 +2931,7 @@ static long gser_ioctl(struct file *fp, unsigned cmd, unsigned long arg)
**【描述】** **【描述】**
**说明:**内核态使用copy_to_user()向用户态拷贝数据时,当数据未完全初始化(如结构体成员未赋值、字节对齐引起的内存空洞等),会导致栈上指针等敏感信息泄漏。攻击者可利用绕过kaslr等安全机制。 **说明**内核态使用copy_to_user()向用户态拷贝数据时,当数据未完全初始化(如结构体成员未赋值、字节对齐引起的内存空洞等),会导致栈上指针等敏感信息泄漏。攻击者可利用绕过kaslr等安全机制。
**【错误代码示例】** **【错误代码示例】**
......
# xxx *(子系统名)* 错误码
> **说明:**
>
> *1、所有的写作说明,在完成写作后,都要删除。*
>
> *2、错误码文档的命名规则:统一前缀,命名格式为errorcode-xxx(具体子系统名).md。*
| | 说明项 | 细则 |
| ---- | ------------------------------ | ------------------------------------------------------------ |
| 1 | 错误码error.errorNumber | 按统一的错误码编号规则设计错误码ID。 |
| 2 | 错误信息error.message | **字段含义**:出现异常时,会给开发者抛出一个错误对象,对象里包括errorNumber和error.message,此处定义error.message的值,即英文错误码简述。<br/>**要求**<br/>1.应当简洁、具体,避免过于宽泛的定义。<br/>2.此处英文描述必须经过翻译中心审校。在提交本错误码设计评审前,请将预期的中英文message描述提供给翻译中心,将翻译中心审校后的英文填至此处。 |
| 3 | 错误简述<br/>Short Description | **字段含义**:中文错误码简述。<br/>**要求**<br/>1.与”错误信息“对应的中文简述,应当简洁、具体,避免过于宽泛的定义。 |
| 4 | 错误描述<br/>Description | **字段含义**:错误码详细描述,告知错误码所属的业务场景、产生位置等。<br/>**要求**<br/>1.描述错误码所属的业务场景(比如开发xx业务、开发xx功能时)。<br/>2.描述出现异常的具体现象、产生位置(比如xx模块、xx类、xx接口等),辅助开发者理解和处理异常。 |
| 5 | 可能原因<br/>Possible Causes | **字段含义**:列举出现该异常的所有可能原因(对应该错误码的产生机制)。<br/>**要求**<br/>1.全面、无遗漏。<br/>2.言简意赅。<br/>3.根据可能性从高到低排序。 |
| 6 | 处理步骤<br/>Procedure | **字段含义**:根据错误现象及可能原因,告知开发者遇到该异常时如何应对。<br/>**要求**<br/>1.采用step样式描述处理指导。每个大步骤与可能原因一一对应,按顺序分别给出各原因对应的处理指导。大步骤下可以有子步骤。<br/>2.步骤要明确、具体、可执行。涉及判断的,提供明确的判断标准。<br/>3.对系统或业务有影响的操作,在操作前以“注意”或“警告”形式提供警示信息。具体提示要求,请参见“风格指南”中的“提示与说明”:https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/style-guide/style-guide-content-elements.md |
## 1300001 重复操作 *(错误码number+空格+错误简述)*
### 错误信息
This is repeat operation.
### 错误描述
> **说明:**
>
> *1.描述**错误码所属的业务场景(比如开发xx业务、开发xx功能时)***。
>
> *2.描述**出现异常的具体现象、产生位置(比如xx模块、xx类、xx接口等)**,辅助开发者理解和处理异常。*
当对同一窗口对象存在重复操作时,xx模块(或xx类,或xx接口)会上报此错误码。
### 可能原因
> **说明:**
>
> *列举出现该异常的所有可能原因(对应该错误码的产生机制)。*
>
> *1.全面、无遗漏。*
>
> *2.言简意赅。*
>
> *3.根据可能性从高到低排序。*
1. 重复创建已创建的窗口。
2. xxx。
### 处理步骤
> **说明:**
>
> *根据错误现象及可能原因,告知开发者遇到该异常时如何应对。*
>
> *1.采用step样式描述处理指导。**每个大步骤与可能原因一一对应**,按顺序分别给出各原因对应的处理指导。**大步骤下可以有子步骤**。*
>
> *2.步骤要**明确、具体、可执行。涉及判断的,提供明确的判断标准**。*
>
> *3.对系统或业务有影响的操作,在操作前以“注意”或“警告”形式提供警示信息。具体提示要求,请参见“风格指南”中的“提示与说明”:https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/style-guide/style-guide-content-elements.md*
1. 检查该窗口是否已创建。
xxx。
```
uth([in] String appId, [in] IHwShareCallback callback);
int shareFaInfo([in] PacMapEx pacMapEx);
}
```
2. xxx。
a. xxx。
```
uth([in] String appId, [in] IHwShareCallback callback);
int shareFaInfo([in] PacMapEx pacMapEx);
}
```
b. xxx。
## 1300002 窗口状态异常
### 错误信息
xxx
### 错误描述
xxx
### 可能原因
1. xxx
### 处理步骤
1. 检查该窗口是否已创建。
xxx。
```
uth([in] String appId, [in] IHwShareCallback callback);
int shareFaInfo([in] PacMapEx pacMapEx);
}
```
2. xxx。
a. xxx。
```
uth([in] String appId, [in] IHwShareCallback callback);
int shareFaInfo([in] PacMapEx pacMapEx);
}
```
b. xxx。
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
## 常见编译问题和解决方法 ## 常见编译问题和解决方法
### 编译构建过程中,提示“usr/sbin/ninja: invalid option -- w” ### 提示“usr/sbin/ninja: invalid option -- w”
- **现象描述:** 编译失败,提示“usr/sbin/ninja: invalid option -- w”。 - **现象描述:** 编译失败,提示“usr/sbin/ninja: invalid option -- w”。
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
- **解决办法:** 卸载环境中ninja和gn,按照[获取工具](../../device-dev/get-code/gettools-ide.md) - **解决办法:** 卸载环境中ninja和gn,按照[获取工具](../../device-dev/get-code/gettools-ide.md)
### 编译构建过程中,提示“/usr/bin/ld: cannot find -lncurses” ### 提示“/usr/bin/ld: cannot find -lncurses”
- **现象描述:** 编译失败,提示“/usr/bin/ld: cannot find -lncurses”。 - **现象描述:** 编译失败,提示“/usr/bin/ld: cannot find -lncurses”。
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
sudo apt-get install lib32ncurses5-dev sudo apt-get install lib32ncurses5-dev
``` ```
### 编译构建过程中,提示“line 77: mcopy: command not found” ### 提示“line 77: mcopy: command not found”
- **现象描述:** 编译失败,提示“line 77: mcopy: command not found”。 - **现象描述:** 编译失败,提示“line 77: mcopy: command not found”。
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
sudo apt-get install dosfstools mtools sudo apt-get install dosfstools mtools
``` ```
### 编译构建过程中,提示“riscv32-unknown-elf-gcc: error trying to exec 'cc1': execvp: No such file or directory” ### 提示“riscv32-unknown-elf-gcc: error trying to exec 'cc1': execvp: No such file or directory”
- **现象描述:** 编译失败,提示“riscv32-unknown-elf-gcc: error trying to exec 'cc1': execvp: No such file or directory”。 - **现象描述:** 编译失败,提示“riscv32-unknown-elf-gcc: error trying to exec 'cc1': execvp: No such file or directory”。
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
使用chmod命令修改目录权限为755。 使用chmod命令修改目录权限为755。
### 编译构建过程中,提示“No module named 'Crypto'” ### 提示“No module named 'Crypto'”
- **现象描述:** 编译失败,提示“No module named 'Crypto'”。 - **现象描述:** 编译失败,提示“No module named 'Crypto'”。
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
sudo pip3 install pycryptodome sudo pip3 install pycryptodome
``` ```
### 编译构建过程中,提示“xx.sh : xx unexpected operator” ### 提示“xx.sh : xx unexpected operator”
- **现象描述:** 编译失败:“xx.sh [: xx unexpected operator”。 - **现象描述:** 编译失败:“xx.sh [: xx unexpected operator”。
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
``` ```
### 编译构建过程中,提示“some services are not authenticated. Listed as follow” ### 提示“some services are not authenticated. Listed as follow”
- **现象描述:** 编译失败:“some services are not authenticated. Listed as follow”。 - **现象描述:** 编译失败:“some services are not authenticated. Listed as follow”。
......
# HiTrace开发指导 # HiTraceChain开发指导
## 概述 ## 概述
HiTrace主要是对于跨设备/跨进程/跨线程的业务流程,通过相同的traceid在整个业务流程中传递,将流程处理过程中的调用关系、各种输出信息关联和展现出来,帮助使用者分析、定位问题和系统调优。 HiTraceChain主要是对于跨设备/跨进程/跨线程的业务流程,通过相同的traceid在整个业务流程中传递,将流程处理过程中的调用关系、各种输出信息关联和展现出来,帮助使用者分析、定位问题和系统调优。
## 应用场景 ## 应用场景
HiTrace在产品中应用场景如下,包括: HiTraceChain在产品中应用场景如下,包括:
- 端侧业务流程信息(日志、事件等)关联、上报 - 端侧业务流程信息(日志、事件等)关联、上报
...@@ -15,7 +15,7 @@ HiTrace在产品中应用场景如下,包括: ...@@ -15,7 +15,7 @@ HiTrace在产品中应用场景如下,包括:
- IDE对业务流程详细信息、耗时分布进行调试,辅助系统调优 - IDE对业务流程详细信息、耗时分布进行调试,辅助系统调优
**图1** HiTrace应用场景 **图1** HiTraceChain应用场景
![zh-cn_image_0000001216312860](figures/zh-cn_image_0000001216312860.png) ![zh-cn_image_0000001216312860](figures/zh-cn_image_0000001216312860.png)
...@@ -39,9 +39,9 @@ HiTrace在产品中应用场景如下,包括: ...@@ -39,9 +39,9 @@ HiTrace在产品中应用场景如下,包括:
## 接口说明 ## 接口说明
HiTrace提供C++、C接口。上层业务主要使用HiTrace跟踪启动、结束接口。 HiTraceChain提供C++、C接口。上层业务主要使用HiTraceChain跟踪启动、结束接口。
HiTrace实现在C层,主要原理是在一次业务调用流程中,利用通信传递traceid,在业务处理前将traceid设置到当前线程的TLS(Thread Local Storage)中,业务处理结束清除当前线程的TLS;这样的话,在业务处理中可以从当前线程的上下文TLS取到traceid,自动附加到日志、事件信息中。 HiTraceChain实现在C层,主要原理是在一次业务调用流程中,利用通信传递traceid,在业务处理前将traceid设置到当前线程的TLS(Thread Local Storage)中,业务处理结束清除当前线程的TLS;这样的话,在业务处理中可以从当前线程的上下文TLS取到traceid,自动附加到日志、事件信息中。
### 接口形式对比 ### 接口形式对比
...@@ -51,28 +51,28 @@ HiTrace实现在C层,主要原理是在一次业务调用流程中,利用通 ...@@ -51,28 +51,28 @@ HiTrace实现在C层,主要原理是在一次业务调用流程中,利用通
| | **C++** | **C** | | | **C++** | **C** |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| **类** | **函数** | **函数** | | **类** | **函数** | **函数** |
| HiTrace | HiTraceId&nbsp;Begin(const&nbsp;std::string&amp;&nbsp;name,&nbsp;int&nbsp;flags) | HiTraceIdStruct&nbsp;HiTraceBegin(const&nbsp;char\*&nbsp;name,&nbsp;int&nbsp;flags) | | HiTraceChain | HiTraceId&nbsp;Begin(const&nbsp;std::string&amp;&nbsp;name,&nbsp;int&nbsp;flags) | HiTraceIdStruct&nbsp;HiTraceChainBegin(const&nbsp;char\*&nbsp;name,&nbsp;int&nbsp;flags) |
| | void&nbsp;End(const&nbsp;HiTraceId&amp;&nbsp;id) | void&nbsp;HiTraceEnd(const&nbsp;HiTraceIdStruct\*&nbsp;pId) | | | void&nbsp;End(const&nbsp;HiTraceId&amp;&nbsp;id) | void&nbsp;HiTraceChainEnd(const&nbsp;HiTraceIdStruct\*&nbsp;pId) |
| | HiTraceId&nbsp;GetId(); | HiTraceIdStruct&nbsp;HiTraceGetId() | | | HiTraceId&nbsp;GetId(); | HiTraceIdStruct&nbsp;HiTraceChainGetId() |
| | void&nbsp;SetId(const&nbsp;HiTraceId&amp;&nbsp;id) | void&nbsp;HiTraceSetId(const&nbsp;HiTraceIdStruct\*&nbsp;pId) | | | void&nbsp;SetId(const&nbsp;HiTraceId&amp;&nbsp;id) | void&nbsp;HiTraceChainSetId(const&nbsp;HiTraceIdStruct\*&nbsp;pId) |
| | void&nbsp;ClearId() | void&nbsp;HiTraceClearId() | | | void&nbsp;ClearId() | void&nbsp;HiTraceChainClearId() |
| | HiTraceId&nbsp;CreateSpan() | HiTraceIdStruct&nbsp;HiTraceCreateSpan() | | | HiTraceId&nbsp;CreateSpan() | HiTraceIdStruct&nbsp;HiTraceChainCreateSpan() |
| | void&nbsp;Tracepoint(HiTraceTracepointType&nbsp;type,&nbsp;const&nbsp;HiTraceId&amp;&nbsp;id,&nbsp;const&nbsp;char\*&nbsp;fmt,&nbsp;...) | void&nbsp;HiTraceTracepoint(HiTraceTracepointType&nbsp;type,&nbsp;const&nbsp;HiTraceIdStruct_&nbsp;pId,&nbsp;const&nbsp;char_&nbsp;fmt,&nbsp;...) | | | void&nbsp;Tracepoint(HiTraceTracepointType&nbsp;type,&nbsp;const&nbsp;HiTraceId&amp;&nbsp;id,&nbsp;const&nbsp;char\*&nbsp;fmt,&nbsp;...) | void&nbsp;HiTraceChainTracepoint(HiTraceTracepointType&nbsp;type,&nbsp;const&nbsp;HiTraceIdStruct_&nbsp;pId,&nbsp;const&nbsp;char_&nbsp;fmt,&nbsp;...) |
| | void&nbsp;Tracepoint(HiTraceCommunicationMode&nbsp;mode,&nbsp;HiTraceTracepointType&nbsp;type,&nbsp;const&nbsp;HiTraceId&amp;&nbsp;id,&nbsp;const&nbsp;char\*&nbsp;fmt,&nbsp;...) | void&nbsp;HiTraceTracepointEx(HiTraceCommunicationMode&nbsp;mode,&nbsp;HiTraceTracepointType&nbsp;type,&nbsp;const&nbsp;HiTraceIdStruct_&nbsp;pId,&nbsp;const&nbsp;char_&nbsp;fmt,&nbsp;...) | | | void&nbsp;Tracepoint(HiTraceCommunicationMode&nbsp;mode,&nbsp;HiTraceTracepointType&nbsp;type,&nbsp;const&nbsp;HiTraceId&amp;&nbsp;id,&nbsp;const&nbsp;char\*&nbsp;fmt,&nbsp;...) | void&nbsp;HiTraceChainTracepointEx(HiTraceCommunicationMode&nbsp;mode,&nbsp;HiTraceTracepointType&nbsp;type,&nbsp;const&nbsp;HiTraceIdStruct_&nbsp;pId,&nbsp;const&nbsp;char_&nbsp;fmt,&nbsp;...) |
| HiTraceId | HiTraceId(); | void&nbsp;HiTraceInitId(HiTraceIdStruct\*&nbsp;pId) | | HiTraceId | HiTraceId(); | void&nbsp;HiTraceChainInitId(HiTraceIdStruct\*&nbsp;pId) |
| | HiTraceId(const&nbsp;uint8_t\*&nbsp;pIdArray,&nbsp;int&nbsp;len) | HiTraceIdStruct&nbsp;HiTraceBytesToId(const&nbsp;uint8_t\*&nbsp;pIdArray,&nbsp;int&nbsp;len) | | | HiTraceId(const&nbsp;uint8_t\*&nbsp;pIdArray,&nbsp;int&nbsp;len) | HiTraceIdStruct&nbsp;HiTraceChainBytesToId(const&nbsp;uint8_t\*&nbsp;pIdArray,&nbsp;int&nbsp;len) |
| | bool&nbsp;IsValid() | int&nbsp;HiTraceIsValid(const&nbsp;HiTraceIdStruct\*&nbsp;pId) | | | bool&nbsp;IsValid() | int&nbsp;HiTraceChainIsValid(const&nbsp;HiTraceIdStruct\*&nbsp;pId) |
| | bool&nbsp;IsFlagEnabled(HiTraceFlag&nbsp;flag) | int&nbsp;HiTraceIsFlagEnabled(const&nbsp;HiTraceIdStruct\*&nbsp;pId,&nbsp;HiTraceFlag&nbsp;flag) | | | bool&nbsp;IsFlagEnabled(HiTraceFlag&nbsp;flag) | int&nbsp;HiTraceChainIsFlagEnabled(const&nbsp;HiTraceIdStruct\*&nbsp;pId,&nbsp;HiTraceFlag&nbsp;flag) |
| | void&nbsp;EnableFlag(HiTraceFlag&nbsp;flag) | void&nbsp;HiTraceEnableFlag(HiTraceIdStruct\*&nbsp;pId,&nbsp;HiTraceFlag&nbsp;flag) | | | void&nbsp;EnableFlag(HiTraceFlag&nbsp;flag) | void&nbsp;HiTraceChainEnableFlag(HiTraceIdStruct\*&nbsp;pId,&nbsp;HiTraceFlag&nbsp;flag) |
| | int&nbsp;GetFlags() | int&nbsp;HiTraceGetFlags(const&nbsp;HiTraceIdStruct\*&nbsp;pId) | | | int&nbsp;GetFlags() | int&nbsp;HiTraceChainGetFlags(const&nbsp;HiTraceIdStruct\*&nbsp;pId) |
| | void&nbsp;SetFlags(int&nbsp;flags) | void&nbsp;HiTraceSetFlags(HiTraceIdStruct\*&nbsp;pId,&nbsp;int&nbsp;flags) | | | void&nbsp;SetFlags(int&nbsp;flags) | void&nbsp;HiTraceChainSetFlags(HiTraceIdStruct\*&nbsp;pId,&nbsp;int&nbsp;flags) |
| | uint64_t&nbsp;GetChainId() | uint64_t&nbsp;HiTraceGetChainId(const&nbsp;HiTraceIdStruct\*&nbsp;pId) | | | uint64_t&nbsp;GetChainId() | uint64_t&nbsp;HiTraceChainGetChainId(const&nbsp;HiTraceIdStruct\*&nbsp;pId) |
| | void&nbsp;SetChainId(uint64_t&nbsp;chainId) | void&nbsp;HiTraceSetChainId(HiTraceIdStruct\*&nbsp;pId,&nbsp;uint64_t&nbsp;chainId) | | | void&nbsp;SetChainId(uint64_t&nbsp;chainId) | void&nbsp;HiTraceChainSetChainId(HiTraceIdStruct\*&nbsp;pId,&nbsp;uint64_t&nbsp;chainId) |
| | uint64_t&nbsp;GetSpanId() | uint64_t&nbsp;HiTraceGetSpanId(const&nbsp;HiTraceIdStruct\*&nbsp;pId) | | | uint64_t&nbsp;GetSpanId() | uint64_t&nbsp;HiTraceChainGetSpanId(const&nbsp;HiTraceIdStruct\*&nbsp;pId) |
| | void&nbsp;SetSpanId(uint64_t&nbsp;spanId) | void&nbsp;HiTraceSetSpanId(HiTraceIdStruct\*&nbsp;pId,&nbsp;uint64_t&nbsp;spanId) | | | void&nbsp;SetSpanId(uint64_t&nbsp;spanId) | void&nbsp;HiTraceChainSetSpanId(HiTraceIdStruct\*&nbsp;pId,&nbsp;uint64_t&nbsp;spanId) |
| | uint64_t&nbsp;GetParentSpanId() | uint64_t&nbsp;HiTraceGetParentSpanId(const&nbsp;HiTraceIdStruct\*&nbsp;pId) | | | uint64_t&nbsp;GetParentSpanId() | uint64_t&nbsp;HiTraceChainGetParentSpanId(const&nbsp;HiTraceIdStruct\*&nbsp;pId) |
| | void&nbsp;SetParentSpanId(uint64_t&nbsp;parentSpanId) | void&nbsp;HiTraceSetParentSpanId(HiTraceIdStruct\*&nbsp;pId,&nbsp;uint64_t&nbsp;parentSpanId) | | | void&nbsp;SetParentSpanId(uint64_t&nbsp;parentSpanId) | void&nbsp;HiTraceChainSetParentSpanId(HiTraceIdStruct\*&nbsp;pId,&nbsp;uint64_t&nbsp;parentSpanId) |
| | int&nbsp;ToBytes(uint8_t\*&nbsp;pIdArray,&nbsp;int&nbsp;len) | int&nbsp;HiTraceIdToBytes(const&nbsp;HiTraceIdStruct_&nbsp;pId,&nbsp;uint8_t_&nbsp;pIdArray,&nbsp;int&nbsp;len) | | | int&nbsp;ToBytes(uint8_t\*&nbsp;pIdArray,&nbsp;int&nbsp;len) | int&nbsp;HiTraceChainIdToBytes(const&nbsp;HiTraceIdStruct_&nbsp;pId,&nbsp;uint8_t_&nbsp;pIdArray,&nbsp;int&nbsp;len) |
### 接口功能参数 ### 接口功能参数
...@@ -81,14 +81,14 @@ HiTrace实现在C层,主要原理是在一次业务调用流程中,利用通 ...@@ -81,14 +81,14 @@ HiTrace实现在C层,主要原理是在一次业务调用流程中,利用通
| **类** | **方法** | **描述** | | **类** | **方法** | **描述** |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| HiTrace | HiTraceId&nbsp;Begin(const&nbsp;std::string&amp;&nbsp;name,&nbsp;int&nbsp;flags) | 功能:启动HiTrace跟踪、生成HiTraceId对象并设置到当前线程TLS中。<br/>输入参数:<br/>-&nbsp;name:业务流程名称。<br/>-&nbsp;flags:跟踪指示位,可以组合使用,具体含义为:<br/>&nbsp;&nbsp;-&nbsp;HITRACE_FLAG_INCLUDE_ASYNC:同时跟踪同步调用和异步调用,缺省只跟踪同步调用。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_FLAG_DONOT_CREATE_SPAN:不创建子分支,缺省创建子分支。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_FLAG_TP_INFO:输出tracepoint信息,缺省不输出。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_FLAG_NO_BE_INFO:不输出起始、结束信息,缺省输出。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_FLAG_DONOT_ENABLE_LOG:不与日志关联输出,缺省关联。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_FLAG_FAULT_TRIGGER:故障触发的跟踪,缺省为正常启动的。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_FLAG_D2D_TP_INFO:输出设备间tracepoint信息,缺省不输出。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_FLAG_DEFAULT:&nbsp;缺省标志。<br/>-&nbsp;输出参数:无<br/>-&nbsp;返回值:启动跟踪超过返回有效HiTraceId对象,否则返回无效对象。<br/>注意:嵌套启动跟踪时,内层启动调用返回无效对象。 | | HiTraceChain | HiTraceId&nbsp;Begin(const&nbsp;std::string&amp;&nbsp;name,&nbsp;int&nbsp;flags) | 功能:启动HiTraceChain跟踪、生成HiTraceId对象并设置到当前线程TLS中。<br/>输入参数:<br/>-&nbsp;name:业务流程名称。<br/>-&nbsp;flags:跟踪指示位,可以组合使用,具体含义为:<br/>&nbsp;&nbsp;-&nbsp;HITRACE_FLAG_INCLUDE_ASYNC:同时跟踪同步调用和异步调用,缺省只跟踪同步调用。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_FLAG_DONOT_CREATE_SPAN:不创建子分支,缺省创建子分支。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_FLAG_TP_INFO:输出tracepoint信息,缺省不输出。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_FLAG_NO_BE_INFO:不输出起始、结束信息,缺省输出。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_FLAG_DONOT_ENABLE_LOG:不与日志关联输出,缺省关联。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_FLAG_FAULT_TRIGGER:故障触发的跟踪,缺省为正常启动的。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_FLAG_D2D_TP_INFO:输出设备间tracepoint信息,缺省不输出。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_FLAG_DEFAULT:&nbsp;缺省标志。<br/>-&nbsp;输出参数:无<br/>-&nbsp;返回值:启动跟踪超过返回有效HiTraceId对象,否则返回无效对象。<br/>注意:嵌套启动跟踪时,内层启动调用返回无效对象。 |
| | void&nbsp;End(const&nbsp;HiTraceId&amp;&nbsp;id) | 功能:根据Begin返回的HiTraceId停止HiTrace跟踪;清除当前线程TLS中HiTraceId内容。<br/>输入参数:<br/>-&nbsp;id:HiTraceId对象。<br/>输出参数:无。<br/>返回值:无。 | | | void&nbsp;End(const&nbsp;HiTraceId&amp;&nbsp;id) | 功能:根据Begin返回的HiTraceId停止HiTraceChain跟踪;清除当前线程TLS中HiTraceId内容。<br/>输入参数:<br/>-&nbsp;id:HiTraceId对象。<br/>输出参数:无。<br/>返回值:无。 |
| | HiTraceId&nbsp;GetId(); | 功能:从当前线程TLS中获取HiTraceId对象。<br/>输入参数:无。<br/>输出参数:无。<br/>返回值:当前线程上下文的HiTraceId对象。 | | | HiTraceId&nbsp;GetId(); | 功能:从当前线程TLS中获取HiTraceId对象。<br/>输入参数:无。<br/>输出参数:无。<br/>返回值:当前线程上下文的HiTraceId对象。 |
| | void&nbsp;SetId(const&nbsp;HiTraceId&amp;&nbsp;id) | 功能:设置HiTraceId对象内容到当前线程TLS中。<br/>输入参数:<br/>-&nbsp;id:HiTraceId对象。<br/>输出参数:无。<br/>返回值:无。 | | | void&nbsp;SetId(const&nbsp;HiTraceId&amp;&nbsp;id) | 功能:设置HiTraceId对象内容到当前线程TLS中。<br/>输入参数:<br/>-&nbsp;id:HiTraceId对象。<br/>输出参数:无。<br/>返回值:无。 |
| | void&nbsp;ClearId() | 功能:清除当前线程TLS中的HiTraceId对象。<br/>输入参数:无。<br/>输出参数:无。<br/>返回值:无。 | | | void&nbsp;ClearId() | 功能:清除当前线程TLS中的HiTraceId对象。<br/>输入参数:无。<br/>输出参数:无。<br/>返回值:无。 |
| | HiTraceId&nbsp;CreateSpan() | 接口功能:获取当前HiTraceId对象中的分支ID。<br/>输入参数:无。<br/>输出参数:无。<br/>返回值:当前分支ID。 | | | HiTraceId&nbsp;CreateSpan() | 接口功能:获取当前HiTraceId对象中的分支ID。<br/>输入参数:无。<br/>输出参数:无。<br/>返回值:当前分支ID。 |
| | void&nbsp;Tracepoint(HiTraceTracepointType&nbsp;type,&nbsp;const&nbsp;HiTraceId&amp;&nbsp;id,&nbsp;const&nbsp;char\*&nbsp;fmt,&nbsp;...) | 功能:根据埋点信息类型输出HiTrace埋点信息,包括时间戳、子分支HiTraceId对象信息。<br/>输入参数:<br/>-&nbsp;type:埋点信息类型,具体为<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_CS:Client&nbsp;Send,同步/异步通信客户端发送信息。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_SR:Server&nbsp;Receive,&nbsp;同步/异步通信服务端接收信息。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_SS:Server&nbsp;Send,同步通信服务端发送响应信息。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_CR:Client&nbsp;Receive,同步通信客户端接收响应信息。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_GENERAL:普通输出信息。<br/>-&nbsp;id:当前子分支id。<br/>-&nbsp;fmt:格式化变参描述字符串。<br/>-&nbsp;args:变参。<br/>输出参数:无。<br/>返回值:无。 | | | void&nbsp;Tracepoint(HiTraceTracepointType&nbsp;type,&nbsp;const&nbsp;HiTraceId&amp;&nbsp;id,&nbsp;const&nbsp;char\*&nbsp;fmt,&nbsp;...) | 功能:根据埋点信息类型输出HiTraceChain埋点信息,包括时间戳、子分支HiTraceId对象信息。<br/>输入参数:<br/>-&nbsp;type:埋点信息类型,具体为<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_CS:Client&nbsp;Send,同步/异步通信客户端发送信息。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_SR:Server&nbsp;Receive,&nbsp;同步/异步通信服务端接收信息。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_SS:Server&nbsp;Send,同步通信服务端发送响应信息。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_CR:Client&nbsp;Receive,同步通信客户端接收响应信息。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_GENERAL:普通输出信息。<br/>-&nbsp;id:当前子分支id。<br/>-&nbsp;fmt:格式化变参描述字符串。<br/>-&nbsp;args:变参。<br/>输出参数:无。<br/>返回值:无。 |
| | void&nbsp;Tracepoint(HiTraceCommunicationMode&nbsp;mode,&nbsp;HiTraceTracepointType&nbsp;type,&nbsp;const&nbsp;HiTraceId&amp;&nbsp;id,&nbsp;const&nbsp;char\*&nbsp;fmt,&nbsp;...) | 功能:根据通信模式、埋点信息类型输出HiTrace埋点信息,包括时间戳、子分支HiTraceId对象信息。<br/>输入参数:<br/>-&nbsp;mode:通信模式,具体为<br/>&nbsp;&nbsp;-&nbsp;HITRACE_CM_DEFAULT:未指定通信模式。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_CM_THREAD:线程间通信。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_CM_PROCESS:进程间通信。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_CM_DEVICE:设备间通信。<br/>-&nbsp;type:埋点信息类型,具体为<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_CS:Client&nbsp;Send,同步/异步通信客户端发送信息。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_SR:Server&nbsp;Receive,&nbsp;同步/异步通信服务端接收信息。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_SS:Server&nbsp;Send,同步通信服务端发送响应信息。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_CR:Client&nbsp;Receive,同步通信客户端接收响应信息。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_GENERAL:普通输出信息。<br/>-&nbsp;id:当前子分支id。<br/>-&nbsp;fmt:格式化变参描述字符串。<br/>-&nbsp;args:变参。<br/>输出参数:无。<br/>返回值:无。 | | | void&nbsp;Tracepoint(HiTraceCommunicationMode&nbsp;mode,&nbsp;HiTraceTracepointType&nbsp;type,&nbsp;const&nbsp;HiTraceId&amp;&nbsp;id,&nbsp;const&nbsp;char\*&nbsp;fmt,&nbsp;...) | 功能:根据通信模式、埋点信息类型输出HiTraceChain埋点信息,包括时间戳、子分支HiTraceId对象信息。<br/>输入参数:<br/>-&nbsp;mode:通信模式,具体为<br/>&nbsp;&nbsp;-&nbsp;HITRACE_CM_DEFAULT:未指定通信模式。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_CM_THREAD:线程间通信。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_CM_PROCESS:进程间通信。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_CM_DEVICE:设备间通信。<br/>-&nbsp;type:埋点信息类型,具体为<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_CS:Client&nbsp;Send,同步/异步通信客户端发送信息。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_SR:Server&nbsp;Receive,&nbsp;同步/异步通信服务端接收信息。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_SS:Server&nbsp;Send,同步通信服务端发送响应信息。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_CR:Client&nbsp;Receive,同步通信客户端接收响应信息。<br/>&nbsp;&nbsp;-&nbsp;HITRACE_TP_GENERAL:普通输出信息。<br/>-&nbsp;id:当前子分支id。<br/>-&nbsp;fmt:格式化变参描述字符串。<br/>-&nbsp;args:变参。<br/>输出参数:无。<br/>返回值:无。 |
| HiTraceId | HiTraceId(); | 功能:缺省构造函数,生成无效HiTraceId对象。<br/>输入参数:无。<br/>输出参数:无。<br/>返回值:无。 | | HiTraceId | HiTraceId(); | 功能:缺省构造函数,生成无效HiTraceId对象。<br/>输入参数:无。<br/>输出参数:无。<br/>返回值:无。 |
| | HiTraceId(const&nbsp;uint8_t\*&nbsp;pIdArray,&nbsp;int&nbsp;len) | 功能:构造函数,根据字节数组创建跟踪HiTraceId对象。<br/>输入参数:<br/>-&nbsp;pIdArray:字节数组指针。<br/>-&nbsp;len:字节数组长度。<br/>输出参数:无。<br/>返回值:无。 | | | HiTraceId(const&nbsp;uint8_t\*&nbsp;pIdArray,&nbsp;int&nbsp;len) | 功能:构造函数,根据字节数组创建跟踪HiTraceId对象。<br/>输入参数:<br/>-&nbsp;pIdArray:字节数组指针。<br/>-&nbsp;len:字节数组长度。<br/>输出参数:无。<br/>返回值:无。 |
| | bool&nbsp;IsValid() | 功能:HiTraceId对象是否有效。<br/>输入参数:无。<br/>输出参数:无。<br/>返回值:true&nbsp;有效;false&nbsp;无效。 | | | bool&nbsp;IsValid() | 功能:HiTraceId对象是否有效。<br/>输入参数:无。<br/>输出参数:无。<br/>返回值:true&nbsp;有效;false&nbsp;无效。 |
...@@ -107,7 +107,7 @@ HiTrace实现在C层,主要原理是在一次业务调用流程中,利用通 ...@@ -107,7 +107,7 @@ HiTrace实现在C层,主要原理是在一次业务调用流程中,利用通
## 通信调用处理 ## 通信调用处理
业务使用时跨设备/跨进程/跨线程的调用是通过通信机制实现的,HiTrace需要通信机制传递traceid。 业务使用时跨设备/跨进程/跨线程的调用是通过通信机制实现的,HiTraceChain需要通信机制传递traceid。
OpenHarmony系统内置部分通信机制(如ZIDL)已经支持传递traceid。 OpenHarmony系统内置部分通信机制(如ZIDL)已经支持传递traceid。
...@@ -158,47 +158,47 @@ OpenHarmony系统内置部分通信机制(如ZIDL)已经支持传递traceid ...@@ -158,47 +158,47 @@ OpenHarmony系统内置部分通信机制(如ZIDL)已经支持传递traceid
### C++接口实例 ### C++接口实例
1. 源代码开发 1. 源代码开发
在类定义头文件或者类实现源文件中,包含hitrace头文件: 在类定义头文件或者类实现源文件中,包含hitracechain头文件:
``` ```
#include "hitrace/trace.h" #include "hitrace/tracechain.h"
``` ```
在业务类实现源文件中使用(启动/结束跟踪): 在业务类实现源文件中使用(启动/结束跟踪):
``` ```
using namespace OHOS::HiviewDFX; using namespace OHOS::HiviewDFX;
HiTraceId traceId = HiTrace::Begin("MyServiceFlow", HITRACE_FLAG_DEFAULT); auto traceId = HiTraceChain::Begin("MyServiceFlow", HITRACE_FLAG_DEFAULT);
...... ......
HiTrace::End(traceId); HiTraceChain::End(traceId);
``` ```
2. 编译设置,在BUILD.gn里增加子系统SDK依赖: 2. 编译设置,在BUILD.gn里增加子系统SDK依赖:
``` ```
external_deps = [ "hiviewdfx:libhitrace" ] external_deps = [ "hiviewdfx:libhitracechain" ]
``` ```
### C接口实例 ### C接口实例
1. 源代码开发 1. 源代码开发
在源文件中,包含hitrace头文件: 在源文件中,包含hitracechain头文件:
``` ```
#include "hitrace/trace.h" #include "hitrace/tracechain.h"
``` ```
在业务类实现源文件中使用(启动/结束跟踪): 在业务类实现源文件中使用(启动/结束跟踪):
``` ```
HiTraceIdStruct traceId = HiTraceBegin("MyServiceFlow", HITRACE_FLAG_DEFAULT); HiTraceIdStruct traceId = HiTraceChainBegin("MyServiceFlow", HITRACE_FLAG_DEFAULT);
...... ......
HiTraceEnd(traceId); HiTraceChainEnd(traceId);
``` ```
2. 编译设置,在BUILD.gn里增加子系统SDK依赖: 2. 编译设置,在BUILD.gn里增加子系统SDK依赖:
``` ```
external_deps = [ "hiviewdfx:libhitrace" ] external_deps = [ "hiviewdfx:libhitracechain" ]
``` ```
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
- 根据产品配置可以按照组件组装打包产品需要的能力。 - 根据产品配置可以按照组件组装打包产品需要的能力。
## 基本概念<a name="section175012297491"></a> ## 简介<a name="section175012297491"></a>
在了解编译构建子系统的能力前,应了解如下基本概念: 在了解编译构建子系统的能力前,应了解如下基本概念:
...@@ -31,6 +31,51 @@ ...@@ -31,6 +31,51 @@
ninja是一个专注于速度的小型构建系统。 ninja是一个专注于速度的小型构建系统。
## 目录
```text
/build # 编译构建主目录
├── __pycache__
├── build_scripts/ # 编译相关的python脚本
├── common/
├── config/ # 编译相关的配置项
├── core
│ ├── gn/ # 编译入口BUILD.gn配置
│ └── build_scripts/
├── docs
├── gn_helpers.py*
├── lite/ # hb和preloader入口
├── misc/
├── ohos # OpenHarmony编译打包流程配置
│ ├── kits # kits编译打包模板和处理流程
│ ├── ndk # ndk模板和处理流程
│ ├── notice # notice模板和处理流程
│ ├── packages # 版本打包模板和处理流程
│ ├── sa_profile # sa模板和处理流程
│ ├── sdk # sdk模板和处理流程,包括sdk中包含的模块配置
│ └── testfwk # 测试相关的处理
├── ohos.gni* # 汇总了常用的gni文件,方便各个模块一次性import
├── ohos_system.prop
├── ohos_var.gni*
├── prebuilts_download.sh* # 预编译脚本
├── print_python_deps.py*
├── scripts/
├── subsystem_config.json
├── subsystem_config_example.json
├── templates/ # c/c++编译模板定义
├── test.gni*
├── toolchain # 编译工具链配置
├── tools # 常用工具
├── version.gni
├── zip.py*
```
**图 1** 编译构建子系统架构图<a name="fig16488143010409"></a>
![](figures/build_framework_ZN.png "编译构建子系统架构图")
## 运作机制<a name="section193961322175011"></a> ## 运作机制<a name="section193961322175011"></a>
OpenHarmony侧的编译构建流程主要包括以下三个步骤: OpenHarmony侧的编译构建流程主要包括以下三个步骤:
...@@ -51,9 +96,7 @@ OpenHarmony侧的编译构建流程主要包括以下三个步骤: ...@@ -51,9 +96,7 @@ OpenHarmony侧的编译构建流程主要包括以下三个步骤:
## 相关仓<a name="section44651652878"></a> ## 相关仓<a name="section44651652878"></a>
**编译构建子系统** [build\_lite](https://gitee.com/openharmony/build_lite/blob/master/README_zh.md)
[build\_lite](https://gitee.com/openharmony/build_lite)
[build](https://gitee.com/openharmony/build) [build](https://gitee.com/openharmony/build/blob/master/README_zh.md)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册