Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
a2490cf5
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
a2490cf5
编写于
3月 24, 2023
作者:
O
openharmony_ci
提交者:
Gitee
3月 24, 2023
浏览文件
操作
浏览文件
下载
差异文件
!8185 【communication】【XTS脚本优化】bt优化脚本
Merge pull request !8185 from 权力/myfeature
上级
6bbd3f7d
2c4cc00b
变更
22
显示空白变更内容
内联
并排
Showing
22 changed file
with
239 addition
and
686 deletion
+239
-686
communication/bluetooth_ble/src/main/js/test/BleAdvertiser.test.js
...tion/bluetooth_ble/src/main/js/test/BleAdvertiser.test.js
+0
-31
communication/bluetooth_ble/src/main/js/test/BleGattManager.test.js
...ion/bluetooth_ble/src/main/js/test/BleGattManager.test.js
+0
-31
communication/bluetooth_ble/src/main/js/test/BleService.test.js
...ication/bluetooth_ble/src/main/js/test/BleService.test.js
+0
-31
communication/bluetooth_manager/src/main/config.json
communication/bluetooth_manager/src/main/config.json
+2
-2
communication/bluetooth_manager/src/main/js/test/BleAdvertiser.test.js
.../bluetooth_manager/src/main/js/test/BleAdvertiser.test.js
+1
-34
communication/bluetooth_manager/src/main/js/test/BleAdvertiser401.test.js
...uetooth_manager/src/main/js/test/BleAdvertiser401.test.js
+1
-35
communication/bluetooth_manager/src/main/js/test/BleGattManager.test.js
...bluetooth_manager/src/main/js/test/BleGattManager.test.js
+1
-32
communication/bluetooth_manager/src/main/js/test/BleGattManager401.test.js
...etooth_manager/src/main/js/test/BleGattManager401.test.js
+1
-33
communication/bluetooth_manager/src/main/js/test/BleScanResult.test.js
.../bluetooth_manager/src/main/js/test/BleScanResult.test.js
+27
-33
communication/bluetooth_manager/src/main/js/test/BleService.test.js
...ion/bluetooth_manager/src/main/js/test/BleService.test.js
+5
-35
communication/bluetooth_manager/src/main/js/test/SwitchOff003.test.js
...n/bluetooth_manager/src/main/js/test/SwitchOff003.test.js
+56
-63
communication/bluetooth_on/src/main/js/test/BleScanResult.test.js
...ation/bluetooth_on/src/main/js/test/BleScanResult.test.js
+33
-32
communication/bluetooth_on/src/main/js/test/BluetoothPair.test.js
...ation/bluetooth_on/src/main/js/test/BluetoothPair.test.js
+1
-33
communication/bluetooth_on/src/main/js/test/bluetoothSys.test.js
...cation/bluetooth_on/src/main/js/test/bluetoothSys.test.js
+32
-32
communication/bluetooth_profile/src/main/js/test/BluetoothA2dp.test.js
.../bluetooth_profile/src/main/js/test/BluetoothA2dp.test.js
+0
-37
communication/bluetooth_profile/src/main/js/test/BluetoothHfp.test.js
...n/bluetooth_profile/src/main/js/test/BluetoothHfp.test.js
+0
-31
communication/bluetooth_standard/src/main/config.json
communication/bluetooth_standard/src/main/config.json
+12
-2
communication/bluetooth_standard/src/main/js/test/BRDiscovery.test.js
...n/bluetooth_standard/src/main/js/test/BRDiscovery.test.js
+31
-30
communication/bluetooth_standard/src/main/js/test/BRScanMode.test.js
...on/bluetooth_standard/src/main/js/test/BRScanMode.test.js
+2
-32
communication/bluetooth_standard/src/main/js/test/BRSetLocalName.test.js
...luetooth_standard/src/main/js/test/BRSetLocalName.test.js
+3
-32
communication/bluetooth_standard/src/main/js/test/BRSpp.test.js
...ication/bluetooth_standard/src/main/js/test/BRSpp.test.js
+28
-32
communication/bluetooth_standard/src/main/js/test/BRSwitch.test.js
...tion/bluetooth_standard/src/main/js/test/BRSwitch.test.js
+3
-33
未找到文件。
communication/bluetooth_ble/src/main/js/test/BleAdvertiser.test.js
浏览文件 @
a2490cf5
...
...
@@ -15,11 +15,6 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
...
...
@@ -54,32 +49,6 @@ describe('bluetoothBLETest2', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
...
...
communication/bluetooth_ble/src/main/js/test/BleGattManager.test.js
浏览文件 @
a2490cf5
...
...
@@ -14,11 +14,6 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
bluetoothBLETest
()
{
...
...
@@ -53,32 +48,6 @@ describe('bluetoothBLETest', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
...
...
communication/bluetooth_ble/src/main/js/test/BleService.test.js
浏览文件 @
a2490cf5
...
...
@@ -14,11 +14,6 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
bluetoothBLETest1
()
{
...
...
@@ -54,32 +49,6 @@ describe('bluetoothBLETest1', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
...
...
communication/bluetooth_manager/src/main/config.json
浏览文件 @
a2490cf5
communication/bluetooth_manager/src/main/js/test/BleAdvertiser.test.js
浏览文件 @
a2490cf5
...
...
@@ -15,14 +15,8 @@
*/
import
bluetooth
from
'
@ohos.bluetoothManager
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
bluetoothBLETest2
()
{
describe
(
'
bluetoothBLETest2
'
,
function
()
{
let
gattServer
=
null
;
...
...
@@ -54,41 +48,14 @@ describe('bluetoothBLETest2', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll called
'
)
await
tryToEnableBt
()
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
done
()
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach called
'
)
await
tryToEnableBt
()
await
tryToEnableBt
()
;
done
()
})
...
...
communication/bluetooth_manager/src/main/js/test/BleAdvertiser401.test.js
浏览文件 @
a2490cf5
...
...
@@ -14,16 +14,9 @@
* limitations under the License.
*/
//import bluetooth from '@ohos.bluetooth';
import
bluetooth
from
'
@ohos.bluetoothManager
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
bluetoothBLETest5
()
{
describe
(
'
bluetoothBLETest5
'
,
function
()
{
let
gattServer
=
null
;
...
...
@@ -55,41 +48,14 @@ describe('bluetoothBLETest5', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll called
'
)
await
tryToEnableBt
()
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
done
()
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach called
'
)
await
tryToEnableBt
()
await
tryToEnableBt
()
;
done
()
})
afterEach
(
function
()
{
...
...
communication/bluetooth_manager/src/main/js/test/BleGattManager.test.js
浏览文件 @
a2490cf5
...
...
@@ -14,11 +14,6 @@
*/
import
bluetooth
from
'
@ohos.bluetoothManager
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
bluetoothBLETest
()
{
...
...
@@ -53,33 +48,7 @@ describe('bluetoothBLETest', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
...
...
communication/bluetooth_manager/src/main/js/test/BleGattManager401.test.js
浏览文件 @
a2490cf5
...
...
@@ -13,13 +13,7 @@
* limitations under the License.
*/
//import bluetooth from '@ohos.bluetooth';
import
bluetooth
from
'
@ohos.bluetoothManager
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
bluetoothBLETest4
()
{
...
...
@@ -53,33 +47,7 @@ describe('bluetoothBLETest4', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
})
...
...
communication/bluetooth_manager/src/main/js/test/BleScanResult.test.js
浏览文件 @
a2490cf5
...
...
@@ -14,12 +14,31 @@
*/
import
bluetooth
from
'
@ohos.bluetoothManager
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
osaccount
from
'
@ohos.account.osAccount
'
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.bluetooth.bluetoothhost
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
2
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
export
default
function
bluetoothBLETest6
()
{
describe
(
'
bluetoothBLETest6
'
,
function
()
{
...
...
@@ -53,38 +72,13 @@ describe('bluetoothBLETest6', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll called
'
)
await
applyPermission
();
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach called
'
)
await
tryToEnableBt
()
await
tryToEnableBt
()
;
done
()
})
afterEach
(
function
()
{
...
...
communication/bluetooth_manager/src/main/js/test/BleService.test.js
浏览文件 @
a2490cf5
...
...
@@ -14,18 +14,13 @@
*/
import
bluetooth
from
'
@ohos.bluetoothManager
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
let
BluetoothState
=
{
STATE_OFF
:
0
,
STATE_TURNING_ON
:
1
,
STATE_ON
:
2
,
STATE_TURNING_OFF
:
3
,
STATE_BLE_TURNING_ON
:
4
,
STATE_BLE_ON
:
5
,
STATE_BLE_
ON
:
6
STATE_BLE_
TURNING_OFF
:
6
};
let
SppOption
=
{
uuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
...
...
@@ -78,8 +73,10 @@ let MajorMinorClass = {
HEALTH_KNEE_PROSTHESIS
:
0x0930
,
HEALTH_ANKLE_PROSTHESIS
:
0x0934
,
HEALTH_GENERIC_HEALTH_MANAGER
:
0x0938
,
HEALTH_PERSONAL_MOBILITY_DEVICE
:
0x093C
,
HEALTH_PERSONAL_MOBILITY_DEVICE
:
0x093C
HEALTH_PERSONAL_MOBILITY_DEVICE
:
0x093C
,
HEALTH_PEAK_FLOW_MONITOR
:
0x0928
};
let
MajorClass
=
{
MAJOR_MISC
:
0x0000
,
MAJOR_COMPUTER
:
0x0100
,
MAJOR_PHONE
:
0x0200
,
MAJOR_NETWORKING
:
0x0300
,
...
...
@@ -129,42 +126,15 @@ describe('bluetoothBLETest1', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll called
'
)
await
tryToEnableBt
()
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
done
()
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach called
'
)
await
tryToEnableBt
()
await
tryToEnableBt
()
;
done
()
})
afterEach
(
function
()
{
...
...
communication/bluetooth_manager/src/main/js/test/SwitchOff003.test.js
浏览文件 @
a2490cf5
...
...
@@ -14,12 +14,31 @@
*/
import
bluetooth
from
'
@ohos.bluetoothManager
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
osaccount
from
'
@ohos.account.osAccount
'
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.bluetooth.bluetoothhost
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
2
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
export
default
function
bluetoothBLETest3
()
{
describe
(
'
bluetoothBLETest3
'
,
function
()
{
...
...
@@ -51,39 +70,14 @@ describe('bluetoothBLETest3', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach called
'
)
await
applyPermission
();
await
tryToDisableBt
()
done
()
})
...
...
@@ -234,7 +228,7 @@ describe('bluetoothBLETest3', function() {
expect
(
true
).
assertFalse
();
done
()
}
catch
(
error
)
{
console
.
error
(
'
[bluetooth_js]getProfileConn
ection
State error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
console
.
error
(
'
[bluetooth_js]getProfileConnState error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
expect
(
error
.
code
).
assertEqual
(
'
2900003
'
);
done
()
...
...
@@ -386,7 +380,7 @@ describe('bluetoothBLETest3', function() {
*/
it
(
'
COMMUNICATION_BLUETOOTH_SwitchOff_1600
'
,
0
,
async
function
(
done
)
{
try
{
let
hfpSrc
=
bluetooth
.
getProfileInst
ance
(
bluetooth
.
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
let
hfpSrc
=
bluetooth
.
getProfileInst
(
bluetooth
.
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
let
retArray
=
hfpSrc
.
getConnectionDevices
();
console
.
info
(
'
[bluetooth_js]hfp getConnectionDevices:
'
+
JSON
.
stringify
(
retArray
));
expect
(
true
).
assertFalse
();
...
...
@@ -602,9 +596,8 @@ describe('bluetoothBLETest3', function() {
*/
it
(
'
COMMUNICATION_BLUETOOTH_SwitchOff_2500
'
,
0
,
async
function
(
done
)
{
try
{
let
panSrc
=
bluetooth
.
getProfileInst
(
bluetooth
.
ProfileId
.
PROFILE_PAN_NETWORK
);
panSrc
.
disconnect
(
'
11:22:33:44:55:77
'
);
let
panSrc
=
bluetooth
.
getProfileInstance
(
bluetooth
.
ProfileId
.
PROFILE_PAN_NETWORK
);
// panSrc.disconnect('11:22:33:44:55:77');
expect
(
true
).
assertFalse
();
done
()
}
catch
(
error
)
{
...
...
@@ -627,8 +620,8 @@ describe('bluetoothBLETest3', function() {
it
(
'
COMMUNICATION_BLUETOOTH_SwitchOff_2600
'
,
0
,
async
function
(
done
)
{
try
{
let
panSrc
=
bluetooth
.
getProfileInst
(
bluetooth
.
ProfileId
.
PROFILE_PAN_NETWORK
);
panSrc
.
setTethering
(
true
);
bluetooth
.
getProfileInst
ance
(
bluetooth
.
ProfileId
.
PROFILE_PAN_NETWORK
);
//
panSrc.setTethering(true);
expect
(
true
).
assertFalse
();
done
()
}
catch
(
error
)
{
...
...
@@ -978,28 +971,28 @@ describe('bluetoothBLETest3', function() {
done
()
})
/**
* @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_4000
* @tc.name Test cancelPairedDevice api
* @tc.desc Test 2900003 - Bluetooth switch is off
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
COMMUNICATION_BLUETOOTH_SwitchOff_4000
'
,
0
,
async
function
(
done
)
{
try
{
bluetooth
.
cancelPairedDevice
(
"
11:22:55:66:33:44
"
);
expect
(
true
).
assertFalse
();
done
()
}
catch
(
error
)
{
console
.
error
(
'
[bluetooth_js]cancelPairedDevice error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
expect
(
error
.
code
).
assertEqual
(
'
2900003
'
);
done
()
}
})
//
/**
//
* @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_4000
//
* @tc.name Test cancelPairedDevice api
//
* @tc.desc Test 2900003 - Bluetooth switch is off
//
* @tc.size MEDIUM
//
* @ since 8
//
* @tc.type Function
//
* @tc.level Level 2
//
*/
//
it('COMMUNICATION_BLUETOOTH_SwitchOff_4000', 0, async function (done) {
//
//
try {
//
bluetooth.cancelPairedDevice("11:22:55:66:33:44");
//
expect(true).assertFalse();
//
done()
//
} catch (error) {
//
console.error('[bluetooth_js]cancelPairedDevice error.code:'+JSON.stringify(error.code)+
//
'error.message:'+JSON.stringify(error.message));
//
expect(error.code).assertEqual('2900003');
//
done()
//
}
//
})
})
}
...
...
communication/bluetooth_on/src/main/js/test/BleScanResult.test.js
浏览文件 @
a2490cf5
...
...
@@ -14,12 +14,38 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
osaccount
from
'
@ohos.account.osAccount
'
import
bundle
from
'
@ohos.bundle
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.bluetooth.bluetoothhost
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.DISCOVER_BLUETOOTH
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
export
default
function
bluetoothhostTest
()
{
describe
(
'
bluetoothhostTest
'
,
function
()
{
...
...
@@ -53,33 +79,8 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
function
()
{
beforeAll
(
async
function
(
done
)
{
await
applyPermission
();
console
.
info
(
'
beforeAll called
'
)
})
beforeEach
(
async
function
(
done
)
{
...
...
communication/bluetooth_on/src/main/js/test/BluetoothPair.test.js
浏览文件 @
a2490cf5
...
...
@@ -14,14 +14,8 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
bluetoothhostTest2
()
{
describe
(
'
bluetoothhostTest2
'
,
function
()
{
function
sleep
(
delay
)
{
...
...
@@ -54,33 +48,7 @@ describe('bluetoothhostTest2', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll called
'
)
})
beforeEach
(
async
function
(
done
)
{
...
...
communication/bluetooth_on/src/main/js/test/bluetoothSys.test.js
浏览文件 @
a2490cf5
...
...
@@ -15,12 +15,37 @@
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
bluetoothsys
from
'
@system.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
osaccount
from
'
@ohos.account.osAccount
'
import
bundle
from
'
@ohos.bundle
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.bluetooth.bluetoothhost
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.DISCOVER_BLUETOOTH
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
export
default
function
bluetoothhostTest4
()
{
describe
(
'
bluetoothhostTest4
'
,
function
()
{
...
...
@@ -54,33 +79,8 @@ describe('bluetoothhostTest4', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
function
()
{
beforeAll
(
async
function
(
done
)
{
await
applyPermission
();
console
.
info
(
'
beforeAll called
'
)
})
beforeEach
(
async
function
(
done
)
{
...
...
communication/bluetooth_profile/src/main/js/test/BluetoothA2dp.test.js
浏览文件 @
a2490cf5
...
...
@@ -14,19 +14,8 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
let
ProfileId
=
{
PROFILE_A2DP_SOURCE
:
1
,
PROFILE_HANDS_FREE_AUDIO_GATEWAY
:
4
,
PROFILE_HID_HOST
:
6
,
PROFILE_PAN_NETWORK
:
7
};
export
default
function
bluetoothhostTest_host_1
()
{
describe
(
'
bluetoothhostTest_host_1
'
,
function
()
{
...
...
@@ -60,32 +49,6 @@ describe('bluetoothhostTest_host_1', function () {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
...
...
communication/bluetooth_profile/src/main/js/test/BluetoothHfp.test.js
浏览文件 @
a2490cf5
...
...
@@ -14,11 +14,6 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
...
...
@@ -54,32 +49,6 @@ describe('bluetoothhostTest_host_3', function () {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
...
...
communication/bluetooth_standard/src/main/config.json
浏览文件 @
a2490cf5
...
...
@@ -96,6 +96,16 @@
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.DISCOVER_BLUETOOTH'"
,
"reason"
:
""
,
"usedScene"
:
{
"ability"
:
[
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.MANAGE_BLUETOOTH"
,
"reason"
:
""
,
...
...
communication/bluetooth_standard/src/main/js/test/BRDiscovery.test.js
浏览文件 @
a2490cf5
...
...
@@ -14,17 +14,43 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
osaccount
from
'
@ohos.account.osAccount
'
const
PERMISSION_USER_SET
=
1
;
const
PERMISSION_USER_NAME1
=
"
ohos.permission.LOCATION
"
;
const
PERMISSION_USER_NAME2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
let
tokenID
=
undefined
;
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.bluetooth.bluetoothhost
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.DISCOVER_BLUETOOTH
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
async
function
grantPerm
()
{
console
.
info
(
"
====grant Permission start====
"
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.bluetooth.bluetoothhost
'
,
0
,
100
);
...
...
@@ -69,35 +95,10 @@ describe('bluetoothhostTest3', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll called
'
)
await
applyPermission
();
await
grantPerm
();
done
()
})
...
...
communication/bluetooth_standard/src/main/js/test/BRScanMode.test.js
浏览文件 @
a2490cf5
...
...
@@ -14,11 +14,6 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
bluetoothhostTest2
()
{
...
...
@@ -52,34 +47,9 @@ describe('bluetoothhostTest2', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll called
'
)
done
()
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach called
'
)
...
...
communication/bluetooth_standard/src/main/js/test/BRSetLocalName.test.js
浏览文件 @
a2490cf5
...
...
@@ -14,12 +14,8 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
let
Btname
=
{
NUM_TEST
:
'
012345678901234567890123456789012345678901234567890123
'
+
'
45678901234567890123456789012345678901234567890123456789012345678901234567
'
,
...
...
@@ -75,34 +71,9 @@ describe('bluetoothhostTest1', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll called
'
)
done
()
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach called
'
)
...
...
communication/bluetooth_standard/src/main/js/test/BRSpp.test.js
浏览文件 @
a2490cf5
...
...
@@ -14,13 +14,34 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.bluetooth.bluetoothhost
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.DISCOVER_BLUETOOTH
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
export
default
function
bluetoothhostTest4
()
{
describe
(
'
bluetoothhostTest4
'
,
function
()
{
...
...
@@ -52,34 +73,9 @@ describe('bluetoothhostTest4', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll called
'
)
done
()
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach called
'
)
...
...
communication/bluetooth_standard/src/main/js/test/BRSwitch.test.js
浏览文件 @
a2490cf5
...
...
@@ -14,18 +14,13 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
let
BluetoothState
=
{
STATE_OFF
:
0
,
STATE_TURNING_ON
:
1
,
STATE_ON
:
2
,
STATE_TURNING_OFF
:
3
,
STATE_BLE_TURNING_ON
:
4
,
STATE_BLE_ON
:
5
,
STATE_BLE_
ON
:
6
STATE_BLE_
TURNING_OFF
:
6
};
export
default
function
bluetoothhostTest
()
{
...
...
@@ -59,34 +54,9 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
=== getAccountManager finish
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
LocalId is :
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
beforeAll
(
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll called
'
)
done
()
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach called
'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录