summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Rick Yiu <rickyiu@google.com> 2018-09-08 18:05:30 +0800
committer Rick Yiu <rickyiu@google.com> 2018-09-08 18:34:04 +0800
commitecf80f0e7ea5448efe4dcd43c1cefce201ce90ee (patch)
treec532862609c868668a52bc66a04fa4319cee1323
parent7a5a757c2b548411de77063e2eaf0b10e678bcde (diff)
Add null check for vrManager
If VrManagerService is not started, vrManager will be null. Need add check for it. Test: system does not break if VrManagerService is not started Bug: 112064298 Change-Id: I3c1d78247043feca3d1a195f28567d622483a318
-rw-r--r--services/core/java/com/android/server/HardwarePropertiesManagerService.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/HardwarePropertiesManagerService.java b/services/core/java/com/android/server/HardwarePropertiesManagerService.java
index 4016d29fd2e6..c593af7cda0a 100644
--- a/services/core/java/com/android/server/HardwarePropertiesManagerService.java
+++ b/services/core/java/com/android/server/HardwarePropertiesManagerService.java
@@ -26,7 +26,6 @@ import static android.os.HardwarePropertiesManager.TEMPERATURE_THROTTLING;
import static android.os.HardwarePropertiesManager.TEMPERATURE_THROTTLING_BELOW_VR_MIN;
import android.Manifest;
-import android.app.ActivityManager;
import android.app.AppOpsManager;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
@@ -34,8 +33,8 @@ import android.content.pm.PackageManager;
import android.os.Binder;
import android.os.CpuUsageInfo;
import android.os.IHardwarePropertiesManager;
-import android.os.Process;
import android.os.UserHandle;
+
import com.android.internal.util.DumpUtils;
import com.android.server.vr.VrManagerInternal;
@@ -166,12 +165,14 @@ public class HardwarePropertiesManagerService extends IHardwarePropertiesManager
final VrManagerInternal vrService = LocalServices.getService(VrManagerInternal.class);
final DevicePolicyManager dpm = mContext.getSystemService(DevicePolicyManager.class);
if (!dpm.isDeviceOwnerApp(callingPackage)
- && !vrService.isCurrentVrListener(callingPackage, userId)
&& mContext.checkCallingOrSelfPermission(Manifest.permission.DEVICE_POWER)
!= PackageManager.PERMISSION_GRANTED) {
- throw new SecurityException("The caller is not a device owner, bound VrListenerService"
+ throw new SecurityException("The caller is not a device owner"
+ ", or holding the DEVICE_POWER permission.");
}
+ if (vrService != null && !vrService.isCurrentVrListener(callingPackage, userId)) {
+ throw new SecurityException("The caller is not bound VrListenerService.");
+ }
}
}