Skip to content

Commit fdddeaa

Browse files
committed
FIX: WeChat is unexpectedly launched upon notification arrival of new conversation.
After WeChat v8.0.30.
1 parent 9daaa8b commit fdddeaa

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/main/java/com/oasisfeng/nevo/decorators/wechat/WeChatDecorator.kt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.oasisfeng.nevo.decorators.wechat
1818

19+
import android.app.ActivityOptions
1920
import android.app.Notification.*
2021
import android.app.NotificationChannel
2122
import android.app.NotificationManager
@@ -99,12 +100,6 @@ class WeChatDecorator : NevoDecoratorService() {
99100
try { return UserHandle(parcel.apply { writeInt(user); setDataPosition(0) }) }
100101
finally { parcel.recycle() }
101102
}
102-
103-
private fun buildParcelableWithFileDescriptor(): Parcelable? {
104-
try { return if (SDK_INT >= Q) SharedMemory.create(null, 1) else ParcelFileDescriptor.createPipe()[0] }
105-
catch (e: Exception) { Log.e(TAG, "Partially incompatible ROM: " + e.message) }
106-
return null
107-
}
108103
}
109104

110105
public override fun apply(evolving: MutableStatusBarNotification): Boolean {
@@ -152,15 +147,15 @@ class WeChatDecorator : NevoDecoratorService() {
152147
if (messaging == null) return true
153148
val messages = messaging.messages
154149
if (messages.isEmpty()) return true
155-
if (conversation.id == null && mActivityBlocker != null) try {
150+
if (conversation.id == null) try {
156151
val latch = CountDownLatch(1)
157-
n.contentIntent.send(this, 0, Intent().putExtra("", mActivityBlocker), { _: PendingIntent?, intent: Intent, _: Int, _: String?, _: Bundle? ->
152+
n.contentIntent.send(this, 0, null, { _: PendingIntent?, intent: Intent, _: Int, _: String?, _: Bundle? ->
158153
val id = intent.getStringExtra(EXTRA_USERNAME) ?: return@send Unit.also {
159154
Log.e(TAG, "Unexpected null ID received for conversation: " + conversation.title) }
160155
conversation.id = id // setType() below will trigger rebuilding of conversation sender.
161156
latch.countDown()
162157
if (BuildConfig.DEBUG && id.hashCode() != conversation.nid) Log.e(TAG, "NID is not hash code of CID")
163-
}, null)
158+
}, null, null, mActivityBlocker)
164159
try {
165160
if (latch.await(100, MILLISECONDS)) {
166161
if (BuildConfig.DEBUG) Log.d(TAG, "Conversation ID retrieved: " + conversation.id)
@@ -307,7 +302,7 @@ class WeChatDecorator : NevoDecoratorService() {
307302
private lateinit var mPreferences: SharedPreferences
308303
private lateinit var mPrefKeyWear: String
309304
private val mHandler = Handler(Looper.myLooper()!!)
310-
private val mActivityBlocker = buildParcelableWithFileDescriptor()
305+
private val mActivityBlocker = ActivityOptions.makeBasic().setLaunchDisplayId(Int.MAX_VALUE / 2).toBundle()
311306
}
312307

313308
const val TAG = "Nevo.Decorator[WeChat]"

0 commit comments

Comments
 (0)