Commit 57f8c0f3 authored by Max Lv's avatar Max Lv

disable notification auto-hiding on Kitkat and below #216

parent 601c2276
...@@ -160,6 +160,25 @@ LOCAL_SRC_FILES := $(addprefix shadowsocks-libev/libcork/,$(CORK_SOURCE)) ...@@ -160,6 +160,25 @@ LOCAL_SRC_FILES := $(addprefix shadowsocks-libev/libcork/,$(CORK_SOURCE))
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
########################################################
## libudns
########################################################
include $(CLEAR_VARS)
UDNS_SOURCES := udns_dn.c udns_dntosp.c udns_parse.c udns_resolver.c udns_init.c \
udns_misc.c udns_XtoX.c \
udns_rr_a.c udns_rr_ptr.c udns_rr_mx.c udns_rr_txt.c udns_bl.c \
udns_rr_srv.c udns_rr_naptr.c udns_codes.c udns_jran.c
LOCAL_MODULE := libudns
LOCAL_CFLAGS += -O2 -I$(LOCAL_PATH)/shadowsocks-libev/libudns \
-DHAVE_DECL_INET_NTOP
LOCAL_SRC_FILES := $(addprefix shadowsocks-libev/libudns/,$(UDNS_SOURCES))
include $(BUILD_STATIC_LIBRARY)
######################################################## ########################################################
## libev ## libev
######################################################## ########################################################
...@@ -223,12 +242,13 @@ LOCAL_CFLAGS := -Wall -O2 -fno-strict-aliasing -DUDPRELAY_LOCAL \ ...@@ -223,12 +242,13 @@ LOCAL_CFLAGS := -Wall -O2 -fno-strict-aliasing -DUDPRELAY_LOCAL \
-DUSE_CRYPTO_OPENSSL -DANDROID -DHAVE_CONFIG_H \ -DUSE_CRYPTO_OPENSSL -DANDROID -DHAVE_CONFIG_H \
-I$(LOCAL_PATH)/libev/ \ -I$(LOCAL_PATH)/libev/ \
-I$(LOCAL_PATH)/openssl/include \ -I$(LOCAL_PATH)/openssl/include \
-I$(LOCAL_PATH)/shadowsocks-libev/libudns \
-I$(LOCAL_PATH)/shadowsocks-libev/libcork/include \ -I$(LOCAL_PATH)/shadowsocks-libev/libcork/include \
-I$(LOCAL_PATH)/shadowsocks-libev/libsodium/src/libsodium/include \ -I$(LOCAL_PATH)/shadowsocks-libev/libsodium/src/libsodium/include \
-I$(LOCAL_PATH)/shadowsocks-libev/libsodium/src/libsodium/include/sodium \ -I$(LOCAL_PATH)/shadowsocks-libev/libsodium/src/libsodium/include/sodium \
-I$(LOCAL_PATH)/shadowsocks-libev/libipset/include -I$(LOCAL_PATH)/shadowsocks-libev/libipset/include
LOCAL_STATIC_LIBRARIES := libev libcrypto libipset libcork libsodium LOCAL_STATIC_LIBRARIES := libev libcrypto libipset libcork libudns libsodium
LOCAL_LDLIBS := -llog LOCAL_LDLIBS := -llog
...@@ -247,11 +267,13 @@ LOCAL_SRC_FILES := $(addprefix shadowsocks-libev/src/, $(SHADOWSOCKS_SOURCES)) ...@@ -247,11 +267,13 @@ LOCAL_SRC_FILES := $(addprefix shadowsocks-libev/src/, $(SHADOWSOCKS_SOURCES))
LOCAL_CFLAGS := -Wall -O2 -fno-strict-aliasing -DUDPRELAY_LOCAL -DUDPRELAY_TUNNEL \ LOCAL_CFLAGS := -Wall -O2 -fno-strict-aliasing -DUDPRELAY_LOCAL -DUDPRELAY_TUNNEL \
-DUSE_CRYPTO_OPENSSL -DANDROID -DHAVE_CONFIG_H -DSSTUNNEL_JNI \ -DUSE_CRYPTO_OPENSSL -DANDROID -DHAVE_CONFIG_H -DSSTUNNEL_JNI \
-I$(LOCAL_PATH)/libev/ \ -I$(LOCAL_PATH)/libev/ \
-I$(LOCAL_PATH)/shadowsocks-libev/libudns \
-I$(LOCAL_PATH)/shadowsocks-libev/libcork/include \
-I$(LOCAL_PATH)/shadowsocks-libev/libsodium/src/libsodium/include \ -I$(LOCAL_PATH)/shadowsocks-libev/libsodium/src/libsodium/include \
-I$(LOCAL_PATH)/shadowsocks-libev/libsodium/src/libsodium/include/sodium \ -I$(LOCAL_PATH)/shadowsocks-libev/libsodium/src/libsodium/include/sodium \
-I$(LOCAL_PATH)/openssl/include -I$(LOCAL_PATH)/openssl/include
LOCAL_STATIC_LIBRARIES := libev libcrypto libsodium LOCAL_STATIC_LIBRARIES := libev libcrypto libsodium libcork libudns
LOCAL_LDLIBS := -llog LOCAL_LDLIBS := -llog
......
Subproject commit 2a15e971969a1e068fc93b1c32d27de4814d1de8 Subproject commit 9cdc3dc7ef8e7a87169755a6b4287a5394745dd1
...@@ -513,31 +513,33 @@ class ShadowsocksNatService extends Service with BaseService { ...@@ -513,31 +513,33 @@ class ShadowsocksNatService extends Service with BaseService {
} }
registerReceiver(closeReceiver, filter) registerReceiver(closeReceiver, filter)
val screenFilter = new IntentFilter() if (Utils.isLollipopOrAbove) {
screenFilter.addAction(Intent.ACTION_SCREEN_ON) val screenFilter = new IntentFilter()
screenFilter.addAction(Intent.ACTION_SCREEN_OFF) screenFilter.addAction(Intent.ACTION_SCREEN_ON)
screenFilter.addAction(Intent.ACTION_USER_PRESENT) screenFilter.addAction(Intent.ACTION_SCREEN_OFF)
lockReceiver = new BroadcastReceiver() { screenFilter.addAction(Intent.ACTION_USER_PRESENT)
def onReceive(context: Context, intent: Intent) { lockReceiver = new BroadcastReceiver() {
if (getState == State.CONNECTED) { def onReceive(context: Context, intent: Intent) {
val action = intent.getAction if (getState == State.CONNECTED) {
if (action == Intent.ACTION_SCREEN_OFF) { val action = intent.getAction
notifyForegroundAlert(getString(R.string.forward_success), if (action == Intent.ACTION_SCREEN_OFF) {
getString(R.string.service_running).formatLocal(Locale.ENGLISH, config.profileName), false) notifyForegroundAlert(getString(R.string.forward_success),
} else if (action == Intent.ACTION_SCREEN_ON) { getString(R.string.service_running).formatLocal(Locale.ENGLISH, config.profileName), false)
val keyGuard = getSystemService(Context.KEYGUARD_SERVICE).asInstanceOf[KeyguardManager] } else if (action == Intent.ACTION_SCREEN_ON) {
if (!keyGuard.inKeyguardRestrictedInputMode) { val keyGuard = getSystemService(Context.KEYGUARD_SERVICE).asInstanceOf[KeyguardManager]
if (!keyGuard.inKeyguardRestrictedInputMode) {
notifyForegroundAlert(getString(R.string.forward_success),
getString(R.string.service_running).formatLocal(Locale.ENGLISH, config.profileName), true)
}
} else if (action == Intent.ACTION_USER_PRESENT) {
notifyForegroundAlert(getString(R.string.forward_success), notifyForegroundAlert(getString(R.string.forward_success),
getString(R.string.service_running).formatLocal(Locale.ENGLISH, config.profileName), true) getString(R.string.service_running).formatLocal(Locale.ENGLISH, config.profileName), true)
} }
} else if (action == Intent.ACTION_USER_PRESENT) { }
notifyForegroundAlert(getString(R.string.forward_success),
getString(R.string.service_running).formatLocal(Locale.ENGLISH, config.profileName), true)
} }
} }
} registerReceiver(lockReceiver, screenFilter)
} }
registerReceiver(lockReceiver, screenFilter)
// send event // send event
application.tracker.send(new HitBuilders.EventBuilder() application.tracker.send(new HitBuilders.EventBuilder()
...@@ -606,9 +608,12 @@ class ShadowsocksNatService extends Service with BaseService { ...@@ -606,9 +608,12 @@ class ShadowsocksNatService extends Service with BaseService {
unregisterReceiver(closeReceiver) unregisterReceiver(closeReceiver)
closeReceiver = null closeReceiver = null
} }
if (lockReceiver != null) {
unregisterReceiver(lockReceiver) if (Utils.isLollipopOrAbove) {
lockReceiver = null if (lockReceiver != null) {
unregisterReceiver(lockReceiver)
lockReceiver = null
}
} }
// send event // send event
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment