|
16 | 16 |
|
17 | 17 | package com.oasisfeng.nevo.decorators.wechat
|
18 | 18 |
|
| 19 | +import android.app.ActivityOptions |
19 | 20 | import android.app.Notification.*
|
20 | 21 | import android.app.NotificationChannel
|
21 | 22 | import android.app.NotificationManager
|
@@ -99,12 +100,6 @@ class WeChatDecorator : NevoDecoratorService() {
|
99 | 100 | try { return UserHandle(parcel.apply { writeInt(user); setDataPosition(0) }) }
|
100 | 101 | finally { parcel.recycle() }
|
101 | 102 | }
|
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 |
| - } |
108 | 103 | }
|
109 | 104 |
|
110 | 105 | public override fun apply(evolving: MutableStatusBarNotification): Boolean {
|
@@ -152,15 +147,15 @@ class WeChatDecorator : NevoDecoratorService() {
|
152 | 147 | if (messaging == null) return true
|
153 | 148 | val messages = messaging.messages
|
154 | 149 | if (messages.isEmpty()) return true
|
155 |
| - if (conversation.id == null && mActivityBlocker != null) try { |
| 150 | + if (conversation.id == null) try { |
156 | 151 | 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? -> |
158 | 153 | val id = intent.getStringExtra(EXTRA_USERNAME) ?: return@send Unit.also {
|
159 | 154 | Log.e(TAG, "Unexpected null ID received for conversation: " + conversation.title) }
|
160 | 155 | conversation.id = id // setType() below will trigger rebuilding of conversation sender.
|
161 | 156 | latch.countDown()
|
162 | 157 | if (BuildConfig.DEBUG && id.hashCode() != conversation.nid) Log.e(TAG, "NID is not hash code of CID")
|
163 |
| - }, null) |
| 158 | + }, null, null, mActivityBlocker) |
164 | 159 | try {
|
165 | 160 | if (latch.await(100, MILLISECONDS)) {
|
166 | 161 | if (BuildConfig.DEBUG) Log.d(TAG, "Conversation ID retrieved: " + conversation.id)
|
@@ -307,7 +302,7 @@ class WeChatDecorator : NevoDecoratorService() {
|
307 | 302 | private lateinit var mPreferences: SharedPreferences
|
308 | 303 | private lateinit var mPrefKeyWear: String
|
309 | 304 | private val mHandler = Handler(Looper.myLooper()!!)
|
310 |
| - private val mActivityBlocker = buildParcelableWithFileDescriptor() |
| 305 | + private val mActivityBlocker = ActivityOptions.makeBasic().setLaunchDisplayId(Int.MAX_VALUE / 2).toBundle() |
311 | 306 | }
|
312 | 307 |
|
313 | 308 | const val TAG = "Nevo.Decorator[WeChat]"
|
0 commit comments