Skip to content

Commit

Permalink
VPN-5900 (part 2): Don't send Android daemon metrics when switching s…
Browse files Browse the repository at this point in the history
…erver (#8793)

* vpn-5900 fix android daemon
  • Loading branch information
mcleinman authored Dec 12, 2023
1 parent a6d2fef commit 3b34f68
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class VPNService : android.net.VpnService() {
override fun onTick(millisUntilFinished: Long) {}
override fun onFinish() {
Log.i(tag, "Sending daemon_timer ping")
if (isSuperDooperMetricsActive) {
if (shouldRecordMetrics) {
Pings.daemonsession.submit(
Pings.daemonsessionReasonCodes.daemonTimer,
)
Expand All @@ -60,6 +60,17 @@ class VPNService : android.net.VpnService() {
return this.mConfig?.optBoolean("isSuperDooperFeatureActive", false) ?: false
}

private val isChangingServers: Boolean
get() {
// could be user choosing new server or silent switching
return (this.mConfig?.optInt("reason") ?: 0) == 1
}

private val shouldRecordMetrics: Boolean
get() {
return isSuperDooperMetricsActive && !isChangingServers
}

private val isUsingShortTimerSessionPing: Boolean
get() {
return this.mConfig?.optBoolean("isUsingShortTimerSessionPing", false) ?: false
Expand Down Expand Up @@ -338,7 +349,7 @@ class VPNService : android.net.VpnService() {
Log.i(tag, "Setting Glean debug tag for daemon.")
Glean.setDebugViewTag(gleanTag)
}
if (isSuperDooperMetricsActive) {
if (shouldRecordMetrics) {
val installationIdString = json.getString("installationId")
installationIdString?.let {
try {
Expand Down Expand Up @@ -421,7 +432,7 @@ class VPNService : android.net.VpnService() {
// Clear the notification message, so the content
// is not "disconnected" in case we connect from a non-client.
CannedNotification(mConfig)?.let { mNotificationHandler.hide(it) }
if (isSuperDooperMetricsActive) {
if (shouldRecordMetrics) {
Session.daemonSessionEnd.set()
Pings.daemonsession.submit(
Pings.daemonsessionReasonCodes.daemonEnd,
Expand Down

0 comments on commit 3b34f68

Please sign in to comment.