Loading core/java/android/os/HardwarePropertiesManager.java +6 −3 Original line number Diff line number Diff line Loading @@ -101,7 +101,8 @@ public class HardwarePropertiesManager { * {@link #UNDEFINED_TEMPERATURE} if undefined. * Empty if platform doesn't provide the queried temperature. * * @throws SecurityException if a non profile or device owner tries to call this method. * @throws SecurityException if something other than the profile or device owner, or the * current VR service tries to retrieve information provided by this service. */ public @NonNull float[] getDeviceTemperatures(@DeviceTemperatureType int type, @TemperatureSource int source) { Loading Loading @@ -137,7 +138,8 @@ public class HardwarePropertiesManager { * each unplugged core. * Empty if CPU usage is not supported on this system. * * @throws SecurityException if a non profile or device owner tries to call this method. * @throws SecurityException if something other than the profile or device owner, or the * current VR service tries to retrieve information provided by this service. */ public @NonNull CpuUsageInfo[] getCpuUsages() { try { Loading @@ -153,7 +155,8 @@ public class HardwarePropertiesManager { * @return an array of float fan speeds in RPM. Empty if there are no fans or fan speed is not * supported on this system. * * @throws SecurityException if a non profile or device owner tries to call this method. * @throws SecurityException if something other than the profile or device owner, or the * current VR service tries to retrieve information provided by this service. */ public @NonNull float[] getFanSpeeds() { try { Loading services/core/java/com/android/server/HardwarePropertiesManagerService.java +11 −5 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import android.os.Binder; import android.os.CpuUsageInfo; import android.os.IHardwarePropertiesManager; import android.os.Process; import android.os.UserHandle; import com.android.server.vr.VrManagerInternal; import java.util.Arrays; Loading Loading @@ -78,14 +80,15 @@ public class HardwarePropertiesManagerService extends IHardwarePropertiesManager * * @param callingPackage The calling package name. * * @throws SecurityException if a non profile or device owner or system tries to retrieve * information provided by the service. * @throws SecurityException if something other than the profile or device owner, or the * current VR service tries to retrieve information provided by this service. */ private void enforceHardwarePropertiesRetrievalAllowed(String callingPackage) throws SecurityException { final PackageManager pm = mContext.getPackageManager(); int uid = 0; try { final int uid = pm.getPackageUid(callingPackage, 0); uid = pm.getPackageUid(callingPackage, 0); if (Binder.getCallingUid() != uid) { throw new SecurityException("The caller has faked the package name."); } Loading @@ -93,10 +96,13 @@ public class HardwarePropertiesManagerService extends IHardwarePropertiesManager 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) && Binder.getCallingUid() != Process.SYSTEM_UID) { throw new SecurityException("The caller is not a device or profile owner or system."); && !vrService.isCurrentVrListener(callingPackage, userId)) { throw new SecurityException("The caller is not a device or profile owner or bound " + "VrListenerService."); } } } services/core/java/com/android/server/vr/VrManagerInternal.java +11 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,17 @@ public abstract class VrManagerInternal { */ public abstract boolean isInVrMode(); /** * Return {@code true} if the given package is the currently bound VrListenerService for the * given user. * * @param packageName The package name to check. * @param userId the user ID to check the package name for. * * @return {@code true} if the given package is the currently bound VrListenerService. */ public abstract boolean isCurrentVrListener(String packageName, int userId); /** * Set the current VR mode state. * Loading services/core/java/com/android/server/vr/VrManagerService.java +15 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,11 @@ public class VrManagerService extends SystemService implements EnabledComponentC VrManagerService.this.setVrMode(enabled, packageName, userId, callingPackage); } @Override public boolean isCurrentVrListener(String packageName, int userId) { return VrManagerService.this.isCurrentVrListener(packageName, userId); } @Override public void registerListener(VrStateListener listener) { VrManagerService.this.addListener(listener); Loading Loading @@ -355,6 +360,16 @@ public class VrManagerService extends SystemService implements EnabledComponentC } } private boolean isCurrentVrListener(String packageName, int userId) { synchronized (mLock) { if (mCurrentVrService == null) { return false; } return mCurrentVrService.getComponent().getPackageName().equals(packageName) && userId == mCurrentVrService.getUserId(); } } private void addListener(VrStateListener listener) { synchronized (mLock) { mListeners.add(listener); Loading Loading
core/java/android/os/HardwarePropertiesManager.java +6 −3 Original line number Diff line number Diff line Loading @@ -101,7 +101,8 @@ public class HardwarePropertiesManager { * {@link #UNDEFINED_TEMPERATURE} if undefined. * Empty if platform doesn't provide the queried temperature. * * @throws SecurityException if a non profile or device owner tries to call this method. * @throws SecurityException if something other than the profile or device owner, or the * current VR service tries to retrieve information provided by this service. */ public @NonNull float[] getDeviceTemperatures(@DeviceTemperatureType int type, @TemperatureSource int source) { Loading Loading @@ -137,7 +138,8 @@ public class HardwarePropertiesManager { * each unplugged core. * Empty if CPU usage is not supported on this system. * * @throws SecurityException if a non profile or device owner tries to call this method. * @throws SecurityException if something other than the profile or device owner, or the * current VR service tries to retrieve information provided by this service. */ public @NonNull CpuUsageInfo[] getCpuUsages() { try { Loading @@ -153,7 +155,8 @@ public class HardwarePropertiesManager { * @return an array of float fan speeds in RPM. Empty if there are no fans or fan speed is not * supported on this system. * * @throws SecurityException if a non profile or device owner tries to call this method. * @throws SecurityException if something other than the profile or device owner, or the * current VR service tries to retrieve information provided by this service. */ public @NonNull float[] getFanSpeeds() { try { Loading
services/core/java/com/android/server/HardwarePropertiesManagerService.java +11 −5 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import android.os.Binder; import android.os.CpuUsageInfo; import android.os.IHardwarePropertiesManager; import android.os.Process; import android.os.UserHandle; import com.android.server.vr.VrManagerInternal; import java.util.Arrays; Loading Loading @@ -78,14 +80,15 @@ public class HardwarePropertiesManagerService extends IHardwarePropertiesManager * * @param callingPackage The calling package name. * * @throws SecurityException if a non profile or device owner or system tries to retrieve * information provided by the service. * @throws SecurityException if something other than the profile or device owner, or the * current VR service tries to retrieve information provided by this service. */ private void enforceHardwarePropertiesRetrievalAllowed(String callingPackage) throws SecurityException { final PackageManager pm = mContext.getPackageManager(); int uid = 0; try { final int uid = pm.getPackageUid(callingPackage, 0); uid = pm.getPackageUid(callingPackage, 0); if (Binder.getCallingUid() != uid) { throw new SecurityException("The caller has faked the package name."); } Loading @@ -93,10 +96,13 @@ public class HardwarePropertiesManagerService extends IHardwarePropertiesManager 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) && Binder.getCallingUid() != Process.SYSTEM_UID) { throw new SecurityException("The caller is not a device or profile owner or system."); && !vrService.isCurrentVrListener(callingPackage, userId)) { throw new SecurityException("The caller is not a device or profile owner or bound " + "VrListenerService."); } } }
services/core/java/com/android/server/vr/VrManagerInternal.java +11 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,17 @@ public abstract class VrManagerInternal { */ public abstract boolean isInVrMode(); /** * Return {@code true} if the given package is the currently bound VrListenerService for the * given user. * * @param packageName The package name to check. * @param userId the user ID to check the package name for. * * @return {@code true} if the given package is the currently bound VrListenerService. */ public abstract boolean isCurrentVrListener(String packageName, int userId); /** * Set the current VR mode state. * Loading
services/core/java/com/android/server/vr/VrManagerService.java +15 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,11 @@ public class VrManagerService extends SystemService implements EnabledComponentC VrManagerService.this.setVrMode(enabled, packageName, userId, callingPackage); } @Override public boolean isCurrentVrListener(String packageName, int userId) { return VrManagerService.this.isCurrentVrListener(packageName, userId); } @Override public void registerListener(VrStateListener listener) { VrManagerService.this.addListener(listener); Loading Loading @@ -355,6 +360,16 @@ public class VrManagerService extends SystemService implements EnabledComponentC } } private boolean isCurrentVrListener(String packageName, int userId) { synchronized (mLock) { if (mCurrentVrService == null) { return false; } return mCurrentVrService.getComponent().getPackageName().equals(packageName) && userId == mCurrentVrService.getUserId(); } } private void addListener(VrStateListener listener) { synchronized (mLock) { mListeners.add(listener); Loading