Merge "Revert "[Mainline]Remove PhoneFactory.addLocalLog and PhoneFactory.localLog"" into rvc-dev
diff --git a/src/com/android/providers/telephony/TelephonyProvider.java b/src/com/android/providers/telephony/TelephonyProvider.java
index d16e030..4966e5a 100644
--- a/src/com/android/providers/telephony/TelephonyProvider.java
+++ b/src/com/android/providers/telephony/TelephonyProvider.java
@@ -130,6 +130,7 @@
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -2576,6 +2577,7 @@
private void restoreApnsWithService(int subId) {
Context context = getContext();
Resources r = context.getResources();
+ AtomicBoolean connectionBindingInvalid = new AtomicBoolean(false);
ServiceConnection connection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className,
@@ -2594,6 +2596,24 @@
mIApnSourceService = null;
}
}
+
+ @Override
+ public void onBindingDied(ComponentName name) {
+ loge("The binding to the apn service connection is dead: " + name);
+ synchronized (mLock) {
+ connectionBindingInvalid.set(true);
+ mLock.notifyAll();
+ }
+ }
+
+ @Override
+ public void onNullBinding(ComponentName name) {
+ loge("Null binding: " + name);
+ synchronized (mLock) {
+ connectionBindingInvalid.set(true);
+ mLock.notifyAll();
+ }
+ }
};
Intent intent = new Intent(IApnSourceService.class.getName());
@@ -2604,13 +2624,17 @@
if (context.bindService(intent, connection, Context.BIND_IMPORTANT |
Context.BIND_AUTO_CREATE)) {
synchronized (mLock) {
- while (mIApnSourceService == null) {
+ while (mIApnSourceService == null && !connectionBindingInvalid.get()) {
try {
mLock.wait();
} catch (InterruptedException e) {
loge("Error while waiting for service connection: " + e);
}
}
+ if (connectionBindingInvalid.get()) {
+ loge("The binding is invalid.");
+ return;
+ }
try {
ContentValues[] values = mIApnSourceService.getApns(subId);
if (values != null) {