[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [orbot/master] move getSharedPrefs() from TorServiceUtils to Prefs



commit 22bf175cc027f40a2a66d6532a7b483e2263e03e
Author: Hans-Christoph Steiner <hans@xxxxxxx>
Date:   Mon Oct 7 17:18:09 2019 +0200

    move getSharedPrefs() from TorServiceUtils to Prefs
---
 .../java/org/torproject/android/mini/MiniMainActivity.java |  3 +--
 .../org/torproject/android/mini/ui/AppConfigActivity.java  |  4 ++--
 .../org/torproject/android/mini/ui/AppManagerActivity.java |  4 ++--
 .../java/org/torproject/android/OrbotMainActivity.java     |  3 +--
 .../java/org/torproject/android/ui/AppManagerActivity.java |  4 ++--
 .../java/org/torproject/android/service/TorService.java    | 14 +++++++-------
 .../java/org/torproject/android/service/util/Prefs.java    |  7 ++++++-
 .../torproject/android/service/util/TorServiceUtils.java   |  4 ----
 8 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/app-mini/src/main/java/org/torproject/android/mini/MiniMainActivity.java b/app-mini/src/main/java/org/torproject/android/mini/MiniMainActivity.java
index 6710778d..e8612ed5 100644
--- a/app-mini/src/main/java/org/torproject/android/mini/MiniMainActivity.java
+++ b/app-mini/src/main/java/org/torproject/android/mini/MiniMainActivity.java
@@ -61,7 +61,6 @@ import org.torproject.android.service.OrbotConstants;
 import org.torproject.android.service.TorService;
 import org.torproject.android.service.TorServiceConstants;
 import org.torproject.android.service.util.Prefs;
-import org.torproject.android.service.util.TorServiceUtils;
 import org.torproject.android.service.vpn.TorifiedApp;
 import org.torproject.android.service.vpn.VpnConstants;
 import org.torproject.android.service.vpn.VpnPrefs;
@@ -124,7 +123,7 @@ public class MiniMainActivity extends AppCompatActivity
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
+        mPrefs = Prefs.getSharedPrefs(getApplicationContext());
 
         /* Create the widgets before registering for broadcasts to guarantee
          * that the widgets exist when the status updates try to update them */
diff --git a/app-mini/src/main/java/org/torproject/android/mini/ui/AppConfigActivity.java b/app-mini/src/main/java/org/torproject/android/mini/ui/AppConfigActivity.java
index a8488e3d..a731ef29 100644
--- a/app-mini/src/main/java/org/torproject/android/mini/ui/AppConfigActivity.java
+++ b/app-mini/src/main/java/org/torproject/android/mini/ui/AppConfigActivity.java
@@ -13,7 +13,7 @@ import android.widget.CompoundButton;
 import android.widget.Switch;
 import org.torproject.android.mini.R;
 import org.torproject.android.service.OrbotConstants;
-import org.torproject.android.service.util.TorServiceUtils;
+import org.torproject.android.service.util.Prefs;
 import org.torproject.android.service.vpn.TorifiedApp;
 
 import static org.torproject.android.mini.MiniMainActivity.getApp;
@@ -40,7 +40,7 @@ public class AppConfigActivity extends AppCompatActivity {
 
         final String pkgId = getIntent().getStringExtra(Intent.EXTRA_PACKAGE_NAME);
 
-        mPrefs =  TorServiceUtils.getSharedPrefs(getApplicationContext());
+        mPrefs =  Prefs.getSharedPrefs(getApplicationContext());
 
         ApplicationInfo aInfo = null;
         try {
diff --git a/app-mini/src/main/java/org/torproject/android/mini/ui/AppManagerActivity.java b/app-mini/src/main/java/org/torproject/android/mini/ui/AppManagerActivity.java
index 27425bce..489aba4c 100644
--- a/app-mini/src/main/java/org/torproject/android/mini/ui/AppManagerActivity.java
+++ b/app-mini/src/main/java/org/torproject/android/mini/ui/AppManagerActivity.java
@@ -28,7 +28,7 @@ import android.widget.ProgressBar;
 import android.widget.TextView;
 import org.torproject.android.mini.R;
 import org.torproject.android.service.OrbotConstants;
-import org.torproject.android.service.util.TorServiceUtils;
+import org.torproject.android.service.util.Prefs;
 import org.torproject.android.service.vpn.TorifiedApp;
 
 import java.util.ArrayList;
@@ -63,7 +63,7 @@ public class AppManagerActivity extends AppCompatActivity implements OnClickList
     @Override
     protected void onResume() {
         super.onResume();
-        mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
+        mPrefs = Prefs.getSharedPrefs(getApplicationContext());
         reloadApps();
     }
 
diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
index 82a0cef9..947f3a76 100644
--- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java
+++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
@@ -57,7 +57,6 @@ import org.torproject.android.service.OrbotConstants;
 import org.torproject.android.service.TorService;
 import org.torproject.android.service.TorServiceConstants;
 import org.torproject.android.service.util.Prefs;
-import org.torproject.android.service.util.TorServiceUtils;
 import org.torproject.android.service.vpn.VpnConstants;
 import org.torproject.android.service.vpn.VpnPrefs;
 import org.torproject.android.settings.Languages;
@@ -167,7 +166,7 @@ public class OrbotMainActivity extends AppCompatActivity
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
+        mPrefs = Prefs.getSharedPrefs(getApplicationContext());
 
         migratePreferences(); // Migrate old preferences
 
diff --git a/app/src/main/java/org/torproject/android/ui/AppManagerActivity.java b/app/src/main/java/org/torproject/android/ui/AppManagerActivity.java
index d5ea6f8e..111dda5f 100644
--- a/app/src/main/java/org/torproject/android/ui/AppManagerActivity.java
+++ b/app/src/main/java/org/torproject/android/ui/AppManagerActivity.java
@@ -29,7 +29,7 @@ import android.widget.ProgressBar;
 import android.widget.TextView;
 import org.torproject.android.R;
 import org.torproject.android.service.OrbotConstants;
-import org.torproject.android.service.util.TorServiceUtils;
+import org.torproject.android.service.util.Prefs;
 import org.torproject.android.service.vpn.TorifiedApp;
 
 import java.util.ArrayList;
@@ -65,7 +65,7 @@ public class AppManagerActivity extends AppCompatActivity implements OnClickList
     @Override
     protected void onResume() {
         super.onResume();
-        mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
+        mPrefs = Prefs.getSharedPrefs(getApplicationContext());
         reloadApps();
     }
 
diff --git a/orbotservice/src/main/java/org/torproject/android/service/TorService.java b/orbotservice/src/main/java/org/torproject/android/service/TorService.java
index 96dedfd8..f8137632 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/TorService.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/TorService.java
@@ -610,7 +610,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
 
     private boolean torUpgradeAndConfig() throws IOException, TimeoutException {
 
-        SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
+        SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
         String version = prefs.getString(PREF_BINARY_TOR_VERSION_INSTALLED,null);
 
         logNotice("checking binary version: " + version);
@@ -638,7 +638,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
 
     private File updateTorrcCustomFile () throws IOException, TimeoutException
     {
-        SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
+        SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
 
         StringBuffer extraLines = new StringBuffer();
 
@@ -838,7 +838,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
 	        // make sure there are no stray daemons running
 	        killAllDaemons();
 
-            SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
+            SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
             String version = prefs.getString(PREF_BINARY_TOR_VERSION_INSTALLED,null);
             logNotice("checking binary version: " + version);
 
@@ -1152,7 +1152,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
                 bufferedReader.close();
 
                 //store last valid control port
-                SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
+                SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
                 prefs.edit().putInt("controlport", result).commit();
                 
             }
@@ -1471,7 +1471,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
         	if (mCurrentStatus == STATUS_OFF)
         		return;
         	
-            SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
+            SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
 
             boolean doNetworKSleep = prefs.getBoolean(OrbotConstants.PREF_DISABLE_NETWORK, true);
             
@@ -1530,7 +1530,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
     {
         logNotice(getString(R.string.updating_settings_in_tor_service));
         
-        SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
+        SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
         
         boolean useBridges = Prefs.bridgesEnabled();
 
@@ -1897,7 +1897,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
     
     private void setExitNode (String newExits)
     {
-    	SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
+    	SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
         
     	if (TextUtils.isEmpty(newExits))
     	{
diff --git a/orbotservice/src/main/java/org/torproject/android/service/util/Prefs.java b/orbotservice/src/main/java/org/torproject/android/service/util/Prefs.java
index 7b5f132b..9b6ab825 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/util/Prefs.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/util/Prefs.java
@@ -3,6 +3,7 @@ package org.torproject.android.service.util;
 
 import android.content.Context;
 import android.content.SharedPreferences;
+import org.torproject.android.service.OrbotConstants;
 
 import java.util.Locale;
 
@@ -24,7 +25,7 @@ public class Prefs {
 
     public static void setContext(Context context) {
         if (prefs == null)
-            prefs = TorServiceUtils.getSharedPrefs(context);
+            prefs = getSharedPrefs(context);
     }
 
     private static void putBoolean(String key, boolean value) {
@@ -109,4 +110,8 @@ public class Prefs {
     {
     	putString(PREF_EXIT_NODES,exits);
     }
+
+    public static SharedPreferences getSharedPrefs (Context context) {
+        return context.getSharedPreferences(OrbotConstants.PREF_TOR_SHARED_PREFS,0 | Context.MODE_MULTI_PROCESS);
+    }
 }
diff --git a/orbotservice/src/main/java/org/torproject/android/service/util/TorServiceUtils.java b/orbotservice/src/main/java/org/torproject/android/service/util/TorServiceUtils.java
index e9e88590..018d7e42 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/util/TorServiceUtils.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/util/TorServiceUtils.java
@@ -13,10 +13,6 @@ import java.net.Socket;
 
 public class TorServiceUtils implements TorServiceConstants {
 
-	public static SharedPreferences getSharedPrefs (Context context) {
-		return context.getSharedPreferences(OrbotConstants.PREF_TOR_SHARED_PREFS,0 | Context.MODE_MULTI_PROCESS);
-	}
-
     public static boolean isPortOpen(final String ip, final int port, final int timeout) {
         try {
             Socket socket = new Socket();



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits