Use deviceId instead of displayId for Vibration.
Context#getDeviceId is the correct way of identifying virtual devices
instead of relying on an associated display id.
Do not blanket ignore all vibration requests from UIDs that run on
virtual devices as these apps have no way of vibrating the default
device; they can now request default device context and trigger the
default device vibration.
Not handling ExternalVibration here. ExternalVibration passes invalid
deviceId, which tells VibrationSettings to apply the existing fallback
UID-based logic.
Bug: 249785241
Fix: 250568048
Test: presubmit
Test: manual with streamed app that triggers vibration
Change-Id: Ie0f6d96faa8480bfd8427680ff05bc60faad02e8
diff --git a/core/java/android/os/IVibratorManagerService.aidl b/core/java/android/os/IVibratorManagerService.aidl
index f30dd20..0f27569 100644
--- a/core/java/android/os/IVibratorManagerService.aidl
+++ b/core/java/android/os/IVibratorManagerService.aidl
@@ -33,13 +33,13 @@
boolean unregisterVibratorStateListener(int vibratorId, in IVibratorStateListener listener);
boolean setAlwaysOnEffect(int uid, String opPkg, int alwaysOnId,
in CombinedVibration vibration, in VibrationAttributes attributes);
- void vibrate(int uid, int displayId, String opPkg, in CombinedVibration vibration,
+ void vibrate(int uid, int deviceId, String opPkg, in CombinedVibration vibration,
in VibrationAttributes attributes, String reason, IBinder token);
void cancelVibrate(int usageFilter, IBinder token);
// Async oneway APIs.
// There is no order guarantee with respect to the two-way APIs above like
// vibrate/isVibrating/cancel.
- oneway void performHapticFeedback(int uid, int displayId, String opPkg, int constant,
+ oneway void performHapticFeedback(int uid, int deviceId, String opPkg, int constant,
boolean always, String reason, IBinder token);
}
diff --git a/core/java/android/os/SystemVibratorManager.java b/core/java/android/os/SystemVibratorManager.java
index ee90834..bc85412e 100644
--- a/core/java/android/os/SystemVibratorManager.java
+++ b/core/java/android/os/SystemVibratorManager.java
@@ -137,8 +137,8 @@
return;
}
try {
- mService.vibrate(uid, mContext.getAssociatedDisplayId(), opPkg, effect, attributes,
- reason, mToken);
+ mService.vibrate(uid, mContext.getDeviceId(), opPkg, effect, attributes, reason,
+ mToken);
} catch (RemoteException e) {
Log.w(TAG, "Failed to vibrate.", e);
}
@@ -152,8 +152,8 @@
}
try {
mService.performHapticFeedback(
- Process.myUid(), mContext.getAssociatedDisplayId(), mPackageName, constant,
- always, reason, mToken);
+ Process.myUid(), mContext.getDeviceId(), mPackageName, constant, always, reason,
+ mToken);
} catch (RemoteException e) {
Log.w(TAG, "Failed to perform haptic feedback.", e);
}
diff --git a/services/companion/java/com/android/server/companion/virtual/VirtualDeviceManagerService.java b/services/companion/java/com/android/server/companion/virtual/VirtualDeviceManagerService.java
index 92af68b..85b3c9a 100644
--- a/services/companion/java/com/android/server/companion/virtual/VirtualDeviceManagerService.java
+++ b/services/companion/java/com/android/server/companion/virtual/VirtualDeviceManagerService.java
@@ -441,10 +441,8 @@
+ " is not the owner of the supplied VirtualDevice");
}
- int displayId = virtualDeviceImpl.createVirtualDisplay(virtualDisplayConfig, callback,
- packageName);
- mLocalService.onVirtualDisplayCreated(displayId);
- return displayId;
+ return virtualDeviceImpl.createVirtualDisplay(
+ virtualDisplayConfig, callback, packageName);
}
@Override // Binder call
@@ -625,9 +623,6 @@
private final class LocalService extends VirtualDeviceManagerInternal {
@GuardedBy("mVirtualDeviceManagerLock")
- private final ArrayList<VirtualDisplayListener>
- mVirtualDisplayListeners = new ArrayList<>();
- @GuardedBy("mVirtualDeviceManagerLock")
private final ArrayList<AppsOnVirtualDeviceListener>
mAppsOnVirtualDeviceListeners = new ArrayList<>();
@GuardedBy("mVirtualDeviceManagerLock")
@@ -665,35 +660,15 @@
}
@Override
- public void onVirtualDisplayCreated(int displayId) {
- final VirtualDisplayListener[] listeners;
- synchronized (mVirtualDeviceManagerLock) {
- listeners = mVirtualDisplayListeners.toArray(new VirtualDisplayListener[0]);
- }
- mHandler.post(() -> {
- for (VirtualDisplayListener listener : listeners) {
- listener.onVirtualDisplayCreated(displayId);
- }
- });
- }
-
- @Override
public void onVirtualDisplayRemoved(IVirtualDevice virtualDevice, int displayId) {
- final VirtualDisplayListener[] listeners;
VirtualDeviceImpl virtualDeviceImpl;
synchronized (mVirtualDeviceManagerLock) {
- listeners = mVirtualDisplayListeners.toArray(new VirtualDisplayListener[0]);
virtualDeviceImpl = mVirtualDevices.get(
((VirtualDeviceImpl) virtualDevice).getDeviceId());
}
if (virtualDeviceImpl != null) {
virtualDeviceImpl.onVirtualDisplayRemoved(displayId);
}
- mHandler.post(() -> {
- for (VirtualDisplayListener listener : listeners) {
- listener.onVirtualDisplayRemoved(displayId);
- }
- });
}
@Override
@@ -799,22 +774,6 @@
}
@Override
- public void registerVirtualDisplayListener(
- @NonNull VirtualDisplayListener listener) {
- synchronized (mVirtualDeviceManagerLock) {
- mVirtualDisplayListeners.add(listener);
- }
- }
-
- @Override
- public void unregisterVirtualDisplayListener(
- @NonNull VirtualDisplayListener listener) {
- synchronized (mVirtualDeviceManagerLock) {
- mVirtualDisplayListeners.remove(listener);
- }
- }
-
- @Override
public void registerAppsOnVirtualDeviceListener(
@NonNull AppsOnVirtualDeviceListener listener) {
synchronized (mVirtualDeviceManagerLock) {
diff --git a/services/core/java/com/android/server/companion/virtual/VirtualDeviceManagerInternal.java b/services/core/java/com/android/server/companion/virtual/VirtualDeviceManagerInternal.java
index 283353dd..0d7f778 100644
--- a/services/core/java/com/android/server/companion/virtual/VirtualDeviceManagerInternal.java
+++ b/services/core/java/com/android/server/companion/virtual/VirtualDeviceManagerInternal.java
@@ -32,29 +32,12 @@
*/
public abstract class VirtualDeviceManagerInternal {
- /** Interface to listen to the creation and destruction of virtual displays. */
- public interface VirtualDisplayListener {
- /** Notifies that a virtual display was created. */
- void onVirtualDisplayCreated(int displayId);
-
- /** Notifies that a virtual display was removed. */
- void onVirtualDisplayRemoved(int displayId);
- }
-
/** Interface to listen to the changes on the list of app UIDs running on any virtual device. */
public interface AppsOnVirtualDeviceListener {
/** Notifies that running apps on any virtual device has changed */
void onAppsOnAnyVirtualDeviceChanged(Set<Integer> allRunningUids);
}
- /** Register a listener for the creation and destruction of virtual displays. */
- public abstract void registerVirtualDisplayListener(
- @NonNull VirtualDisplayListener listener);
-
- /** Unregister a listener for the creation and destruction of virtual displays. */
- public abstract void unregisterVirtualDisplayListener(
- @NonNull VirtualDisplayListener listener);
-
/** Register a listener for changes of running app UIDs on any virtual device. */
public abstract void registerAppsOnVirtualDeviceListener(
@NonNull AppsOnVirtualDeviceListener listener);
@@ -104,13 +87,6 @@
public abstract @NonNull ArraySet<Integer> getDeviceIdsForUid(int uid);
/**
- * Notifies that a virtual display is created.
- *
- * @param displayId The display id of the created virtual display.
- */
- public abstract void onVirtualDisplayCreated(int displayId);
-
- /**
* Notifies that a virtual display is removed.
*
* @param virtualDevice The virtual device where the virtual display located.
diff --git a/services/core/java/com/android/server/vibrator/Vibration.java b/services/core/java/com/android/server/vibrator/Vibration.java
index fed6e7e..b2e808a 100644
--- a/services/core/java/com/android/server/vibrator/Vibration.java
+++ b/services/core/java/com/android/server/vibrator/Vibration.java
@@ -117,16 +117,16 @@
static final class CallerInfo {
public final VibrationAttributes attrs;
public final int uid;
- public final int displayId;
+ public final int deviceId;
public final String opPkg;
public final String reason;
- CallerInfo(@NonNull VibrationAttributes attrs, int uid, int displayId,
- String opPkg, String reason) {
+ CallerInfo(@NonNull VibrationAttributes attrs, int uid, int deviceId, String opPkg,
+ String reason) {
Objects.requireNonNull(attrs);
this.attrs = attrs;
this.uid = uid;
- this.displayId = displayId;
+ this.deviceId = deviceId;
this.opPkg = opPkg;
this.reason = reason;
}
@@ -138,14 +138,14 @@
CallerInfo that = (CallerInfo) o;
return Objects.equals(attrs, that.attrs)
&& uid == that.uid
- && displayId == that.displayId
+ && deviceId == that.deviceId
&& Objects.equals(opPkg, that.opPkg)
&& Objects.equals(reason, that.reason);
}
@Override
public int hashCode() {
- return Objects.hash(attrs, uid, displayId, opPkg, reason);
+ return Objects.hash(attrs, uid, deviceId, opPkg, reason);
}
@Override
@@ -153,7 +153,7 @@
return "CallerInfo{"
+ " uid=" + uid
+ ", opPkg=" + opPkg
- + ", displayId=" + displayId
+ + ", deviceId=" + deviceId
+ ", attrs=" + attrs
+ ", reason=" + reason
+ '}';
@@ -267,8 +267,8 @@
mStartTime == 0 ? "" : DEBUG_TIME_FORMAT.format(new Date(mStartTime)),
mEndTime == 0 ? "" : DEBUG_TIME_FORMAT.format(new Date(mEndTime)));
String callerInfoStr = String.format(Locale.ROOT,
- " | %s (uid=%d, displayId=%d) | usage: %s (audio=%s) | flags: %s | reason: %s",
- mCallerInfo.opPkg, mCallerInfo.uid, mCallerInfo.displayId,
+ " | %s (uid=%d, deviceId=%d) | usage: %s (audio=%s) | flags: %s | reason: %s",
+ mCallerInfo.opPkg, mCallerInfo.uid, mCallerInfo.deviceId,
mCallerInfo.attrs.usageToString(),
AudioAttributes.usageToString(mCallerInfo.attrs.getAudioUsage()),
Long.toBinaryString(mCallerInfo.attrs.getFlags()),
diff --git a/services/core/java/com/android/server/vibrator/VibrationSettings.java b/services/core/java/com/android/server/vibrator/VibrationSettings.java
index 7f55836..839c207 100644
--- a/services/core/java/com/android/server/vibrator/VibrationSettings.java
+++ b/services/core/java/com/android/server/vibrator/VibrationSettings.java
@@ -61,7 +61,6 @@
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.util.proto.ProtoOutputStream;
-import android.view.Display;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
@@ -166,7 +165,6 @@
final MyUidObserver mUidObserver;
@VisibleForTesting
final SettingsBroadcastReceiver mSettingChangeReceiver;
- final VirtualDeviceListener mVirtualDeviceListener;
@GuardedBy("mLock")
private final List<OnVibratorSettingsChanged> mListeners = new ArrayList<>();
@@ -180,6 +178,8 @@
@GuardedBy("mLock")
@Nullable
private PowerManagerInternal mPowerManagerInternal;
+ @Nullable
+ private VirtualDeviceManagerInternal mVirtualDeviceManagerInternal;
@GuardedBy("mLock")
private boolean mVibrateInputDevices;
@@ -207,8 +207,6 @@
mSettingObserver = new SettingsContentObserver(handler);
mUidObserver = new MyUidObserver();
mSettingChangeReceiver = new SettingsBroadcastReceiver();
- mVirtualDeviceListener = new VirtualDeviceListener();
-
mSystemUiPackage = LocalServices.getService(PackageManagerInternal.class)
.getSystemUiServiceComponent().getPackageName();
@@ -272,13 +270,6 @@
}
});
- VirtualDeviceManagerInternal vdm = LocalServices.getService(
- VirtualDeviceManagerInternal.class);
- if (vdm != null) {
- vdm.registerVirtualDisplayListener(mVirtualDeviceListener);
- vdm.registerAppsOnVirtualDeviceListener(mVirtualDeviceListener);
- }
-
registerSettingsChangeReceiver(USER_SWITCHED_INTENT_FILTER);
registerSettingsChangeReceiver(INTERNAL_RINGER_MODE_CHANGED_INTENT_FILTER);
@@ -414,8 +405,14 @@
&& !BACKGROUND_PROCESS_USAGE_ALLOWLIST.contains(usage)) {
return Vibration.Status.IGNORED_BACKGROUND;
}
- if (mVirtualDeviceListener.isAppOrDisplayOnAnyVirtualDevice(callerInfo.uid,
- callerInfo.displayId)) {
+
+ if (callerInfo.deviceId != Context.DEVICE_ID_DEFAULT
+ && callerInfo.deviceId != Context.DEVICE_ID_INVALID) {
+ return Vibration.Status.IGNORED_FROM_VIRTUAL_DEVICE;
+ }
+
+ if (callerInfo.deviceId == Context.DEVICE_ID_INVALID
+ && isAppRunningOnAnyVirtualDevice(callerInfo.uid)) {
return Vibration.Status.IGNORED_FROM_VIRTUAL_DEVICE;
}
@@ -794,6 +791,15 @@
return out;
}
+ private boolean isAppRunningOnAnyVirtualDevice(int uid) {
+ if (mVirtualDeviceManagerInternal == null) {
+ mVirtualDeviceManagerInternal =
+ LocalServices.getService(VirtualDeviceManagerInternal.class);
+ }
+ return mVirtualDeviceManagerInternal != null
+ && mVirtualDeviceManagerInternal.isAppRunningOnAnyVirtualDevice(uid);
+ }
+
/** Implementation of {@link ContentObserver} to be registered to a setting {@link Uri}. */
@VisibleForTesting
final class SettingsContentObserver extends ContentObserver {
@@ -853,73 +859,4 @@
}
}
}
-
- /**
- * Implementation of Virtual Device listeners for the changes of virtual displays and of apps
- * running on any virtual device.
- */
- final class VirtualDeviceListener implements
- VirtualDeviceManagerInternal.VirtualDisplayListener,
- VirtualDeviceManagerInternal.AppsOnVirtualDeviceListener {
- @GuardedBy("mLock")
- private final Set<Integer> mVirtualDisplays = new HashSet<>();
- @GuardedBy("mLock")
- private final Set<Integer> mAppsOnVirtualDevice = new HashSet<>();
-
-
- @Override
- public void onVirtualDisplayCreated(int displayId) {
- synchronized (mLock) {
- mVirtualDisplays.add(displayId);
- }
- }
-
- @Override
- public void onVirtualDisplayRemoved(int displayId) {
- synchronized (mLock) {
- mVirtualDisplays.remove(displayId);
- }
- }
-
-
- @Override
- public void onAppsOnAnyVirtualDeviceChanged(Set<Integer> allRunningUids) {
- synchronized (mLock) {
- mAppsOnVirtualDevice.clear();
- mAppsOnVirtualDevice.addAll(allRunningUids);
- }
- }
-
- /**
- * @param uid: uid of the calling app.
- * @param displayId: the id of a Display.
- * @return Returns true if:
- * <ul>
- * <li> the displayId is valid, and it's owned by a virtual device.</li>
- * <li> the displayId is invalid, and the calling app (uid) is running on a virtual
- * device.</li>
- * </ul>
- */
- public boolean isAppOrDisplayOnAnyVirtualDevice(int uid, int displayId) {
- if (displayId == Display.DEFAULT_DISPLAY) {
- // The default display is the primary physical display on the phone.
- return false;
- }
-
- synchronized (mLock) {
- if (displayId == Display.INVALID_DISPLAY) {
- // There is no Display object associated with the Context of calling
- // {@link SystemVibratorManager}, checking the calling UID instead.
- return mAppsOnVirtualDevice.contains(uid);
- } else {
- // Other valid display IDs representing valid logical displays will be
- // checked
- // against the active virtual displays set built with the registered
- // {@link VirtualDisplayListener}.
- return mVirtualDisplays.contains(displayId);
- }
- }
- }
-
- }
}
diff --git a/services/core/java/com/android/server/vibrator/VibratorManagerService.java b/services/core/java/com/android/server/vibrator/VibratorManagerService.java
index ace7777..cf33cc5 100644
--- a/services/core/java/com/android/server/vibrator/VibratorManagerService.java
+++ b/services/core/java/com/android/server/vibrator/VibratorManagerService.java
@@ -63,7 +63,6 @@
import android.util.Slog;
import android.util.SparseArray;
import android.util.proto.ProtoOutputStream;
-import android.view.Display;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
@@ -385,7 +384,7 @@
return false;
}
AlwaysOnVibration alwaysOnVibration = new AlwaysOnVibration(alwaysOnId,
- new Vibration.CallerInfo(attrs, uid, Display.DEFAULT_DISPLAY, opPkg,
+ new Vibration.CallerInfo(attrs, uid, Context.DEVICE_ID_DEFAULT, opPkg,
null), effects);
mAlwaysOnEffects.put(alwaysOnId, alwaysOnVibration);
updateAlwaysOnLocked(alwaysOnVibration);
@@ -397,16 +396,16 @@
}
@Override // Binder call
- public void vibrate(int uid, int displayId, String opPkg, @NonNull CombinedVibration effect,
+ public void vibrate(int uid, int deviceId, String opPkg, @NonNull CombinedVibration effect,
@Nullable VibrationAttributes attrs, String reason, IBinder token) {
- vibrateWithPermissionCheck(uid, displayId, opPkg, effect, attrs, reason, token);
+ vibrateWithPermissionCheck(uid, deviceId, opPkg, effect, attrs, reason, token);
}
@Override // Binder call
public void performHapticFeedback(
- int uid, int displayId, String opPkg, int constant, boolean always, String reason,
+ int uid, int deviceId, String opPkg, int constant, boolean always, String reason,
IBinder token) {
- performHapticFeedbackInternal(uid, displayId, opPkg, constant, always, reason, token);
+ performHapticFeedbackInternal(uid, deviceId, opPkg, constant, always, reason, token);
}
/**
@@ -417,7 +416,7 @@
@VisibleForTesting
@Nullable
HalVibration performHapticFeedbackInternal(
- int uid, int displayId, String opPkg, int constant, boolean always, String reason,
+ int uid, int deviceId, String opPkg, int constant, boolean always, String reason,
IBinder token) {
HapticFeedbackVibrationProvider hapticVibrationProvider = getHapticVibrationProvider();
if (hapticVibrationProvider == null) {
@@ -433,7 +432,7 @@
VibrationAttributes attrs =
hapticVibrationProvider.getVibrationAttributesForHapticFeedback(
constant, /* bypassVibrationIntensitySetting= */ always);
- return vibrateWithoutPermissionCheck(uid, displayId, opPkg, combinedVibration, attrs,
+ return vibrateWithoutPermissionCheck(uid, deviceId, opPkg, combinedVibration, attrs,
"performHapticFeedback: " + reason, token);
}
@@ -444,7 +443,7 @@
*/
@VisibleForTesting
@Nullable
- HalVibration vibrateWithPermissionCheck(int uid, int displayId, String opPkg,
+ HalVibration vibrateWithPermissionCheck(int uid, int deviceId, String opPkg,
@NonNull CombinedVibration effect, @Nullable VibrationAttributes attrs,
String reason, IBinder token) {
Trace.traceBegin(Trace.TRACE_TAG_VIBRATOR, "vibrate, reason = " + reason);
@@ -452,24 +451,24 @@
attrs = fixupVibrationAttributes(attrs, effect);
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.VIBRATE, "vibrate");
- return vibrateInternal(uid, displayId, opPkg, effect, attrs, reason, token);
+ return vibrateInternal(uid, deviceId, opPkg, effect, attrs, reason, token);
} finally {
Trace.traceEnd(Trace.TRACE_TAG_VIBRATOR);
}
}
- HalVibration vibrateWithoutPermissionCheck(int uid, int displayId, String opPkg,
+ HalVibration vibrateWithoutPermissionCheck(int uid, int deviceId, String opPkg,
@NonNull CombinedVibration effect, @NonNull VibrationAttributes attrs,
String reason, IBinder token) {
Trace.traceBegin(Trace.TRACE_TAG_VIBRATOR, "vibrate no perm check, reason = " + reason);
try {
- return vibrateInternal(uid, displayId, opPkg, effect, attrs, reason, token);
+ return vibrateInternal(uid, deviceId, opPkg, effect, attrs, reason, token);
} finally {
Trace.traceEnd(Trace.TRACE_TAG_VIBRATOR);
}
}
- private HalVibration vibrateInternal(int uid, int displayId, String opPkg,
+ private HalVibration vibrateInternal(int uid, int deviceId, String opPkg,
@NonNull CombinedVibration effect, @NonNull VibrationAttributes attrs,
String reason, IBinder token) {
if (token == null) {
@@ -482,7 +481,7 @@
}
// Create Vibration.Stats as close to the received request as possible, for tracking.
HalVibration vib = new HalVibration(token, effect,
- new Vibration.CallerInfo(attrs, uid, displayId, opPkg, reason));
+ new Vibration.CallerInfo(attrs, uid, deviceId, opPkg, reason));
fillVibrationFallbacks(vib, effect);
if (attrs.isFlagSet(VibrationAttributes.FLAG_INVALIDATE_SETTINGS_CACHE)) {
@@ -1558,10 +1557,9 @@
private ExternalVibrationHolder(ExternalVibration externalVibration) {
super(externalVibration.getToken(), new Vibration.CallerInfo(
externalVibration.getVibrationAttributes(), externalVibration.getUid(),
- // TODO(b/243604888): propagating displayID from IExternalVibration instead of
- // using INVALID_DISPLAY for all external vibrations.
- Display.INVALID_DISPLAY,
- externalVibration.getPackage(), null));
+ // TODO(b/249785241): Find a way to link ExternalVibration to a VirtualDevice
+ // instead of using DEVICE_ID_INVALID here and relying on the UID checks.
+ Context.DEVICE_ID_INVALID, externalVibration.getPackage(), null));
this.externalVibration = externalVibration;
this.scale = IExternalVibratorService.SCALE_NONE;
mStatus = Vibration.Status.RUNNING;
@@ -1974,8 +1972,6 @@
boolean alreadyUnderExternalControl = false;
boolean waitForCompletion = false;
synchronized (mLock) {
- // TODO(b/243604888): propagating displayID from IExternalVibration instead of
- // using INVALID_DISPLAY for all external vibrations.
Vibration.EndInfo vibrationEndInfo = shouldIgnoreVibrationLocked(
vibHolder.callerInfo);
@@ -2184,7 +2180,7 @@
IBinder deathBinder = commonOptions.background ? VibratorManagerService.this
: mShellCallbacksToken;
HalVibration vib = vibrateWithPermissionCheck(Binder.getCallingUid(),
- Display.DEFAULT_DISPLAY, SHELL_PACKAGE_NAME, combined, attrs,
+ Context.DEVICE_ID_DEFAULT, SHELL_PACKAGE_NAME, combined, attrs,
commonOptions.description, deathBinder);
maybeWaitOnVibration(vib, commonOptions);
}
@@ -2241,7 +2237,7 @@
IBinder deathBinder = commonOptions.background ? VibratorManagerService.this
: mShellCallbacksToken;
HalVibration vib = performHapticFeedbackInternal(Binder.getCallingUid(),
- Display.DEFAULT_DISPLAY, SHELL_PACKAGE_NAME, constant,
+ Context.DEVICE_ID_DEFAULT, SHELL_PACKAGE_NAME, constant,
/* always= */ commonOptions.force, /* reason= */ commonOptions.description,
deathBinder);
maybeWaitOnVibration(vib, commonOptions);
diff --git a/services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceManagerServiceTest.java
index 461d637..4ef2ddc 100644
--- a/services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceManagerServiceTest.java
@@ -259,8 +259,6 @@
@Mock
private Consumer<ArraySet<Integer>> mRunningAppsChangedCallback;
@Mock
- private VirtualDeviceManagerInternal.VirtualDisplayListener mDisplayListener;
- @Mock
private VirtualDeviceManagerInternal.AppsOnVirtualDeviceListener mAppsOnVirtualDeviceListener;
@Mock
IPowerManager mIPowerManagerMock;
@@ -722,28 +720,6 @@
}
@Test
- public void onVirtualDisplayCreatedLocked_listenersNotified() {
- mLocalService.registerVirtualDisplayListener(mDisplayListener);
-
- mLocalService.onVirtualDisplayCreated(DISPLAY_ID_1);
- TestableLooper.get(this).processAllMessages();
-
- verify(mDisplayListener).onVirtualDisplayCreated(DISPLAY_ID_1);
- }
-
- @Test
- public void onVirtualDisplayRemovedLocked_listenersNotified() {
- mLocalService.registerVirtualDisplayListener(mDisplayListener);
-
- addVirtualDisplay(mDeviceImpl, DISPLAY_ID_1);
-
- mLocalService.onVirtualDisplayRemoved(mDeviceImpl, DISPLAY_ID_1);
- TestableLooper.get(this).processAllMessages();
-
- verify(mDisplayListener).onVirtualDisplayRemoved(DISPLAY_ID_1);
- }
-
- @Test
public void onAppsOnVirtualDeviceChanged_singleVirtualDevice_listenersNotified() {
ArraySet<Integer> uids = new ArraySet<>(Arrays.asList(UID_1, UID_2));
mLocalService.registerAppsOnVirtualDeviceListener(mAppsOnVirtualDeviceListener);
diff --git a/services/tests/vibrator/src/com/android/server/vibrator/VibrationSettingsTest.java b/services/tests/vibrator/src/com/android/server/vibrator/VibrationSettingsTest.java
index 7a2bb5a..f080341 100644
--- a/services/tests/vibrator/src/com/android/server/vibrator/VibrationSettingsTest.java
+++ b/services/tests/vibrator/src/com/android/server/vibrator/VibrationSettingsTest.java
@@ -75,8 +75,6 @@
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.provider.Settings;
-import android.util.ArraySet;
-import android.view.Display;
import androidx.test.InstrumentationRegistry;
@@ -103,7 +101,7 @@
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
private static final int UID = 1;
- private static final int VIRTUAL_DISPLAY_ID = 1;
+ private static final int VIRTUAL_DEVICE_ID = 1;
private static final String SYSUI_PACKAGE_NAME = "sysui";
private static final PowerSaveState NORMAL_POWER_STATE = new PowerSaveState.Builder().build();
private static final PowerSaveState LOW_POWER_STATE = new PowerSaveState.Builder()
@@ -137,9 +135,6 @@
private VibrationSettings mVibrationSettings;
private PowerManagerInternal.LowPowerModeListener mRegisteredPowerModeListener;
private BroadcastReceiver mRegisteredBatteryBroadcastReceiver;
- private VirtualDeviceManagerInternal.VirtualDisplayListener mRegisteredVirtualDisplayListener;
- private VirtualDeviceManagerInternal.AppsOnVirtualDeviceListener
- mRegisteredAppsOnVirtualDeviceListener;
@Before
public void setUp() throws Exception {
@@ -155,14 +150,6 @@
}).when(mPowerManagerInternalMock).registerLowPowerModeObserver(any());
when(mPackageManagerInternalMock.getSystemUiServiceComponent())
.thenReturn(new ComponentName(SYSUI_PACKAGE_NAME, ""));
- doAnswer(invocation -> {
- mRegisteredVirtualDisplayListener = invocation.getArgument(0);
- return null;
- }).when(mVirtualDeviceManagerInternalMock).registerVirtualDisplayListener(any());
- doAnswer(invocation -> {
- mRegisteredAppsOnVirtualDeviceListener = invocation.getArgument(0);
- return null;
- }).when(mVirtualDeviceManagerInternalMock).registerAppsOnVirtualDeviceListener(any());
removeServicesForTest();
addServicesForTest();
@@ -654,62 +641,20 @@
}
@Test
- public void shouldIgnoreVibrationFromVirtualDisplays_displayNonVirtual_neverIgnored() {
- // Vibrations from the primary display is never ignored regardless of the creation and
- // removal of virtual displays and of the changes of apps running on virtual displays.
- mRegisteredVirtualDisplayListener.onVirtualDisplayCreated(VIRTUAL_DISPLAY_ID);
- mRegisteredAppsOnVirtualDeviceListener.onAppsOnAnyVirtualDeviceChanged(
- new ArraySet<>(Arrays.asList(UID)));
+ public void shouldIgnoreVibrationFromVirtualDevices_defaultDevice_neverIgnored() {
+ // Vibrations from the primary device is never ignored.
for (int usage : ALL_USAGES) {
- assertVibrationNotIgnoredForUsageAndDisplay(usage, Display.DEFAULT_DISPLAY);
- }
-
- mRegisteredVirtualDisplayListener.onVirtualDisplayRemoved(VIRTUAL_DISPLAY_ID);
- for (int usage : ALL_USAGES) {
- assertVibrationNotIgnoredForUsageAndDisplay(usage, Display.DEFAULT_DISPLAY);
- }
-
- mRegisteredAppsOnVirtualDeviceListener.onAppsOnAnyVirtualDeviceChanged(new ArraySet<>());
- for (int usage : ALL_USAGES) {
- assertVibrationNotIgnoredForUsageAndDisplay(usage, Display.DEFAULT_DISPLAY);
+ assertVibrationNotIgnoredForUsageAndDevice(usage, Context.DEVICE_ID_DEFAULT);
}
}
@Test
- public void shouldIgnoreVibrationFromVirtualDisplays_displayVirtual() {
- // Ignore the vibration when the coming display id represents a virtual display.
- mRegisteredVirtualDisplayListener.onVirtualDisplayCreated(VIRTUAL_DISPLAY_ID);
-
+ public void shouldIgnoreVibrationFromVirtualDevices_virtualDevice_alwaysIgnored() {
+ // Ignore the vibration when the coming device id represents a virtual device.
for (int usage : ALL_USAGES) {
- assertVibrationIgnoredForUsageAndDisplay(usage, VIRTUAL_DISPLAY_ID,
+ assertVibrationIgnoredForUsageAndDevice(usage, VIRTUAL_DEVICE_ID,
Vibration.Status.IGNORED_FROM_VIRTUAL_DEVICE);
}
-
- // Stop ignoring when the virtual display is removed.
- mRegisteredVirtualDisplayListener.onVirtualDisplayRemoved(VIRTUAL_DISPLAY_ID);
- for (int usage : ALL_USAGES) {
- assertVibrationNotIgnoredForUsageAndDisplay(usage, VIRTUAL_DISPLAY_ID);
- }
- }
-
-
- @Test
- public void shouldIgnoreVibrationFromVirtualDisplays_appsOnVirtualDisplay() {
- // Ignore when the passed-in display id is invalid and the calling uid is on a virtual
- // display.
- mRegisteredAppsOnVirtualDeviceListener.onAppsOnAnyVirtualDeviceChanged(
- new ArraySet<>(Arrays.asList(UID)));
- for (int usage : ALL_USAGES) {
- assertVibrationIgnoredForUsageAndDisplay(usage, Display.INVALID_DISPLAY,
- Vibration.Status.IGNORED_FROM_VIRTUAL_DEVICE);
- }
-
- // Stop ignoring when the app is no longer on virtual display.
- mRegisteredAppsOnVirtualDeviceListener.onAppsOnAnyVirtualDeviceChanged(new ArraySet<>());
- for (int usage : ALL_USAGES) {
- assertVibrationNotIgnoredForUsageAndDisplay(usage, Display.INVALID_DISPLAY);
- }
-
}
@Test
@@ -932,13 +877,13 @@
private void assertVibrationIgnoredForUsage(@VibrationAttributes.Usage int usage,
Vibration.Status expectedStatus) {
- assertVibrationIgnoredForUsageAndDisplay(usage, Display.DEFAULT_DISPLAY, expectedStatus);
+ assertVibrationIgnoredForUsageAndDevice(usage, Context.DEVICE_ID_DEFAULT, expectedStatus);
}
- private void assertVibrationIgnoredForUsageAndDisplay(@VibrationAttributes.Usage int usage,
- int displayId, Vibration.Status expectedStatus) {
+ private void assertVibrationIgnoredForUsageAndDevice(@VibrationAttributes.Usage int usage,
+ int deviceId, Vibration.Status expectedStatus) {
Vibration.CallerInfo callerInfo = new Vibration.CallerInfo(
- VibrationAttributes.createForUsage(usage), UID, displayId, null, null);
+ VibrationAttributes.createForUsage(usage), UID, deviceId, null, null);
assertEquals(errorMessageForUsage(usage), expectedStatus,
mVibrationSettings.shouldIgnoreVibration(callerInfo));
}
@@ -946,7 +891,7 @@
private void assertVibrationIgnoredForAttributes(VibrationAttributes attrs,
Vibration.Status expectedStatus) {
Vibration.CallerInfo callerInfo = new Vibration.CallerInfo(attrs, UID,
- Display.DEFAULT_DISPLAY, null, null);
+ Context.DEVICE_ID_DEFAULT, null, null);
assertEquals(errorMessageForAttributes(attrs), expectedStatus,
mVibrationSettings.shouldIgnoreVibration(callerInfo));
}
@@ -957,27 +902,27 @@
private void assertVibrationNotIgnoredForUsageAndFlags(@VibrationAttributes.Usage int usage,
@VibrationAttributes.Flag int flags) {
- assertVibrationNotIgnoredForUsageAndFlagsAndDisplay(usage, Display.DEFAULT_DISPLAY, flags);
+ assertVibrationNotIgnoredForUsageAndFlagsAndDevice(usage, Context.DEVICE_ID_DEFAULT, flags);
}
- private void assertVibrationNotIgnoredForUsageAndDisplay(@VibrationAttributes.Usage int usage,
- int displayId) {
- assertVibrationNotIgnoredForUsageAndFlagsAndDisplay(usage, displayId, /* flags= */ 0);
+ private void assertVibrationNotIgnoredForUsageAndDevice(@VibrationAttributes.Usage int usage,
+ int deviceId) {
+ assertVibrationNotIgnoredForUsageAndFlagsAndDevice(usage, deviceId, /* flags= */ 0);
}
- private void assertVibrationNotIgnoredForUsageAndFlagsAndDisplay(
- @VibrationAttributes.Usage int usage, int displayId,
+ private void assertVibrationNotIgnoredForUsageAndFlagsAndDevice(
+ @VibrationAttributes.Usage int usage, int deviceId,
@VibrationAttributes.Flag int flags) {
Vibration.CallerInfo callerInfo = new Vibration.CallerInfo(
new VibrationAttributes.Builder().setUsage(usage).setFlags(flags).build(), UID,
- displayId, null, null);
+ deviceId, null, null);
assertNull(errorMessageForUsage(usage),
mVibrationSettings.shouldIgnoreVibration(callerInfo));
}
private void assertVibrationNotIgnoredForAttributes(VibrationAttributes attrs) {
Vibration.CallerInfo callerInfo = new Vibration.CallerInfo(attrs, UID,
- Display.DEFAULT_DISPLAY, null, null);
+ Context.DEVICE_ID_DEFAULT, null, null);
assertNull(errorMessageForAttributes(attrs),
mVibrationSettings.shouldIgnoreVibration(callerInfo));
}
@@ -1032,7 +977,7 @@
private Vibration.CallerInfo createCallerInfo(int uid, String opPkg,
@VibrationAttributes.Usage int usage) {
VibrationAttributes attrs = VibrationAttributes.createForUsage(usage);
- return new Vibration.CallerInfo(attrs, uid, VIRTUAL_DISPLAY_ID, opPkg, null);
+ return new Vibration.CallerInfo(attrs, uid, VIRTUAL_DEVICE_ID, opPkg, null);
}
private void setBatteryReceiverRegistrationResult(Intent result) {
diff --git a/services/tests/vibrator/src/com/android/server/vibrator/VibrationThreadTest.java b/services/tests/vibrator/src/com/android/server/vibrator/VibrationThreadTest.java
index 085241f..b0aef47 100644
--- a/services/tests/vibrator/src/com/android/server/vibrator/VibrationThreadTest.java
+++ b/services/tests/vibrator/src/com/android/server/vibrator/VibrationThreadTest.java
@@ -88,7 +88,7 @@
private static final int TEST_TIMEOUT_MILLIS = 900;
private static final int UID = Process.ROOT_UID;
- private static final int DISPLAY_ID = 10;
+ private static final int DEVICE_ID = 10;
private static final int VIBRATOR_ID = 1;
private static final String PACKAGE_NAME = "package";
private static final VibrationAttributes ATTRS = new VibrationAttributes.Builder().build();
@@ -250,7 +250,7 @@
Vibration.EndInfo cancelVibrationInfo = new Vibration.EndInfo(
Vibration.Status.CANCELLED_SUPERSEDED, new Vibration.CallerInfo(
VibrationAttributes.createForUsage(VibrationAttributes.USAGE_ALARM), /* uid= */
- 1, /* displayId= */ -1, /* opPkg= */ null, /* reason= */ null));
+ 1, /* deviceId= */ -1, /* opPkg= */ null, /* reason= */ null));
mVibrationConductor.notifyCancelled(
cancelVibrationInfo,
/* immediate= */ false);
@@ -1641,7 +1641,7 @@
private HalVibration createVibration(CombinedVibration effect) {
return new HalVibration(mVibrationToken, effect,
- new Vibration.CallerInfo(ATTRS, UID, DISPLAY_ID, PACKAGE_NAME, "reason"));
+ new Vibration.CallerInfo(ATTRS, UID, DEVICE_ID, PACKAGE_NAME, "reason"));
}
private SparseArray<VibratorController> createVibratorControllers() {
diff --git a/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java b/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java
index 3dfaed6..3fce9e7 100644
--- a/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java
+++ b/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java
@@ -84,10 +84,8 @@
import android.os.vibrator.VibrationEffectSegment;
import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.Settings;
-import android.util.ArraySet;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
-import android.view.Display;
import android.view.HapticFeedbackConstants;
import android.view.InputDevice;
import android.view.flags.Flags;
@@ -129,7 +127,7 @@
// be cancelled in the body of the individual test.
private static final int CLEANUP_TIMEOUT_MILLIS = 100;
private static final int UID = Process.ROOT_UID;
- private static final int VIRTUAL_DISPLAY_ID = 1;
+ private static final int VIRTUAL_DEVICE_ID = 1;
private static final String PACKAGE_NAME = "package";
private static final PowerSaveState NORMAL_POWER_STATE = new PowerSaveState.Builder().build();
private static final PowerSaveState LOW_POWER_STATE = new PowerSaveState.Builder()
@@ -190,9 +188,6 @@
private PowerManagerInternal.LowPowerModeListener mRegisteredPowerModeListener;
private VibratorManagerService.ExternalVibratorService mExternalVibratorService;
private VibrationConfig mVibrationConfig;
- private VirtualDeviceManagerInternal.VirtualDisplayListener mRegisteredVirtualDisplayListener;
- private VirtualDeviceManagerInternal.AppsOnVirtualDeviceListener
- mRegisteredAppsOnVirtualDeviceListener;
private InputManagerGlobal.TestSession mInputManagerGlobalSession;
private InputManager mInputManager;
@@ -223,14 +218,6 @@
mRegisteredPowerModeListener = invocation.getArgument(0);
return null;
}).when(mPowerManagerInternalMock).registerLowPowerModeObserver(any());
- doAnswer(invocation -> {
- mRegisteredVirtualDisplayListener = invocation.getArgument(0);
- return null;
- }).when(mVirtualDeviceManagerInternalMock).registerVirtualDisplayListener(any());
- doAnswer(invocation -> {
- mRegisteredAppsOnVirtualDeviceListener = invocation.getArgument(0);
- return null;
- }).when(mVirtualDeviceManagerInternalMock).registerAppsOnVirtualDeviceListener(any());
setUserSetting(Settings.System.VIBRATE_WHEN_RINGING, 1);
setUserSetting(Settings.System.HAPTIC_FEEDBACK_ENABLED, 1);
@@ -273,6 +260,7 @@
LocalServices.removeServiceForTest(PackageManagerInternal.class);
LocalServices.removeServiceForTest(PowerManagerInternal.class);
+ LocalServices.removeServiceForTest(VirtualDeviceManagerInternal.class);
// Ignore potential exceptions about the looper having never dispatched any messages.
mTestLooper.stopAutoDispatchAndIgnoreExceptions();
if (mInputManagerGlobalSession != null) {
@@ -1510,65 +1498,33 @@
}
@Test
- public void vibrate_withVirtualDisplayChange_ignoreVibrationFromVirtualDisplay()
- throws Exception {
+ public void vibrate_ignoreVibrationFromVirtualDevice() throws Exception {
mockVibrators(1);
VibratorManagerService service = createSystemReadyService();
- mRegisteredVirtualDisplayListener.onVirtualDisplayCreated(VIRTUAL_DISPLAY_ID);
- vibrateWithDisplay(service,
- VIRTUAL_DISPLAY_ID,
+ vibrateWithDevice(service,
+ VIRTUAL_DEVICE_ID,
CombinedVibration.startParallel()
.addVibrator(1, VibrationEffect.createOneShot(1000, 100))
.combine(),
HAPTIC_FEEDBACK_ATTRS);
- // Haptic feedback ignored when it's from a virtual display.
+ // Haptic feedback ignored when it's from a virtual device.
assertFalse(waitUntil(s -> s.isVibrating(1), service, /* timeout= */ 50));
- mRegisteredVirtualDisplayListener.onVirtualDisplayRemoved(VIRTUAL_DISPLAY_ID);
- vibrateWithDisplay(service,
- VIRTUAL_DISPLAY_ID,
+ vibrateWithDevice(service,
+ Context.DEVICE_ID_DEFAULT,
CombinedVibration.startParallel()
.addVibrator(1, VibrationEffect.createOneShot(1000, 100))
.combine(),
HAPTIC_FEEDBACK_ATTRS);
- // Haptic feedback played normally when the virtual display is removed.
+ // Haptic feedback played normally when it's from the default device.
assertTrue(waitUntil(s -> s.isVibrating(1), service, TEST_TIMEOUT_MILLIS));
cancelVibrate(service); // Clean up long-ish effect.
}
@Test
- public void vibrate_withAppsOnVirtualDisplayChange_ignoreVibrationFromVirtualDisplay()
- throws Exception {
- mockVibrators(1);
- VibratorManagerService service = createSystemReadyService();
- mRegisteredAppsOnVirtualDeviceListener.onAppsOnAnyVirtualDeviceChanged(
- new ArraySet<>(Arrays.asList(UID)));
- vibrateWithDisplay(service,
- Display.INVALID_DISPLAY,
- CombinedVibration.startParallel()
- .addVibrator(1, VibrationEffect.createOneShot(1000, 100))
- .combine(),
- HAPTIC_FEEDBACK_ATTRS);
-
- // Haptic feedback ignored when it's from an app running virtual display.
- assertFalse(waitUntil(s -> s.isVibrating(1), service, /* timeout= */ 50));
-
- mRegisteredAppsOnVirtualDeviceListener.onAppsOnAnyVirtualDeviceChanged(new ArraySet<>());
- vibrateWithDisplay(service,
- Display.INVALID_DISPLAY,
- CombinedVibration.startParallel()
- .addVibrator(1, VibrationEffect.createOneShot(1000, 100))
- .combine(),
- HAPTIC_FEEDBACK_ATTRS);
- // Haptic feedback played normally when the same app no long runs on a virtual display.
- assertTrue(waitUntil(s -> s.isVibrating(1), service, TEST_TIMEOUT_MILLIS));
- cancelVibrate(service); // Clean up long-ish effect.
- }
-
- @Test
public void vibrate_prebakedAndComposedVibrationsWithFallbacks_playsFallbackOnlyForPredefined()
throws Exception {
mockVibrators(1);
@@ -1685,7 +1641,7 @@
}
@Test
- public void onExternalVibration_ignoreVibrationFromVirtualDevices() throws Exception {
+ public void onExternalVibration_ignoreVibrationFromVirtualDevices() {
mockVibrators(1);
mVibratorProviders.get(1).setCapabilities(IVibrator.CAP_EXTERNAL_CONTROL);
createSystemReadyService();
@@ -1697,8 +1653,8 @@
int scale = mExternalVibratorService.onExternalVibrationStart(externalVibration);
assertNotEquals(IExternalVibratorService.SCALE_MUTE, scale);
- mRegisteredAppsOnVirtualDeviceListener.onAppsOnAnyVirtualDeviceChanged(
- new ArraySet<>(Arrays.asList(UID)));
+ when(mVirtualDeviceManagerInternalMock.isAppRunningOnAnyVirtualDevice(UID))
+ .thenReturn(true);
scale = mExternalVibratorService.onExternalVibrationStart(externalVibration);
assertEquals(IExternalVibratorService.SCALE_MUTE, scale);
}
@@ -2396,7 +2352,7 @@
private HalVibration performHapticFeedbackAndWaitUntilFinished(VibratorManagerService service,
int constant, boolean always) throws InterruptedException {
HalVibration vib =
- service.performHapticFeedbackInternal(UID, Display.DEFAULT_DISPLAY, PACKAGE_NAME,
+ service.performHapticFeedbackInternal(UID, Context.DEVICE_ID_DEFAULT, PACKAGE_NAME,
constant, always, "some reason", service);
if (vib != null) {
vib.waitForEnd();
@@ -2414,7 +2370,7 @@
private HalVibration vibrateAndWaitUntilFinished(VibratorManagerService service,
CombinedVibration effect, VibrationAttributes attrs) throws InterruptedException {
HalVibration vib =
- service.vibrateWithPermissionCheck(UID, Display.DEFAULT_DISPLAY, PACKAGE_NAME,
+ service.vibrateWithPermissionCheck(UID, Context.DEVICE_ID_DEFAULT, PACKAGE_NAME,
effect, attrs, "some reason", service);
if (vib != null) {
vib.waitForEnd();
@@ -2430,12 +2386,12 @@
private void vibrate(VibratorManagerService service, CombinedVibration effect,
VibrationAttributes attrs) {
- vibrateWithDisplay(service, Display.DEFAULT_DISPLAY, effect, attrs);
+ vibrateWithDevice(service, Context.DEVICE_ID_DEFAULT, effect, attrs);
}
- private void vibrateWithDisplay(VibratorManagerService service, int displayId,
+ private void vibrateWithDevice(VibratorManagerService service, int deviceId,
CombinedVibration effect, VibrationAttributes attrs) {
- service.vibrate(UID, displayId, PACKAGE_NAME, effect, attrs, "some reason", service);
+ service.vibrate(UID, deviceId, PACKAGE_NAME, effect, attrs, "some reason", service);
}
private boolean waitUntil(Predicate<VibratorManagerService> predicate,
diff --git a/tests/permission/src/com/android/framework/permission/tests/VibratorManagerServicePermissionTest.java b/tests/permission/src/com/android/framework/permission/tests/VibratorManagerServicePermissionTest.java
index 421ceb7..07b7338 100644
--- a/tests/permission/src/com/android/framework/permission/tests/VibratorManagerServicePermissionTest.java
+++ b/tests/permission/src/com/android/framework/permission/tests/VibratorManagerServicePermissionTest.java
@@ -50,7 +50,7 @@
public class VibratorManagerServicePermissionTest {
private static final String PACKAGE_NAME = "com.android.framework.permission.tests";
- private static final int DISPLAY_ID = 1;
+ private static final int DEVICE_ID = 1;
private static final CombinedVibration EFFECT =
CombinedVibration.createParallel(
VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE));
@@ -107,7 +107,7 @@
@Test
public void testVibrateWithoutPermissionFails() throws RemoteException {
expectSecurityException("VIBRATE");
- mVibratorService.vibrate(Process.myUid(), DISPLAY_ID, PACKAGE_NAME, EFFECT, ATTRS,
+ mVibratorService.vibrate(Process.myUid(), DEVICE_ID, PACKAGE_NAME, EFFECT, ATTRS,
"testVibrate",
new Binder());
}
@@ -117,7 +117,7 @@
throws RemoteException {
getInstrumentation().getUiAutomation().adoptShellPermissionIdentity(
Manifest.permission.VIBRATE);
- mVibratorService.vibrate(Process.myUid(), DISPLAY_ID, PACKAGE_NAME, EFFECT, ATTRS,
+ mVibratorService.vibrate(Process.myUid(), DEVICE_ID, PACKAGE_NAME, EFFECT, ATTRS,
"testVibrate",
new Binder());
}
@@ -127,7 +127,7 @@
expectSecurityException("UPDATE_APP_OPS_STATS");
getInstrumentation().getUiAutomation().adoptShellPermissionIdentity(
Manifest.permission.VIBRATE);
- mVibratorService.vibrate(Process.SYSTEM_UID, DISPLAY_ID, "android", EFFECT, ATTRS,
+ mVibratorService.vibrate(Process.SYSTEM_UID, DEVICE_ID, "android", EFFECT, ATTRS,
"testVibrate",
new Binder());
}
@@ -137,7 +137,7 @@
getInstrumentation().getUiAutomation().adoptShellPermissionIdentity(
Manifest.permission.VIBRATE,
Manifest.permission.UPDATE_APP_OPS_STATS);
- mVibratorService.vibrate(Process.SYSTEM_UID, DISPLAY_ID, "android", EFFECT, ATTRS,
+ mVibratorService.vibrate(Process.SYSTEM_UID, DEVICE_ID, "android", EFFECT, ATTRS,
"testVibrate",
new Binder());
}