Loading api/16.txt +5 −5 Original line number Diff line number Diff line Loading @@ -15190,11 +15190,11 @@ package android.os { method public abstract void released(); } public class Vibrator { method public void cancel(); method public boolean hasVibrator(); method public void vibrate(long); method public void vibrate(long[], int); public abstract class Vibrator { method public abstract void cancel(); method public abstract boolean hasVibrator(); method public abstract void vibrate(long); method public abstract void vibrate(long[], int); } public class WorkSource implements android.os.Parcelable { api/current.txt +5 −5 Original line number Diff line number Diff line Loading @@ -15514,11 +15514,11 @@ package android.os { ctor public TransactionTooLargeException(); } public class Vibrator { method public void cancel(); method public boolean hasVibrator(); method public void vibrate(long); method public void vibrate(long[], int); public abstract class Vibrator { method public abstract void cancel(); method public abstract boolean hasVibrator(); method public abstract void vibrate(long); method public abstract void vibrate(long[], int); } public class WorkSource implements android.os.Parcelable { core/java/android/app/ContextImpl.java +2 −2 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserId; import android.os.Vibrator; import android.os.SystemVibrator; import android.os.storage.StorageManager; import android.telephony.TelephonyManager; import android.content.ClipboardManager; Loading Loading @@ -455,7 +455,7 @@ class ContextImpl extends Context { registerService(VIBRATOR_SERVICE, new ServiceFetcher() { public Object createService(ContextImpl ctx) { return new Vibrator(); return new SystemVibrator(); }}); registerService(WALLPAPER_SERVICE, WALLPAPER_FETCHER); Loading core/java/android/os/SystemVibrator.java 0 → 100644 +94 −0 Original line number Diff line number Diff line /* * Copyright (C) 2012 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; import android.util.Log; /** * Vibrator implementation that controls the main system vibrator. * * @hide */ public class SystemVibrator extends Vibrator { private static final String TAG = "Vibrator"; private final IVibratorService mService; private final Binder mToken = new Binder(); public SystemVibrator() { mService = IVibratorService.Stub.asInterface( ServiceManager.getService("vibrator")); } @Override 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; } @Override public void vibrate(long milliseconds) { if (mService == null) { Log.w(TAG, "Failed to vibrate; no vibrator service."); return; } try { mService.vibrate(milliseconds, mToken); } catch (RemoteException e) { Log.w(TAG, "Failed to vibrate.", e); } } @Override public void vibrate(long[] pattern, int repeat) { if (mService == null) { Log.w(TAG, "Failed to vibrate; no vibrator service."); return; } // catch this here because the server will do nothing. pattern may // not be null, let that be checked, because the server will drop it // anyway if (repeat < pattern.length) { try { mService.vibratePattern(pattern, repeat, mToken); } catch (RemoteException e) { Log.w(TAG, "Failed to vibrate.", e); } } else { throw new ArrayIndexOutOfBoundsException(); } } @Override public void cancel() { if (mService == null) { return; } try { mService.cancelVibrate(mToken); } catch (RemoteException e) { Log.w(TAG, "Failed to cancel vibration.", e); } } } core/java/android/os/Vibrator.java +17 −69 Original line number Diff line number Diff line Loading @@ -16,61 +16,37 @@ package android.os; import android.util.Log; import android.content.Context; /** * Class that operates the vibrator on the device. * <p> * If your process exits, any vibration you started with will stop. * </p> * * To obtain an instance of the system vibrator, call * {@link Context#getSystemService} with {@link Context#VIBRATOR_SERVICE} as argument. */ public class Vibrator { private static final String TAG = "Vibrator"; IVibratorService mService; private final Binder mToken = new Binder(); /** @hide */ public Vibrator() { mService = IVibratorService.Stub.asInterface( ServiceManager.getService("vibrator")); public abstract class Vibrator { /** * @hide to prevent subclassing from outside of the framework */ public Vibrator() { } /** * Check whether the hardware has a vibrator. Returns true if a vibrator * exists, else false. * Check whether the hardware has a vibrator. * * @return True if the hardware has a vibrator, 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; } public abstract boolean hasVibrator(); /** * Turn the vibrator on. * Vibrate constantly for the specified period of time. * * @param milliseconds The number of milliseconds to vibrate. */ public void vibrate(long milliseconds) { if (mService == null) { Log.w(TAG, "Failed to vibrate; no vibrator service."); return; } try { mService.vibrate(milliseconds, mToken); } catch (RemoteException e) { Log.w(TAG, "Failed to vibrate.", e); } } public abstract void vibrate(long milliseconds); /** * Vibrate with a given pattern. Loading @@ -90,38 +66,10 @@ public class Vibrator * @param repeat the index into pattern at which to repeat, or -1 if * you don't want to repeat. */ public void vibrate(long[] pattern, int repeat) { if (mService == null) { Log.w(TAG, "Failed to vibrate; no vibrator service."); return; } // catch this here because the server will do nothing. pattern may // not be null, let that be checked, because the server will drop it // anyway if (repeat < pattern.length) { try { mService.vibratePattern(pattern, repeat, mToken); } catch (RemoteException e) { Log.w(TAG, "Failed to vibrate.", e); } } else { throw new ArrayIndexOutOfBoundsException(); } } public abstract void vibrate(long[] pattern, int repeat); /** * Turn the vibrator off. */ public void cancel() { if (mService == null) { return; } try { mService.cancelVibrate(mToken); } catch (RemoteException e) { Log.w(TAG, "Failed to cancel vibration.", e); } } public abstract void cancel(); } Loading
api/16.txt +5 −5 Original line number Diff line number Diff line Loading @@ -15190,11 +15190,11 @@ package android.os { method public abstract void released(); } public class Vibrator { method public void cancel(); method public boolean hasVibrator(); method public void vibrate(long); method public void vibrate(long[], int); public abstract class Vibrator { method public abstract void cancel(); method public abstract boolean hasVibrator(); method public abstract void vibrate(long); method public abstract void vibrate(long[], int); } public class WorkSource implements android.os.Parcelable {
api/current.txt +5 −5 Original line number Diff line number Diff line Loading @@ -15514,11 +15514,11 @@ package android.os { ctor public TransactionTooLargeException(); } public class Vibrator { method public void cancel(); method public boolean hasVibrator(); method public void vibrate(long); method public void vibrate(long[], int); public abstract class Vibrator { method public abstract void cancel(); method public abstract boolean hasVibrator(); method public abstract void vibrate(long); method public abstract void vibrate(long[], int); } public class WorkSource implements android.os.Parcelable {
core/java/android/app/ContextImpl.java +2 −2 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserId; import android.os.Vibrator; import android.os.SystemVibrator; import android.os.storage.StorageManager; import android.telephony.TelephonyManager; import android.content.ClipboardManager; Loading Loading @@ -455,7 +455,7 @@ class ContextImpl extends Context { registerService(VIBRATOR_SERVICE, new ServiceFetcher() { public Object createService(ContextImpl ctx) { return new Vibrator(); return new SystemVibrator(); }}); registerService(WALLPAPER_SERVICE, WALLPAPER_FETCHER); Loading
core/java/android/os/SystemVibrator.java 0 → 100644 +94 −0 Original line number Diff line number Diff line /* * Copyright (C) 2012 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; import android.util.Log; /** * Vibrator implementation that controls the main system vibrator. * * @hide */ public class SystemVibrator extends Vibrator { private static final String TAG = "Vibrator"; private final IVibratorService mService; private final Binder mToken = new Binder(); public SystemVibrator() { mService = IVibratorService.Stub.asInterface( ServiceManager.getService("vibrator")); } @Override 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; } @Override public void vibrate(long milliseconds) { if (mService == null) { Log.w(TAG, "Failed to vibrate; no vibrator service."); return; } try { mService.vibrate(milliseconds, mToken); } catch (RemoteException e) { Log.w(TAG, "Failed to vibrate.", e); } } @Override public void vibrate(long[] pattern, int repeat) { if (mService == null) { Log.w(TAG, "Failed to vibrate; no vibrator service."); return; } // catch this here because the server will do nothing. pattern may // not be null, let that be checked, because the server will drop it // anyway if (repeat < pattern.length) { try { mService.vibratePattern(pattern, repeat, mToken); } catch (RemoteException e) { Log.w(TAG, "Failed to vibrate.", e); } } else { throw new ArrayIndexOutOfBoundsException(); } } @Override public void cancel() { if (mService == null) { return; } try { mService.cancelVibrate(mToken); } catch (RemoteException e) { Log.w(TAG, "Failed to cancel vibration.", e); } } }
core/java/android/os/Vibrator.java +17 −69 Original line number Diff line number Diff line Loading @@ -16,61 +16,37 @@ package android.os; import android.util.Log; import android.content.Context; /** * Class that operates the vibrator on the device. * <p> * If your process exits, any vibration you started with will stop. * </p> * * To obtain an instance of the system vibrator, call * {@link Context#getSystemService} with {@link Context#VIBRATOR_SERVICE} as argument. */ public class Vibrator { private static final String TAG = "Vibrator"; IVibratorService mService; private final Binder mToken = new Binder(); /** @hide */ public Vibrator() { mService = IVibratorService.Stub.asInterface( ServiceManager.getService("vibrator")); public abstract class Vibrator { /** * @hide to prevent subclassing from outside of the framework */ public Vibrator() { } /** * Check whether the hardware has a vibrator. Returns true if a vibrator * exists, else false. * Check whether the hardware has a vibrator. * * @return True if the hardware has a vibrator, 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; } public abstract boolean hasVibrator(); /** * Turn the vibrator on. * Vibrate constantly for the specified period of time. * * @param milliseconds The number of milliseconds to vibrate. */ public void vibrate(long milliseconds) { if (mService == null) { Log.w(TAG, "Failed to vibrate; no vibrator service."); return; } try { mService.vibrate(milliseconds, mToken); } catch (RemoteException e) { Log.w(TAG, "Failed to vibrate.", e); } } public abstract void vibrate(long milliseconds); /** * Vibrate with a given pattern. Loading @@ -90,38 +66,10 @@ public class Vibrator * @param repeat the index into pattern at which to repeat, or -1 if * you don't want to repeat. */ public void vibrate(long[] pattern, int repeat) { if (mService == null) { Log.w(TAG, "Failed to vibrate; no vibrator service."); return; } // catch this here because the server will do nothing. pattern may // not be null, let that be checked, because the server will drop it // anyway if (repeat < pattern.length) { try { mService.vibratePattern(pattern, repeat, mToken); } catch (RemoteException e) { Log.w(TAG, "Failed to vibrate.", e); } } else { throw new ArrayIndexOutOfBoundsException(); } } public abstract void vibrate(long[] pattern, int repeat); /** * Turn the vibrator off. */ public void cancel() { if (mService == null) { return; } try { mService.cancelVibrate(mToken); } catch (RemoteException e) { Log.w(TAG, "Failed to cancel vibration.", e); } } public abstract void cancel(); }