Skip to content

Commit

Permalink
Merge branch 'reisxd:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
inotia00 authored Mar 26, 2023
2 parents 23ca55d + 898bb48 commit 8449fe1
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
sudo apt -y update
sudo apt -y upgrade
sudo apt -y install nodejs
sudo curl -Lo /usr/bin/ldid https://github.com/ProcursusTeam/ldid/releases/download/v2.1.5-procursus2/ldid_linux_x86_64
sudo curl -Lo /usr/bin/ldid https://github.com/ProcursusTeam/ldid/releases/download/v2.1.5-procursus7/ldid_linux_x86_64
sudo chmod a+rwx /usr/bin/ldid
- name: Clone repo
uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Clone the repository and `cd` into the directory `revanced-builder`
### Build using `docker-compose`

```bash
docker-compose build --no-cache
docker-compose build --pull --no-cache
```

This builds the Docker image (`--no-cache` is used to build the image from scratch; sometimes the cache might cause version conflicts).
Expand All @@ -53,7 +53,7 @@ To update to a newer version, stop the existing container if it is running, buil
### Build using only `docker`

```bash
docker build . -t <name_of_the_image> --no-cache
docker build . --pull -t <name_of_the_image> --no-cache
```

Run the newly built container:
Expand Down
45 changes: 42 additions & 3 deletions public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,36 @@ ws.onmessage = (msg) => {
};
}
break;
case 'installingStockApp': {
if (message.status === 'DOWNLOAD_STARTED') {
document.getElementsByTagName('header')[0].innerHTML =
'<h1><i class="fa-solid fa-download"></i>Downloading APK</h1>';
document.getElementById('content').innerHTML =
'<span class="log"></span>';
document.getElementsByTagName('main')[0].innerHTML +=
'<progress value="0"></progress>';
isDownloading = true;
document.getElementById('continue').classList.add('disabled');
} else if (message.status === 'DOWNLOAD_COMPLETE') {
document.getElementById('continue').classList.add('disabled');
isDownloading = false;
document.getElementsByClassName(
'log'
)[0].innerHTML += `<span class="log-line info"><strong>[builder]</strong> Uninstalling the stock app...</span><br>`;
} else if (message.status === 'UNINSTALL_COMPLETE') {
document.getElementsByClassName(
'log'
)[0].innerHTML += `<span class="log-line info"><strong>[builder]</strong> Installing the downloaded (stock) APK...</span><br>`;
} else if (message.status === 'ALL_DONE') {
document.getElementsByClassName(
'log'
)[0].innerHTML += `<span class="log-line info"><strong>[builder]</strong> Complete.</span><br>`;
document.getElementById('continue').classList.remove('disabled');
document.getElementById('continue').onclick = () => {
location.href = '/patch';
};
}
}
case 'patchLog':
{
const logLevel = message.log.includes('WARNING')
Expand Down Expand Up @@ -525,12 +555,21 @@ ws.onmessage = (msg) => {
}
case 'askRootVersion': {
const confirmVer = confirm(
`**Non Recommended Version**\nYour device has an non recommended version, do you want to patch it?`
`**Non Recommended Version**\nYour device has a non recommended version. This means you have to let the builder replace the stock YouTube with a recommended version.\nContinue?`
);

if (confirmVer)
return sendCommand({ event: 'getAppVersion', useVer: true });
else return sendCommand({ event: 'getAppVersion' });
return sendCommand({
event: 'getAppVersion',
installLatestRecommended: true
});
else {
if (confirm('Alright, proceed with the non-recommended version?'))
return sendCommand({
event: 'getAppVersion',
useVer: true
});
}
}

case 'appList': {
Expand Down
2 changes: 1 addition & 1 deletion wsEvents/checkForUpdates.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { getDownloadLink } = require('../utils/FileDownloader.js');

const currentVersion = 'v3.8.0';
const currentVersion = 'v3.9.0';

/**
* @param {import('ws').WebSocket} ws
Expand Down
69 changes: 69 additions & 0 deletions wsEvents/getAppVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const exec = require('../utils/promisifiedExec.js');
const fetch = require('node-fetch');
const { load } = require('cheerio');
const semver = require('semver');
const { join: joinPath } = require('path');

const { getAppVersion: getAppVersion_ } = require('../utils/getAppVersion.js');
const { downloadApp: downloadApp_ } = require('../utils/downloadApp.js');
Expand All @@ -29,6 +30,68 @@ async function getPage(url) {
return fetch(url).then((res) => res.text());
}

async function installRecommendedStock(ws, dId) {
try {
const latestVer = global.versions[global.versions.length - 1];
global.apkInfo.version = latestVer;
ws.send(
JSON.stringify({
event: 'installingStockApp',
status: 'DOWNLOAD_STARTED'
})
);
await downloadApp_(ws);
const downloadedApkPath = `${joinPath(
global.revancedDir,
global.jarNames.selectedApp.packageName
)}.apk`;
ws.send(
JSON.stringify({
event: 'installingStockApp',
status: 'DOWNLOAD_COMPLETE'
})
);
if (dId === 'CURRENT_DEVICE') {
await exec(
`su -c pm uninstall ${global.jarNames.selectedApp.packageName}`
);
ws.send(
JSON.stringify({
event: 'installingStockApp',
status: 'UNINSTALL_COMPLETE'
})
);
await exec(`su -c pm install ${downloadedApkPath}`);
} else {
ws.send(
JSON.stringify({
event: 'installingStockApp',
status: 'UNINSTALL_COMPLETE'
})
);
await exec(
`adb -s ${dId} uninstall ${global.jarNames.selectedApp.packageName}`
);
await exec(`adb -s ${dId} install ${downloadedApkPath}`);
}
ws.send(
JSON.stringify({
event: 'installingStockApp',
status: 'ALL_DONE'
})
);
} catch (_) {
return ws.send(
JSON.stringify({
event: 'error',
error: `An error occured while trying to install the stock app${
dId !== 'CURRENT_DEVICE' ? ` for device ID ${dId}` : ''
}.\nPlease install the recommended version manually and run Builder again.`
})
);
}
}

async function downloadApp(ws, message) {
if (message.useVer) return await downloadApp_(ws);
else if (message.checkVer) {
Expand All @@ -40,6 +103,12 @@ async function downloadApp(ws, message) {
event: 'askRootVersion'
})
);
} else if (message.installLatestRecommended) {
const useAdb =
process.platform !== 'android' && global.jarNames?.devices.length !== 0;
if (useAdb) {
for (const id of global.jarNames.devices) installRecommendedStock(ws, id);
} else installRecommendedStock(ws, 'CURRENT_DEVICE');
} else
return ws.send(
JSON.stringify({
Expand Down

0 comments on commit 8449fe1

Please sign in to comment.