|
57 | 57 | import com.noshufou.android.su.preferences.Preferences; |
58 | 58 | import com.noshufou.android.su.preferences.PreferencesActivity; |
59 | 59 | import com.noshufou.android.su.preferences.PreferencesActivityHC; |
| 60 | +import com.noshufou.android.su.provider.PermissionsProvider.Apps.AllowType; |
60 | 61 | import com.noshufou.android.su.service.UpdaterService; |
61 | 62 |
|
62 | 63 | public class Util { |
@@ -810,28 +811,31 @@ public static boolean writeStoreFile(Context context, int uid, int execUid, Stri |
810 | 811 | return true; |
811 | 812 | } |
812 | 813 |
|
813 | | - public static boolean writeDetaultStoreFile(Context context, String action) { |
814 | | - File storedDir = new File(context.getFilesDir().getAbsolutePath() + File.separator + "stored"); |
815 | | - storedDir.mkdirs(); |
816 | | - File defFile = new File(storedDir.getAbsolutePath() + File.separator + "default"); |
817 | | - try { |
818 | | - OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(defFile.getAbsolutePath())); |
819 | | - if (action.equals("allow")) { |
820 | | - out.write("1"); |
821 | | - } else if (action.equals("deny")) { |
822 | | - out.write("0"); |
823 | | - } else { |
824 | | - out.write("-1"); |
825 | | - } |
826 | | - out.flush(); |
827 | | - out.close(); |
828 | | - } catch (FileNotFoundException e) { |
829 | | - Log.w(TAG, "Default file not written", e); |
830 | | - return false; |
831 | | - } catch (IOException e) { |
832 | | - Log.w(TAG, "Default file not written", e); |
833 | | - return false; |
834 | | - } |
835 | | - return true; |
| 814 | + public static boolean writeDetaultStoreFile(Context context) { |
| 815 | + File storedDir = new File(context.getFilesDir().getAbsolutePath() + File.separator + "stored"); |
| 816 | + storedDir.mkdirs(); |
| 817 | + File defFile = new File(storedDir.getAbsolutePath() + File.separator + "default"); |
| 818 | + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); |
| 819 | + String action = prefs.getString(Preferences.AUTOMATIC_ACTION, "prompt"); |
| 820 | + try { |
| 821 | + OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(defFile.getAbsolutePath())); |
| 822 | + out.write("default\n"); |
| 823 | + if (action.equals("allow")) { |
| 824 | + out.write("1"); |
| 825 | + } else if (action.equals("deny")) { |
| 826 | + out.write("0"); |
| 827 | + } else { |
| 828 | + out.write("-1"); |
| 829 | + } |
| 830 | + out.flush(); |
| 831 | + out.close(); |
| 832 | + } catch (FileNotFoundException e) { |
| 833 | + Log.w(TAG, "Default file not written", e); |
| 834 | + return false; |
| 835 | + } catch (IOException e) { |
| 836 | + Log.w(TAG, "Default file not written", e); |
| 837 | + return false; |
| 838 | + } |
| 839 | + return true; |
836 | 840 | } |
837 | 841 | } |
0 commit comments