Skip to content

Commit 1c3a153

Browse files
Merge pull request #1476 from hussainmohd-a/v055m
v055m
2 parents 91ed53d + 9cbf03e commit 1c3a153

File tree

28 files changed

+391
-95
lines changed

28 files changed

+391
-95
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ dependencies {
249249
fullImplementation 'com.github.kirich1409:viewbindingpropertydelegate-noreflection:1.5.9'
250250

251251
// from: https://jitpack.io/#celzero/firestack
252-
download 'com.github.celzero:firestack:6cc4d626df@aar'
253-
implementation 'com.github.celzero:firestack:6cc4d626df@aar'
252+
download 'com.github.celzero:firestack:ad33ecd668@aar'
253+
implementation 'com.github.celzero:firestack:ad33ecd668@aar'
254254

255255
// Work manager
256256
implementation('androidx.work:work-runtime-ktx:2.9.0') {

app/src/main/java/com/celzero/bravedns/util/Logger.kt renamed to app/src/fdroid/java/com/celzero/bravedns/util/Logger.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ object Logger : KoinComponent {
7070
log(tag, message, LoggerType.ERROR, e)
7171
}
7272

73+
fun crash(tag: String, message: String, e: Exception) {
74+
log(tag, message, LoggerType.ERROR, e)
75+
}
76+
7377
fun updateConfigLevel(level: Long) {
7478
logLevel = level
7579
}

app/src/full/java/com/celzero/bravedns/customdownloader/RetrofitManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class RetrofitManager {
118118
}
119119
}
120120
} catch (e: Exception) {
121-
Logger.e(
121+
Logger.crash(
122122
Logger.LOG_TAG_DOWNLOAD,
123123
"err while getting custom dns: ${e.message}",
124124
e

app/src/full/java/com/celzero/bravedns/download/BlocklistDownloadHelper.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class BlocklistDownloadHelper {
164164
return processCheckDownloadResponse(r)
165165
}
166166
} catch (ex: Exception) {
167-
Logger.e(LOG_TAG_DOWNLOAD, "exception in checkBlocklistUpdate: ${ex.message}", ex)
167+
Logger.crash(LOG_TAG_DOWNLOAD, "exception in checkBlocklistUpdate: ${ex.message}", ex)
168168
}
169169
Logger.i(
170170
LOG_TAG_DOWNLOAD,
@@ -204,7 +204,7 @@ class BlocklistDownloadHelper {
204204

205205
return BlocklistUpdateServerResponse(version, shouldUpdate, timestamp)
206206
} catch (e: JSONException) {
207-
Logger.e(LOG_TAG_DOWNLOAD, "Error in parsing the response: ${e.message}", e)
207+
Logger.crash(LOG_TAG_DOWNLOAD, "Error in parsing the response: ${e.message}", e)
208208
}
209209
return null
210210
}

app/src/full/java/com/celzero/bravedns/service/WireguardManager.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ object WireguardManager : KoinComponent {
407407
}
408408

409409
fun getConfigIdForApp(uid: Int): WgConfigFilesImmutable? {
410+
// this method does not account the settings "Bypass all proxies" which is app-specific
410411
val configId = ProxyManager.getProxyIdForApp(uid)
411412
if (configId == "" || !configId.contains(ProxyManager.ID_WG_BASE)) {
412413
Logger.d(LOG_TAG_PROXY, "app config mapping not found for uid: $uid")

app/src/full/java/com/celzero/bravedns/ui/HomeScreenActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ class HomeScreenActivity : AppCompatActivity(R.layout.activity_home_screen) {
501501
installStateUpdatedListener
502502
) // Might be play updater or web updater
503503
} catch (e: Exception) {
504-
Logger.e(LOG_TAG_APP_UPDATE, "err in app update check: ${e.message}", e)
504+
Logger.crash(LOG_TAG_APP_UPDATE, "err in app update check: ${e.message}", e)
505505
showDownloadDialog(
506506
AppUpdater.InstallSource.STORE,
507507
getString(R.string.download_update_dialog_failure_title),

app/src/full/java/com/celzero/bravedns/ui/bottomsheet/ConnTrackerBottomSheet.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,19 @@ class ConnTrackerBottomSheet : BottomSheetDialogFragment(), KoinComponent {
439439

440440
if (a == fStatus && c == connStatus) return@io
441441

442+
if (VpnController.isVpnLockdown() && fStatus.isExclude()) {
443+
uiCtx {
444+
// reset the spinner to previous selection
445+
updateFirewallRulesUi(a, c)
446+
showToastUiCentered(
447+
requireContext(),
448+
getString(R.string.hsf_exclude_error),
449+
Toast.LENGTH_LONG
450+
)
451+
}
452+
return@io
453+
}
454+
442455
Logger.i(
443456
LOG_TAG_FIREWALL,
444457
"Change in firewall rule for app uid: ${info?.uid}, firewall status: $fStatus, conn status: $connStatus"

app/src/full/java/com/celzero/bravedns/ui/fragment/HomeScreenFragment.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,7 @@ class HomeScreenFragment : Fragment(R.layout.fragment_home_screen) {
11611161
// versions.
11621162
// VpnService.prepare() is now registered with requireContext() instead of context.
11631163
// Issue #469
1164+
Logger.i(LOG_TAG_VPN, "Preparing VPN service")
11641165
VpnService.prepare(requireContext())
11651166
} catch (e: NullPointerException) {
11661167
// This exception is not mentioned in the documentation, but it has been encountered
@@ -1172,9 +1173,11 @@ class HomeScreenFragment : Fragment(R.layout.fragment_home_screen) {
11721173
// If the VPN.prepare() is not null, then the first time VPN dialog is shown, Show info
11731174
// dialog before that.
11741175
if (prepareVpnIntent != null) {
1176+
Logger.i(LOG_TAG_VPN, "VPN service is prepared")
11751177
showFirstTimeVpnDialog(prepareVpnIntent)
11761178
return false
11771179
}
1180+
Logger.i(LOG_TAG_VPN, "VPN service is prepared, starting VPN service")
11781181
return true
11791182
}
11801183

app/src/full/java/com/celzero/bravedns/viewmodel/AppConnectionsViewModel.kt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ class AppConnectionsViewModel(private val nwlogDao: ConnectionTrackerDAO) : View
7575
startTime.value =
7676
System.currentTimeMillis() - ONE_HOUR_MILLIS
7777
}
78+
7879
TimeCategory.TWENTY_FOUR_HOUR -> {
7980
startTime.value =
8081
System.currentTimeMillis() - ONE_DAY_MILLIS
8182
}
83+
8284
TimeCategory.SEVEN_DAYS -> {
8385
startTime.value =
8486
System.currentTimeMillis() - ONE_WEEK_MILLIS
@@ -102,21 +104,21 @@ class AppConnectionsViewModel(private val nwlogDao: ConnectionTrackerDAO) : View
102104
private fun fetchIpLogs(uid: Int, input: String): LiveData<PagingData<AppConnection>> {
103105
val to = getStartTime()
104106
return if (input.isEmpty()) {
105-
Pager(pagingConfig) { nwlogDao.getAppIpLogs(uid, to) }
106-
} else {
107-
Pager(pagingConfig) { nwlogDao.getAppIpLogsFiltered(uid, to, "%$input%") }
108-
}
107+
Pager(pagingConfig) { nwlogDao.getAppIpLogs(uid, to) }
108+
} else {
109+
Pager(pagingConfig) { nwlogDao.getAppIpLogsFiltered(uid, to, "%$input%") }
110+
}
109111
.liveData
110112
.cachedIn(viewModelScope)
111113
}
112114

113115
private fun fetchAppDomainLogs(uid: Int, input: String): LiveData<PagingData<AppConnection>> {
114116
val to = getStartTime()
115117
return if (input.isEmpty()) {
116-
Pager(pagingConfig) { nwlogDao.getAppDomainLogs(uid, to) }
117-
} else {
118-
Pager(pagingConfig) { nwlogDao.getAppDomainLogsFiltered(uid, to, "%$input%") }
119-
}
118+
Pager(pagingConfig) { nwlogDao.getAppDomainLogs(uid, to) }
119+
} else {
120+
Pager(pagingConfig) { nwlogDao.getAppDomainLogsFiltered(uid, to, "%$input%") }
121+
}
120122
.liveData
121123
.cachedIn(viewModelScope)
122124
}
@@ -134,13 +136,15 @@ class AppConnectionsViewModel(private val nwlogDao: ConnectionTrackerDAO) : View
134136
}
135137

136138
fun getDomainLogsLimited(uid: Int): LiveData<PagingData<AppConnection>> {
137-
return Pager(pagingConfig) { nwlogDao.getAppDomainLogsLimited(uid) }
139+
val to = System.currentTimeMillis() - ONE_WEEK_MILLIS
140+
return Pager(pagingConfig) { nwlogDao.getAppDomainLogsLimited(uid, to) }
138141
.liveData
139142
.cachedIn(viewModelScope)
140143
}
141144

142145
fun getIpLogsLimited(uid: Int): LiveData<PagingData<AppConnection>> {
143-
return Pager(pagingConfig) { nwlogDao.getAppIpLogsLimited(uid) }
146+
val to = System.currentTimeMillis() - ONE_WEEK_MILLIS
147+
return Pager(pagingConfig) { nwlogDao.getAppIpLogsLimited(uid, to) }
144148
.liveData
145149
.cachedIn(viewModelScope)
146150
}

app/src/full/res/layout/list_item_app_domain_details.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
android:background="@drawable/drawable_purple_gradient"
9191
android:fontFamily="sans-serif-light"
9292
android:gravity="center"
93-
android:maxWidth="40dp"
93+
android:maxWidth="60dp"
9494
android:minWidth="40dp"
9595
android:padding="5dp"
9696
android:singleLine="true"

0 commit comments

Comments
 (0)