Commit 7ffe7ac4 authored by Sky's avatar Sky

~

parent 93ab5b42
...@@ -13,7 +13,7 @@ ohos { ...@@ -13,7 +13,7 @@ ohos {
signAlg 'SHA256withECDSA' signAlg 'SHA256withECDSA'
} }
} }
compileSdkVersion 3 compileSdkVersion 4
defaultConfig { defaultConfig {
compatibleSdkVersion 3 compatibleSdkVersion 3
} }
...@@ -30,7 +30,7 @@ buildscript { ...@@ -30,7 +30,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.huawei.ohos:hap:2.0.0.6' classpath 'com.huawei.ohos:hap:2.4.1.4'
} }
} }
......
...@@ -6,9 +6,9 @@ ohos { ...@@ -6,9 +6,9 @@ ohos {
certpath file('D:/HuaweiWatchClient/com.company.fit.overseas_debug.cer') certpath file('D:/HuaweiWatchClient/com.company.fit.overseas_debug.cer')
profile file('D:/HuaweiWatchClient/com.company.fit.proDebug.p7b') profile file('D:/HuaweiWatchClient/com.company.fit.proDebug.p7b')
signAlg 'SHA256withECDSA' signAlg 'SHA256withECDSA'
keyPassword '0000001B9E576AD11A22A05641A642CA17ED844BB71D8027C1ACF79F928F7C1EA950008D8C70ADDF7E8429' keyPassword '0000001B17F8F53E0CF14D52675968C4FD60AA48E6580B4EEEE4AE8348FA556850E01CC92EEA6DE834CA36'
keyAlias 'huawei_watch_overseas Release' keyAlias 'huawei_watch_overseas Release'
storePassword '0000001B3F89F001102D6FF1A0BB38E371027272283910D107D7F11A763F26295938F1A4E704A7F054C552' storePassword '0000001B16A4C8B18003852BF6E890B38F6D624C8314D7E55CE2FD87CBC3F2C9E2DA9403C977F0C988ABAE'
storeFile file('D:/HuaweiWatchClient/huawei_watch_overseas.p12') storeFile file('D:/HuaweiWatchClient/huawei_watch_overseas.p12')
} }
release { release {
...@@ -21,7 +21,8 @@ ohos { ...@@ -21,7 +21,8 @@ ohos {
certpath file('D:/HuaweiWatchClient/com.company.fit.overseas_release.cer') certpath file('D:/HuaweiWatchClient/com.company.fit.overseas_release.cer')
} }
} }
compileSdkVersion 3 mergeJsSrc true
compileSdkVersion 4
defaultConfig { defaultConfig {
compatibleSdkVersion 3 compatibleSdkVersion 3
} }
......
...@@ -2,18 +2,19 @@ ...@@ -2,18 +2,19 @@
"app": { "app": {
"bundleName": "com.company.fit", "bundleName": "com.company.fit",
"version": { "version": {
"code": 15, "code": 20,
"name": "1.0.1" "name": "1.0.2"
}, },
"apiVersion": { "apiVersion": {
"compatible": 3, "compatible": 3,
"target": 3 "target": 4
} }
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"deviceType": [ "deviceType": [
"liteWearable" "liteWearable",
"wearable"
], ],
"abilities": [ "abilities": [
{ {
......
This diff is collapsed.
import brightness from '@system.brightness' //保持屏幕常亮 import brightness from '@system.brightness' //保持屏幕常亮
import app from '@system.app' //右滑退出 import app from '@system.app' //右滑退出
import router from '@system.router' //页面跳转 import router from '@system.router' //页面跳转
import {P2pClient} from '../wearengine'
// 步骤1:创建点对点通信对象
var p2pClient = new P2pClient();
export default { export default {
data: { data: {
...@@ -31,7 +35,10 @@ export default { ...@@ -31,7 +35,10 @@ export default {
}, },
onDestroy() { onDestroy() {
//取消接收手机侧第三方应用发过来的消息 //取消接收手机侧第三方应用发过来的消息
FeatureAbility.unsubscribeMsg(); p2pClient.unregisterReceiver({
onSuccess: function () {
},
});
}, },
start(msg) { start(msg) {
let _this = this; let _this = this;
...@@ -52,13 +59,19 @@ export default { ...@@ -52,13 +59,19 @@ export default {
*/ */
getMsg() { getMsg() {
let _this = this; let _this = this;
FeatureAbility.subscribeMsg({ // 步骤4:接收手机侧第三方应用发过来的简短消息或文件
success: function (data) { var receiver = {
_this.start(JSON.parse(data.message)); onSuccess: function () {
// 处理注册接收手机侧简短消息或文件成功的回调函数
}, },
fail: function (data, code) { onFailure: function () {
} // 处理注册接收手机侧简短消息或文件失败的回调函数
}); },
onReceiveMessage: function (data) {
_this.start(JSON.parse(data));
},
}
p2pClient.registerReceiver(receiver);
}, },
/** /**
......
...@@ -4,8 +4,13 @@ import brightness from '@system.brightness' //保持屏幕常亮 ...@@ -4,8 +4,13 @@ import brightness from '@system.brightness' //保持屏幕常亮
import app from '@system.app' //右滑退出 import app from '@system.app' //右滑退出
import router from '@system.router' //页面跳转 import router from '@system.router' //页面跳转
import storage from '@system.storage' //本地数据 import storage from '@system.storage' //本地数据
import {P2pClient, Message, Builder} from '../wearengine'
var timer; var timer;
// 步骤1:创建点对点通信对象
var p2pClient = new P2pClient();
var builderClient = new Builder();
var sendMessage = new Message();
export default { export default {
data: { data: {
...@@ -31,6 +36,9 @@ export default { ...@@ -31,6 +36,9 @@ export default {
isFirstInit: true, //是否是第一次初始化事件 isFirstInit: true, //是否是第一次初始化事件
showPrivacy: true, //显示隐私权限页面 showPrivacy: true, //显示隐私权限页面
}, },
onInit() {
p2pClient.setPeerPkgName("com.sportq.fit");
},
onReady() { onReady() {
let _this = this; let _this = this;
//获取本地隐私权限标识 //获取本地隐私权限标识
...@@ -102,7 +110,10 @@ export default { ...@@ -102,7 +110,10 @@ export default {
}); });
this.quit(); this.quit();
//取消接收手机侧第三方应用发过来的消息 //取消接收手机侧第三方应用发过来的消息
FeatureAbility.unsubscribeMsg(); p2pClient.unregisterReceiver({
onSuccess: function () {
},
});
}, },
start(msg) { start(msg) {
let _this = this; let _this = this;
...@@ -323,16 +334,16 @@ export default { ...@@ -323,16 +334,16 @@ export default {
*/ */
checkInstall() { checkInstall() {
let _this = this; let _this = this;
FeatureAbility.detect({ p2pClient.ping({
bundleName: 'com.sportq.fit', onSuccess: function () {
success: function () { console.log('ping success.');
//已安装
}, },
fail: function (data, code) { onFailure: function () {
if (!data && !code) { //未安装 _this.page = "99";
_this.page = "99"; _this.isJumpLoginPage = false;
_this.isJumpLoginPage = false; },
} onPingResult: function (resultCode) {
console.log(resultCode.data + resultCode.code);
}, },
}); });
}, },
...@@ -344,19 +355,26 @@ export default { ...@@ -344,19 +355,26 @@ export default {
sendMsg(obj) { sendMsg(obj) {
let _this = this; let _this = this;
_this.sendFlg = true; _this.sendFlg = true;
FeatureAbility.sendMsg({ // 步骤4:发送简短消息到手机侧对应的第三方应用
deviceId: 'remote', builderClient.setDescription(JSON.stringify(obj));
bundleName: 'com.sportq.fit', sendMessage.builder = builderClient;
message: JSON.stringify(obj), // 定义回调函数
success: function () { var sendCallback = {
onSuccess: function () {
_this.sendFlg = false; _this.sendFlg = false;
console.log('sendMsg success.');
}, },
fail: function (data, code) { onFailure: function () {
_this.sendFlg = false; _this.sendFlg = false;
console.log('handing fail, message: ' + data + ', code: ' + code); },
} onSendResult: function (resultCode) {
}); // send任务执行结束后返回的错误码和信息进行处理
console.log(resultCode.data + resultCode.code);
},
}
if (sendMessage != null && sendCallback != null) {
p2pClient.send(sendMessage, sendCallback);
}
;
}, },
/** /**
...@@ -364,15 +382,23 @@ export default { ...@@ -364,15 +382,23 @@ export default {
*/ */
sendHeartRateMsg(obj) { sendHeartRateMsg(obj) {
let _this = this; let _this = this;
FeatureAbility.sendMsg({ // 步骤4:发送简短消息到手机侧对应的第三方应用
deviceId: 'remote', builderClient.setDescription(JSON.stringify(obj));
bundleName: 'com.sportq.fit', sendMessage.builder = builderClient;
message: JSON.stringify(obj), // 定义回调函数
success: function () { var sendCallback = {
onSuccess: function () {
}, },
fail: function (data, code) { onFailure: function () {
} },
}); onSendResult: function (resultCode) {
console.log(resultCode.data + resultCode.code);
},
}
if (sendMessage != null && sendCallback != null) {
p2pClient.send(sendMessage, sendCallback);
}
;
}, },
/** /**
...@@ -394,13 +420,19 @@ export default { ...@@ -394,13 +420,19 @@ export default {
*/ */
getMsg() { getMsg() {
let _this = this; let _this = this;
FeatureAbility.subscribeMsg({ // 步骤4:接收手机侧第三方应用发过来的简短消息或文件
success: function (data) { var receiver = {
_this.start(JSON.parse(data.message)); onSuccess: function () {
// 处理注册接收手机侧简短消息或文件成功的回调函数
}, },
fail: function (data, code) { onFailure: function () {
} // 处理注册接收手机侧简短消息或文件失败的回调函数
}); },
onReceiveMessage: function (data) {
_this.start(JSON.parse(data));
},
}
p2pClient.registerReceiver(receiver);
} }
, ,
...@@ -523,7 +555,10 @@ export default { ...@@ -523,7 +555,10 @@ export default {
this.progress = "", //进度条 this.progress = "", //进度条
this.countdownT = "", // 倒计时 this.countdownT = "", // 倒计时
//取消接收手机侧第三方应用发过来的消息 //取消接收手机侧第三方应用发过来的消息
FeatureAbility.unsubscribeMsg(); p2pClient.unregisterReceiver({
onSuccess: function () {
},
});
sensor.unsubscribeHeartRate() //取消监听心率 sensor.unsubscribeHeartRate() //取消监听心率
}, },
......
This diff is collapsed.
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
File added
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment