forked from reisxd/revanced-builder
-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathinstallReVanced.js
142 lines (129 loc) · 3.71 KB
/
installReVanced.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
const { join: joinPath } = require('node:path');
const exec = require('../utils/promisifiedExec.js');
const { getAppVersion_ } = require('../utils/getAppVersion.js');
const { getDownloadLink } = require('../utils/FileDownloader.js');
const mountReVancedInstaller = require('../utils/mountReVancedInstaller.js');
module.exports = async function installReVanced(ws) {
if (
!global.jarNames.isRooted &&
global.jarNames.devices &&
global.jarNames.devices[0]
) {
for (const deviceId of global.jarNames.devices) {
ws.send(
JSON.stringify({
event: 'patchLog',
log: `INFO: Installing ReVanced (non-root) for ${deviceId}.`
})
);
try {
await exec(
`adb -s ${deviceId} install "${joinPath(
global.revancedDir,
global.outputName
)}"`
);
ws.send(
JSON.stringify({
event: 'patchLog',
log: `INFO: Installed ReVanced (non-root) for ${deviceId}.`
})
);
} catch (e) {
ws.send(
JSON.stringify({
event: 'patchLog',
log: `SEVERE: Could not install ReVanced to ${deviceId}. Please check the console for more info.`
})
);
throw e;
}
}
} else if (
global.jarNames.isRooted &&
global.jarNames.devices &&
global.jarNames.devices[0]
) {
for (const deviceId of global.jarNames.devices) {
ws.send(
JSON.stringify({
event: 'patchLog',
log: `INFO: Installing ReVanced (root) for ${deviceId}.`
})
);
try {
mountReVancedInstaller(deviceId);
ws.send(
JSON.stringify({
event: 'patchLog',
log: `INFO: Installed ReVanced (root) for ${deviceId}.`
})
);
} catch (e) {
ws.send(
JSON.stringify({
event: 'patchLog',
log: `SEVERE: Could not install ReVanced to ${deviceId}. Please check the console for more info.`
})
);
throw e;
}
}
}
if (
!global.jarNames.isRooted &&
global.jarNames.devices &&
global.jarNames.devices[0] &&
(global.jarNames.selectedApp.packageName === 'com.google.android.youtube' ||
global.jarNames.selectedApp.packageName ===
'com.google.android.apps.youtube.music')
) {
const currentMicroGVersion = (
await getDownloadLink({ owner: 'TeamVanced', repo: 'VancedMicroG' })
).version
.replace('v', '')
.split('-')[0];
for (const deviceId of global.jarNames.devices) {
const microGVersion = await getAppVersion_(
'com.mgoogle.android.gms',
null,
false,
deviceId
);
if (!microGVersion || microGVersion !== currentMicroGVersion) {
try {
await exec(`adb -s ${deviceId} install "${global.jarNames.microG}"`);
ws.send(
JSON.stringify({
event: 'patchLog',
log: `INFO: MicroG has been ${
!microGVersion ? 'installed' : 'updated'
} for device ${deviceId}.`
})
);
} catch (e) {
ws.send(
JSON.stringify({
event: 'patchLog',
log: `SEVERE: Could not ${
!microGVersion ? 'install' : 'update'
} MicroG for device ${deviceId}. Please check the console for more info.`
})
);
throw e;
}
} else
ws.send(
JSON.stringify({
event: 'patchLog',
log: `MicroG is already up to date for device ${deviceId}`
})
);
}
}
return ws.send(
JSON.stringify({
event: 'buildFinished'
})
);
};