0

在升级我们的应用程序以使用 targetSdkVersion 和 compileSdkVersion 到 31 后,我们在 esim 激活过程中面临不同的行为,当调用startResolutionActivity应用程序时,现在会崩溃:

08-27 10:49:06.288  6641  6641 D DownloadEsimSubscription: 2 - Event received!, com.myapp.download_subscription - 1
08-27 10:49:06.288  6641  6641 D DownloadEsimSubscription: 2 - Subscription downloaded, com.myapp.download_subscription - 1
08-27 10:49:06.296  6641  6641 E AndroidRuntime: FATAL EXCEPTION: main
08-27 10:49:06.296  6641  6641 E AndroidRuntime: Process: com.myapp, PID: 6641
08-27 10:49:06.296  6641  6641 E AndroidRuntime: io.reactivex.exceptions.OnErrorNotImplementedException: Invalid result intent
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:704)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:701)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at io.reactivex.internal.observers.LambdaObserver.onError(LambdaObserver.java:74)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:64)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:200)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:252)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker$BooleanRunnable.run(ExecutorScheduler.java:260)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker.run(ExecutorScheduler.java:225)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:938)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:99)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at android.os.Looper.loopOnce(Looper.java:201)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:288)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7822)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
08-27 10:49:06.296  6641  6641 E AndroidRuntime: Caused by: java.lang.IllegalArgumentException: Invalid result intent
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at android.telephony.euicc.EuiccManager.startResolutionActivity(EuiccManager.java:954)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at com.myapp.esim.system.StartResolvableErrorActivity.invoke(StartResolvableErrorActivity.kt:33)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at com.myapp.esim.ui.EsimFlowView$onCreate$$inlined$observe$1.onChanged(ArchitectureComponentsExtensions.kt:29)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at com.myapp.ui.-$$Lambda$Hv4SBqiTm1O-ghpLWVMxBLQvcAA.accept(Unknown Source:4)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:60)
08-27 10:49:06.296  6641  6641 E AndroidRuntime:    ... 12 more

检查源代码似乎现在在意图中有一个必需的额外内容:

    public void startResolutionActivity(Activity activity, int requestCode, Intent resultIntent,
            PendingIntent callbackIntent) throws IntentSender.SendIntentException {
        PendingIntent resolutionIntent =
                resultIntent.getParcelableExtra(EXTRA_EMBEDDED_SUBSCRIPTION_RESOLUTION_INTENT);
        if (resolutionIntent == null) {
            throw new IllegalArgumentException("Invalid result intent");
        }
        Intent fillInIntent = new Intent();
        fillInIntent.putExtra(EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_RESOLUTION_CALLBACK_INTENT,
                callbackIntent);
        activity.startIntentSenderForResult(resolutionIntent.getIntentSender(), requestCode,
                fillInIntent, 0 /* flagsMask */, 0 /* flagsValues */, 0 /* extraFlags */);
    }

这是:

    /**
     * Key for an extra set on {@link PendingIntent} result callbacks providing the resolution
     * pending intent for {@link #EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR}s.
     * @hide
     */
    public static final String EXTRA_EMBEDDED_SUBSCRIPTION_RESOLUTION_INTENT =
            "android.telephony.euicc.extra.EMBEDDED_SUBSCRIPTION_RESOLUTION_INTENT";

但我不清楚这个额外的应该是什么。在文档中也没有提到(我想还没有)。

针对 api 30 测试相同的代码并构建应用程序是可行的。

相关代码:


 open operator fun invoke(intent: Intent) {
        val callbackIntent = PendingIntent.getBroadcast(activity,
            RequestCodes.REQUEST_DOWNLOAD,
            Intent(DownloadEsimSubscription.getActionDownloadSubscriptionName(activity)),
            PendingIntent.FLAG_UPDATE_CURRENT
        )

        val euiccManager = activity.getSystemService(Context.EUICC_SERVICE) as EuiccManager

        try {
            euiccManager.startResolutionActivity(
                activity,
                RequestCodes.REQUEST_SOLVE_ISSUE,
                intent,
                callbackIntent
            )
        } catch (e: IntentSender.SendIntentException) {
            Logger.e(LOGTAG, "SendIntentException when calling again startResolutionActivity - ", e)
        }

        esimActivationFlowBL.switch()
    }

其中传递给此方法的意图是在监听订阅过程的广播接收器中返回

有没有其他人遇到过这个?

4

1 回答 1

0

中使用的回调意图

euiccManager.downloadSubscription(subscription, true, callbackIntent)

应该具有可变标志,因此系统可以添加解决活动所需的额外内容。

就我而言:

val callbackIntent = PendingIntent.getBroadcast(context, RequestCodes.REQUEST_DOWNLOAD, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE)

val euiccManager = context.getSystemService(Context.EUICC_SERVICE) as EuiccManager
       euiccManager.downloadSubscription(subscription, true, callbackIntent)
于 2021-08-30T10:39:32.883 回答