Loading src/java/com/android/internal/telephony/domainselection/DomainSelectionController.java +6 −1 Original line number Diff line number Diff line Loading @@ -101,6 +101,7 @@ public class DomainSelectionController { private ExponentialBackoff mBackoff; private boolean mBackoffStarted = false; private boolean mUnbind = false; // Retry the bind to the DomainSelectionService that has died after mBindRetry timeout. private Runnable mRestartBindingRunnable = new Runnable() { Loading Loading @@ -470,12 +471,14 @@ public class DomainSelectionController { */ public boolean bind(@NonNull ComponentName componentName) { mComponentName = componentName; mUnbind = false; return bind(); } private boolean bind() { logd("bind isBindingOrBound=" + mIsBound); synchronized (mLock) { if (mUnbind) return false; if (!mIsBound) { mIsBound = true; Intent serviceIntent = new Intent(DomainSelectionService.SERVICE_INTERFACE) Loading Loading @@ -512,6 +515,7 @@ public class DomainSelectionController { */ public void unbind() { synchronized (mLock) { mUnbind = true; stopBackoffTimer(); mIsBound = false; setServiceController(null); Loading Loading @@ -548,7 +552,8 @@ public class DomainSelectionController { } private void notifyBindFailure() { logi("notifyBindFailure " + mBackoffStarted); logi("notifyBindFailure started=" + mBackoffStarted + ", unbind=" + mUnbind); if (mUnbind) return; if (mBackoffStarted) { mBackoff.notifyFailed(); } else { Loading tests/telephonytests/src/com/android/internal/telephony/domainselection/DomainSelectionControllerTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -246,6 +246,24 @@ public class DomainSelectionControllerTest extends TelephonyTest { verify(mMockContext, times(1)).bindService(any(), any(), anyInt()); } /** * Ensure that calling unbind stops automatic rebind from occurring. */ @SmallTest @Test public void testUnbindCauseAutoBindCancelAfterBinderDied() throws RemoteException { ServiceConnection conn = bindAndConnectService(); conn.onBindingDied(null /*null*/); mTestController.unbind(); long delay = mTestController.getBindDelay(); waitForHandlerActionDelayed(mHandler, delay, 2 * delay); // Unbind should stop the autobind from occurring. verify(mMockContext, times(1)).bindService(any(), any(), anyInt()); } private void bindAndNullServiceError() { ServiceConnection connection = bindService(mTestComponentName); connection.onNullBinding(mTestComponentName); Loading Loading
src/java/com/android/internal/telephony/domainselection/DomainSelectionController.java +6 −1 Original line number Diff line number Diff line Loading @@ -101,6 +101,7 @@ public class DomainSelectionController { private ExponentialBackoff mBackoff; private boolean mBackoffStarted = false; private boolean mUnbind = false; // Retry the bind to the DomainSelectionService that has died after mBindRetry timeout. private Runnable mRestartBindingRunnable = new Runnable() { Loading Loading @@ -470,12 +471,14 @@ public class DomainSelectionController { */ public boolean bind(@NonNull ComponentName componentName) { mComponentName = componentName; mUnbind = false; return bind(); } private boolean bind() { logd("bind isBindingOrBound=" + mIsBound); synchronized (mLock) { if (mUnbind) return false; if (!mIsBound) { mIsBound = true; Intent serviceIntent = new Intent(DomainSelectionService.SERVICE_INTERFACE) Loading Loading @@ -512,6 +515,7 @@ public class DomainSelectionController { */ public void unbind() { synchronized (mLock) { mUnbind = true; stopBackoffTimer(); mIsBound = false; setServiceController(null); Loading Loading @@ -548,7 +552,8 @@ public class DomainSelectionController { } private void notifyBindFailure() { logi("notifyBindFailure " + mBackoffStarted); logi("notifyBindFailure started=" + mBackoffStarted + ", unbind=" + mUnbind); if (mUnbind) return; if (mBackoffStarted) { mBackoff.notifyFailed(); } else { Loading
tests/telephonytests/src/com/android/internal/telephony/domainselection/DomainSelectionControllerTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -246,6 +246,24 @@ public class DomainSelectionControllerTest extends TelephonyTest { verify(mMockContext, times(1)).bindService(any(), any(), anyInt()); } /** * Ensure that calling unbind stops automatic rebind from occurring. */ @SmallTest @Test public void testUnbindCauseAutoBindCancelAfterBinderDied() throws RemoteException { ServiceConnection conn = bindAndConnectService(); conn.onBindingDied(null /*null*/); mTestController.unbind(); long delay = mTestController.getBindDelay(); waitForHandlerActionDelayed(mHandler, delay, 2 * delay); // Unbind should stop the autobind from occurring. verify(mMockContext, times(1)).bindService(any(), any(), anyInt()); } private void bindAndNullServiceError() { ServiceConnection connection = bindService(mTestComponentName); connection.onNullBinding(mTestComponentName); Loading