Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
PublicAndroidApps
Nebulo
Commits
3d3f4fd6
Commit
3d3f4fd6
authored
Nov 17, 2019
by
Daniel Wolf
Browse files
Don't use the same request code for all pending intents
parent
e05d033a
Changes
7
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/com/frostnerd/smokescreen/SmokeScreen.kt
View file @
3d3f4fd6
...
...
@@ -12,6 +12,7 @@ import com.frostnerd.smokescreen.activity.PinActivity
import
com.frostnerd.smokescreen.database.AppDatabase
import
com.frostnerd.smokescreen.util.crashhelpers.DatasavingSentryEventHelper
import
com.frostnerd.smokescreen.util.Notifications
import
com.frostnerd.smokescreen.util.RequestCodes
import
com.frostnerd.smokescreen.util.preferences.AppSettings
import
com.frostnerd.smokescreen.util.preferences.Crashreporting
import
io.sentry.Sentry
...
...
@@ -54,7 +55,7 @@ class SmokeScreen : Application() {
.
setAutoCancel
(
true
)
.
setContentIntent
(
PendingIntent
.
getActivity
(
this
,
1
,
this
,
RequestCodes
.
CRASH_NOTIFICATION
,
PinActivity
.
openAppIntent
(
this
),
PendingIntent
.
FLAG_UPDATE_CURRENT
)
)
...
...
@@ -62,7 +63,7 @@ class SmokeScreen : Application() {
if
(
getPreferences
().
loggingEnabled
)
{
val
pendingIntent
=
PendingIntent
.
getActivity
(
this
,
1
,
RequestCodes
.
CRASH_NOTIFICATION_SEND_LOGS
,
Intent
(
this
,
LoggingDialogActivity
::
class
.
java
...
...
app/src/main/java/com/frostnerd/smokescreen/activity/PinActivity.kt
View file @
3d3f4fd6
...
...
@@ -27,6 +27,7 @@ import com.frostnerd.smokescreen.service.Command
import
com.frostnerd.smokescreen.service.DnsVpnService
import
com.frostnerd.smokescreen.util.LanguageContextWrapper
import
com.frostnerd.smokescreen.util.Notifications
import
com.frostnerd.smokescreen.util.RequestCodes
import
kotlinx.android.synthetic.main.dialog_pin.view.*
import
java.math.BigInteger
import
java.security.MessageDigest
...
...
@@ -58,12 +59,14 @@ class PinActivity: BaseActivity() {
fun
openAppIntent
(
context
:
Context
,
extras
:
Bundle
?
=
null
):
Intent
{
return
if
(
shouldValidatePin
(
context
,
null
))
{
println
(
">>>>>>>>>>>>>>>>>>>>>> ASK PIN"
)
val
intent
=
Intent
(
context
,
PinActivity
::
class
.
java
)
if
(
intent
.
extras
!=
null
)
intent
.
putExtra
(
"extras"
,
extras
)
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
intent
.
putExtra
(
"pin_type"
,
PinType
.
APP
)
intent
}
else
{
println
(
">>>>>>>>>> TO MAIN"
)
Intent
(
context
,
MainActivity
::
class
.
java
).
apply
{
if
(
extras
!=
null
)
putExtras
(
extras
)
}
...
...
@@ -82,7 +85,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
,
1
,
intent
,
PendingIntent
.
FLAG_CANCEL_CURRENT
))
.
setContentIntent
(
PendingIntent
.
getActivity
(
context
,
RequestCodes
.
PIN_NOTIFICATION
,
intent
,
PendingIntent
.
FLAG_CANCEL_CURRENT
))
.
setAutoCancel
(
true
)
.
setDefaults
(
NotificationCompat
.
DEFAULT_ALL
)
.
setPriority
(
NotificationCompat
.
PRIORITY_HIGH
)
...
...
app/src/main/java/com/frostnerd/smokescreen/service/DnsVpnService.kt
View file @
3d3f4fd6
...
...
@@ -34,6 +34,7 @@ import com.frostnerd.smokescreen.database.getDatabase
import
com.frostnerd.smokescreen.dialog.DnsRuleDialog
import
com.frostnerd.smokescreen.util.DeepActionState
import
com.frostnerd.smokescreen.util.Notifications
import
com.frostnerd.smokescreen.util.RequestCodes
import
com.frostnerd.smokescreen.util.preferences.VpnServiceState
import
com.frostnerd.smokescreen.util.proxy.*
import
com.frostnerd.vpntunnelproxy.FutureAnswer
...
...
@@ -114,7 +115,6 @@ class DnsVpnService : VpnService(), Runnable {
const
val
BROADCAST_VPN_ACTIVE
=
BuildConfig
.
APPLICATION_ID
+
".VPN_ACTIVE"
const
val
BROADCAST_VPN_INACTIVE
=
BuildConfig
.
APPLICATION_ID
+
".VPN_INACTIVE"
const
val
BROADCAST_DNSRULES_REFRESHED
=
BuildConfig
.
APPLICATION_ID
+
".DNSRULE_REFRESH"
private
const
val
REQUEST_CODE_IGNORE_SERVICE_KILLED
=
10
var
currentTrafficStats
:
TrafficStats
?
=
null
private
set
...
...
@@ -179,16 +179,16 @@ class DnsVpnService : VpnService(), Runnable {
val
ignorePendingIntent
=
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
PendingIntent
.
getForegroundService
(
this
@DnsVpnService
,
REQUEST_CODE_IGNORE_SERVICE_KILLED
,
RequestCodes
.
REQUEST_CODE_IGNORE_SERVICE_KILLED
,
ignoreIntent
,
PendingIntent
.
FLAG_
ONE_SHO
T
PendingIntent
.
FLAG_
UPDATE_CURREN
T
)
}
else
{
PendingIntent
.
getService
(
this
@DnsVpnService
,
REQUEST_CODE_IGNORE_SERVICE_KILLED
,
RequestCodes
.
REQUEST_CODE_IGNORE_SERVICE_KILLED
,
ignoreIntent
,
PendingIntent
.
FLAG_
ONE_SHO
T
PendingIntent
.
FLAG_
UPDATE_CURREN
T
)
}
NotificationCompat
.
Builder
(
this
,
Notifications
.
getDefaultNotificationChannelId
(
this
))
...
...
@@ -367,7 +367,7 @@ class DnsVpnService : VpnService(), Runnable {
notificationBuilder
.
setUsesChronometer
(!
getPreferences
().
simpleNotification
)
notificationBuilder
.
setContentIntent
(
PendingIntent
.
getActivity
(
this
,
1
,
this
,
RequestCodes
.
MAIN_NOTIFICATION
,
PinActivity
.
openAppIntent
(
this
),
PendingIntent
.
FLAG_UPDATE_CURRENT
)
)
...
...
@@ -375,7 +375,7 @@ class DnsVpnService : VpnService(), Runnable {
val
stopPendingIntent
=
PendingIntent
.
getService
(
this
,
1
,
RequestCodes
.
MAIN_NOTIFICATION_STOP
,
commandIntent
(
this
,
Command
.
STOP
),
PendingIntent
.
FLAG_CANCEL_CURRENT
)
...
...
@@ -390,7 +390,7 @@ class DnsVpnService : VpnService(), Runnable {
val
pausePendingIntent
=
PendingIntent
.
getService
(
this
,
2
,
RequestCodes
.
MAIN_NOTIFICATION_PAUSE
,
commandIntent
(
this
,
Command
.
PAUSE_RESUME
),
PendingIntent
.
FLAG_CANCEL_CURRENT
)
...
...
@@ -756,7 +756,7 @@ class DnsVpnService : VpnService(), Runnable {
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
{
builder
.
setMetered
(
false
)
}
builder
.
setConfigureIntent
(
PendingIntent
.
getActivity
(
this
,
1
,
PinActivity
.
openAppIntent
(
this
),
PendingIntent
.
FLAG_CANCEL_CURRENT
))
builder
.
setConfigureIntent
(
PendingIntent
.
getActivity
(
this
,
RequestCodes
.
VPN_CONFIGURE
,
PinActivity
.
openAppIntent
(
this
),
PendingIntent
.
FLAG_CANCEL_CURRENT
))
val
deviceHasIpv6
=
hasDeviceIpv6Address
()
val
deviceHasIpv4
=
hasDeviceIpv4Address
()
...
...
app/src/main/java/com/frostnerd/smokescreen/service/RuleExportService.kt
View file @
3d3f4fd6
...
...
@@ -14,6 +14,7 @@ import com.frostnerd.smokescreen.database.getDatabase
import
com.frostnerd.smokescreen.sendLocalBroadcast
import
com.frostnerd.smokescreen.util.DeepActionState
import
com.frostnerd.smokescreen.util.Notifications
import
com.frostnerd.smokescreen.util.RequestCodes
import
com.frostnerd.smokescreen.watchIfEnabled
import
leakcanary.LeakSentry
import
java.io.BufferedWriter
...
...
@@ -88,7 +89,7 @@ class RuleExportService : IntentService("RuleExportService") {
notification
!!
.
setContentIntent
(
DeepActionState
.
DNS_RULES
.
pendingIntentTo
(
this
))
val
abortPendingAction
=
PendingIntent
.
getService
(
this
,
1
,
RequestCodes
.
RULE_EXPORT_ABORT
,
Intent
(
this
,
RuleExportService
::
class
.
java
).
putExtra
(
"abort"
,
true
),
PendingIntent
.
FLAG_CANCEL_CURRENT
)
...
...
app/src/main/java/com/frostnerd/smokescreen/service/RuleImportService.kt
View file @
3d3f4fd6
...
...
@@ -17,6 +17,7 @@ import com.frostnerd.smokescreen.log
import
com.frostnerd.smokescreen.sendLocalBroadcast
import
com.frostnerd.smokescreen.util.DeepActionState
import
com.frostnerd.smokescreen.util.Notifications
import
com.frostnerd.smokescreen.util.RequestCodes
import
com.frostnerd.smokescreen.watchIfEnabled
import
leakcanary.LeakSentry
import
okhttp3.OkHttpClient
...
...
@@ -107,7 +108,7 @@ class RuleImportService : IntentService("RuleImportService") {
notification
!!
.
setContentIntent
(
DeepActionState
.
DNS_RULES
.
pendingIntentTo
(
this
))
val
abortPendingAction
=
PendingIntent
.
getService
(
this
,
1
,
RequestCodes
.
RULE_IMPORT_ABORT
,
Intent
(
this
,
RuleImportService
::
class
.
java
).
putExtra
(
"abort"
,
true
),
PendingIntent
.
FLAG_CANCEL_CURRENT
)
...
...
app/src/main/java/com/frostnerd/smokescreen/util/DeepActionState.kt
View file @
3d3f4fd6
...
...
@@ -5,6 +5,7 @@ import android.content.Context
import
android.content.Intent
import
android.os.Bundle
import
com.frostnerd.smokescreen.activity.PinActivity
import
kotlin.random.Random
/*
* Copyright (C) 2019 Daniel Wolf (Ch4t4r)
...
...
@@ -34,6 +35,6 @@ enum class DeepActionState {
}
fun
pendingIntentTo
(
context
:
Context
):
PendingIntent
{
return
PendingIntent
.
getActivity
(
context
,
1
,
intentTo
(
context
),
PendingIntent
.
FLAG_CANCEL_CURRENT
)
return
PendingIntent
.
getActivity
(
context
,
RequestCodes
.
max
+
Random
.
nextInt
(
1
,
9999
)
,
intentTo
(
context
),
PendingIntent
.
FLAG_CANCEL_CURRENT
)
}
}
\ No newline at end of file
app/src/main/java/com/frostnerd/smokescreen/util/Notifications.kt
View file @
3d3f4fd6
...
...
@@ -105,4 +105,19 @@ class Notifications {
return
"pinchannel"
}
}
}
object
RequestCodes
{
val
max
=
20
val
CRASH_NOTIFICATION
=
1
val
CRASH_NOTIFICATION_SEND_LOGS
=
2
val
MAIN_NOTIFICATION
=
3
val
MAIN_NOTIFICATION_STOP
=
4
val
MAIN_NOTIFICATION_PAUSE
=
5
val
VPN_CONFIGURE
=
6
val
RULE_IMPORT_ABORT
=
7
val
RULE_EXPORT_ABORT
=
8
val
PIN_NOTIFICATION
=
9
val
REQUEST_CODE_IGNORE_SERVICE_KILLED
=
10
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment