From 89eee84a1fd960b8b560b6905df3ddbf95e4b78e Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Mon, 27 Apr 2020 12:40:59 +0100 Subject: [PATCH] start remove compatible apps --- lib/inquirer.js | 1 + pages/pages.js | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/lib/inquirer.js b/lib/inquirer.js index 94a129e..a932aa7 100644 --- a/lib/inquirer.js +++ b/lib/inquirer.js @@ -15,6 +15,7 @@ module.exports = { "Remove Xiaomi Apps", "Restore Xiaomi Apps", "Install Compatible Apps", + "Remove Compatible Apps", "Quit" ], filter: function (val) { diff --git a/pages/pages.js b/pages/pages.js index 922c067..7d362e7 100644 --- a/pages/pages.js +++ b/pages/pages.js @@ -13,6 +13,60 @@ var shell = require('shelljs'); module.exports = { + removeCompatibleApps: async () => { + common.header('Remove Compatible Apps') + let compatibleApps + let url = "http://kithub.cf/Karl/MiWatchKleaner-APKs/raw/master/compatibleApps.json"; + http.get(url, (res) => { + let body = ""; + + res.on("data", (chunk) => { + body += chunk; + }); + + res.on("end", () => { + try { + compatibleApps = JSON.parse(body); + // do something with JSON + } catch (error) { + console.error(error.message); + }; + }); + + }).on("error", (error) => { + console.error(error.message); + }); + + const value = await inquirer.compatibleApps(); + + const apkList = await getFilesIn('./data/apps', matchFiletypes = ['apk'], checkSubDirectories = false) + + for (let element of apkList) { + console.log('Installing ' + element) + if (process.platform === 'win32' || process.platform === 'win64') { + await shellExec('adb install -r ' + element).then(async function (result) { + console.log(element + ' - ' + result.stdout); + if (element === "data\\apps\\MoreLocale.apk") { + await shellExec('adb shell pm grant jp.co.c_lis.ccl.morelocale android.permission.CHANGE_CONFIGURATION').then(function (result) { + console.log('moreLocale Activated On Watch'); + }); + } + }); + } else { + await shellExec('./adb install -r ' + element).then(async function (result) { + console.log(element + ' - ' + result.stdout); + if (element === "data\\apps\\MoreLocale.apk") { + await shellExec('./adb shell pm grant jp.co.c_lis.ccl.morelocale android.permission.CHANGE_CONFIGURATION').then(function (result) { + console.log('moreLocale Activated On Watch'); + }); + } + }); + } + } + console.log(chalk.green('Compatible Apps Installed')) + await common.pause(2000) + module.exports.mainMenu() + }, compatibleApps: async () => { common.header('Install Compatible Apps') let compatibleApps @@ -205,6 +259,9 @@ module.exports = { case 'install compatible apps': module.exports.compatibleApps() break; + case 'remove compatible apps' : + module.exports.removeCompatibleApps() + break; case 'quit': break; default: