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

Commit 69509926 authored by Daniel Sandler's avatar Daniel Sandler Committed by Android (Google) Code Review
Browse files

Merge "More termination conditions for Dreams." into jb-mr1-dev

parents 3b89190b a2fbe53f
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -70,7 +70,13 @@ public class Dream extends Service implements Window.Callback {
    // begin Window.Callback methods
    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        // TODO: create more flexible version of mInteractive that allows use of KEYCODE_BACK
        if (!mInteractive) {
            if (DEBUG) Slog.v(TAG, "finishing on keyEvent");
            finish();
            return true;
        } else if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
            if (DEBUG) Slog.v(TAG, "finishing on back key");
            finish();
            return true;
        }
@@ -80,6 +86,7 @@ public class Dream extends Service implements Window.Callback {
    @Override
    public boolean dispatchKeyShortcutEvent(KeyEvent event) {
        if (!mInteractive) { 
            if (DEBUG) Slog.v(TAG, "finishing on keyShortcutEvent");
            finish();
            return true;
        }
@@ -88,7 +95,10 @@ public class Dream extends Service implements Window.Callback {

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        // TODO: create more flexible version of mInteractive that allows clicks 
        // but finish()es on any other kind of activity
        if (!mInteractive) { 
            if (DEBUG) Slog.v(TAG, "finishing on touchEvent");
            finish();
            return true;
        }
@@ -98,6 +108,7 @@ public class Dream extends Service implements Window.Callback {
    @Override
    public boolean dispatchTrackballEvent(MotionEvent event) {
        if (!mInteractive) {
            if (DEBUG) Slog.v(TAG, "finishing on trackballEvent");
            finish();
            return true;
        }
@@ -107,6 +118,7 @@ public class Dream extends Service implements Window.Callback {
    @Override
    public boolean dispatchGenericMotionEvent(MotionEvent event) {
        if (!mInteractive) { 
            if (DEBUG) Slog.v(TAG, "finishing on genericMotionEvent");
            finish();
            return true;
        }
+17 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.UserId;
import android.provider.Settings;
import android.service.dreams.IDreamManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.Slog;
@@ -153,6 +154,7 @@ public class PhoneStatusBar extends BaseStatusBar {
    Display mDisplay;

    IWindowManager mWindowManager;
    IDreamManager mDreamManager;

    StatusBarWindowView mStatusBarWindow;
    PhoneStatusBarView mStatusBarView;
@@ -302,6 +304,9 @@ public class PhoneStatusBar extends BaseStatusBar {
        mWindowManager = IWindowManager.Stub.asInterface(
                ServiceManager.getService(Context.WINDOW_SERVICE));

        mDreamManager = IDreamManager.Stub.asInterface(
                ServiceManager.checkService("dreams"));

        super.start(); // calls createAndAddWindows()

        addNavigationBar();
@@ -606,6 +611,7 @@ public class PhoneStatusBar extends BaseStatusBar {
    private Runnable mShowSearchPanel = new Runnable() {
        public void run() {
            showSearchPanel();
            awakenDreams();
        }
    };

@@ -622,12 +628,23 @@ public class PhoneStatusBar extends BaseStatusBar {
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
                mHandler.removeCallbacks(mShowSearchPanel);
                awakenDreams();
            break;
        }
        return false;
        }
    };

    private void awakenDreams() {
        if (mDreamManager != null) {
            try {
                mDreamManager.awaken();
            } catch (RemoteException e) {
                // fine, stay asleep then
            }
        }
    }

    private void prepareNavigationBarView() {
        mNavigationBarView.reorient();