@@ -9,6 +9,7 @@ export const modDir = '/data/adb/modules/KPatch-Next';
99export const persistDir = '/data/adb/kp-next' ;
1010
1111export let superkey = localStorage . getItem ( 'kp-next_superkey' ) || '' ;
12+ export let MAX_CHUNK_SIZE = 96 * 1024 ;
1213
1314async function updateStatus ( ) {
1415 const version = await patchModule . getInstalledVersion ( ) ;
@@ -64,7 +65,7 @@ function updateBtnState(value) {
6465}
6566
6667export function initInfo ( ) {
67- exec ( 'uname -r && getprop ro.build.version.release && getprop ro.build.fingerprint && getenforce' ) . then ( ( result ) => {
68+ return exec ( 'uname -r && getprop ro.build.version.release && getprop ro.build.fingerprint && getenforce' ) . then ( ( result ) => {
6869 if ( import . meta. env . DEV ) { // vite debug
6970 result . stdout = '6.18.2-linux\n16\nLinuxPC\nEnforcing'
7071 }
@@ -84,6 +85,18 @@ async function reboot(reason = "") {
8485 exec ( `/system/bin/svc power reboot ${ reason } || /system/bin/reboot ${ reason } ` ) ;
8586}
8687
88+ function getMaxChunkSize ( ) {
89+ exec ( 'getconf ARG_MAX' ) . then ( ( result ) => {
90+ try {
91+ const max_arg = parseInt ( result . stdout . trim ( ) ) ;
92+ if ( ! isNaN ( max_arg ) ) {
93+ // max_arg * 0.75 (base64 size increase) - command length
94+ MAX_CHUNK_SIZE = Math . floor ( max_arg * 0.75 ) - 1024 ;
95+ }
96+ } catch ( e ) { }
97+ } ) ;
98+ }
99+
87100document . addEventListener ( 'DOMContentLoaded' , async ( ) => {
88101 document . querySelectorAll ( '[unresolved]' ) . forEach ( el => el . removeAttribute ( 'unresolved' ) ) ;
89102 const splash = document . getElementById ( 'splash' ) ;
@@ -169,9 +182,8 @@ document.addEventListener('DOMContentLoaded', async () => {
169182 kpmModule . refreshKpmList ( ) ;
170183 }
171184
172- updateStatus ( ) ;
173185 updateBtnState ( superkey ) ;
174- initInfo ( ) ;
186+ getMaxChunkSize ( ) ;
175187 excludeModule . initExcludePage ( ) ;
176188 kpmModule . initKPMPage ( ) ;
177189
0 commit comments