Loading api/current.xml +11 −0 Original line number Diff line number Diff line Loading @@ -142511,6 +142511,17 @@ visibility="public" > </method> <method name="hasVibrator" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="vibrate" return="void" abstract="false" core/java/android/os/IVibratorService.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.os; /** {@hide} */ interface IVibratorService { boolean hasVibrator(); void vibrate(long milliseconds, IBinder token); void vibratePattern(in long[] pattern, int repeat, IBinder token); void cancelVibrate(IBinder token); Loading core/java/android/os/Vibrator.java +16 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,22 @@ public class Vibrator ServiceManager.getService("vibrator")); } /** * Check whether the hardware has a vibrator. Returns true if a vibrator * exists, else false. */ public boolean hasVibrator() { if (mService == null) { Log.w(TAG, "Failed to vibrate; no vibrator service."); return false; } try { return mService.hasVibrator(); } catch (RemoteException e) { } return false; } /** * Turn the vibrator on. * Loading services/java/com/android/server/VibratorService.java +5 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,10 @@ public class VibratorService extends IVibratorService.Stub { context.registerReceiver(mIntentReceiver, filter); } public boolean hasVibrator() { return vibratorExists(); } public void vibrate(long milliseconds, IBinder token) { if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.VIBRATE) != PackageManager.PERMISSION_GRANTED) { Loading Loading @@ -380,6 +384,7 @@ public class VibratorService extends IVibratorService.Stub { volatile VibrateThread mThread; native static boolean vibratorExists(); native static void vibratorOn(long milliseconds); native static void vibratorOff(); } services/jni/com_android_server_VibratorService.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,11 @@ namespace android { static jboolean vibratorExists(JNIEnv *env, jobject clazz) { return vibrator_exists() > 0 ? JNI_TRUE : JNI_FALSE; } static void vibratorOn(JNIEnv *env, jobject clazz, jlong timeout_ms) { // LOGI("vibratorOn\n"); Loading @@ -42,6 +47,7 @@ static void vibratorOff(JNIEnv *env, jobject clazz) } static JNINativeMethod method_table[] = { { "vibratorExists", "()Z", (void*)vibratorExists }, { "vibratorOn", "(J)V", (void*)vibratorOn }, { "vibratorOff", "()V", (void*)vibratorOff } }; Loading Loading
api/current.xml +11 −0 Original line number Diff line number Diff line Loading @@ -142511,6 +142511,17 @@ visibility="public" > </method> <method name="hasVibrator" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="vibrate" return="void" abstract="false"
core/java/android/os/IVibratorService.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.os; /** {@hide} */ interface IVibratorService { boolean hasVibrator(); void vibrate(long milliseconds, IBinder token); void vibratePattern(in long[] pattern, int repeat, IBinder token); void cancelVibrate(IBinder token); Loading
core/java/android/os/Vibrator.java +16 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,22 @@ public class Vibrator ServiceManager.getService("vibrator")); } /** * Check whether the hardware has a vibrator. Returns true if a vibrator * exists, else false. */ public boolean hasVibrator() { if (mService == null) { Log.w(TAG, "Failed to vibrate; no vibrator service."); return false; } try { return mService.hasVibrator(); } catch (RemoteException e) { } return false; } /** * Turn the vibrator on. * Loading
services/java/com/android/server/VibratorService.java +5 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,10 @@ public class VibratorService extends IVibratorService.Stub { context.registerReceiver(mIntentReceiver, filter); } public boolean hasVibrator() { return vibratorExists(); } public void vibrate(long milliseconds, IBinder token) { if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.VIBRATE) != PackageManager.PERMISSION_GRANTED) { Loading Loading @@ -380,6 +384,7 @@ public class VibratorService extends IVibratorService.Stub { volatile VibrateThread mThread; native static boolean vibratorExists(); native static void vibratorOn(long milliseconds); native static void vibratorOff(); }
services/jni/com_android_server_VibratorService.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,11 @@ namespace android { static jboolean vibratorExists(JNIEnv *env, jobject clazz) { return vibrator_exists() > 0 ? JNI_TRUE : JNI_FALSE; } static void vibratorOn(JNIEnv *env, jobject clazz, jlong timeout_ms) { // LOGI("vibratorOn\n"); Loading @@ -42,6 +47,7 @@ static void vibratorOff(JNIEnv *env, jobject clazz) } static JNINativeMethod method_table[] = { { "vibratorExists", "()Z", (void*)vibratorExists }, { "vibratorOn", "(J)V", (void*)vibratorOn }, { "vibratorOff", "()V", (void*)vibratorOff } }; Loading