!668 【usb_usb_manager】AI Review告警整改

Merge pull request !668 from luzhiye/master
This commit is contained in:
openharmony_ci 2024-11-22 02:13:12 +00:00 committed by Gitee
commit d97863cc73
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 9 additions and 5 deletions

View File

@ -129,6 +129,10 @@ export default class UsbDialogAbility extends extension {
private checkPermission(tokenID: number, permissionName: Permissions): boolean {
let aac = abilityAccessCtrl.createAtManager();
if (!aac) {
console.error('createAtManager returned null');
return false;
}
try {
let grantStatus = aac.verifyAccessTokenSync(tokenID, permissionName);
if (grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_DENIED) {

View File

@ -53,7 +53,7 @@ private:
void ProcessHandle(int32_t curAccStatus);
int32_t ProcessAccessoryStart(int32_t curFunc, int32_t curAccStatus);
int32_t ProcessAccessoryStop(int32_t curFunc, int32_t curAccStatus);
int32_t ProcessAccessoryStop();
int32_t ProcessAccessorySend();
void InitBase64Map();
std::vector<uint8_t> Base64Decode(const std::string& encoded_string);
std::string SerialValueHash(const std::string &serialValue);

View File

@ -191,14 +191,14 @@ int32_t UsbAccessoryManager::ProcessAccessoryStop(int32_t curFunc, int32_t curAc
return UEC_OK;
}
int32_t UsbAccessoryManager::ProcessAccessoryStop()
int32_t UsbAccessoryManager::ProcessAccessorySend()
{
this->accStatus_ = ACC_SEND;
std::vector<std::string> accessorys;
usbdImpl_->GetAccessoryInfo(accessorys);
this->accessory.SetAccessory(accessorys);
std::string extraInfo;
if (accessorys.size() >= ACCESSORY_INFO_SIZE && !accessorys[ACCESSORY_EXTRA_INDEX].empty()) {
if (accessorys.size() > ACCESSORY_INFO_SIZE && !accessorys[ACCESSORY_EXTRA_INDEX].empty()) {
if (base64Map_.empty()) {
InitBase64Map();
}
@ -312,7 +312,7 @@ void UsbAccessoryManager::ProcessHandle(int32_t curAccStatus)
return;
}
} else if (curAccStatus == ACC_SEND) {
ProcessAccessoryStop();
ProcessAccessorySend();
}
return;
}

View File

@ -41,7 +41,7 @@ UsbDescriptorParser::~UsbDescriptorParser() {}
int32_t UsbDescriptorParser::ParseDeviceDescriptor(const uint8_t *buffer, uint32_t length, UsbDevice &dev)
{
if (buffer == nullptr || length == 0) {
USB_HILOGE(MODULE_USB_SERVICE, "buffer is null");
USB_HILOGE(MODULE_USB_SERVICE, "buffer is null or length is zero");
return UEC_SERVICE_INVALID_VALUE;
}