├── assets └── xposed_init ├── README.md ├── ic_launcher-web.png ├── res ├── mipmap-hdpi │ └── ic_launcher.png ├── mipmap-mdpi │ └── ic_launcher.png ├── mipmap-xhdpi │ └── ic_launcher.png ├── mipmap-xxhdpi │ └── ic_launcher.png ├── mipmap-xxxhdpi │ └── ic_launcher.png ├── values │ ├── styles.xml │ └── strings.xml ├── values-zh-rCN │ └── strings.xml ├── values-zh-rTW │ └── strings.xml ├── values-ko │ └── strings.xml ├── values-ja │ └── strings.xml ├── values-hi │ └── strings.xml ├── values-cs │ └── strings.xml ├── values-in │ └── strings.xml ├── values-sk │ └── strings.xml ├── values-ru │ └── strings.xml ├── values-fa │ └── strings.xml ├── values-pt │ └── strings.xml ├── values-de │ └── strings.xml ├── values-hu │ └── strings.xml ├── values-it │ └── strings.xml ├── values-nl │ └── strings.xml ├── values-es │ └── strings.xml └── xml │ └── preferences.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .idea └── vcs.xml ├── .settings └── org.eclipse.jdt.core.prefs ├── .gitignore ├── .classpath ├── project.properties ├── proguard-project.txt ├── .project ├── src └── com │ └── pyler │ └── xinternalsd │ ├── Common.java │ ├── Preferences.java │ └── XInternalSD.java ├── LICENSE ├── AndroidManifest.xml ├── gradlew.bat └── gradlew /assets/xposed_init: -------------------------------------------------------------------------------- 1 | com.pyler.xinternalsd.XInternalSD -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # XInternalSD 2 | [Xposed module] Android Storage/SD card API tweaks 3 | -------------------------------------------------------------------------------- /ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pylerSM/XInternalSD/HEAD/ic_launcher-web.png -------------------------------------------------------------------------------- /res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pylerSM/XInternalSD/HEAD/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pylerSM/XInternalSD/HEAD/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pylerSM/XInternalSD/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pylerSM/XInternalSD/HEAD/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pylerSM/XInternalSD/HEAD/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pylerSM/XInternalSD/HEAD/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon May 09 12:07:16 IST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | # Log Files 26 | *.log 27 | 28 | .idea/ 29 | *.iml 30 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-23 15 | -------------------------------------------------------------------------------- /res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /res/values-zh-rCN/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 更改路径为内置储存卡 4 | 设置 5 | 自定义内置储存卡路径 6 | 内置储存卡路径 7 | 对某些应用启用 8 | 对所有应用启用 9 | 对某些应用禁用 10 | 输入内置储存卡的路径 11 | 对外置储存卡的完整权限 12 | 包含系统应用 13 | 需要重启设备才能生效 14 | 显示应用程序图标 15 | 16 | 17 | -------------------------------------------------------------------------------- /res/values-zh-rTW/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 變更內置SD卡路徑 4 | 設定 5 | 自訂內置SD卡路徑 6 | 內置SD卡路徑 7 | 僅套用部分應用程式 8 | 套用所有應用程式 9 | 對部分應用程式禁用 10 | 輸入內置SD卡路徑 11 | 取得外置SD卡完整讀寫權限 12 | 包含系統應用程式 13 | 設備重啟需要更改生效 14 | 顯示應用程序圖標 15 | 16 | 17 | -------------------------------------------------------------------------------- /res/values-ko/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 내부 스토리지의 경로를 변경합니다 4 | 설정 5 | 내부 스토리지의 경로 변경 6 | 변경 후의 내부 스토리지 경로 7 | 활성화 할 앱 8 | 모든 앱에 활성화 9 | 비활성화 할 앱 10 | 내부 스토리지의 경로를 입력하세요 11 | 외부 스토리지 접근 권한 활성화 12 | 시스템 앱 포함 13 | 변경 사항을 적용하려면 장치 재부팅이 필요합니다. 14 | 보기 응용 프로그램 아이콘 15 | 16 | -------------------------------------------------------------------------------- /res/values-ja/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 内部ストレージのパスを変更します 4 | 設定 5 | 内部ストレージパスの変更 6 | 変更後の内部ストレージパス 7 | 有効にするアプリの指定 8 | 全てのアプリで有効化 9 | 無効にするアプリの指定 10 | 内部ストレージパスを入力してください 11 | 外部ストレージへのフルアクセス 12 | システムアプリを含める 13 | 変更を有効にするにはデバイスの再起動が必要です。 14 | 表示するアプリケーションアイコン 15 | 16 | 17 | -------------------------------------------------------------------------------- /proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | XInternalSD 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/com/pyler/xinternalsd/Common.java: -------------------------------------------------------------------------------- 1 | package com.pyler.xinternalsd; 2 | 3 | 4 | import java.io.File; 5 | 6 | public class Common { 7 | 8 | public static final String CLASS_PACKAGE_PARSER_PACKAGE = "android.content.pm.PackageParser.Package"; 9 | public static final String[] MTP_APPS = {"com.android.MtpApplication", "com.samsung.android.MtpApplication"}; 10 | public static final String PERM_WRITE_EXTERNAL_STORAGE = "android.permission.WRITE_EXTERNAL_STORAGE"; 11 | public static final String PERM_ACCESS_ALL_EXTERNAL_STORAGE = "android.permission.ACCESS_ALL_EXTERNAL_STORAGE"; 12 | public static final String PERM_WRITE_MEDIA_STORAGE = "android.permission.WRITE_MEDIA_STORAGE"; 13 | 14 | private Common() { 15 | } 16 | 17 | public static String appendFileSeparator(String path) { 18 | if (!path.endsWith(File.separator)) { 19 | path += File.separator; 20 | } 21 | return path; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /res/values-hi/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | आंतरिक एसडी कार्ड के लिए बदल पथ 4 | सेटिंग्स 5 | आंतरिक एसडी कार्ड के लिए अनुकूलित पथ 6 | आंतरिक एसडी कार्ड के लिए पथ 7 | ऐप्स के लिए चालू 8 | हर ऐप के लिए चालू 9 | ऐप्स के लिए बंद 10 | आंतरिक एसडी कार्ड के लिए पथ दर्ज करें 11 | बाहरी एसडी कार्ड का पूरा उपयोग 12 | सिस्टम ऐप्स शामिल 13 | परिवर्तनो को लागु होने के लिए डिवाइस को रिबूट करे 14 | शो आवेदन आइकन 15 | 16 | -------------------------------------------------------------------------------- /res/values-cs/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Změnit cestu k interní kartě SD 4 | Nastavení 5 | Vlastní cesta k interní kartě SD 6 | Cesta k interní kartě SD 7 | Povolit pro aplikace 8 | Povolit pro všechny aplikace 9 | Zakázat pro aplikace 10 | Zadejte cestu k interní kartě SD 11 | Plný přístup ke externí kartě SD 12 | Zahrnout systémové aplikace 13 | Vyžaduje se restart zařízení pro použití nového nastavení. 14 | Zobrazit ikonu aplikace 15 | 16 | -------------------------------------------------------------------------------- /res/values-in/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Ubah jalur ke kartu SD internal 4 | Pengaturan 5 | Jalur khusus ke kartu SD internal 6 | Jalur ke kartu SD internal 7 | Nyalakan untuk aplikasi 8 | Nyalakan untuk semua aplikasi 9 | Matikan untuk aplikasi 10 | Masukkan jalur ke kartu SD internal 11 | Akses penuh ke kartu SD eksternal 12 | Termasuk aplikasi sistem 13 | Diperlukan reboot perangkat untuk menerapkan perubahan. 14 | Tampilkan ikon aplikasi 15 | 16 | 17 | -------------------------------------------------------------------------------- /res/values-sk/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Zmeniť cestu k internej karte SD 4 | Nastavenia 5 | Vlastná cesta k internej karte SD 6 | Cesta k internej karte SD 7 | Povoliť pre aplikácie 8 | Povoliť pre všetky aplikácie 9 | Zakázať pre aplikácie 10 | Zadajte cestu k internej karte SD 11 | Plný prístup ku externej karte SD 12 | Zahrnúť systémové aplikácie 13 | Vyžaduje sa reštart zariadenia pre použitie nového nastavenia. 14 | Zobraziť ikonu aplikácie 15 | 16 | -------------------------------------------------------------------------------- /res/values-ru/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Изменяет путь к внутренней SD карте 4 | Настройки 5 | Изменённый путь к внутренней SD карте 6 | Путь к внутренней SD карте 7 | Включить для приложений 8 | Включить для всех приложений 9 | Отключить для приложений 10 | Введите путь к внутренней SD карте 11 | Полный доступ к внешней SD карте 12 | Включить системные приложения 13 | Для применения изменений требуется перезагрузка. 14 | Показывать значок приложения 15 | 16 | 17 | -------------------------------------------------------------------------------- /res/values-fa/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | تغییر مسیر و ایجاد دسترسی روی کارت حافظه 4 | تنظیمات 5 | ایجاد دسترسی روی کارت حافظه 6 | مسیر کارت حافظه 7 | قابلیت فعال برای برنامه ها انتخابی 8 | قابلیت فعال برای همه برنامه ها 9 | قابلیت غیرفعال برای برنامه ها انتخابی 10 | مسیر برای کارت حافظه داخلی وارد کنید 11 | دسترسی کامل به کارت حافظه خارجی 12 | شامل برنامه ها سیستمی و تغییر حافظه 13 | دستگاه برای ایجاد تغییرات نیاز به راه اندازی مجدد دارد 14 | نمایش آیکون برنامه 15 | 16 | 17 | -------------------------------------------------------------------------------- /res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | XInternalSD 4 | Change path to internal SD card 5 | Settings 6 | Custom path to internal SD card 7 | Path to internal SD card 8 | Enable for apps 9 | Enable for all apps 10 | Disable for apps 11 | Enter path to internal SD card 12 | Full access to external SD card 13 | Include system apps 14 | Device reboot is required for changes to take effect. 15 | Show app icon 16 | 17 | 18 | -------------------------------------------------------------------------------- /res/values-pt/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Mudar caminho para memória interna 4 | Configurações 5 | Camin. custom. para memória interna 6 | Caminho para memória interna 7 | Ativar para os seguintes apps 8 | Ativar para todos apps 9 | Desativar para os seguintes apps 10 | Entre com o caminho para a memória interna 11 | Acesso completo ao cartão sd 12 | Incluir apps de sistema 13 | Reiniciar o dispositivo é necessário para as alterações tomarem efeito. 14 | Mostrar ícone do app 15 | 16 | 17 | -------------------------------------------------------------------------------- /res/values-de/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Vertauscht Pfad zu interner SD Karte 4 | Einstellungen 5 | Verweise Pfad auf interne SD Karte 6 | Mein Pfad zur internen SD Karte 7 | Aktivierung für Apps 8 | Aktivierung für alle Apps 9 | Deaktivierung für Apps 10 | Wähle Pfad zur internen SD Karte 11 | Voller Zugriff auf externe SD Karte 12 | Einschließlich System Apps 13 | Geräte Neustart ist erforderlich damit die Veränderungen wirksam werden. 14 | Zeige App Symbol 15 | -------------------------------------------------------------------------------- /res/values-hu/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Belső SD kártya útvonal módosítása 4 | Beállítások 5 | Egyéni útvonal a Belső SD kártyáról 6 | Útvonal a Belső SD kártyáról 7 | Engedélyezett alkalmazások 8 | Engedélyezi az összes alkalmazást 9 | Alkalmazások tiltása 10 | Adja meg a belső SD kártya útvonalát 11 | Teljes hozzáférés a Külső SD kártyán 12 | Tartalmazza a rendszer alkalmazásokat 13 | Készülék újraindítása szükséges a változtatások életbe léptetéséhez. 14 | Mutatása alkalmazás ikonja 15 | 16 | 17 | -------------------------------------------------------------------------------- /res/values-it/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Modifica il percorso della scheda SD 4 | Impostazioni 5 | Percorso personalizzato della scheda SD 6 | Percorso della scheda SD 7 | Abilita applicazioni 8 | Abilita per tutte le applicazioni 9 | Disabilita applicazioni 10 | Immettere il percorso della scheda SD 11 | Accesso completo alla scheda SD 12 | Includi le applicazioni di sistema 13 | Necessario il riavvio del dispositivo per rendere permanenti le modifiche. 14 | Mostra l\'icona delle app 15 | 16 | 17 | -------------------------------------------------------------------------------- /res/values-nl/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Verander het pad van uw interne SD kaart. 3 | Instellingen 4 | Aangepast pad voor uw interne SD kaart 5 | Pad voor uw interne SD kaart 6 | Inschakelen voor applicaties 7 | Inschakelen voor alle applicaties 8 | Uitschakelen voor applicaties 9 | Vul het pad van uw interne SD kaart in. 10 | Volledige toegang tot uw externe SD kaart 11 | Systeem applicaties inclusief 12 | Een herstart van uw mobiele apparaat is nodig om de veranderingen door te voeren. 13 | Applicatie icoon weergeven 14 | -------------------------------------------------------------------------------- /res/values-es/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Cambia la ruta de acceso a la tarjeta SD interna 4 | Ajustes 5 | Ruta por defecto para la tarjeta SD interna 6 | Ruta de acceso a la tarjeta SD interna 7 | Aplicaciones a permitir 8 | Permitir todas las aplicaciones 9 | Aplicaciones a ignorar 10 | Escriba la ruta de acceso a la tarjeta SD interna 11 | Acceso completo a la tarjeta SD externa 12 | Mostrar apps del sistema 13 | Reinicio del dispositivo es necesario para que los cambios surtan efecto. 14 | Mostrar icono de la aplicación 15 | 16 | 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, pyler 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 9 | 10 | 15 | 18 | 21 | 24 | 25 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /res/xml/preferences.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 11 | 12 | 16 | 17 | 21 | 22 | 25 | 28 | 29 | 33 | 37 | 38 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /src/com/pyler/xinternalsd/Preferences.java: -------------------------------------------------------------------------------- 1 | package com.pyler.xinternalsd; 2 | 3 | import android.app.Activity; 4 | import android.content.ComponentName; 5 | import android.content.Context; 6 | import android.content.SharedPreferences; 7 | import android.content.pm.ApplicationInfo; 8 | import android.content.pm.PackageManager; 9 | import android.os.AsyncTask; 10 | import android.os.Build; 11 | import android.os.Bundle; 12 | import android.os.Environment; 13 | import android.preference.EditTextPreference; 14 | import android.preference.MultiSelectListPreference; 15 | import android.preference.Preference; 16 | import android.preference.PreferenceCategory; 17 | import android.preference.PreferenceFragment; 18 | import android.preference.PreferenceManager; 19 | import android.view.WindowManager; 20 | import android.widget.Toast; 21 | 22 | import java.io.File; 23 | import java.util.ArrayList; 24 | import java.util.Arrays; 25 | import java.util.Collections; 26 | import java.util.Comparator; 27 | import java.util.List; 28 | 29 | public class Preferences extends Activity { 30 | public static Context context; 31 | public static SharedPreferences prefs; 32 | 33 | @Override 34 | protected void onCreate(Bundle savedInstanceState) { 35 | super.onCreate(savedInstanceState); 36 | context = getApplicationContext(); 37 | getFragmentManager().beginTransaction() 38 | .replace(android.R.id.content, new Settings()).commit(); 39 | } 40 | 41 | @SuppressWarnings("deprecation") 42 | public static class Settings extends PreferenceFragment { 43 | @Override 44 | public void onCreate(Bundle savedInstanceState) { 45 | super.onCreate(savedInstanceState); 46 | getPreferenceManager() 47 | .setSharedPreferencesMode(MODE_WORLD_READABLE); 48 | addPreferencesFromResource(R.xml.preferences); 49 | prefs = PreferenceManager.getDefaultSharedPreferences(context); 50 | PreferenceCategory appSettings = (PreferenceCategory) findPreference("app_settings"); 51 | Preference externalSdCardFullAccess = findPreference("external_sdcard_full_access"); 52 | EditTextPreference internalSdPath = (EditTextPreference) findPreference("internal_sdcard_path"); 53 | Preference includeSystemApps = findPreference("include_system_apps"); 54 | 55 | String internalSd = prefs.getString("internal_sdcard_path", ""); 56 | if (!internalSd.isEmpty()) { 57 | internalSd = Common.appendFileSeparator(internalSd); 58 | internalSdPath.setSummary(internalSd); 59 | internalSdPath.setText(internalSd); 60 | } 61 | 62 | internalSdPath.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { 63 | @Override 64 | public boolean onPreferenceChange( 65 | Preference preference, Object newValue) { 66 | String newPath = (String) newValue; 67 | if (newPath.isEmpty()) { 68 | newPath = getString(R.string.enter_internal_sdcard_path); 69 | preference.setSummary(newPath); 70 | } else { 71 | newPath = Common.appendFileSeparator(newPath); 72 | } 73 | preference.setSummary(newPath); 74 | return true; 75 | } 76 | }); 77 | 78 | includeSystemApps 79 | .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { 80 | @Override 81 | public boolean onPreferenceChange( 82 | Preference preference, Object newValue) { 83 | reloadAppsList(); 84 | return true; 85 | } 86 | }); 87 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 88 | externalSdCardFullAccess.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { 89 | @Override 90 | public boolean onPreferenceChange(Preference preference, Object newValue) { 91 | Toast.makeText(context, R.string.reboot_required, Toast.LENGTH_LONG).show(); 92 | return true; 93 | } 94 | }); 95 | } 96 | 97 | reloadAppsList(); 98 | 99 | String customInternalSd = prefs.getString("internal_sdcard_path", 100 | ""); 101 | if (!customInternalSd.isEmpty()) { // not empty 102 | internalSdPath.setSummary(customInternalSd); 103 | } else { // empty, try to detect it 104 | String externalSd = null; 105 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 106 | File[] dirs = context.getExternalMediaDirs(); 107 | for (File dir : dirs) { 108 | if (dir == null || !dir.exists()) { 109 | continue; 110 | } 111 | if (Environment.isExternalStorageRemovable(dir)) { 112 | String absolutePath = dir.getAbsolutePath(); 113 | int end = absolutePath.indexOf("/Android/"); 114 | externalSd = absolutePath.substring(0, end); 115 | } 116 | } 117 | } else { 118 | String externalStorage = System.getenv("SECONDARY_STORAGE"); 119 | if (externalStorage != null && !externalStorage.isEmpty()) { 120 | externalSd = externalStorage.split(":")[0]; 121 | } 122 | } 123 | 124 | if (externalSd != null && !externalSd.isEmpty()) { 125 | externalSd = Common.appendFileSeparator(externalSd); 126 | internalSdPath.setSummary(externalSd); 127 | internalSdPath.setText(externalSd); 128 | prefs.edit().putString("internal_sdcard_path", externalSd).apply(); 129 | } 130 | } 131 | 132 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { 133 | appSettings.removePreference(externalSdCardFullAccess); 134 | } 135 | 136 | Preference showAppIcon = findPreference("show_app_icon"); 137 | showAppIcon.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { 138 | @Override 139 | public boolean onPreferenceChange( 140 | Preference preference, Object newValue) { 141 | PackageManager packageManager = context.getPackageManager(); 142 | int state = (boolean) newValue ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED 143 | : PackageManager.COMPONENT_ENABLED_STATE_DISABLED; 144 | String settings = BuildConfig.APPLICATION_ID + ".Settings"; 145 | ComponentName alias = new ComponentName(context, settings); 146 | packageManager.setComponentEnabledSetting(alias, state, 147 | PackageManager.DONT_KILL_APP); 148 | return true; 149 | } 150 | }); 151 | } 152 | 153 | @Override 154 | public void onPause() { 155 | super.onPause(); 156 | 157 | // Set preferences file permissions to be world readable 158 | File prefsDir = new File(getActivity().getApplicationInfo().dataDir, "shared_prefs"); 159 | File prefsFile = new File(prefsDir, getPreferenceManager().getSharedPreferencesName() + ".xml"); 160 | if (prefsFile.exists()) { 161 | prefsFile.setReadable(true, false); 162 | } 163 | } 164 | 165 | public void reloadAppsList() { 166 | new LoadApps().execute(); 167 | } 168 | 169 | public boolean isAllowedApp(ApplicationInfo appInfo) { 170 | boolean includeSystemApps = prefs.getBoolean("include_system_apps", 171 | false); 172 | if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0 173 | && !includeSystemApps) { 174 | return false; 175 | } 176 | 177 | if (Arrays.asList(Common.MTP_APPS).contains(appInfo.packageName)) { 178 | return false; 179 | } 180 | return true; 181 | } 182 | 183 | public class LoadApps extends AsyncTask { 184 | MultiSelectListPreference enabledApps = (MultiSelectListPreference) findPreference("enable_for_apps"); 185 | MultiSelectListPreference disabledApps = (MultiSelectListPreference) findPreference("disable_for_apps"); 186 | List appNames = new ArrayList<>(); 187 | List packageNames = new ArrayList<>(); 188 | PackageManager pm = context.getPackageManager(); 189 | List packages = pm 190 | .getInstalledApplications(PackageManager.GET_META_DATA); 191 | 192 | @Override 193 | protected void onPreExecute() { 194 | enabledApps.setEnabled(false); 195 | disabledApps.setEnabled(false); 196 | } 197 | 198 | @Override 199 | protected Void doInBackground(Void... arg0) { 200 | List sortedApps = new ArrayList<>(); 201 | 202 | for (ApplicationInfo app : packages) { 203 | if (isAllowedApp(app)) { 204 | sortedApps.add(new String[]{ 205 | app.packageName, 206 | app.loadLabel(pm) 207 | .toString()}); 208 | } 209 | } 210 | 211 | Collections.sort(sortedApps, new Comparator() { 212 | @Override 213 | public int compare(String[] entry1, String[] entry2) { 214 | return entry1[1].compareToIgnoreCase(entry2[1]); 215 | } 216 | }); 217 | 218 | for (int i = 0; i < sortedApps.size(); i++) { 219 | appNames.add(sortedApps.get(i)[1] + "\n" + "(" + sortedApps.get(i)[0] + ")"); 220 | packageNames.add(sortedApps.get(i)[0]); 221 | } 222 | 223 | return null; 224 | } 225 | 226 | @Override 227 | protected void onPostExecute(Void result) { 228 | CharSequence[] appNamesList = appNames 229 | .toArray(new CharSequence[appNames.size()]); 230 | CharSequence[] packageNamesList = packageNames 231 | .toArray(new CharSequence[packageNames.size()]); 232 | 233 | enabledApps.setEntries(appNamesList); 234 | enabledApps.setEntryValues(packageNamesList); 235 | enabledApps.setEnabled(true); 236 | disabledApps.setEntries(appNamesList); 237 | disabledApps.setEntryValues(packageNamesList); 238 | disabledApps.setEnabled(true); 239 | 240 | Preference.OnPreferenceClickListener listener = new Preference.OnPreferenceClickListener() { 241 | @Override 242 | public boolean onPreferenceClick(Preference preference) { 243 | ((MultiSelectListPreference) preference).getDialog().getWindow().setLayout(WindowManager.LayoutParams.FILL_PARENT, WindowManager.LayoutParams.FILL_PARENT); 244 | return false; 245 | } 246 | }; 247 | 248 | enabledApps.setOnPreferenceClickListener(listener); 249 | disabledApps.setOnPreferenceClickListener(listener); 250 | } 251 | } 252 | 253 | } 254 | } 255 | -------------------------------------------------------------------------------- /src/com/pyler/xinternalsd/XInternalSD.java: -------------------------------------------------------------------------------- 1 | package com.pyler.xinternalsd; 2 | 3 | import android.content.pm.ApplicationInfo; 4 | import android.os.Build; 5 | import android.os.Environment; 6 | 7 | import org.xmlpull.v1.XmlPullParser; 8 | 9 | import java.io.File; 10 | import java.util.ArrayList; 11 | import java.util.Arrays; 12 | import java.util.HashSet; 13 | import java.util.Set; 14 | 15 | import de.robv.android.xposed.IXposedHookLoadPackage; 16 | import de.robv.android.xposed.IXposedHookZygoteInit; 17 | import de.robv.android.xposed.XC_MethodHook; 18 | import de.robv.android.xposed.XC_MethodHook.MethodHookParam; 19 | import de.robv.android.xposed.XSharedPreferences; 20 | import de.robv.android.xposed.XposedHelpers; 21 | import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam; 22 | 23 | public class XInternalSD implements IXposedHookZygoteInit, 24 | IXposedHookLoadPackage { 25 | public XSharedPreferences prefs; 26 | public String internalSd; 27 | public XC_MethodHook getExternalStorageDirectoryHook; 28 | public XC_MethodHook getExternalFilesDirHook; 29 | public XC_MethodHook getObbDirHook; 30 | public XC_MethodHook getExternalStoragePublicDirectoryHook; 31 | public XC_MethodHook getExternalFilesDirsHook; 32 | public XC_MethodHook getObbDirsHook; 33 | public XC_MethodHook externalSdCardAccessHook; // 4.4 - 5.0 34 | public XC_MethodHook externalSdCardAccessHook2; // 6.0 and up 35 | boolean detectedSdPath = false; 36 | 37 | @Override 38 | public void initZygote(StartupParam startupParam) throws Throwable { 39 | prefs = new XSharedPreferences(XInternalSD.class.getPackage().getName()); 40 | prefs.makeWorldReadable(); 41 | 42 | getExternalStorageDirectoryHook = new XC_MethodHook() { 43 | @Override 44 | protected void afterHookedMethod(MethodHookParam param) 45 | throws Throwable { 46 | changeDirPath(param); 47 | } 48 | }; 49 | 50 | getExternalFilesDirHook = new XC_MethodHook() { 51 | @Override 52 | protected void afterHookedMethod(MethodHookParam param) 53 | throws Throwable { 54 | changeDirPath(param); 55 | 56 | } 57 | }; 58 | 59 | getObbDirHook = new XC_MethodHook() { 60 | @Override 61 | protected void afterHookedMethod(MethodHookParam param) 62 | throws Throwable { 63 | changeDirPath(param); 64 | } 65 | }; 66 | 67 | getExternalStoragePublicDirectoryHook = new XC_MethodHook() { 68 | @Override 69 | protected void afterHookedMethod(MethodHookParam param) 70 | throws Throwable { 71 | changeDirPath(param); 72 | } 73 | }; 74 | 75 | getExternalFilesDirsHook = new XC_MethodHook() { 76 | @Override 77 | protected void afterHookedMethod(MethodHookParam param) 78 | throws Throwable { 79 | changeDirsPath(param); 80 | } 81 | }; 82 | 83 | getObbDirsHook = new XC_MethodHook() { 84 | @Override 85 | protected void afterHookedMethod(MethodHookParam param) 86 | throws Throwable { 87 | changeDirsPath(param); 88 | } 89 | }; 90 | 91 | externalSdCardAccessHook = new XC_MethodHook() { 92 | @Override 93 | protected void afterHookedMethod(MethodHookParam param) 94 | throws Throwable { 95 | prefs.reload(); 96 | String permission = (String) param.args[1]; 97 | boolean externalSdCardFullAccess = prefs.getBoolean( 98 | "external_sdcard_full_access", true); 99 | if (!externalSdCardFullAccess) { 100 | return; 101 | } 102 | if (Common.PERM_WRITE_EXTERNAL_STORAGE 103 | .equals(permission) 104 | || Common.PERM_ACCESS_ALL_EXTERNAL_STORAGE 105 | .equals(permission)) { 106 | Class process = XposedHelpers.findClass( 107 | "android.os.Process", null); 108 | int gid = (Integer) XposedHelpers.callStaticMethod(process, 109 | "getGidForName", "media_rw"); 110 | Object permissions = null; 111 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 112 | permissions = XposedHelpers.getObjectField( 113 | param.thisObject, "mPermissions"); 114 | } else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) { 115 | Object settings = XposedHelpers.getObjectField( 116 | param.thisObject, "mSettings"); 117 | permissions = XposedHelpers.getObjectField(settings, 118 | "mPermissions"); 119 | } 120 | Object bp = XposedHelpers.callMethod(permissions, "get", 121 | permission); 122 | int[] bpGids = (int[]) XposedHelpers.getObjectField(bp, 123 | "gids"); 124 | XposedHelpers.setObjectField(bp, "gids", 125 | appendInt(bpGids, gid)); 126 | } 127 | } 128 | }; 129 | 130 | 131 | externalSdCardAccessHook2 = new XC_MethodHook() { 132 | @Override 133 | protected void afterHookedMethod(MethodHookParam param) 134 | throws Throwable { 135 | prefs.reload(); 136 | boolean externalSdCardFullAccess = prefs.getBoolean( 137 | "external_sdcard_full_access", true); 138 | if (!externalSdCardFullAccess) { 139 | return; 140 | } 141 | Object extras = XposedHelpers.getObjectField(param.args[0], "mExtras"); 142 | Object ps = XposedHelpers.callMethod(extras, "getPermissionsState"); 143 | Object settings = XposedHelpers.getObjectField(param.thisObject, "mSettings"); 144 | Object permissions = XposedHelpers.getObjectField(settings, "mPermissions"); 145 | boolean hasPermission = (boolean) XposedHelpers.callMethod(ps, "hasInstallPermission", Common.PERM_WRITE_MEDIA_STORAGE); 146 | if (!hasPermission) { 147 | Object permWriteMediaStorage = XposedHelpers.callMethod(permissions, "get", 148 | Common.PERM_WRITE_MEDIA_STORAGE); 149 | XposedHelpers.callMethod(ps, "grantInstallPermission", permWriteMediaStorage); 150 | } 151 | 152 | } 153 | }; 154 | } 155 | 156 | @SuppressWarnings("unchecked") 157 | @Override 158 | public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable { 159 | 160 | if ("android".equals(lpparam.packageName) 161 | && "android".equals(lpparam.processName)) { 162 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 163 | XposedHelpers.findAndHookMethod(XposedHelpers.findClass( 164 | "com.android.server.pm.PackageManagerService", 165 | lpparam.classLoader), "grantPermissionsLPw", 166 | Common.CLASS_PACKAGE_PARSER_PACKAGE, boolean.class, String.class, externalSdCardAccessHook2); 167 | } else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP || Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP_MR1) { 168 | XposedHelpers.findAndHookMethod( 169 | XposedHelpers.findClass( 170 | "com.android.server.SystemConfig", 171 | lpparam.classLoader), "readPermission", 172 | XmlPullParser.class, String.class, 173 | externalSdCardAccessHook); 174 | } else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) { 175 | XposedHelpers.findAndHookMethod(XposedHelpers.findClass( 176 | "com.android.server.pm.PackageManagerService", 177 | lpparam.classLoader), "readPermission", 178 | XmlPullParser.class, String.class, 179 | externalSdCardAccessHook); 180 | } 181 | } 182 | 183 | if (!detectedSdPath) { 184 | try { 185 | File internalSdPath = Environment.getExternalStorageDirectory(); 186 | internalSd = internalSdPath.getPath(); 187 | detectedSdPath = true; 188 | } catch (Exception e) { 189 | // nothing 190 | } 191 | } 192 | 193 | if (!isEnabledApp(lpparam)) { 194 | return; 195 | 196 | } 197 | 198 | XposedHelpers.findAndHookMethod(Environment.class, 199 | "getExternalStorageDirectory", getExternalStorageDirectoryHook); 200 | XposedHelpers.findAndHookMethod(XposedHelpers.findClass( 201 | "android.app.ContextImpl", lpparam.classLoader), 202 | "getExternalFilesDir", String.class, getExternalFilesDirHook); 203 | XposedHelpers.findAndHookMethod(XposedHelpers.findClass( 204 | "android.app.ContextImpl", lpparam.classLoader), "getObbDir", 205 | getObbDirHook); 206 | XposedHelpers.findAndHookMethod(Environment.class, 207 | "getExternalStoragePublicDirectory", String.class, 208 | getExternalStoragePublicDirectoryHook); 209 | 210 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 211 | XposedHelpers.findAndHookMethod(XposedHelpers.findClass( 212 | "android.app.ContextImpl", lpparam.classLoader), 213 | "getExternalFilesDirs", String.class, 214 | getExternalFilesDirsHook); 215 | XposedHelpers.findAndHookMethod(XposedHelpers.findClass( 216 | "android.app.ContextImpl", lpparam.classLoader), 217 | "getObbDirs", getObbDirsHook); 218 | } 219 | } 220 | 221 | public boolean isEnabledApp(LoadPackageParam lpparam) { 222 | boolean isEnabledApp = true; 223 | prefs.reload(); 224 | boolean enabledModule = prefs.getBoolean("custom_internal_sd", true); 225 | if (!enabledModule) { 226 | return false; 227 | } 228 | if (!isAllowedApp(lpparam.appInfo)) { 229 | return false; 230 | } 231 | String packageName = lpparam.packageName; 232 | boolean enabledForAllApps = prefs.getBoolean("enable_for_all_apps", 233 | false); 234 | if (enabledForAllApps) { 235 | Set disabledApps = prefs.getStringSet("disable_for_apps", 236 | new HashSet()); 237 | if (!disabledApps.isEmpty()) { 238 | isEnabledApp = !disabledApps.contains(packageName); 239 | } 240 | } else { 241 | Set enabledApps = prefs.getStringSet("enable_for_apps", 242 | new HashSet()); 243 | if (!enabledApps.isEmpty()) { 244 | isEnabledApp = enabledApps.contains(packageName); 245 | } else { 246 | isEnabledApp = !isEnabledApp; 247 | } 248 | } 249 | return isEnabledApp; 250 | } 251 | 252 | public void changeDirPath(MethodHookParam param) { 253 | File oldDirPath = (File) param.getResult(); 254 | if (oldDirPath == null) { 255 | return; 256 | } 257 | String customInternalSd = getCustomInternalSd(); 258 | if (customInternalSd.isEmpty()) { 259 | return; 260 | } 261 | String internalSd = getInternalSd(); 262 | if (internalSd.isEmpty()) { 263 | return; 264 | } 265 | 266 | String dir = Common.appendFileSeparator(oldDirPath.getPath()); 267 | String newDir = dir.replaceFirst(internalSd, 268 | customInternalSd); 269 | File newDirPath = new File(newDir); 270 | if (!newDirPath.exists()) { 271 | newDirPath.mkdirs(); 272 | } 273 | param.setResult(newDirPath); 274 | } 275 | 276 | public void changeDirsPath(MethodHookParam param) { 277 | File[] oldDirPaths = (File[]) param.getResult(); 278 | ArrayList newDirPaths = new ArrayList(); 279 | for (File oldDirPath : oldDirPaths) { 280 | if (oldDirPath != null) { 281 | newDirPaths.add(oldDirPath); 282 | } 283 | } 284 | 285 | String customInternalSd = getCustomInternalSd(); 286 | if (customInternalSd.isEmpty()) { 287 | return; 288 | } 289 | 290 | String internalSd = getInternalSd(); 291 | if (internalSd.isEmpty()) { 292 | return; 293 | } 294 | 295 | String dir = Common.appendFileSeparator(oldDirPaths[0].getPath()); 296 | String newDir = dir.replaceFirst(internalSd, customInternalSd); 297 | File newDirPath = new File(newDir); 298 | 299 | if (!newDirPaths.contains(newDirPath)) { 300 | newDirPaths.add(newDirPath); 301 | } 302 | if (!newDirPath.exists()) { 303 | newDirPath.mkdirs(); 304 | } 305 | 306 | File[] appendedDirPaths = newDirPaths.toArray(new File[newDirPaths 307 | .size()]); 308 | param.setResult(appendedDirPaths); 309 | } 310 | 311 | public String getCustomInternalSd() { 312 | prefs.reload(); 313 | String customInternalSd = prefs.getString("internal_sdcard_path", 314 | getInternalSd()); 315 | customInternalSd = Common.appendFileSeparator(customInternalSd); 316 | return customInternalSd; 317 | } 318 | 319 | public String getInternalSd() { 320 | internalSd = Common.appendFileSeparator(internalSd); 321 | return internalSd; 322 | } 323 | 324 | public boolean isAllowedApp(ApplicationInfo appInfo) { 325 | prefs.reload(); 326 | boolean includeSystemApps = prefs.getBoolean("include_system_apps", 327 | false); 328 | if (appInfo == null) { 329 | return includeSystemApps; 330 | } else { 331 | if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0 332 | && !includeSystemApps) { 333 | return false; 334 | } 335 | if (Arrays.asList(Common.MTP_APPS).contains(appInfo.packageName)) { 336 | return false; 337 | } 338 | } 339 | return true; 340 | } 341 | 342 | public int[] appendInt(int[] cur, int val) { 343 | if (cur == null) { 344 | return new int[]{val}; 345 | } 346 | final int N = cur.length; 347 | for (int i = 0; i < N; i++) { 348 | if (cur[i] == val) { 349 | return cur; 350 | } 351 | } 352 | int[] ret = new int[N + 1]; 353 | System.arraycopy(cur, 0, ret, 0, N); 354 | ret[N] = val; 355 | return ret; 356 | } 357 | } 358 | --------------------------------------------------------------------------------