use of android.support.annotation.RequiresApi in project WifiUtils by ThanosFisherman.
the class ConnectorUtils method connectWps.
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
static void connectWps(@NonNull final WifiManager wifiManager, @NonNull final ScanResult scanResult, @NonNull String pin, long timeOutMillis, @NonNull final ConnectionWpsListener connectionWpsListener) {
final WeakHandler handler = new WeakHandler();
final WpsInfo wpsInfo = new WpsInfo();
final Runnable handlerTimeoutRunnable = new Runnable() {
@Override
public void run() {
wifiManager.cancelWps(null);
wifiLog("Connection with WPS has timed out");
cleanPreviousConfiguration(wifiManager, scanResult);
connectionWpsListener.isSuccessful(false);
handler.removeCallbacks(this);
}
};
final WifiManager.WpsCallback wpsCallback = new WifiManager.WpsCallback() {
@Override
public void onStarted(String pin) {
}
@Override
public void onSucceeded() {
handler.removeCallbacks(handlerTimeoutRunnable);
wifiLog("CONNECTED With WPS successfully");
connectionWpsListener.isSuccessful(true);
}
@Override
public void onFailed(int reason) {
handler.removeCallbacks(handlerTimeoutRunnable);
final String reasonStr;
switch(reason) {
case 3:
reasonStr = "WPS_OVERLAP_ERROR";
break;
case 4:
reasonStr = "WPS_WEP_PROHIBITED";
break;
case 5:
reasonStr = "WPS_TKIP_ONLY_PROHIBITED";
break;
case 6:
reasonStr = "WPS_AUTH_FAILURE";
break;
case 7:
reasonStr = "WPS_TIMED_OUT";
break;
default:
reasonStr = String.valueOf(reason);
}
wifiLog("FAILED to connect with WPS. Reason: " + reasonStr);
cleanPreviousConfiguration(wifiManager, scanResult);
reenableAllHotspots(wifiManager);
connectionWpsListener.isSuccessful(false);
}
};
wifiLog("Connecting with WPS...");
wpsInfo.setup = WpsInfo.KEYPAD;
wpsInfo.BSSID = scanResult.BSSID;
wpsInfo.pin = pin;
wifiManager.cancelWps(null);
if (!cleanPreviousConfiguration(wifiManager, scanResult))
disableAllButOne(wifiManager, scanResult);
handler.postDelayed(handlerTimeoutRunnable, timeOutMillis);
wifiManager.startWps(wpsInfo, wpsCallback);
}
use of android.support.annotation.RequiresApi in project Auto.js by hyb1996.
the class ActionFactory method createActionWithEditableFilter.
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static SimpleAction createActionWithEditableFilter(final int action, int index, final String text) {
return new SearchTargetAction(action, new FilterAction.EditableFilter(index)) {
@Override
protected void performAction(UiObject node) {
Bundle args = new Bundle();
if (action == AccessibilityNodeInfo.ACTION_SET_TEXT) {
args.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, text);
} else {
args.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, node.text() + text);
}
node.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, args);
}
};
}
use of android.support.annotation.RequiresApi in project Auto.js by hyb1996.
the class Events method observeNotification.
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public void observeNotification() {
mScriptRuntime.requiresApi(18);
if (mListeningNotification)
return;
mListeningNotification = true;
ensureHandler();
mLoopers.waitWhenIdle(true);
if (NotificationListenerService.getInstance() == null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
mContext.startActivity(new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS));
}
throw new ScriptException(mContext.getString(R.string.exception_notification_service_disabled));
}
NotificationListenerService.getInstance().addListener(this);
}
use of android.support.annotation.RequiresApi in project Auto.js by hyb1996.
the class Images method captureScreen.
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public boolean captureScreen(String path) {
path = mScriptRuntime.files.path(path);
ImageWrapper image = captureScreen();
if (image != null) {
saveImage(image, path);
return true;
}
return false;
}
use of android.support.annotation.RequiresApi in project Auto.js by hyb1996.
the class GlobalActionAutomator method gesturesWithoutHandler.
@RequiresApi(api = Build.VERSION_CODES.N)
private boolean gesturesWithoutHandler(GestureDescription description) {
prepareLooperIfNeeded();
final VolatileBox<Boolean> result = new VolatileBox<>(false);
Handler handler = new Handler(Looper.myLooper());
mService.dispatchGesture(description, new AccessibilityService.GestureResultCallback() {
@Override
public void onCompleted(GestureDescription gestureDescription) {
result.set(true);
quitLoop();
}
@Override
public void onCancelled(GestureDescription gestureDescription) {
result.set(false);
quitLoop();
}
}, handler);
Looper.loop();
return result.get();
}
Aggregations