diff options
| author | dianlujitao <dianlujitao@lineageos.org> | 2019-01-25 15:36:02 +0800 |
|---|---|---|
| committer | Ali B <abittin@gmail.com> | 2019-02-05 16:05:13 +0300 |
| commit | 5b31d157400e72e3f54920a1a9102d6269a30949 (patch) | |
| tree | 823acd20e6b28485b203d816ee1df1c94c5f1400 | |
| parent | edab4be39031881b7b4177b07508f1f49dfd6c10 (diff) | |
TelephonyExtUtils: Handle extphone binder death
* If extphone binder service is invoked after death, phone service
would crash due to android.os.DeadObjectException.
Change-Id: I8dec7bfd709b0443654001ecd67219a2ba8cc134
| -rw-r--r-- | internal/src/org/codeaurora/internal/TelephonyExtUtils.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/src/org/codeaurora/internal/TelephonyExtUtils.java b/internal/src/org/codeaurora/internal/TelephonyExtUtils.java index c77c99a..057b00d 100644 --- a/internal/src/org/codeaurora/internal/TelephonyExtUtils.java +++ b/internal/src/org/codeaurora/internal/TelephonyExtUtils.java @@ -20,6 +20,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.os.IBinder.DeathRecipient; import android.os.RemoteException; import android.os.ServiceManager; import android.telephony.SubscriptionManager; @@ -74,6 +75,17 @@ public final class TelephonyExtUtils { } }; + private final DeathRecipient mDeathRecipient = new DeathRecipient() { + @Override + public void binderDied() { + if (DEBUG) Log.d(TAG, "Binder died"); + synchronized(TelephonyExtUtils.class) { + mExtTelephony.asBinder().unlinkToDeath(mDeathRecipient, 0); + mExtTelephony = null; + } + } + }; + // This class is not supposed to be instantiated externally private TelephonyExtUtils(Context context) { if (DEBUG) Log.d(TAG, "Registering listeners!"); @@ -227,10 +239,15 @@ public final class TelephonyExtUtils { try { mExtTelephony = IExtTelephony.Stub.asInterface(ServiceManager.getService("extphone")); + if (mExtTelephony != null) { + mExtTelephony.asBinder().linkToDeath(mDeathRecipient, 0); + } } catch (NoClassDefFoundError ex) { // Ignore, device does not ship with telephony-ext Log.d(TAG, "Failed to get telephony extension service!"); mNoServiceAvailable = true; + } catch (RemoteException ex) { + Log.d(TAG, "linkToDeath failed!"); } } |
