Merge "Fix NPE when trying to add starting window"
diff --git a/core/java/android/os/HardwarePropertiesManager.java b/core/java/android/os/HardwarePropertiesManager.java
index 2b00ecb..67edefc 100644
--- a/core/java/android/os/HardwarePropertiesManager.java
+++ b/core/java/android/os/HardwarePropertiesManager.java
@@ -109,8 +109,8 @@
      *         {@link #UNDEFINED_TEMPERATURE} if undefined.
      *         Empty if platform doesn't provide the queried temperature.
      *
-     * @throws SecurityException if something other than the profile or device owner, or the
-     *        current VR service tries to retrieve information provided by this service.
+     * @throws SecurityException if something other than the 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) {
@@ -147,8 +147,8 @@
      *         each unplugged core.
      *         Empty if CPU usage is not supported on this system.
      *
-     * @throws SecurityException if something other than the profile or device owner, or the
-     *        current VR service tries to retrieve information provided by this service.
+     * @throws SecurityException if something other than the device owner or the current VR service
+     *         tries to retrieve information provided by this service.
      */
     public @NonNull CpuUsageInfo[] getCpuUsages() {
         try {
@@ -164,8 +164,8 @@
      * @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 something other than the profile or device owner, or the
-     *        current VR service tries to retrieve information provided by this service.
+     * @throws SecurityException if something other than the device owner or the current VR service
+     *         tries to retrieve information provided by this service.
      */
     public @NonNull float[] getFanSpeeds() {
         try {
diff --git a/services/core/java/com/android/server/HardwarePropertiesManagerService.java b/services/core/java/com/android/server/HardwarePropertiesManagerService.java
index 36a16cd..e03a478 100644
--- a/services/core/java/com/android/server/HardwarePropertiesManagerService.java
+++ b/services/core/java/com/android/server/HardwarePropertiesManagerService.java
@@ -82,9 +82,9 @@
      *
      * @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.
+     * @throws SecurityException if something other than the 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 {
@@ -102,12 +102,12 @@
         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)
+        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 or profile owner, bound "
-                + "VrListenerService, or holding the DEVICE_POWER permission.");
+            throw new SecurityException("The caller is not a device owner, bound VrListenerService"
+                + ", or holding the DEVICE_POWER permission.");
         }
     }
 }
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 46edf43..cfd2bed 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -4360,8 +4360,9 @@
         Preconditions.checkArgument(timeoutMs >= 0, "Timeout must not be a negative number.");
         // timeoutMs with value 0 means that the admin doesn't participate
         // timeoutMs is clamped to the interval in case the internal constants change in the future
-        if (timeoutMs != 0 && timeoutMs < MINIMUM_STRONG_AUTH_TIMEOUT_MS) {
-            timeoutMs = MINIMUM_STRONG_AUTH_TIMEOUT_MS;
+        final long minimumStrongAuthTimeout = getMinimumStrongAuthTimeoutMs();
+        if (timeoutMs != 0 && timeoutMs < minimumStrongAuthTimeout) {
+            timeoutMs = minimumStrongAuthTimeout;
         }
         if (timeoutMs > DevicePolicyManager.DEFAULT_STRONG_AUTH_TIMEOUT_MS) {
             timeoutMs = DevicePolicyManager.DEFAULT_STRONG_AUTH_TIMEOUT_MS;
@@ -4405,10 +4406,21 @@
                     strongAuthUnlockTimeout = Math.min(timeout, strongAuthUnlockTimeout);
                 }
             }
-            return Math.max(strongAuthUnlockTimeout, MINIMUM_STRONG_AUTH_TIMEOUT_MS);
+            return Math.max(strongAuthUnlockTimeout, getMinimumStrongAuthTimeoutMs());
         }
     }
 
+    private long getMinimumStrongAuthTimeoutMs() {
+        if (!mInjector.isBuildDebuggable()) {
+            return MINIMUM_STRONG_AUTH_TIMEOUT_MS;
+        }
+        // ideally the property was named persist.sys.min_strong_auth_timeout, but system property
+        // name cannot be longer than 31 characters
+        return Math.min(mInjector.systemPropertiesGetLong("persist.sys.min_str_auth_timeo",
+                MINIMUM_STRONG_AUTH_TIMEOUT_MS),
+                MINIMUM_STRONG_AUTH_TIMEOUT_MS);
+    }
+
     @Override
     public void lockNow(int flags, boolean parent) {
         if (!mHasFeature) {