55import android .content .res .Resources ;
66import android .graphics .Color ;
77import android .graphics .drawable .ColorDrawable ;
8+ import android .os .Build ;
89import android .os .Bundle ;
910import android .util .Log ;
1011import android .view .KeyEvent ;
3738import java .io .IOException ;
3839import java .io .OutputStream ;
3940import java .util .zip .ZipEntry ;
41+ import java .util .zip .ZipFile ;
4042import java .util .zip .ZipInputStream ;
4143
4244public class InstallerActivity extends CompatActivity {
@@ -87,8 +89,8 @@ protected void onCreate(Bundle savedInstanceState) {
8789 boolean urlMode = target .startsWith ("http://" ) || target .startsWith ("https://" );
8890 getWindow ().addFlags (WindowManager .LayoutParams .FLAG_KEEP_SCREEN_ON );
8991 setTitle (name );
90- setContentView (( this .textWrap =
91- MainApplication . isTextWrapEnabled ()) ?
92+ this .textWrap = MainApplication . isTextWrapEnabled ();
93+ setContentView ( this . textWrap ?
9294 R .layout .installer_wrap :R .layout .installer );
9395 int background ;
9496 int foreground ;
@@ -252,6 +254,30 @@ private void doInstall(File file,boolean noExtensions,boolean rootless) {
252254 " /dev/null 1 \" " + file .getAbsolutePath () + "\" " )
253255 .to (installerController , installerMonitor );
254256 } else {
257+ String arch32 = "true" ; // Do nothing by default
258+ if (Build .SUPPORTED_32_BIT_ABIS .length == 0 ) {
259+ boolean needs32bit = false ;
260+ try (ZipFile zipFile = new ZipFile (file )) {
261+ if (zipFile .getEntry ( // Check if module hard require 32bit support
262+ "common/addon/Volume-Key-Selector/tools/arm64/keycheck" ) == null &&
263+ zipFile .getEntry (
264+ "common/addon/Volume-Key-Selector/install.sh" ) != null ) {
265+ needs32bit = true ;
266+ }
267+ } catch (IOException ignored ) {}
268+ if (needs32bit ) {
269+ this .setInstallStateFinished (false ,
270+ "! This module can't be installed on a 64bit only system" ,
271+ null );
272+ return ;
273+ }
274+ } else {
275+ // Restore Magisk legacy stuff for retro compatibility
276+ if (Build .SUPPORTED_32_BIT_ABIS [0 ].contains ("arm" ))
277+ arch32 = "export ARCH32=arm" ;
278+ if (Build .SUPPORTED_32_BIT_ABIS [0 ].contains ("x86" ))
279+ arch32 = "export ARCH32=x86" ;
280+ }
255281 String installCommand ;
256282 File installExecutable ;
257283 if (InstallerInitializer .peekMagiskVersion () >=
@@ -272,11 +298,11 @@ private void doInstall(File file,boolean noExtensions,boolean rootless) {
272298 }
273299 installerMonitor = new InstallerMonitor (installExecutable );
274300 if (noExtensions ) {
275- installJob = Shell .su ( // No Extensions
301+ installJob = Shell .su (arch32 , // No Extensions
276302 "cd \" " + this .moduleCache .getAbsolutePath () + "\" " ,
277303 installCommand ).to (installerController , installerMonitor );
278304 } else {
279- installJob = Shell .su ("export MMM_EXT_SUPPORT=1" ,
305+ installJob = Shell .su (arch32 , "export MMM_EXT_SUPPORT=1" ,
280306 "export MMM_USER_LANGUAGE=" + (MainApplication .isForceEnglish () ?
281307 "en-US" : Resources .getSystem ()
282308 .getConfiguration ().locale .toLanguageTag ()),
@@ -428,12 +454,14 @@ public boolean dispatchKeyEvent(KeyEvent event) {
428454
429455 public static class InstallerMonitor extends CallbackList <String > {
430456 private static final String DEFAULT_ERR = "! Install failed" ;
431- private final String installScriptPath ;
457+ private final String installScriptErr ;
432458 public String lastCommand = "" ;
433459
434460 public InstallerMonitor (File installScript ) {
435461 super (Runnable ::run );
436- this .installScriptPath = installScript .getAbsolutePath ();
462+ this .installScriptErr =
463+ installScript .getAbsolutePath () +
464+ ": /data/adb/modules_update/" ;
437465 }
438466
439467 @ Override
@@ -443,8 +471,7 @@ public void onAddElement(String s) {
443471 }
444472
445473 private String doCleanUp () {
446- String installScriptErr =
447- this .installScriptPath + ": /data/adb/modules_update/" ;
474+ String installScriptErr = this .installScriptErr ;
448475 // This block is mainly to help fixing customize.sh syntax errors
449476 if (this .lastCommand .startsWith (installScriptErr )) {
450477 installScriptErr = this .lastCommand .substring (installScriptErr .length ());
0 commit comments