@@ -28,13 +28,15 @@ import android.app.NotificationChannel
2828import android.app.NotificationManager
2929import android.app.PendingIntent
3030import android.app.Service
31+ import android.app.UiModeManager
3132import android.content.Context
3233import android.content.Intent
3334import android.content.SharedPreferences
3435import android.content.SharedPreferences.OnSharedPreferenceChangeListener
3536import android.content.pm.PackageManager
3637import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE
3738import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SYSTEM_EXEMPTED
39+ import android.content.res.Configuration
3840import android.net.ConnectivityManager
3941import android.net.Network
4042import android.net.NetworkCapabilities
@@ -1273,11 +1275,18 @@ class BraveVPNService :
12731275 // 1. Pause / Resume, Stop action button.
12741276 // 2. RethinkDNS modes (dns & dns+firewall mode)
12751277 // 3. No action button.
1276- logd(" notification action type: ${persistentState.notificationActionType} " )
1278+ val isAppLockEnabled = persistentState.biometricAuth && ! isAppRunningOnTv()
1279+ // do not show notification action when app lock is enabled
1280+ val notifActionType = if (isAppLockEnabled) {
1281+ NotificationActionType .NONE
1282+ } else {
1283+ NotificationActionType .getNotificationActionType(
1284+ persistentState.notificationActionType
1285+ )
1286+ }
1287+ logd(" notification action type: ${persistentState.notificationActionType} , $notifActionType " )
12771288
1278- when (
1279- NotificationActionType .getNotificationActionType(persistentState.notificationActionType)
1280- ) {
1289+ when (notifActionType) {
12811290 NotificationActionType .PAUSE_STOP -> {
12821291 // Add the action based on AppState (PAUSE/ACTIVE)
12831292 val openIntent1 =
@@ -1343,6 +1352,7 @@ class BraveVPNService :
13431352
13441353 NotificationActionType .NONE -> {
13451354 Logger .i(LOG_TAG_VPN , " No notification action" )
1355+ builder.setContentTitle(contentTitle)
13461356 }
13471357 }
13481358
@@ -1370,6 +1380,15 @@ class BraveVPNService :
13701380 return notification
13711381 }
13721382
1383+ private fun isAppRunningOnTv (): Boolean {
1384+ return try {
1385+ val uiModeManager: UiModeManager = getSystemService(UI_MODE_SERVICE ) as UiModeManager
1386+ uiModeManager.currentModeType == Configuration .UI_MODE_TYPE_TELEVISION
1387+ } catch (ignored: Exception ) {
1388+ false
1389+ }
1390+ }
1391+
13731392 // keep in sync with RefreshDatabase#makeVpnIntent
13741393 private fun makeVpnIntent (notificationID : Int , intentExtra : String ): PendingIntent {
13751394 val intent = Intent (this , NotificationActionReceiver ::class .java)
@@ -1727,6 +1746,11 @@ class BraveVPNService :
17271746 notificationManager.notify(SERVICE_ID , updateNotificationBuilder())
17281747 }
17291748
1749+ PersistentState .BIOMETRIC_AUTH -> {
1750+ // update the notification builder to show the action buttons based on the biometric
1751+ notificationManager.notify(SERVICE_ID , updateNotificationBuilder())
1752+ }
1753+
17301754 PersistentState .INTERNET_PROTOCOL -> {
17311755 io(" chooseIpVersion" ) { handleIPProtoChanges() }
17321756 }
0 commit comments