diff options
-rw-r--r-- | Android.mk | 1 | ||||
-rw-r--r-- | core/java/android/service/dreams/DozeHardware.java | 77 | ||||
-rw-r--r-- | core/java/android/service/dreams/DreamService.java | 25 | ||||
-rw-r--r-- | core/java/android/service/dreams/IDozeHardware.aidl | 24 | ||||
-rw-r--r-- | core/java/android/service/dreams/IDreamManager.aidl | 2 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/doze/DozeService.java | 8 | ||||
-rw-r--r-- | services/core/java/com/android/server/dreams/DreamManagerService.java | 76 | ||||
-rw-r--r-- | services/core/java/com/android/server/dreams/McuHal.java | 46 | ||||
-rw-r--r-- | services/core/jni/Android.mk | 1 | ||||
-rw-r--r-- | services/core/jni/com_android_server_dreams_McuHal.cpp | 100 | ||||
-rw-r--r-- | services/core/jni/onload.cpp | 2 | ||||
-rw-r--r-- | tests/DozeTest/src/com/android/dreams/dozetest/DozeTestDream.java | 18 |
12 files changed, 2 insertions, 378 deletions
@@ -215,7 +215,6 @@ LOCAL_SRC_FILES += \ core/java/android/print/IWriteResultCallback.aidl \ core/java/android/printservice/IPrintService.aidl \ core/java/android/printservice/IPrintServiceClient.aidl \ - core/java/android/service/dreams/IDozeHardware.aidl \ core/java/android/service/dreams/IDreamManager.aidl \ core/java/android/service/dreams/IDreamService.aidl \ core/java/android/service/persistentdata/IPersistentDataBlockService.aidl \ diff --git a/core/java/android/service/dreams/DozeHardware.java b/core/java/android/service/dreams/DozeHardware.java deleted file mode 100644 index b5e7f43..0000000 --- a/core/java/android/service/dreams/DozeHardware.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package android.service.dreams; - -import android.os.RemoteException; -import android.util.Log; - -/** - * Provides access to low-level hardware features that a dream may use to provide - * a richer user experience while dozing. - * <p> - * This class contains functions that should be called by the dream to configure - * hardware before starting to doze and allowing the application processor to suspend. - * For example, the dream may provide the hardware with enough information to render - * some content on its own without any further assistance from the application processor. - * </p><p> - * This object is obtained by calling {@link DreamService#getDozeHardware()}. - * </p> - * - * @hide experimental - */ -public final class DozeHardware { - private static final String TAG = "DozeHardware"; - - public static final String MSG_ENABLE_MCU = "enable_mcu"; - - public static final byte[] VALUE_ON = "on".getBytes(); - public static final byte[] VALUE_OFF = "off".getBytes(); - - private final IDozeHardware mHardware; - - DozeHardware(IDozeHardware hardware) { - mHardware = hardware; - } - - /** - * Sets whether to enable the microcontroller. - * - * @param enable If true, enables the MCU otherwise disables it. - */ - public void setEnableMcu(boolean enable) { - sendMessage(MSG_ENABLE_MCU, enable ? VALUE_ON : VALUE_OFF); - } - - /** - * Sends a message to the doze hardware module. - * - * @param msg The name of the message to send. - * @param arg An optional argument data blob, may be null. - * @return A result data blob, may be null. - */ - public byte[] sendMessage(String msg, byte[] arg) { - if (msg == null) { - throw new IllegalArgumentException("msg must not be null"); - } - - try { - return mHardware.sendMessage(msg, arg); - } catch (RemoteException ex) { - Log.e(TAG, "Failed to send message to doze hardware module.", ex); - return null; - } - } -} diff --git a/core/java/android/service/dreams/DreamService.java b/core/java/android/service/dreams/DreamService.java index 5cf8aa6..7e04ae8 100644 --- a/core/java/android/service/dreams/DreamService.java +++ b/core/java/android/service/dreams/DreamService.java @@ -183,7 +183,6 @@ public class DreamService extends Service implements Window.Callback { private boolean mCanDoze; private boolean mDozing; private boolean mWindowless; - private DozeHardware mDozeHardware; private int mDozeScreenState = Display.STATE_UNKNOWN; private int mDozeScreenBrightness = PowerManager.BRIGHTNESS_DEFAULT; @@ -658,29 +657,6 @@ public class DreamService extends Service implements Window.Callback { } /** - * Gets an object that may be used to access low-level hardware features that a - * dream may use to provide a richer user experience while dozing. - * - * @return An instance of {@link DozeHardware} or null if this device does not offer - * hardware support for dozing. - * - * @hide For use by system UI components only. - */ - public DozeHardware getDozeHardware() { - if (mCanDoze && mDozeHardware == null && mWindowToken != null) { - try { - IDozeHardware hardware = mSandman.getDozeHardware(mWindowToken); - if (hardware != null) { - mDozeHardware = new DozeHardware(hardware); - } - } catch (RemoteException ex) { - // system server died - } - } - return mDozeHardware; - } - - /** * Gets the screen state to use while dozing. * * @return The screen state to use while dozing, such as {@link Display#STATE_ON}, @@ -1084,7 +1060,6 @@ public class DreamService extends Service implements Window.Callback { else if (canDoze()) pw.print(" candoze"); pw.println(); if (canDoze()) { - pw.println(" doze hardware: " + mDozeHardware); pw.println(" doze screen state: " + Display.stateToString(mDozeScreenState)); pw.println(" doze screen brightness: " + mDozeScreenBrightness); } diff --git a/core/java/android/service/dreams/IDozeHardware.aidl b/core/java/android/service/dreams/IDozeHardware.aidl deleted file mode 100644 index f5a657b..0000000 --- a/core/java/android/service/dreams/IDozeHardware.aidl +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.service.dreams; - -/** - * @hide - */ -interface IDozeHardware { - byte[] sendMessage(String msg, in byte[] arg); -} diff --git a/core/java/android/service/dreams/IDreamManager.aidl b/core/java/android/service/dreams/IDreamManager.aidl index 648426c..be3f3b3 100644 --- a/core/java/android/service/dreams/IDreamManager.aidl +++ b/core/java/android/service/dreams/IDreamManager.aidl @@ -20,7 +20,6 @@ import android.content.ComponentName; import android.os.Bundle; import android.os.ParcelFileDescriptor; import android.os.IBinder; -import android.service.dreams.IDozeHardware; /** @hide */ interface IDreamManager { @@ -34,5 +33,4 @@ interface IDreamManager { void finishSelf(in IBinder token, boolean immediate); void startDozing(in IBinder token, int screenState, int screenBrightness); void stopDozing(in IBinder token); - IDozeHardware getDozeHardware(in IBinder token); } diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java index 333b8b4..d7e0738 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeService.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeService.java @@ -32,7 +32,6 @@ import android.os.Handler; import android.os.PowerManager; import android.os.SystemProperties; import android.os.Vibrator; -import android.service.dreams.DozeHardware; import android.service.dreams.DreamService; import android.util.Log; import android.util.MathUtils; @@ -55,7 +54,6 @@ public class DozeService extends DreamService { private final Handler mHandler = new Handler(); private Host mHost; - private DozeHardware mDozeHardware; private SensorManager mSensors; private Sensor mSigMotionSensor; private PowerManager mPowerManager; @@ -77,7 +75,6 @@ public class DozeService extends DreamService { protected void dumpOnHandler(FileDescriptor fd, PrintWriter pw, String[] args) { super.dumpOnHandler(fd, pw, args); pw.print(" mDreaming: "); pw.println(mDreaming); - pw.print(" mDozeHardware: "); pw.println(mDozeHardware); pw.print(" mTeaseReceiverRegistered: "); pw.println(mTeaseReceiverRegistered); pw.print(" mSigMotionSensor: "); pw.println(mSigMotionSensor); pw.print(" mSigMotionConfigured: "); pw.println(mSigMotionConfigured); @@ -123,9 +120,7 @@ public class DozeService extends DreamService { @Override public void onDreamingStarted() { super.onDreamingStarted(); - mDozeHardware = getDozeHardware(); - if (DEBUG) Log.d(mTag, "onDreamingStarted canDoze=" + canDoze() - + " dozeHardware=" + mDozeHardware); + if (DEBUG) Log.d(mTag, "onDreamingStarted canDoze=" + canDoze()); mDreaming = true; listenForTeaseSignals(true); requestDoze(); @@ -162,7 +157,6 @@ public class DozeService extends DreamService { super.onDreamingStopped(); mDreaming = false; - mDozeHardware = null; if (mWakeLock.isHeld()) { mWakeLock.release(); } diff --git a/services/core/java/com/android/server/dreams/DreamManagerService.java b/services/core/java/com/android/server/dreams/DreamManagerService.java index 107a6f6..b894304 100644 --- a/services/core/java/com/android/server/dreams/DreamManagerService.java +++ b/services/core/java/com/android/server/dreams/DreamManagerService.java @@ -45,7 +45,6 @@ import android.os.UserHandle; import android.provider.Settings; import android.service.dreams.DreamManagerInternal; import android.service.dreams.DreamService; -import android.service.dreams.IDozeHardware; import android.service.dreams.IDreamManager; import android.text.TextUtils; import android.util.Slog; @@ -75,7 +74,6 @@ public final class DreamManagerService extends SystemService { private final PowerManager mPowerManager; private final PowerManagerInternal mPowerManagerInternal; private final PowerManager.WakeLock mDozeWakeLock; - private final McuHal mMcuHal; // synchronized on self private Binder mCurrentDreamToken; private ComponentName mCurrentDreamName; @@ -86,7 +84,6 @@ public final class DreamManagerService extends SystemService { private boolean mCurrentDreamIsWaking; private int mCurrentDreamDozeScreenState = Display.STATE_UNKNOWN; private int mCurrentDreamDozeScreenBrightness = PowerManager.BRIGHTNESS_DEFAULT; - private DozeHardwareWrapper mCurrentDreamDozeHardware; public DreamManagerService(Context context) { super(context); @@ -97,11 +94,6 @@ public final class DreamManagerService extends SystemService { mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); mPowerManagerInternal = getLocalService(PowerManagerInternal.class); mDozeWakeLock = mPowerManager.newWakeLock(PowerManager.DOZE_WAKE_LOCK, TAG); - - mMcuHal = McuHal.open(); - if (mMcuHal != null) { - mMcuHal.reset(); - } } @Override @@ -130,9 +122,6 @@ public final class DreamManagerService extends SystemService { private void dumpInternal(PrintWriter pw) { pw.println("DREAM MANAGER (dumpsys dreams)"); pw.println(); - - pw.println("mMcuHal=" + mMcuHal); - pw.println(); pw.println("mCurrentDreamToken=" + mCurrentDreamToken); pw.println("mCurrentDreamName=" + mCurrentDreamName); pw.println("mCurrentDreamUserId=" + mCurrentDreamUserId); @@ -143,7 +132,6 @@ public final class DreamManagerService extends SystemService { pw.println("mCurrentDreamDozeScreenState=" + Display.stateToString(mCurrentDreamDozeScreenState)); pw.println("mCurrentDreamDozeScreenBrightness=" + mCurrentDreamDozeScreenBrightness); - pw.println("mCurrentDreamDozeHardware=" + mCurrentDreamDozeHardware); pw.println("getDozeComponent()=" + getDozeComponent()); pw.println(); @@ -259,17 +247,6 @@ public final class DreamManagerService extends SystemService { } } - private IDozeHardware getDozeHardwareInternal(IBinder token) { - synchronized (mLock) { - if (mCurrentDreamToken == token && mCurrentDreamCanDoze - && mCurrentDreamDozeHardware == null && mMcuHal != null) { - mCurrentDreamDozeHardware = new DozeHardwareWrapper(); - return mCurrentDreamDozeHardware; - } - return null; - } - } - private ComponentName chooseDreamForUser(boolean doze, int userId) { if (doze) { ComponentName dozeComponent = getDozeComponent(); @@ -420,10 +397,6 @@ public final class DreamManagerService extends SystemService { } mCurrentDreamDozeScreenState = Display.STATE_UNKNOWN; mCurrentDreamDozeScreenBrightness = PowerManager.BRIGHTNESS_DEFAULT; - if (mCurrentDreamDozeHardware != null) { - mCurrentDreamDozeHardware.release(); - mCurrentDreamDozeHardware = null; - } } private void checkPermission(String permission) { @@ -642,21 +615,6 @@ public final class DreamManagerService extends SystemService { Binder.restoreCallingIdentity(ident); } } - - @Override // Binder call - public IDozeHardware getDozeHardware(IBinder token) { - // Requires no permission, called by Dream from an arbitrary process. - if (token == null) { - throw new IllegalArgumentException("token must not be null"); - } - - final long ident = Binder.clearCallingIdentity(); - try { - return getDozeHardwareInternal(token); - } finally { - Binder.restoreCallingIdentity(ident); - } - } } private final class LocalService extends DreamManagerInternal { @@ -676,40 +634,6 @@ public final class DreamManagerService extends SystemService { } } - private final class DozeHardwareWrapper extends IDozeHardware.Stub { - private boolean mReleased; - - public void release() { - synchronized (mMcuHal) { - if (!mReleased) { - mReleased = true; - mMcuHal.reset(); - } - } - } - - @Override // Binder call - public byte[] sendMessage(String msg, byte[] arg) { - if (msg == null) { - throw new IllegalArgumentException("msg must not be null"); - } - - final long ident = Binder.clearCallingIdentity(); - try { - synchronized (mMcuHal) { - if (mReleased) { - Slog.w(TAG, "Ignoring message to MCU HAL because the dream " - + "has already ended: " + msg); - return null; - } - return mMcuHal.sendMessage(msg, arg); - } - } finally { - Binder.restoreCallingIdentity(ident); - } - } - } - private final Runnable mSystemPropertiesChanged = new Runnable() { @Override public void run() { diff --git a/services/core/java/com/android/server/dreams/McuHal.java b/services/core/java/com/android/server/dreams/McuHal.java deleted file mode 100644 index 1dc79c7..0000000 --- a/services/core/java/com/android/server/dreams/McuHal.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.server.dreams; - -import android.service.dreams.DozeHardware; - -/** - * Provides access to the low-level microcontroller hardware abstraction layer. - */ -final class McuHal { - private final long mPtr; - - private static native long nativeOpen(); - private static native byte[] nativeSendMessage(long ptr, String msg, byte[] arg); - - private McuHal(long ptr) { - mPtr = ptr; - } - - public static McuHal open() { - long ptr = nativeOpen(); - return ptr != 0 ? new McuHal(ptr) : null; - } - - public void reset() { - sendMessage(DozeHardware.MSG_ENABLE_MCU, DozeHardware.VALUE_OFF); - } - - public byte[] sendMessage(String msg, byte[] arg) { - return nativeSendMessage(mPtr, msg, arg); - } -} diff --git a/services/core/jni/Android.mk b/services/core/jni/Android.mk index 5599760..9a4d900 100644 --- a/services/core/jni/Android.mk +++ b/services/core/jni/Android.mk @@ -10,7 +10,6 @@ LOCAL_SRC_FILES += \ $(LOCAL_REL_DIR)/com_android_server_AssetAtlasService.cpp \ $(LOCAL_REL_DIR)/com_android_server_connectivity_Vpn.cpp \ $(LOCAL_REL_DIR)/com_android_server_ConsumerIrService.cpp \ - $(LOCAL_REL_DIR)/com_android_server_dreams_McuHal.cpp \ $(LOCAL_REL_DIR)/com_android_server_hdmi_HdmiCecController.cpp \ $(LOCAL_REL_DIR)/com_android_server_hdmi_HdmiMhlController.cpp \ $(LOCAL_REL_DIR)/com_android_server_input_InputApplicationHandle.cpp \ diff --git a/services/core/jni/com_android_server_dreams_McuHal.cpp b/services/core/jni/com_android_server_dreams_McuHal.cpp deleted file mode 100644 index a6d9297..0000000 --- a/services/core/jni/com_android_server_dreams_McuHal.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "McuHal" - -//#define LOG_NDEBUG 0 - -#include "JNIHelp.h" -#include "jni.h" - -#include <ScopedUtfChars.h> -#include <ScopedPrimitiveArray.h> - -#include <utils/Errors.h> -#include <utils/Log.h> -#include <hardware/mcu.h> - -namespace android { - -static jlong nativeOpen(JNIEnv* env, jclass clazz) { - mcu_module_t* module = NULL; - status_t err = hw_get_module(MCU_HARDWARE_MODULE_ID, - (hw_module_t const**)&module); - if (err) { - ALOGE("Couldn't load %s module (%s)", MCU_HARDWARE_MODULE_ID, strerror(-err)); - return 0; - } - - err = module->init(module); - if (err) { - ALOGE("Couldn't initialize %s module (%s)", MCU_HARDWARE_MODULE_ID, strerror(-err)); - return 0; - } - - return reinterpret_cast<jlong>(module); -} - -static jbyteArray nativeSendMessage(JNIEnv* env, jclass clazz, - jlong ptr, jstring msgStr, jbyteArray argArray) { - mcu_module_t* module = reinterpret_cast<mcu_module_t*>(ptr); - - ScopedUtfChars msg(env, msgStr); - ALOGV("Sending message %s to MCU", msg.c_str()); - - void* result = NULL; - size_t resultSize = 0; - status_t err; - if (argArray) { - ScopedByteArrayRO arg(env, argArray); - err = module->sendMessage(module, msg.c_str(), arg.get(), arg.size(), - &result, &resultSize); - } else { - err = module->sendMessage(module, msg.c_str(), NULL, 0, &result, &resultSize); - } - if (err) { - ALOGE("Couldn't send message to MCU (%s)", strerror(-err)); - return NULL; - } - - if (!result) { - return NULL; - } - - jbyteArray resultArray = env->NewByteArray(resultSize); - if (resultArray) { - env->SetByteArrayRegion(resultArray, 0, resultSize, static_cast<jbyte*>(result)); - } - free(result); - return resultArray; -} - -static JNINativeMethod gMcuHalMethods[] = { - /* name, signature, funcPtr */ - { "nativeOpen", "()J", - (void*) nativeOpen }, - { "nativeSendMessage", "(JLjava/lang/String;[B)[B", - (void*) nativeSendMessage }, -}; - -int register_android_server_dreams_McuHal(JNIEnv* env) { - int res = jniRegisterNativeMethods(env, "com/android/server/dreams/McuHal", - gMcuHalMethods, NELEM(gMcuHalMethods)); - LOG_FATAL_IF(res < 0, "Unable to register native methods."); - return 0; -} - -} /* namespace android */ diff --git a/services/core/jni/onload.cpp b/services/core/jni/onload.cpp index bf7501e..ce2ca9b 100644 --- a/services/core/jni/onload.cpp +++ b/services/core/jni/onload.cpp @@ -37,7 +37,6 @@ int register_android_server_VibratorService(JNIEnv* env); int register_android_server_location_GpsLocationProvider(JNIEnv* env); int register_android_server_location_FlpHardwareProvider(JNIEnv* env); int register_android_server_connectivity_Vpn(JNIEnv* env); -int register_android_server_dreams_McuHal(JNIEnv* env); int register_android_server_hdmi_HdmiCecController(JNIEnv* env); int register_android_server_hdmi_HdmiMhlController(JNIEnv* env); int register_android_server_tv_TvInputHal(JNIEnv* env); @@ -73,7 +72,6 @@ extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) register_android_server_connectivity_Vpn(env); register_android_server_AssetAtlasService(env); register_android_server_ConsumerIrService(env); - register_android_server_dreams_McuHal(env); register_android_server_BatteryStatsService(env); register_android_server_hdmi_HdmiCecController(env); register_android_server_hdmi_HdmiMhlController(env); diff --git a/tests/DozeTest/src/com/android/dreams/dozetest/DozeTestDream.java b/tests/DozeTest/src/com/android/dreams/dozetest/DozeTestDream.java index f72e331..f4f610b 100644 --- a/tests/DozeTest/src/com/android/dreams/dozetest/DozeTestDream.java +++ b/tests/DozeTest/src/com/android/dreams/dozetest/DozeTestDream.java @@ -24,7 +24,6 @@ import android.content.Intent; import android.content.IntentFilter; import android.os.Handler; import android.os.PowerManager; -import android.service.dreams.DozeHardware; import android.service.dreams.DreamService; import android.text.format.DateFormat; import android.util.Log; @@ -49,10 +48,6 @@ public class DozeTestDream extends DreamService { // refreshed once the dream has finished rendering a new frame. private static final int UPDATE_TIME_TIMEOUT = 100; - // A doze hardware message string we use for end-to-end testing. - // Doesn't mean anything. Real hardware won't handle it. - private static final String TEST_PING_MESSAGE = "test.ping"; - // Not all hardware supports dozing. We should use Display.STATE_DOZE but // for testing purposes it is convenient to use Display.STATE_ON so the // test still works on hardware that does not support dozing. @@ -70,7 +65,6 @@ public class DozeTestDream extends DreamService { private java.text.DateFormat mTimeFormat; private boolean mDreaming; - private DozeHardware mDozeHardware; private long mLastTime = Long.MIN_VALUE; @@ -121,17 +115,11 @@ public class DozeTestDream extends DreamService { super.onDreamingStarted(); mDreaming = true; - mDozeHardware = getDozeHardware(); - Log.d(TAG, "Dream started: canDoze=" + canDoze() - + ", dozeHardware=" + mDozeHardware); + Log.d(TAG, "Dream started: canDoze=" + canDoze()); performTimeUpdate(); - if (mDozeHardware != null) { - mDozeHardware.sendMessage(TEST_PING_MESSAGE, null); - mDozeHardware.setEnableMcu(true); - } startDozing(); } @@ -140,10 +128,6 @@ public class DozeTestDream extends DreamService { super.onDreamingStopped(); mDreaming = false; - if (mDozeHardware != null) { - mDozeHardware.setEnableMcu(false); - mDozeHardware = null; - } Log.d(TAG, "Dream ended: isDozing=" + isDozing()); |