Search in sources :

Example 56 with RequiresApi

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);
}
Also used : WifiManager(android.net.wifi.WifiManager) WpsInfo(android.net.wifi.WpsInfo) RequiresApi(android.support.annotation.RequiresApi)

Example 57 with RequiresApi

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);
        }
    };
}
Also used : UiObject(com.stardust.automator.UiObject) Bundle(android.os.Bundle) RequiresApi(android.support.annotation.RequiresApi)

Example 58 with RequiresApi

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);
}
Also used : ScriptException(com.stardust.autojs.runtime.exception.ScriptException) Intent(android.content.Intent) RequiresApi(android.support.annotation.RequiresApi)

Example 59 with RequiresApi

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;
}
Also used : ImageWrapper(com.stardust.autojs.core.image.ImageWrapper) RequiresApi(android.support.annotation.RequiresApi)

Example 60 with RequiresApi

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();
}
Also used : AccessibilityService(android.accessibilityservice.AccessibilityService) VolatileBox(com.stardust.concurrent.VolatileBox) Handler(android.os.Handler) GestureDescription(android.accessibilityservice.GestureDescription) RequiresApi(android.support.annotation.RequiresApi)

Aggregations

RequiresApi (android.support.annotation.RequiresApi)191 Intent (android.content.Intent)30 NotificationChannel (android.app.NotificationChannel)28 View (android.view.View)25 NotificationManager (android.app.NotificationManager)17 ViewGroup (android.view.ViewGroup)15 Allocation (android.renderscript.Allocation)14 Bitmap (android.graphics.Bitmap)13 RecyclerView (android.support.v7.widget.RecyclerView)13 ViewTreeObserver (android.view.ViewTreeObserver)12 WindowInsets (android.view.WindowInsets)12 TextView (android.widget.TextView)12 ActionBar (android.support.v7.app.ActionBar)11 Toolbar (android.support.v7.widget.Toolbar)11 Handler (android.os.Handler)10 StatFs (android.os.StatFs)9 Button (android.widget.Button)8 Cipher (javax.crypto.Cipher)8 SuppressLint (android.annotation.SuppressLint)7 Uri (android.net.Uri)7