am 69509926: Merge "More termination conditions for Dreams." into jb-mr1-dev
* commit '69509926454e4f873bb48ecaa932ccbd76d5b123': More termination conditions for Dreams.
This commit is contained in:
@@ -70,7 +70,13 @@ public class Dream extends Service implements Window.Callback {
|
||||
// begin Window.Callback methods
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
if (!mInteractive) {
|
||||
// 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;
|
||||
}
|
||||
@@ -97,7 +107,8 @@ public class Dream extends Service implements Window.Callback {
|
||||
|
||||
@Override
|
||||
public boolean dispatchTrackballEvent(MotionEvent event) {
|
||||
if (!mInteractive) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user