summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2017-06-13 23:51:06 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-06-13 23:51:13 +0000
commit644f8e858318867ac5d9caf96cc89f23ed0e9f90 (patch)
treec6e6a4d6e9fb07ac7190a55cc1a71e939f6f230e
parent85c96384381ffc36a739524e787b077b83ecb556 (diff)
parentf33a097232f153e8dfeabd222d8809cd6a8d9457 (diff)
Merge "Add plugin hooks to DozeService" into oc-dr1-dev
-rw-r--r--packages/SystemUI/plugin/src/com/android/systemui/plugins/DozeServicePlugin.java21
-rw-r--r--packages/SystemUI/src/com/android/systemui/doze/DozeService.java47
2 files changed, 64 insertions, 4 deletions
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/DozeServicePlugin.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/DozeServicePlugin.java
new file mode 100644
index 000000000000..3ca5690af474
--- /dev/null
+++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/DozeServicePlugin.java
@@ -0,0 +1,21 @@
+package com.android.systemui.plugins;
+
+import com.android.systemui.plugins.annotations.ProvidesInterface;
+
+@ProvidesInterface(action = DozeServicePlugin.ACTION, version = DozeServicePlugin.VERSION)
+public interface DozeServicePlugin extends Plugin {
+ String ACTION = "com.android.systemui.action.PLUGIN_DOZE";
+ int VERSION = 1;
+
+ public interface RequestDoze {
+ void onRequestShowDoze();
+
+ void onRequestHideDoze();
+ }
+
+ void onDreamingStarted();
+
+ void onDreamingStopped();
+
+ void setDozeRequester(RequestDoze requester);
+}
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java
index 3271caf598cf..d9fb087a6041 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java
@@ -16,23 +16,27 @@
package com.android.systemui.doze;
+import android.content.Context;
import android.os.PowerManager;
import android.os.SystemClock;
import android.service.dreams.DreamService;
import android.util.Log;
import com.android.systemui.Dependency;
-import com.android.systemui.plugins.Plugin;
+import com.android.systemui.plugins.DozeServicePlugin;
import com.android.systemui.plugins.PluginManager;
-
+import com.android.systemui.plugins.DozeServicePlugin.RequestDoze;
+import com.android.systemui.plugins.PluginListener;
import java.io.FileDescriptor;
import java.io.PrintWriter;
-public class DozeService extends DreamService implements DozeMachine.Service {
+public class DozeService extends DreamService
+ implements DozeMachine.Service, RequestDoze, PluginListener<DozeServicePlugin> {
private static final String TAG = "DozeService";
static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private DozeMachine mDozeMachine;
+ private DozeServicePlugin mDozePlugin;
public DozeService() {
setDebug(DEBUG);
@@ -48,23 +52,44 @@ public class DozeService extends DreamService implements DozeMachine.Service {
finish();
return;
}
-
+ Dependency.get(PluginManager.class).addPluginListener(this,
+ DozeServicePlugin.class, false /* Allow multiple */);
mDozeMachine = new DozeFactory().assembleMachine(this);
}
@Override
+ public void onPluginConnected(DozeServicePlugin plugin, Context pluginContext) {
+ mDozePlugin = plugin;
+ mDozePlugin.setDozeRequester(this);
+ }
+
+ @Override
+ public void onPluginDisconnected(DozeServicePlugin plugin) {
+ if (mDozePlugin != null) {
+ mDozePlugin.onDreamingStopped();
+ mDozePlugin = null;
+ }
+ }
+
+ @Override
public void onDreamingStarted() {
super.onDreamingStarted();
mDozeMachine.requestState(DozeMachine.State.INITIALIZED);
startDozing();
setDozeScreenBrightness(getResources().getInteger(
com.android.internal.R.integer.config_screenBrightnessDoze));
+ if (mDozePlugin != null) {
+ mDozePlugin.onDreamingStarted();
+ }
}
@Override
public void onDreamingStopped() {
super.onDreamingStopped();
mDozeMachine.requestState(DozeMachine.State.FINISH);
+ if (mDozePlugin != null) {
+ mDozePlugin.onDreamingStopped();
+ }
}
@Override
@@ -79,4 +104,18 @@ public class DozeService extends DreamService implements DozeMachine.Service {
PowerManager pm = getSystemService(PowerManager.class);
pm.wakeUp(SystemClock.uptimeMillis(), "com.android.systemui:NODOZE");
}
+
+ @Override
+ public void onRequestShowDoze() {
+ if (mDozeMachine != null) {
+ mDozeMachine.requestState(DozeMachine.State.DOZE_AOD);
+ }
+ }
+
+ @Override
+ public void onRequestHideDoze() {
+ if (mDozeMachine != null) {
+ mDozeMachine.requestState(DozeMachine.State.DOZE);
+ }
+ }
}