Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5dfdfb19 authored by danielwbhuang's avatar danielwbhuang
Browse files

Use Compatibility Framework to remap error codes.

1. Compatibility Framework part is already merged in ag/9881174, so propagate this to master.
2. Use Compatibility Framework to remap error codes.

Test: run atest.
1.atest TelephonyManagerTest#testPreferredOpportunisticDataSubscription
[1/1] android.telephony.cts.TelephonyManagerTest#testPreferredOpportunisticDataSubscription: PASSED (1.662s)
2.atest TelephonyManagerTest#testUpdateAvailableNetworks
[1/1] android.telephony.cts.TelephonyManagerTest#testUpdateAvailableNetworks: PASSED (534ms)

Bug: 130595455
Change-Id: Id16469a1c1ec7486df215c228fbebe27ac0296b7
parent 4f059fa5
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -38,6 +38,9 @@ import android.annotation.UnsupportedAppUsage;
import android.annotation.WorkerThread;
import android.app.ActivityThread;
import android.app.PendingIntent;
import android.compat.Compatibility;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledAfter;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -141,6 +144,14 @@ import java.util.regex.Pattern;
public class TelephonyManager {
    private static final String TAG = "TelephonyManager";

    /**
     * To expand the error codes for {@link TelephonyManager#updateAvailableNetworks} and
     * {@link TelephonyManager#setPreferredOpportunisticDataSubscription}.
     */
    @ChangeId
    @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.Q)
    private static final long CALLBACK_ON_MORE_ERROR_CODE_CHANGE = 130595455L;

    /**
     * The key to use when placing the result of {@link #requestModemActivityInfo(ResultReceiver)}
     * into the ResultReceiver Bundle.
@@ -11522,7 +11533,11 @@ public class TelephonyManager {
                final long identity = Binder.clearCallingIdentity();
                try {
                    executor.execute(() -> {
                        if (Compatibility.isChangeEnabled(CALLBACK_ON_MORE_ERROR_CODE_CHANGE)) {
                            callback.accept(SET_OPPORTUNISTIC_SUB_REMOTE_SERVICE_EXCEPTION);
                        } else {
                            callback.accept(SET_OPPORTUNISTIC_SUB_INACTIVE_SUBSCRIPTION);
                        }
                    });
                } finally {
                    Binder.restoreCallingIdentity(identity);
@@ -11619,7 +11634,11 @@ public class TelephonyManager {
                    final long identity = Binder.clearCallingIdentity();
                    try {
                        executor.execute(() -> {
                            if (Compatibility.isChangeEnabled(CALLBACK_ON_MORE_ERROR_CODE_CHANGE)) {
                                callback.accept(UPDATE_AVAILABLE_NETWORKS_REMOTE_SERVICE_EXCEPTION);
                            } else {
                                callback.accept(UPDATE_AVAILABLE_NETWORKS_UNKNOWN_FAILURE);
                            }
                        });
                    } finally {
                        Binder.restoreCallingIdentity(identity);