Skip to content
This repository has been archived by the owner on Jul 18, 2023. It is now read-only.

Get installed yt/ytm version when building on rooted android #343

Merged
merged 1 commit into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion utils/getAppVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const actualExec = promisify(exec);
module.exports = async function (pkgName, ws, shouldReturnMSG) {
try {
const { stdout, stderr } = await actualExec(
`adb -s ${global.jarNames.deviceID} shell dumpsys package ${pkgName}`,
os.platform() !== 'android'
? `adb -s ${global.jarNames.deviceID} shell dumpsys package ${pkgName}`
: `su -c dumpsys package ${pkgName}`,
{ maxBuffer: 10240 * 1024 }
);
const dumpSysOut = stdout || stderr;
Expand Down
38 changes: 21 additions & 17 deletions wsEvents/GetAppVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,32 @@ async function getPage (pageUrl) {
module.exports = async function (message, ws) {
let versionsList;

if (global.jarNames.isRooted && os.platform() !== 'android') {
if (!global.jarNames.deviceID) {
return ws.send(
JSON.stringify({
event: 'error',
error:
"You either don't have a device plugged in or don't have ADB installed."
})
);
}

actualExec(`adb -s ${global.jarNames.deviceID} shell su -c exit`).catch(
() => {
if (global.jarNames.isRooted) {
let pkgName;
if (os.platform() !== 'android') {
if (!global.jarNames.deviceID) {
return ws.send(
JSON.stringify({
event: 'error',
error:
'The plugged in device is not rooted or Shell was denied root access. If you didn\'t intend on doing a rooted build, include all "Root required to exclude" patches'
"You either don't have a device plugged in or don't have ADB installed."
})
);
}
);

let pkgName;
actualExec(`adb -s ${global.jarNames.deviceID} shell su -c exit`).catch(
() => {
return ws.send(
JSON.stringify({
event: 'error',
error:
'The plugged in device is not rooted or Shell was denied root access. If you didn\'t intend on doing a rooted build, include all "Root required to exclude" patches'
})
);
}
);
}

switch (global.jarNames.selectedApp) {
case 'youtube': {
pkgName = 'com.google.android.youtube';
Expand All @@ -60,7 +62,9 @@ module.exports = async function (message, ws) {

if (global.jarNames.selectedApp === 'music') {
const deviceArch = await actualExec(
`adb -s ${global.jarNames.deviceID} shell getprop ro.product.cpu.abi`
os.platform() !== 'android'
? `adb -s ${global.jarNames.deviceID} shell getprop ro.product.cpu.abi`
: `getprop ro.product.cpu.abi`
);
global.apkInfo = {
version: appVersion,
Expand Down