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

[tor-commits] [orbot/master] Battery permissions on v3 services



commit 85dba3bf440f68ba1036dda596f4adceea1b5d94
Author: bim <dsnake@xxxxxxxxxxxxxx>
Date:   Sat Nov 28 12:46:28 2020 -0500

    Battery permissions on v3 services
---
 .../android/ui/v3onionservice/OnionServicesActivity.java    | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/app/src/main/java/org/torproject/android/ui/v3onionservice/OnionServicesActivity.java b/app/src/main/java/org/torproject/android/ui/v3onionservice/OnionServicesActivity.java
index ba06b7c0..64a014e4 100644
--- a/app/src/main/java/org/torproject/android/ui/v3onionservice/OnionServicesActivity.java
+++ b/app/src/main/java/org/torproject/android/ui/v3onionservice/OnionServicesActivity.java
@@ -26,6 +26,7 @@ import org.torproject.android.core.DiskUtils;
 import org.torproject.android.core.LocaleHelper;
 import org.torproject.android.ui.hiddenservices.backup.BackupUtils;
 import org.torproject.android.ui.hiddenservices.backup.ZipUtilities;
+import org.torproject.android.ui.hiddenservices.permissions.PermissionManager;
 
 import java.io.File;
 
@@ -161,8 +162,16 @@ public class OnionServicesActivity extends AppCompatActivity {
 
         @Override
         public void onChange(boolean selfChange) {
-            mAdapter.changeCursor(mContentResolver.query(OnionServiceContentProvider.CONTENT_URI, OnionServiceContentProvider.PROJECTION, BASE_WHERE_SELECTION_CLAUSE + '1', null, null));
-            // todo battery optimization stuff if lollipop or higher and running onion services
+            filterServices(radioShowUserServices.isChecked()); // updates adapter
+            if (!PermissionManager.isLollipopOrHigher()) return;
+            Cursor activeServices = mContentResolver.query(OnionServiceContentProvider.CONTENT_URI, OnionServiceContentProvider.PROJECTION,
+                    OnionServiceContentProvider.OnionService.ENABLED + "=1", null, null);
+            if (activeServices == null) return;
+            if (activeServices.getCount() > 0)
+                PermissionManager.requestBatteryPermissions(OnionServicesActivity.this, getApplicationContext());
+            else
+                PermissionManager.requestDropBatteryPermissions(OnionServicesActivity.this, getApplicationContext());
+            activeServices.close();
         }
     }
 



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