use of android.service.vr.IVrListener in project android_frameworks_base by DirtyUnicorns.
the class VrManagerService method updateCurrentVrServiceLocked.
/**
* Send VR mode changes (if the mode state has changed), and update the bound/unbound state of
* the currently selected VR listener service. If the component selected for the VR listener
* service has changed, unbind the previous listener and bind the new listener (if enabled).
* <p/>
* Note: Must be called while holding {@code mLock}.
*
* @param enabled new state for VR mode.
* @param component new component to be bound as a VR listener.
* @param userId user owning the component to be bound.
* @param calling the component currently using VR mode, or null to leave unchanged.
*
* @return {@code true} if the component/user combination specified is valid.
*/
private boolean updateCurrentVrServiceLocked(boolean enabled, @NonNull ComponentName component, int userId, ComponentName calling) {
boolean sendUpdatedCaller = false;
final long identity = Binder.clearCallingIdentity();
try {
boolean validUserComponent = (mComponentObserver.isValid(component, userId) == EnabledComponentsObserver.NO_ERROR);
boolean goingIntoVrMode = validUserComponent && enabled;
if (!mVrModeEnabled && !goingIntoVrMode) {
// Disabled -> Disabled transition does nothing.
return validUserComponent;
}
String oldVrServicePackage = mCurrentVrService != null ? mCurrentVrService.getComponent().getPackageName() : null;
final int oldUserId = mCurrentVrModeUser;
// Notify system services and VR HAL of mode change.
changeVrModeLocked(goingIntoVrMode);
boolean nothingChanged = false;
if (!goingIntoVrMode) {
// Not going into VR mode, unbind whatever is running
if (mCurrentVrService != null) {
Slog.i(TAG, "Leaving VR mode, disconnecting " + mCurrentVrService.getComponent() + " for user " + mCurrentVrService.getUserId());
mCurrentVrService.disconnect();
mCurrentVrService = null;
} else {
nothingChanged = true;
}
} else {
// Going into VR mode
if (mCurrentVrService != null) {
// selection.
if (mCurrentVrService.disconnectIfNotMatching(component, userId)) {
Slog.i(TAG, "VR mode component changed to " + component + ", disconnecting " + mCurrentVrService.getComponent() + " for user " + mCurrentVrService.getUserId());
createAndConnectService(component, userId);
sendUpdatedCaller = true;
} else {
nothingChanged = true;
}
// The service with the correct component/user is already bound, do nothing.
} else {
// Nothing was previously running, bind a new service for the latest
// component/user selection.
createAndConnectService(component, userId);
sendUpdatedCaller = true;
}
}
if (calling != null && !Objects.equals(calling, mCurrentVrModeComponent)) {
mCurrentVrModeComponent = calling;
sendUpdatedCaller = true;
}
if (mCurrentVrModeUser != userId) {
mCurrentVrModeUser = userId;
sendUpdatedCaller = true;
}
String newVrServicePackage = mCurrentVrService != null ? mCurrentVrService.getComponent().getPackageName() : null;
final int newUserId = mCurrentVrModeUser;
// Update AppOps settings that change state when entering/exiting VR mode, or changing
// the current VrListenerService.
updateDependentAppOpsLocked(newVrServicePackage, newUserId, oldVrServicePackage, oldUserId);
if (mCurrentVrService != null && sendUpdatedCaller) {
final ComponentName c = mCurrentVrModeComponent;
mCurrentVrService.sendEvent(new PendingEvent() {
@Override
public void runEvent(IInterface service) throws RemoteException {
IVrListener l = (IVrListener) service;
l.focusedActivityChanged(c);
}
});
}
if (!nothingChanged) {
logStateLocked();
}
return validUserComponent;
} finally {
Binder.restoreCallingIdentity(identity);
}
}
use of android.service.vr.IVrListener in project android_frameworks_base by ResurrectionRemix.
the class VrManagerService method updateCurrentVrServiceLocked.
/**
* Send VR mode changes (if the mode state has changed), and update the bound/unbound state of
* the currently selected VR listener service. If the component selected for the VR listener
* service has changed, unbind the previous listener and bind the new listener (if enabled).
* <p/>
* Note: Must be called while holding {@code mLock}.
*
* @param enabled new state for VR mode.
* @param component new component to be bound as a VR listener.
* @param userId user owning the component to be bound.
* @param calling the component currently using VR mode, or null to leave unchanged.
*
* @return {@code true} if the component/user combination specified is valid.
*/
private boolean updateCurrentVrServiceLocked(boolean enabled, @NonNull ComponentName component, int userId, ComponentName calling) {
boolean sendUpdatedCaller = false;
final long identity = Binder.clearCallingIdentity();
try {
boolean validUserComponent = (mComponentObserver.isValid(component, userId) == EnabledComponentsObserver.NO_ERROR);
boolean goingIntoVrMode = validUserComponent && enabled;
if (!mVrModeEnabled && !goingIntoVrMode) {
// Disabled -> Disabled transition does nothing.
return validUserComponent;
}
String oldVrServicePackage = mCurrentVrService != null ? mCurrentVrService.getComponent().getPackageName() : null;
final int oldUserId = mCurrentVrModeUser;
// Notify system services and VR HAL of mode change.
changeVrModeLocked(goingIntoVrMode);
boolean nothingChanged = false;
if (!goingIntoVrMode) {
// Not going into VR mode, unbind whatever is running
if (mCurrentVrService != null) {
Slog.i(TAG, "Leaving VR mode, disconnecting " + mCurrentVrService.getComponent() + " for user " + mCurrentVrService.getUserId());
mCurrentVrService.disconnect();
mCurrentVrService = null;
} else {
nothingChanged = true;
}
} else {
// Going into VR mode
if (mCurrentVrService != null) {
// selection.
if (mCurrentVrService.disconnectIfNotMatching(component, userId)) {
Slog.i(TAG, "VR mode component changed to " + component + ", disconnecting " + mCurrentVrService.getComponent() + " for user " + mCurrentVrService.getUserId());
createAndConnectService(component, userId);
sendUpdatedCaller = true;
} else {
nothingChanged = true;
}
// The service with the correct component/user is already bound, do nothing.
} else {
// Nothing was previously running, bind a new service for the latest
// component/user selection.
createAndConnectService(component, userId);
sendUpdatedCaller = true;
}
}
if (calling != null && !Objects.equals(calling, mCurrentVrModeComponent)) {
mCurrentVrModeComponent = calling;
sendUpdatedCaller = true;
}
if (mCurrentVrModeUser != userId) {
mCurrentVrModeUser = userId;
sendUpdatedCaller = true;
}
String newVrServicePackage = mCurrentVrService != null ? mCurrentVrService.getComponent().getPackageName() : null;
final int newUserId = mCurrentVrModeUser;
// Update AppOps settings that change state when entering/exiting VR mode, or changing
// the current VrListenerService.
updateDependentAppOpsLocked(newVrServicePackage, newUserId, oldVrServicePackage, oldUserId);
if (mCurrentVrService != null && sendUpdatedCaller) {
final ComponentName c = mCurrentVrModeComponent;
mCurrentVrService.sendEvent(new PendingEvent() {
@Override
public void runEvent(IInterface service) throws RemoteException {
IVrListener l = (IVrListener) service;
l.focusedActivityChanged(c);
}
});
}
if (!nothingChanged) {
logStateLocked();
}
return validUserComponent;
} finally {
Binder.restoreCallingIdentity(identity);
}
}
use of android.service.vr.IVrListener in project platform_frameworks_base by android.
the class VrManagerService method updateCurrentVrServiceLocked.
/**
* Send VR mode changes (if the mode state has changed), and update the bound/unbound state of
* the currently selected VR listener service. If the component selected for the VR listener
* service has changed, unbind the previous listener and bind the new listener (if enabled).
* <p/>
* Note: Must be called while holding {@code mLock}.
*
* @param enabled new state for VR mode.
* @param component new component to be bound as a VR listener.
* @param userId user owning the component to be bound.
* @param calling the component currently using VR mode, or null to leave unchanged.
*
* @return {@code true} if the component/user combination specified is valid.
*/
private boolean updateCurrentVrServiceLocked(boolean enabled, @NonNull ComponentName component, int userId, ComponentName calling) {
boolean sendUpdatedCaller = false;
final long identity = Binder.clearCallingIdentity();
try {
boolean validUserComponent = (mComponentObserver.isValid(component, userId) == EnabledComponentsObserver.NO_ERROR);
if (!mVrModeEnabled && !enabled) {
// Disabled -> Disabled transition does nothing.
return validUserComponent;
}
String oldVrServicePackage = mCurrentVrService != null ? mCurrentVrService.getComponent().getPackageName() : null;
final int oldUserId = mCurrentVrModeUser;
// Always send mode change events.
changeVrModeLocked(enabled);
if (!enabled || !validUserComponent) {
// Unbind whatever is running
if (mCurrentVrService != null) {
Slog.i(TAG, "Disconnecting " + mCurrentVrService.getComponent() + " for user " + mCurrentVrService.getUserId());
mCurrentVrService.disconnect();
mCurrentVrService = null;
}
} else {
if (mCurrentVrService != null) {
// Unbind any running service that doesn't match the component/user selection
if (mCurrentVrService.disconnectIfNotMatching(component, userId)) {
Slog.i(TAG, "Disconnecting " + mCurrentVrService.getComponent() + " for user " + mCurrentVrService.getUserId());
createAndConnectService(component, userId);
sendUpdatedCaller = true;
}
// The service with the correct component/user is bound
} else {
// Nothing was previously running, bind a new service
createAndConnectService(component, userId);
sendUpdatedCaller = true;
}
}
if (calling != null && !Objects.equals(calling, mCurrentVrModeComponent)) {
mCurrentVrModeComponent = calling;
sendUpdatedCaller = true;
}
if (mCurrentVrModeUser != userId) {
mCurrentVrModeUser = userId;
sendUpdatedCaller = true;
}
String newVrServicePackage = mCurrentVrService != null ? mCurrentVrService.getComponent().getPackageName() : null;
final int newUserId = mCurrentVrModeUser;
// Update AppOps settings that change state when entering/exiting VR mode, or changing
// the current VrListenerService.
updateDependentAppOpsLocked(newVrServicePackage, newUserId, oldVrServicePackage, oldUserId);
if (mCurrentVrService != null && sendUpdatedCaller) {
final ComponentName c = mCurrentVrModeComponent;
mCurrentVrService.sendEvent(new PendingEvent() {
@Override
public void runEvent(IInterface service) throws RemoteException {
IVrListener l = (IVrListener) service;
l.focusedActivityChanged(c);
}
});
}
logStateLocked();
return validUserComponent;
} finally {
Binder.restoreCallingIdentity(identity);
}
}
use of android.service.vr.IVrListener in project android_frameworks_base by crdroidandroid.
the class VrManagerService method updateCurrentVrServiceLocked.
/**
* Send VR mode changes (if the mode state has changed), and update the bound/unbound state of
* the currently selected VR listener service. If the component selected for the VR listener
* service has changed, unbind the previous listener and bind the new listener (if enabled).
* <p/>
* Note: Must be called while holding {@code mLock}.
*
* @param enabled new state for VR mode.
* @param component new component to be bound as a VR listener.
* @param userId user owning the component to be bound.
* @param calling the component currently using VR mode, or null to leave unchanged.
*
* @return {@code true} if the component/user combination specified is valid.
*/
private boolean updateCurrentVrServiceLocked(boolean enabled, @NonNull ComponentName component, int userId, ComponentName calling) {
boolean sendUpdatedCaller = false;
final long identity = Binder.clearCallingIdentity();
try {
boolean validUserComponent = (mComponentObserver.isValid(component, userId) == EnabledComponentsObserver.NO_ERROR);
boolean goingIntoVrMode = validUserComponent && enabled;
if (!mVrModeEnabled && !goingIntoVrMode) {
// Disabled -> Disabled transition does nothing.
return validUserComponent;
}
String oldVrServicePackage = mCurrentVrService != null ? mCurrentVrService.getComponent().getPackageName() : null;
final int oldUserId = mCurrentVrModeUser;
// Notify system services and VR HAL of mode change.
changeVrModeLocked(goingIntoVrMode);
boolean nothingChanged = false;
if (!goingIntoVrMode) {
// Not going into VR mode, unbind whatever is running
if (mCurrentVrService != null) {
Slog.i(TAG, "Leaving VR mode, disconnecting " + mCurrentVrService.getComponent() + " for user " + mCurrentVrService.getUserId());
mCurrentVrService.disconnect();
mCurrentVrService = null;
} else {
nothingChanged = true;
}
} else {
// Going into VR mode
if (mCurrentVrService != null) {
// selection.
if (mCurrentVrService.disconnectIfNotMatching(component, userId)) {
Slog.i(TAG, "VR mode component changed to " + component + ", disconnecting " + mCurrentVrService.getComponent() + " for user " + mCurrentVrService.getUserId());
createAndConnectService(component, userId);
sendUpdatedCaller = true;
} else {
nothingChanged = true;
}
// The service with the correct component/user is already bound, do nothing.
} else {
// Nothing was previously running, bind a new service for the latest
// component/user selection.
createAndConnectService(component, userId);
sendUpdatedCaller = true;
}
}
if (calling != null && !Objects.equals(calling, mCurrentVrModeComponent)) {
mCurrentVrModeComponent = calling;
sendUpdatedCaller = true;
}
if (mCurrentVrModeUser != userId) {
mCurrentVrModeUser = userId;
sendUpdatedCaller = true;
}
String newVrServicePackage = mCurrentVrService != null ? mCurrentVrService.getComponent().getPackageName() : null;
final int newUserId = mCurrentVrModeUser;
// Update AppOps settings that change state when entering/exiting VR mode, or changing
// the current VrListenerService.
updateDependentAppOpsLocked(newVrServicePackage, newUserId, oldVrServicePackage, oldUserId);
if (mCurrentVrService != null && sendUpdatedCaller) {
final ComponentName c = mCurrentVrModeComponent;
mCurrentVrService.sendEvent(new PendingEvent() {
@Override
public void runEvent(IInterface service) throws RemoteException {
IVrListener l = (IVrListener) service;
l.focusedActivityChanged(c);
}
});
}
if (!nothingChanged) {
logStateLocked();
}
return validUserComponent;
} finally {
Binder.restoreCallingIdentity(identity);
}
}
Aggregations