@@ -264,7 +264,7 @@ public static String getSpecialDescription(Context ctx, String acct) {
264
264
}
265
265
266
266
public static String getSpecialDescriptionSystem (Context ctx , String packageName ) {
267
- switch (packageName ){
267
+ switch (packageName ) {
268
268
case "any" :
269
269
return ctx .getString (R .string .all_item );
270
270
case "kernel" :
@@ -1431,12 +1431,12 @@ public static List<PackageInfoData> getApps(Context ctx, GetAppList appList) {
1431
1431
if (G .enableLAN () && !app .selected_lan && Collections .binarySearch (selected_lan , app .uid ) >= 0 ) {
1432
1432
app .selected_lan = true ;
1433
1433
}
1434
- if (G .supportDual ()) {
1435
- checkPartOfMultiUser (apinfo , name , uid , pkgmanager ,multiUserAppsMap );
1434
+ if (G .supportDual ()) {
1435
+ checkPartOfMultiUser (apinfo , name , uid , pkgmanager , multiUserAppsMap );
1436
1436
}
1437
1437
}
1438
1438
1439
- if (G .supportDual ()) {
1439
+ if (G .supportDual ()) {
1440
1440
//run through multi user map
1441
1441
for (int i = 0 ; i < multiUserAppsMap .size (); i ++) {
1442
1442
app = multiUserAppsMap .valueAt (i );
@@ -1512,7 +1512,7 @@ public static List<PackageInfoData> getSpecialData(boolean additional) {
1512
1512
specialData .add (new PackageInfoData (SPECIAL_UID_KERNEL , ctx .getString (R .string .kernel_item ), "dev.afwall.special.kernel" ));
1513
1513
specialData .add (new PackageInfoData (SPECIAL_UID_TETHER , ctx .getString (R .string .tethering_item ), "dev.afwall.special.tether" ));
1514
1514
specialData .add (new PackageInfoData (SPECIAL_UID_NTP , ctx .getString (R .string .ntp_item ), "dev.afwall.special.ntp" ));
1515
- if (additional ) {
1515
+ if (additional ) {
1516
1516
specialData .add (new PackageInfoData (1020 , "mDNS" , "dev.afwall.special.mDNS" ));
1517
1517
}
1518
1518
for (String acct : specialAndroidAccounts ) {
@@ -1760,22 +1760,66 @@ private static boolean installBinary(Context ctx, int resId, String filename) {
1760
1760
}
1761
1761
}
1762
1762
1763
- /*private static boolean migrateSettings(Context ctx, int lastVer, int currentVer) {
1764
- if (lastVer <= 138) {
1765
- // migrate busybox/iptables path settings from <= 1.2.7-BETA
1766
- if (G.bb_path().equals("1")) {
1767
- G.bb_path("system");
1768
- } else if (G.bb_path().equals("2")) {
1769
- G.bb_path("builtin");
1770
- }
1771
- if (G.ip_path().equals("1")) {
1772
- G.ip_path("system");
1773
- } else if (G.ip_path().equals("2")) {
1774
- G.ip_path("auto");
1775
- }
1763
+ private static void deleteStartFixFiles (final Context ctx ) {
1764
+ String path = G .initPath ();
1765
+ File f = new File (path );
1766
+ final String initScript = "afwallstart" ;
1767
+ if (f .exists () && f .isDirectory ()) {
1768
+ final String filePath = path + "/" + initScript ;
1769
+ new AsyncTask <Void , Void , Void >() {
1770
+ @ Override
1771
+ public Void doInBackground (Void ... args ) {
1772
+ if (mountDir (ctx , getFixLeakPath (initScript ), "RW" )) {
1773
+ new RootCommand ()
1774
+ .setReopenShell (true ).setCallback (new RootCommand .Callback () {
1775
+ @ Override
1776
+ public void cbFunc (RootCommand state ) {
1777
+ if (state .exitCode == 0 ) {
1778
+ sendToastBroadcast (ctx , ctx .getString (R .string .remove_initd ));
1779
+ } else {
1780
+ sendToastBroadcast (ctx , ctx .getString (R .string .delete_initd_error ));
1781
+ }
1782
+ }
1783
+ }).setLogging (true ).run (ctx , "rm -f " + filePath );
1784
+ mountDir (ctx , getFixLeakPath (initScript ), "RO" );
1785
+ } else {
1786
+ Api .sendToastBroadcast (ctx , ctx .getString (R .string .mount_initd_error ));
1787
+ }
1788
+ return null ;
1789
+ }
1790
+ }.execute ();
1776
1791
}
1777
- return true;
1778
- }*/
1792
+ }
1793
+
1794
+ private static void updateFixLeakScript (Context ctx ) {
1795
+ final String initScript = "afwallstart" ;
1796
+ final String srcPath = new File (ctx .getDir ("bin" , 0 ), initScript )
1797
+ .getAbsolutePath ();
1798
+
1799
+ new AsyncTask <Void , Void , Void >() {
1800
+ @ Override
1801
+ public Void doInBackground (Void ... args ) {
1802
+ String path = G .initPath ();
1803
+ if (path != null ) {
1804
+ File f = new File (path );
1805
+ if (mountDir (ctx , getFixLeakPath (initScript ), "RW" )) {
1806
+ //make sure it's executable
1807
+ new RootCommand ()
1808
+ .setReopenShell (true )
1809
+ .run (ctx , "chmod 755 " + f .getAbsolutePath ());
1810
+ if (RootTools .copyFile (srcPath , (f .getAbsolutePath () + "/" + initScript ),
1811
+ true , false )) {
1812
+ Api .sendToastBroadcast (ctx , ctx .getString (R .string .success_initd ));
1813
+ }
1814
+ mountDir (ctx , getFixLeakPath (initScript ), "RO" );
1815
+ } else {
1816
+ Api .sendToastBroadcast (ctx , ctx .getString (R .string .mount_initd_error ));
1817
+ }
1818
+ }
1819
+ return null ;
1820
+ }
1821
+ }.execute ();
1822
+ }
1779
1823
1780
1824
/**
1781
1825
* Asserts that the binary files are installed in the cache directory.
@@ -1832,6 +1876,7 @@ public static boolean assertBinaries(Context ctx, boolean showErrors) {
1832
1876
ret &= installBinary (ctx , R .raw .afwallstart , "afwallstart" );
1833
1877
//Log.d(TAG, "binary installation for " + abi + (ret ? " succeeded" : " failed"));
1834
1878
1879
+
1835
1880
if (showErrors ) {
1836
1881
if (ret ) {
1837
1882
toast (ctx , ctx .getString (R .string .toast_bin_installed ));
@@ -1851,6 +1896,17 @@ public static boolean assertBinaries(Context ctx, boolean showErrors) {
1851
1896
G .appVersion (currentVer );
1852
1897
}
1853
1898
1899
+ //make sure we update afwall script as well
1900
+ if (!G .initPath ().isEmpty () && G .fixLeak ()) {
1901
+ try {
1902
+ deleteStartFixFiles (ctx );
1903
+ updateFixLeakScript (ctx );
1904
+ }catch (Exception e ) {
1905
+
1906
+ }
1907
+ }
1908
+
1909
+
1854
1910
return ret ;
1855
1911
}
1856
1912
@@ -2955,11 +3011,10 @@ private static void initSpecial() {
2955
3011
}
2956
3012
2957
3013
2958
-
2959
3014
public static void updateLanguage (Context context , String lang ) {
2960
- if (lang .equals ("sys" )){
2961
- Locale defaultLocale = Resources .getSystem ().getConfiguration ().locale ;
2962
- Locale .setDefault (defaultLocale );
3015
+ if (lang .equals ("sys" )) {
3016
+ Locale defaultLocale = Resources .getSystem ().getConfiguration ().locale ;
3017
+ Locale .setDefault (defaultLocale );
2963
3018
Resources res = context .getResources ();
2964
3019
Configuration conf = res .getConfiguration ();
2965
3020
conf .locale = defaultLocale ;
@@ -3330,7 +3385,7 @@ public static boolean isFixPathFileExist(String fileName) {
3330
3385
public static boolean mountDir (Context context , String path , String mountType ) {
3331
3386
if (path != null ) {
3332
3387
String busyboxPath = Api .getBusyBoxPath (context , false );
3333
- if (busyboxPath != null && !busyboxPath .trim ().isEmpty ()) {
3388
+ if (busyboxPath != null && !busyboxPath .trim ().isEmpty ()) {
3334
3389
return RootTools .remount (path , mountType , busyboxPath );
3335
3390
} else {
3336
3391
return false ;
0 commit comments