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

Commit ad921cb4 authored by Android (Google) Code Review's avatar Android (Google) Code Review Committed by The Android Open Source Project
Browse files

am c52d55c5: Merge change 6608 into donut

Merge commit 'c52d55c5'

* commit 'c52d55c5':
  Move the watchdog timer to a separate thread...
parents bda4584b c52d55c5
Loading
Loading
Loading
Loading
+21 −14
Original line number Diff line number Diff line
@@ -189,7 +189,7 @@ abstract class VpnService<E extends VpnProfile> {

            mServiceHelper.stop();
        } catch (Throwable e) {
            Log.e(TAG, "onError()", e);
            Log.e(TAG, "onDisconnect()", e);
            onFinalCleanUp();
        }
    }
@@ -219,22 +219,29 @@ abstract class VpnService<E extends VpnProfile> {
    }

    private void waitUntilConnectedOrTimedout() {
        // Run this in the background thread to not block UI
        new Thread(new Runnable() {
            public void run() {
                sleep(2000); // 2 seconds
                for (int i = 0; i < 60; i++) {
                    if (VPN_IS_UP.equals(SystemProperties.get(VPN_UP))) {
                        onConnected();
                        return;
                    } else if (mState != VpnState.CONNECTING) {
                        break;
                    }
                    sleep(500); // 0.5 second
                }

        synchronized (this) {
                synchronized (VpnService.this) {
                    if (mState == VpnState.CONNECTING) {
                        Log.d(TAG, "       connecting timed out !!");
                        onError();
                    }
                }
            }
        }).start();
    }

    private synchronized void onConnected() {
        Log.d(TAG, "onConnected()");