| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- let MiddleUpdate = require('MiddleUpdate');
- cc.Class({
- extends: MiddleUpdate,
- doCommand (params) {
- params.module = 'update';
- let paramsStr = JSON.stringify(params);
- let className = 'com/jiami/bridge/GameToJava';
- let methodName = 'doCommand';
- let sig = '(Ljava/lang/String;)Ljava/lang/String;';
- let resultStr = jsb.reflection.callStaticMethod(className, methodName, sig, paramsStr);
- let result = JSON.parse(resultStr);
- return result;
- },
- isSupportUpdate () {
- let ret = this.doCommand({
- sdkName: this.getSdkName(),
- cmd: 'isSupportUpdate'
- });
- return (ret.code == 200 && ret.result) ? ret.result.value : false;
- },
- isDidDownload () {
- let ret = this.doCommand({
- sdkName: this.getSdkName(),
- cmd: 'isDidDownload'
- });
- return (ret.code == 200 && ret.result) ? ret.result.value : false;
- },
- pauseDownload () {
- this.doCommand({
- sdkName: this.getSdkName(),
- cmd: 'pauseDownload'
- });
- },
- resumeDownload () {
- this.doCommand({
- sdkName: this.getSdkName(),
- cmd: 'resumeDownload'
- });
- },
- isDownloading () {
- let ret = this.doCommand({
- sdkName: this.getSdkName(),
- cmd: 'isDownloading'
- });
- return (ret.code == 200 && ret.result) ? ret.result.value : false;
- },
- download (newAppUrl, newAppMd5) {
- let ret = this.doCommand({
- sdkName: this.getSdkName(),
- cmd: 'download',
- args: {
- newAppUrl: newAppUrl,
- newAppMd5: newAppMd5
- }
- });
- return (ret.code == 200 && ret.result) ? ret.result.value : false;
- },
- install () {
- let ret = this.doCommand({
- sdkName: this.getSdkName(),
- cmd: 'install'
- });
- return (ret.code == 200 && ret.result) ? ret.result.value : false;
- },
- getDownloadedPath (newAppUrl, newAppMd5) {
- let ret = this.doCommand({
- sdkName: this.getSdkName(),
- cmd: 'getDownloadedPath',
- args: {
- newAppUrl: newAppUrl,
- newAppMd5: newAppMd5
- }
- });
- return (ret.code == 200 && ret.result) ? ret.result.value : '';
- },
- getCurProgress () {
- let ret = this.doCommand({
- sdkName: this.getSdkName(),
- cmd: 'getCurProgress'
- });
- return (ret.code == 200 && ret.result) ? ret.result.value : 0;
- },
- setWifiOnlyDownload (wifiOnly) {
- this.doCommand({
- sdkName: this.getSdkName(),
- cmd: 'setWifiOnlyDownload',
- args: {
- wifiOnly: wifiOnly
- }
- });
- },
- setSilenceDownload (silence) {
- this.doCommand({
- sdkName: this.getSdkName(),
- cmd: 'setSilenceDownload',
- args: {
- silence: silence
- }
- });
- },
- deleteDownloadedApk () {
- let ret = this.doCommand({
- sdkName: this.getSdkName(),
- cmd: 'deleteDownloadedApk'
- });
- return (ret.code == 200 && ret.result) ? ret.result.value : false;
- }
- });
|