Skip to content

Commit c8a13af

Browse files
committed
Merge branch 'master' into snowflake_bridge_script
2 parents ba8a254 + b610f94 commit c8a13af

File tree

45 files changed

+251
-281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+251
-281
lines changed

OrbotLib/OrbotLib.aar

-42.2 KB
Binary file not shown.

app-tv/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ android {
55
defaultConfig {
66
applicationId "org.torproject.android.tv"
77
minSdkVersion 23
8-
targetSdkVersion 33
8+
targetSdkVersion 34
99
}
1010

1111
buildTypes {
@@ -22,7 +22,7 @@ android {
2222
dimension "teevee"
2323
minSdkVersion 23
2424
applicationId 'org.torproject.android.tv'
25-
compileSdkVersion 33
25+
compileSdkVersion 34
2626
versionCode 10020000
2727
versionName 'orbot-tv-1.0.1-tor-0.4.7.14'
2828
archivesBaseName = "Orbot-TV-$versionName"

app/build.gradle

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ android {
2121
applicationId "org.torproject.android"
2222
versionName getVersionName()
2323
minSdkVersion 23
24-
compileSdkVersion 33
25-
targetSdkVersion 33
24+
compileSdk 34
25+
targetSdkVersion 34
2626
multiDexEnabled true
2727
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
2828
archivesBaseName = "Orbot"
@@ -47,7 +47,7 @@ android {
4747
fullperm {
4848
dimension "free"
4949
applicationId 'org.torproject.android'
50-
versionCode 1721300100
50+
versionCode 1722300100
5151
versionName getVersionName()
5252
archivesBaseName = "Orbot-${versionName}"
5353
}
@@ -103,14 +103,14 @@ android {
103103
namespace 'org.torproject.android'
104104
}
105105
dependencies {
106-
implementation "androidx.core:core-ktx:1.8.0"
106+
implementation "androidx.core:core-ktx:1.13.1"
107107
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
108-
testImplementation 'junit:junit:4.12'
109-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
110-
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
108+
testImplementation 'junit:junit:4.13.2'
109+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
110+
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
111111
// Kotlin
112-
implementation "androidx.navigation:navigation-fragment-ktx:2.5.3"
113-
implementation "androidx.navigation:navigation-ui-ktx:2.5.3"
112+
implementation "androidx.navigation:navigation-fragment-ktx:2.7.7"
113+
implementation "androidx.navigation:navigation-ui-ktx:2.7.7"
114114

115115
//root detection
116116
implementation 'com.scottyab:rootbeer-lib:0.1.0'

app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919

2020
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
2121

22-
<!-- for Android 13 -->
22+
<!-- For Android 13 -->
2323
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
2424

25+
<!-- For Android 14 -->
26+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
2527

2628
<queries>
2729
<intent>
@@ -40,8 +42,7 @@
4042
android:theme="@style/DefaultTheme"
4143
tools:replace="android:allowBackup"
4244
android:hasFragileUserData="false"
43-
android:taskAffinity=""
44-
>
45+
android:taskAffinity="">
4546

4647
<activity android:name=".OrbotActivity"
4748
android:excludeFromRecents="false"

app/src/main/java/org/torproject/android/ConnectFragment.kt

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ import android.content.Context
55
import android.content.Intent
66
import android.content.res.ColorStateList
77
import android.graphics.Paint
8-
import android.net.ConnectivityManager
9-
import android.net.NetworkCapabilities
108
import android.net.VpnService
11-
import android.os.Build
129
import android.os.Bundle
1310
import android.os.Handler
1411
import android.os.Looper
@@ -19,10 +16,14 @@ import android.view.ViewGroup
1916
import android.view.animation.Animation
2017
import android.view.animation.AnimationUtils
2118
import android.widget.*
19+
2220
import androidx.appcompat.app.AppCompatActivity
2321
import androidx.core.content.ContextCompat
2422
import androidx.fragment.app.Fragment
23+
2524
import net.freehaven.tor.control.TorControlCommands
25+
26+
import org.torproject.android.core.NetworkUtils.isNetworkAvailable
2627
import org.torproject.android.core.putNotSystem
2728
import org.torproject.android.service.OrbotConstants
2829
import org.torproject.android.service.OrbotService
@@ -78,7 +79,6 @@ class ConnectFragment : Fragment(), ConnectionHelperCallbacks,
7879
if (!isNetworkAvailable(requireContext())) {
7980
doLayoutNoInternet(requireContext())
8081
} else {
81-
8282
when (lastStatus) {
8383
OrbotConstants.STATUS_OFF -> doLayoutOff()
8484
OrbotConstants.STATUS_STARTING -> doLayoutStarting(requireContext())
@@ -88,7 +88,6 @@ class ConnectFragment : Fragment(), ConnectionHelperCallbacks,
8888
doLayoutOff()
8989
}
9090
}
91-
9291
}
9392

9493

@@ -97,37 +96,6 @@ class ConnectFragment : Fragment(), ConnectionHelperCallbacks,
9796
return view
9897
}
9998

100-
private fun isNetworkAvailable(context: Context?): Boolean {
101-
if (context == null) return false
102-
val connectivityManager =
103-
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
104-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
105-
val capabilities =
106-
connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)
107-
if (capabilities != null) {
108-
when {
109-
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> {
110-
return true
111-
}
112-
113-
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> {
114-
return true
115-
}
116-
117-
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> {
118-
return true
119-
}
120-
}
121-
}
122-
} else {
123-
val activeNetworkInfo = connectivityManager.activeNetworkInfo
124-
if (activeNetworkInfo != null && activeNetworkInfo.isConnected) {
125-
return true
126-
}
127-
}
128-
return false
129-
}
130-
13199
private fun stopTorAndVpn() {
132100
sendIntentToService(OrbotConstants.ACTION_STOP)
133101
sendIntentToService(OrbotConstants.ACTION_STOP_VPN)

app/src/main/java/org/torproject/android/OrbotActivity.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,21 +215,20 @@ class OrbotActivity : BaseActivity() {
215215
allCircumventionAttemptsFailed = false
216216
return
217217
}
218-
var shouldDoOffLayout = true
219-
if (Prefs.getConnectionPathway().equals(Prefs.PATHWAY_SMART)) {
220-
shouldDoOffLayout = false
218+
if (!Prefs.getConnectionPathway().equals(Prefs.PATHWAY_SMART) && fragConnect.isAdded && fragConnect.context != null) {
219+
fragConnect.doLayoutOff()
221220
}
222-
if (shouldDoOffLayout && fragConnect.isAdded) fragConnect.doLayoutOff()
223-
} else fragConnect.doLayoutOff()
221+
} else if (fragConnect.isAdded && fragConnect.context != null) {
222+
fragConnect.doLayoutOff()
223+
}
224224
}
225225

226-
OrbotConstants.STATUS_STARTING -> fragConnect.doLayoutStarting(this@OrbotActivity)
227-
OrbotConstants.STATUS_ON -> fragConnect.doLayoutOn(this@OrbotActivity)
226+
OrbotConstants.STATUS_STARTING -> if (fragConnect.isAdded && fragConnect.context != null) fragConnect.doLayoutStarting(this@OrbotActivity)
227+
OrbotConstants.STATUS_ON -> if (fragConnect.isAdded && fragConnect.context != null) fragConnect.doLayoutOn(this@OrbotActivity)
228228
OrbotConstants.STATUS_STOPPING -> {}
229229
}
230230

231231
previousReceivedTorStatus = status
232-
233232
}
234233

235234
OrbotConstants.LOCAL_ACTION_LOG -> {

app/src/main/java/org/torproject/android/ui/LogBottomSheet.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import android.os.Bundle
77
import android.view.LayoutInflater
88
import android.view.View
99
import android.view.ViewGroup
10-
import android.widget.Button
1110
import android.widget.TextView
1211
import android.widget.Toast
12+
13+
import com.google.android.material.floatingactionbutton.FloatingActionButton
14+
1315
import org.torproject.android.OrbotBottomSheetDialogFragment
1416
import org.torproject.android.R
1517

@@ -25,7 +27,7 @@ class LogBottomSheet : OrbotBottomSheetDialogFragment() {
2527
tvLog = v.findViewById(R.id.orbotLog)
2628
tvLog.text = buffer.toString()
2729

28-
v.findViewById<Button>(R.id.btnCopyLog).setOnClickListener {
30+
v.findViewById<FloatingActionButton>(R.id.btnCopyLog).setOnClickListener {
2931
val clipboard = context?.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
3032
val clip: ClipData = ClipData.newPlainText("log", tvLog.text)
3133
clipboard.setPrimaryClip(clip)

app/src/main/java/org/torproject/android/ui/v3onionservice/PermissionManager.java

Lines changed: 0 additions & 59 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package org.torproject.android.ui.v3onionservice
2+
3+
import android.content.Context
4+
import android.content.Intent
5+
import android.net.Uri
6+
import android.os.PowerManager
7+
import android.provider.Settings
8+
import android.view.View
9+
10+
import androidx.fragment.app.FragmentActivity
11+
12+
import com.google.android.material.snackbar.Snackbar
13+
14+
import org.torproject.android.R
15+
16+
object PermissionManager {
17+
private const val SNACK_BAR_DURATION = 5000
18+
19+
@JvmStatic
20+
fun requestBatteryPermissions(activity: FragmentActivity, view: View) {
21+
val packageName = activity.packageName
22+
val pm = activity.applicationContext.getSystemService(Context.POWER_SERVICE) as PowerManager
23+
24+
if (pm.isIgnoringBatteryOptimizations(packageName)) {
25+
return
26+
}
27+
28+
Snackbar.make(view, R.string.consider_disable_battery_optimizations,
29+
SNACK_BAR_DURATION).setAction(R.string.disable) {
30+
val intent = Intent().apply {
31+
action = Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
32+
data = Uri.parse("package:$packageName")
33+
}
34+
activity.startActivity(intent)
35+
}.show()
36+
}
37+
38+
@JvmStatic
39+
fun requestDropBatteryPermissions(activity: FragmentActivity, view: View) {
40+
val pm = activity.applicationContext.getSystemService(Context.POWER_SERVICE) as PowerManager
41+
if (!pm.isIgnoringBatteryOptimizations(activity.packageName)) {
42+
return
43+
}
44+
45+
Snackbar.make(view, R.string.consider_enable_battery_optimizations,
46+
SNACK_BAR_DURATION).setAction(R.string.enable) {
47+
val intent = Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS)
48+
activity.startActivity(intent)
49+
}.show()
50+
}
51+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="960"
5+
android:viewportHeight="960"
6+
android:tint="?attr/colorControlNormal"
7+
android:autoMirrored="true">
8+
<path
9+
android:fillColor="@android:color/white"
10+
android:pathData="M360,720Q327,720 303.5,696.5Q280,673 280,640L280,160Q280,127 303.5,103.5Q327,80 360,80L720,80Q753,80 776.5,103.5Q800,127 800,160L800,640Q800,673 776.5,696.5Q753,720 720,720L360,720ZM360,640L720,640Q720,640 720,640Q720,640 720,640L720,160Q720,160 720,160Q720,160 720,160L360,160Q360,160 360,160Q360,160 360,160L360,640Q360,640 360,640Q360,640 360,640ZM200,880Q167,880 143.5,856.5Q120,833 120,800L120,240L200,240L200,800Q200,800 200,800Q200,800 200,800L640,800L640,880L200,880ZM360,640Q360,640 360,640Q360,640 360,640L360,160Q360,160 360,160Q360,160 360,160L360,160Q360,160 360,160Q360,160 360,160L360,640Q360,640 360,640Q360,640 360,640L360,640Z"/>
11+
</vector>

0 commit comments

Comments
 (0)