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

Commit 05543317 authored by Jiri Tyr's avatar Jiri Tyr
Browse files

Do not unlock when running in background

It allows to run any application (e.g Toggle WiFi or Bluetooth OnOff) in
the background without the need to unlock the lockscreen. It also
vibrates when correct gesture was drawn.

Change-Id: Ia041a08108c2f1ced9b577fe2423eef0a9b59beb
parent c984e3b7
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import android.os.ParcelFileDescriptor;
import android.os.BatteryManager;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.Vibrator;
import android.provider.Settings;

import java.util.ArrayList;
@@ -1199,7 +1200,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
    public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
        ArrayList<Prediction> predictions = mLibrary.recognize(gesture);
        if (predictions.size() > 0 && predictions.get(0).score > mGestureSensitivity) {
            String[] payload = predictions.get(0).name.split("___", 2);
            String[] payload = predictions.get(0).name.split("___", 3);
            String uri = payload[1];
            if (uri != null) {
                if ("UNLOCK".equals(uri)) {
@@ -1216,7 +1217,20 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
                        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                                | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
                        mContext.startActivity(i);
                        // Run in background if requested
                        if (payload.length > 2) {
                            // Define vibrator
                            Vibrator v = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
                            // Vibrate pattern when gesture is correct
                            long[] pattern = {
                                0, 200
                            };
                            v.vibrate(pattern, -1);

                            mCallback.pokeWakelock();
                        } else {
                            mCallback.goToUnlockScreen();
                        }
                    } catch (URISyntaxException e) {
                    } catch (ActivityNotFoundException e) {
                    }
@@ -1225,6 +1239,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
            mCallback.pokeWakelock(); // reset timeout - give them another chance to gesture
        }
    }

    // shameless kang of music widgets
    public static Uri getArtworkUri(Context context, long song_id, long album_id) {