diff --git a/en/contribute/OpenHarmony-Java-secure-coding-guide.md b/en/contribute/OpenHarmony-Java-secure-coding-guide.md index f61c28892897c2f5a66ac2762755c78ed6433af5..a5acff2b48e22d91de6b38fe95940a652ad85d87 100644 --- a/en/contribute/OpenHarmony-Java-secure-coding-guide.md +++ b/en/contribute/OpenHarmony-Java-secure-coding-guide.md @@ -803,10 +803,10 @@ public class DeserializeExample implements Serializable { //Deserialize external data ObjectInputStream ois2= new ObjectInputStream(fis); - PersionInfo myPerson = (PersionInfo) ois2.readObject(); + PersonInfo myPerson = (PersonInfo) ois2.readObject(); ``` -In this noncompliant code example, when the object of the deserialization operation is the serialization result of the **DeserializeExample** object constructed by the attacker, an error will be reported when the `PersionInfo myPerson = (PersionInfo) ois2.readObject()` statement is executed, but the attack code in the `readObject()` method of the **DeserializeExample** object is executed. +In this noncompliant code example, when the object of the deserialization operation is the serialization result of the **DeserializeExample** object constructed by the attacker, an error will be reported when the `PersonInfo myPerson = (PersonInfo) ois2.readObject()` statement is executed, but the attack code in the `readObject()` method of the **DeserializeExample** object is executed. **\[Compliant Code Example]** (Trustlist Validation) @@ -822,7 +822,7 @@ public final class SecureObjectInputStream extends ObjectInputStream { protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { - if (!desc.getName().equals("com.xxxx.PersionInfo")) {//Trustlist validation + if (!desc.getName().equals("com.xxxx.PersonInfo")) {//Trustlist validation throw new ClassNotFoundException(desc.getName() + " not find"); } return super.resolveClass(desc); @@ -870,7 +870,7 @@ public final class HWObjectInputStream extends ObjectInputStream { (3) Set a trustlist in the policy file. ``` -permission java.io.SerializablePermission "com.xxxx.PersionInfo"; +permission java.io.SerializablePermission "com.xxxx.PersonInfo"; ``` @@ -1406,7 +1406,7 @@ The trustlist validation ensures that the user ID contains only letters, digits, **\[Compliant Code Example]** (Using a Secure XML Library) ```java -public static void buidlXML(FileWriter writer, User user) throws IOException { +public static void buildXML(FileWriter writer, User user) throws IOException { Document userDoc = DocumentHelper.createDocument(); Element userElem = userDoc.addElement("user"); Element idElem = userElem.addElement("id"); diff --git a/en/contribute/OpenHarmony-JavaScript-coding-style-guide.md b/en/contribute/OpenHarmony-JavaScript-coding-style-guide.md index f540122b839d6b685a2f97a0b064c39c83c8c4f5..ff9bc6ddcaaf7395604a2a5303cda93d06cf1d08 100755 --- a/en/contribute/OpenHarmony-JavaScript-coding-style-guide.md +++ b/en/contribute/OpenHarmony-JavaScript-coding-style-guide.md @@ -643,7 +643,7 @@ The effective solutions are as follows: 1. Use integers as much as possible because integers do not need to be rounded. -2. The native JavaScript method `Number.prototype.toFixed(digits)`,`digist` is used to indicate the number of digits after the decimal point. The exponential method is not used. If necessary, the number is rounded off. This method is used to reduce the precision of the calculation result before determining the floating-point number calculation result. The sample code is as follows: +2. The native JavaScript method `Number.prototype.toFixed(digits)`,`digits` is used to indicate the number of digits after the decimal point. The exponential method is not used. If necessary, the number is rounded off. This method is used to reduce the precision of the calculation result before determining the floating-point number calculation result. The sample code is as follows: ```javascript parseFloat(0.1 + 0.2).toFixed(1); //0.3 diff --git a/en/contribute/OpenHarmony-c-coding-style-guide.md b/en/contribute/OpenHarmony-c-coding-style-guide.md index 487fb2588569ea2c684a6aa73154323d9660404f..6af91b00c5c18e9ed1d70ef3e9e0e4bc6fdb713c 100755 --- a/en/contribute/OpenHarmony-c-coding-style-guide.md +++ b/en/contribute/OpenHarmony-c-coding-style-guide.md @@ -238,8 +238,8 @@ typedef struct { // Good: The anonymous struct is used because self-nesting i int a; int b; } MyType; // The struct alias uses the UpperCamelCase style. - -​```c +``` +```c typedef struct tagNode { // Good: Add the 'tag' prefix or use 'Node_'. struct tagNode *prev; struct tagNode *next; @@ -575,11 +575,11 @@ int result = reallyReallyLongVariableName1 + // Good: The plus sign is placed After an expression is wrapped, ensure that the lines are properly aligned or indented by 4 spaces. Example: ```c -int sum = longVaribleName1 + longVaribleName2 + longVaribleName3 + - longVaribleName4 + longVaribleName5 + longVaribleName6; // OK: indented with 4 spaces +int sum = longVariableName1 + longVariableName2 + longVariableName3 + + longVariableName4 + longVariableName5 + longVariableName6; // OK: indented with 4 spaces -int sum = longVaribleName1 + longVaribleName2 + longVaribleName3 + - longVaribleName4 + longVaribleName5 + longVaribleName6; // OK: aligned +int sum = longVariableName1 + longVariableName2 + longVariableName3 + + longVariableName4 + longVariableName5 + longVariableName6; // OK: aligned ``` ## Variable Assignment @@ -664,7 +664,7 @@ int c[][8] = { Note: -- If the left brace is placed at the end of the line, the corresponding right brace shoud be placed into a new line. +- If the left brace is placed at the end of the line, the corresponding right brace should be placed into a new line. - If the left brace is followed by the content, the corresponding right brace should also follow the content. ### Rule 2.12 Initialize each member in a separate line during struct and union member initialization. diff --git a/en/contribute/OpenHarmony-c-cpp-secure-coding-guide.md b/en/contribute/OpenHarmony-c-cpp-secure-coding-guide.md index e5bcc1db9120dc9bc29ba91bd6b9e5d7a8f4ec08..617e9945c672a08d07b31cb215b2ef22f9bdc768 100644 --- a/en/contribute/OpenHarmony-c-cpp-secure-coding-guide.md +++ b/en/contribute/OpenHarmony-c-cpp-secure-coding-guide.md @@ -1167,7 +1167,7 @@ int Fun() // msg is saved to the global queue, and the freed body member may be used. if (!InsertMsgToQueue(msg)) { - delete msg->body; // The memory to which the bbodyb points may be freed again. + delete msg->body; // The memory to which the body points may be freed again. delete msg; return -1; } @@ -1736,7 +1736,7 @@ An incorrect format string may cause memory damage or abnormal program terminati ## Ensure that the format parameter is not controlled by external data when a formatted input/output function is called **\[Description]** -When a formatted function is called, the **format** parameter provided or concatenated by external data will cause a string formatting vulnerability. Take the formatted output function of the C standard library as an example. When the **format** parameter is externally controllable, an attacker can use the %n convertor to write an integer to a specified address, use the %x or %d convertor to view the stack or register content, or use the %s convertor to cause process crashes or other issues. +When a formatted function is called, the **format** parameter provided or concatenated by external data will cause a string formatting vulnerability. Take the formatted output function of the C standard library as an example. When the **format** parameter is externally controllable, an attacker can use the %n converter to write an integer to a specified address, use the %x or %d converter to view the stack or register content, or use the %s converter to cause process crashes or other issues. Common formatted functions are as follows: @@ -3030,7 +3030,7 @@ if (file == NULL) { } if (IS_ERR(file)) { - printk("Error occured while opening file %s, exiting ...\n", MY_FILE); + printk("Error occurred while opening file %s, exiting ...\n", MY_FILE); return 0; } diff --git a/en/contribute/OpenHarmony-cpp-coding-style-guide.md b/en/contribute/OpenHarmony-cpp-coding-style-guide.md index b997e0877a2ad1bc442577f05c0c9e196ef44872..2d7b54fc9ead844d6c53afb97c0f00d46e0fce39 100755 --- a/en/contribute/OpenHarmony-cpp-coding-style-guide.md +++ b/en/contribute/OpenHarmony-cpp-coding-style-guide.md @@ -417,7 +417,7 @@ Example: // Assume that the first line exceeds the length limit. ```cpp if (currentValue > threshold && // Good: After the line break, the logical-AND operators are placed at the end of the line. - someConditionsion) { + someCondition) { DoSomething(); ... } @@ -428,11 +428,11 @@ int result = reallyReallyLongVariableName1 + // Good After an expression is wrapped, ensure that the lines are aligned appropriately or indented with 4 spaces. See the following example. ```cpp -int sum = longVaribleName1 + longVaribleName2 + longVaribleName3 + - longVaribleName4 + longVaribleName5 + longVaribleName6; // Good: indented with 4 spaces +int sum = longVariableName1 + longVariableName2 + longVariableName3 + + longVariableName4 + longVariableName5 + longVariableName6; // Good: indented with 4 spaces -int sum = longVaribleName1 + longVaribleName2 + longVaribleName3 + - longVaribleName4 + longVaribleName5 + longVaribleName6; // Good: The lines are aligned. +int sum = longVariableName1 + longVariableName2 + longVariableName3 + + longVariableName4 + longVariableName5 + longVariableName6; // Good: The lines are aligned. ``` ## Variable Assignment @@ -2189,12 +2189,12 @@ class LockGuard { public: LockGuard(const LockType& lockType): lock_(lockType) { - lock_.Aquire(); + lock_.Acquire(); } ~LockGuard() { - lock_.Relase(); + lock_.Release(); } private: @@ -2662,7 +2662,7 @@ void func() ``` ## Smart Pointers -### Rule 10.2.1 Preferentially use the original pointer source instead of the smart pointer for singletons and class members that are not held by multiple parties. +### Rule 10.2.1 Preferentially use the original pointer instead of the smart pointer for singletons and class members that are not held by multiple parties. **Reason:** Smart pointers automatically release object resources to prevent resource leakage, but they require extra resource overheads. For example, the classes, constructors, and destructors automatically generated by smart pointers consume more resources such as memory. diff --git a/en/contribute/OpenHarmony-hdf-coding-guide.md b/en/contribute/OpenHarmony-hdf-coding-guide.md index a34fd17158e73becde9811797554386b7ea91fe9..64f3ca9810220de6990ca4df576e7c42f9792285 100644 --- a/en/contribute/OpenHarmony-hdf-coding-guide.md +++ b/en/contribute/OpenHarmony-hdf-coding-guide.md @@ -526,7 +526,7 @@ int32_t SampleDriverInit(struct HdfDeviceObject *deviceObject) ret = InitDiver(); // A custom method uses an error code provided by the HDF. if (ret != HDF_SUCCESS) { - HDF_LOGE("init drvier is failed"); + HDF_LOGE("init driver is failed"); return ret; } return HDF_SUCCESS; diff --git a/en/contribute/docs-reviewers.md b/en/contribute/docs-reviewers.md index 44a5a50546c38b884dd0302e726092bde0d85365..456d3bc63311348e3af055b6621c64ee1d035ef4 100644 --- a/en/contribute/docs-reviewers.md +++ b/en/contribute/docs-reviewers.md @@ -5,8 +5,8 @@ | Feature | Docs Reviewers | | ------------ | ------------------------------------------------------------ | -| Getting Started| [@duangavin123](https://gitee.com/duangavin123) | -| Source Code Acquisition| [@duangavin123](https://gitee.com/duangavin123) | +| Getting Started| [@duangavin123](https://gitee.com/duangavin123_admin) | +| Source Code Acquisition| [@duangavin123](https://gitee.com/duangavin123_admin) | | Kernel| [@Austin23](https://gitee.com/Austin23) | | Driver| [@Qianchenya](https://gitee.com/Qianchenya) | | Device Development Guidelines| [@Austin23](https://gitee.com/Austin23) | diff --git a/en/contribute/how-to-contribute.md b/en/contribute/how-to-contribute.md index 0e2260a1b722aca4d808f4cfa8573c632ea00a40..26a3bb146ec3cb2e80c898d668262fc98f0992ca 100644 --- a/en/contribute/how-to-contribute.md +++ b/en/contribute/how-to-contribute.md @@ -1,4 +1,4 @@ -# Contribution +# How to Contribute ## Contributing Code diff --git a/en/contribute/introducing-third-party-open-source-software.md b/en/contribute/introducing-third-party-open-source-software.md index 4ae63d713d86b94ad4322f5d1ce56d432ba26531..424984cf3833831891026e77ddceb2a0ac231e0c 100644 --- a/en/contribute/introducing-third-party-open-source-software.md +++ b/en/contribute/introducing-third-party-open-source-software.md @@ -36,7 +36,7 @@ For easier maintenance and evolution, comply with the following principles when 8. Do not introduce any software version that has high-risk vulnerabilities and does not provide solutions. 9. If you need to modify the software, place the new code in the software repository and ensure that the new code meets the license requirements of the software. Retain the original license for the modified files, and use the same license for the new files (recommended). 10. Provide the **README.OpenSource** file in the root directory of the software repository. Include the following information in the file: software name, license, license file location, version, upstream community address of the corresponding version, software maintenance owner, function description, and introduction reason. -11. Make sure the software to introduce will be under the custody of a domain SIG. In principle, the PMC will deny the introduction of a piece of software without the confirmation of the SIG QA and the corresponding domain SIG. When introducing multiple pieces of software at a time, you can ask the PMC to hold a temporary review meeting between SIGs for faster introduction. If you want to introduce a piece of software but fail to meet the preceding requirements, send an email to law@openatom.org. +11. Make sure the software you introduce is under the custody of a domain SIG. In principle, the PMC will deny the introduction of a piece of software without the confirmation of the SIG QA and the corresponding domain SIG. When introducing multiple pieces of software at a time, you can ask the PMC to hold a temporary review meeting between SIGs for faster introduction. If you want to introduce a piece of software but fail to meet the preceding requirements, send an email to law@openatom.org. ### Software Introduction Process diff --git a/en/contribute/template/guide-template.md b/en/contribute/template/guide-template.md index 50b38875303b1c94c3d9c4bf8e991161f371a0bb..90b5133d0817050586903c8514ddb5e2b838a324 100644 --- a/en/contribute/template/guide-template.md +++ b/en/contribute/template/guide-template.md @@ -56,10 +56,10 @@ The **AudioRenderer** class provides open audio playback capabilities. For detai | API| Description| | -------- | -------- | -| AudioRenderer(AudioRendererInfo audioRendererInfo, PlayMode pm) throws IllegalArgumentException | A constructor used to create an **AudioRenderer** instance based on the specified playback parameters, the specified playback mode, and the default playback device.| -| AudioRenderer(AudioRendererInfo audioRendererInfo, PlayMode pm, AudioDeviceDescriptor outputDevice) throws IllegalArgumentException | A constructor used to create an **AudioRenderer** instance based on the specified playback parameters, playback mode, and playback device.| -| boolean play() | Plays audio streams.| -| boolean write(byte[] data, int offset, int size) | Writes audio data in the specified byte array into an audio receiver for playback.| +| AudioRenderer(AudioRendererInfo audioRendererInfo, PlayMode pm) throws IllegalArgumentException | A constructor used to create an **AudioRenderer** instance based on the specified playback parameters, the specified playback mode, and the default playback device.| +| AudioRenderer(AudioRendererInfo audioRendererInfo, PlayMode pm, AudioDeviceDescriptor outputDevice) throws IllegalArgumentException | A constructor used to create an **AudioRenderer** instance based on the specified playback parameters, playback mode, and playback device.| +| boolean play() | Plays audio streams.| +| boolean write(byte[] data, int offset, int size) | Writes audio data in the specified byte array into an audio receiver for playback.| ## How to Develop @@ -89,26 +89,48 @@ The **AudioRenderer** class provides open audio playback capabilities. For detai 1. Use **AudioStreamInfo.Builder** to create an **AudioStreamInfo** instance for audio stream parameters. The following example uses the default values of the input parameters for **AudioStreamInfo.Builder**. You need to set the parameters based on the audio stream specification. ``` - AudioStreamInfo audioStreamInfo = new AudioStreamInfo.Builder().sampleRate( AudioStreamInfo.SAMPLE_RATE_UNSPECIFIED) .audioStreamFlag(AudioStreamInfo.AudioStreamFlag.AUDIO_STREAM_FLAG_NONE) .encodingFormat(AudioStreamInfo.EncodingFormat.ENCODING_INVALID) .channelMask(AudioStreamInfo.ChannelMask.CHANNEL_INVALID) .streamUsage(AudioStreamInfo.StreamUsage.STREAM_USAGE_UNKNOWN) .build(); + AudioStreamInfo audioStreamInfo = new AudioStreamInfo.Builder() + .sampleRate(AudioStreamInfo.SAMPLE_RATE_UNSPECIFIED) + .audioStreamFlag(AudioStreamInfo.AudioStreamFlag.AUDIO_STREAM_FLAG_NONE) + .encodingFormat(AudioStreamInfo.EncodingFormat.ENCODING_INVALID) + .channelMask(AudioStreamInfo.ChannelMask.CHANNEL_INVALID) + .streamUsage(AudioStreamInfo.StreamUsage.STREAM_USAGE_UNKNOWN) + .build(); ``` - Example code for playing a PCM stream: - ``` - AudioStreamInfo audioStreamInfo = new AudioStreamInfo.Builder().sampleRate(44100)// 44.1 kHz .audioStreamFlag(AudioStreamInfo.AudioStreamFlag.AUDIO_STREAM_FLAG_MAY_DUCK)// Set audio ducking. .encodingFormat(AudioStreamInfo.EncodingFormat.ENCODING_PCM_16BIT)//16-bit PCM .channelMask(AudioStreamInfo.ChannelMask.CHANNEL_OUT_STEREO)// Set the dual output channel. .streamUsage(AudioStreamInfo.StreamUsage.STREAM_USAGE_MEDIA)// Set the stream to be used for media. .build(); - ``` - + Example code for playing a PCM stream: + ``` + AudioStreamInfo audioStreamInfo = new AudioStreamInfo.Builder().sampleRate(44100)// 44.1 kHz + .audioStreamFlag(AudioStreamInfo.AudioStreamFlag.AUDIO_STREAM_FLAG_MAY_DUCK)// Set audio ducking. + .encodingFormat(AudioStreamInfo.EncodingFormat.ENCODING_PCM_16BIT)//16-bit PCM + .channelMask(AudioStreamInfo.ChannelMask.CHANNEL_OUT_STEREO)// Set the dual output channel. + .streamUsage(AudioStreamInfo.StreamUsage.STREAM_USAGE_MEDIA)// Set the stream to be used for media. + .build(); + ``` 2. Build the playback parameter structure via **AudioRendererInfo** for the audio stream created in Step 1, and use **AudioRendererInfo.Builder** to create an instance. The following example uses the default parameter values of the **AudioRendererInfo.Builder** instance. You need to set the playback parameters based on the audio playback specification. ``` - AudioRendererInfo audioRendererInfo = new AudioRendererInfo.Builder().audioStreamInfo(audioStreamInfo) .audioStreamOutputFlag(AudioRendererInfo.AudioStreamOutputFlag.AUDIO_STREAM_OUTPUT_FLAG_NONE) .bufferSizeInBytes(0) .distributedDeviceId("") .isOffload(false) .sessionID(AudioRendererInfo.SESSION_ID_UNSPECIFIED) .build(); + AudioRendererInfo audioRendererInfo = new AudioRendererInfo.Builder() + .audioStreamInfo(audioStreamInfo) + .audioStreamOutputFlag(AudioRendererInfo.AudioStreamOutputFlag.AUDIO_STREAM_OUTPUT_FLAG_NONE) + .bufferSizeInBytes(0) + .distributedDeviceId("") + .isOffload(false) + .sessionID(AudioRendererInfo.SESSION_ID_UNSPECIFIED) + .build(); ``` Example code for playing a PCM stream: ``` - AudioRendererInfo audioRendererInfo = new AudioRendererInfo.Builder().audioStreamInfo(audioStreamInfo) .audioStreamOutputFlag(AudioRendererInfo.AudioStreamOutputFlag.AUDIO_STREAM_OUTPUT_FLAG_DIRECT_PCM)// Set direct PCM output .bufferSizeInBytes(100) .distributedDeviceId("E54***5E8")// Use distributed device E54***5E8 for playback. .isOffload(false)// Value false indicates that the audio stream is transmitted to the buffer on a segment-by-segment basis for several times and then played. Value true indicates that the audio stream is transmitted to the HAL layer at a time. .build(); + AudioRendererInfo audioRendererInfo = new AudioRendererInfo.Builder() + .audioStreamInfo(audioStreamInfo) + .audioStreamOutputFlag(AudioRendererInfo.AudioStreamOutputFlag.AUDIO_STREAM_OUTPUT_FLAG_DIRECT_PCM)// Set direct PCM output. + .bufferSizeInBytes(100) + .distributedDeviceId("E54***5E8")// Use distributed device E54***5E8 for playback. + .isOffload(false)// Value false indicates that the audio stream is transmitted to the buffer on a segment-by-segment basis for several times and then played. Value true indicates that the audio stream is transmitted to the HAL layer at a time. + .build(); ``` - + 3. Specify the playback mode based on the audio stream to be played. The playback modes differ only in the data writing process. Create an **AudioRenderer** instance using a constructor that fits your need. - .... 4. After the playback task is complete, call the **release()** method on the **AudioRenderer** instance to release resources. diff --git a/en/contribute/template/js-template.md b/en/contribute/template/js-template.md index 3db27cbb7917bb597e2e39086ed68e520b7a9ca5..fddf204b85f3fc9a981476e2a00b3c3556ed4d43 100644 --- a/en/contribute/template/js-template.md +++ b/en/contribute/template/js-template.md @@ -98,7 +98,7 @@ import call from '@ohos.telephony.call'; > > 4.4 - For a writable attribute, if only fixed fields are supported, describe them. > -> 4.5 - If the items in the table require different system capabilities, add the following description: The items in the table below require different system capabilities. For details, see the table. Then, describe the system capabilities for each item. See [Enumeration](#Enumeration). +> 4.5 - If the items in the table require different system capabilities, add the following description: The items in the table below require different system capabilities. For details, see the table. Then, describe the system capabilities for each item. See [Enums](#enums). **System capability**: SystemCapability.xxx.xxx (Mandatory) @@ -247,4 +247,5 @@ The following is an example of the custom type of a key-value pair. | Name | Type | Readable| Writable| Description | | ------------ | ------------------- | ---- | ---- | ------------------------------------------------------------ | | parameterUrl | string | Yes | Yes | Media output URI. The following types of URIs are supported:
1. Relative path whose protocol type is internal. Examples:
Temporary directory: internal://cache/test.mp4

2. Absolute path. Examples:
file:///data/data/ohos.xxx.xxx/files/test.mp4
| -| parameterOne | [CustomEnum](#Enumeration)| Yes | Yes | Describe the attributes. The requirements are similar to those for the parameter description. | +| parameterOne | [CustomEnum](#enums) | Yes | Yes | Describe the attributes. The requirements are similar to those for the parameter description. | +