Methods Summary |
---|
public void | cancelVibrate()
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.VIBRATE,
"cancelVibrate");
// so wakelock calls will succeed
long identity = Binder.clearCallingIdentity();
try {
doCancelVibrate();
}
finally {
Binder.restoreCallingIdentity(identity);
}
|
private void | doCancelVibrate()
synchronized (this) {
if (mThread != null) {
synchronized (mThread) {
mThread.mDone = true;
mThread.notify();
}
mThread = null;
}
vibratorOff();
}
|
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);
|
protected void | finalize()
finalize_native(mNativePointer);
super.finalize();
|
private static native void | finalize_native(int ptr)
|
public boolean | getFlashlightEnabled()
return Hardware.getFlashlightEnabled();
|
private static native int | init_native()
|
private boolean | isAll0(long[] pattern)
int N = pattern.length;
for (int i = 0; i < N; i++) {
if (pattern[i] != 0) {
return false;
}
}
return true;
|
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, 0xff101010,
LIGHT_FLASH_NONE, 0, 0);
mH.sendMessageDelayed(Message.obtain(mH, 1), 3000);
}
}
|
public void | setAttentionLight(boolean on)
// Not worthy of a permission. We shouldn't have a flashlight permission.
synchronized (this) {
mAttentionLightOn = on;
mPulsing = false;
setLight_native(mNativePointer, LIGHT_ID_ATTENTION, on ? 0xffffffff : 0,
LIGHT_FLASH_NONE, 0, 0);
}
|
public void | setBacklights(int brightness)
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.HARDWARE_TEST)
!= PackageManager.PERMISSION_GRANTED) {
throw new SecurityException("Requires HARDWARE_TEST permission");
}
// Don't let applications turn the screen all the way off
brightness = Math.max(brightness, Power.BRIGHTNESS_DIM);
setLightBrightness_UNCHECKED(LIGHT_ID_BACKLIGHT, brightness);
setLightBrightness_UNCHECKED(LIGHT_ID_KEYBOARD, brightness);
setLightBrightness_UNCHECKED(LIGHT_ID_BUTTONS, brightness);
long identity = Binder.clearCallingIdentity();
try {
mBatteryStats.noteScreenBrightness(brightness);
} catch (RemoteException e) {
Log.w(TAG, "RemoteException calling noteScreenBrightness on BatteryStatsService", e);
} finally {
Binder.restoreCallingIdentity(identity);
}
|
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);
|
void | setLightBrightness_UNCHECKED(int light, int brightness)
int b = brightness & 0x000000ff;
b = 0xff000000 | (b << 16) | (b << 8) | b;
setLight_native(mNativePointer, light, b, LIGHT_FLASH_NONE, 0, 0);
|
void | setLightColor_UNCHECKED(int light, int color)
setLight_native(mNativePointer, light, color, LIGHT_FLASH_NONE, 0, 0);
|
void | setLightFlashing_UNCHECKED(int light, int color, int mode, int onMS, int offMS)
setLight_native(mNativePointer, light, color, mode, onMS, offMS);
|
void | setLightOff_UNCHECKED(int light)
setLight_native(mNativePointer, light, 0, LIGHT_FLASH_NONE, 0, 0);
|
private static native void | setLight_native(int ptr, int light, int color, int mode, int onMS, int offMS)
|
public void | vibrate(long milliseconds)
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.VIBRATE)
!= PackageManager.PERMISSION_GRANTED) {
throw new SecurityException("Requires VIBRATE permission");
}
doCancelVibrate();
vibratorOn(milliseconds);
|
public void | vibratePattern(long[] pattern, int repeat, android.os.IBinder token)
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.VIBRATE)
!= PackageManager.PERMISSION_GRANTED) {
throw new SecurityException("Requires VIBRATE permission");
}
// so wakelock calls will succeed
long identity = Binder.clearCallingIdentity();
try {
if (false) {
String s = "";
int N = pattern.length;
for (int i=0; i<N; i++) {
s += " " + pattern[i];
}
Log.i(TAG, "vibrating with pattern: " + s);
}
// we're running in the server so we can't fail
if (pattern == null || pattern.length == 0
|| isAll0(pattern)
|| repeat >= pattern.length || token == null) {
return;
}
synchronized (this) {
Death death = new Death(token);
try {
token.linkToDeath(death, 0);
} catch (RemoteException e) {
return;
}
Thread oldThread = mThread;
if (oldThread != null) {
// stop the old one
synchronized (mThread) {
mThread.mDone = true;
mThread.notify();
}
}
if (mDeath != null) {
mToken.unlinkToDeath(mDeath, 0);
}
mDeath = death;
mToken = token;
// start the new thread
mThread = new VibrateThread(pattern, repeat);
mThread.start();
}
}
finally {
Binder.restoreCallingIdentity(identity);
}
|
static native void | vibratorOff()
|
static native void | vibratorOn(long milliseconds)
|