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

Commit 2186a561 authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Catch ServiceSpecificExceptions properly when getting reg state/ transport type

We were not catching ServiceSpecificExceptions that were thrown,
causing unclear exceptions. Instead, return the default value when
the ImsService is unavailable.

Bug: 192930411
Test: atest CtsTelephonyTestCases
Change-Id: I3d50b19047bc287ce6200e75bb59cf98bf8bfef0
parent f7c7e7da
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.telephony.ims.aidl.IImsCapabilityCallback;
import android.telephony.ims.feature.ImsFeature;
import android.telephony.ims.feature.MmTelFeature;
import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.IIntegerConsumer;
@@ -447,8 +448,9 @@ public class ImsMmTelManager implements RegistrationManager {
                    executor.execute(() -> stateCallback.accept(result));
                }
            });
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        } catch (ServiceSpecificException | RemoteException e) {
            Log.w("ImsMmTelManager", "Error getting registration state: " + e);
            executor.execute(() -> stateCallback.accept(REGISTRATION_STATE_NOT_REGISTERED));
        }
    }

@@ -488,8 +490,10 @@ public class ImsMmTelManager implements RegistrationManager {
                            executor.execute(() -> transportTypeCallback.accept(result));
                        }
                    });
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        } catch (ServiceSpecificException | RemoteException e) {
            Log.w("ImsMmTelManager", "Error getting transport type: " + e);
            executor.execute(() -> transportTypeCallback.accept(
                    AccessNetworkConstants.TRANSPORT_TYPE_INVALID));
        }
    }

+8 −4
Original line number Diff line number Diff line
@@ -302,8 +302,10 @@ public class ImsRcsManager {
                    executor.execute(() -> stateCallback.accept(result));
                }
            });
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        } catch (ServiceSpecificException | RemoteException e) {
            Log.w(TAG, "Get registration state error: " + e);
            executor.execute(() -> stateCallback.accept(
                    RegistrationManager.REGISTRATION_STATE_NOT_REGISTERED));
        }
    }

@@ -346,8 +348,10 @@ public class ImsRcsManager {
                            executor.execute(() -> transportTypeCallback.accept(result));
                        }
                    });
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        } catch (ServiceSpecificException | RemoteException e) {
            Log.w(TAG, "Get registration transport type error: " + e);
            executor.execute(() -> transportTypeCallback.accept(
                    AccessNetworkConstants.TRANSPORT_TYPE_INVALID));
        }
    }