Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
3862afd7
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看板
未验证
提交
3862afd7
编写于
10月 24, 2022
作者:
O
openharmony_ci
提交者:
Gitee
10月 24, 2022
浏览文件
操作
浏览文件
下载
差异文件
!6028 【元能力启动管控】关联启动适配
Merge pull request !6028 from HuangXW/startUp_associatedWakeUp
上级
2eb5d0ba
13f2f628
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
1000 addition
and
19 deletion
+1000
-19
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/config.json
...accessortest/actsfwkdataaccessortest/src/main/config.json
+32
-0
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/js/TestDataAbility/data.js
...tsfwkdataaccessortest/src/main/js/TestDataAbility/data.js
+254
-0
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/js/TestDataAbility2/data.js
...sfwkdataaccessortest/src/main/js/TestDataAbility2/data.js
+254
-0
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/js/TestDataAbility3/data.js
...sfwkdataaccessortest/src/main/js/TestDataAbility3/data.js
+216
-0
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/js/test/DataAbilityHelperJsSt.test.js
...cessortest/src/main/js/test/DataAbilityHelperJsSt.test.js
+8
-8
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/js/test/DataAbilityHelperJsStPermission.test.js
.../src/main/js/test/DataAbilityHelperJsStPermission.test.js
+1
-1
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/resources/base/element/string.json
...aaccessortest/src/main/resources/base/element/string.json
+9
-1
ability/ability_runtime/faapicover/faapicoverhaptest/BUILD.gn
...ity/ability_runtime/faapicover/faapicoverhaptest/BUILD.gn
+3
-5
ability/ability_runtime/faapicover/faapicoverhaptest/entry/src/main/config.json
...e/faapicover/faapicoverhaptest/entry/src/main/config.json
+18
-0
ability/ability_runtime/faapicover/faapicoverhaptest/entry/src/main/ets/ServiceAbility/service.ts
...coverhaptest/entry/src/main/ets/ServiceAbility/service.ts
+103
-0
ability/ability_runtime/faapicover/faapicoverhaptest/entry/src/main/ets/ServiceAbility2/service.ts
...overhaptest/entry/src/main/ets/ServiceAbility2/service.ts
+90
-0
ability/ability_runtime/faapicover/faapicoverhaptest/entry/src/main/ets/test/VerificationTest.ets
...coverhaptest/entry/src/main/ets/test/VerificationTest.ets
+4
-4
ability/ability_runtime/faapicover/faapicoverhaptest/entry/src/main/resources/base/element/string.json
...haptest/entry/src/main/resources/base/element/string.json
+8
-0
未找到文件。
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/config.json
浏览文件 @
3862afd7
...
...
@@ -60,6 +60,38 @@
"type"
:
"page"
,
"visible"
:
true
,
"launchType"
:
"standard"
},
{
"srcPath"
:
"TestDataAbility"
,
"name"
:
".TestDataAbility"
,
"icon"
:
"$media:icon"
,
"srcLanguage"
:
"ets"
,
"description"
:
"$string:description_testdataability"
,
"type"
:
"data"
,
"visible"
:
true
,
"uri"
:
"dataability://com.example.myapplication.TestDataAbility"
},
{
"srcPath"
:
"TestDataAbility2"
,
"name"
:
".TestDataAbility2"
,
"icon"
:
"$media:icon"
,
"srcLanguage"
:
"ets"
,
"description"
:
"$string:description_testdataability"
,
"type"
:
"data"
,
"visible"
:
true
,
"uri"
:
"dataability://com.example.myapplication.TestDataAbility2"
},
{
"srcPath"
:
"TestDataAbility3"
,
"name"
:
".TestDataAbility3"
,
"icon"
:
"$media:icon"
,
"srcLanguage"
:
"ets"
,
"description"
:
"$string:description_testdataability"
,
"type"
:
"data"
,
"visible"
:
true
,
"uri"
:
"dataability://com.example.myapplication.TestDataAbility3"
,
"readPermission"
:
"ohos.permission.READ_CONTACTS"
,
"writePermission"
:
"ohos.permission.WRITE_CONTACTS"
}
],
"js"
:
[
...
...
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/js/TestDataAbility/data.js
0 → 100755
浏览文件 @
3862afd7
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
dataAbility
from
'
@ohos.data.dataAbility
'
import
fileio
from
'
@ohos.fileio
'
import
dataRdb
from
'
@ohos.data.rdb
'
const
TABLE_NAME
=
'
book
'
const
STORE_CONFIG
=
{
name
:
'
book.db
'
}
const
SQL_CREATE_TABLE
=
'
CREATE TABLE IF NOT EXISTS book
'
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, age INTEGER, introduction TEXT NOT NULL)
'
let
rdbStore
=
undefined
const
TAG
=
'
ACTS_ DataAbility.data
'
const
context
=
featureAbility
.
getContext
()
let
defaultReturn
=
1
;
let
returnError
=
0
;
let
returnError1
=
-
1
;
let
returnError2
=
-
2
;
let
returnError3
=
-
3
;
let
dataAbilityUri
=
(
"
dataability:///com.example.myapplication.TestDataAbility
"
);
export
default
{
onInitialized
(
abilityInfo
)
{
console
.
debug
(
'
ACTS_ DataAbility onInitialized,abilityInfo=
'
+
abilityInfo
.
bundleName
)
dataRdb
.
getRdbStore
(
context
,
STORE_CONFIG
,
1
,
(
err
,
store
)
=>
{
console
.
debug
(
'
ACTS_ [data]getRdbStoreThen
'
)
store
.
executeSql
(
SQL_CREATE_TABLE
,
[])
rdbStore
=
store
});
},
insert
(
uri
,
valueBucket
,
callback
)
{
console
.
debug
(
TAG
+
'
insert start 1121
'
)
console
.
debug
(
TAG
+
'
valueBucket json=>
'
+
JSON
.
stringify
(
valueBucket
))
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
console
.
debug
(
TAG
+
'
valueBucket.age =>
'
+
valueBucket
.
age
)
console
.
debug
(
TAG
+
'
valueBucket.name =>
'
+
valueBucket
.
name
)
console
.
debug
(
TAG
+
'
valueBucket.salary =>
'
+
valueBucket
.
salary
)
if
(
valueBucket
.
age
!=
24
)
{
err
=
"
Error age
"
callback
(
err
,
returnError2
);
}
if
(
valueBucket
.
name
!=
"
ActsDataAbilityHelperTest
"
)
{
err
=
"
Error name
"
callback
(
err
,
returnError2
);
}
if
(
valueBucket
.
salary
!=
2024.20
)
{
err
=
"
Error salary
"
callback
(
err
,
returnError2
);
}
err
=
"
Error insert
"
console
.
debug
(
TAG
+
'
rdbStore.insert
'
)
rdbStore
.
insert
(
TABLE_NAME
,
valueBucket
,
function
(
err
,
resultSet
)
{
console
.
log
(
TAG
+
"
insert callback resultSet:
"
+
resultSet
+
"
,json=
"
+
JSON
.
stringify
(
resultSet
)
+
'
,err
'
+
err
)
callback
(
err
,
defaultReturn
);
})
},
query
(
uri
,
columns
,
predicates
,
callback
)
{
console
.
debug
(
TAG
+
'
query start
'
)
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
let
rdbPredicates
=
dataAbility
.
createRdbPredicates
(
TABLE_NAME
,
predicates
)
rdbStore
.
query
(
rdbPredicates
,
columns
,
callback
)
},
update
(
uri
,
valueBucket
,
predicates
,
callback
)
{
console
.
debug
(
TAG
+
'
update start
'
)
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
console
.
debug
(
TAG
+
'
valueBucket.age =>
'
+
valueBucket
.
age
)
console
.
debug
(
TAG
+
'
valueBucket.name =>
'
+
valueBucket
.
name
)
console
.
debug
(
TAG
+
'
valueBucket.salary =>
'
+
valueBucket
.
salary
)
if
(
valueBucket
.
age
!=
24
)
{
err
=
"
Error age
"
callback
(
err
,
returnError2
);
}
if
(
valueBucket
.
name
!=
"
ActsDataAbilityHelperTest
"
)
{
err
=
"
Error name
"
callback
(
err
,
returnError2
);
}
if
(
valueBucket
.
salary
!=
2024.20
)
{
err
=
"
Error salary
"
callback
(
err
,
returnError2
);
}
err
=
"
Error update
"
let
rdbPredicates
=
dataAbility
.
createRdbPredicates
(
TABLE_NAME
,
predicates
)
rdbStore
.
update
(
valueBucket
,
rdbPredicates
,
function
(
err
,
resultSet
)
{
console
.
log
(
TAG
+
"
insert callback resultSet:
"
+
resultSet
+
"
,json=
"
+
JSON
.
stringify
(
resultSet
)
+
'
,err
'
+
err
)
callback
(
err
,
defaultReturn
);
})
},
delete
(
uri
,
predicates
,
callback
)
{
console
.
debug
(
TAG
+
'
delete start
'
)
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
let
rdbPredicates
=
dataAbility
.
createRdbPredicates
(
TABLE_NAME
,
predicates
)
rdbStore
.
delete
(
rdbPredicates
,
function
(
err
,
resultSet
)
{
console
.
log
(
TAG
+
"
insert callback resultSet:
"
+
resultSet
+
"
,json=
"
+
JSON
.
stringify
(
resultSet
)
+
'
,err
'
+
err
)
callback
(
err
,
defaultReturn
);
})
},
call
(
uri
,
method
,
arg
,
extras
,
callback
)
{
console
.
debug
(
TAG
+
'
call start
'
)
console
.
debug
(
TAG
+
'
uri---->
'
+
uri
)
console
.
debug
(
TAG
+
'
method---->
'
+
uri
)
},
batchInsert
(
uri
,
values
,
callback
)
{
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
for
(
var
j
=
0
;
j
<
values
.
length
;
j
++
)
{
rdbStore
.
insert
(
"
EMPLOYEE
"
,
values
[
j
],
function
(
err
,
ret
)
{
console
.
log
(
TAG
+
"
batchInsert callback ret:
"
+
JSON
.
stringify
(
ret
))
})
}
console
.
log
(
TAG
+
"
batchInsert values.length:
"
+
values
.
length
+
'
,json=
'
+
JSON
.
stringify
(
values
.
length
))
callback
(
err
,
values
.
length
);
},
getType
(
uri
,
callback
)
{
console
.
info
(
TAG
+
'
==================== DataAbility test interface by getType ================
'
);
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
callback
(
"
success
"
,
uri
);
},
getFileTypes
(
uri
,
mimeTypeFilter
,
callback
)
{
console
.
info
(
TAG
+
'
==================== DataAbility test interface by GetFileTypes ================
'
);
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
let
type1
=
"
"
;
let
type2
=
"
"
;
let
type3
=
"
"
;
let
types
;
if
(
mimeTypeFilter
==
"
*/*
"
)
{
type1
=
(
"
hap
"
);
type2
=
(
"
jpg
"
);
type3
=
(
"
image/png
"
);
types
=
[
type1
,
type2
,
type3
];
}
else
if
(
mimeTypeFilter
==
"
image/*
"
)
{
type1
=
(
"
image/png
"
);
types
=
[
type1
];
}
else
if
(
mimeTypeFilter
==
"
*/jpg
"
)
{
type1
=
(
"
jpg
"
);
types
=
[
type1
];
}
console
.
log
(
TAG
+
"
GetFileTypes callback ret:
"
+
JSON
.
stringify
(
types
))
callback
(
"
success
"
,
types
);
},
openFile
(
uri
,
mode
,
callback
)
{
console
.
info
(
TAG
+
'
==================== DataAbility test interface by openFile ================
'
);
let
defaultReturn
=
1
;
let
returnError1
=
-
1
;
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
if
(
!
(
mode
==
(
"
r
"
)
||
mode
==
(
"
w
"
)
||
mode
==
(
"
wt
"
)
||
mode
==
(
"
wa
"
)
||
mode
==
(
"
rw
"
)
||
mode
==
(
"
rwt
"
)))
{
if
(
mode
==
(
"
A1@k#4%$,.<>)(oioiu*((*&(&*giIGT^%&^Ug;sdfk;losd*7873iug8%&^$&%]ERFUy&^%&&R7
"
))
{
defaultReturn
=
returnError2
;
}
else
defaultReturn
=
returnError3
;
}
console
.
info
(
TAG
+
"
path = /data/test
"
);
let
path
=
"
/data/test
"
fileio
.
stat
(
path
).
then
(
function
(
stat
)
{
console
.
info
(
TAG
+
"
openFile getFileInfo successfully callback ret:
"
+
JSON
.
stringify
(
stat
));
}).
catch
(
function
(
err
)
{
console
.
info
(
TAG
+
"
openFile getFileInfo failed with error callback ret:
"
+
err
);
defaultReturn
=
returnError1
;
});
console
.
info
(
TAG
+
"
path ==>
"
+
path
);
callback
(
"
success
"
,
defaultReturn
);
},
normalizeUri
(
uri
,
callback
)
{
console
.
info
(
TAG
+
'
==================== DataAbility test interface by normalizeUri ================
'
);
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
""
);
}
callback
(
"
success
"
,
uri
);
},
denormalizeUri
(
uri
,
callback
)
{
console
.
info
(
TAG
+
'
==================== DataAbility test interface by denormalizeUri ================
'
);
console
.
info
(
TAG
+
"
denormalizeUri uri:
"
+
JSON
.
stringify
(
uri
));
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
""
);
}
callback
(
"
success
"
,
uri
);
}
};
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/js/TestDataAbility2/data.js
0 → 100755
浏览文件 @
3862afd7
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
dataAbility
from
'
@ohos.data.dataAbility
'
import
fileio
from
'
@ohos.fileio
'
import
dataRdb
from
'
@ohos.data.rdb
'
const
TABLE_NAME
=
'
book
'
const
STORE_CONFIG
=
{
name
:
'
book.db
'
}
const
SQL_CREATE_TABLE
=
'
CREATE TABLE IF NOT EXISTS book
'
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, age INTEGER, introduction TEXT NOT NULL)
'
let
rdbStore
=
undefined
const
TAG
=
'
ACTS_ DataAbility.data
'
const
context
=
featureAbility
.
getContext
()
let
defaultReturn
=
1
;
let
returnError
=
0
;
let
returnError1
=
-
1
;
let
returnError2
=
-
2
;
let
returnError3
=
-
3
;
let
dataAbilityUri
=
(
"
dataability:///com.example.myapplication.TestDataAbility2
"
);
export
default
{
onInitialized
(
abilityInfo
)
{
console
.
debug
(
'
ACTS_ DataAbility onInitialized,abilityInfo=
'
+
abilityInfo
.
bundleName
)
dataRdb
.
getRdbStore
(
context
,
STORE_CONFIG
,
1
,
(
err
,
store
)
=>
{
console
.
debug
(
'
ACTS_ [data]getRdbStoreThen
'
)
store
.
executeSql
(
SQL_CREATE_TABLE
,
[])
rdbStore
=
store
});
},
insert
(
uri
,
valueBucket
,
callback
)
{
console
.
debug
(
TAG
+
'
insert start 1121
'
)
console
.
debug
(
TAG
+
'
valueBucket json=>
'
+
JSON
.
stringify
(
valueBucket
))
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
console
.
debug
(
TAG
+
'
valueBucket.age =>
'
+
valueBucket
.
age
)
console
.
debug
(
TAG
+
'
valueBucket.name =>
'
+
valueBucket
.
name
)
console
.
debug
(
TAG
+
'
valueBucket.salary =>
'
+
valueBucket
.
salary
)
if
(
valueBucket
.
age
!=
24
)
{
err
=
"
Error age
"
callback
(
err
,
returnError2
);
}
if
(
valueBucket
.
name
!=
"
ActsDataAbilityHelperTest
"
)
{
err
=
"
Error name
"
callback
(
err
,
returnError2
);
}
if
(
valueBucket
.
salary
!=
2024.20
)
{
err
=
"
Error salary
"
callback
(
err
,
returnError2
);
}
err
=
"
Error insert
"
console
.
debug
(
TAG
+
'
rdbStore.insert
'
)
rdbStore
.
insert
(
TABLE_NAME
,
valueBucket
,
function
(
err
,
resultSet
)
{
console
.
log
(
TAG
+
"
insert callback resultSet:
"
+
resultSet
+
"
,json=
"
+
JSON
.
stringify
(
resultSet
)
+
'
,err
'
+
err
)
callback
(
err
,
defaultReturn
);
})
},
query
(
uri
,
columns
,
predicates
,
callback
)
{
console
.
debug
(
TAG
+
'
query start
'
)
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
let
rdbPredicates
=
dataAbility
.
createRdbPredicates
(
TABLE_NAME
,
predicates
)
rdbStore
.
query
(
rdbPredicates
,
columns
,
callback
)
},
update
(
uri
,
valueBucket
,
predicates
,
callback
)
{
console
.
debug
(
TAG
+
'
update start
'
)
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
console
.
debug
(
TAG
+
'
valueBucket.age =>
'
+
valueBucket
.
age
)
console
.
debug
(
TAG
+
'
valueBucket.name =>
'
+
valueBucket
.
name
)
console
.
debug
(
TAG
+
'
valueBucket.salary =>
'
+
valueBucket
.
salary
)
if
(
valueBucket
.
age
!=
24
)
{
err
=
"
Error age
"
callback
(
err
,
returnError2
);
}
if
(
valueBucket
.
name
!=
"
ActsDataAbilityHelperTest
"
)
{
err
=
"
Error name
"
callback
(
err
,
returnError2
);
}
if
(
valueBucket
.
salary
!=
2024.20
)
{
err
=
"
Error salary
"
callback
(
err
,
returnError2
);
}
err
=
"
Error update
"
let
rdbPredicates
=
dataAbility
.
createRdbPredicates
(
TABLE_NAME
,
predicates
)
rdbStore
.
update
(
valueBucket
,
rdbPredicates
,
function
(
err
,
resultSet
)
{
console
.
log
(
TAG
+
"
insert callback resultSet:
"
+
resultSet
+
"
,json=
"
+
JSON
.
stringify
(
resultSet
)
+
'
,err
'
+
err
)
callback
(
err
,
defaultReturn
);
})
},
delete
(
uri
,
predicates
,
callback
)
{
console
.
debug
(
TAG
+
'
delete start
'
)
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
let
rdbPredicates
=
dataAbility
.
createRdbPredicates
(
TABLE_NAME
,
predicates
)
rdbStore
.
delete
(
rdbPredicates
,
function
(
err
,
resultSet
)
{
console
.
log
(
TAG
+
"
insert callback resultSet:
"
+
resultSet
+
"
,json=
"
+
JSON
.
stringify
(
resultSet
)
+
'
,err
'
+
err
)
callback
(
err
,
defaultReturn
);
})
},
call
(
uri
,
method
,
arg
,
extras
,
callback
)
{
console
.
debug
(
TAG
+
'
call start
'
)
console
.
debug
(
TAG
+
'
uri---->
'
+
uri
)
console
.
debug
(
TAG
+
'
method---->
'
+
uri
)
},
batchInsert
(
uri
,
values
,
callback
)
{
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
for
(
var
j
=
0
;
j
<
values
.
length
;
j
++
)
{
rdbStore
.
insert
(
"
EMPLOYEE
"
,
values
[
j
],
function
(
err
,
ret
)
{
console
.
log
(
TAG
+
"
batchInsert callback ret:
"
+
JSON
.
stringify
(
ret
))
})
}
console
.
log
(
TAG
+
"
batchInsert values.length:
"
+
values
.
length
+
'
,json=
'
+
JSON
.
stringify
(
values
.
length
))
callback
(
err
,
values
.
length
);
},
getType
(
uri
,
callback
)
{
console
.
info
(
TAG
+
'
==================== DataAbility test interface by getType ================
'
);
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
callback
(
"
success
"
,
uri
);
},
getFileTypes
(
uri
,
mimeTypeFilter
,
callback
)
{
console
.
info
(
TAG
+
'
==================== DataAbility test interface by GetFileTypes ================
'
);
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
let
type1
=
"
"
;
let
type2
=
"
"
;
let
type3
=
"
"
;
let
types
;
if
(
mimeTypeFilter
==
"
*/*
"
)
{
type1
=
(
"
hap
"
);
type2
=
(
"
jpg
"
);
type3
=
(
"
image/png
"
);
types
=
[
type1
,
type2
,
type3
];
}
else
if
(
mimeTypeFilter
==
"
image/*
"
)
{
type1
=
(
"
image/png
"
);
types
=
[
type1
];
}
else
if
(
mimeTypeFilter
==
"
*/jpg
"
)
{
type1
=
(
"
jpg
"
);
types
=
[
type1
];
}
console
.
log
(
TAG
+
"
GetFileTypes callback ret:
"
+
JSON
.
stringify
(
types
))
callback
(
"
success
"
,
types
);
},
openFile
(
uri
,
mode
,
callback
)
{
console
.
info
(
TAG
+
'
==================== DataAbility test interface by openFile ================
'
);
let
defaultReturn
=
1
;
let
returnError1
=
-
1
;
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
if
(
!
(
mode
==
(
"
r
"
)
||
mode
==
(
"
w
"
)
||
mode
==
(
"
wt
"
)
||
mode
==
(
"
wa
"
)
||
mode
==
(
"
rw
"
)
||
mode
==
(
"
rwt
"
)))
{
if
(
mode
==
(
"
A1@k#4%$,.<>)(oioiu*((*&(&*giIGT^%&^Ug;sdfk;losd*7873iug8%&^$&%]ERFUy&^%&&R7
"
))
{
defaultReturn
=
returnError2
;
}
else
defaultReturn
=
returnError3
;
}
console
.
info
(
TAG
+
"
path = /data/test
"
);
let
path
=
"
/data/test
"
fileio
.
stat
(
path
).
then
(
function
(
stat
)
{
console
.
info
(
TAG
+
"
openFile getFileInfo successfully callback ret:
"
+
JSON
.
stringify
(
stat
));
}).
catch
(
function
(
err
)
{
console
.
info
(
TAG
+
"
openFile getFileInfo failed with error callback ret:
"
+
err
);
defaultReturn
=
returnError1
;
});
console
.
info
(
TAG
+
"
path ==>
"
+
path
);
callback
(
"
success
"
,
defaultReturn
);
},
normalizeUri
(
uri
,
callback
)
{
console
.
info
(
TAG
+
'
==================== DataAbility test interface by normalizeUri ================
'
);
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
""
);
}
callback
(
"
success
"
,
uri
);
},
denormalizeUri
(
uri
,
callback
)
{
console
.
info
(
TAG
+
'
==================== DataAbility test interface by denormalizeUri ================
'
);
console
.
info
(
TAG
+
"
denormalizeUri uri:
"
+
JSON
.
stringify
(
uri
));
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
""
);
}
callback
(
"
success
"
,
uri
);
}
};
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/js/TestDataAbility3/data.js
0 → 100755
浏览文件 @
3862afd7
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
dataAbility
from
'
@ohos.data.dataAbility
'
import
fileio
from
'
@ohos.fileio
'
import
dataRdb
from
'
@ohos.data.rdb
'
const
TABLE_NAME
=
'
book
'
const
STORE_CONFIG
=
{
name
:
'
book.db
'
}
const
SQL_CREATE_TABLE
=
'
CREATE TABLE IF NOT EXISTS book
'
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, age INTEGER, introduction TEXT NOT NULL)
'
let
rdbStore
=
undefined
const
TAG
=
'
ACTS_ DataAbility.data
'
const
context
=
featureAbility
.
getContext
()
let
defaultReturn
=
1
;
let
returnError
=
0
;
let
returnError1
=
-
1
;
let
returnError2
=
-
2
;
let
returnError3
=
-
3
;
let
dataAbilityUri
=
(
"
dataability:///com.example.myapplication.TestDataAbility3
"
);
export
default
{
onInitialized
(
abilityInfo
)
{
console
.
debug
(
'
ACTS_ DataAbility onInitialized,abilityInfo=
'
+
abilityInfo
.
bundleName
)
dataRdb
.
getRdbStore
(
context
,
STORE_CONFIG
,
1
,
(
err
,
store
)
=>
{
console
.
debug
(
'
ACTS_ [data]getRdbStoreThen
'
)
store
.
executeSql
(
SQL_CREATE_TABLE
,
[])
rdbStore
=
store
});
},
insert
(
uri
,
valueBucket
,
callback
)
{
console
.
debug
(
TAG
+
'
insert start 1121
'
)
console
.
debug
(
TAG
+
'
valueBucket json=>
'
+
JSON
.
stringify
(
valueBucket
))
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
console
.
debug
(
TAG
+
'
valueBucket.age =>
'
+
valueBucket
.
age
)
console
.
debug
(
TAG
+
'
valueBucket.name =>
'
+
valueBucket
.
name
)
console
.
debug
(
TAG
+
'
valueBucket.salary =>
'
+
valueBucket
.
salary
)
if
(
valueBucket
.
age
!=
24
)
{
err
=
"
Error age
"
callback
(
err
,
returnError2
);
}
if
(
valueBucket
.
name
!=
"
ActsDataAbilityHelperPermissionTest
"
)
{
err
=
"
Error name
"
callback
(
err
,
returnError2
);
}
if
(
valueBucket
.
salary
!=
2024.20
)
{
err
=
"
Error salary
"
callback
(
err
,
returnError2
);
}
err
=
"
Error insert
"
console
.
debug
(
TAG
+
'
rdbStore.insert
'
)
rdbStore
.
insert
(
TABLE_NAME
,
valueBucket
,
function
(
err
,
resultSet
)
{
console
.
log
(
TAG
+
"
insert callback resultSet:
"
+
resultSet
+
"
,json=
"
+
JSON
.
stringify
(
resultSet
)
+
'
,err
'
+
err
)
callback
(
err
,
defaultReturn
);
})
},
query
(
uri
,
columns
,
predicates
,
callback
)
{
console
.
debug
(
TAG
+
'
query start
'
)
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
let
rdbPredicates
=
dataAbility
.
createRdbPredicates
(
TABLE_NAME
,
predicates
)
rdbStore
.
query
(
rdbPredicates
,
columns
,
callback
)
},
update
(
uri
,
valueBucket
,
predicates
,
callback
)
{
console
.
debug
(
TAG
+
'
update start
'
)
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
console
.
debug
(
TAG
+
'
valueBucket.age =>
'
+
valueBucket
.
age
)
console
.
debug
(
TAG
+
'
valueBucket.name =>
'
+
valueBucket
.
name
)
console
.
debug
(
TAG
+
'
valueBucket.salary =>
'
+
valueBucket
.
salary
)
if
(
valueBucket
.
age
!=
24
)
{
err
=
"
Error age
"
callback
(
err
,
returnError2
);
}
if
(
valueBucket
.
name
!=
"
ActsDataAbilityHelperPermissionTest
"
)
{
err
=
"
Error name
"
callback
(
err
,
returnError2
);
}
if
(
valueBucket
.
salary
!=
2024.20
)
{
err
=
"
Error salary
"
callback
(
err
,
returnError2
);
}
err
=
"
Error update
"
let
rdbPredicates
=
dataAbility
.
createRdbPredicates
(
TABLE_NAME
,
predicates
)
rdbStore
.
update
(
valueBucket
,
rdbPredicates
,
function
(
err
,
resultSet
)
{
console
.
log
(
TAG
+
"
insert callback resultSet:
"
+
resultSet
+
"
,json=
"
+
JSON
.
stringify
(
resultSet
)
+
'
,err
'
+
err
)
callback
(
err
,
defaultReturn
);
})
},
delete
(
uri
,
predicates
,
callback
)
{
console
.
debug
(
TAG
+
'
delete start
'
)
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
let
rdbPredicates
=
dataAbility
.
createRdbPredicates
(
TABLE_NAME
,
predicates
)
rdbStore
.
delete
(
rdbPredicates
,
function
(
err
,
resultSet
)
{
console
.
log
(
TAG
+
"
insert callback resultSet:
"
+
resultSet
+
"
,json=
"
+
JSON
.
stringify
(
resultSet
)
+
'
,err
'
+
err
)
callback
(
err
,
defaultReturn
);
})
},
call
(
uri
,
method
,
arg
,
extras
,
callback
)
{
console
.
debug
(
TAG
+
'
call start
'
)
console
.
debug
(
TAG
+
'
uri---->
'
+
uri
)
console
.
debug
(
TAG
+
'
method---->
'
+
uri
)
},
batchInsert
(
uri
,
values
,
callback
)
{
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
for
(
var
j
=
0
;
j
<
values
.
length
;
j
++
)
{
rdbStore
.
insert
(
"
EMPLOYEE
"
,
values
[
j
],
function
(
err
,
ret
)
{
console
.
log
(
TAG
+
"
batchInsert callback ret:
"
+
JSON
.
stringify
(
ret
))
})
}
console
.
log
(
TAG
+
"
batchInsert values.length:
"
+
values
.
length
+
'
,json=
'
+
JSON
.
stringify
(
values
.
length
))
callback
(
err
,
values
.
length
);
},
openFile
(
uri
,
mode
,
callback
)
{
console
.
info
(
TAG
+
'
==================== DataAbility test interface by openFile ================
'
);
let
defaultReturn
=
1
;
let
returnError1
=
-
1
;
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
if
(
!
(
mode
==
(
"
r
"
)
||
mode
==
(
"
w
"
)
||
mode
==
(
"
wt
"
)
||
mode
==
(
"
wa
"
)
||
mode
==
(
"
rw
"
)
||
mode
==
(
"
rwt
"
)))
{
if
(
mode
==
(
"
A1@k#4%$,.<>)(oioiu*((*&(&*giIGT^%&^Ug;sdfk;losd*7873iug8%&^$&%]ERFUy&^%&&R7
"
))
{
defaultReturn
=
returnError2
;
}
else
defaultReturn
=
returnError3
;
}
console
.
info
(
TAG
+
"
path = /data/test
"
);
let
path
=
"
/data/test
"
fileio
.
stat
(
path
).
then
(
function
(
stat
)
{
console
.
info
(
TAG
+
"
openFile getFileInfo successfully callback ret:
"
+
JSON
.
stringify
(
stat
));
}).
catch
(
function
(
err
)
{
console
.
info
(
TAG
+
"
openFile getFileInfo failed with error callback ret:
"
+
err
);
defaultReturn
=
returnError1
;
});
console
.
info
(
TAG
+
"
path ==>
"
+
path
);
callback
(
"
success
"
,
defaultReturn
);
},
normalizeUri
(
uri
,
callback
)
{
console
.
info
(
TAG
+
'
==================== DataAbility test interface by normalizeUri ================
'
);
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
""
);
}
callback
(
"
success
"
,
uri
);
},
denormalizeUri
(
uri
,
callback
)
{
console
.
info
(
TAG
+
'
==================== DataAbility test interface by denormalizeUri ================
'
);
console
.
info
(
TAG
+
"
denormalizeUri uri:
"
+
JSON
.
stringify
(
uri
));
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
""
);
}
callback
(
"
success
"
,
uri
);
}
};
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/js/test/DataAbilityHelperJsSt.test.js
浏览文件 @
3862afd7
...
...
@@ -18,9 +18,9 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
export
default
function
ActsDataAbilityHelperTest
()
{
describe
(
'
ActsDataAbilityHelperTest
'
,
function
()
{
let
dataAbilityUri
=
(
"
dataability:///com.example.myapplication.DataAbility
"
);
let
dataAbilityUri2
=
(
"
dataability:///com.example.myapplication.DataAbility2
"
);
let
dataAbilityUri3
=
(
"
dataability:///com.example.myapplication.DataAbility3
"
);
let
dataAbilityUri
=
(
"
dataability:///com.example.myapplication.
Test
DataAbility
"
);
let
dataAbilityUri2
=
(
"
dataability:///com.example.myapplication.
Test
DataAbility2
"
);
let
dataAbilityUri3
=
(
"
dataability:///com.example.myapplication.
Test
DataAbility3
"
);
let
DAHelper
;
let
gSetTimeout
=
500
;
var
valueBucket
=
{
...
...
@@ -4228,9 +4228,9 @@ describe('ActsDataAbilityHelperTest', function () {
dataAbilityUri
,
undefined
,
).
then
((
data
)
=>
{
console
.
debug
(
"
=ACTS_OpenFile_1500 then data====>
"
console
.
debug
(
"
=ACTS_OpenFile_1500 then data
val is
====>
"
+
(
"
json data 【
"
)
+
JSON
.
stringify
(
data
)
+
(
"
】
"
));
expect
(
data
).
assertEqual
(
-
1
)
expect
(
data
).
assertEqual
(
-
3
)
console
.
log
(
'
ACTS_OpenFile_1500====<end
'
);
done
();
}).
catch
(
err
=>
{
...
...
@@ -4264,7 +4264,7 @@ describe('ActsDataAbilityHelperTest', function () {
(
err
,
data
)
=>
{
console
.
debug
(
"
=ACTS_OpenFile_1600 err,data=======>
"
+
(
"
json err【
"
)
+
JSON
.
stringify
(
err
)
+
(
"
】json data【
"
)
+
JSON
.
stringify
(
data
)
+
(
"
】;
"
));
expect
(
data
).
assertEqual
(
-
1
);
expect
(
data
).
assertEqual
(
-
3
);
console
.
log
(
'
ACTS_OpenFile_1600====<end
'
);
done
();
},
...
...
@@ -4292,7 +4292,7 @@ describe('ActsDataAbilityHelperTest', function () {
).
then
((
data
)
=>
{
console
.
debug
(
"
=ACTS_OpenFile_1700 then data====>
"
+
(
"
json data 【
"
)
+
JSON
.
stringify
(
data
)
+
(
"
】
"
));
expect
(
data
).
assertEqual
(
-
1
)
expect
(
data
).
assertEqual
(
-
2
)
console
.
log
(
'
ACTS_OpenFile_1700====<end
'
);
done
();
}).
catch
(
err
=>
{
...
...
@@ -4327,7 +4327,7 @@ describe('ActsDataAbilityHelperTest', function () {
(
err
,
data
)
=>
{
console
.
debug
(
"
=ACTS_OpenFile_1800 err,data=======>
"
+
(
"
json err【
"
)
+
JSON
.
stringify
(
err
)
+
(
"
】json data【
"
)
+
JSON
.
stringify
(
data
)
+
(
"
】;
"
));
expect
(
data
).
assertEqual
(
-
1
);
expect
(
data
).
assertEqual
(
-
2
);
console
.
log
(
'
ACTS_OpenFile_1800====<end
'
);
done
();
},
...
...
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/js/test/DataAbilityHelperJsStPermission.test.js
浏览文件 @
3862afd7
...
...
@@ -18,7 +18,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
export
default
function
ActsDataAbilityHelperPermissionTest
()
{
describe
(
'
ActsDataAbilityHelperPermissionTest
'
,
function
()
{
let
dataAbilityUri
=
(
"
dataability:///com.example.myapplication.DataAbility3
"
);
let
dataAbilityUri
=
(
"
dataability:///com.example.myapplication.
Test
DataAbility3
"
);
let
DAHelper
;
beforeAll
(
async
(
done
)
=>
{
...
...
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/resources/base/element/string.json
浏览文件 @
3862afd7
...
...
@@ -23,6 +23,14 @@
{
"name"
:
"TestAbility_label"
,
"value"
:
"label"
}
},
{
"name"
:
"description_testdataability"
,
"value"
:
"hap sample empty provider"
},
{
"name"
:
"description_dataability"
,
"value"
:
"hap sample empty provider"
}
]
}
\ No newline at end of file
ability/ability_runtime/faapicover/faapicoverhaptest/BUILD.gn
浏览文件 @
3862afd7
...
...
@@ -18,7 +18,6 @@ ohos_js_hap_suite("ActsFaApiCoverTest") {
deps = [
":faapicoverhaptest_ets_assets",
":faapicoverhaptest_ets_resources",
":faapicoverhaptest_ets_test_assets",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
...
...
@@ -27,10 +26,9 @@ ohos_js_hap_suite("ActsFaApiCoverTest") {
part_name = "ability_runtime"
}
ohos_js_assets("faapicoverhaptest_ets_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_js_assets("faapicoverhaptest_ets_test_assets") {
source_dir = "./entry/src/main/ets/TestAbility"
source_dir = "entry/src/main/ets"
hap_profile = "entry/src/main/config.json"
ets2abc = true
}
ohos_resources("faapicoverhaptest_ets_resources") {
sources = [ "./entry/src/main/resources" ]
...
...
ability/ability_runtime/faapicover/faapicoverhaptest/entry/src/main/config.json
浏览文件 @
3862afd7
...
...
@@ -54,6 +54,24 @@
"type"
:
"page"
,
"visible"
:
true
,
"launchType"
:
"singleton"
},
{
"srcPath"
:
"ServiceAbility"
,
"name"
:
".ServiceAbility"
,
"srcLanguage"
:
"ets"
,
"icon"
:
"$media:icon"
,
"description"
:
"$string:ServiceAbility_desc"
,
"type"
:
"service"
,
"visible"
:
true
},
{
"srcPath"
:
"ServiceAbility2"
,
"name"
:
".ServiceAbility2"
,
"srcLanguage"
:
"ets"
,
"icon"
:
"$media:icon"
,
"description"
:
"$string:ServiceAbility2_desc"
,
"type"
:
"service"
,
"visible"
:
true
}
],
"distro"
:
{
...
...
ability/ability_runtime/faapicover/faapicoverhaptest/entry/src/main/ets/ServiceAbility/service.ts
0 → 100755
浏览文件 @
3862afd7
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
rpc
from
"
@ohos.rpc
"
;
import
commonEvent
from
'
@ohos.commonEvent
'
;
import
ability_particleAbility
from
'
@ohos.ability.particleAbility
'
;
class
StubTest1
extends
rpc
.
RemoteObject
{
constructor
(
des
)
{
if
(
typeof
des
===
'
string
'
)
{
super
(
des
);
}
else
{
return
null
;
}
}
queryLocalInterface
(
descriptor
)
{
return
null
;
}
getInterfaceDescriptor
()
{
return
""
;
}
sendRequest
(
code
,
data
,
reply
,
options
)
{
return
null
;
}
getCallingPid
()
{
return
0
;
}
getCallingUid
()
{
return
0
;
}
attachLocalInterface
(
localInterface
,
descriptor
)
{
}
onRemoteRequest
(
code
,
data
,
reply
,
options
)
{
console
.
info
(
printLogS1
+
"
onRemoteRequest
"
);
if
(
code
==
1
)
{
console
.
info
(
printLogS1
+
"
onRemoteRequest code 1
"
);
let
op1
=
data
.
readInt
();
let
op2
=
data
.
readInt
();
console
.
info
(
printLogS1
+
"
onRemoteRequest op1 =
"
+
op1
+
"
, op2 =
"
+
op2
);
reply
.
writeInt
(
op1
+
op2
);
}
else
{
console
.
info
(
printLogS1
+
"
onRemoteRequest code =
"
+
code
);
}
return
true
;
}
}
var
printLogS1
=
"
Fa:Auxiliary:ServiceAbility:
"
;
var
listPushS1
=
"
Fa_Auxiliary_ServiceAbility_
"
;
export
default
{
onStart
()
{
console
.
info
(
printLogS1
+
'
onStart
'
);
commonEvent
.
publish
(
listPushS1
+
"
onStart
"
,
(
err
)
=>
{
console
.
info
(
printLogS1
+
listPushS1
+
"
onStart
"
);
});
},
onStop
()
{
console
.
info
(
printLogS1
+
'
onStop
'
);
commonEvent
.
publish
(
listPushS1
+
"
onStop
"
,
(
err
)
=>
{
console
.
info
(
printLogS1
+
listPushS1
+
"
onStop
"
);
});
},
onCommand
(
want
,
startId
)
{
console
.
info
(
printLogS1
+
'
onCommand
'
);
commonEvent
.
publish
(
listPushS1
+
"
onCommand
"
,
(
err
)
=>
{
console
.
info
(
printLogS1
+
listPushS1
+
"
onCommand
"
);
});
setTimeout
(()
=>
{
ability_particleAbility
.
terminateSelf
().
then
((
data
)
=>
{
console
.
info
(
printLogS1
+
"
terminateSelf data =
"
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
info
(
printLogS1
+
"
terminateSelf err =
"
+
JSON
.
stringify
(
err
));
});
},
3000
)
},
onConnect
(
want
)
{
console
.
info
(
printLogS1
+
'
onConnect
'
);
return
new
StubTest1
(
"
Test1
"
);
},
onDisconnect
(
want
)
{
console
.
info
(
printLogS1
+
'
onDisconnect
'
);
},
onReconnect
(
want
)
{
console
.
info
(
printLogS1
+
'
onReconnect
'
);
}
};
\ No newline at end of file
ability/ability_runtime/faapicover/faapicoverhaptest/entry/src/main/ets/ServiceAbility2/service.ts
0 → 100755
浏览文件 @
3862afd7
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
rpc
from
"
@ohos.rpc
"
;
import
commonEvent
from
'
@ohos.commonEvent
'
;
class
StubTest2
extends
rpc
.
RemoteObject
{
constructor
(
des
)
{
if
(
typeof
des
===
'
string
'
)
{
super
(
des
);
}
else
{
return
null
;
}
}
queryLocalInterface
(
descriptor
)
{
return
null
;
}
getInterfaceDescriptor
()
{
return
""
;
}
sendRequest
(
code
,
data
,
reply
,
options
)
{
return
null
;
}
getCallingPid
()
{
return
0
;
}
getCallingUid
()
{
return
0
;
}
attachLocalInterface
(
localInterface
,
descriptor
)
{
}
onRemoteRequest
(
code
,
data
,
reply
,
options
)
{
console
.
info
(
printLogS1
+
"
onRemoteRequest
"
);
if
(
code
==
1
)
{
console
.
info
(
printLogS1
+
"
onRemoteRequest code 1
"
);
let
op1
=
data
.
readInt
();
let
op2
=
data
.
readInt
();
console
.
info
(
printLogS1
+
"
onRemoteRequest op1 =
"
+
op1
+
"
, op2 =
"
+
op2
);
reply
.
writeInt
(
op1
+
op2
);
}
else
{
console
.
info
(
printLogS1
+
"
onRemoteRequest code =
"
+
code
);
}
return
true
;
}
}
var
printLogS1
=
"
Fa:Auxiliary:ServiceAbility2:
"
;
var
listPushS1
=
"
Fa_Auxiliary_ServiceAbility2_
"
;
export
default
{
onStart
()
{
console
.
info
(
printLogS1
+
'
onStart
'
);
},
onStop
()
{
console
.
info
(
printLogS1
+
'
onStop
'
);
},
onCommand
(
want
,
startId
)
{
console
.
info
(
printLogS1
+
'
onCommand
'
);
},
onConnect
(
want
)
{
console
.
info
(
printLogS1
+
'
onConnect
'
);
commonEvent
.
publish
(
listPushS1
+
"
onConnect
"
,
(
err
)
=>
{
console
.
info
(
printLogS1
+
listPushS1
+
"
onCreate
"
);
});
return
new
StubTest2
(
"
Test1
"
);
},
onDisconnect
(
want
)
{
console
.
info
(
printLogS1
+
'
onDisconnect
'
);
commonEvent
.
publish
(
listPushS1
+
"
onDisconnect
"
,
(
err
)
=>
{
console
.
info
(
printLogS1
+
listPushS1
+
"
onDisconnect
"
);
});
},
onReconnect
(
want
)
{
console
.
info
(
printLogS1
+
'
onReconnect
'
);
}
};
\ No newline at end of file
ability/ability_runtime/faapicover/faapicoverhaptest/entry/src/main/ets/test/VerificationTest.ets
浏览文件 @
3862afd7
...
...
@@ -307,8 +307,8 @@ export default function verificationTest(){
let
wantNum
=
{
want
:
{
bundleName
:
'
ohos.acts.aafwk.test.faauxiliary
'
,
abilityName
:
'
ohos.acts.aafwk.test.faauxiliary
.ServiceAbility'
bundleName
:
'
com.example.faapicoverhaptest
'
,
abilityName
:
'
com.example.faapicoverhaptest
.ServiceAbility'
}
}
await
ability_featureAbility
.
startAbility
(
wantNum
)
.
then
((
data
)
=>
{
...
...
@@ -406,8 +406,8 @@ export default function verificationTest(){
}
};
let
wantNum
=
{
bundleName
:
'
ohos.acts.aafwk.test.faauxiliary
'
,
abilityName
:
'
ohos.acts.aafwk.test.faauxiliary
.ServiceAbility2'
bundleName
:
'
com.example.faapicoverhaptest
'
,
abilityName
:
'
com.example.faapicoverhaptest
.ServiceAbility2'
}
let
num
=
ability_featureAbility
.
connectAbility
(
wantNum
,
options
)
}
catch
(
err
)
{
...
...
ability/ability_runtime/faapicover/faapicoverhaptest/entry/src/main/resources/base/element/string.json
浏览文件 @
3862afd7
...
...
@@ -19,6 +19,14 @@
{
"name"
:
"TestAbility_label"
,
"value"
:
"label"
},
{
"name"
:
"ServiceAbility_desc"
,
"value"
:
"hap sample empty service"
},
{
"name"
:
"ServiceAbility2_desc"
,
"value"
:
"hap sample empty service"
}
]
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录