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

Commit b35b54f7 authored by Meng Wang's avatar Meng Wang Committed by android-build-merger
Browse files

Merge "Do not use hidden API ParcelableException"

am: e777c277

Change-Id: I640e1f6aa16ef101ac5eeabbe9ce4d911e57b308
parents 5248e936 e777c277
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package android.telephony;

import android.os.ParcelableException;
import android.telephony.CellInfo;

import java.util.List;
@@ -28,5 +27,5 @@ import java.util.List;
oneway interface ICellInfoCallback
{
    void onCellInfo(in List<CellInfo> state);
    void onError(in int errorCode, in ParcelableException detail);
    void onError(in int errorCode, in String exceptionName, in String message);
}
+20 −6
Original line number Diff line number Diff line
@@ -70,7 +70,6 @@ import android.telephony.Annotation.NetworkType;
import android.telephony.Annotation.RadioPowerState;
import android.telephony.Annotation.SimActivationState;
import android.telephony.VisualVoicemailService.VisualVoicemailTask;
import android.telephony.data.ApnSetting;
import android.telephony.emergency.EmergencyNumber;
import android.telephony.emergency.EmergencyNumber.EmergencyServiceCategories;
import android.telephony.ims.ImsMmTelManager;
@@ -5490,19 +5489,20 @@ public class TelephonyManager {
            telephony.requestCellInfoUpdate(
                    getSubId(),
                    new ICellInfoCallback.Stub() {
                        @Override
                        public void onCellInfo(List<CellInfo> cellInfo) {
                            Binder.withCleanCallingIdentity(() ->
                                    executor.execute(() -> callback.onCellInfo(cellInfo)));
                        }

                        public void onError(int errorCode, android.os.ParcelableException detail) {
                        @Override
                        public void onError(int errorCode, String exceptionName, String message) {
                            Binder.withCleanCallingIdentity(() ->
                                    executor.execute(() -> callback.onError(
                                            errorCode,
                                            detail == null ? null : detail.getCause())));
                                            createThrowableByClassName(exceptionName, message))));
                        }
                    }, getOpPackageName());

        } catch (RemoteException ex) {
        }
    }
@@ -5531,22 +5531,36 @@ public class TelephonyManager {
            telephony.requestCellInfoUpdateWithWorkSource(
                    getSubId(),
                    new ICellInfoCallback.Stub() {
                        @Override
                        public void onCellInfo(List<CellInfo> cellInfo) {
                            Binder.withCleanCallingIdentity(() ->
                                    executor.execute(() -> callback.onCellInfo(cellInfo)));
                        }

                        public void onError(int errorCode, android.os.ParcelableException detail) {
                        @Override
                        public void onError(int errorCode, String exceptionName, String message) {
                            Binder.withCleanCallingIdentity(() ->
                                    executor.execute(() -> callback.onError(
                                            errorCode,
                                            detail == null ? null : detail.getCause())));
                                            createThrowableByClassName(exceptionName, message))));
                        }
                    }, getOpPackageName(), workSource);
        } catch (RemoteException ex) {
        }
    }

    private static Throwable createThrowableByClassName(String className, String message) {
        if (className == null) {
            return null;
        }
        try {
            Class<?> c = Class.forName(className);
            return (Throwable) c.getConstructor(String.class).newInstance(message);
        } catch (ReflectiveOperationException | ClassCastException e) {
        }
        return new RuntimeException(className + ": " + message);
    }

    /**
     * Sets the minimum time in milli-seconds between {@link PhoneStateListener#onCellInfoChanged
     * PhoneStateListener.onCellInfoChanged} will be invoked.