|
|
@ -5,14 +5,10 @@
|
|
|
|
package com.tailscale.ipn;
|
|
|
|
package com.tailscale.ipn;
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.ComponentName;
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.service.quicksettings.Tile;
|
|
|
|
import android.service.quicksettings.Tile;
|
|
|
|
import android.service.quicksettings.TileService;
|
|
|
|
import android.service.quicksettings.TileService;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class QuickToggleService extends TileService {
|
|
|
|
public class QuickToggleService extends TileService {
|
|
|
|
// lock protects the static fields below it.
|
|
|
|
// lock protects the static fields below it.
|
|
|
|
private static Object lock = new Object();
|
|
|
|
private static Object lock = new Object();
|
|
|
@ -79,5 +75,14 @@ public class QuickToggleService extends TileService {
|
|
|
|
updateTile();
|
|
|
|
updateTile();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static native void onTileClick();
|
|
|
|
private void onTileClick() {
|
|
|
|
|
|
|
|
boolean act;
|
|
|
|
|
|
|
|
synchronized (lock) {
|
|
|
|
|
|
|
|
act = active && ready;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Intent i = new Intent(act ? IPNReceiver.INTENT_DISCONNECT_VPN : IPNReceiver.INTENT_CONNECT_VPN);
|
|
|
|
|
|
|
|
i.setPackage(getPackageName());
|
|
|
|
|
|
|
|
i.setClass(getApplicationContext(), com.tailscale.ipn.IPNReceiver.class);
|
|
|
|
|
|
|
|
sendBroadcast(i);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|