Loading packages/SystemUI/plugin/src/com/android/systemui/plugins/DozeServicePlugin.java 0 → 100644 +21 −0 Original line number Diff line number Diff line 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); } packages/SystemUI/src/com/android/systemui/doze/DozeService.java +43 −4 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -48,10 +52,25 @@ 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(); Loading @@ -59,12 +78,18 @@ public class DozeService extends DreamService implements DozeMachine.Service { 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 Loading @@ -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); } } } Loading
packages/SystemUI/plugin/src/com/android/systemui/plugins/DozeServicePlugin.java 0 → 100644 +21 −0 Original line number Diff line number Diff line 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); }
packages/SystemUI/src/com/android/systemui/doze/DozeService.java +43 −4 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -48,10 +52,25 @@ 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(); Loading @@ -59,12 +78,18 @@ public class DozeService extends DreamService implements DozeMachine.Service { 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 Loading @@ -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); } } }