未验证 提交 3a9730d8 编写于 作者: O openharmony_ci 提交者: Gitee

!5704 根据master更正3.1 release分支contribute EN文件夹的拼写错误等问题

Merge pull request !5704 from wusongqing/contribute-0622-ENV2
......@@ -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");
......
......@@ -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
......
......@@ -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
```
## <a name="c2-10"></a>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.
### <a name="r2-12"></a>Rule 2.12 Initialize each member in a separate line during struct and union member initialization.
......
......@@ -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;
}
......
......@@ -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.
```
## <a name="c3-10"></a> 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()
```
## <a name="c10-2"></a> Smart Pointers
### <a name="r10-2-1"></a>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.
### <a name="r10-2-1"></a>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.
......
......@@ -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;
......
......@@ -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) |
......
# Contribution<a name="EN-US_TOPIC_0000001055208082"></a>
# How to Contribute<a name="EN-US_TOPIC_0000001055208082"></a>
## Contributing Code<a name="en-us_topic_0000001053868136_section10170447161315"></a>
......
......@@ -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
......
......@@ -56,10 +56,10 @@ The **AudioRenderer** class provides open audio playback capabilities. For detai
| API| Description|
| -------- | -------- |
| AudioRenderer(AudioRendererInfo&nbsp;audioRendererInfo,&nbsp;PlayMode&nbsp;pm)&nbsp;throws&nbsp;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&nbsp;audioRendererInfo,&nbsp;PlayMode&nbsp;pm,&nbsp;AudioDeviceDescriptor&nbsp;outputDevice)&nbsp;throws&nbsp;IllegalArgumentException | A constructor used to create an **AudioRenderer** instance based on the specified playback parameters, playback mode, and playback device.|
| boolean&nbsp;play() | Plays audio streams.|
| boolean&nbsp;write(byte[]&nbsp;data,&nbsp;int&nbsp;offset,&nbsp;int&nbsp;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();
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.
......
......@@ -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:<br>1. Relative path whose protocol type is internal. Examples:<br>Temporary directory: internal://cache/test.mp4<br><br>2. Absolute path. Examples:<br>file:///data/data/ohos.xxx.xxx/files/test.mp4<br> |
| 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. |
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册