am 30348b0d
: Merge change I086d681f into eclair-mr2
Merge commit '30348b0de11b6c6cba43dfc7960e4d2084af6d8b' into eclair-mr2-plus-aosp * commit '30348b0de11b6c6cba43dfc7960e4d2084af6d8b': Remove HardwareService and move vibrator support to VibratorService.
This commit is contained in:
@ -108,13 +108,13 @@ LOCAL_SRC_FILES += \
|
|||||||
core/java/android/hardware/ISensorService.aidl \
|
core/java/android/hardware/ISensorService.aidl \
|
||||||
core/java/android/net/IConnectivityManager.aidl \
|
core/java/android/net/IConnectivityManager.aidl \
|
||||||
core/java/android/os/ICheckinService.aidl \
|
core/java/android/os/ICheckinService.aidl \
|
||||||
core/java/android/os/IHardwareService.aidl \
|
|
||||||
core/java/android/os/IMessenger.aidl \
|
core/java/android/os/IMessenger.aidl \
|
||||||
core/java/android/os/IMountService.aidl \
|
core/java/android/os/IMountService.aidl \
|
||||||
core/java/android/os/INetStatService.aidl \
|
core/java/android/os/INetStatService.aidl \
|
||||||
core/java/android/os/IParentalControlCallback.aidl \
|
core/java/android/os/IParentalControlCallback.aidl \
|
||||||
core/java/android/os/IPermissionController.aidl \
|
core/java/android/os/IPermissionController.aidl \
|
||||||
core/java/android/os/IPowerManager.aidl \
|
core/java/android/os/IPowerManager.aidl \
|
||||||
|
core/java/android/os/IVibratorService.aidl \
|
||||||
core/java/android/service/wallpaper/IWallpaperConnection.aidl \
|
core/java/android/service/wallpaper/IWallpaperConnection.aidl \
|
||||||
core/java/android/service/wallpaper/IWallpaperEngine.aidl \
|
core/java/android/service/wallpaper/IWallpaperEngine.aidl \
|
||||||
core/java/android/service/wallpaper/IWallpaperService.aidl \
|
core/java/android/service/wallpaper/IWallpaperService.aidl \
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2006 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.os;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@hide}
|
|
||||||
*/
|
|
||||||
public class Hardware
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
/* ********************************************************************************
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Don't add anything else to this class. Add it to HardwareService instead.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* ********************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
public static native boolean getFlashlightEnabled();
|
|
||||||
public static native void setFlashlightEnabled(boolean on);
|
|
||||||
public static native void enableCameraFlash(int milliseconds);
|
|
||||||
}
|
|
@ -17,19 +17,10 @@
|
|||||||
package android.os;
|
package android.os;
|
||||||
|
|
||||||
/** {@hide} */
|
/** {@hide} */
|
||||||
interface IHardwareService
|
interface IVibratorService
|
||||||
{
|
{
|
||||||
// Vibrator support
|
|
||||||
void vibrate(long milliseconds, IBinder token);
|
void vibrate(long milliseconds, IBinder token);
|
||||||
void vibratePattern(in long[] pattern, int repeat, IBinder token);
|
void vibratePattern(in long[] pattern, int repeat, IBinder token);
|
||||||
void cancelVibrate(IBinder token);
|
void cancelVibrate(IBinder token);
|
||||||
|
|
||||||
// flashlight support
|
|
||||||
boolean getFlashlightEnabled();
|
|
||||||
void setFlashlightEnabled(boolean on);
|
|
||||||
void enableCameraFlash(int milliseconds);
|
|
||||||
|
|
||||||
// for the phone
|
|
||||||
void setAttentionLight(boolean on, int color);
|
|
||||||
}
|
}
|
||||||
|
|
@ -23,14 +23,14 @@ package android.os;
|
|||||||
*/
|
*/
|
||||||
public class Vibrator
|
public class Vibrator
|
||||||
{
|
{
|
||||||
IHardwareService mService;
|
IVibratorService mService;
|
||||||
private final Binder mToken = new Binder();
|
private final Binder mToken = new Binder();
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public Vibrator()
|
public Vibrator()
|
||||||
{
|
{
|
||||||
mService = IHardwareService.Stub.asInterface(
|
mService = IVibratorService.Stub.asInterface(
|
||||||
ServiceManager.getService("hardware"));
|
ServiceManager.getService("vibrator"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +54,6 @@ LOCAL_SRC_FILES:= \
|
|||||||
android_os_SystemClock.cpp \
|
android_os_SystemClock.cpp \
|
||||||
android_os_SystemProperties.cpp \
|
android_os_SystemProperties.cpp \
|
||||||
android_os_UEventObserver.cpp \
|
android_os_UEventObserver.cpp \
|
||||||
android_os_Hardware.cpp \
|
|
||||||
android_net_LocalSocketImpl.cpp \
|
android_net_LocalSocketImpl.cpp \
|
||||||
android_net_NetUtils.cpp \
|
android_net_NetUtils.cpp \
|
||||||
android_net_wifi_Wifi.cpp \
|
android_net_wifi_Wifi.cpp \
|
||||||
|
@ -130,7 +130,6 @@ extern int register_android_os_ParcelFileDescriptor(JNIEnv *env);
|
|||||||
extern int register_android_os_Power(JNIEnv *env);
|
extern int register_android_os_Power(JNIEnv *env);
|
||||||
extern int register_android_os_StatFs(JNIEnv *env);
|
extern int register_android_os_StatFs(JNIEnv *env);
|
||||||
extern int register_android_os_SystemProperties(JNIEnv *env);
|
extern int register_android_os_SystemProperties(JNIEnv *env);
|
||||||
extern int register_android_os_Hardware(JNIEnv* env);
|
|
||||||
extern int register_android_os_SystemClock(JNIEnv* env);
|
extern int register_android_os_SystemClock(JNIEnv* env);
|
||||||
extern int register_android_os_FileObserver(JNIEnv *env);
|
extern int register_android_os_FileObserver(JNIEnv *env);
|
||||||
extern int register_android_os_FileUtils(JNIEnv *env);
|
extern int register_android_os_FileUtils(JNIEnv *env);
|
||||||
@ -1166,7 +1165,6 @@ static const RegJNIRec gRegJNI[] = {
|
|||||||
REG_JNI(register_android_text_KeyCharacterMap),
|
REG_JNI(register_android_text_KeyCharacterMap),
|
||||||
REG_JNI(register_android_os_Process),
|
REG_JNI(register_android_os_Process),
|
||||||
REG_JNI(register_android_os_Binder),
|
REG_JNI(register_android_os_Binder),
|
||||||
REG_JNI(register_android_os_Hardware),
|
|
||||||
REG_JNI(register_android_view_Display),
|
REG_JNI(register_android_view_Display),
|
||||||
REG_JNI(register_android_nio_utils),
|
REG_JNI(register_android_nio_utils),
|
||||||
REG_JNI(register_android_graphics_PixelFormat),
|
REG_JNI(register_android_graphics_PixelFormat),
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2006, 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <hardware_legacy/flashlight.h>
|
|
||||||
#include <hardware_legacy/power.h>
|
|
||||||
|
|
||||||
#include <nativehelper/jni.h>
|
|
||||||
#include <android_runtime/AndroidRuntime.h>
|
|
||||||
#include <nativehelper/JNIHelp.h>
|
|
||||||
|
|
||||||
namespace android {
|
|
||||||
|
|
||||||
static jint
|
|
||||||
getFlashlightEnabled(JNIEnv *env, jobject clazz)
|
|
||||||
{
|
|
||||||
return get_flashlight_enabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
setFlashlightEnabled(JNIEnv *env, jobject clazz, jboolean on)
|
|
||||||
{
|
|
||||||
set_flashlight_enabled(on);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
enableCameraFlash(JNIEnv *env, jobject clazz, jint milliseconds)
|
|
||||||
{
|
|
||||||
enable_camera_flash(milliseconds);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
/*
|
|
||||||
* JNI registration.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static JNINativeMethod g_methods[] = {
|
|
||||||
/* name, signature, funcPtr */
|
|
||||||
{ "getFlashlightEnabled", "()Z", (void*)getFlashlightEnabled },
|
|
||||||
{ "setFlashlightEnabled", "(Z)V", (void*)setFlashlightEnabled },
|
|
||||||
{ "enableCameraFlash", "(I)V", (void*)enableCameraFlash },
|
|
||||||
};
|
|
||||||
|
|
||||||
int register_android_os_Hardware(JNIEnv* env)
|
|
||||||
{
|
|
||||||
return AndroidRuntime::registerNativeMethods(env,
|
|
||||||
"android/os/Hardware", g_methods, NELEM(g_methods));
|
|
||||||
}
|
|
||||||
|
|
||||||
}; // namespace android
|
|
@ -501,10 +501,8 @@ android.os.FileUtils
|
|||||||
android.os.FileUtils$FileStatus
|
android.os.FileUtils$FileStatus
|
||||||
android.os.Handler
|
android.os.Handler
|
||||||
android.os.HandlerThread
|
android.os.HandlerThread
|
||||||
android.os.Hardware
|
|
||||||
android.os.IBinder
|
android.os.IBinder
|
||||||
android.os.ICheckinService$Stub
|
android.os.ICheckinService$Stub
|
||||||
android.os.IHardwareService$Stub
|
|
||||||
android.os.IInterface
|
android.os.IInterface
|
||||||
android.os.IMountService$Stub
|
android.os.IMountService$Stub
|
||||||
android.os.IMountService$Stub$Proxy
|
android.os.IMountService$Stub$Proxy
|
||||||
@ -512,6 +510,7 @@ android.os.INetStatService$Stub
|
|||||||
android.os.IParentalControlCallback$Stub
|
android.os.IParentalControlCallback$Stub
|
||||||
android.os.IPowerManager$Stub
|
android.os.IPowerManager$Stub
|
||||||
android.os.IPowerManager$Stub$Proxy
|
android.os.IPowerManager$Stub$Proxy
|
||||||
|
android.os.IVibratorService$Stub
|
||||||
android.os.Looper
|
android.os.Looper
|
||||||
android.os.MemoryFile
|
android.os.MemoryFile
|
||||||
android.os.Message
|
android.os.Message
|
||||||
|
133
services/java/com/android/server/LightsService.java
Normal file
133
services/java/com/android/server/LightsService.java
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2008 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;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
public class LightsService {
|
||||||
|
private static final String TAG = "LightsService";
|
||||||
|
|
||||||
|
static final int LIGHT_ID_BACKLIGHT = 0;
|
||||||
|
static final int LIGHT_ID_KEYBOARD = 1;
|
||||||
|
static final int LIGHT_ID_BUTTONS = 2;
|
||||||
|
static final int LIGHT_ID_BATTERY = 3;
|
||||||
|
static final int LIGHT_ID_NOTIFICATIONS = 4;
|
||||||
|
static final int LIGHT_ID_ATTENTION = 5;
|
||||||
|
|
||||||
|
static final int LIGHT_FLASH_NONE = 0;
|
||||||
|
static final int LIGHT_FLASH_TIMED = 1;
|
||||||
|
static final int LIGHT_FLASH_HARDWARE = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Light brightness is managed by a user setting.
|
||||||
|
*/
|
||||||
|
static final int BRIGHTNESS_MODE_USER = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Light brightness is managed by a light sensor.
|
||||||
|
*/
|
||||||
|
static final int BRIGHTNESS_MODE_SENSOR = 1;
|
||||||
|
|
||||||
|
private boolean mAttentionLightOn;
|
||||||
|
private boolean mPulsing;
|
||||||
|
|
||||||
|
LightsService(Context context) {
|
||||||
|
|
||||||
|
mNativePointer = init_native();
|
||||||
|
mContext = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void finalize() throws Throwable {
|
||||||
|
finalize_native(mNativePointer);
|
||||||
|
super.finalize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLightOff(int light) {
|
||||||
|
setLight_native(mNativePointer, light, 0, LIGHT_FLASH_NONE, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLightBrightness(int light, int brightness, int brightnessMode) {
|
||||||
|
int b = brightness & 0x000000ff;
|
||||||
|
b = 0xff000000 | (b << 16) | (b << 8) | b;
|
||||||
|
setLight_native(mNativePointer, light, b, LIGHT_FLASH_NONE, 0, 0, brightnessMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLightColor(int light, int color) {
|
||||||
|
setLight_native(mNativePointer, light, color, LIGHT_FLASH_NONE, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLightFlashing(int light, int color, int mode, int onMS, int offMS) {
|
||||||
|
setLight_native(mNativePointer, light, color, mode, onMS, offMS, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAttentionLight(boolean on, int color) {
|
||||||
|
// Not worthy of a permission. We shouldn't have a flashlight permission.
|
||||||
|
synchronized (this) {
|
||||||
|
mAttentionLightOn = on;
|
||||||
|
mPulsing = false;
|
||||||
|
setLight_native(mNativePointer, LIGHT_ID_ATTENTION, color,
|
||||||
|
LIGHT_FLASH_HARDWARE, on ? 3 : 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pulseBreathingLight() {
|
||||||
|
synchronized (this) {
|
||||||
|
// HACK: Added at the last minute of cupcake -- design this better;
|
||||||
|
// Don't reuse the attention light -- make another one.
|
||||||
|
if (false) {
|
||||||
|
Log.d(TAG, "pulseBreathingLight mAttentionLightOn=" + mAttentionLightOn
|
||||||
|
+ " mPulsing=" + mPulsing);
|
||||||
|
}
|
||||||
|
if (!mAttentionLightOn && !mPulsing) {
|
||||||
|
mPulsing = true;
|
||||||
|
setLight_native(mNativePointer, LIGHT_ID_ATTENTION, 0x00ffffff,
|
||||||
|
LIGHT_FLASH_HARDWARE, 7, 0, 0);
|
||||||
|
mH.sendMessageDelayed(Message.obtain(mH, 1), 3000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Handler mH = new Handler() {
|
||||||
|
@Override
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
synchronized (this) {
|
||||||
|
if (false) {
|
||||||
|
Log.d(TAG, "pulse cleanup handler firing mPulsing=" + mPulsing);
|
||||||
|
}
|
||||||
|
if (mPulsing) {
|
||||||
|
mPulsing = false;
|
||||||
|
setLight_native(mNativePointer, LIGHT_ID_ATTENTION,
|
||||||
|
mAttentionLightOn ? 0xffffffff : 0,
|
||||||
|
LIGHT_FLASH_NONE, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private static native int init_native();
|
||||||
|
private static native void finalize_native(int ptr);
|
||||||
|
|
||||||
|
private static native void setLight_native(int ptr, int light, int color, int mode,
|
||||||
|
int onMS, int offMS, int brightnessMode);
|
||||||
|
|
||||||
|
private final Context mContext;
|
||||||
|
|
||||||
|
private int mNativePointer;
|
||||||
|
}
|
@ -86,7 +86,7 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
|
|
||||||
private WorkerHandler mHandler;
|
private WorkerHandler mHandler;
|
||||||
private StatusBarService mStatusBarService;
|
private StatusBarService mStatusBarService;
|
||||||
private HardwareService mHardware;
|
private LightsService mLightsService;
|
||||||
|
|
||||||
private NotificationRecord mSoundNotification;
|
private NotificationRecord mSoundNotification;
|
||||||
private AsyncPlayer mSound;
|
private AsyncPlayer mSound;
|
||||||
@ -363,11 +363,11 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
private final SettingsObserver mSettingsObserver;
|
private final SettingsObserver mSettingsObserver;
|
||||||
|
|
||||||
NotificationManagerService(Context context, StatusBarService statusBar,
|
NotificationManagerService(Context context, StatusBarService statusBar,
|
||||||
HardwareService hardware)
|
LightsService lights)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mHardware = hardware;
|
mLightsService = lights;
|
||||||
mAm = ActivityManagerNative.getDefault();
|
mAm = ActivityManagerNative.getDefault();
|
||||||
mSound = new AsyncPlayer(TAG);
|
mSound = new AsyncPlayer(TAG);
|
||||||
mSound.setUsesWakeLock(context);
|
mSound.setUsesWakeLock(context);
|
||||||
@ -678,7 +678,7 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
long identity = Binder.clearCallingIdentity();
|
long identity = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
r.statusBarKey = mStatusBarService.addIcon(icon, n);
|
r.statusBarKey = mStatusBarService.addIcon(icon, n);
|
||||||
mHardware.pulseBreathingLight();
|
mLightsService.pulseBreathingLight();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
Binder.restoreCallingIdentity(identity);
|
Binder.restoreCallingIdentity(identity);
|
||||||
@ -969,24 +969,24 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
// Battery low always shows, other states only show if charging.
|
// Battery low always shows, other states only show if charging.
|
||||||
if (mBatteryLow) {
|
if (mBatteryLow) {
|
||||||
if (mBatteryCharging) {
|
if (mBatteryCharging) {
|
||||||
mHardware.setLightColor_UNCHECKED(HardwareService.LIGHT_ID_BATTERY,
|
mLightsService.setLightColor(LightsService.LIGHT_ID_BATTERY,
|
||||||
BATTERY_LOW_ARGB);
|
BATTERY_LOW_ARGB);
|
||||||
} else {
|
} else {
|
||||||
// Flash when battery is low and not charging
|
// Flash when battery is low and not charging
|
||||||
mHardware.setLightFlashing_UNCHECKED(HardwareService.LIGHT_ID_BATTERY,
|
mLightsService.setLightFlashing(LightsService.LIGHT_ID_BATTERY,
|
||||||
BATTERY_LOW_ARGB, HardwareService.LIGHT_FLASH_TIMED,
|
BATTERY_LOW_ARGB, LightsService.LIGHT_FLASH_TIMED,
|
||||||
BATTERY_BLINK_ON, BATTERY_BLINK_OFF);
|
BATTERY_BLINK_ON, BATTERY_BLINK_OFF);
|
||||||
}
|
}
|
||||||
} else if (mBatteryCharging) {
|
} else if (mBatteryCharging) {
|
||||||
if (mBatteryFull) {
|
if (mBatteryFull) {
|
||||||
mHardware.setLightColor_UNCHECKED(HardwareService.LIGHT_ID_BATTERY,
|
mLightsService.setLightColor(LightsService.LIGHT_ID_BATTERY,
|
||||||
BATTERY_FULL_ARGB);
|
BATTERY_FULL_ARGB);
|
||||||
} else {
|
} else {
|
||||||
mHardware.setLightColor_UNCHECKED(HardwareService.LIGHT_ID_BATTERY,
|
mLightsService.setLightColor(LightsService.LIGHT_ID_BATTERY,
|
||||||
BATTERY_MEDIUM_ARGB);
|
BATTERY_MEDIUM_ARGB);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mHardware.setLightOff_UNCHECKED(HardwareService.LIGHT_ID_BATTERY);
|
mLightsService.setLightOff(LightsService.LIGHT_ID_BATTERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle notification lights
|
// handle notification lights
|
||||||
@ -998,12 +998,12 @@ class NotificationManagerService extends INotificationManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mLedNotification == null) {
|
if (mLedNotification == null) {
|
||||||
mHardware.setLightOff_UNCHECKED(HardwareService.LIGHT_ID_NOTIFICATIONS);
|
mLightsService.setLightOff(LightsService.LIGHT_ID_NOTIFICATIONS);
|
||||||
} else {
|
} else {
|
||||||
mHardware.setLightFlashing_UNCHECKED(
|
mLightsService.setLightFlashing(
|
||||||
HardwareService.LIGHT_ID_NOTIFICATIONS,
|
LightsService.LIGHT_ID_NOTIFICATIONS,
|
||||||
mLedNotification.notification.ledARGB,
|
mLedNotification.notification.ledARGB,
|
||||||
HardwareService.LIGHT_FLASH_TIMED,
|
LightsService.LIGHT_FLASH_TIMED,
|
||||||
mLedNotification.notification.ledOnMS,
|
mLedNotification.notification.ledOnMS,
|
||||||
mLedNotification.notification.ledOffMS);
|
mLedNotification.notification.ledOffMS);
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
private final LockList mLocks = new LockList();
|
private final LockList mLocks = new LockList();
|
||||||
private Intent mScreenOffIntent;
|
private Intent mScreenOffIntent;
|
||||||
private Intent mScreenOnIntent;
|
private Intent mScreenOnIntent;
|
||||||
private HardwareService mHardware;
|
private LightsService mLightsService;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private UnsynchronizedWakeLock mBroadcastWakeLock;
|
private UnsynchronizedWakeLock mBroadcastWakeLock;
|
||||||
private UnsynchronizedWakeLock mStayOnWhilePluggedInScreenDimLock;
|
private UnsynchronizedWakeLock mStayOnWhilePluggedInScreenDimLock;
|
||||||
@ -420,9 +420,9 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
|
|
||||||
private ContentQueryMap mSettings;
|
private ContentQueryMap mSettings;
|
||||||
|
|
||||||
void init(Context context, HardwareService hardware, IActivityManager activity,
|
void init(Context context, LightsService lights, IActivityManager activity,
|
||||||
BatteryService battery) {
|
BatteryService battery) {
|
||||||
mHardware = hardware;
|
mLightsService = lights;
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mActivityService = activity;
|
mActivityService = activity;
|
||||||
mBatteryStats = BatteryStatsService.getService();
|
mBatteryStats = BatteryStatsService.getService();
|
||||||
@ -1363,11 +1363,11 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
if (!on) {
|
if (!on) {
|
||||||
// make sure button and key backlights are off too
|
// make sure button and key backlights are off too
|
||||||
int brightnessMode = (mUseSoftwareAutoBrightness
|
int brightnessMode = (mUseSoftwareAutoBrightness
|
||||||
? HardwareService.BRIGHTNESS_MODE_SENSOR
|
? LightsService.BRIGHTNESS_MODE_SENSOR
|
||||||
: HardwareService.BRIGHTNESS_MODE_USER);
|
: LightsService.BRIGHTNESS_MODE_USER);
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS, 0,
|
mLightsService.setLightBrightness(LightsService.LIGHT_ID_BUTTONS, 0,
|
||||||
brightnessMode);
|
brightnessMode);
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_KEYBOARD, 0,
|
mLightsService.setLightBrightness(LightsService.LIGHT_ID_KEYBOARD, 0,
|
||||||
brightnessMode);
|
brightnessMode);
|
||||||
// clear current value so we will update based on the new conditions
|
// clear current value so we will update based on the new conditions
|
||||||
// when the sensor is reenabled.
|
// when the sensor is reenabled.
|
||||||
@ -1720,21 +1720,21 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
|
|
||||||
private void setLightBrightness(int mask, int value) {
|
private void setLightBrightness(int mask, int value) {
|
||||||
int brightnessMode = (mAutoBrightessEnabled
|
int brightnessMode = (mAutoBrightessEnabled
|
||||||
? HardwareService.BRIGHTNESS_MODE_SENSOR
|
? LightsService.BRIGHTNESS_MODE_SENSOR
|
||||||
: HardwareService.BRIGHTNESS_MODE_USER);
|
: LightsService.BRIGHTNESS_MODE_USER);
|
||||||
if ((mask & SCREEN_BRIGHT_BIT) != 0) {
|
if ((mask & SCREEN_BRIGHT_BIT) != 0) {
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BACKLIGHT, value,
|
mLightsService.setLightBrightness(LightsService.LIGHT_ID_BACKLIGHT, value,
|
||||||
brightnessMode);
|
brightnessMode);
|
||||||
}
|
}
|
||||||
brightnessMode = (mUseSoftwareAutoBrightness
|
brightnessMode = (mUseSoftwareAutoBrightness
|
||||||
? HardwareService.BRIGHTNESS_MODE_SENSOR
|
? LightsService.BRIGHTNESS_MODE_SENSOR
|
||||||
: HardwareService.BRIGHTNESS_MODE_USER);
|
: LightsService.BRIGHTNESS_MODE_USER);
|
||||||
if ((mask & BUTTON_BRIGHT_BIT) != 0) {
|
if ((mask & BUTTON_BRIGHT_BIT) != 0) {
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS, value,
|
mLightsService.setLightBrightness(LightsService.LIGHT_ID_BUTTONS, value,
|
||||||
brightnessMode);
|
brightnessMode);
|
||||||
}
|
}
|
||||||
if ((mask & KEYBOARD_BRIGHT_BIT) != 0) {
|
if ((mask & KEYBOARD_BRIGHT_BIT) != 0) {
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_KEYBOARD, value,
|
mLightsService.setLightBrightness(LightsService.LIGHT_ID_KEYBOARD, value,
|
||||||
brightnessMode);
|
brightnessMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2081,9 +2081,9 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int brightnessMode = (mAutoBrightessEnabled
|
int brightnessMode = (mAutoBrightessEnabled
|
||||||
? HardwareService.BRIGHTNESS_MODE_SENSOR
|
? LightsService.BRIGHTNESS_MODE_SENSOR
|
||||||
: HardwareService.BRIGHTNESS_MODE_USER);
|
: LightsService.BRIGHTNESS_MODE_USER);
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BACKLIGHT,
|
mLightsService.setLightBrightness(LightsService.LIGHT_ID_BACKLIGHT,
|
||||||
lcdValue, brightnessMode);
|
lcdValue, brightnessMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2096,9 +2096,9 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int brightnessMode = (mUseSoftwareAutoBrightness
|
int brightnessMode = (mUseSoftwareAutoBrightness
|
||||||
? HardwareService.BRIGHTNESS_MODE_SENSOR
|
? LightsService.BRIGHTNESS_MODE_SENSOR
|
||||||
: HardwareService.BRIGHTNESS_MODE_USER);
|
: LightsService.BRIGHTNESS_MODE_USER);
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS,
|
mLightsService.setLightBrightness(LightsService.LIGHT_ID_BUTTONS,
|
||||||
buttonValue, brightnessMode);
|
buttonValue, brightnessMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2111,9 +2111,9 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int brightnessMode = (mUseSoftwareAutoBrightness
|
int brightnessMode = (mUseSoftwareAutoBrightness
|
||||||
? HardwareService.BRIGHTNESS_MODE_SENSOR
|
? LightsService.BRIGHTNESS_MODE_SENSOR
|
||||||
: HardwareService.BRIGHTNESS_MODE_USER);
|
: LightsService.BRIGHTNESS_MODE_USER);
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_KEYBOARD,
|
mLightsService.setLightBrightness(LightsService.LIGHT_ID_KEYBOARD,
|
||||||
keyboardValue, brightnessMode);
|
keyboardValue, brightnessMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2443,12 +2443,12 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
|
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
|
||||||
// Don't let applications turn the screen all the way off
|
// Don't let applications turn the screen all the way off
|
||||||
brightness = Math.max(brightness, Power.BRIGHTNESS_DIM);
|
brightness = Math.max(brightness, Power.BRIGHTNESS_DIM);
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BACKLIGHT, brightness,
|
mLightsService.setLightBrightness(LightsService.LIGHT_ID_BACKLIGHT, brightness,
|
||||||
HardwareService.BRIGHTNESS_MODE_USER);
|
LightsService.BRIGHTNESS_MODE_USER);
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_KEYBOARD,
|
mLightsService.setLightBrightness(LightsService.LIGHT_ID_KEYBOARD,
|
||||||
(mKeyboardVisible ? brightness : 0), HardwareService.BRIGHTNESS_MODE_USER);
|
(mKeyboardVisible ? brightness : 0), LightsService.BRIGHTNESS_MODE_USER);
|
||||||
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS, brightness,
|
mLightsService.setLightBrightness(LightsService.LIGHT_ID_BUTTONS, brightness,
|
||||||
HardwareService.BRIGHTNESS_MODE_USER);
|
LightsService.BRIGHTNESS_MODE_USER);
|
||||||
long identity = Binder.clearCallingIdentity();
|
long identity = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
mBatteryStats.noteScreenBrightness(brightness);
|
mBatteryStats.noteScreenBrightness(brightness);
|
||||||
|
@ -84,7 +84,7 @@ class ServerThread extends Thread {
|
|||||||
int factoryTest = "".equals(factoryTestStr) ? SystemServer.FACTORY_TEST_OFF
|
int factoryTest = "".equals(factoryTestStr) ? SystemServer.FACTORY_TEST_OFF
|
||||||
: Integer.parseInt(factoryTestStr);
|
: Integer.parseInt(factoryTestStr);
|
||||||
|
|
||||||
HardwareService hardware = null;
|
LightsService lights = null;
|
||||||
PowerManagerService power = null;
|
PowerManagerService power = null;
|
||||||
BatteryService battery = null;
|
BatteryService battery = null;
|
||||||
ConnectivityService connectivity = null;
|
ConnectivityService connectivity = null;
|
||||||
@ -141,13 +141,15 @@ class ServerThread extends Thread {
|
|||||||
battery = new BatteryService(context);
|
battery = new BatteryService(context);
|
||||||
ServiceManager.addService("battery", battery);
|
ServiceManager.addService("battery", battery);
|
||||||
|
|
||||||
Log.i(TAG, "Hardware Service");
|
Log.i(TAG, "Lights Service");
|
||||||
hardware = new HardwareService(context);
|
lights = new LightsService(context);
|
||||||
ServiceManager.addService("hardware", hardware);
|
|
||||||
|
Log.i(TAG, "Vibrator Service");
|
||||||
|
ServiceManager.addService("vibrator", new VibratorService(context));
|
||||||
|
|
||||||
// only initialize the power service after we have started the
|
// only initialize the power service after we have started the
|
||||||
// hardware service, content providers and the battery service.
|
// lights service, content providers and the battery service.
|
||||||
power.init(context, hardware, ActivityManagerService.getDefault(), battery);
|
power.init(context, lights, ActivityManagerService.getDefault(), battery);
|
||||||
|
|
||||||
Log.i(TAG, "Alarm Manager");
|
Log.i(TAG, "Alarm Manager");
|
||||||
AlarmManagerService alarm = new AlarmManagerService(context);
|
AlarmManagerService alarm = new AlarmManagerService(context);
|
||||||
@ -253,7 +255,7 @@ class ServerThread extends Thread {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Log.i(TAG, "Notification Manager");
|
Log.i(TAG, "Notification Manager");
|
||||||
notification = new NotificationManagerService(context, statusBar, hardware);
|
notification = new NotificationManagerService(context, statusBar, lights);
|
||||||
ServiceManager.addService(Context.NOTIFICATION_SERVICE, notification);
|
ServiceManager.addService(Context.NOTIFICATION_SERVICE, notification);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Log.e(TAG, "Failure starting Notification Manager", e);
|
Log.e(TAG, "Failure starting Notification Manager", e);
|
||||||
|
@ -16,19 +16,13 @@
|
|||||||
|
|
||||||
package com.android.server;
|
package com.android.server;
|
||||||
|
|
||||||
import com.android.internal.app.IBatteryStats;
|
|
||||||
import com.android.server.am.BatteryStatsService;
|
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Hardware;
|
import android.os.IVibratorService;
|
||||||
import android.os.IHardwareService;
|
|
||||||
import android.os.Message;
|
|
||||||
import android.os.Power;
|
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
@ -40,36 +34,12 @@ import android.util.Log;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
public class HardwareService extends IHardwareService.Stub {
|
public class VibratorService extends IVibratorService.Stub {
|
||||||
private static final String TAG = "HardwareService";
|
private static final String TAG = "VibratorService";
|
||||||
|
|
||||||
static final int LIGHT_ID_BACKLIGHT = 0;
|
|
||||||
static final int LIGHT_ID_KEYBOARD = 1;
|
|
||||||
static final int LIGHT_ID_BUTTONS = 2;
|
|
||||||
static final int LIGHT_ID_BATTERY = 3;
|
|
||||||
static final int LIGHT_ID_NOTIFICATIONS = 4;
|
|
||||||
static final int LIGHT_ID_ATTENTION = 5;
|
|
||||||
|
|
||||||
static final int LIGHT_FLASH_NONE = 0;
|
|
||||||
static final int LIGHT_FLASH_TIMED = 1;
|
|
||||||
static final int LIGHT_FLASH_HARDWARE = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Light brightness is managed by a user setting.
|
|
||||||
*/
|
|
||||||
static final int BRIGHTNESS_MODE_USER = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Light brightness is managed by a light sensor.
|
|
||||||
*/
|
|
||||||
static final int BRIGHTNESS_MODE_SENSOR = 1;
|
|
||||||
|
|
||||||
private final LinkedList<Vibration> mVibrations;
|
private final LinkedList<Vibration> mVibrations;
|
||||||
private Vibration mCurrentVibration;
|
private Vibration mCurrentVibration;
|
||||||
|
|
||||||
private boolean mAttentionLightOn;
|
|
||||||
private boolean mPulsing;
|
|
||||||
|
|
||||||
private class Vibration implements IBinder.DeathRecipient {
|
private class Vibration implements IBinder.DeathRecipient {
|
||||||
private final IBinder mToken;
|
private final IBinder mToken;
|
||||||
private final long mTimeout;
|
private final long mTimeout;
|
||||||
@ -120,13 +90,11 @@ public class HardwareService extends IHardwareService.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HardwareService(Context context) {
|
VibratorService(Context context) {
|
||||||
// Reset the hardware to a default state, in case this is a runtime
|
// Reset the hardware to a default state, in case this is a runtime
|
||||||
// restart instead of a fresh boot.
|
// restart instead of a fresh boot.
|
||||||
vibratorOff();
|
vibratorOff();
|
||||||
|
|
||||||
mNativePointer = init_native();
|
|
||||||
|
|
||||||
mContext = context;
|
mContext = context;
|
||||||
PowerManager pm = (PowerManager)context.getSystemService(
|
PowerManager pm = (PowerManager)context.getSystemService(
|
||||||
Context.POWER_SERVICE);
|
Context.POWER_SERVICE);
|
||||||
@ -135,18 +103,11 @@ public class HardwareService extends IHardwareService.Stub {
|
|||||||
|
|
||||||
mVibrations = new LinkedList<Vibration>();
|
mVibrations = new LinkedList<Vibration>();
|
||||||
|
|
||||||
mBatteryStats = BatteryStatsService.getService();
|
|
||||||
|
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||||
context.registerReceiver(mIntentReceiver, filter);
|
context.registerReceiver(mIntentReceiver, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void finalize() throws Throwable {
|
|
||||||
finalize_native(mNativePointer);
|
|
||||||
super.finalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void vibrate(long milliseconds, IBinder token) {
|
public void vibrate(long milliseconds, IBinder token) {
|
||||||
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.VIBRATE)
|
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.VIBRATE)
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
@ -251,92 +212,6 @@ public class HardwareService extends IHardwareService.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getFlashlightEnabled() {
|
|
||||||
return Hardware.getFlashlightEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFlashlightEnabled(boolean on) {
|
|
||||||
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.FLASHLIGHT)
|
|
||||||
!= PackageManager.PERMISSION_GRANTED &&
|
|
||||||
mContext.checkCallingOrSelfPermission(android.Manifest.permission.HARDWARE_TEST)
|
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
|
||||||
throw new SecurityException("Requires FLASHLIGHT or HARDWARE_TEST permission");
|
|
||||||
}
|
|
||||||
Hardware.setFlashlightEnabled(on);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enableCameraFlash(int milliseconds) {
|
|
||||||
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.CAMERA)
|
|
||||||
!= PackageManager.PERMISSION_GRANTED &&
|
|
||||||
mContext.checkCallingOrSelfPermission(android.Manifest.permission.HARDWARE_TEST)
|
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
|
||||||
throw new SecurityException("Requires CAMERA or HARDWARE_TEST permission");
|
|
||||||
}
|
|
||||||
Hardware.enableCameraFlash(milliseconds);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setLightOff_UNCHECKED(int light) {
|
|
||||||
setLight_native(mNativePointer, light, 0, LIGHT_FLASH_NONE, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setLightBrightness_UNCHECKED(int light, int brightness, int brightnessMode) {
|
|
||||||
int b = brightness & 0x000000ff;
|
|
||||||
b = 0xff000000 | (b << 16) | (b << 8) | b;
|
|
||||||
setLight_native(mNativePointer, light, b, LIGHT_FLASH_NONE, 0, 0, brightnessMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setLightColor_UNCHECKED(int light, int color) {
|
|
||||||
setLight_native(mNativePointer, light, color, LIGHT_FLASH_NONE, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setLightFlashing_UNCHECKED(int light, int color, int mode, int onMS, int offMS) {
|
|
||||||
setLight_native(mNativePointer, light, color, mode, onMS, offMS, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAttentionLight(boolean on, int color) {
|
|
||||||
// Not worthy of a permission. We shouldn't have a flashlight permission.
|
|
||||||
synchronized (this) {
|
|
||||||
mAttentionLightOn = on;
|
|
||||||
mPulsing = false;
|
|
||||||
setLight_native(mNativePointer, LIGHT_ID_ATTENTION, color,
|
|
||||||
LIGHT_FLASH_HARDWARE, on ? 3 : 0, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void pulseBreathingLight() {
|
|
||||||
synchronized (this) {
|
|
||||||
// HACK: Added at the last minute of cupcake -- design this better;
|
|
||||||
// Don't reuse the attention light -- make another one.
|
|
||||||
if (false) {
|
|
||||||
Log.d(TAG, "pulseBreathingLight mAttentionLightOn=" + mAttentionLightOn
|
|
||||||
+ " mPulsing=" + mPulsing);
|
|
||||||
}
|
|
||||||
if (!mAttentionLightOn && !mPulsing) {
|
|
||||||
mPulsing = true;
|
|
||||||
setLight_native(mNativePointer, LIGHT_ID_ATTENTION, 0x00ffffff,
|
|
||||||
LIGHT_FLASH_HARDWARE, 7, 0, 0);
|
|
||||||
mH.sendMessageDelayed(Message.obtain(mH, 1), 3000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Handler mH = new Handler() {
|
|
||||||
@Override
|
|
||||||
public void handleMessage(Message msg) {
|
|
||||||
synchronized (this) {
|
|
||||||
if (false) {
|
|
||||||
Log.d(TAG, "pulse cleanup handler firing mPulsing=" + mPulsing);
|
|
||||||
}
|
|
||||||
if (mPulsing) {
|
|
||||||
mPulsing = false;
|
|
||||||
setLight_native(mNativePointer, LIGHT_ID_ATTENTION,
|
|
||||||
mAttentionLightOn ? 0xffffffff : 0,
|
|
||||||
LIGHT_FLASH_NONE, 0, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private final Runnable mVibrationRunnable = new Runnable() {
|
private final Runnable mVibrationRunnable = new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
synchronized (mVibrations) {
|
synchronized (mVibrations) {
|
||||||
@ -452,7 +327,7 @@ public class HardwareService extends IHardwareService.Stub {
|
|||||||
// duration is saved for delay() at top of loop
|
// duration is saved for delay() at top of loop
|
||||||
duration = pattern[index++];
|
duration = pattern[index++];
|
||||||
if (duration > 0) {
|
if (duration > 0) {
|
||||||
HardwareService.this.vibratorOn(duration);
|
VibratorService.this.vibratorOn(duration);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (repeat < 0) {
|
if (repeat < 0) {
|
||||||
@ -490,21 +365,13 @@ public class HardwareService extends IHardwareService.Stub {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static native int init_native();
|
private Handler mH = new Handler();
|
||||||
private static native void finalize_native(int ptr);
|
|
||||||
|
|
||||||
private static native void setLight_native(int ptr, int light, int color, int mode,
|
|
||||||
int onMS, int offMS, int brightnessMode);
|
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final PowerManager.WakeLock mWakeLock;
|
private final PowerManager.WakeLock mWakeLock;
|
||||||
|
|
||||||
private final IBatteryStats mBatteryStats;
|
|
||||||
|
|
||||||
volatile VibrateThread mThread;
|
volatile VibrateThread mThread;
|
||||||
|
|
||||||
private int mNativePointer;
|
|
||||||
|
|
||||||
native static void vibratorOn(long milliseconds);
|
native static void vibratorOn(long milliseconds);
|
||||||
native static void vibratorOff();
|
native static void vibratorOff();
|
||||||
}
|
}
|
@ -4,10 +4,11 @@ include $(CLEAR_VARS)
|
|||||||
LOCAL_SRC_FILES:= \
|
LOCAL_SRC_FILES:= \
|
||||||
com_android_server_AlarmManagerService.cpp \
|
com_android_server_AlarmManagerService.cpp \
|
||||||
com_android_server_BatteryService.cpp \
|
com_android_server_BatteryService.cpp \
|
||||||
com_android_server_HardwareService.cpp \
|
|
||||||
com_android_server_KeyInputQueue.cpp \
|
com_android_server_KeyInputQueue.cpp \
|
||||||
|
com_android_server_LightsService.cpp \
|
||||||
com_android_server_SensorService.cpp \
|
com_android_server_SensorService.cpp \
|
||||||
com_android_server_SystemServer.cpp \
|
com_android_server_SystemServer.cpp \
|
||||||
|
com_android_server_VibratorService.cpp \
|
||||||
onload.cpp
|
onload.cpp
|
||||||
|
|
||||||
LOCAL_C_INCLUDES += \
|
LOCAL_C_INCLUDES += \
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
/* //device/libs/android_runtime/android_os_Vibrator.cpp
|
/*
|
||||||
**
|
* Copyright (C) 2009 The Android Open Source Project
|
||||||
** Copyright 2006, The Android Open Source Project
|
*
|
||||||
**
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
* you may not use this file except in compliance with the License.
|
||||||
** you may not use this file except in compliance with the License.
|
* You may obtain a copy of the License at
|
||||||
** You may obtain a copy of the License at
|
*
|
||||||
**
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
** http://www.apache.org/licenses/LICENSE-2.0
|
*
|
||||||
**
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
** Unless required by applicable law or agreed to in writing, software
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* See the License for the specific language governing permissions and
|
||||||
** See the License for the specific language governing permissions and
|
* limitations under the License.
|
||||||
** limitations under the License.
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
#define LOG_TAG "HardwareService"
|
#define LOG_TAG "LightsService"
|
||||||
|
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
#include "JNIHelp.h"
|
#include "JNIHelp.h"
|
||||||
@ -23,18 +22,16 @@
|
|||||||
|
|
||||||
#include <utils/misc.h>
|
#include <utils/misc.h>
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
#include <hardware_legacy/vibrator.h>
|
|
||||||
#include <hardware/hardware.h>
|
#include <hardware/hardware.h>
|
||||||
#include <hardware/lights.h>
|
#include <hardware/lights.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
//#include <string.h>
|
|
||||||
|
|
||||||
namespace android
|
namespace android
|
||||||
{
|
{
|
||||||
|
|
||||||
// These values must correspond with the LIGHT_ID constants in
|
// These values must correspond with the LIGHT_ID constants in
|
||||||
// HardwareService.java
|
// LightsService.java
|
||||||
enum {
|
enum {
|
||||||
LIGHT_INDEX_BACKLIGHT = 0,
|
LIGHT_INDEX_BACKLIGHT = 0,
|
||||||
LIGHT_INDEX_KEYBOARD = 1,
|
LIGHT_INDEX_KEYBOARD = 1,
|
||||||
@ -120,29 +117,15 @@ static void setLight_native(JNIEnv *env, jobject clazz, int ptr,
|
|||||||
devices->lights[light]->set_light(devices->lights[light], &state);
|
devices->lights[light]->set_light(devices->lights[light], &state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vibratorOn(JNIEnv *env, jobject clazz, jlong timeout_ms)
|
|
||||||
{
|
|
||||||
// LOGI("vibratorOn\n");
|
|
||||||
vibrator_on(timeout_ms);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void vibratorOff(JNIEnv *env, jobject clazz)
|
|
||||||
{
|
|
||||||
// LOGI("vibratorOff\n");
|
|
||||||
vibrator_off();
|
|
||||||
}
|
|
||||||
|
|
||||||
static JNINativeMethod method_table[] = {
|
static JNINativeMethod method_table[] = {
|
||||||
{ "init_native", "()I", (void*)init_native },
|
{ "init_native", "()I", (void*)init_native },
|
||||||
{ "finalize_native", "(I)V", (void*)finalize_native },
|
{ "finalize_native", "(I)V", (void*)finalize_native },
|
||||||
{ "setLight_native", "(IIIIIII)V", (void*)setLight_native },
|
{ "setLight_native", "(IIIIIII)V", (void*)setLight_native },
|
||||||
{ "vibratorOn", "(J)V", (void*)vibratorOn },
|
|
||||||
{ "vibratorOff", "()V", (void*)vibratorOff }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int register_android_server_HardwareService(JNIEnv *env)
|
int register_android_server_LightsService(JNIEnv *env)
|
||||||
{
|
{
|
||||||
return jniRegisterNativeMethods(env, "com/android/server/HardwareService",
|
return jniRegisterNativeMethods(env, "com/android/server/LightsService",
|
||||||
method_table, NELEM(method_table));
|
method_table, NELEM(method_table));
|
||||||
}
|
}
|
||||||
|
|
55
services/jni/com_android_server_VibratorService.cpp
Normal file
55
services/jni/com_android_server_VibratorService.cpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009 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 "VibratorService"
|
||||||
|
|
||||||
|
#include "jni.h"
|
||||||
|
#include "JNIHelp.h"
|
||||||
|
#include "android_runtime/AndroidRuntime.h"
|
||||||
|
|
||||||
|
#include <utils/misc.h>
|
||||||
|
#include <utils/Log.h>
|
||||||
|
#include <hardware_legacy/vibrator.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
namespace android
|
||||||
|
{
|
||||||
|
|
||||||
|
static void vibratorOn(JNIEnv *env, jobject clazz, jlong timeout_ms)
|
||||||
|
{
|
||||||
|
// LOGI("vibratorOn\n");
|
||||||
|
vibrator_on(timeout_ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vibratorOff(JNIEnv *env, jobject clazz)
|
||||||
|
{
|
||||||
|
// LOGI("vibratorOff\n");
|
||||||
|
vibrator_off();
|
||||||
|
}
|
||||||
|
|
||||||
|
static JNINativeMethod method_table[] = {
|
||||||
|
{ "vibratorOn", "(J)V", (void*)vibratorOn },
|
||||||
|
{ "vibratorOff", "()V", (void*)vibratorOff }
|
||||||
|
};
|
||||||
|
|
||||||
|
int register_android_server_VibratorService(JNIEnv *env)
|
||||||
|
{
|
||||||
|
return jniRegisterNativeMethods(env, "com/android/server/VibratorService",
|
||||||
|
method_table, NELEM(method_table));
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
@ -7,8 +7,9 @@ namespace android {
|
|||||||
int register_android_server_AlarmManagerService(JNIEnv* env);
|
int register_android_server_AlarmManagerService(JNIEnv* env);
|
||||||
int register_android_server_BatteryService(JNIEnv* env);
|
int register_android_server_BatteryService(JNIEnv* env);
|
||||||
int register_android_server_KeyInputQueue(JNIEnv* env);
|
int register_android_server_KeyInputQueue(JNIEnv* env);
|
||||||
int register_android_server_HardwareService(JNIEnv* env);
|
int register_android_server_LightsService(JNIEnv* env);
|
||||||
int register_android_server_SensorService(JNIEnv* env);
|
int register_android_server_SensorService(JNIEnv* env);
|
||||||
|
int register_android_server_VibratorService(JNIEnv* env);
|
||||||
int register_android_server_SystemServer(JNIEnv* env);
|
int register_android_server_SystemServer(JNIEnv* env);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -26,10 +27,11 @@ extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved)
|
|||||||
LOG_ASSERT(env, "Could not retrieve the env!");
|
LOG_ASSERT(env, "Could not retrieve the env!");
|
||||||
|
|
||||||
register_android_server_KeyInputQueue(env);
|
register_android_server_KeyInputQueue(env);
|
||||||
register_android_server_HardwareService(env);
|
register_android_server_LightsService(env);
|
||||||
register_android_server_AlarmManagerService(env);
|
register_android_server_AlarmManagerService(env);
|
||||||
register_android_server_BatteryService(env);
|
register_android_server_BatteryService(env);
|
||||||
register_android_server_SensorService(env);
|
register_android_server_SensorService(env);
|
||||||
|
register_android_server_VibratorService(env);
|
||||||
register_android_server_SystemServer(env);
|
register_android_server_SystemServer(env);
|
||||||
|
|
||||||
return JNI_VERSION_1_4;
|
return JNI_VERSION_1_4;
|
||||||
|
@ -19,7 +19,7 @@ package com.android.framework.permission.tests;
|
|||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IHardwareService;
|
import android.os.IVibratorService;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
@ -28,25 +28,25 @@ import android.test.suitebuilder.annotation.SmallTest;
|
|||||||
* Verify that Hardware apis cannot be called without required permissions.
|
* Verify that Hardware apis cannot be called without required permissions.
|
||||||
*/
|
*/
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class HardwareServicePermissionTest extends TestCase {
|
public class VibratorServicePermissionTest extends TestCase {
|
||||||
|
|
||||||
private IHardwareService mHardwareService;
|
private IVibratorService mVibratorService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
mHardwareService = IHardwareService.Stub.asInterface(
|
mVibratorService = IVibratorService.Stub.asInterface(
|
||||||
ServiceManager.getService("hardware"));
|
ServiceManager.getService("vibrator"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that calling {@link android.os.IHardwareService#vibrate(long)} requires permissions.
|
* Test that calling {@link android.os.IVibratorService#vibrate(long)} requires permissions.
|
||||||
* <p>Tests permission:
|
* <p>Tests permission:
|
||||||
* {@link android.Manifest.permission#VIBRATE}
|
* {@link android.Manifest.permission#VIBRATE}
|
||||||
* @throws RemoteException
|
* @throws RemoteException
|
||||||
*/
|
*/
|
||||||
public void testVibrate() throws RemoteException {
|
public void testVibrate() throws RemoteException {
|
||||||
try {
|
try {
|
||||||
mHardwareService.vibrate(2000, new Binder());
|
mVibratorService.vibrate(2000, new Binder());
|
||||||
fail("vibrate did not throw SecurityException as expected");
|
fail("vibrate did not throw SecurityException as expected");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
// expected
|
// expected
|
||||||
@ -54,7 +54,7 @@ public class HardwareServicePermissionTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that calling {@link android.os.IHardwareService#vibratePattern(long[],
|
* Test that calling {@link android.os.IVibratorService#vibratePattern(long[],
|
||||||
* int, android.os.IBinder)} requires permissions.
|
* int, android.os.IBinder)} requires permissions.
|
||||||
* <p>Tests permission:
|
* <p>Tests permission:
|
||||||
* {@link android.Manifest.permission#VIBRATE}
|
* {@link android.Manifest.permission#VIBRATE}
|
||||||
@ -62,7 +62,7 @@ public class HardwareServicePermissionTest extends TestCase {
|
|||||||
*/
|
*/
|
||||||
public void testVibratePattern() throws RemoteException {
|
public void testVibratePattern() throws RemoteException {
|
||||||
try {
|
try {
|
||||||
mHardwareService.vibratePattern(new long[] {0}, 0, new Binder());
|
mVibratorService.vibratePattern(new long[] {0}, 0, new Binder());
|
||||||
fail("vibratePattern did not throw SecurityException as expected");
|
fail("vibratePattern did not throw SecurityException as expected");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
// expected
|
// expected
|
||||||
@ -70,51 +70,17 @@ public class HardwareServicePermissionTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that calling {@link android.os.IHardwareService#cancelVibrate()} requires permissions.
|
* Test that calling {@link android.os.IVibratorService#cancelVibrate()} requires permissions.
|
||||||
* <p>Tests permission:
|
* <p>Tests permission:
|
||||||
* {@link android.Manifest.permission#VIBRATE}
|
* {@link android.Manifest.permission#VIBRATE}
|
||||||
* @throws RemoteException
|
* @throws RemoteException
|
||||||
*/
|
*/
|
||||||
public void testCancelVibrate() throws RemoteException {
|
public void testCancelVibrate() throws RemoteException {
|
||||||
try {
|
try {
|
||||||
mHardwareService.cancelVibrate(new Binder());
|
mVibratorService.cancelVibrate(new Binder());
|
||||||
fail("cancelVibrate did not throw SecurityException as expected");
|
fail("cancelVibrate did not throw SecurityException as expected");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test that calling {@link android.os.IHardwareService#setFlashlightEnabled(boolean)}
|
|
||||||
* requires permissions.
|
|
||||||
* <p>Tests permissions:
|
|
||||||
* {@link android.Manifest.permission#HARDWARE_TEST}
|
|
||||||
* {@link android.Manifest.permission#FLASHLIGHT}
|
|
||||||
* @throws RemoteException
|
|
||||||
*/
|
|
||||||
public void testSetFlashlightEnabled() throws RemoteException {
|
|
||||||
try {
|
|
||||||
mHardwareService.setFlashlightEnabled(true);
|
|
||||||
fail("setFlashlightEnabled did not throw SecurityException as expected");
|
|
||||||
} catch (SecurityException e) {
|
|
||||||
// expected
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test that calling {@link android.os.IHardwareService#enableCameraFlash(int)} requires
|
|
||||||
* permissions.
|
|
||||||
* <p>Tests permission:
|
|
||||||
* {@link android.Manifest.permission#HARDWARE_TEST}
|
|
||||||
* {@link android.Manifest.permission#CAMERA}
|
|
||||||
* @throws RemoteException
|
|
||||||
*/
|
|
||||||
public void testEnableCameraFlash() throws RemoteException {
|
|
||||||
try {
|
|
||||||
mHardwareService.enableCameraFlash(100);
|
|
||||||
fail("enableCameraFlash did not throw SecurityException as expected");
|
|
||||||
} catch (SecurityException e) {
|
|
||||||
// expected
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user