diff --git a/lib/inquirer.js b/lib/inquirer.js index 14ce38f..f06465f 100644 --- a/lib/inquirer.js +++ b/lib/inquirer.js @@ -15,7 +15,7 @@ module.exports = { "Remove Xiaomi Apps", "Restore Xiaomi Apps", "Install Compatible Apps", - // "Remove Compatible Apps", + "Remove Installed Apps", "Quit" ], filter: function (val) { @@ -57,6 +57,15 @@ module.exports = { }, ]; return inquirer.prompt(questions); }, + installedApps: async (installedApps) => { + const questions = [{ + type: "checkbox", + name: "removeAppsList", + message: "What Installed apps do you want to remove?", + choices: installedApps, + }, ]; + return inquirer.prompt(questions); + }, getCompatibleApps: async () => { var options = { method: 'GET', diff --git a/package.json b/package.json index d0dca46..2a7d271 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "miwatchkleaner2.0", - "version": "2.0.1", + "version": "2.0.2", "description": "MiWatch Cleaning Tool", "main": "app.js", "bin": "app.js", diff --git a/pages/pages.js b/pages/pages.js index 17ab6df..d8a667d 100644 --- a/pages/pages.js +++ b/pages/pages.js @@ -15,41 +15,22 @@ let adbRun 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); + let installedAppList + common.header('Remove Installed Apps') + await shellExec(adbRun + ' shell pm list packages -3').then(async function (result) { + installedAppList = result.stdout.split('\r\n'); // split string on comma space + installedAppList.splice(-1, 1) }); - const value = await inquirer.compatibleApps(); + const value = await inquirer.installedApps(installedAppList); + for (let element of value.removeAppsList) { - console.log('Installing ' + element) - await shellExec(adbRun + ' install -r ' + element).then(async function (result) { + console.log('Removing ' + element) + const package = element.substring(8) + await shellExec(adbRun + ' uninstall ' + package).then(async function (result) { console.log(element + ' - ' + result.stdout); - if (element === "data\\apps\\MoreLocale.apk") { - await shellExec(adbRun + ' 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')) + console.log(chalk.green('Removed Selected User Apps')) await common.pause(2000) module.exports.mainMenu() }, @@ -193,7 +174,7 @@ module.exports = { case 'install compatible apps': module.exports.compatibleApps() break; - case 'remove compatible apps': + case 'remove installed apps': module.exports.removeCompatibleApps() break; case 'quit':