-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Connection tracking implementation and various issue fixes 0.4.4
Connection Tracking : Network monitor screen performance has been improved. New schema has been introduced to handle the changes. Now user has provision to search by app name and IP address. Filtering of logs based on blocked/all is implemented. Provision to delete the logs from network monitor. Some of the features are yet to be implemented. Bug FIxes: * Samsung Minor bug fix - Introduced the INTERACT_ACROSS_USERS permission for samsung devices. Always-on - prompt is shown now when user taps the 'Start' button. * Background Apps - Universal firewall for allow apps on background logic is changed. Now the uid's which are in range from APP_START to APP_END is included. Now it works as originally intended. #65 * Lwip Fix - A critical stability fix that caused frequent app crashes in the background. #32 * Accessbility Services - On-Interuppt method was not handled properly earlier. #75 * In Firewall screen the warning text for System apps in included. #70 * App crashes when other VPN is in active - Application state is now properly updated so that it can handle the other VPN active scenarios. * Right-to-Left languages - UI changes. The Home screen's 'Start' button and about page UI modifications to support rtl languages. * Firewall crash - app crash when there is change in installed/system packages. Now the app list is refreshed based on the app changes. When a new app in installed/modified/removed the list will be refreshed with the current data. * Auto-start - auto start of application is now been disabled. Will introduce advanced settings on later versions to enable/disable the auto start of app during phone boot updated #41
- Loading branch information
1 parent
9734485
commit c763dd6
Showing
60 changed files
with
2,200 additions
and
1,303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
app/src/main/java/com/celzero/bravedns/adapter/ConnectionTrackerAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package com.celzero.bravedns.adapter | ||
|
||
import android.util.Log | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.ImageView | ||
import android.widget.LinearLayout | ||
import android.widget.TextView | ||
import androidx.paging.PagedListAdapter | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.celzero.bravedns.R | ||
import com.celzero.bravedns.database.ConnectionTracker | ||
import com.celzero.bravedns.ui.ConnectionTrackerActivity | ||
import com.celzero.bravedns.util.Protocol | ||
import com.celzero.bravedns.util.Utilities | ||
|
||
class ConnectionTrackerAdapter(val activity : ConnectionTrackerActivity) : PagedListAdapter<ConnectionTracker, ConnectionTrackerAdapter.ConnectionTrackerViewHolder>(DIFF_CALLBACK) { | ||
|
||
|
||
companion object { | ||
private val DIFF_CALLBACK = object : | ||
DiffUtil.ItemCallback<ConnectionTracker>() { | ||
// Concert details may have changed if reloaded from the database, | ||
// but ID is fixed. | ||
override fun areItemsTheSame(oldConnection: ConnectionTracker, newConnection: ConnectionTracker) | ||
= oldConnection.id == newConnection.id | ||
|
||
override fun areContentsTheSame(oldConnection: ConnectionTracker, newConnection: ConnectionTracker) | ||
= oldConnection == newConnection | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ConnectionTrackerViewHolder { | ||
val v: View = LayoutInflater.from(parent.context).inflate( | ||
R.layout.connection_transaction_row, | ||
parent, false | ||
) | ||
return ConnectionTrackerViewHolder(v) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ConnectionTrackerViewHolder, position: Int) { | ||
val connTracker: ConnectionTracker? = getItem(position) | ||
holder.update(connTracker,position) | ||
} | ||
|
||
|
||
|
||
inner class ConnectionTrackerViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
|
||
// Overall view | ||
private var rowView: View? = null | ||
|
||
private var parentView: LinearLayout? = null | ||
|
||
// Contents of the condensed view | ||
private var timeView: TextView? = null | ||
private var flagView: TextView? = null | ||
|
||
private var fqdnView: TextView? = null | ||
private var ipView: TextView? = null | ||
private var latencyTxt: TextView? = null | ||
private var queryLayoutLL: LinearLayout? = null | ||
private var connectionType: TextView? = null | ||
private var appIcon: ImageView? = null | ||
private var connectionIndicator: TextView? = null | ||
|
||
init { | ||
rowView = itemView | ||
parentView = itemView.findViewById(R.id.connection_parent_layout) | ||
timeView = itemView.findViewById(R.id.connection_response_time) | ||
flagView = itemView.findViewById(R.id.connection_flag) | ||
fqdnView = itemView.findViewById(R.id.connection_app_name) | ||
ipView = itemView.findViewById(R.id.connection_ip_address) | ||
latencyTxt = itemView.findViewById(R.id.conn_latency_txt) | ||
connectionType = itemView.findViewById(R.id.connection_type) | ||
queryLayoutLL = itemView.findViewById(R.id.connection_screen_ll) | ||
appIcon = itemView.findViewById(R.id.connection_app_icon) | ||
connectionIndicator = itemView.findViewById(R.id.connection_status_indicator) | ||
} | ||
|
||
fun update(connTracker: ConnectionTracker?, position: Int) { | ||
if(connTracker != null){ | ||
var time = Utilities.convertLongToTime(connTracker.timeStamp) | ||
timeView!!.text = time | ||
flagView!!.text = connTracker.flag | ||
ipView!!.text = connTracker.ipAddress | ||
latencyTxt!!.text = connTracker.port.toString() | ||
fqdnView!!.text = connTracker.appName | ||
connectionType!!.text = Protocol.getProtocolName(connTracker.protocol).name | ||
if (connTracker.isBlocked) | ||
connectionIndicator!!.visibility = View.VISIBLE | ||
else | ||
connectionIndicator!!.visibility = View.INVISIBLE | ||
if (connTracker.appName != "Unknown") { | ||
try { | ||
var appArray = activity.packageManager.getPackagesForUid(connTracker!!.uid) | ||
appIcon!!.setImageDrawable(activity.packageManager.getApplicationIcon(appArray?.get(0)!!)) | ||
} catch (e: Exception) { | ||
appIcon!!.setImageDrawable(activity.getDrawable(R.drawable.default_app_icon)) | ||
Log.e("BraveDNS", "Package Not Found - " + e.message, e) | ||
} | ||
} | ||
|
||
/*parentView!!.setOnClickListener { | ||
val bottomSheetFragment = ConnTrackerBottomSheetFragment(activity, connTracker) | ||
val frag = activity as FragmentActivity | ||
bottomSheetFragment.show(frag.supportFragmentManager, bottomSheetFragment.tag) | ||
}*/ | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
} | ||
|
||
|
Oops, something went wrong.