Skip to content

Commit

Permalink
Set required PendingIntent flag
Browse files Browse the repository at this point in the history
Closes #295
  • Loading branch information
Ch4t4r committed Jul 14, 2022
1 parent 6fb91da commit ecbfa87
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 20 deletions.
1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ apply plugin: 'kotlin-kapt'
def debugKeyPath = new File(System.properties['user.home'], ".android/debug.keystore")

android {
compileSdkVersion 31
compileSdkVersion 32
defaultConfig {
applicationId "com.frostnerd.smokescreen"
minSdkVersion 21
targetSdkVersion 31
minSdkVersion 23
targetSdkVersion 32
versionCode 80
versionName "2.1.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/frostnerd/smokescreen/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ fun <T : Activity>Activity.restart(activityClass: Class<T>? = null, exitProcess:
this,
RequestCodes.RESTART_WHOLE_APP,
intent,
PendingIntent.FLAG_CANCEL_CURRENT
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
(getSystemService(Context.ALARM_SERVICE) as AlarmManager).setExact(
AlarmManager.RTC,
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/frostnerd/smokescreen/SmokeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class SmokeScreen : Application() {
.setContentIntent(
PendingIntent.getActivity(
this, RequestCodes.CRASH_NOTIFICATION,
PinActivity.openAppIntent(this), PendingIntent.FLAG_UPDATE_CURRENT
PinActivity.openAppIntent(this), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
)
.setContentTitle(getString(R.string.notification_appcrash_title))
Expand All @@ -119,7 +119,7 @@ class SmokeScreen : Application() {
this,
LoggingDialogActivity::class.java
).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK),
PendingIntent.FLAG_CANCEL_CURRENT
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
notification.addAction(
R.drawable.ic_share,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class PinActivity: BaseActivity() {
.setContentTitle(context.getString(R.string.notification_pin_title))
.setContentText(context.getString(R.string.notification_pin_message))
.setStyle(NotificationCompat.BigTextStyle().bigText(context.getString(R.string.notification_pin_message)))
.setContentIntent(PendingIntent.getActivity(context, RequestCodes.PIN_NOTIFICATION, intent, PendingIntent.FLAG_CANCEL_CURRENT))
.setContentIntent(PendingIntent.getActivity(context, RequestCodes.PIN_NOTIFICATION, intent, PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE))
.setAutoCancel(true)
.setDefaults(NotificationCompat.DEFAULT_ALL)
.setPriority(NotificationCompat.PRIORITY_HIGH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,14 @@ class DnsVpnService : VpnService(), Runnable, CoroutineScope {
this@DnsVpnService,
RequestCodes.REQUEST_CODE_IGNORE_SERVICE_KILLED,
ignoreIntent,
PendingIntent.FLAG_UPDATE_CURRENT
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
} else {
PendingIntent.getService(
this@DnsVpnService,
RequestCodes.REQUEST_CODE_IGNORE_SERVICE_KILLED,
ignoreIntent,
PendingIntent.FLAG_UPDATE_CURRENT
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
}
NotificationCompat.Builder(this, Notifications.getDefaultNotificationChannelId(this))
Expand Down Expand Up @@ -403,7 +403,7 @@ class DnsVpnService : VpnService(), Runnable, CoroutineScope {
notificationBuilder.setContentIntent(
PendingIntent.getActivity(
this, RequestCodes.MAIN_NOTIFICATION,
PinActivity.openAppIntent(this), PendingIntent.FLAG_UPDATE_CURRENT
PinActivity.openAppIntent(this), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
)
if (getPreferences().allowStopInNotification) {
Expand All @@ -412,7 +412,7 @@ class DnsVpnService : VpnService(), Runnable, CoroutineScope {
this,
RequestCodes.MAIN_NOTIFICATION_STOP,
commandIntent(this, Command.STOP),
PendingIntent.FLAG_CANCEL_CURRENT
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
val stopAction = NotificationCompat.Action(
R.drawable.ic_stop,
Expand All @@ -427,7 +427,7 @@ class DnsVpnService : VpnService(), Runnable, CoroutineScope {
this,
RequestCodes.MAIN_NOTIFICATION_PAUSE,
commandIntent(this, Command.PAUSE_RESUME),
PendingIntent.FLAG_CANCEL_CURRENT
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
pauseNotificationAction = NotificationCompat.Action(
R.drawable.ic_stat_pause,
Expand Down Expand Up @@ -467,7 +467,7 @@ class DnsVpnService : VpnService(), Runnable, CoroutineScope {
noConnectionNotificationBuilder.setContentText(getString(R.string.notification_noconnection_text))
noConnectionNotificationBuilder.setContentIntent(PendingIntent.getActivity(
this, RequestCodes.NO_CONNECTION_NOTIFICATION,
PinActivity.openAppIntent(this), PendingIntent.FLAG_UPDATE_CURRENT
PinActivity.openAppIntent(this), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
)
noConnectionNotificationBuilder.setStyle(
Expand Down Expand Up @@ -585,14 +585,14 @@ class DnsVpnService : VpnService(), Runnable, CoroutineScope {
this@DnsVpnService,
RequestCodes.REQUEST_CODE_IGNORE_BAD_CONNECTION,
ignoreIntent,
PendingIntent.FLAG_UPDATE_CURRENT
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
} else {
PendingIntent.getService(
this@DnsVpnService,
RequestCodes.REQUEST_CODE_IGNORE_BAD_CONNECTION,
ignoreIntent,
PendingIntent.FLAG_UPDATE_CURRENT
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
}

Expand Down Expand Up @@ -991,7 +991,7 @@ class DnsVpnService : VpnService(), Runnable, CoroutineScope {
setSmallIcon(R.drawable.ic_cloud_warn)
setContentTitle(getString(R.string.notification_service_revoked_title))
setContentText(getString(R.string.notification_service_revoked_message))
setContentIntent(PendingIntent.getActivity(this@DnsVpnService, RequestCodes.RESTART_AFTER_REVOKE, Intent(this@DnsVpnService, BackgroundVpnConfigureActivity::class.java), PendingIntent.FLAG_CANCEL_CURRENT))
setContentIntent(PendingIntent.getActivity(this@DnsVpnService, RequestCodes.RESTART_AFTER_REVOKE, Intent(this@DnsVpnService, BackgroundVpnConfigureActivity::class.java), PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE))
setAutoCancel(true)
priority = NotificationCompat.PRIORITY_HIGH
}.build().also {
Expand Down Expand Up @@ -1046,7 +1046,7 @@ class DnsVpnService : VpnService(), Runnable, CoroutineScope {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
builder.setMetered(false)
}
builder.setConfigureIntent(PendingIntent.getActivity(this, RequestCodes.VPN_CONFIGURE, PinActivity.openAppIntent(this), PendingIntent.FLAG_CANCEL_CURRENT))
builder.setConfigureIntent(PendingIntent.getActivity(this, RequestCodes.VPN_CONFIGURE, PinActivity.openAppIntent(this), PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_IMMUTABLE))
val deviceHasIpv6 = hasDeviceIpv6Address()
val deviceHasIpv4 = hasDeviceIpv4Address()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class RuleExportService : IntentService("RuleExportService") {
this,
RequestCodes.RULE_EXPORT_ABORT,
Intent(this, RuleExportService::class.java).putExtra("abort", true),
PendingIntent.FLAG_CANCEL_CURRENT
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
val abortAction =
NotificationCompat.Action(R.drawable.ic_times, getString(android.R.string.cancel), abortPendingAction)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class RuleImportService : IntentService("RuleImportService") {
this,
RequestCodes.RULE_IMPORT_ABORT,
Intent(this, RuleImportService::class.java).putExtra("abort", true),
PendingIntent.FLAG_CANCEL_CURRENT
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
val abortAction =
NotificationCompat.Action(R.drawable.ic_times, getString(android.R.string.cancel), abortPendingAction)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ enum class DeepActionState {

fun pendingIntentTo(context: Context):PendingIntent {
val requestCode = RequestCodes.max + Random.nextInt(1, 9999)
return PendingIntent.getActivity(context, requestCode , intentTo(context), PendingIntent.FLAG_CANCEL_CURRENT)
return PendingIntent.getActivity(context, requestCode , intentTo(context), PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE)
}

private fun asBundle() = Bundle().apply { putSerializable("deep_action", this@DeepActionState) }
Expand Down

0 comments on commit ecbfa87

Please sign in to comment.