diff --git a/AppScope/app.json5 b/AppScope/app.json5
new file mode 100644
index 0000000..b144781
--- /dev/null
+++ b/AppScope/app.json5
@@ -0,0 +1,14 @@
+
+{
+ "app": {
+ "bundleName": "com.ohos.callui",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name",
+ "distributedNotificationEnabled": true,
+ "singleton": true,
+ "keepAlive": true
+ },
+}
diff --git a/AppScope/resources/base/element/string.json b/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000..7a71c9e
--- /dev/null
+++ b/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "通话"
+ }
+ ]
+}
diff --git a/AppScope/resources/base/media/app_icon.png b/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000..4ef5ab8
Binary files /dev/null and b/AppScope/resources/base/media/app_icon.png differ
diff --git a/build-profile.json5 b/build-profile.json5
index 141abea..fd783cb 100644
--- a/build-profile.json5
+++ b/build-profile.json5
@@ -16,7 +16,7 @@
"app": {
"signingConfigs": [
{
- "name": "default",
+ "name": "release",
"material": {
"storePassword": "",
"certpath": "signature/OpenHarmony.cer",
@@ -28,19 +28,19 @@
}
}
],
- "compileSdkVersion": 8,
- "compatibleSdkVersion": 8,
+ "compileSdkVersion": 9,
+ "compatibleSdkVersion": 9,
"products": [
{
"name": "default",
- "signingConfig": "default",
+ "signingConfig": "release",
}
]
},
"modules": [
{
- "name": "callui",
- "srcPath": "./callui",
+ "name": "com.ohos.callui",
+ "srcPath": "./entry",
"targets": [
{
"name": "default",
@@ -51,7 +51,11 @@
]
},
{
- "name": "mobiledatasettings",
+ "name": "common",
+ "srcPath": "./common"
+ },
+ {
+ "name": "com.ohos.mobiledatasettings",
"srcPath": "./mobiledatasettings",
"targets": [
{
diff --git a/callui/build-profile.json5 b/callui/build-profile.json5
deleted file mode 100644
index cec88c9..0000000
--- a/callui/build-profile.json5
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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.
- */
-{
- apiType: 'faMode',
- showInServiceCenter: false,
- buildOption: {
- },
- "targets": [
- {
- "name": "default",
- }
- ]
-}
\ No newline at end of file
diff --git a/callui/hvigorfile.js b/callui/hvigorfile.js
deleted file mode 100644
index 23d0ec3..0000000
--- a/callui/hvigorfile.js
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = require('@ohos/hvigor-ohos-plugin').legacyHapTasks
\ No newline at end of file
diff --git a/callui/src/main/config.json b/callui/src/main/config.json
deleted file mode 100644
index b920bb6..0000000
--- a/callui/src/main/config.json
+++ /dev/null
@@ -1,93 +0,0 @@
-{
- "app": {
- "bundleName": "com.ohos.callui",
- "vendor": "ohos",
- "singleton": true,
- "version": {
- "code": 1000000,
- "name": "1.0.0"
- }
- },
- "deviceConfig": {
- "default": {
- "keepAlive": true
- }
- },
- "module": {
- "package": "com.ohos.callui",
- "name": ".MyApplication",
- "mainAbility": ".ServiceAbility",
- "srcPath": "",
- "deviceType": [
- "phone",
- "tablet"
- ],
- "distro": {
- "deliveryWithInstall": true,
- "moduleName": "callui",
- "moduleType": "entry",
- "installationFree": false
- },
- "abilities": [
- {
- "skills": [
- {
- "entities": [
- "entity.system.home"
- ],
- "actions": [
- "action.system.home"
- ]
- }
- ],
- "orientation": "unspecified",
- "visible": true,
- "srcPath": "default",
- "name": ".MainAbility",
- "srcLanguage": "ets",
- "icon": "$media:icon",
- "description": "JS_Empty Ability",
- "formsEnabled": false,
- "label": "$string:entry_MainAbility",
- "type": "page",
- "launchType": "singleton"
- },
- {
- "name": ".ServiceAbility",
- "icon": "$media:icon",
- "description": "service",
- "type": "service",
- "srcPath": "ServiceAbility",
- "srcLanguage": "ets",
- "visible": true
- }
- ],
- "js": [
- {
- "mode": {
- "syntax": "ets",
- "type": "pageAbility"
- },
- "pages": [
- "pages/index"
- ],
- "name": ".MainAbility",
- "window": {
- "designWidth": 720,
- "autoDesignWidth": false
- }
- }
- ],
- "reqPermissions" : [
- {
- "name" : "ohos.permission.READ_CONTACTS"
- },
- {
- "name" : "ohos.permission.SEND_MESSAGES"
- },
- {
- "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
- }
- ]
- }
-}
\ No newline at end of file
diff --git a/callui/src/main/ets/ServiceAbility/Service.ts b/callui/src/main/ets/ServiceAbility/Service.ts
deleted file mode 100644
index af4d5b0..0000000
--- a/callui/src/main/ets/ServiceAbility/Service.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * @file: service entry
- */
-
-import CallManagerService from './CallManagerService';
-import HiLog from '../default/common/utils/Hilog';
-
-const TAG = "Service";
-
-export default {
-
- /**
- * onStart
- */
- onStart() {
- HiLog.i(TAG, "onStart callUI service")
- this.callManagerService = new CallManagerService();
- },
-
- /**
- * onStop
- */
- onStop() {
- HiLog.i(TAG, "onStop callUI service")
- this.callManagerService.unsubscribe();
- this.callManagerService.removeRegisterListener();
- }
-};
diff --git a/callui/src/main/ets/default/app.ets b/callui/src/main/ets/default/app.ets
deleted file mode 100644
index 90b8922..0000000
--- a/callui/src/main/ets/default/app.ets
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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 CallManager from './model/CallManager';
-import CallStateConst from './common/constant/CallStateConst';
-import HiLog from './common/utils/Hilog';
-import deviceInfo from '@ohos.deviceInfo';
-
-const TAG = "App";
-
-export default {
- data:{
- callData: {
- ...CallStateConst.defaultCallData
- },
- callList: [],
- callTimeList: [],
- appInactiveState: false,
- },
-
- /**
- * onCreate
- */
- onCreate() {
- globalThis.deviceTypeInfo = deviceInfo.deviceType;
- HiLog.i(TAG, "callui app Application onCreate")
- },
-
- /**
- * onDestroy
- */
- onDestroy() {
- HiLog.i(TAG, "callui app Application onDestroy")
- globalThis.callManager.clearTimer();
- globalThis.callManager.unsubscribe();
- }
-};
\ No newline at end of file
diff --git a/callui/src/main/ets/default/assets/picture/ic_public_add_filled_Grey.svg b/callui/src/main/ets/default/assets/picture/ic_public_add_filled_Grey.svg
deleted file mode 100644
index 2887f77..0000000
--- a/callui/src/main/ets/default/assets/picture/ic_public_add_filled_Grey.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
\ No newline at end of file
diff --git a/callui/src/main/ets/default/assets/picture/ic_public_contacts_Grey.svg b/callui/src/main/ets/default/assets/picture/ic_public_contacts_Grey.svg
deleted file mode 100644
index 82537bb..0000000
--- a/callui/src/main/ets/default/assets/picture/ic_public_contacts_Grey.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
\ No newline at end of file
diff --git a/callui/src/main/ets/default/assets/picture/ic_public_recording_Grey.svg b/callui/src/main/ets/default/assets/picture/ic_public_recording_Grey.svg
deleted file mode 100644
index ad31e9b..0000000
--- a/callui/src/main/ets/default/assets/picture/ic_public_recording_Grey.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
\ No newline at end of file
diff --git a/callui/src/main/ets/default/assets/picture/ic_public_video_Grey.svg b/callui/src/main/ets/default/assets/picture/ic_public_video_Grey.svg
deleted file mode 100644
index e3792cb..0000000
--- a/callui/src/main/ets/default/assets/picture/ic_public_video_Grey.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
\ No newline at end of file
diff --git a/callui/src/main/ets/default/assets/picture/ic_public_voice_Grey.svg b/callui/src/main/ets/default/assets/picture/ic_public_voice_Grey.svg
deleted file mode 100644
index 26bb2d0..0000000
--- a/callui/src/main/ets/default/assets/picture/ic_public_voice_Grey.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
\ No newline at end of file
diff --git a/callui/src/main/ets/default/model/ContactManager.ets b/callui/src/main/ets/default/model/ContactManager.ets
deleted file mode 100644
index 4b1f0fb..0000000
--- a/callui/src/main/ets/default/model/ContactManager.ets
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * @file: Contact management
- */
-
-import featureAbility from '@ohos.ability.featureAbility';
-import dataAbility from '@ohos.data.dataAbility';
-import HiLog from '../common/utils/Hilog';
-
-const TAG = "ContactManager";
-const DBbaseUri = 'dataability:///com.ohos.contactsdataability';
-const DBUri = DBbaseUri + '/contacts/contact_data';
-
-/**
- * class ContactManager
- */
-export default class ContactManager {
-
- /**
- * get contact info
- *
- * @param { Object } callData -Object
- */
- async getContactInfo(callData) {
- try {
- const columns = ['id', 'display_name', 'detail_info'];
- const predicates = new dataAbility.DataAbilityPredicates();
- predicates.equalTo('detail_info', callData.accountNumber);
- predicates.equalTo('is_deleted', 0);
- const dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(DBbaseUri);
- const resSet = await dataAbilityHelper.query(DBUri, columns, predicates);
- HiLog.i(TAG, "getContactInfo resSet : %s" + JSON.stringify(resSet))
- if (resSet.rowCount > 0) {
- resSet.goToFirstRow();
- callData.contactName = resSet.getString(resSet.getColumnIndex('display_name'));
- }
- } catch (err) {
- HiLog.i(TAG, "getContactInfo catch err : %s" + JSON.stringify(err))
- }
- }
-}
\ No newline at end of file
diff --git a/callui/src/main/resources/base/media/ic_public_add_filled_Grey.svg b/callui/src/main/resources/base/media/ic_public_add_filled_Grey.svg
deleted file mode 100644
index 2887f77..0000000
--- a/callui/src/main/resources/base/media/ic_public_add_filled_Grey.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
\ No newline at end of file
diff --git a/callui/src/main/resources/base/media/ic_public_contacts_Grey.svg b/callui/src/main/resources/base/media/ic_public_contacts_Grey.svg
deleted file mode 100644
index 82537bb..0000000
--- a/callui/src/main/resources/base/media/ic_public_contacts_Grey.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
\ No newline at end of file
diff --git a/callui/src/main/resources/base/media/ic_public_pause_Grey.svg b/callui/src/main/resources/base/media/ic_public_pause_Grey.svg
deleted file mode 100644
index 41cd39f..0000000
--- a/callui/src/main/resources/base/media/ic_public_pause_Grey.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
\ No newline at end of file
diff --git a/callui/src/main/resources/base/media/ic_public_recording_Grey.svg b/callui/src/main/resources/base/media/ic_public_recording_Grey.svg
deleted file mode 100644
index ad31e9b..0000000
--- a/callui/src/main/resources/base/media/ic_public_recording_Grey.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
\ No newline at end of file
diff --git a/callui/src/main/resources/base/media/ic_public_video_Grey.svg b/callui/src/main/resources/base/media/ic_public_video_Grey.svg
deleted file mode 100644
index e3792cb..0000000
--- a/callui/src/main/resources/base/media/ic_public_video_Grey.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
\ No newline at end of file
diff --git a/callui/src/main/resources/base/media/ic_public_voice_Grey.svg b/callui/src/main/resources/base/media/ic_public_voice_Grey.svg
deleted file mode 100644
index 26bb2d0..0000000
--- a/callui/src/main/resources/base/media/ic_public_voice_Grey.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
\ No newline at end of file
diff --git a/common/.gitignore b/common/.gitignore
new file mode 100644
index 0000000..16ad228
--- /dev/null
+++ b/common/.gitignore
@@ -0,0 +1,3 @@
+/node_modules
+/.preview
+/build
\ No newline at end of file
diff --git a/common/build-profile.json5 b/common/build-profile.json5
new file mode 100644
index 0000000..e517103
--- /dev/null
+++ b/common/build-profile.json5
@@ -0,0 +1,5 @@
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ }
+}
diff --git a/common/hvigorfile.js b/common/hvigorfile.js
new file mode 100644
index 0000000..c111e5e
--- /dev/null
+++ b/common/hvigorfile.js
@@ -0,0 +1,3 @@
+// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
+module.exports = require('@ohos/hvigor-ohos-plugin').harTasks
+
diff --git a/common/index.ets b/common/index.ets
new file mode 100644
index 0000000..97b1efa
--- /dev/null
+++ b/common/index.ets
@@ -0,0 +1 @@
+export { MainPage } from './src/main/ets/components/MainPage/MainPage'
diff --git a/common/package.json b/common/package.json
new file mode 100644
index 0000000..d7974d0
--- /dev/null
+++ b/common/package.json
@@ -0,0 +1,14 @@
+{
+ "license":"ISC",
+ "types":"",
+ "devDependencies":{},
+ "name":"@ohos/common",
+ "description":"a npm package which contains arkUI2.0 page",
+ "ohos":{
+ "org":""
+ },
+ "main":"index.ets",
+ "repository":{},
+ "version":"1.0.0",
+ "dependencies":{}
+}
\ No newline at end of file
diff --git a/common/src/main/ets/components/MainPage/MainPage.ets b/common/src/main/ets/components/MainPage/MainPage.ets
new file mode 100644
index 0000000..70f1037
--- /dev/null
+++ b/common/src/main/ets/components/MainPage/MainPage.ets
@@ -0,0 +1,16 @@
+@Component
+export struct MainPage {
+ @State message: string = 'Hello World'
+
+ build() {
+ Row() {
+ Column() {
+ Text(this.message)
+ .fontSize(50)
+ .fontWeight(FontWeight.Bold)
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
diff --git a/common/src/main/module.json5 b/common/src/main/module.json5
new file mode 100644
index 0000000..4e8fe1e
--- /dev/null
+++ b/common/src/main/module.json5
@@ -0,0 +1,10 @@
+{
+ "module": {
+ "name": "common",
+ "type": "har",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ]
+ }
+}
diff --git a/common/src/main/resources/base/element/string.json b/common/src/main/resources/base/element/string.json
new file mode 100644
index 0000000..78fe302
--- /dev/null
+++ b/common/src/main/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "page_show",
+ "value": "page from npm package"
+ }
+ ]
+}
diff --git a/doc/Instructions.md b/doc/Instructions.md
index c0ecdc5..87da4e9 100644
--- a/doc/Instructions.md
+++ b/doc/Instructions.md
@@ -105,7 +105,7 @@ import dataStorage from '@ohos.data.storage';
-(2)选择 Project → Signing Configs,添加StorePassword:123456abcdef,KeyPassword:123456,
+(2)选择 Project → Signing Configs,添加StorePassword:123456abc,KeyPassword:123456abc,
依次填入下图中,完成后点击Apply,再点击OK
![](../doc/image/signature_2.png)
diff --git a/callui/.gitignore b/entry/.gitignore
similarity index 53%
rename from callui/.gitignore
rename to entry/.gitignore
index 7d5b7a9..4a65948 100644
--- a/callui/.gitignore
+++ b/entry/.gitignore
@@ -1,2 +1,4 @@
-/build
-/node_modules
+/node_modules
+/.preview
+/build
+/.cxx
\ No newline at end of file
diff --git a/entry/build-profile.json5 b/entry/build-profile.json5
new file mode 100644
index 0000000..f6660dc
--- /dev/null
+++ b/entry/build-profile.json5
@@ -0,0 +1,13 @@
+{
+ "apiType": 'stageMode',
+ "buildOption": {
+ },
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/hvigorfile.js b/entry/hvigorfile.js
new file mode 100644
index 0000000..d7720ee
--- /dev/null
+++ b/entry/hvigorfile.js
@@ -0,0 +1,2 @@
+// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
+module.exports = require('@ohos/hvigor-ohos-plugin').hapTasks
diff --git a/entry/package.json b/entry/package.json
new file mode 100644
index 0000000..fbf1c05
--- /dev/null
+++ b/entry/package.json
@@ -0,0 +1,14 @@
+{
+ "license":"ISC",
+ "devDependencies":{},
+ "name":"entry",
+ "ohos":{
+ "org":"huawei",
+ "directoryLevel":"module",
+ "buildTool":"hvigor"
+ },
+ "description":"example description",
+ "repository":{},
+ "version":"1.0.0",
+ "dependencies":{}
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/Application/MyAbilityStage.ts b/entry/src/main/ets/Application/MyAbilityStage.ts
new file mode 100644
index 0000000..1f9f46e
--- /dev/null
+++ b/entry/src/main/ets/Application/MyAbilityStage.ts
@@ -0,0 +1,33 @@
+import AbilityStage from "@ohos.application.AbilityStage"
+import deviceInfo from '@ohos.deviceInfo';
+import backgroundTaskManager from '@ohos.backgroundTaskManager';
+import LogUtils from '../common/utils/LogUtils'
+
+const TAG = "MyAbilityStage";
+
+export default class MyAbilityStage extends AbilityStage {
+ onCreate() {
+ globalThis.deviceTypeInfo = deviceInfo.deviceType;
+ this.applyEfficiencyResources();
+ LogUtils.i(TAG, "MyAbilityStage onCreate")
+ }
+
+ onDestroy() {
+ LogUtils.i(TAG, "MyAbilityStage onDestroy")
+ backgroundTaskManager.resetAllEfficiencyResources();
+ }
+
+ private applyEfficiencyResources() {
+ let request: backgroundTaskManager.EfficiencyResourcesRequest = {
+ resourceTypes: backgroundTaskManager.ResourceType.COMMON_EVENT,
+ isApply: true,
+ timeOut: 0,
+ reason: "apply",
+ isPersist: true,
+ isProcess: false,
+ }
+ let res = backgroundTaskManager.applyEfficiencyResources(request);
+ LogUtils.i(TAG, "result of applyEfficiencyResources is:" + res)
+ }
+}
+
diff --git a/entry/src/main/ets/MainAbility/MainAbility.ts b/entry/src/main/ets/MainAbility/MainAbility.ts
new file mode 100644
index 0000000..b4e4232
--- /dev/null
+++ b/entry/src/main/ets/MainAbility/MainAbility.ts
@@ -0,0 +1,46 @@
+import featureAbility from '@ohos.ability.featureAbility';
+import Ability from '@ohos.application.Ability'
+import LogUtils from '../common/utils/LogUtils'
+
+const TAG = "MainAbility";
+
+export default class MainAbility extends Ability {
+ onCreate(want, launchParam) {
+ LogUtils.i(TAG, "onCreate")
+ globalThis.abilityWant = want;
+ globalThis.calluiAbilityContext = this.context;
+ }
+
+ onWindowStageCreate(windowStage) {
+ // Main window is created, set main page for this ability
+ LogUtils.i(TAG, "onWindowStageCreate")
+ windowStage.loadContent("pages/index", (err, data) => {
+ if (err.code) {
+ console.error('Failed to load the content. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
+ });
+ }
+
+ onWindowStageDestroy() {
+ // Main window is destroyed, release UI related resources
+ LogUtils.i(TAG, "onWindowStageDestroy")
+ }
+
+ onForeground() {
+ // Ability has brought to foreground
+ LogUtils.i(TAG, "onForeground")
+ }
+
+ onBackground() {
+ // Ability has back to background
+ LogUtils.i(TAG, "onBackground")
+ }
+
+ onDestroy() {
+ LogUtils.i(TAG, "onDestroy")
+ globalThis.callManager.clearTimer();
+ globalThis.callManager.unsubscribe();
+ }
+};
diff --git a/callui/src/main/ets/ServiceAbility/CallManagerService.ets b/entry/src/main/ets/ServiceAbility/CallManagerService.ts
similarity index 84%
rename from callui/src/main/ets/ServiceAbility/CallManagerService.ets
rename to entry/src/main/ets/ServiceAbility/CallManagerService.ts
index 3629281..1852eeb 100644
--- a/callui/src/main/ets/ServiceAbility/CallManagerService.ets
+++ b/entry/src/main/ets/ServiceAbility/CallManagerService.ts
@@ -20,7 +20,7 @@
import PA from '@ohos.ability.particleAbility';
import TelephonyCall from './TelephonyApi';
import commonEvent from '@ohos.commonEvent';
-import HiLog from '../default/common/utils/Hilog';
+import LogUtils from "../common/utils/LogUtils"
let subscriber;
const TAG = "CallManagerService";
@@ -39,22 +39,24 @@ export default class CallManagerService {
private mTelephonyCall: TelephonyCall ;
private callData = null;
private callList = [];
+ private context: any;
- public constructor() {
+ public constructor(context: any) {
this.mTelephonyCall = new TelephonyCall;
this.addRegisterListener();
this.addSubscriber();
+ this.context = context;
}
/**
* add callui app subscriber
*/
async addSubscriber() {
+ LogUtils.i(TAG, "addSubscriber")
subscriber = await new Promise((resolve) => {
commonEvent.createSubscriber({
events
}, (err, data) => {
- HiLog.i(TAG, "addSubscriber")
resolve(data);
});
});
@@ -73,11 +75,11 @@ export default class CallManagerService {
this.btnclickAgent(callId, btnType)
}
} else {
- HiLog.i(TAG, "callui service commonEvent.subscribe failed err : %s" + JSON.stringify(err))
+ LogUtils.i(TAG, "addSubscriber commonEvent.subscribe failed err :" + JSON.stringify(err))
}
subscriber.finishCommonEvent()
.then(() => {
- HiLog.i(TAG, "addSubscriber finishCommonEvent")
+ LogUtils.i(TAG, "addSubscriber finishCommonEvent")
})
});
}
@@ -89,7 +91,7 @@ export default class CallManagerService {
* @param { string } btnType - button type
*/
btnclickAgent(callId, btnType) {
- HiLog.i(TAG, "btnType : %s" + btnType)
+ LogUtils.i(TAG, "btnclickAgent btnType :" + btnType)
this.getMapObj(btnType, callId)
}
@@ -139,16 +141,14 @@ export default class CallManagerService {
* @param { Object } callData - Object
*/
startAbility(callData) {
- PA.startAbility({
- want: {
+ this.context.startAbility({
bundleName: CALL_BUNDLE_NAME,
abilityName: ABILITY_NAME,
parameters: callData
- }
}).then((data) => {
- HiLog.i(TAG, "callUI service PA.startAbility data : %s" + JSON.stringify(data))
+ LogUtils.i(TAG, "callUI service startAbility data :" + JSON.stringify(data))
}).catch((err) => {
- HiLog.i(TAG, "callUI service PA.startAbility err : %s" + JSON.stringify(err))
+ LogUtils.i(TAG, "callUI service startAbility err :" + JSON.stringify(err))
});
}
@@ -179,12 +179,12 @@ export default class CallManagerService {
* @param { Object } callData - Object
*/
publishData(callData) {
- commonEvent.publish('callui.event.callDetailsChange', {
- bundleName: CALL_BUNDLE_NAME,
+ commonEvent.publish('callui.event.callDetailsChange', {
+ bundleName: 'com.ohos.callui',
isOrdered: false,
data: JSON.stringify(callData)
}, (res) => {
- HiLog.i(TAG, "callUI service commonEvent.publish callback res")
+ LogUtils.i(TAG, "publishData commonEvent.publish callback res: callui.event.callDetailsChange")
});
}
@@ -194,7 +194,7 @@ export default class CallManagerService {
unsubscribe() {
commonEvent.unsubscribe(subscriber, (err) => {
if (err.code !== 0) {
- HiLog.i(TAG, "callUI service commonEvent.unsubscribe err: %s" + JSON.stringify(err))
+ LogUtils.i(TAG, "unsubscribe commonEvent.unsubscribe err:" + JSON.stringify(err))
}
});
}
diff --git a/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/entry/src/main/ets/ServiceAbility/ServiceAbility.ts
new file mode 100644
index 0000000..35e6264
--- /dev/null
+++ b/entry/src/main/ets/ServiceAbility/ServiceAbility.ts
@@ -0,0 +1,47 @@
+import Want from '@ohos.application.Want';
+import ServiceExtension from '@ohos.application.ServiceExtensionAbility';
+import CallManagerService from './CallManagerService';
+import rpc from '@ohos.rpc';
+import LogUtils from "../common/utils/LogUtils"
+
+const TAG = "ServiceAbility";
+export default class ServiceAbility extends ServiceExtension {
+ callManagerService: CallManagerService
+ onCreate(want) {
+ LogUtils.i(TAG, "onCreate callUI service");
+ this.callManagerService = new CallManagerService(this.context);
+ }
+
+ onConnect(want:Want) {
+ LogUtils.i(TAG, "onConnect callUI service want:" + JSON.stringify(want));
+ let callData:any = {};
+ callData.accountNumber = want.parameters.accountNumber;
+ callData.videoState = want.parameters.videoState;
+ callData.callType = want.parameters.callType;
+ callData.callState = want.parameters.callState;
+ callData.conferenceState = want.parameters.conferenceState;
+ this.callManagerService.getCallData(callData);
+ return new Stub("ServiceAbility");
+ }
+
+ onRequest(want:Want, startId:number) {
+ LogUtils.i(TAG, "onRequest callUI service");
+ }
+
+ onDestroy() {
+ LogUtils.i(TAG, "onDestroy callUI service");
+ }
+}
+class Stub extends rpc.RemoteObject {
+ constructor(descriptor) {
+ super(descriptor);
+ }
+ onRemoteRequest(code, date, reply, option) {
+ try {
+ LogUtils.i(TAG, "Stub onRemoteRequest code:" + code)
+ return true;
+ } finally {
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/callui/src/main/ets/ServiceAbility/TelephonyApi.ets b/entry/src/main/ets/ServiceAbility/TelephonyApi.ets
similarity index 68%
rename from callui/src/main/ets/ServiceAbility/TelephonyApi.ets
rename to entry/src/main/ets/ServiceAbility/TelephonyApi.ets
index 43d0b06..71529e2 100644
--- a/callui/src/main/ets/ServiceAbility/TelephonyApi.ets
+++ b/entry/src/main/ets/ServiceAbility/TelephonyApi.ets
@@ -18,7 +18,7 @@
*/
import call from '@ohos.telephony.call';
-import HiLog from '../default/common/utils/Hilog';
+import LogUtils from "../common/utils/LogUtils"
const prefixLog = 'callui service:@ohos.telephony.call:';
const TAG = "TelephonyApi";
@@ -33,10 +33,10 @@ export default class TelephonyApi {
public registerCallStateCallback(callBack) {
call.on('callDetailsChange', (data) => {
if (!data) {
- HiLog.i(TAG, prefixLog + "call.on registerCallStateCallback" + JSON.stringify(data))
+ LogUtils.i(TAG, prefixLog + "call.on registerCallStateCallback: " + JSON.stringify(data))
return;
}
- HiLog.i(TAG, prefixLog + "call.on registerCallStateCallback callState :" + JSON.stringify(data.callState))
+ LogUtils.i(TAG, prefixLog + "call.on registerCallStateCallback callState: " + JSON.stringify(data.callState))
callBack(data);
});
}
@@ -47,10 +47,10 @@ export default class TelephonyApi {
public unRegisterCallStateCallback() {
call.off('callDetailsChange', (data) => {
if (!data) {
- HiLog.i(TAG, prefixLog + "call.off unRegisterCallStateCallback" + JSON.stringify(data))
+ LogUtils.i(TAG, prefixLog + "call.off unRegisterCallStateCallback" + JSON.stringify(data))
return;
}
- HiLog.i(TAG, prefixLog + "call.off unRegisterCallStateCallback")
+ LogUtils.i(TAG, prefixLog + "call.off unRegisterCallStateCallback")
});
}
@@ -61,9 +61,9 @@ export default class TelephonyApi {
*/
public acceptCall = function (callId) {
call.answer(callId).then((res) => {
- HiLog.i(TAG, prefixLog + "call.answer")
+ LogUtils.i(TAG, prefixLog + "call.answer")
}).catch((err) => {
- HiLog.i(TAG, prefixLog + "call.answer catch : %s" + JSON.stringify(err))
+ LogUtils.i(TAG, prefixLog + "call.answer catch : %s" + JSON.stringify(err))
})
}
@@ -77,12 +77,14 @@ export default class TelephonyApi {
* @param { string } msg - message string
*/
public rejectCall = function (callId, isSendSms = false, msg = '') {
- const rejectCallPromise = isSendSms ? call.reject(callId, {messageContent: msg}) : call.reject(callId);
+ const rejectCallPromise = isSendSms ? call.reject(callId, {
+ messageContent: msg
+ }) : call.reject(callId);
rejectCallPromise.then((res) => {
- HiLog.i(TAG, prefixLog + "then:rejectCall")
+ LogUtils.i(TAG, prefixLog + "then:rejectCall")
})
.catch((err) => {
- HiLog.i(TAG, prefixLog + "catch:rejectCall : %s" + JSON.stringify(err))
+ LogUtils.i(TAG, prefixLog + "catch:rejectCall : " + JSON.stringify(err))
});
};
@@ -96,10 +98,10 @@ export default class TelephonyApi {
public hangUpCall = (callId) => new Promise((resolve, reject) => {
call.hangup(callId).then((res) => {
resolve(res);
- HiLog.i(TAG, prefixLog + "then:hangUpCall : %s" + JSON.stringify(callId))
+ LogUtils.i(TAG, prefixLog + "then:hangUpCall : %s" + JSON.stringify(callId))
}).catch((err) => {
reject(err);
- HiLog.i(TAG, prefixLog + "catch:hangUpCall : %s" + JSON.stringify(err))
+ LogUtils.i(TAG, prefixLog + "catch:hangUpCall : %s" + JSON.stringify(err))
});
});
}
diff --git a/callui/src/main/ets/default/assets/picture/addCall.png b/entry/src/main/ets/assets/picture/addCall.png
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/addCall.png
rename to entry/src/main/ets/assets/picture/addCall.png
diff --git a/callui/src/main/ets/default/assets/picture/addCallGrey.png b/entry/src/main/ets/assets/picture/addCallGrey.png
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/addCallGrey.png
rename to entry/src/main/ets/assets/picture/addCallGrey.png
diff --git a/callui/src/main/ets/default/assets/picture/exchange.png b/entry/src/main/ets/assets/picture/exchange.png
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/exchange.png
rename to entry/src/main/ets/assets/picture/exchange.png
diff --git a/callui/src/main/ets/default/assets/picture/exchangeGrey.png b/entry/src/main/ets/assets/picture/exchangeGrey.png
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/exchangeGrey.png
rename to entry/src/main/ets/assets/picture/exchangeGrey.png
diff --git a/callui/src/main/ets/default/assets/picture/exchangeIcon.png b/entry/src/main/ets/assets/picture/exchangeIcon.png
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/exchangeIcon.png
rename to entry/src/main/ets/assets/picture/exchangeIcon.png
diff --git a/callui/src/main/ets/default/assets/picture/ic_public_add_filled.svg b/entry/src/main/ets/assets/picture/ic_public_add_filled.svg
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/ic_public_add_filled.svg
rename to entry/src/main/ets/assets/picture/ic_public_add_filled.svg
diff --git a/entry/src/main/ets/assets/picture/ic_public_add_filled_Grey.svg b/entry/src/main/ets/assets/picture/ic_public_add_filled_Grey.svg
new file mode 100644
index 0000000..24192c1
--- /dev/null
+++ b/entry/src/main/ets/assets/picture/ic_public_add_filled_Grey.svg
@@ -0,0 +1,31 @@
+
+
\ No newline at end of file
diff --git a/callui/src/main/ets/default/assets/picture/ic_public_contacts.svg b/entry/src/main/ets/assets/picture/ic_public_contacts.svg
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/ic_public_contacts.svg
rename to entry/src/main/ets/assets/picture/ic_public_contacts.svg
diff --git a/entry/src/main/ets/assets/picture/ic_public_contacts_Grey.svg b/entry/src/main/ets/assets/picture/ic_public_contacts_Grey.svg
new file mode 100644
index 0000000..80bc251
--- /dev/null
+++ b/entry/src/main/ets/assets/picture/ic_public_contacts_Grey.svg
@@ -0,0 +1,32 @@
+
+
\ No newline at end of file
diff --git a/callui/src/main/ets/default/assets/picture/ic_public_message.svg b/entry/src/main/ets/assets/picture/ic_public_message.svg
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/ic_public_message.svg
rename to entry/src/main/ets/assets/picture/ic_public_message.svg
diff --git a/callui/src/main/ets/default/assets/picture/ic_public_pause.svg b/entry/src/main/ets/assets/picture/ic_public_pause.svg
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/ic_public_pause.svg
rename to entry/src/main/ets/assets/picture/ic_public_pause.svg
diff --git a/callui/src/main/ets/default/assets/picture/ic_public_pause_Enabled.svg b/entry/src/main/ets/assets/picture/ic_public_pause_Enabled.svg
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/ic_public_pause_Enabled.svg
rename to entry/src/main/ets/assets/picture/ic_public_pause_Enabled.svg
diff --git a/entry/src/main/ets/assets/picture/ic_public_pause_Grey.svg b/entry/src/main/ets/assets/picture/ic_public_pause_Grey.svg
new file mode 100644
index 0000000..988901b
--- /dev/null
+++ b/entry/src/main/ets/assets/picture/ic_public_pause_Grey.svg
@@ -0,0 +1,21 @@
+
+
\ No newline at end of file
diff --git a/callui/src/main/ets/default/assets/picture/ic_public_recording_.svg b/entry/src/main/ets/assets/picture/ic_public_recording_.svg
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/ic_public_recording_.svg
rename to entry/src/main/ets/assets/picture/ic_public_recording_.svg
diff --git a/entry/src/main/ets/assets/picture/ic_public_recording_Grey.svg b/entry/src/main/ets/assets/picture/ic_public_recording_Grey.svg
new file mode 100644
index 0000000..ec296ce
--- /dev/null
+++ b/entry/src/main/ets/assets/picture/ic_public_recording_Grey.svg
@@ -0,0 +1,32 @@
+
+
\ No newline at end of file
diff --git a/callui/src/main/ets/default/assets/picture/ic_public_video.svg b/entry/src/main/ets/assets/picture/ic_public_video.svg
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/ic_public_video.svg
rename to entry/src/main/ets/assets/picture/ic_public_video.svg
diff --git a/entry/src/main/ets/assets/picture/ic_public_video_Grey.svg b/entry/src/main/ets/assets/picture/ic_public_video_Grey.svg
new file mode 100644
index 0000000..0a8aae9
--- /dev/null
+++ b/entry/src/main/ets/assets/picture/ic_public_video_Grey.svg
@@ -0,0 +1,32 @@
+
+
\ No newline at end of file
diff --git a/callui/src/main/ets/default/assets/picture/ic_public_video_filled.svg b/entry/src/main/ets/assets/picture/ic_public_video_filled.svg
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/ic_public_video_filled.svg
rename to entry/src/main/ets/assets/picture/ic_public_video_filled.svg
diff --git a/callui/src/main/ets/default/assets/picture/ic_public_voice.svg b/entry/src/main/ets/assets/picture/ic_public_voice.svg
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/ic_public_voice.svg
rename to entry/src/main/ets/assets/picture/ic_public_voice.svg
diff --git a/callui/src/main/ets/default/assets/picture/ic_public_voice_Enabled.svg b/entry/src/main/ets/assets/picture/ic_public_voice_Enabled.svg
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/ic_public_voice_Enabled.svg
rename to entry/src/main/ets/assets/picture/ic_public_voice_Enabled.svg
diff --git a/entry/src/main/ets/assets/picture/ic_public_voice_Grey.svg b/entry/src/main/ets/assets/picture/ic_public_voice_Grey.svg
new file mode 100644
index 0000000..9a97c44
--- /dev/null
+++ b/entry/src/main/ets/assets/picture/ic_public_voice_Grey.svg
@@ -0,0 +1,32 @@
+
+
\ No newline at end of file
diff --git a/callui/src/main/ets/default/assets/picture/remindDisabled.png b/entry/src/main/ets/assets/picture/remindDisabled.png
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/remindDisabled.png
rename to entry/src/main/ets/assets/picture/remindDisabled.png
diff --git a/callui/src/main/ets/default/assets/picture/shunt.png b/entry/src/main/ets/assets/picture/shunt.png
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/shunt.png
rename to entry/src/main/ets/assets/picture/shunt.png
diff --git a/callui/src/main/ets/default/assets/picture/shuntHang.png b/entry/src/main/ets/assets/picture/shuntHang.png
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/shuntHang.png
rename to entry/src/main/ets/assets/picture/shuntHang.png
diff --git a/callui/src/main/ets/default/assets/picture/soundEnabled.png b/entry/src/main/ets/assets/picture/soundEnabled.png
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/soundEnabled.png
rename to entry/src/main/ets/assets/picture/soundEnabled.png
diff --git a/callui/src/main/ets/default/assets/picture/userCall.png b/entry/src/main/ets/assets/picture/userCall.png
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/userCall.png
rename to entry/src/main/ets/assets/picture/userCall.png
diff --git a/callui/src/main/ets/default/assets/picture/wallpaper.png b/entry/src/main/ets/assets/picture/wallpaper.png
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/wallpaper.png
rename to entry/src/main/ets/assets/picture/wallpaper.png
diff --git a/callui/src/main/ets/default/common/components/BottomBtn.ets b/entry/src/main/ets/common/components/BottomBtn.ets
similarity index 92%
rename from callui/src/main/ets/default/common/components/BottomBtn.ets
rename to entry/src/main/ets/common/components/BottomBtn.ets
index 5cd479b..79e7bc4 100644
--- a/callui/src/main/ets/default/common/components/BottomBtn.ets
+++ b/entry/src/main/ets/common/components/BottomBtn.ets
@@ -18,7 +18,7 @@
*/
import CallServiceProxy from '../../model/CallServiceProxy';
-import HiLog from '../utils/Hilog';
+import LogUtils from '../utils/LogUtils';
const TAG = "BottomBtn";
@@ -29,8 +29,8 @@ export default struct BottomBtn {
private mCallServiceProxy: CallServiceProxy;
private imageList;
- public aboutToAppear(callData, callList, callTimeList): void {
- HiLog.i(TAG, "aboutToAppear :");
+ public aboutToAppear() {
+ LogUtils.i(TAG, "aboutToAppear :");
this.getImageList();
this.mCallServiceProxy = CallServiceProxy.getInstance();
}
@@ -60,7 +60,7 @@ export default struct BottomBtn {
*/
onHangUp() {
this.mCallServiceProxy.hangUpCall(this.callData.callId);
- HiLog.i(TAG, "onHangUp this.callData.callId : %s", this.callData.callId);
+ LogUtils.i(TAG, "onHangUp this.callData.callId : " + this.callData.callId);
}
/**
diff --git a/callui/src/main/ets/default/common/components/contactCard.ets b/entry/src/main/ets/common/components/ContactCard.ets
similarity index 95%
rename from callui/src/main/ets/default/common/components/contactCard.ets
rename to entry/src/main/ets/common/components/ContactCard.ets
index 829ff06..62fb0be 100644
--- a/callui/src/main/ets/default/common/components/contactCard.ets
+++ b/entry/src/main/ets/common/components/ContactCard.ets
@@ -17,21 +17,23 @@
* @file: Header information display component
*/
-import callList from '../components/CallList';
-import Utils from '../utils/utils';
+
+import LogUtils from '../utils/LogUtils';
import callStateConst from '../constant/CallStateConst';
-import HiLog from '../utils/Hilog';
+import Utils from '../utils/utils'
const TAG = "contactCard";
/**
- * call global variable
+ * call global variable 会黑屏
*/
+/*
let callTimeList;
let defaultTemp = globalThis.exports.default;
if (defaultTemp != undefined) {
callTimeList = defaultTemp.data.callTimeList;
}
+*/
@Component
export default struct ContactCard {
@@ -40,29 +42,40 @@ export default struct ContactCard {
@Prop isShowKeyboard: boolean;
@Link callList: Array;
@Link callData: any;
+ @StorageLink("TextInput") textInput: string = '';
+ @StorageLink("TextInputValue") textInputValue: string = '';
+ @StorageLink("CallTimeList") callTimeList: any = [];
+ @StorageLink("AccountNumber") accountNumber: string = '';
+ @StorageLink("IsEmergencyPhoneNumber") isEmergencyPhoneNumber: boolean = false;
private mUtils: Utils;
private timer;
private emergency = $r('app.string.emergency');
- @StorageLink("CallTimeList") callTimeList: any = [];
- @StorageLink("TextInput") textInput: string = '';
- @StorageLink("TextInputValue") textInputValue: string = '';
- @StorageLink("AccountNumber") accountNumber: string = '';
- @StorageLink("IsEmergencyPhoneNumber") isEmergencyPhoneNumber: boolean = false;
- public aboutToAppear(callData, callList, callTimeList): void {
- HiLog.i(TAG, "aboutToAppear");
+ public aboutToAppear(): void {
+ LogUtils.i(TAG, "aboutToAppear");
this.mUtils = Utils.getInstance();
+ this.callTimeList = [];
this.timer = setInterval(() => {
if (this.dialing === '...') {
this.dialing = '';
}
this.dialing += '.';
- },500)
+ }, 500)
if (this.callData.callState === 3) {
clearInterval(this.timer)
}
}
+ /**
+ * Determine whether to display the call list or the input box
+ *
+ * @return {boolean} - return success true fail false
+ */
+ private isShowCard() {
+ return this.callList.length === 1 || (this.callList.length > 1 && this.callList.some((v) =>
+ v.callState === callStateConst.CALL_STATUS_WAITING));
+ }
+
/**
* Call status
*
@@ -81,16 +94,6 @@ export default struct ContactCard {
return this.callState() === callStateConst.CALL_STATUS_ACTIVE && this.callList.length === 1;
}
- /**
- * Determine whether to display the call list or the input box
- *
- * @return {boolean} - return success true fail false
- */
- private isShowCard() {
- return this.callList.length === 1 || (this.callList.length > 1 && this.callList.some((v) =>
- v.callState === callStateConst.CALL_STATUS_WAITING));
- }
-
build() {
GridContainer({ gutter: 24, margin: 24 }) {
Column() {
@@ -195,6 +198,7 @@ export default struct ContactCard {
if (this.isShowTime()) {
Column() {
Text(this.callTimeList[0].callTime)
+ // Text('00:56 ')
.fontSize(14)
.height(19)
.lineHeight(19)
diff --git a/callui/src/main/ets/default/common/components/DtmfBtn.ets b/entry/src/main/ets/common/components/DtmfBtn.ets
similarity index 89%
rename from callui/src/main/ets/default/common/components/DtmfBtn.ets
rename to entry/src/main/ets/common/components/DtmfBtn.ets
index c946a32..552fe85 100644
--- a/callui/src/main/ets/default/common/components/DtmfBtn.ets
+++ b/entry/src/main/ets/common/components/DtmfBtn.ets
@@ -14,7 +14,7 @@
*/
import CallServiceProxy from "../../model/CallServiceProxy";
-import HiLog from '../utils/Hilog';
+import LogUtils from '../utils/LogUtils';
const TAG = "DtmfBtn";
@@ -31,7 +31,7 @@ export default struct DtmfBtn {
public aboutToAppear(): void {
this.textInput = "";
- HiLog.i(TAG, "aboutToAppear");
+ LogUtils.i(TAG, "aboutToAppear");
this.mCallServiceProxy = new CallServiceProxy();
}
@@ -42,7 +42,7 @@ export default struct DtmfBtn {
*/
onBtnTouchStart(obj) {
this.mCallServiceProxy.startDTMF(this.callData.callId, String(obj.value));
- HiLog.i(TAG, "onBtnTouchStart :");
+ LogUtils.i(TAG, "onBtnTouchStart :");
}
/**
@@ -52,7 +52,7 @@ export default struct DtmfBtn {
*/
onBtnTouchEnd() {
this.mCallServiceProxy.stopDTMF(this.callData.callId);
- HiLog.i(TAG, "onBtnTouchEnd :");
+ LogUtils.i(TAG, "onBtnTouchEnd :");
}
build() {
@@ -90,7 +90,7 @@ export default struct DtmfBtn {
}
AppStorage.SetOrCreate("textInputValue", this.textInputValue)
AppStorage.SetOrCreate("TextInput", this.textInput)
- HiLog.i(TAG, "textInputValue + TextInput : %s" + JSON.stringify(AppStorage.Get("textInputValue")) + JSON.stringify(AppStorage.Get("TextInput")));
+ LogUtils.i(TAG, "textInputValue + TextInput : %s" + JSON.stringify(AppStorage.Get("textInputValue")) + JSON.stringify(AppStorage.Get("TextInput")));
this.onBtnTouchStart(this.item)
}
if (event.type === TouchType.Up) {
diff --git a/callui/src/main/ets/default/common/components/FuncBtn.ets b/entry/src/main/ets/common/components/FuncBtn.ets
similarity index 91%
rename from callui/src/main/ets/default/common/components/FuncBtn.ets
rename to entry/src/main/ets/common/components/FuncBtn.ets
index abe1db0..fd73eae 100644
--- a/callui/src/main/ets/default/common/components/FuncBtn.ets
+++ b/entry/src/main/ets/common/components/FuncBtn.ets
@@ -14,7 +14,7 @@
*/
import Method from '../utils/Method';
-import HiLog from '../utils/Hilog';
+import LogUtils from '../utils/LogUtils';
const TAG = "FuncBtn";
@@ -37,7 +37,7 @@ export default struct FuncBtn {
*/
iconUrl() {
if (this.isDisable && this.iconDisableUrl) {
- HiLog.i(TAG, "iconUrl this.isDisable : %s" + this.isDisable);
+ LogUtils.i(TAG, "iconUrl this.isDisable : " + this.isDisable);
return this.iconDisableUrl;
}
return this.isActive && this.iconDefaultUrl ? this.iconActiveUrl : this.iconDefaultUrl;
@@ -47,7 +47,7 @@ export default struct FuncBtn {
* Button group change picture
*/
changeBtn(type) {
- HiLog.i(TAG, "changeBtn type : %s" + type);
+ LogUtils.i(TAG, "changeBtn type : " + type);
const BtnName = ['record', 'video', 'mute'];
if (Method.includes(BtnName, type)) {
this.isActive = !this.isActive;
@@ -73,12 +73,12 @@ export default struct FuncBtn {
return '';
}
this.textColor = 'rgb(255, 255, 255)';
- HiLog.i(TAG, "iconClassName this.isDisable :");
+ LogUtils.i(TAG, "iconClassName this.isDisable :");
return 'default';
}
- private aboutToAppear(): void {
- HiLog.i(TAG, "aboutToAppear");
+ aboutToAppear() {
+ LogUtils.i(TAG, "aboutToAppear");
this.iconClassName();
}
diff --git a/callui/src/main/ets/default/common/components/FuncBtnGroup.ets b/entry/src/main/ets/common/components/FuncBtnGroup.ets
similarity index 90%
rename from callui/src/main/ets/default/common/components/FuncBtnGroup.ets
rename to entry/src/main/ets/common/components/FuncBtnGroup.ets
index eb24452..6d26570 100644
--- a/callui/src/main/ets/default/common/components/FuncBtnGroup.ets
+++ b/entry/src/main/ets/common/components/FuncBtnGroup.ets
@@ -15,13 +15,12 @@
import Method from '../utils/Method';
import FuncBtn from './FuncBtn';
-import FA from '@ohos.ability.featureAbility';
import CallStateConst from '../constant/CallStateConst';
import CallServiceProxy from '../../model/CallServiceProxy';
import Clone from '../utils/clone';
import ConferenceConst from '../constant/ConferenceConst';
import BtnGroupConfig from '../configs/BtnGroupConfig';
-import HiLog from '../utils/Hilog';
+import LogUtils from '../utils/LogUtils';
const TAG = 'FuncBtnGroup';
const textMap =
@@ -53,7 +52,7 @@ export default struct FuncBtnGroup {
private btnListCall;
private btnListDialing;
- private aboutToAppear(): void {
+ aboutToAppear() {
this.mClone = Clone.getInstance()
this.mCallServiceProxy = CallServiceProxy.getInstance();
this.mBtnGroupConfig.btnGroupList.forEach((v) => {
@@ -66,20 +65,20 @@ export default struct FuncBtnGroup {
this.getBtnListCall()
this.btnList = this.btnListCall
this.updateBtnList()
- HiLog.i(TAG, "aboutToAppear :");
+ LogUtils.i(TAG, "aboutToAppear :");
}
/**
* Switching BtnList Based on CallStatus
*/
updateBtnList() {
- if (this.callData.callState === CallStateConst.CALL_STATUS_DIALING|| this.callData.callState === CallStateConst.CALL_STATUS_ALERTING) {
+ if (this.callData.callState === CallStateConst.CALL_STATUS_DIALING || this.callData.callState === CallStateConst.CALL_STATUS_ALERTING) {
this.btnList = this.btnListDialing
- }else{
+ } else {
this.btnList = this.btnListCall
}
this.onCallStateChange(this.callData.callState)
- HiLog.i(TAG, "upData BtnList");
+ LogUtils.i(TAG, "upData BtnList");
}
/**
@@ -89,7 +88,6 @@ export default struct FuncBtnGroup {
this.btnListDialing = this.mClone.clone(this.mBtnGroupConfig.btnGroupList);
this.btnListDialing[1].isDisable = true
this.btnListDialing[2].isDisable = true
- HiLog.i(TAG, "get btnListCall");
}
/**
@@ -98,7 +96,7 @@ export default struct FuncBtnGroup {
* @param {Object} callData - call data
*/
onCallStateChange(newVal) {
- HiLog.i(TAG, "Calling status changed : %s" + JSON.stringify(newVal));
+ LogUtils.i(TAG, "Calling status changed newState : " + JSON.stringify(newVal));
const BtnName= ['video', 'record', 'add', 'contact']
if (newVal === CallStateConst.CALL_STATUS_ACTIVE || newVal === CallStateConst.CALL_STATUS_HOLDING) {
this.btnList.forEach((item) => {
@@ -114,7 +112,7 @@ export default struct FuncBtnGroup {
} else {
this.btnList.forEach((item) => {
if (item.type === 'contact') {
- item.isDisable = true;
+ item.isDisable = false;
}
});
}
@@ -126,7 +124,7 @@ export default struct FuncBtnGroup {
* @param {Object} obj - object
*/
btnClick(obj) {
- HiLog.i(TAG, "btnClick get icon type : %s" + JSON.stringify(obj));
+ LogUtils.i(TAG, "btnClick get icon type : " + JSON.stringify(obj));
const BtnName= ['record', 'video', 'mute']
const type = obj.type;
const { callId } = this.callData;
@@ -156,14 +154,12 @@ export default struct FuncBtnGroup {
this.mCallServiceProxy.switchCall(callId);
break;
case 'add':
- FA.startAbility({
- want: {
+ globalThis.calluiAbilityContext.startAbility({
bundleName: 'com.ohos.contacts',
abilityName: 'com.ohos.contacts.MainAbility',
parameters: {
pageFlag : 'page_flag_dialer'
}
- }
});
break;
case 'video':
@@ -172,14 +168,12 @@ export default struct FuncBtnGroup {
this.muteHandle('mute');
break;
case 'contact':
- FA.startAbility({
- want: {
+ globalThis.calluiAbilityContext.startAbility({
bundleName: 'com.ohos.contacts',
abilityName: 'com.ohos.contacts.MainAbility',
parameters: {
pageFlag: "page_flag_choose_contacts"
}
- }
});
break;
case 'merge':
@@ -197,7 +191,7 @@ export default struct FuncBtnGroup {
*/
keepHandle(type) {
const awaitIsActive = this.btnList.find((v) => v.type === type).isActive;
- HiLog.i(TAG, "keep handle");
+ LogUtils.i(TAG, "keep handle awaitIsActive : " + !awaitIsActive);
!awaitIsActive ? this.mCallServiceProxy.holdCall(this.callData.callId) : this.mCallServiceProxy.unHoldCall(this.callData.callId);
}
@@ -208,7 +202,7 @@ export default struct FuncBtnGroup {
*/
muteHandle(type) {
const awaitIsActive = this.btnList.find((v) => v.type === type).isActive;
- HiLog.i(TAG, "mute Handle");
+ LogUtils.i(TAG, "mute Handle awaitIsActive : " + awaitIsActive);
awaitIsActive ? this.mCallServiceProxy.setMuted() : this.mCallServiceProxy.cancelMuted();
}
@@ -216,7 +210,7 @@ export default struct FuncBtnGroup {
* Clear timer
*/
onDestroy() {
- HiLog.i(TAG, "onDestroy");
+ LogUtils.i(TAG, "onDestroy");
this.timer && clearInterval(this.timer);
}
diff --git a/callui/src/main/ets/default/common/components/InComDialog.ets b/entry/src/main/ets/common/components/InComDialog.ets
similarity index 95%
rename from callui/src/main/ets/default/common/components/InComDialog.ets
rename to entry/src/main/ets/common/components/InComDialog.ets
index 6120be2..ee1c482 100644
--- a/callui/src/main/ets/default/common/components/InComDialog.ets
+++ b/entry/src/main/ets/common/components/InComDialog.ets
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-import HiLog from '../utils/Hilog';
+import LogUtils from '../utils/LogUtils';
const TAG = 'InComDialog';
@@ -54,7 +54,7 @@ export default struct InComDialog {
.onClick(() => {
this.controller.close();
this.confirm(item)
- HiLog.i(TAG, "onClick and confirm");
+ LogUtils.i(TAG, "onClick and confirm");
})
if (item.id !== 4) {
@@ -73,7 +73,7 @@ export default struct InComDialog {
}
.margin({ top: 8, bottom: 16 })
.onClick(() => {
- HiLog.i(TAG, "onClick");
+ LogUtils.i(TAG, "onClick");
this.controller.close();
})
}
diff --git a/callui/src/main/ets/default/common/components/IncomingCom.ets b/entry/src/main/ets/common/components/IncomingCom.ets
similarity index 92%
rename from callui/src/main/ets/default/common/components/IncomingCom.ets
rename to entry/src/main/ets/common/components/IncomingCom.ets
index 8d72004..b9b9fe6 100644
--- a/callui/src/main/ets/default/common/components/IncomingCom.ets
+++ b/entry/src/main/ets/common/components/IncomingCom.ets
@@ -21,7 +21,7 @@ import CallServiceProxy from '../../model/CallServiceProxy';
import sms from '@ohos.telephony.sms';
import resourceManager from '@ohos.resourceManager';
import prompt from '@system.prompt';
-import HiLog from '../utils/Hilog';
+import LogUtils from '../utils/LogUtils';
const TAG = "IncomingCom";
const SMS_REJECTION = `${ImagePathConst.BASE_URL}ic_public_message.svg`;
@@ -51,10 +51,10 @@ const SEND_SMS_FAILURE_SERVICE_UNAVAILABLE = 3;
export default struct IncomingCom {
@State SendResult: any = {};
@Link callData: any;
- private btnList= [];
+ private btnList = [];
private msgList = [];
- private remindList= [];
- mCallServiceProxy: CallServiceProxy= null;
+ private remindList = [];
+ mCallServiceProxy: CallServiceProxy = null;
msgDialogController: CustomDialogController = new CustomDialogController
({
builder: InComDialog({
@@ -74,7 +74,7 @@ export default struct IncomingCom {
alignment: (globalThis.deviceTypeInfo === "phone" || globalThis.deviceTypeInfo === "default") ? DialogAlignment.Bottom : DialogAlignment.Default
});
- private aboutToAppear(): void {
+ aboutToAppear() {
this.mCallServiceProxy = CallServiceProxy.getInstance();
this.getMsgList();
this.getBtnList();
@@ -92,7 +92,7 @@ export default struct IncomingCom {
resourceManager.getResourceManager().then(result => {
result.getString(obj.msg.id, (err, typeName) => {
content = typeName
- HiLog.i(TAG, "sendMessage resourceManager.getResourceManager :");
+ LogUtils.i(TAG, "sendMessage resourceManager.getResourceManager :");
return new Promise(function (resolve, reject) {
sms.sendMessage({
slotId: slotId,
@@ -164,14 +164,14 @@ export default struct IncomingCom {
if (this.SendResult) {
resourceManager.getResourceManager().then(result => {
result.getString($r("app.string.SMS_Sent")
- .id, (err, typeName) => {
+ .id, (err, typeName) => {
Content = typeName
prompt.showToast({
message: this.callData.contactName ? Content + `${this.callData.contactName}` : Content + `${this.callData.accountNumber}`,
duration: 2000,
});
this.mCallServiceProxy.rejectCall(this.callData.callId, obj.msg);
- HiLog.i(TAG, "msgItemClick :");
+ LogUtils.i(TAG, "msgItemClick :");
})
})
} else {
@@ -194,10 +194,10 @@ export default struct IncomingCom {
const {callId, callState} = this.callData;
if (callState !== CallStateConst.CALL_STATUS_WAITING) {
this.mCallServiceProxy.rejectCall(callId);
- HiLog.i(TAG, "onReject this.mCallServiceProxy.rejectCall :");
+ LogUtils.i(TAG, "onReject this.mCallServiceProxy.rejectCall :");
} else {
this.mCallServiceProxy.hangUpCall(callId);
- HiLog.i(TAG, "onReject this.mCallServiceProxy.hangUpCall :");
+ LogUtils.i(TAG, "onReject this.mCallServiceProxy.hangUpCall :");
}
}
@@ -205,7 +205,7 @@ export default struct IncomingCom {
* Enable the SMS reply pop-up
*/
private btnClick(type) {
- HiLog.i(TAG, "btnClick : %s" + JSON.stringify(type));
+ LogUtils.i(TAG, "btnClick : %s" + JSON.stringify(type));
if (type === 'msg') {
this.msgDialogController.open();
}
@@ -215,7 +215,7 @@ export default struct IncomingCom {
* Answer the phone interface
*/
private onAnswer() {
- HiLog.i(TAG, "onAnswer :");
+ LogUtils.i(TAG, "onAnswer :");
this.mCallServiceProxy.acceptCall(this.callData.callId);
}
diff --git a/callui/src/main/ets/default/common/components/Keyboard.ets b/entry/src/main/ets/common/components/Keyboard.ets
similarity index 100%
rename from callui/src/main/ets/default/common/components/Keyboard.ets
rename to entry/src/main/ets/common/components/Keyboard.ets
diff --git a/callui/src/main/ets/default/common/components/callList.ets b/entry/src/main/ets/common/components/callList.ets
similarity index 95%
rename from callui/src/main/ets/default/common/components/callList.ets
rename to entry/src/main/ets/common/components/callList.ets
index 4309eec..e2ffee5 100644
--- a/callui/src/main/ets/default/common/components/callList.ets
+++ b/entry/src/main/ets/common/components/callList.ets
@@ -20,7 +20,7 @@
import CallStateConst from '../constant/CallStateConst';
import CallServiceProxy from '../../model/CallServiceProxy';
import app from '@system.app';
-import HiLog from '../utils/Hilog';
+import LogUtils from '../utils/LogUtils';
const TAG = "CallList";
const font_color = "rgba(255, 255, 255, 0.60)";
@@ -36,7 +36,7 @@ export default struct callList {
private mCallServiceProxy: CallServiceProxy;
public aboutToAppear(): void {
- HiLog.i(TAG, "aboutToAppear");
+ LogUtils.i(TAG, "aboutToAppear");
this.mCallStateConst = new CallStateConst();
this.mCallServiceProxy = CallServiceProxy.getInstance();
}
@@ -88,7 +88,9 @@ export default struct callList {
public onHangUp(callId) {
this.mCallServiceProxy.hangUpCall(callId);
if (this.callList.length === 1) {
- app.terminate();
+ globalThis.calluiAbilityContext.terminateSelf().then((data) => {
+ LogUtils.i(TAG, "onHangUp terminateSelfCallBack");
+ });
}
}
diff --git a/callui/src/main/ets/default/common/configs/BtnGroupConfig.ets b/entry/src/main/ets/common/configs/BtnGroupConfig.ets
similarity index 100%
rename from callui/src/main/ets/default/common/configs/BtnGroupConfig.ets
rename to entry/src/main/ets/common/configs/BtnGroupConfig.ets
diff --git a/callui/src/main/ets/default/common/constant/CallModeConst.ets b/entry/src/main/ets/common/constant/CallModeConst.ets
similarity index 100%
rename from callui/src/main/ets/default/common/constant/CallModeConst.ets
rename to entry/src/main/ets/common/constant/CallModeConst.ets
diff --git a/callui/src/main/ets/default/common/constant/CallStateConst.ets b/entry/src/main/ets/common/constant/CallStateConst.ets
similarity index 100%
rename from callui/src/main/ets/default/common/constant/CallStateConst.ets
rename to entry/src/main/ets/common/constant/CallStateConst.ets
diff --git a/callui/src/main/ets/default/common/constant/CallTypeConst.ets b/entry/src/main/ets/common/constant/CallTypeConst.ets
similarity index 100%
rename from callui/src/main/ets/default/common/constant/CallTypeConst.ets
rename to entry/src/main/ets/common/constant/CallTypeConst.ets
diff --git a/callui/src/main/ets/default/common/constant/ConferenceConst.ets b/entry/src/main/ets/common/constant/ConferenceConst.ets
similarity index 100%
rename from callui/src/main/ets/default/common/constant/ConferenceConst.ets
rename to entry/src/main/ets/common/constant/ConferenceConst.ets
diff --git a/callui/src/main/ets/default/common/constant/ImagePathConst.ets b/entry/src/main/ets/common/constant/ImagePathConst.ets
similarity index 100%
rename from callui/src/main/ets/default/common/constant/ImagePathConst.ets
rename to entry/src/main/ets/common/constant/ImagePathConst.ets
diff --git a/callui/src/main/ets/default/common/constant/SimStateConst.ets b/entry/src/main/ets/common/constant/SimStateConst.ets
similarity index 100%
rename from callui/src/main/ets/default/common/constant/SimStateConst.ets
rename to entry/src/main/ets/common/constant/SimStateConst.ets
diff --git a/callui/src/main/ets/default/common/utils/Clone.ets b/entry/src/main/ets/common/utils/Clone.ets
similarity index 99%
rename from callui/src/main/ets/default/common/utils/Clone.ets
rename to entry/src/main/ets/common/utils/Clone.ets
index 223e29b..3414094 100644
--- a/callui/src/main/ets/default/common/utils/Clone.ets
+++ b/entry/src/main/ets/common/utils/Clone.ets
@@ -36,7 +36,7 @@ const deepType = [mapType, setType, arrayType, objectType, argsType];
export default class Getclone {
private static getclone: Getclone = new Getclone();
- public static getInstance(): Getclone{
+ public static getInstance(): Getclone {
return this.getclone;
}
diff --git a/callui/src/main/ets/default/common/utils/HiLog.ets b/entry/src/main/ets/common/utils/LogUtils.ts
similarity index 50%
rename from callui/src/main/ets/default/common/utils/HiLog.ets
rename to entry/src/main/ets/common/utils/LogUtils.ts
index 2661b3c..8f83798 100644
--- a/callui/src/main/ets/default/common/utils/HiLog.ets
+++ b/entry/src/main/ets/common/utils/LogUtils.ts
@@ -24,36 +24,29 @@
* 5. the function execute many times can not print.
* 6. uniqueness.
*/
-export default class HiLog {
- private static readonly IS_DEBUG_ON: boolean = false;
- private static readonly CALLUI: string = "callui";
- private static readonly SLASH: string = "/";
- private static readonly COLON: string = ": ";
- constructor() {
- }
- private static prefix(tag: string) {
- return this.CALLUI + this.SLASH + tag + this.COLON;
- }
-
- static d(tag: string, msg: string, ...args: any[]) {
- if (this.IS_DEBUG_ON) {
- console.info(this.prefix(tag) + msg, args);
- } else {
- console.debug(this.prefix(tag) + msg, args);
+/**
+ * log package tool class
+ */
+export class LogUtils {
+ d(TAG, msg): void {
+ console.debug("[callui:]" + TAG + ":" + msg);
}
- }
- static i(tag: string, msg: string, ...args: any[]) {
- console.info(this.prefix(tag) + msg, args);
- }
+ i(TAG, msg): void {
+ console.info("[callui:]" + TAG + ":" + msg);
+ }
- static w(tag: string, msg: string, ...args: any[]) {
- console.warn(this.prefix(tag) + msg, args);
- }
+ w(TAG, msg): void {
+ console.warn("[callui:]" + TAG + ":" + msg);
+ }
- static e(tag: string, msg: string, ...args: any[]) {
- console.error(this.prefix(tag) + msg, args);
- }
+ e(TAG, msg): void {
+ console.error("[callui:]" + TAG + ":" + msg);
+ }
}
+let mLogUtil = new LogUtils();
+
+export default mLogUtil as LogUtils;
+
diff --git a/callui/src/main/ets/default/common/utils/Method.ets b/entry/src/main/ets/common/utils/Method.ets
similarity index 100%
rename from callui/src/main/ets/default/common/utils/Method.ets
rename to entry/src/main/ets/common/utils/Method.ets
diff --git a/callui/src/main/ets/default/common/utils/Storage.ets b/entry/src/main/ets/common/utils/Storage.ets
similarity index 100%
rename from callui/src/main/ets/default/common/utils/Storage.ets
rename to entry/src/main/ets/common/utils/Storage.ets
diff --git a/callui/src/main/ets/default/common/utils/utils.ets b/entry/src/main/ets/common/utils/utils.ets
similarity index 100%
rename from callui/src/main/ets/default/common/utils/utils.ets
rename to entry/src/main/ets/common/utils/utils.ets
diff --git a/callui/src/main/ets/default/model/CallDataManager.ets b/entry/src/main/ets/model/CallDataManager.ets
similarity index 86%
rename from callui/src/main/ets/default/model/CallDataManager.ets
rename to entry/src/main/ets/model/CallDataManager.ets
index 5d534d2..d396cc7 100644
--- a/callui/src/main/ets/default/model/CallDataManager.ets
+++ b/entry/src/main/ets/model/CallDataManager.ets
@@ -18,9 +18,8 @@
*/
import CallStateManager from './CallStateManager';
import CallStateConst from '../common/constant/CallStateConst';
-import app from '@system.app';
import NotificationManager from '../model/NotificationManager';
-import HiLog from '../common/utils/Hilog';
+import LogUtils from '../common/utils/LogUtils';
const TAG = "CallDataManager";
@@ -28,7 +27,7 @@ const TAG = "CallDataManager";
* class CallDataManager
*/
export default class CallDataManager {
- callData: any= {};
+ callData: any = {};
callList: any = [];
callTimeList: any = [];
private callStateChange: any;
@@ -47,17 +46,22 @@ export default class CallDataManager {
/**
* update callList and callData callTimeList
+ *`
*
* @param { object } callData
*/
public update(callData) {
const { callState, callId } = callData;
const targetObj = this.callList.find((v) => v.callId === callId);
- HiLog.i(TAG, "update :")
+ LogUtils.i(TAG, "update :")
if (targetObj) {
+ const { oldCallState } = targetObj;
Object.assign(targetObj, {
...callData
});
+ if (oldCallState != callState) {
+ AppStorage.Get('notificationManager').sendCapsuleNotification(callData, globalThis.appInactiveState);
+ }
} else {
this.addCallList({
...callData
@@ -80,7 +84,10 @@ export default class CallDataManager {
if (this.callList.length === 1) {
this.NotificationManager.cancelNotification();
AppStorage.Get('notificationManager').sendCapsuleNotification(callData, true);
- app.terminate();
+ AppStorage.Delete("CallTimeList");
+ globalThis.calluiAbilityContext.terminateSelf().then((data) => {
+ LogUtils.i(TAG, "calluiAbility terminateSelf");
+ });
} else {
this.removeCallById(callId);
const activeCallData = this.callList.find((v) => v.callState === CallStateConst.CALL_STATUS_ACTIVE);
@@ -124,7 +131,7 @@ export default class CallDataManager {
*/
updateCallTimeList(callData) {
const CallTimeObj = this.callTimeList.find((v) => v.callId === callData.callId);
- HiLog.i(TAG, "updateCallTimeList : %s" + JSON.stringify(CallTimeObj))
+ LogUtils.i(TAG, "updateCallTimeList : " + JSON.stringify(CallTimeObj))
if (!CallTimeObj && callData.callState === CallStateConst.CALL_STATUS_ACTIVE) {
const obj = {
callId: callData.callId,
@@ -134,7 +141,7 @@ export default class CallDataManager {
};
this.callTimeList.push(obj);
AppStorage.SetOrCreate("CallTimeList", this.callTimeList)
- HiLog.i(TAG, "updateCallTimeList : %s" + JSON.stringify(this.callTimeList))
+ LogUtils.i(TAG, "updateCallTimeList : " + JSON.stringify(this.callTimeList))
}
}
}
\ No newline at end of file
diff --git a/callui/src/main/ets/default/model/CallManager.ets b/entry/src/main/ets/model/CallManager.ets
similarity index 82%
rename from callui/src/main/ets/default/model/CallManager.ets
rename to entry/src/main/ets/model/CallManager.ets
index 5b3555a..6303881 100644
--- a/callui/src/main/ets/default/model/CallManager.ets
+++ b/entry/src/main/ets/model/CallManager.ets
@@ -19,10 +19,9 @@
import CallDataManager from './CallDataManager';
import Utils from '../common/utils/utils';
import commonEvent from '@ohos.commonEvent';
-import featureAbility from '@ohos.ability.featureAbility';
import CallServiceProxy from './CallServiceProxy';
import ContactManager from './ContactManager';
-import HiLog from '../common/utils/Hilog';
+import LogUtils from '../common/utils/LogUtils'
import call from '@ohos.telephony.call';
import CallStateConst from '../common/constant/CallStateConst';
@@ -66,20 +65,15 @@ export default class CallManager {
* init CallData
*/
private initCallData() {
- featureAbility.getWant().then((want) => {
- if (want && want.parameters && ('callState' in want.parameters)) {
- this.update(want.parameters);
- HiLog.i(TAG, "initCallData featureAbility.getWant :")
- } else {
- this.mCallServiceProxy.publish({
- key: 'getInitCallData',
- params: []
- });
- }
- })
- .catch((error) => {
- HiLog.i(TAG, "initCallData catch error : %s" + JSON.stringify(error))
+ if (globalThis.abilityWant && globalThis.abilityWant.parameters && ('callState' in globalThis.abilityWant.parameters)) {
+ this.update(globalThis.abilityWant.parameters);
+ LogUtils.i(TAG, "initCallData featureAbility.getWant :")
+ } else {
+ this.mCallServiceProxy.publish({
+ key: 'getInitCallData',
+ params: []
});
+ }
}
/*
@@ -99,13 +93,13 @@ export default class CallManager {
commonEvent.subscribe(subscriber, (err, res) => {
if (err.code === 0) {
const callData = JSON.parse(res.data);
- HiLog.i(TAG, "commonEvent subscribe : %s" + JSON.stringify(subscriber))
+ LogUtils.i(TAG, "commonEvent subscribe : %s" + JSON.stringify(subscriber))
if (callData) {
this.callData = callData
this.update(callData);
}
} else {
- HiLog.i(TAG, "commonEvent.subscribe err : %s" + JSON.stringify(err))
+ LogUtils.i(TAG, "commonEvent.subscribe err : %s" + JSON.stringify(err))
}
});
}
@@ -116,7 +110,7 @@ export default class CallManager {
private unsubscribe() {
commonEvent.unsubscribe(subscriber, (err) => {
if (err.code !== 0) {
- HiLog.i(TAG, "commonEvent.unsubscribe err: %s" + JSON.stringify(err))
+ LogUtils.i(TAG, "commonEvent.unsubscribe err: %s" + JSON.stringify(err))
}
});
}
@@ -137,7 +131,7 @@ export default class CallManager {
}
});
this.isEmergencyPhoneNumber(callData.accountNumber)
- HiLog.i(TAG, "update :")
+ LogUtils.i(TAG, "update :")
}
/**
@@ -148,13 +142,15 @@ export default class CallManager {
* @return { boolean } - return success true fail false
*/
private isEmergencyPhoneNumber = (phoneNumber) => new Promise((resolve, reject) => {
- call.isEmergencyPhoneNumber(phoneNumber, {slotId: 0}).then((res) => {
+ call.isEmergencyPhoneNumber(phoneNumber, {
+ slotId: 0
+ }).then((res) => {
resolve(res);
AppStorage.SetOrCreate("IsEmergencyPhoneNumber", res)
- HiLog.i(TAG, "then:isEmergencyPhoneNumber : %s" + JSON.stringify(res))
+ LogUtils.i(TAG, "then:isEmergencyPhoneNumber : %s" + JSON.stringify(res))
}).catch((err) => {
reject(err);
- HiLog.i(TAG, "catch:isEmergencyPhoneNumber : %s" + JSON.stringify(err))
+ LogUtils.i(TAG, "catch:isEmergencyPhoneNumber : %s" + JSON.stringify(err))
});
});
diff --git a/callui/src/main/ets/default/model/CallServiceProxy.ets b/entry/src/main/ets/model/CallServiceProxy.ets
similarity index 69%
rename from callui/src/main/ets/default/model/CallServiceProxy.ets
rename to entry/src/main/ets/model/CallServiceProxy.ets
index 80d3431..9819758 100644
--- a/callui/src/main/ets/default/model/CallServiceProxy.ets
+++ b/entry/src/main/ets/model/CallServiceProxy.ets
@@ -26,7 +26,7 @@
import commonEvent from '@ohos.commonEvent';
import call from '@ohos.telephony.call';
import app from '@system.app';
-import HiLog from '../common/utils/Hilog';
+import LogUtils from '../common/utils/LogUtils';
const TAG = "CallServiceProxy";
const prefixLog = 'callUI app:@ohos.telephony.call:';
@@ -46,7 +46,7 @@ export default class CallServiceProxy {
* Make a phone call
*/
public dialCall(phoneNumber, accountId = 0, videoState = 0, dialScene = 0) {
- HiLog.i(TAG, "dialCall phoneNumber :")
+ LogUtils.i(TAG, "dialCall phoneNumber :")
return call.dial(phoneNumber, {
accountId,
videoState,
@@ -68,9 +68,9 @@ export default class CallServiceProxy {
*/
public acceptCall = function (callId) {
call.answer(callId).then((res) => {
- HiLog.i(TAG, prefixLog + "call.answer : %s" + JSON.stringify(callId))
+ LogUtils.i(TAG, prefixLog + "call.answer : %s" + JSON.stringify(callId))
}).catch((err) => {
- HiLog.i(TAG, prefixLog + "call.answer catch : %s" + JSON.stringify(err))
+ LogUtils.i(TAG, prefixLog + "call.answer catch : %s" + JSON.stringify(err))
});
};
@@ -86,10 +86,10 @@ export default class CallServiceProxy {
public rejectCall = function (callId, isSendSms = false, msg = '') {
const rejectCallPromise = isSendSms ? call.reject(callId, {messageContent: msg}) : call.reject(callId);
rejectCallPromise.then((res) => {
- HiLog.i(TAG,prefixLog + "then:rejectCall")
+ LogUtils.i(TAG,prefixLog + "then:rejectCall")
})
.catch((err) => {
- HiLog.i(TAG, prefixLog + "catch:rejectCall : %s" + JSON.stringify(err))
+ LogUtils.i(TAG, prefixLog + "catch:rejectCall : %s" + JSON.stringify(err))
});
};
@@ -103,10 +103,10 @@ export default class CallServiceProxy {
public hangUpCall = (callId) => new Promise((resolve, reject) => {
call.hangup(callId).then((res) => {
resolve(res);
- HiLog.i(TAG, prefixLog + "then:hangUpCall : %s" + JSON.stringify(callId))
+ LogUtils.i(TAG, prefixLog + "then:hangUpCall : %s" + JSON.stringify(callId))
}).catch((err) => {
reject(err);
- HiLog.i(TAG, prefixLog + "catch:hangUpCall : %s" + JSON.stringify(err))
+ LogUtils.i(TAG, prefixLog + "catch:hangUpCall : %s" + JSON.stringify(err))
});
});
@@ -120,11 +120,11 @@ export default class CallServiceProxy {
public holdCall = (callId) => new Promise((resolve, reject) => {
call.holdCall(callId).then((res) => {
resolve(res);
- HiLog.i(TAG, prefixLog + "then:holdCall : %s" + JSON.stringify(callId))
+ LogUtils.i(TAG, prefixLog + "then:holdCall : %s" + JSON.stringify(callId))
})
.catch((err) => {
reject(err);
- HiLog.i(TAG, prefixLog + "catch:holdCall : %s" + JSON.stringify(err))
+ LogUtils.i(TAG, prefixLog + "catch:holdCall : %s" + JSON.stringify(err))
});
});
@@ -138,11 +138,11 @@ export default class CallServiceProxy {
public unHoldCall = (callId) => new Promise((resolve, reject) => {
call.unHoldCall(callId).then((res) => {
resolve(res);
- HiLog.i(TAG, prefixLog + "then:unholdCall : %s" + JSON.stringify(callId))
+ LogUtils.i(TAG, prefixLog + "then:unholdCall : %s" + JSON.stringify(callId))
})
.catch((err) => {
reject(err);
- HiLog.i(TAG, prefixLog + "catch:unHoldCall : %s" + JSON.stringify(err))
+ LogUtils.i(TAG, prefixLog + "catch:unHoldCall : %s" + JSON.stringify(err))
});
});
@@ -156,11 +156,11 @@ export default class CallServiceProxy {
*/
public setAudioDevice = (device = 1) => new Promise((resolve, reject) => {
call.setAudioDevice(device).then((res) => {
- HiLog.i(TAG, prefixLog + "then:setAudioDevice : %s" + JSON.stringify(device))
+ LogUtils.i(TAG, prefixLog + "then:setAudioDevice : %s" + JSON.stringify(device))
resolve(res);
}).catch((err) => {
reject(err);
- HiLog.i(TAG, prefixLog + "catch:setAudioDevice : %s" + JSON.stringify(err))
+ LogUtils.i(TAG, prefixLog + "catch:setAudioDevice : %s" + JSON.stringify(err))
});
});
@@ -169,9 +169,9 @@ export default class CallServiceProxy {
*/
public setMuted() {
call.setMuted().then((res) => {
- HiLog.i(TAG, prefixLog + "then:setMute")
+ LogUtils.i(TAG, prefixLog + "then:setMute")
}).catch((err) => {
- HiLog.i(TAG,prefixLog + "catch:setMute : %s" + JSON.stringify(err))
+ LogUtils.i(TAG,prefixLog + "catch:setMute : %s" + JSON.stringify(err))
});
};
@@ -180,9 +180,9 @@ export default class CallServiceProxy {
*/
public cancelMuted() {
call.cancelMuted().then((res) => {
- HiLog.i(TAG,prefixLog + "then:cancelMuted")
+ LogUtils.i(TAG,prefixLog + "then:cancelMuted")
}).catch((err) => {
- HiLog.i(TAG, prefixLog + "catch:cancelMuted : %s" + JSON.stringify(err))
+ LogUtils.i(TAG, prefixLog + "catch:cancelMuted : %s" + JSON.stringify(err))
});
};
@@ -196,11 +196,11 @@ export default class CallServiceProxy {
public switchCall = (callId) => new Promise((resolve, reject) => {
call.switchCall(callId).then((res) => {
resolve(res);
- HiLog.i(TAG, prefixLog + "then:switchCall : %s" + JSON.stringify(callId))
+ LogUtils.i(TAG, prefixLog + "then:switchCall : %s" + JSON.stringify(callId))
})
.catch((err) => {
reject(err);
- HiLog.i(TAG, prefixLog + "catch:switchCall : %s" + JSON.stringify(err))
+ LogUtils.i(TAG, prefixLog + "catch:switchCall : %s" + JSON.stringify(err))
});
});
@@ -212,10 +212,10 @@ export default class CallServiceProxy {
public registerCallStateCallback(callBack) {
call.on('callDetailsChange', (data) => {
if (!data) {
- HiLog.i(TAG, prefixLog + "call.on registerCallStateCallback")
+ LogUtils.i(TAG, prefixLog + "call.on registerCallStateCallback")
return;
}
- HiLog.i(TAG, prefixLog + "call.on registerCallStateCallback callState")
+ LogUtils.i(TAG, prefixLog + "call.on registerCallStateCallback callState")
callBack(data);
});
}
@@ -226,10 +226,10 @@ export default class CallServiceProxy {
public unRegisterCallStateCallback() {
call.off('callDetailsChange', (data) => {
if (!data) {
- HiLog.i(TAG, prefixLog + "call.off unRegisterCallStateCallback")
+ LogUtils.i(TAG, prefixLog + "call.off unRegisterCallStateCallback")
return;
}
- HiLog.i(TAG, prefixLog + "call.off unRegisterCallStateCallback")
+ LogUtils.i(TAG, prefixLog + "call.off unRegisterCallStateCallback")
});
}
@@ -239,9 +239,9 @@ export default class CallServiceProxy {
public registerCallEventCallback() {
call.on('callEventChange', (data) => {
if (!data) {
- HiLog.i(TAG, prefixLog + "call.on callEventChange")
+ LogUtils.i(TAG, prefixLog + "call.on callEventChange")
} else {
- HiLog.i(TAG, prefixLog + "call.on callEventChange")
+ LogUtils.i(TAG, prefixLog + "call.on callEventChange")
}
});
}
@@ -252,9 +252,9 @@ export default class CallServiceProxy {
public unRegisterCallEventCallback() {
call.off('callEventChange', (data) => {
if (!data) {
- HiLog.i(TAG,prefixLog + "call.off unRegisterCallEventCallback : %s")
+ LogUtils.i(TAG,prefixLog + "call.off unRegisterCallEventCallback : %s")
} else {
- HiLog.i(TAG,prefixLog + "call.off unRegisterCallEventCallback : %s")
+ LogUtils.i(TAG,prefixLog + "call.off unRegisterCallEventCallback : %s")
}
});
}
@@ -268,9 +268,9 @@ export default class CallServiceProxy {
*/
public startDTMF = (callId, str) => {
call.startDTMF(callId, str).then((res) => {
- HiLog.i(TAG, prefixLog + "then:startDtmf : %s" + JSON.stringify(callId) + JSON.stringify(str))
+ LogUtils.i(TAG, prefixLog + "then:startDtmf : %s" + JSON.stringify(callId) + JSON.stringify(str))
}).catch((err) => {
- HiLog.i(TAG, prefixLog + "catch:startDtmf : %s" + JSON.stringify(err))
+ LogUtils.i(TAG, prefixLog + "catch:startDtmf : %s" + JSON.stringify(err))
});
};
@@ -281,9 +281,9 @@ export default class CallServiceProxy {
*/
public stopDTMF = (callId) => {
call.stopDTMF(callId).then((res) => {
- HiLog.i(TAG, prefixLog + "then:stopDtmf : %s" + JSON.stringify(callId))
+ LogUtils.i(TAG, prefixLog + "then:stopDtmf : %s" + JSON.stringify(callId))
}).catch((err) => {
- HiLog.i(TAG, prefixLog + "then:startDtmf : %s" + JSON.stringify(err))
+ LogUtils.i(TAG, prefixLog + "then:startDtmf : %s" + JSON.stringify(err))
});
};
@@ -294,22 +294,22 @@ export default class CallServiceProxy {
*/
public combineConference = (callId) => {
call.combineConference(callId).then((res) => {
- HiLog.i(TAG, prefixLog + "then:combineConference : %s" + JSON.stringify(callId))
+ LogUtils.i(TAG, prefixLog + "then:combineConference : %s" + JSON.stringify(callId))
}).catch((err) => {
- HiLog.i(TAG, prefixLog + "catch:combineConference : %s" + JSON.stringify(err))
+ LogUtils.i(TAG, prefixLog + "catch:combineConference : %s" + JSON.stringify(err))
});
};
public publish(data) {
- HiLog.i(TAG, prefixLog + "callui.event.callEvent publish")
+ LogUtils.i(TAG, prefixLog + "callui.event.callEvent publish")
commonEvent.publish('callui.event.callEvent', {
bundleName: 'com.ohos.callui',
isOrdered: false,
data: JSON.stringify(data)
}, (res) => {
- HiLog.i(TAG, prefixLog + "callui.event.callEvent success")
+ LogUtils.i(TAG, prefixLog + "callui.event.callEvent success")
});
- HiLog.i(TAG, prefixLog + "callui.event.callEvent publish end")
+ LogUtils.i(TAG, prefixLog + "callui.event.callEvent publish end")
}
}
diff --git a/callui/src/main/ets/default/model/CallStateManager.ets b/entry/src/main/ets/model/CallStateManager.ets
similarity index 95%
rename from callui/src/main/ets/default/model/CallStateManager.ets
rename to entry/src/main/ets/model/CallStateManager.ets
index 564cea3..33bf005 100644
--- a/callui/src/main/ets/default/model/CallStateManager.ets
+++ b/entry/src/main/ets/model/CallStateManager.ets
@@ -33,7 +33,7 @@ export default class CallStateManager {
*
* @param { Object } data - callData
*/
- public static getInstance():CallStateManager{
+ public static getInstance(): CallStateManager {
return CallStateManager.sCallStateManager;
}
diff --git a/entry/src/main/ets/model/ContactManager.ts b/entry/src/main/ets/model/ContactManager.ts
new file mode 100644
index 0000000..d81508b
--- /dev/null
+++ b/entry/src/main/ets/model/ContactManager.ts
@@ -0,0 +1,55 @@
+/**
+ * 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.
+ */
+
+/**
+ * @file: Contact management
+ */
+import featureAbility from '@ohos.ability.featureAbility';
+import dataAbility from '@ohos.data.dataAbility';
+import LogUtils from '../common/utils/LogUtils';
+
+const TAG = "ContactManager";
+const DBbaseUri = 'dataability:///com.ohos.contactsdataability';
+const DBUri = DBbaseUri + '/contacts/contact_data';
+
+/**
+ * class ContactManager
+ */
+export default class ContactManager {
+
+ /**
+ * get contact info
+ *
+ * @param { Object } callData -Object
+ */
+ async getContactInfo(callData) {
+ try {
+ const columns = ['id', 'display_name', 'detail_info'];
+ const predicates = new dataAbility.DataAbilityPredicates();
+ predicates.equalTo('detail_info', callData.accountNumber);
+ predicates.equalTo('is_deleted', 0);
+ const dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(globalThis.calluiAbilityContext, DBbaseUri);
+ const resSet = await dataAbilityHelper.query(DBUri, columns, predicates);
+ LogUtils.i(TAG, "getContactInfo resSet : " + JSON.stringify(resSet))
+ if (resSet.rowCount > 0) {
+ resSet.goToFirstRow();
+ callData.contactName = resSet.getString(resSet.getColumnIndex('display_name'));
+ LogUtils.i(TAG, "getContactInfo callData.contactName:" + callData.contactName);
+ }
+ } catch (err) {
+ LogUtils.i(TAG, "getContactInfo catch err : %s" + JSON.stringify(err))
+ }
+ }
+}
\ No newline at end of file
diff --git a/callui/src/main/ets/default/model/NotificationManager.ets b/entry/src/main/ets/model/NotificationManager.ets
similarity index 66%
rename from callui/src/main/ets/default/model/NotificationManager.ets
rename to entry/src/main/ets/model/NotificationManager.ets
index 119e564..662f32f 100644
--- a/callui/src/main/ets/default/model/NotificationManager.ets
+++ b/entry/src/main/ets/model/NotificationManager.ets
@@ -21,7 +21,7 @@ import wantAgent from '@ohos.wantAgent';
import notification from '@ohos.notification';
import commonEvent from '@ohos.commonEvent';
import callStateConst from '../common/constant/CallStateConst';
-import HiLog from '../common/utils/Hilog';
+import LogUtils from '../common/utils/LogUtils';
import resourceManager from '@ohos.resourceManager';
const TAG = "NotificationManager";
@@ -79,28 +79,29 @@ export default class NotificationManager {
callId, btnType: key
};
const wantAgentObj = await this.getWantAgent(data, SEND_COMMON_EVENT);
- resourceManager.getResourceManager((error, mgr) => {
+ globalThis.calluiAbilityContext.resourceManager.getString(textMap[key].id, (error, value) => {
if (error != null) {
- return;
+ LogUtils.i(TAG, "sendNotification getResourceManager getString err")
+ } else {
+ LogUtils.i(TAG, "sendNotification getResourceManager getString value" + value)
+ notificationRequest.actionButtons.push({
+ title: value,
+ wantAgent: wantAgentObj
+ });
+ Object.assign(notificationRequest.content.longText, {
+ title: text,
+ expandedTitle: text
+ });
+ notification.publish(notificationRequest).then((data) => {
+ LogUtils.i(TAG, "sendNotification publish success")
+ }).catch((err) => {
+ LogUtils.i(TAG, "sendNotification public err" + JSON.stringify(err))
+ });
}
- mgr.getString(textMap[key].id, (error, value) => {
- if (error != null) {
- } else {
- notificationRequest.actionButtons.push({
- title: value,
- wantAgent: wantAgentObj
- });
- Object.assign(notificationRequest.content.longText, {
- title: text,
- expandedTitle: text
- });
- notification.publish(notificationRequest);
- }
- });
});
}
}
- HiLog.i(TAG, "sendNotification end :")
+ LogUtils.i(TAG, "sendNotification end :")
}
/**
@@ -108,22 +109,22 @@ export default class NotificationManager {
* @param callState
*/
getMapObj(callState) {
- if (callState===callStateConst.CALL_STATUS_INCOMING) {
+ if (callState === callStateConst.CALL_STATUS_INCOMING) {
return ['answer', 'reject']
}
- if (callState===callStateConst.CALL_STATUS_ACTIVE) {
+ if (callState === callStateConst.CALL_STATUS_ACTIVE) {
return ['hangUp']
}
- if (callState===callStateConst.CALL_STATUS_HOLDING) {
+ if (callState === callStateConst.CALL_STATUS_HOLDING) {
return ['hangUp']
}
- if (callState===callStateConst.CALL_STATUS_ALERTING) {
+ if (callState === callStateConst.CALL_STATUS_ALERTING) {
return ['hangUp']
}
- if (callState===callStateConst.CALL_STATUS_DIALING) {
+ if (callState === callStateConst.CALL_STATUS_DIALING) {
return ['hangUp']
}
- if (callState===callStateConst.CALL_STATUS_WAITING) {
+ if (callState === callStateConst.CALL_STATUS_WAITING) {
return ['answer', 'reject']
}
}
@@ -157,11 +158,11 @@ export default class NotificationManager {
* Cancel notice
*/
cancelNotification() {
- HiLog.i(TAG, "cancelNotification")
+ LogUtils.i(TAG, "cancelNotification")
notification.cancel(ID).then((res) => {
- HiLog.i(TAG, "notify.cancel res data : %s" + JSON.stringify(res))
+ LogUtils.i(TAG, "notify.cancel res data : %s" + JSON.stringify(res))
}).catch((err) => {
- HiLog.i(TAG, "notify.cancel err data : %s" + JSON.stringify(err))
+ LogUtils.i(TAG, "notify.cancel err data : %s" + JSON.stringify(err))
});
}
@@ -173,22 +174,28 @@ export default class NotificationManager {
* @param {boolean} isBackground - is background
*/
sendCapsuleNotification(callData, isBackground) {
- HiLog.i(TAG, "sendCapsuleNotification isBackground : %s" + JSON.stringify(isBackground))
+ LogUtils.i(TAG, "sendCapsuleNotification isBackground : " + JSON.stringify(isBackground))
callData.startTime = (callData.startTime)
- HiLog.i(TAG, "sendCapsuleNotification callData.startTime :")
+ LogUtils.i(TAG, "sendCapsuleNotification callData.startTime :")
const {callState, startTime} = callData;
- commonEvent.publish('CAPSULE_EVENT_CALL_UI', {
- bundleName: 'com.ohos.callui',
+ let commonEventPublishData = {
+ bundleName: 'com.ohos.systemui',
isOrdered: false,
data: JSON.stringify({
callState,
- startTime: startTime*1000,
+ startTime: startTime * 1000,
isBackground,
wantBundleName: CALL_BUNDLE_NAME,
wantAbilityName: CALL_ABILITY_NAME
})
- }, (res) => {
- HiLog.i(TAG, "callUI app commonEvent.publish CAPSULE_EVENT_CALL_UI callback res : %s" + JSON.stringify(res))
- });
+ }
+
+ commonEvent.publish('CAPSULE_EVENT_CALL_UI', commonEventPublishData, (err, data) => {
+ if (err) {
+ LogUtils.i(TAG, "sendCapsuleNotification publish launcher err:" + JSON.stringify(err))
+ } else {
+ LogUtils.i(TAG, "sendCapsuleNotification publish launcher success:" + JSON.stringify(data))
+ }
+ })
}
}
\ No newline at end of file
diff --git a/callui/src/main/ets/default/pages/index.ets b/entry/src/main/ets/pages/index.ets
similarity index 72%
rename from callui/src/main/ets/default/pages/index.ets
rename to entry/src/main/ets/pages/index.ets
index 097bb43..843560b 100644
--- a/callui/src/main/ets/default/pages/index.ets
+++ b/entry/src/main/ets/pages/index.ets
@@ -1,189 +1,164 @@
-/**
- * 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.
- */
-
-/**
- * @file: Main interface
- */
-
-import ContactCard from '../common/components/ContactCard';
-import FuncBtnGroup from '../common/components/FuncBtnGroup';
-import Keyboard from '../common/components/Keyboard';
-import BottomBtn from '../common/components/BottomBtn';
-import IncomingCom from '../common/components/IncomingCom';
-import CallStateConst from '../common/constant/CallStateConst';
-import NotificationManager from '../model/NotificationManager';
-import call from '@ohos.telephony.call';
-import CallManager from '../model/CallManager';
-import HiLog from '../common/utils/Hilog';
-import bundle from '@ohos.bundle';
-import abilityAccessCtrl from "@ohos.abilityAccessCtrl";
-import featureAbility from "@ohos.ability.featureAbility"
-import byTrace from "@ohos.bytrace"
-
-const TAG = "Index";
-const prefixLog = 'callUI app:@ohos.telephony.call:';
-const SIM_CARD_DELAYED_DISPLAY = 100;
-const textMap =
- {
- 'answer': $r('app.string.answer'),
- 'reject': $r('app.string.reject'),
- 'hangUp': $r('app.string.hangUp'),
- 'mute': $r('app.string.mute'),
- 'callHold': $r('app.string.callHold'),
- };
-
-/**
- * @file: Main interface
- */
-@Entry
-@Component
-export default struct Index {
- @StorageLink("InputNum") inputNum: any = [];
- @State callData: any = CallStateConst.defaultCallData;
- @State isShowKeyboard: boolean = false;
- private appInactiveState = false
- @State callList: Array = [];
- private consoleTxt: '';
- private callStateConst;
- private notificationManager: NotificationManager;
-
- /**
- * Call status
- *
- * @return {number} - callState
- */
- private callState() {
- return this.callData.callState;
- }
-
- /**
- * method to control the display of DTMF keyboard
- *
- * parent component pass by value child component
- */
- public showKeyboard() {
- this.isShowKeyboard = !this.isShowKeyboard;
- }
-
- /**
- * Dialing function
- */
- public dialCall(phoneNumber, accountId = 0, videoState = 0, dialScene = 0) {
- HiLog.i(TAG, "dialCall phoneNumber :")
- call.dial(phoneNumber, {
- accountId,
- videoState,
- dialScene
- });
- }
-
- aboutToAppear(): void {
- HiLog.i(TAG, "aboutToAppear :")
- byTrace.startTrace('aboutToAppear', 0);
- this.callStateConst = new CallStateConst();
- this.notificationManager = new NotificationManager();
- globalThis.callManager = new CallManager(this)
- AppStorage.SetOrCreate('notificationManager', this.notificationManager);
- let delayMethod = setTimeout(() => {
- clearTimeout(delayMethod);
- }, SIM_CARD_DELAYED_DISPLAY);
- byTrace.finishTrace('aboutToAppear', 0);
- }
-
- onPageShow() {
- HiLog.i(TAG, "onPageShow : ")
- byTrace.startTrace('onPageShow', 1);
- this.appInactiveState = false;
- this.notificationManager.cancelNotification();
- this.notificationManager.sendCapsuleNotification(this.callData, false);
- byTrace.finishTrace('onPageShow', 1);
- HiLog.i(TAG, "onPageShow end : ")
- }
-
- onPageHide() {
- HiLog.i(TAG, "onPageHide :")
- this.appInactiveState = true;
- const {callState, accountNumber, contactName, callId} = this.callData;
- let fool = (callState !== CallStateConst.callStateObj.CALL_STATUS_DISCONNECTED && callId)
- if (callState !== CallStateConst.callStateObj.CALL_STATUS_DISCONNECTED && callId) {
- let text = contactName + ' ' + accountNumber + ' ';
- if (!contactName) {
- text = accountNumber + ' ' ;
- }
- this.notificationManager.sendNotification(text, this.callData);
- this.notificationManager.sendCapsuleNotification(this.callData, true);
- HiLog.i(TAG, "onPageHide end : ")
- }
- }
-
- build() {
- Column() {
- Stack() {
- Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
- Column() {
- ContactCard({
- callData: $callData,
- isShowKeyboard: this.isShowKeyboard,
- callList: $callList
- })
- }
- .margin({ top: 56 })
-
- if (this.callState() !== CallStateConst.callStateObj.CALL_STATUS_WAITING
- && this.callState() !== CallStateConst.callStateObj.CALL_STATUS_INCOMING) {
- Column() {
- Column() {
- Column() {
- FuncBtnGroup({ callData: $callData, callList: $callList })
- }
- .margin({ bottom: 29.5 })
- }
- .visibility(!this.isShowKeyboard ? Visibility.Visible : Visibility.None)
-
- Column() {
- Column() {
- Keyboard({ callData: $callData })
- }
- .margin({ bottom: 32 })
- }
- .visibility(this.isShowKeyboard ? Visibility.Visible : Visibility.None)
-
- Column() {
- BottomBtn({
- callData: $callData,
- onItemClick: () => {
- this.showKeyboard()
- }
- })
- }
- }
- .margin({ bottom: 106 })
- } else {
- Column() {
- IncomingCom({
- callData: $callData,
- })
- }
- .margin({ bottom: 106 })
- }
- }
- }
- }
- .width("100%")
- .height("100%")
- .backgroundImage('assets/picture/wallpaper.png', ImageRepeat.NoRepeat)
- .backgroundImageSize(ImageSize.Cover)
- }
-}
+import ContactCard from '../common/components/ContactCard';
+import FuncBtnGroup from '../common/components/FuncBtnGroup';
+import BottomBtn from '../common/components/BottomBtn';
+import Keyboard from '../common/components/Keyboard';
+import IncomingCom from '../common/components/IncomingCom';
+import CallStateConst from '../common/constant/CallStateConst';
+import LogUtils from '../common/utils/LogUtils';
+import byTrace from "@ohos.bytrace"
+import NotificationManager from '../model/NotificationManager';
+import call from '@ohos.telephony.call';
+import CallManager from '../model/CallManager';
+import notification from '@ohos.notification';
+
+const TAG = "MainAbility Index";
+const SIM_CARD_DELAYED_DISPLAY = 100;
+
+/**
+ * @file: Main interface
+ */
+@Entry
+@Component
+struct Index {
+ @State message: string = 'Hello World'
+ @StorageLink("InputNum") inputNum: any = [];
+ @State callData: any = CallStateConst.defaultCallData;
+ @State isShowKeyboard: boolean = false;
+ @State callList: Array = [];
+ private consoleTxt: '';
+ private callStateConst;
+ private notificationManager: NotificationManager;
+
+ aboutToAppear(): void {
+ LogUtils.i(TAG, "aboutToAppear :")
+ byTrace.startTrace('aboutToAppear', 0);
+ this.callStateConst = new CallStateConst();
+ this.notificationManager = new NotificationManager();
+ globalThis.callManager = new CallManager(this)
+ AppStorage.SetOrCreate('notificationManager', this.notificationManager);
+ let delayMethod = setTimeout(() => {
+ clearTimeout(delayMethod);
+ }, SIM_CARD_DELAYED_DISPLAY);
+ byTrace.finishTrace('aboutToAppear', 0);
+ }
+
+ onPageShow() {
+ LogUtils.i(TAG, "onPageShow : ")
+ byTrace.startTrace('onPageShow', 1);
+ globalThis.appInactiveState = false;
+ this.notificationManager.cancelNotification();
+ this.notificationManager.sendCapsuleNotification(this.callData, false);
+ byTrace.finishTrace('onPageShow', 1);
+ LogUtils.i(TAG, "onPageShow end : ")
+ }
+
+ onPageHide() {
+ LogUtils.i(TAG, "onPageHide :")
+ globalThis.appInactiveState = true;
+ const {callState, accountNumber, contactName, callId} = this.callData;
+ let fool = (callState !== CallStateConst.callStateObj.CALL_STATUS_DISCONNECTED && callId)
+ if (callState !== CallStateConst.callStateObj.CALL_STATUS_DISCONNECTED && callId) {
+ let text = contactName + ' ' + accountNumber + ' ';
+ if (!contactName) {
+ text = accountNumber + ' ';
+ }
+ this.notificationManager.sendNotification(text, this.callData);
+ this.notificationManager.sendCapsuleNotification(this.callData, true);
+ LogUtils.i(TAG, "onPageHide end : ")
+ }
+ }
+
+ /**
+ * method to control the display of DTMF keyboard
+ *
+ * parent component pass by value child component
+ */
+ public showKeyboard() {
+ this.isShowKeyboard = !this.isShowKeyboard;
+ }
+
+ /**
+ * Call status
+ *
+ * @return {number} - callState
+ */
+ private callState() {
+ LogUtils.i(TAG, "callState : " + this.callData.callState)
+ return this.callData.callState;
+ }
+
+ /**
+ * Dialing function
+ */
+ public dialCall(phoneNumber, accountId = 0, videoState = 0, dialScene = 0) {
+ LogUtils.i(TAG, "dialCall phoneNumber :")
+ call.dial(phoneNumber, {
+ accountId,
+ videoState,
+ dialScene
+ });
+ }
+
+ build() {
+ Column() {
+ Stack() {
+ Flex({
+ direction: FlexDirection.Column,
+ alignItems: ItemAlign.Center,
+ justifyContent: FlexAlign.SpaceBetween
+ }) {
+ Column() {
+ ContactCard({
+ callData: $callData,
+ isShowKeyboard: this.isShowKeyboard,
+ callList: $callList
+ })
+ }
+ .margin({ top: 56 })
+
+ if (this.callState() !== CallStateConst.callStateObj.CALL_STATUS_WAITING
+ && this.callState() !== CallStateConst.callStateObj.CALL_STATUS_INCOMING) {
+ Column() {
+ Column() {
+ Column() {
+ FuncBtnGroup({ callData: $callData, callList: $callList })
+ }
+ .margin({ bottom: 29.5 })
+ }
+ .visibility(!this.isShowKeyboard ? Visibility.Visible : Visibility.None)
+
+ Column() {
+ Column() {
+ Keyboard({ callData: $callData })
+ }
+ .margin({ bottom: 32 })
+ }
+ .visibility(this.isShowKeyboard ? Visibility.Visible : Visibility.None)
+
+ Column() {
+ BottomBtn({
+ callData: $callData,
+ onItemClick: () => {
+ this.showKeyboard()
+ }
+ })
+ }
+ }
+ .margin({ bottom: 106 })
+ } else {
+ Column() {
+ IncomingCom({
+ callData: $callData,
+ })
+ }
+ .margin({ bottom: 106 })
+ }
+ }
+ }
+ }
+ .width("100%")
+ .height("100%")
+ .backgroundImage('assets/picture/wallpaper.png', ImageRepeat.NoRepeat)
+ .backgroundImageSize(ImageSize.Cover)
+ }
+}
diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5
new file mode 100644
index 0000000..883313b
--- /dev/null
+++ b/entry/src/main/module.json5
@@ -0,0 +1,67 @@
+{
+ "module": {
+ "name": "com.ohos.callui",
+ "type": "entry",
+ "srcEntrance": "./ets/Application/MyAbilityStage.ts",
+ "description": "$string:callui_description",
+ "mainElement": "com.ohos.callui.ServiceAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "uiSyntax": "ets",
+ "abilities": [
+ {
+ "name": "com.ohos.callui.MainAbility",
+ "srcEntrance": "./ets/MainAbility/MainAbility.ts",
+ "description": "$string:callui_description",
+ "icon": "$media:icon",
+ "label": "$string:callui_description",
+ "startWindowIcon": "$media:icon",
+ "startWindowBackground": "$color:black",
+ "visible": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "com.ohos.callui.ServiceAbility",
+ "icon": "$media:app_icon",
+ "description": "service",
+ "type": "service",
+ "visible": true,
+ "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts",
+ "label": "$string:callui_description"
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.READ_CONTACTS"
+ },
+ {
+ "name": "ohos.permission.SEND_MESSAGES"
+ },
+ {
+ "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
+ },
+ {
+ "name": "ohos.permission.SET_TELEPHONY_STATE"
+ },
+ {
+ "name": "ohos.permission.GET_TELEPHONY_STATE"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000..667e7ac
--- /dev/null
+++ b/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,12 @@
+{
+ "color": [
+ {
+ "name": "white",
+ "value": "#FFFFFF"
+ },
+ {
+ "name": "black",
+ "value": "#000000"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/callui/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json
similarity index 93%
rename from callui/src/main/resources/base/element/string.json
rename to entry/src/main/resources/base/element/string.json
index 1cfc7f6..7a2716e 100644
--- a/callui/src/main/resources/base/element/string.json
+++ b/entry/src/main/resources/base/element/string.json
@@ -1,212 +1,208 @@
-{
- "string": [
- {
- "name": "entry_MainAbility",
- "value": "通话"
- },
- {
- "name": "mainability_description",
- "value": "JS_Empty Ability"
- },
- {
- "name": "sms",
- "value": "Message"
- },
- {
- "name": "remind",
- "value": "Reminder"
- },
- {
- "name": "hangUpReply",
- "value": "Respond with"
- },
- {
- "name": "backLater",
- "value": "I'll call you back."
- },
- {
- "name": "answerThePhone",
- "value": "Sorry, I can't talk right now."
- },
- {
- "name": "contactMeLater",
- "value": "I'm in a meeting. I'll get back to you ASAP."
- },
- {
- "name": "beThereSoon",
- "value": "I'm on my way."
- },
- {
- "name": "customSMS",
- "value": "Custom..."
- },
- {
- "name": "cancel",
- "value": "CANCEL"
- },
- {
- "name": "callBackReminder",
- "value": "Callback reminder"
- },
- {
- "name": "minutes",
- "value": "In 30 minutes"
- },
- {
- "name": "oneHourLater",
- "value": "In 1 hour"
- },
- {
- "name": "twoHoursLater",
- "value": "In 2 hours"
- },
- {
- "name": "dialing",
- "value": "Dialing"
- },
- {
- "name": "calling",
- "value": "calling"
- },
- {
- "name": "callHold",
- "value": "Call hold"
- },
- {
- "name": "hangUpCompleted",
- "value": "Hang up completed"
- },
- {
- "name": "hangingUp",
- "value": "Hanging up"
- },
- {
- "name": "recording",
- "value": "Record"
- },
- {
- "name": "keep",
- "value": "Hold"
- },
- {
- "name": "addCall",
- "value": "Add call"
- },
- {
- "name": "videoCall",
- "value": "Video call"
- },
- {
- "name": "mute",
- "value": "Mute"
- },
- {
- "name": "contactPerson",
- "value": "Contacts"
- },
- {
- "name": "partyIsRinging",
- "value": "Ringing"
- },
- {
- "name": "saveNumber",
- "value": "Save number"
- },
- {
- "name": "addToBlacklist",
- "value": "add to blacklist"
- },
- {
- "name": "shutDown",
- "value": "shut down"
- },
- {
- "name": "speaker",
- "value": "Speaker"
- },
- {
- "name": "phoneHandset",
- "value": "Handset earpiece"
- },
- {
- "name": "mobileNetwork",
- "value": "Unable to access the mobile network."
- },
- {
- "name": "gotIt",
- "value": "Got it"
- },
- {
- "name": "currentCall",
- "value": "Current cal"
- },
- {
- "name": "hangUp",
- "value": "hang up"
- },
- {
- "name": "handsFree",
- "value": "Hands-free"
- },
- {
- "name": "incomingCall",
- "value": "Incoming call"
- },
- {
- "name": "reject",
- "value": "DECLINE"
- },
- {
- "name": "answer",
- "value": "ANSWER"
- },
- {
- "name": "maintain",
- "value": "On hold"
- },
- {
- "name": "exchange",
- "value": "Swap"
- },
- {
- "name": "mergeCall",
- "value": "Merge calls"
- },
- {
- "name": "manageUsers",
- "value": "Manage users"
- },
- {
- "name": "telephoneConference",
- "value": "Conference"
- },
- {
- "name": "unknownNumber",
- "value": "Unknown number"
- },
- {
- "name": "noCard",
- "value": "Can't access mobile network"
- },
- {
- "name": "telephone_Conference",
- "value": "Conference"
- },
- {
- "name": "message_Failed",
- "value": "message failed to send"
- },
- {
- "name": "SMS_Sent",
- "value": "SMS sent to"
- },
- {
- "name": "SMS_Authorization_Notification",
- "value": "Go to settings for SMS Authorization"
- },
- {
- "name": "emergency",
- "value": "Emergency"
- }
- ]
+{
+ "string": [
+ {
+ "name": "callui_description",
+ "value": "Phone"
+ },
+ {
+ "name": "sms",
+ "value": "Message"
+ },
+ {
+ "name": "remind",
+ "value": "Reminder"
+ },
+ {
+ "name": "hangUpReply",
+ "value": "Respond with"
+ },
+ {
+ "name": "backLater",
+ "value": "I'll call you back."
+ },
+ {
+ "name": "answerThePhone",
+ "value": "Sorry, I can't talk right now."
+ },
+ {
+ "name": "contactMeLater",
+ "value": "I'm in a meeting. I'll get back to you ASAP."
+ },
+ {
+ "name": "beThereSoon",
+ "value": "I'm on my way."
+ },
+ {
+ "name": "customSMS",
+ "value": "Custom..."
+ },
+ {
+ "name": "cancel",
+ "value": "CANCEL"
+ },
+ {
+ "name": "callBackReminder",
+ "value": "Callback reminder"
+ },
+ {
+ "name": "minutes",
+ "value": "In 30 minutes"
+ },
+ {
+ "name": "oneHourLater",
+ "value": "In 1 hour"
+ },
+ {
+ "name": "twoHoursLater",
+ "value": "In 2 hours"
+ },
+ {
+ "name": "dialing",
+ "value": "Dialing"
+ },
+ {
+ "name": "calling",
+ "value": "calling"
+ },
+ {
+ "name": "callHold",
+ "value": "Call hold"
+ },
+ {
+ "name": "hangUpCompleted",
+ "value": "Hang up completed"
+ },
+ {
+ "name": "hangingUp",
+ "value": "Hanging up"
+ },
+ {
+ "name": "recording",
+ "value": "Record"
+ },
+ {
+ "name": "keep",
+ "value": "Hold"
+ },
+ {
+ "name": "addCall",
+ "value": "Add call"
+ },
+ {
+ "name": "videoCall",
+ "value": "Video call"
+ },
+ {
+ "name": "mute",
+ "value": "Mute"
+ },
+ {
+ "name": "contactPerson",
+ "value": "Contacts"
+ },
+ {
+ "name": "partyIsRinging",
+ "value": "Ringing"
+ },
+ {
+ "name": "saveNumber",
+ "value": "Save number"
+ },
+ {
+ "name": "addToBlacklist",
+ "value": "add to blacklist"
+ },
+ {
+ "name": "shutDown",
+ "value": "shut down"
+ },
+ {
+ "name": "speaker",
+ "value": "Speaker"
+ },
+ {
+ "name": "phoneHandset",
+ "value": "Handset earpiece"
+ },
+ {
+ "name": "mobileNetwork",
+ "value": "Unable to access the mobile network."
+ },
+ {
+ "name": "gotIt",
+ "value": "Got it"
+ },
+ {
+ "name": "currentCall",
+ "value": "Current cal"
+ },
+ {
+ "name": "hangUp",
+ "value": "hang up"
+ },
+ {
+ "name": "handsFree",
+ "value": "Hands-free"
+ },
+ {
+ "name": "incomingCall",
+ "value": "Incoming call"
+ },
+ {
+ "name": "reject",
+ "value": "DECLINE"
+ },
+ {
+ "name": "answer",
+ "value": "ANSWER"
+ },
+ {
+ "name": "maintain",
+ "value": "On hold"
+ },
+ {
+ "name": "exchange",
+ "value": "Swap"
+ },
+ {
+ "name": "mergeCall",
+ "value": "Merge calls"
+ },
+ {
+ "name": "manageUsers",
+ "value": "Manage users"
+ },
+ {
+ "name": "telephoneConference",
+ "value": "Conference"
+ },
+ {
+ "name": "unknownNumber",
+ "value": "Unknown number"
+ },
+ {
+ "name": "noCard",
+ "value": "Can't access mobile network"
+ },
+ {
+ "name": "telephone_Conference",
+ "value": "Conference"
+ },
+ {
+ "name": "message_Failed",
+ "value": "message failed to send"
+ },
+ {
+ "name": "SMS_Sent",
+ "value": "SMS sent to"
+ },
+ {
+ "name": "SMS_Authorization_Notification",
+ "value": "Go to settings for SMS Authorization"
+ },
+ {
+ "name": "emergency",
+ "value": "Emergency"
+ }
+ ]
}
\ No newline at end of file
diff --git a/callui/src/main/resources/base/media/contact_default_avatar_dark.svg b/entry/src/main/resources/base/media/contact_default_avatar_dark.svg
similarity index 100%
rename from callui/src/main/resources/base/media/contact_default_avatar_dark.svg
rename to entry/src/main/resources/base/media/contact_default_avatar_dark.svg
diff --git a/callui/src/main/resources/base/media/contact_default_avatar_light.svg b/entry/src/main/resources/base/media/contact_default_avatar_light.svg
similarity index 100%
rename from callui/src/main/resources/base/media/contact_default_avatar_light.svg
rename to entry/src/main/resources/base/media/contact_default_avatar_light.svg
diff --git a/callui/src/main/resources/base/media/divider.svg b/entry/src/main/resources/base/media/divider.svg
similarity index 100%
rename from callui/src/main/resources/base/media/divider.svg
rename to entry/src/main/resources/base/media/divider.svg
diff --git a/callui/src/main/resources/base/media/ic_add_filled.svg b/entry/src/main/resources/base/media/ic_add_filled.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_add_filled.svg
rename to entry/src/main/resources/base/media/ic_add_filled.svg
diff --git a/callui/src/main/resources/base/media/ic_back.svg b/entry/src/main/resources/base/media/ic_back.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_back.svg
rename to entry/src/main/resources/base/media/ic_back.svg
diff --git a/callui/src/main/resources/base/media/ic_me.svg b/entry/src/main/resources/base/media/ic_me.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_me.svg
rename to entry/src/main/resources/base/media/ic_me.svg
diff --git a/callui/src/main/resources/base/media/ic_message.svg b/entry/src/main/resources/base/media/ic_message.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_message.svg
rename to entry/src/main/resources/base/media/ic_message.svg
diff --git a/callui/src/main/resources/base/media/ic_public_DTFS.svg b/entry/src/main/resources/base/media/ic_public_DTFS.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_public_DTFS.svg
rename to entry/src/main/resources/base/media/ic_public_DTFS.svg
diff --git a/callui/src/main/resources/base/media/ic_public_Smart_Speaker_filed.svg b/entry/src/main/resources/base/media/ic_public_Smart_Speaker_filed.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_public_Smart_Speaker_filed.svg
rename to entry/src/main/resources/base/media/ic_public_Smart_Speaker_filed.svg
diff --git a/callui/src/main/resources/base/media/ic_public_add_filled.svg b/entry/src/main/resources/base/media/ic_public_add_filled.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_public_add_filled.svg
rename to entry/src/main/resources/base/media/ic_public_add_filled.svg
diff --git a/entry/src/main/resources/base/media/ic_public_add_filled_Grey.svg b/entry/src/main/resources/base/media/ic_public_add_filled_Grey.svg
new file mode 100644
index 0000000..24192c1
--- /dev/null
+++ b/entry/src/main/resources/base/media/ic_public_add_filled_Grey.svg
@@ -0,0 +1,31 @@
+
+
\ No newline at end of file
diff --git a/callui/src/main/resources/base/media/ic_public_answer.svg b/entry/src/main/resources/base/media/ic_public_answer.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_public_answer.svg
rename to entry/src/main/resources/base/media/ic_public_answer.svg
diff --git a/callui/src/main/resources/base/media/ic_public_avatar.svg b/entry/src/main/resources/base/media/ic_public_avatar.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_public_avatar.svg
rename to entry/src/main/resources/base/media/ic_public_avatar.svg
diff --git a/callui/src/main/resources/base/media/ic_public_clock.svg b/entry/src/main/resources/base/media/ic_public_clock.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_public_clock.svg
rename to entry/src/main/resources/base/media/ic_public_clock.svg
diff --git a/callui/src/main/resources/base/media/ic_public_contacts.svg b/entry/src/main/resources/base/media/ic_public_contacts.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_public_contacts.svg
rename to entry/src/main/resources/base/media/ic_public_contacts.svg
diff --git a/entry/src/main/resources/base/media/ic_public_contacts_Grey.svg b/entry/src/main/resources/base/media/ic_public_contacts_Grey.svg
new file mode 100644
index 0000000..80bc251
--- /dev/null
+++ b/entry/src/main/resources/base/media/ic_public_contacts_Grey.svg
@@ -0,0 +1,32 @@
+
+
\ No newline at end of file
diff --git a/callui/src/main/resources/base/media/ic_public_hangUP.svg b/entry/src/main/resources/base/media/ic_public_hangUP.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_public_hangUP.svg
rename to entry/src/main/resources/base/media/ic_public_hangUP.svg
diff --git a/callui/src/main/resources/base/media/ic_public_keyboard.svg b/entry/src/main/resources/base/media/ic_public_keyboard.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_public_keyboard.svg
rename to entry/src/main/resources/base/media/ic_public_keyboard.svg
diff --git a/callui/src/main/resources/base/media/ic_public_message.svg b/entry/src/main/resources/base/media/ic_public_message.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_public_message.svg
rename to entry/src/main/resources/base/media/ic_public_message.svg
diff --git a/callui/src/main/resources/base/media/ic_public_pause.svg b/entry/src/main/resources/base/media/ic_public_pause.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_public_pause.svg
rename to entry/src/main/resources/base/media/ic_public_pause.svg
diff --git a/callui/src/main/resources/base/media/ic_public_pause_Enabled.svg b/entry/src/main/resources/base/media/ic_public_pause_Enabled.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_public_pause_Enabled.svg
rename to entry/src/main/resources/base/media/ic_public_pause_Enabled.svg
diff --git a/callui/src/main/ets/default/assets/picture/ic_public_pause_Grey.svg b/entry/src/main/resources/base/media/ic_public_pause_Grey.svg
similarity index 100%
rename from callui/src/main/ets/default/assets/picture/ic_public_pause_Grey.svg
rename to entry/src/main/resources/base/media/ic_public_pause_Grey.svg
diff --git a/callui/src/main/resources/base/media/ic_public_recording_.svg b/entry/src/main/resources/base/media/ic_public_recording_.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_public_recording_.svg
rename to entry/src/main/resources/base/media/ic_public_recording_.svg
diff --git a/entry/src/main/resources/base/media/ic_public_recording_Grey.svg b/entry/src/main/resources/base/media/ic_public_recording_Grey.svg
new file mode 100644
index 0000000..ec296ce
--- /dev/null
+++ b/entry/src/main/resources/base/media/ic_public_recording_Grey.svg
@@ -0,0 +1,32 @@
+
+
\ No newline at end of file
diff --git a/callui/src/main/resources/base/media/ic_public_ring_off.svg b/entry/src/main/resources/base/media/ic_public_ring_off.svg
similarity index 99%
rename from callui/src/main/resources/base/media/ic_public_ring_off.svg
rename to entry/src/main/resources/base/media/ic_public_ring_off.svg
index bb4dff6..e45861d 100644
--- a/callui/src/main/resources/base/media/ic_public_ring_off.svg
+++ b/entry/src/main/resources/base/media/ic_public_ring_off.svg
@@ -5,4 +5,5 @@
-
\ No newline at end of file
+
+
diff --git a/callui/src/main/resources/base/media/ic_public_sound.svg b/entry/src/main/resources/base/media/ic_public_sound.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_public_sound.svg
rename to entry/src/main/resources/base/media/ic_public_sound.svg
diff --git a/callui/src/main/resources/base/media/ic_public_sound_louder.svg b/entry/src/main/resources/base/media/ic_public_sound_louder.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_public_sound_louder.svg
rename to entry/src/main/resources/base/media/ic_public_sound_louder.svg
diff --git a/callui/src/main/resources/base/media/ic_public_video.svg b/entry/src/main/resources/base/media/ic_public_video.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_public_video.svg
rename to entry/src/main/resources/base/media/ic_public_video.svg
diff --git a/entry/src/main/resources/base/media/ic_public_video_Grey.svg b/entry/src/main/resources/base/media/ic_public_video_Grey.svg
new file mode 100644
index 0000000..126c774
--- /dev/null
+++ b/entry/src/main/resources/base/media/ic_public_video_Grey.svg
@@ -0,0 +1,32 @@
+
+
\ No newline at end of file
diff --git a/callui/src/main/resources/base/media/ic_public_video_filled.svg b/entry/src/main/resources/base/media/ic_public_video_filled.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_public_video_filled.svg
rename to entry/src/main/resources/base/media/ic_public_video_filled.svg
diff --git a/callui/src/main/resources/base/media/ic_public_voice.svg b/entry/src/main/resources/base/media/ic_public_voice.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_public_voice.svg
rename to entry/src/main/resources/base/media/ic_public_voice.svg
diff --git a/callui/src/main/resources/base/media/ic_public_voice_Enabled.svg b/entry/src/main/resources/base/media/ic_public_voice_Enabled.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_public_voice_Enabled.svg
rename to entry/src/main/resources/base/media/ic_public_voice_Enabled.svg
diff --git a/entry/src/main/resources/base/media/ic_public_voice_Grey.svg b/entry/src/main/resources/base/media/ic_public_voice_Grey.svg
new file mode 100644
index 0000000..9a97c44
--- /dev/null
+++ b/entry/src/main/resources/base/media/ic_public_voice_Grey.svg
@@ -0,0 +1,32 @@
+
+
\ No newline at end of file
diff --git a/callui/src/main/resources/base/media/ic_rocerder.svg b/entry/src/main/resources/base/media/ic_rocerder.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_rocerder.svg
rename to entry/src/main/resources/base/media/ic_rocerder.svg
diff --git a/callui/src/main/resources/base/media/ic_video_filled.svg b/entry/src/main/resources/base/media/ic_video_filled.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_video_filled.svg
rename to entry/src/main/resources/base/media/ic_video_filled.svg
diff --git a/callui/src/main/resources/base/media/ic_voice.svg b/entry/src/main/resources/base/media/ic_voice.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_voice.svg
rename to entry/src/main/resources/base/media/ic_voice.svg
diff --git a/callui/src/main/resources/base/media/ic_voice_filled.svg b/entry/src/main/resources/base/media/ic_voice_filled.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_voice_filled.svg
rename to entry/src/main/resources/base/media/ic_voice_filled.svg
diff --git a/callui/src/main/resources/base/media/ic_volume.svg b/entry/src/main/resources/base/media/ic_volume.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_volume.svg
rename to entry/src/main/resources/base/media/ic_volume.svg
diff --git a/callui/src/main/resources/base/media/ic_volume_filled.svg b/entry/src/main/resources/base/media/ic_volume_filled.svg
similarity index 100%
rename from callui/src/main/resources/base/media/ic_volume_filled.svg
rename to entry/src/main/resources/base/media/ic_volume_filled.svg
diff --git a/callui/src/main/resources/base/media/icon.png b/entry/src/main/resources/base/media/icon.png
similarity index 100%
rename from callui/src/main/resources/base/media/icon.png
rename to entry/src/main/resources/base/media/icon.png
diff --git a/callui/src/main/resources/base/media/phone_default_avatar.svg b/entry/src/main/resources/base/media/phone_default_avatar.svg
similarity index 100%
rename from callui/src/main/resources/base/media/phone_default_avatar.svg
rename to entry/src/main/resources/base/media/phone_default_avatar.svg
diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000..feec276
--- /dev/null
+++ b/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "pages/index"
+ ]
+}
diff --git a/callui/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json
similarity index 96%
rename from callui/src/main/resources/zh_CN/element/string.json
rename to entry/src/main/resources/zh_CN/element/string.json
index f4905a0..5439868 100644
--- a/callui/src/main/resources/zh_CN/element/string.json
+++ b/entry/src/main/resources/zh_CN/element/string.json
@@ -4,6 +4,10 @@
"name": "sms",
"value": "短信"
},
+ {
+ "name": "callui_description",
+ "value": "通话"
+ },
{
"name": "remind",
"value": "提醒"
@@ -184,15 +188,6 @@
"name": "telephone_Conference",
"value": "电话会议"
},
-
- {
- "name": "entry_MainAbility",
- "value": "通话"
- },
- {
- "name": "mainability_description",
- "value": "JS_Empty Ability"
- },
{
"name": "message_Failed",
"value": "短信发送失败"
diff --git a/hvigorfile.js b/hvigorfile.js
index 6f719b7..586ced9 100644
--- a/hvigorfile.js
+++ b/hvigorfile.js
@@ -1 +1,2 @@
-module.exports = require('@ohos/hvigor-ohos-plugin').legacyAppTasks
\ No newline at end of file
+// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
+module.exports = require('@ohos/hvigor-ohos-plugin').appTasks
\ No newline at end of file
diff --git a/mobiledatasettings/.gitignore b/mobiledatasettings/.gitignore
index 796b96d..4a65948 100644
--- a/mobiledatasettings/.gitignore
+++ b/mobiledatasettings/.gitignore
@@ -1 +1,4 @@
-/build
+/node_modules
+/.preview
+/build
+/.cxx
\ No newline at end of file
diff --git a/mobiledatasettings/build-profile.json5 b/mobiledatasettings/build-profile.json5
index cec88c9..e8100bd 100644
--- a/mobiledatasettings/build-profile.json5
+++ b/mobiledatasettings/build-profile.json5
@@ -1,25 +1,16 @@
-/**
- * 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.
- */
-{
- apiType: 'faMode',
- showInServiceCenter: false,
- buildOption: {
- },
- "targets": [
- {
- "name": "default",
- }
- ]
+{
+ "apiType": 'stageMode',
+ "buildOption": {
+ },
+ "entryModules": [
+ "com.ohos.callui"
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
}
\ No newline at end of file
diff --git a/mobiledatasettings/hvigorfile.js b/mobiledatasettings/hvigorfile.js
index 23d0ec3..d7720ee 100644
--- a/mobiledatasettings/hvigorfile.js
+++ b/mobiledatasettings/hvigorfile.js
@@ -1 +1,2 @@
-module.exports = require('@ohos/hvigor-ohos-plugin').legacyHapTasks
\ No newline at end of file
+// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
+module.exports = require('@ohos/hvigor-ohos-plugin').hapTasks
diff --git a/mobiledatasettings/package.json b/mobiledatasettings/package.json
index 0967ef4..7a96193 100644
--- a/mobiledatasettings/package.json
+++ b/mobiledatasettings/package.json
@@ -1 +1,14 @@
-{}
+{
+ "license":"ISC",
+ "devDependencies":{},
+ "name":"mobiledatasettings",
+ "ohos":{
+ "org":"huawei",
+ "directoryLevel":"module",
+ "buildTool":"hvigor"
+ },
+ "description":"example description",
+ "repository":{},
+ "version":"1.0.0",
+ "dependencies":{}
+}
\ No newline at end of file
diff --git a/mobiledatasettings/src/main/config.json b/mobiledatasettings/src/main/config.json
deleted file mode 100644
index c194c17..0000000
--- a/mobiledatasettings/src/main/config.json
+++ /dev/null
@@ -1,77 +0,0 @@
-{
- "app": {
- "bundleName": "com.ohos.callui",
- "vendor": "ohos",
- "singleton": true,
- "version": {
- "code": 1000000,
- "name": "1.0.0"
- }
- },
- "deviceConfig": {},
- "module": {
- "package": "com.ohos.mobiledatasettings",
- "name": ".MyApplication",
- "mainAbility": "com.ohos.mobiledatasettings.MainAbility",
- "srcPath": "",
- "deviceType": [
- "phone",
- "tablet"
- ],
- "distro": {
- "deliveryWithInstall": true,
- "moduleName": "mobiledatasettings",
- "moduleType": "feature",
- "installationFree": true
- },
- "abilities": [
- {
- "skills": [
- {
- "entities": [
- "entity.system.home"
- ],
- "actions": [
- "action.system.home"
- ]
- }
- ],
- "orientation": "unspecified",
- "visible": true,
- "srcPath": "default",
- "srcLanguage": "ets",
- "name": "com.ohos.mobiledatasettings.MainAbility",
- "icon": "$media:icon",
- "description": "JS_Empty Ability",
- "formsEnabled": false,
- "label": "$string:mobiledatasettings_MainAbility",
- "type": "page",
- "launchType": "singleton"
- }
- ],
- "js": [
- {
- "mode": {
- "syntax": "ets",
- "type": "pageAbility"
- },
- "pages": [
- "pages/index"
- ],
- "name": "com.ohos.mobiledatasettings.MainAbility",
- "window": {
- "designWidth": 720,
- "autoDesignWidth": false
- }
- }
- ],
- "reqPermissions" : [
- {
- "name": "ohos.permission.GET_NETWORK_INFO"
- },
- {
- "name": "ohos.permission.SET_TELEPHONY_STATE"
- }
- ]
- }
-}
\ No newline at end of file
diff --git a/mobiledatasettings/src/main/ets/Application/MyAbilityStage.ts b/mobiledatasettings/src/main/ets/Application/MyAbilityStage.ts
new file mode 100644
index 0000000..4bea34b
--- /dev/null
+++ b/mobiledatasettings/src/main/ets/Application/MyAbilityStage.ts
@@ -0,0 +1,9 @@
+import hilog from '@ohos.hilog';
+import AbilityStage from "@ohos.application.AbilityStage"
+
+export default class MyAbilityStage extends AbilityStage {
+ onCreate() {
+ hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'AbilityStage onCreate');
+ }
+}
\ No newline at end of file
diff --git a/mobiledatasettings/src/main/ets/MainAbility/MainAbility.ts b/mobiledatasettings/src/main/ets/MainAbility/MainAbility.ts
new file mode 100644
index 0000000..43b2332
--- /dev/null
+++ b/mobiledatasettings/src/main/ets/MainAbility/MainAbility.ts
@@ -0,0 +1,51 @@
+import hilog from '@ohos.hilog';
+import Ability from '@ohos.application.Ability'
+import Window from '@ohos.window'
+
+export default class MainAbility extends Ability {
+ onCreate(want, launchParam) {
+ hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
+ hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? '');
+ }
+
+ onDestroy() {
+ hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: Window.WindowStage) {
+ // Main window is created, set main page for this ability
+ hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/index', (err, data) => {
+ if (err.code) {
+ hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
+ });
+ }
+
+ onWindowStageDestroy() {
+ // Main window is destroyed, release UI related resources
+ hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground() {
+ // Ability has brought to foreground
+ hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground() {
+ // Ability has back to background
+ hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/mobiledatasettings/src/main/ets/default/app.ets b/mobiledatasettings/src/main/ets/default/app.ets
deleted file mode 100644
index 97683ae..0000000
--- a/mobiledatasettings/src/main/ets/default/app.ets
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * @file: Module root file app
- */
-import deviceInfo from '@ohos.deviceInfo';
-
-export default {
- onCreate() {
- globalThis.deviceTypeInfo = deviceInfo.deviceType;
- },
- onDestroy() {
- },
-}
\ No newline at end of file
diff --git a/mobiledatasettings/src/main/ets/default/pages/index.ets b/mobiledatasettings/src/main/ets/pages/index.ets
similarity index 92%
rename from mobiledatasettings/src/main/ets/default/pages/index.ets
rename to mobiledatasettings/src/main/ets/pages/index.ets
index ecf40ba..a743df7 100644
--- a/mobiledatasettings/src/main/ets/default/pages/index.ets
+++ b/mobiledatasettings/src/main/ets/pages/index.ets
@@ -1,169 +1,187 @@
-/**
- * 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.
- */
-
-/**
- * @file: Mobile Network Home page
- */
-
-import router from '@system.router';
-import telephonyData from '@ohos.telephony.data';
-import telephonyObserver from '@ohos.telephony.observer';
-import telephonySim from '@ohos.telephony.sim';
-
-const TAG = "MobileDataSettings:";
-
-@Entry
-@Component
-struct Index {
- @State isDataOn: boolean = false;
- @State isDataEnable: boolean = false;
-
- aboutToAppear(): void {
- console.info(TAG + "aboutToAppear");
- telephonyObserver.on("simStateChange", (simStateData) => {
- if (!simStateData) {
- return;
- }
- console.info(TAG + "simStateChange simState: " + simStateData.state);
- this.updateDataEnableState(simStateData.state);
- });
- }
-
- onPageShow(): void {
- console.info(TAG + "onPageShow");
- telephonySim.getSimState(0).then((simState) => {
- console.info(TAG + "onPageShow simState: " + simState);
- this.updateDataEnableState(simState);
- }).catch((error) => {
- console.error(TAG + "onPageShow getSimState error: " + error);
- });
- }
-
- aboutToDisappear(): void {
- console.info(TAG + "aboutToDisappear");
- telephonyObserver.off("simStateChange");
- }
-
- private updateDataEnableState(simState) {
- if (simState == telephonySim.SimState.SIM_STATE_NOT_PRESENT) {
- this.isDataEnable = false;
- this.isDataOn = false;
- } else {
- this.isDataEnable = true;
- telephonyData.isCellularDataEnabled().then((dataEnable) => {
- console.info(TAG + "updateDataEnableState isCellularDataEnabled: " + dataEnable);
- this.isDataOn = dataEnable;
- }).catch((error) => {
- console.error(TAG + "updateDataEnableState isCellularDataEnabled error: " + error);
- });
- }
- }
-
- build() {
- Column() {
- GridContainer({ gutter: 12, margin: 12 }) {
- Column() {
- List() {
- ListItem() {
- Row() {
- Image($r("app.media.ic_back"))
- .height(24)
- .width(24)
- .margin({ top: 2, bottom: 2, right: 16 })
- .onClick(() => {
- router.back()
- })
-
- Text($r("app.string.mobile_data"))
- .height(28)
- .lineHeight(28)
- .fontSize(20)
- .fontWeight(FontWeight.Medium)
- .fontColor('#182431')
- }
- .width("100%")
- .height(56)
- .padding({
- left: globalThis.deviceTypeInfo === "phone" || globalThis.deviceTypeInfo === "default" ? 12 : 24,
- top: 14,
- bottom: 14
- })
- .margin({ bottom: 8 })
- }
-
- ListItem() {
- Flex({
- direction: FlexDirection.Row,
- alignItems: ItemAlign.Center,
- justifyContent: FlexAlign.SpaceBetween
- }) {
- Column() {
- Text($r("app.string.mobile_data"))
- .height(22)
- .fontSize(16)
- .fontWeight(FontWeight.Medium)
- .fontColor('#182431')
- .margin({ bottom: 2 })
-
- Text($r("app.string.mobile_data_charges"))
- .height(19)
- .fontSize(14)
- .fontWeight(FontWeight.Regular)
- .fontColor('#182431')
- .opacity(0.6)
- }
- .margin({ left: 12 })
- .alignItems(HorizontalAlign.Start)
-
- Toggle({ type: ToggleType.Switch, isOn: this.isDataOn })
- .onChange((isOn: boolean) => {
- if (isOn) {
- telephonyData.enableCellularData()
- .then((data) => {
- })
- .catch((error) => {
- });
- } else {
- telephonyData.disableCellularData()
- .then((data) => {
- })
- .catch((error) => {
- });
- }
- })
- .height(20)
- .width(36)
- .margin({ right: 12 })
- .enabled(this.isDataEnable)
- }
- .height(72)
- .width('100%')
- .backgroundColor('#FFFFFF')
- .borderRadius(25)
- }
- }
- }
- .useSizeType({
- sm: { span: 4, offset: 0 },
- md: { span: 6, offset: 1 },
- lg: { span: 8, offset: 2 }
- })
- }
- }
- .width('100%')
- .height('100%')
- .backgroundColor('#F1F3F5')
- }
+/*
+@Entry
+@Component
+struct Index {
+ @State message: string = 'Hello World'
+
+ build() {
+ Row() {
+ Column() {
+ Text(this.message)
+ .fontSize(50)
+ .fontWeight(FontWeight.Bold)
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}*/
+/**
+ * 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.
+ */
+
+/**
+ * @file: Mobile Network Home page
+ */
+
+import router from '@system.router';
+import telephonyData from '@ohos.telephony.data';
+import telephonyObserver from '@ohos.telephony.observer';
+import telephonySim from '@ohos.telephony.sim';
+
+const TAG = "MobileDataSettings:";
+
+@Entry
+@Component
+struct Index {
+ @State isDataOn: boolean = false;
+ @State isDataEnable: boolean = false;
+
+ aboutToAppear(): void {
+ console.info(TAG + "aboutToAppear");
+ telephonyObserver.on("simStateChange", (simStateData) => {
+ if (!simStateData) {
+ return;
+ }
+ console.info(TAG + "simStateChange simState: " + simStateData.state);
+ this.updateDataEnableState(simStateData.state);
+ });
+ }
+
+ onPageShow(): void {
+ console.info(TAG + "onPageShow");
+ telephonySim.getSimState(0).then((simState) => {
+ console.info(TAG + "onPageShow simState: " + simState);
+ this.updateDataEnableState(simState);
+ }).catch((error) => {
+ console.error(TAG + "onPageShow getSimState error: " + error);
+ });
+ }
+
+ aboutToDisappear(): void {
+ console.info(TAG + "aboutToDisappear");
+ telephonyObserver.off("simStateChange");
+ }
+
+ private updateDataEnableState(simState) {
+ if (simState == telephonySim.SimState.SIM_STATE_NOT_PRESENT) {
+ this.isDataEnable = false;
+ this.isDataOn = false;
+ } else {
+ this.isDataEnable = true;
+ telephonyData.isCellularDataEnabled().then((dataEnable) => {
+ console.info(TAG + "updateDataEnableState isCellularDataEnabled: " + dataEnable);
+ this.isDataOn = dataEnable;
+ }).catch((error) => {
+ console.error(TAG + "updateDataEnableState isCellularDataEnabled error: " + error);
+ });
+ }
+ }
+
+ build() {
+ Column() {
+ GridContainer({ gutter: 12, margin: 12 }) {
+ Column() {
+ List() {
+ ListItem() {
+ Row() {
+ Image($r("app.media.ic_back"))
+ .height(24)
+ .width(24)
+ .margin({ top: 2, bottom: 2, right: 16 })
+ .onClick(() => {
+ router.back()
+ })
+
+ Text($r("app.string.mobile_data"))
+ .height(28)
+ .lineHeight(28)
+ .fontSize(20)
+ .fontWeight(FontWeight.Medium)
+ .fontColor('#182431')
+ }
+ .width("100%")
+ .height(56)
+ .padding({
+ left: globalThis.deviceTypeInfo === "phone" || globalThis.deviceTypeInfo === "default" ? 12 : 24,
+ top: 14,
+ bottom: 14
+ })
+ .margin({ bottom: 8 })
+ }
+
+ ListItem() {
+ Flex({
+ direction: FlexDirection.Row,
+ alignItems: ItemAlign.Center,
+ justifyContent: FlexAlign.SpaceBetween
+ }) {
+ Column() {
+ Text($r("app.string.mobile_data"))
+ .height(22)
+ .fontSize(16)
+ .fontWeight(FontWeight.Medium)
+ .fontColor('#182431')
+ .margin({ bottom: 2 })
+
+ Text($r("app.string.mobile_data_charges"))
+ .height(19)
+ .fontSize(14)
+ .fontWeight(FontWeight.Regular)
+ .fontColor('#182431')
+ .opacity(0.6)
+ }
+ .margin({ left: 12 })
+ .alignItems(HorizontalAlign.Start)
+
+ Toggle({ type: ToggleType.Switch, isOn: this.isDataOn })
+ .onChange((isOn: boolean) => {
+ if (isOn) {
+ telephonyData.enableCellularData()
+ .then((data) => {
+ })
+ .catch((error) => {
+ });
+ } else {
+ telephonyData.disableCellularData()
+ .then((data) => {
+ })
+ .catch((error) => {
+ });
+ }
+ })
+ .height(20)
+ .width(36)
+ .margin({ right: 12 })
+ .enabled(this.isDataEnable)
+ }
+ .height(72)
+ .width('100%')
+ .backgroundColor('#FFFFFF')
+ .borderRadius(25)
+ }
+ }
+ }
+ .useSizeType({
+ sm: { span: 4, offset: 0 },
+ md: { span: 6, offset: 1 },
+ lg: { span: 8, offset: 2 }
+ })
+ }
+ }
+ .width('100%')
+ .height('100%')
+ .backgroundColor('#F1F3F5')
+ }
}
\ No newline at end of file
diff --git a/mobiledatasettings/src/main/module.json5 b/mobiledatasettings/src/main/module.json5
new file mode 100644
index 0000000..2bb627a
--- /dev/null
+++ b/mobiledatasettings/src/main/module.json5
@@ -0,0 +1,36 @@
+{
+ "module": {
+ "name": "com.ohos.mobiledatasettings",
+ "type": "feature",
+ "srcEntrance": "./ets/Application/MyAbilityStage.ts",
+ "description": "$string:mobiledatasettings_MainAbility",
+ "mainElement": "com.ohos.mobiledatasettings.MainAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "com.ohos.mobiledatasettings.MainAbility",
+ "srcEntrance": "./ets/MainAbility/MainAbility.ts",
+ "description": "$string:mainability_description",
+ "icon": "$media:ic_icon",
+ "label": "$string:MainAbility_label",
+ "startWindowIcon": "$media:ic_icon",
+ "startWindowBackground": "$color:white",
+ "visible": true
+ }
+ ],
+ "requestPermissions" : [
+ {
+ "name": "ohos.permission.GET_NETWORK_INFO"
+ },
+ {
+ "name": "ohos.permission.SET_TELEPHONY_STATE"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/mobiledatasettings/src/main/resources/base/element/color.json b/mobiledatasettings/src/main/resources/base/element/color.json
new file mode 100644
index 0000000..62a137a
--- /dev/null
+++ b/mobiledatasettings/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "white",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/mobiledatasettings/src/main/resources/base/element/string.json b/mobiledatasettings/src/main/resources/base/element/string.json
index 414cb41..9b8ca9d 100644
--- a/mobiledatasettings/src/main/resources/base/element/string.json
+++ b/mobiledatasettings/src/main/resources/base/element/string.json
@@ -1,20 +1,24 @@
-{
- "string": [
- {
- "name": "mobiledatasettings_MainAbility",
- "value": "Phone"
- },
- {
- "name": "mainability_description",
- "value": "JS_Empty Ability"
- },
- {
- "name": "mobile_data",
- "value": "mobile data"
- },
- {
- "name": "mobile_data_charges",
- "value": "After activation, the charges incurred are charged by the operator"
- }
- ]
+{
+ "string": [
+ {
+ "name": "MainAbility_label",
+ "value": "label"
+ },
+ {
+ "name": "mobiledatasettings_MainAbility",
+ "value": "Phone"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Mobile data settings"
+ },
+ {
+ "name": "mobile_data",
+ "value": "mobile data"
+ },
+ {
+ "name": "mobile_data_charges",
+ "value": "After activation, the charges incurred are charged by the operator"
+ }
+ ]
}
\ No newline at end of file
diff --git a/mobiledatasettings/src/main/resources/base/media/icon.png b/mobiledatasettings/src/main/resources/base/media/ic_icon.png
similarity index 100%
rename from mobiledatasettings/src/main/resources/base/media/icon.png
rename to mobiledatasettings/src/main/resources/base/media/ic_icon.png
diff --git a/mobiledatasettings/src/main/resources/base/profile/main_pages.json b/mobiledatasettings/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000..feec276
--- /dev/null
+++ b/mobiledatasettings/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "pages/index"
+ ]
+}
diff --git a/mobiledatasettings/src/main/resources/zh_CN/element/string.json b/mobiledatasettings/src/main/resources/zh_CN/element/string.json
index 4be9023..7dd3bac 100644
--- a/mobiledatasettings/src/main/resources/zh_CN/element/string.json
+++ b/mobiledatasettings/src/main/resources/zh_CN/element/string.json
@@ -6,7 +6,7 @@
},
{
"name": "mainability_description",
- "value": "JS_Empty Ability"
+ "value": "移动网络设置"
},
{
"name": "mobile_data",
diff --git a/package.json b/package.json
index 8d390cd..e4f29ff 100644
--- a/package.json
+++ b/package.json
@@ -11,8 +11,8 @@
"repository":{},
"version":"1.0.0",
"dependencies":{
- "@ohos/hvigor-ohos-plugin":"1.1.3",
- "hypium":"^1.0.0",
- "@ohos/hvigor":"1.1.3"
+ "@ohos/hypium":"1.0.2",
+ "@ohos/hvigor-ohos-plugin":"1.2.2",
+ "@ohos/hvigor":"1.2.2"
}
}
\ No newline at end of file
diff --git a/signature/OpenHarmony.p12 b/signature/OpenHarmony.p12
index 6962b1f..b48d853 100644
Binary files a/signature/OpenHarmony.p12 and b/signature/OpenHarmony.p12 differ
diff --git a/signature/com_ohos_Callui.p7b b/signature/com_ohos_Callui.p7b
index 4469c98..76ca9ad 100644
Binary files a/signature/com_ohos_Callui.p7b and b/signature/com_ohos_Callui.p7b differ