20170123 熱更新優化
一、給每一個hot uopdate 產生的事件增長一個 listen
addEventListener 的 function 第一個參數老是 isTrusted:false,
第二個參數總數 undefined,以上 listen 無法統一在一塊兒
待之後處理 addEventListener 的 function 參數
二、第一輪: apk 和 www 內容徹底同樣
sudo cordova-hcp build
sudo cordova build android
copy www 到 http://192.168.1.103/hot20170113/www
sudo cordova run android
查看 logcat ,收到 chcp_nothingToUpdate,正常!logcat信息以下
01-23 15:21:43.224: I/chromium(5088): [INFO:CONSOLE(72)] "收到事件 444666 events ===={"isTrusted":false}", source: file:///android_asset/www/js/index.js (72)
01-23 15:21:43.224: I/chromium(5088): [INFO:CONSOLE(73)] "收到事件 444666 events ====undefined", source: file:///android_asset/www/js/index.js (73)
01-23 15:21:43.224: I/chromium(5088): [INFO:CONSOLE(74)] "收到事件 chcp_nothingToUpdate ====", source: file:///android_asset/www/js/index.js (74)
三、修改 index.html,
sudo cordova-hcp build
copy www 到 http://192.168.1.103/hot20170113/www
在手機退出程序,再次運行剛纔的 app
查看 logcat ,收到 chcp_updateIsReadyToInstall,正常!logcat信息以下
01-23 15:25:45.214: I/chromium(5088): [INFO:CONSOLE(86)] "收到事件 777666 events ===={"isTrusted":false}", source: file:///data/user/0/io.cordova.hellocordova/files/cordova-hot-code-push-plugin/2017.01.23-15.19.42/www/js/index.js (86)
01-23 15:25:45.214: I/chromium(5088): [INFO:CONSOLE(87)] "收到事件 777666 events ====undefined", source: file:///data/user/0/io.cordova.hellocordova/files/cordova-hot-code-push-plugin/2017.01.23-15.19.42/www/js/index.js (87)
01-23 15:25:45.214: I/chromium(5088): [INFO:CONSOLE(88)] "收到事件 chcp_updateIsReadyToInstall ====", source: file:///data/user/0/io.cordova.hellocordova/files/cordova-hot-code-push-plugin/2017.01.23-15.19.42/www/js/index.js (88)
四、退出app,再次進來app
** 如今 app 已經 update 到和 www 內容徹底同樣
查看 logcat ,收到 chcp_nothingToUpdate,正常!logcat信息以下
01-23 15:28:49.636: I/chromium(5088): [INFO:CONSOLE(72)] "收到事件 444666 events ===={"isTrusted":false}", source: file:///data/user/0/io.cordova.hellocordova/files/cordova-hot-code-push-plugin/2017.01.23-15.25.31/www/js/index.js (72)
01-23 15:28:49.636: I/chromium(5088): [INFO:CONSOLE(73)] "收到事件 444666 events ====undefined", source: file:///data/user/0/io.cordova.hellocordova/files/cordova-hot-code-push-plugin/2017.01.23-15.25.31/www/js/index.js (73)
01-23 15:28:49.636: I/chromium(5088): [INFO:CONSOLE(74)] "收到事件 chcp_nothingToUpdate ====", source: file:///data/user/0/io.cordova.hellocordova/files/cordova-hot-code-push-plugin/2017.01.23-15.25.31/www/js/index.js (74)
五、計劃在 chcp_updateIsReadyToInstall 事件後,彈出提示,主動退出 app
*** 待下次處理