Merge "SettingsLib: Fix assertThat in test"
diff --git a/core/java/android/bluetooth/BluetoothUuid.java b/core/java/android/bluetooth/BluetoothUuid.java
index 0a0d214..605dbd2 100644
--- a/core/java/android/bluetooth/BluetoothUuid.java
+++ b/core/java/android/bluetooth/BluetoothUuid.java
@@ -79,9 +79,8 @@
             ParcelUuid.fromString("00001132-0000-1000-8000-00805F9B34FB");
     public static final ParcelUuid SAP =
             ParcelUuid.fromString("0000112D-0000-1000-8000-00805F9B34FB");
-    /* TODO: b/69623109 update this value. It will change to 16bit UUID!! */
     public static final ParcelUuid HearingAid =
-            ParcelUuid.fromString("7312C48F-22CC-497F-85FD-A0616A3B9E05");
+            ParcelUuid.fromString("0000FDF0-0000-1000-8000-00805f9b34fb");
 
     public static final ParcelUuid BASE_UUID =
             ParcelUuid.fromString("00000000-0000-1000-8000-00805F9B34FB");
diff --git a/core/jni/android/opengl/util.cpp b/core/jni/android/opengl/util.cpp
index 888db32..b163597 100644
--- a/core/jni/android/opengl/util.cpp
+++ b/core/jni/android/opengl/util.cpp
@@ -622,29 +622,25 @@
 
 // ---------------------------------------------------------------------------
 
-static int checkInternalFormat(SkColorType colorType, int format, int type)
+static int checkInternalFormat(SkColorType colorType, int internalformat,
+    int type)
 {
     switch(colorType) {
         case kN32_SkColorType:
+            return (type == GL_UNSIGNED_BYTE &&
+                internalformat == GL_RGBA) ? 0 : -1;
         case kAlpha_8_SkColorType:
-            if (type == GL_UNSIGNED_BYTE)
-                return 0;
+            return (type == GL_UNSIGNED_BYTE &&
+                internalformat == GL_ALPHA) ? 0 : -1;
         case kARGB_4444_SkColorType:
+            return (type == GL_UNSIGNED_SHORT_4_4_4_4 &&
+                internalformat == GL_RGBA) ? 0 : -1;
         case kRGB_565_SkColorType:
-            switch (type) {
-                case GL_UNSIGNED_SHORT_4_4_4_4:
-                case GL_UNSIGNED_SHORT_5_6_5:
-                case GL_UNSIGNED_SHORT_5_5_5_1:
-                    return 0;
-                case GL_UNSIGNED_BYTE:
-                    if (format == GL_LUMINANCE_ALPHA)
-                        return 0;
-            }
-            break;
+            return (type == GL_UNSIGNED_SHORT_5_6_5 &&
+                internalformat == GL_RGB) ? 0 : -1;
         case kRGBA_F16_SkColorType:
-            if (type == GL_HALF_FLOAT && format == GL_RGBA16F)
-                return 0;
-            break;
+            return (type == GL_HALF_FLOAT &&
+                internalformat == GL_RGBA16F) ? 0 : -1;
         default:
             break;
     }
diff --git a/core/proto/android/server/jobscheduler.proto b/core/proto/android/server/jobscheduler.proto
index 2d31c5a..69abed3 100644
--- a/core/proto/android/server/jobscheduler.proto
+++ b/core/proto/android/server/jobscheduler.proto
@@ -36,6 +36,11 @@
 
     optional ConstantsProto settings = 1;
 
+    optional int32 current_heartbeat = 14;
+    repeated int32 next_heartbeat = 15;
+    optional int64 last_heartbeat_time_millis = 16;
+    optional int64 next_heartbeat_time_millis = 17;
+
     repeated int32 started_users = 2;
 
     message RegisteredJob {
@@ -54,6 +59,8 @@
         optional bool is_job_currently_active = 6;
         optional bool is_uid_backing_up = 7;
         optional bool is_component_present = 8;
+
+        optional int64 last_run_heartbeat = 9;
     }
     repeated RegisteredJob registered_jobs = 3;
 
diff --git a/core/tests/coretests/assets/fonts/ascent10em-descent10em.ttf b/core/tests/coretests/assets/fonts/ascent10em-descent10em.ttf
new file mode 100644
index 0000000..47ab623
--- /dev/null
+++ b/core/tests/coretests/assets/fonts/ascent10em-descent10em.ttf
Binary files differ
diff --git a/core/tests/coretests/assets/fonts/ascent10em-descent10em.ttx b/core/tests/coretests/assets/fonts/ascent10em-descent10em.ttx
new file mode 100644
index 0000000..5540277
--- /dev/null
+++ b/core/tests/coretests/assets/fonts/ascent10em-descent10em.ttx
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="3.0">
+
+  <GlyphOrder>
+    <GlyphID id="0" name=".notdef"/>
+    <GlyphID id="1" name="1em"/>
+  </GlyphOrder>
+
+  <head>
+    <tableVersion value="1.0"/>
+    <fontRevision value="1.0"/>
+    <checkSumAdjustment value="0x640cdb2f"/>
+    <magicNumber value="0x5f0f3cf5"/>
+    <flags value="00000000 00000011"/>
+    <unitsPerEm value="1000"/>
+    <created value="Fri Mar 17 07:26:00 2017"/>
+    <macStyle value="00000000 00000000"/>
+    <lowestRecPPEM value="7"/>
+    <fontDirectionHint value="2"/>
+    <glyphDataFormat value="0"/>
+  </head>
+
+  <hhea>
+    <tableVersion value="0x10000"/>
+    <ascent value="10000"/>
+    <descent value="-10000"/>
+    <lineGap value="0"/>
+    <caretSlopeRise value="1"/>
+    <caretSlopeRun value="0"/>
+    <caretOffset value="0"/>
+    <reserved0 value="0"/>
+    <reserved1 value="0"/>
+    <reserved2 value="0"/>
+    <reserved3 value="0"/>
+    <metricDataFormat value="0"/>
+  </hhea>
+
+  <maxp>
+    <tableVersion value="0x10000"/>
+    <maxZones value="0"/>
+    <maxTwilightPoints value="0"/>
+    <maxStorage value="0"/>
+    <maxFunctionDefs value="0"/>
+    <maxInstructionDefs value="0"/>
+    <maxStackElements value="0"/>
+    <maxSizeOfInstructions value="0"/>
+    <maxComponentElements value="0"/>
+  </maxp>
+
+  <OS_2>
+    <!-- The fields 'usFirstCharIndex' and 'usLastCharIndex'
+         will be recalculated by the compiler -->
+    <version value="3"/>
+    <xAvgCharWidth value="594"/>
+    <usWeightClass value="400"/>
+    <usWidthClass value="5"/>
+    <fsType value="00000000 00001000"/>
+    <ySubscriptXSize value="650"/>
+    <ySubscriptYSize value="600"/>
+    <ySubscriptXOffset value="0"/>
+    <ySubscriptYOffset value="75"/>
+    <ySuperscriptXSize value="650"/>
+    <ySuperscriptYSize value="600"/>
+    <ySuperscriptXOffset value="0"/>
+    <ySuperscriptYOffset value="350"/>
+    <yStrikeoutSize value="50"/>
+    <yStrikeoutPosition value="300"/>
+    <sFamilyClass value="0"/>
+    <panose>
+      <bFamilyType value="0"/>
+      <bSerifStyle value="0"/>
+      <bWeight value="5"/>
+      <bProportion value="0"/>
+      <bContrast value="0"/>
+      <bStrokeVariation value="0"/>
+      <bArmStyle value="0"/>
+      <bLetterForm value="0"/>
+      <bMidline value="0"/>
+      <bXHeight value="0"/>
+    </panose>
+    <ulUnicodeRange1 value="00000000 00000000 00000000 00000001"/>
+    <ulUnicodeRange2 value="00000000 00000000 00000000 00000000"/>
+    <ulUnicodeRange3 value="00000000 00000000 00000000 00000000"/>
+    <ulUnicodeRange4 value="00000000 00000000 00000000 00000000"/>
+    <achVendID value="UKWN"/>
+    <fsSelection value="00000000 01000000"/>
+    <usFirstCharIndex value="32"/>
+    <usLastCharIndex value="122"/>
+    <sTypoAscender value="800"/>
+    <sTypoDescender value="-200"/>
+    <sTypoLineGap value="200"/>
+    <usWinAscent value="1000"/>
+    <usWinDescent value="200"/>
+    <ulCodePageRange1 value="00000000 00000000 00000000 00000001"/>
+    <ulCodePageRange2 value="00000000 00000000 00000000 00000000"/>
+    <sxHeight value="500"/>
+    <sCapHeight value="700"/>
+    <usDefaultChar value="0"/>
+    <usBreakChar value="32"/>
+    <usMaxContext value="0"/>
+  </OS_2>
+
+  <hmtx>
+    <mtx name=".notdef" width="1000" lsb="0"/>
+    <mtx name="1em" width="1000" lsb="0"/>
+  </hmtx>
+
+  <cmap>
+    <tableVersion version="0"/>
+    <cmap_format_4 platformID="3" platEncID="10" language="0">
+      <map code="0x000A" name="1em" /> <!-- LINE FEED -->
+      <map code="0x000D" name="1em" /> <!-- CARRIAGE RETURN -->
+    </cmap_format_4>
+  </cmap>
+
+  <loca>
+    <!-- The 'loca' table will be calculated by the compiler -->
+  </loca>
+
+  <glyf>
+    <TTGlyph name=".notdef" xMin="0" yMin="0" xMax="0" yMax="0" />
+    <TTGlyph name="1em" xMin="0" yMin="0" xMax="0" yMax="0" />
+  </glyf>
+
+  <name>
+    <namerecord nameID="0" platformID="3" platEncID="1" langID="0x409">
+      Copyright (C) 2017 The Android Open Source Project
+    </namerecord>
+    <namerecord nameID="1" platformID="3" platEncID="1" langID="0x409">
+      Sample Font
+    </namerecord>
+    <namerecord nameID="2" platformID="3" platEncID="1" langID="0x409">
+      Regular
+    </namerecord>
+    <namerecord nameID="4" platformID="3" platEncID="1" langID="0x409">
+      Sample Font
+    </namerecord>
+    <namerecord nameID="6" platformID="3" platEncID="1" langID="0x409">
+      SampleFont-Regular
+    </namerecord>
+    <namerecord nameID="13" platformID="3" platEncID="1" langID="0x409">
+      Licensed under the Apache License, Version 2.0 (the "License");
+      you may not use this file except in compliance with the License.
+      Unless required by applicable law or agreed to in writing, software
+      distributed under the License is distributed on an "AS IS" BASIS
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+      See the License for the specific language governing permissions and
+      limitations under the License.
+    </namerecord>
+    <namerecord nameID="14" platformID="3" platEncID="1" langID="0x409">
+      http://www.apache.org/licenses/LICENSE-2.0
+    </namerecord>
+  </name>
+
+  <post>
+    <formatType value="3.0"/>
+    <italicAngle value="0.0"/>
+    <underlinePosition value="-75"/>
+    <underlineThickness value="50"/>
+    <isFixedPitch value="0"/>
+    <minMemType42 value="0"/>
+    <maxMemType42 value="0"/>
+    <minMemType1 value="0"/>
+    <maxMemType1 value="0"/>
+  </post>
+
+</ttFont>
diff --git a/core/tests/coretests/src/android/text/StaticLayoutTest.java b/core/tests/coretests/src/android/text/StaticLayoutTest.java
index d817278..2521712 100644
--- a/core/tests/coretests/src/android/text/StaticLayoutTest.java
+++ b/core/tests/coretests/src/android/text/StaticLayoutTest.java
@@ -822,6 +822,9 @@
                 + "  <family>"
                 + "    <font weight='400' style='normal'>ascent3em-descent4em.ttf</font>"
                 + "  </family>"
+                + "  <family>"
+                + "    <font weight='400' style='normal'>ascent10em-descent10em.ttf</font>"
+                + "  </family>"
                 + "</familyset>";
 
         try (FontFallbackSetup setup =
@@ -833,7 +836,7 @@
             assertEquals(2 * textSize, paint.descent(), 0.0f);
 
             final int paraWidth = 5 * textSize;
-            final String text = "aaaaa aabaa aaaaa"; // This should result in three lines.
+            final String text = "aaaaa\naabaa\naaaaa\n"; // This should result in three lines.
 
             // Old line spacing. All lines should get their ascent and descents from the first font.
             StaticLayout layout = StaticLayout.Builder
@@ -841,13 +844,17 @@
                     .setIncludePad(false)
                     .setUseLineSpacingFromFallbacks(false)
                     .build();
-            assertEquals(3, layout.getLineCount());
+            assertEquals(4, layout.getLineCount());
             assertEquals(-textSize, layout.getLineAscent(0));
             assertEquals(2 * textSize, layout.getLineDescent(0));
             assertEquals(-textSize, layout.getLineAscent(1));
             assertEquals(2 * textSize, layout.getLineDescent(1));
             assertEquals(-textSize, layout.getLineAscent(2));
             assertEquals(2 * textSize, layout.getLineDescent(2));
+            // The last empty line spacing should be the default line spacing.
+            // Maybe good to be a previous line spacing?
+            assertEquals(-textSize, layout.getLineAscent(3));
+            assertEquals(2 * textSize, layout.getLineDescent(3));
 
             // New line spacing. The second line has a 'b', so it needs more ascent and descent.
             layout = StaticLayout.Builder
@@ -855,26 +862,52 @@
                     .setIncludePad(false)
                     .setUseLineSpacingFromFallbacks(true)
                     .build();
-            assertEquals(3, layout.getLineCount());
+            assertEquals(4, layout.getLineCount());
             assertEquals(-textSize, layout.getLineAscent(0));
             assertEquals(2 * textSize, layout.getLineDescent(0));
             assertEquals(-3 * textSize, layout.getLineAscent(1));
             assertEquals(4 * textSize, layout.getLineDescent(1));
             assertEquals(-textSize, layout.getLineAscent(2));
             assertEquals(2 * textSize, layout.getLineDescent(2));
+            assertEquals(-textSize, layout.getLineAscent(3));
+            assertEquals(2 * textSize, layout.getLineDescent(3));
 
             // The default is the old line spacing, for backward compatibility.
             layout = StaticLayout.Builder
                     .obtain(text, 0, text.length(), paint, paraWidth)
                     .setIncludePad(false)
                     .build();
-            assertEquals(3, layout.getLineCount());
+            assertEquals(4, layout.getLineCount());
             assertEquals(-textSize, layout.getLineAscent(0));
             assertEquals(2 * textSize, layout.getLineDescent(0));
             assertEquals(-textSize, layout.getLineAscent(1));
             assertEquals(2 * textSize, layout.getLineDescent(1));
             assertEquals(-textSize, layout.getLineAscent(2));
             assertEquals(2 * textSize, layout.getLineDescent(2));
+            assertEquals(-textSize, layout.getLineAscent(3));
+            assertEquals(2 * textSize, layout.getLineDescent(3));
+
+            layout = StaticLayout.Builder
+                    .obtain("\n", 0, 1, paint, textSize)
+                    .setIncludePad(false)
+                    .setUseLineSpacingFromFallbacks(false)
+                    .build();
+            assertEquals(2, layout.getLineCount());
+            assertEquals(-textSize, layout.getLineAscent(0));
+            assertEquals(2 * textSize, layout.getLineDescent(0));
+            assertEquals(-textSize, layout.getLineAscent(1));
+            assertEquals(2 * textSize, layout.getLineDescent(1));
+
+            layout = StaticLayout.Builder
+                    .obtain("\n", 0, 1, paint, textSize)
+                    .setIncludePad(false)
+                    .setUseLineSpacingFromFallbacks(true)
+                    .build();
+            assertEquals(2, layout.getLineCount());
+            assertEquals(-textSize, layout.getLineAscent(0));
+            assertEquals(2 * textSize, layout.getLineDescent(0));
+            assertEquals(-textSize, layout.getLineAscent(1));
+            assertEquals(2 * textSize, layout.getLineDescent(1));
         }
     }
 
diff --git a/packages/SettingsLib/src/com/android/settingslib/utils/IconCache.java b/packages/SettingsLib/src/com/android/settingslib/utils/IconCache.java
new file mode 100644
index 0000000..3d55c4f
--- /dev/null
+++ b/packages/SettingsLib/src/com/android/settingslib/utils/IconCache.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settingslib.utils;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.Icon;
+import android.support.annotation.VisibleForTesting;
+import android.support.v4.util.ArrayMap;
+
+
+/**
+ * Icon cache to avoid multiple loads on the same icon.
+ */
+public class IconCache {
+    private final Context mContext;
+    @VisibleForTesting
+    final ArrayMap<Icon, Drawable> mMap = new ArrayMap<>();
+
+    public IconCache(Context context) {
+        mContext = context;
+    }
+
+    public Drawable getIcon(Icon icon) {
+        if (icon == null) {
+            return null;
+        }
+        Drawable drawable = mMap.get(icon);
+        if (drawable == null) {
+            drawable = icon.loadDrawable(mContext);
+            updateIcon(icon, drawable);
+        }
+        return drawable;
+    }
+
+    public void updateIcon(Icon icon, Drawable drawable) {
+        mMap.put(icon, drawable);
+    }
+}
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/utils/IconCacheTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/utils/IconCacheTest.java
new file mode 100644
index 0000000..026ad47
--- /dev/null
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/utils/IconCacheTest.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settingslib.utils;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static junit.framework.Assert.assertTrue;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.Icon;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class IconCacheTest {
+    private Icon mIcon;
+    private Context mContext;
+    private IconCache mIconCache;
+
+    @Before
+    public void setUp() {
+        mContext = spy(RuntimeEnvironment.application);
+        mIcon = mock(Icon.class);
+        Drawable drawable = mock(Drawable.class);
+        doReturn(drawable).when(mIcon).loadDrawable(mContext);
+        mIconCache = new IconCache(mContext);
+    }
+
+    @Test
+    public void testGetIcon_iconisNull() {
+        assertThat(mIconCache.getIcon(null)).isNull();
+    }
+
+    @Test
+    public void testGetIcon_iconAlreadyLoaded() {
+        mIconCache.getIcon(mIcon);
+        verify(mIcon, times(1)).loadDrawable(mContext);
+        mIconCache.getIcon(mIcon);
+        verify(mIcon, times(1)).loadDrawable(mContext);
+    }
+
+    @Test
+    public void testGetIcon_iconLoadedFirstTime() {
+        mIconCache.getIcon(mIcon);
+        assertTrue(mIconCache.mMap.containsKey(mIcon));
+    }
+}
diff --git a/services/core/java/com/android/server/job/JobSchedulerService.java b/services/core/java/com/android/server/job/JobSchedulerService.java
index 55d5785..0e7e540 100644
--- a/services/core/java/com/android/server/job/JobSchedulerService.java
+++ b/services/core/java/com/android/server/job/JobSchedulerService.java
@@ -87,6 +87,7 @@
 import com.android.server.LocalServices;
 import com.android.server.job.JobSchedulerServiceDumpProto.ActiveJob;
 import com.android.server.job.JobSchedulerServiceDumpProto.PendingJob;
+import com.android.server.job.JobSchedulerServiceDumpProto.RegisteredJob;
 import com.android.server.job.controllers.AppIdleController;
 import com.android.server.job.controllers.BackgroundJobsController;
 import com.android.server.job.controllers.BatteryController;
@@ -2937,6 +2938,23 @@
         synchronized (mLock) {
             mConstants.dump(pw);
             pw.println();
+
+            pw.println("  Heartbeat:");
+            pw.print("    Current:    "); pw.println(mHeartbeat);
+            pw.println("    Next");
+            pw.print("      ACTIVE:   "); pw.println(mNextBucketHeartbeat[0]);
+            pw.print("      WORKING:  "); pw.println(mNextBucketHeartbeat[1]);
+            pw.print("      FREQUENT: "); pw.println(mNextBucketHeartbeat[2]);
+            pw.print("      RARE:     "); pw.println(mNextBucketHeartbeat[3]);
+            pw.print("    Last heartbeat: ");
+            TimeUtils.formatDuration(mLastHeartbeatTime, nowElapsed, pw);
+            pw.println();
+            pw.print("    Next heartbeat: ");
+            TimeUtils.formatDuration(mLastHeartbeatTime + mConstants.STANDBY_HEARTBEAT_TIME,
+                    nowElapsed, pw);
+            pw.println();
+            pw.println();
+
             pw.println("Started users: " + Arrays.toString(mStartedUsers));
             pw.print("Registered ");
             pw.print(mJobs.size());
@@ -2954,6 +2972,10 @@
                     }
 
                     job.dump(pw, "    ", true, nowElapsed);
+                    pw.print("    Last run heartbeat: ");
+                    pw.print(heartbeatWhenJobsLastRun(job));
+                    pw.println();
+
                     pw.print("    Ready: ");
                     pw.print(isReadyToBeExecutedLocked(job));
                     pw.print(" (job=");
@@ -3096,6 +3118,16 @@
 
         synchronized (mLock) {
             mConstants.dump(proto, JobSchedulerServiceDumpProto.SETTINGS);
+            proto.write(JobSchedulerServiceDumpProto.CURRENT_HEARTBEAT, mHeartbeat);
+            proto.write(JobSchedulerServiceDumpProto.NEXT_HEARTBEAT, mNextBucketHeartbeat[0]);
+            proto.write(JobSchedulerServiceDumpProto.NEXT_HEARTBEAT, mNextBucketHeartbeat[1]);
+            proto.write(JobSchedulerServiceDumpProto.NEXT_HEARTBEAT, mNextBucketHeartbeat[2]);
+            proto.write(JobSchedulerServiceDumpProto.NEXT_HEARTBEAT, mNextBucketHeartbeat[3]);
+            proto.write(JobSchedulerServiceDumpProto.LAST_HEARTBEAT_TIME_MILLIS,
+                    mLastHeartbeatTime - nowUptime);
+            proto.write(JobSchedulerServiceDumpProto.NEXT_HEARTBEAT_TIME_MILLIS,
+                    mLastHeartbeatTime + mConstants.STANDBY_HEARTBEAT_TIME - nowUptime);
+
             for (int u : mStartedUsers) {
                 proto.write(JobSchedulerServiceDumpProto.STARTED_USERS, u);
             }
@@ -3134,6 +3166,7 @@
                     }
                     proto.write(JobSchedulerServiceDumpProto.RegisteredJob.IS_COMPONENT_PRESENT,
                             componentPresent);
+                    proto.write(RegisteredJob.LAST_RUN_HEARTBEAT, heartbeatWhenJobsLastRun(job));
 
                     proto.end(rjToken);
                 }
diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
index a7fc470..ef0780a 100644
--- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java
+++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
@@ -1359,9 +1359,7 @@
                             UsbManager.USB_FUNCTION_NONE).equals(
                             getSystemProperty(USB_STATE_PROPERTY, UsbManager.USB_FUNCTION_NONE));
                 }
-                // Mask out adb, since it is stored in mAdbEnabled
-                mCurrentFunctions = UsbManager.usbFunctionsFromString(mCurrentFunctionsStr)
-                        & ~UsbManager.FUNCTION_ADB;
+                mCurrentFunctions = UsbManager.FUNCTION_NONE;
                 mCurrentUsbFunctionsReceived = true;
 
                 String state = FileUtils.readTextFile(new File(STATE_PATH), 0, null).trim();