Search in sources :

Example 6 with VrManagerInternal

use of com.android.server.vr.VrManagerInternal in project android_frameworks_base by ResurrectionRemix.

the class PhoneWindowManager method reportScreenStateToVrManager.

private void reportScreenStateToVrManager(boolean isScreenOn) {
    VrManagerInternal vrService = LocalServices.getService(VrManagerInternal.class);
    if (vrService == null) {
        return;
    }
    vrService.onScreenStateChanged(isScreenOn);
}
Also used : VrManagerInternal(com.android.server.vr.VrManagerInternal)

Example 7 with VrManagerInternal

use of com.android.server.vr.VrManagerInternal in project platform_frameworks_base by android.

the class ActivityManagerService method setVrMode.

@Override
public int setVrMode(IBinder token, boolean enabled, ComponentName packageName) {
    if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_VR_MODE)) {
        throw new UnsupportedOperationException("VR mode not supported on this device!");
    }
    final VrManagerInternal vrService = LocalServices.getService(VrManagerInternal.class);
    ActivityRecord r;
    synchronized (this) {
        r = ActivityRecord.isInStackLocked(token);
    }
    if (r == null) {
        throw new IllegalArgumentException();
    }
    int err;
    if ((err = vrService.hasVrPackage(packageName, r.userId)) != VrManagerInternal.NO_ERROR) {
        return err;
    }
    synchronized (this) {
        r.requestedVrComponent = (enabled) ? packageName : null;
        // Update associated state if this activity is currently focused
        if (r == mFocusedActivity) {
            applyUpdateVrModeLocked(r);
        }
        return 0;
    }
}
Also used : VrManagerInternal(com.android.server.vr.VrManagerInternal) Point(android.graphics.Point)

Example 8 with VrManagerInternal

use of com.android.server.vr.VrManagerInternal in project android_frameworks_base by DirtyUnicorns.

the class ActivityManagerService method setVrMode.

@Override
public int setVrMode(IBinder token, boolean enabled, ComponentName packageName) {
    if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_VR_MODE)) {
        throw new UnsupportedOperationException("VR mode not supported on this device!");
    }
    final VrManagerInternal vrService = LocalServices.getService(VrManagerInternal.class);
    ActivityRecord r;
    synchronized (this) {
        r = ActivityRecord.isInStackLocked(token);
    }
    if (r == null) {
        throw new IllegalArgumentException();
    }
    int err;
    if ((err = vrService.hasVrPackage(packageName, r.userId)) != VrManagerInternal.NO_ERROR) {
        return err;
    }
    synchronized (this) {
        r.requestedVrComponent = (enabled) ? packageName : null;
        // Update associated state if this activity is currently focused
        if (r == mFocusedActivity) {
            applyUpdateVrModeLocked(r);
        }
        return 0;
    }
}
Also used : VrManagerInternal(com.android.server.vr.VrManagerInternal) Point(android.graphics.Point)

Example 9 with VrManagerInternal

use of com.android.server.vr.VrManagerInternal in project android_frameworks_base by ResurrectionRemix.

the class HardwarePropertiesManagerService method enforceHardwarePropertiesRetrievalAllowed.

/**
     * Throws SecurityException if the calling package is not allowed to retrieve information
     * provided by the service.
     *
     * @param callingPackage The calling package name.
     *
     * @throws SecurityException if something other than the profile or device owner, the
     *        current VR service, or a caller holding the {@link Manifest.permission#DEVICE_POWER}
     *        permission tries to retrieve information provided by this service.
     */
private void enforceHardwarePropertiesRetrievalAllowed(String callingPackage) throws SecurityException {
    final PackageManager pm = mContext.getPackageManager();
    int uid = 0;
    try {
        uid = pm.getPackageUid(callingPackage, 0);
        if (Binder.getCallingUid() != uid) {
            throw new SecurityException("The caller has faked the package name.");
        }
    } catch (PackageManager.NameNotFoundException e) {
        throw new SecurityException("The caller has faked the package name.");
    }
    final int userId = UserHandle.getUserId(uid);
    final VrManagerInternal vrService = LocalServices.getService(VrManagerInternal.class);
    final DevicePolicyManager dpm = mContext.getSystemService(DevicePolicyManager.class);
    if (!dpm.isDeviceOwnerApp(callingPackage) && !dpm.isProfileOwnerApp(callingPackage) && !vrService.isCurrentVrListener(callingPackage, userId) && mContext.checkCallingOrSelfPermission(Manifest.permission.DEVICE_POWER) != PackageManager.PERMISSION_GRANTED) {
        throw new SecurityException("The caller is not a device or profile owner, bound " + "VrListenerService, or holding the DEVICE_POWER permission.");
    }
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) PackageManager(android.content.pm.PackageManager) VrManagerInternal(com.android.server.vr.VrManagerInternal)

Example 10 with VrManagerInternal

use of com.android.server.vr.VrManagerInternal in project android_frameworks_base by crdroidandroid.

the class HardwarePropertiesManagerService method enforceHardwarePropertiesRetrievalAllowed.

/**
     * Throws SecurityException if the calling package is not allowed to retrieve information
     * provided by the service.
     *
     * @param callingPackage The calling package name.
     *
     * @throws SecurityException if something other than the profile or device owner, the
     *        current VR service, or a caller holding the {@link Manifest.permission#DEVICE_POWER}
     *        permission tries to retrieve information provided by this service.
     */
private void enforceHardwarePropertiesRetrievalAllowed(String callingPackage) throws SecurityException {
    final PackageManager pm = mContext.getPackageManager();
    int uid = 0;
    try {
        uid = pm.getPackageUid(callingPackage, 0);
        if (Binder.getCallingUid() != uid) {
            throw new SecurityException("The caller has faked the package name.");
        }
    } catch (PackageManager.NameNotFoundException e) {
        throw new SecurityException("The caller has faked the package name.");
    }
    final int userId = UserHandle.getUserId(uid);
    final VrManagerInternal vrService = LocalServices.getService(VrManagerInternal.class);
    final DevicePolicyManager dpm = mContext.getSystemService(DevicePolicyManager.class);
    if (!dpm.isDeviceOwnerApp(callingPackage) && !dpm.isProfileOwnerApp(callingPackage) && !vrService.isCurrentVrListener(callingPackage, userId) && mContext.checkCallingOrSelfPermission(Manifest.permission.DEVICE_POWER) != PackageManager.PERMISSION_GRANTED) {
        throw new SecurityException("The caller is not a device or profile owner, bound " + "VrListenerService, or holding the DEVICE_POWER permission.");
    }
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) PackageManager(android.content.pm.PackageManager) VrManagerInternal(com.android.server.vr.VrManagerInternal)

Aggregations

VrManagerInternal (com.android.server.vr.VrManagerInternal)10 DevicePolicyManager (android.app.admin.DevicePolicyManager)5 PackageManager (android.content.pm.PackageManager)5 Point (android.graphics.Point)2