Merge "Close file descriptors of ProfilerInfo"
diff --git a/Android.mk b/Android.mk
index bbe2faf..e2f88e8 100644
--- a/Android.mk
+++ b/Android.mk
@@ -868,8 +868,12 @@
 
 $(eval $(call copy-one-file,frameworks/base/config/hiddenapi-blacklist.txt,\
                             $(INTERNAL_PLATFORM_HIDDENAPI_BLACKLIST)))
-$(eval $(call copy-one-file,frameworks/base/config/hiddenapi-light-greylist.txt,\
-                            $(INTERNAL_PLATFORM_HIDDENAPI_LIGHT_GREYLIST)))
+
+# Temporarily merge light greylist from two files. Vendor list will become dark
+# grey once we remove the UI toast.
+$(INTERNAL_PLATFORM_HIDDENAPI_LIGHT_GREYLIST): frameworks/base/config/hiddenapi-light-greylist.txt \
+                                               frameworks/base/config/hiddenapi-vendor-list.txt
+	sort $^ > $@
 
 # Generate dark greylist as private API minus (blacklist plus light greylist).
 
diff --git a/api/current.txt b/api/current.txt
index b4373e5..3d2db18 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -6331,6 +6331,7 @@
     method public java.lang.CharSequence loadDescription(android.content.pm.PackageManager) throws android.content.res.Resources.NotFoundException;
     method public android.graphics.drawable.Drawable loadIcon(android.content.pm.PackageManager);
     method public java.lang.CharSequence loadLabel(android.content.pm.PackageManager);
+    method public boolean supportsTransferOwnership();
     method public boolean usesPolicy(int);
     method public void writeToParcel(android.os.Parcel, int);
     field public static final android.os.Parcelable.Creator<android.app.admin.DeviceAdminInfo> CREATOR;
@@ -6395,7 +6396,6 @@
     field public static final java.lang.String EXTRA_DISABLE_WARNING = "android.app.extra.DISABLE_WARNING";
     field public static final java.lang.String EXTRA_LOCK_TASK_PACKAGE = "android.app.extra.LOCK_TASK_PACKAGE";
     field public static final java.lang.String EXTRA_TRANSFER_OWNERSHIP_ADMIN_EXTRAS_BUNDLE = "android.app.extra.TRANSFER_OWNERSHIP_ADMIN_EXTRAS_BUNDLE";
-    field public static final java.lang.String SUPPORT_TRANSFER_OWNERSHIP_META_DATA = "android.app.support_transfer_ownership";
   }
 
   public class DeviceAdminService extends android.app.Service {
@@ -21247,9 +21247,10 @@
     method public final boolean switchToPreviousInputMethod();
     method public void updateFullscreenMode();
     method public void updateInputViewShown();
+    field public static final int BACK_DISPOSITION_ADJUST_NOTHING = 3; // 0x3
     field public static final int BACK_DISPOSITION_DEFAULT = 0; // 0x0
-    field public static final int BACK_DISPOSITION_WILL_DISMISS = 2; // 0x2
-    field public static final int BACK_DISPOSITION_WILL_NOT_DISMISS = 1; // 0x1
+    field public static final deprecated int BACK_DISPOSITION_WILL_DISMISS = 2; // 0x2
+    field public static final deprecated int BACK_DISPOSITION_WILL_NOT_DISMISS = 1; // 0x1
   }
 
   public class InputMethodService.InputMethodImpl extends android.inputmethodservice.AbstractInputMethodService.AbstractInputMethodImpl {
diff --git a/cmds/incidentd/src/FdBuffer.cpp b/cmds/incidentd/src/FdBuffer.cpp
index 3570144..2b85ec0 100644
--- a/cmds/incidentd/src/FdBuffer.cpp
+++ b/cmds/incidentd/src/FdBuffer.cpp
@@ -34,11 +34,11 @@
 
 FdBuffer::~FdBuffer() {}
 
-status_t FdBuffer::read(int fd, int64_t timeout) {
-    struct pollfd pfds = {.fd = fd, .events = POLLIN};
+status_t FdBuffer::read(unique_fd* fd, int64_t timeout) {
+    struct pollfd pfds = {.fd = fd->get(), .events = POLLIN};
     mStartTime = uptimeMillis();
 
-    fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK);
+    fcntl(fd->get(), F_SETFL, fcntl(fd->get(), F_GETFL, 0) | O_NONBLOCK);
 
     while (true) {
         if (mBuffer.size() >= MAX_BUFFER_COUNT * BUFFER_SIZE) {
@@ -67,16 +67,16 @@
                 VLOG("return event has error %s", strerror(errno));
                 return errno != 0 ? -errno : UNKNOWN_ERROR;
             } else {
-                ssize_t amt = ::read(fd, mBuffer.writeBuffer(), mBuffer.currentToWrite());
+                ssize_t amt = ::read(fd->get(), mBuffer.writeBuffer(), mBuffer.currentToWrite());
                 if (amt < 0) {
                     if (errno == EAGAIN || errno == EWOULDBLOCK) {
                         continue;
                     } else {
-                        VLOG("Fail to read %d: %s", fd, strerror(errno));
+                        VLOG("Fail to read %d: %s", fd->get(), strerror(errno));
                         return -errno;
                     }
                 } else if (amt == 0) {
-                    VLOG("Reached EOF of fd=%d", fd);
+                    VLOG("Reached EOF of fd=%d", fd->get());
                     break;
                 }
                 mBuffer.wp()->move(amt);
@@ -87,7 +87,7 @@
     return NO_ERROR;
 }
 
-status_t FdBuffer::readFully(int fd) {
+status_t FdBuffer::readFully(unique_fd* fd) {
     mStartTime = uptimeMillis();
 
     while (true) {
@@ -99,10 +99,10 @@
         }
         if (mBuffer.writeBuffer() == NULL) return NO_MEMORY;
 
-        ssize_t amt =
-                TEMP_FAILURE_RETRY(::read(fd, mBuffer.writeBuffer(), mBuffer.currentToWrite()));
+        ssize_t amt = TEMP_FAILURE_RETRY(
+                ::read(fd->get(), mBuffer.writeBuffer(), mBuffer.currentToWrite()));
         if (amt < 0) {
-            VLOG("Fail to read %d: %s", fd, strerror(errno));
+            VLOG("Fail to read %d: %s", fd->get(), strerror(errno));
             return -errno;
         } else if (amt == 0) {
             VLOG("Done reading %zu bytes", mBuffer.size());
@@ -116,20 +116,20 @@
     return NO_ERROR;
 }
 
-status_t FdBuffer::readProcessedDataInStream(int fd, int toFd, int fromFd, int64_t timeoutMs,
-                                             const bool isSysfs) {
+status_t FdBuffer::readProcessedDataInStream(unique_fd* fd, unique_fd* toFd, unique_fd* fromFd,
+                                             int64_t timeoutMs, const bool isSysfs) {
     struct pollfd pfds[] = {
-            {.fd = fd, .events = POLLIN},
-            {.fd = toFd, .events = POLLOUT},
-            {.fd = fromFd, .events = POLLIN},
+            {.fd = fd->get(), .events = POLLIN},
+            {.fd = toFd->get(), .events = POLLOUT},
+            {.fd = fromFd->get(), .events = POLLIN},
     };
 
     mStartTime = uptimeMillis();
 
     // mark all fds non blocking
-    fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK);
-    fcntl(toFd, F_SETFL, fcntl(toFd, F_GETFL, 0) | O_NONBLOCK);
-    fcntl(fromFd, F_SETFL, fcntl(fromFd, F_GETFL, 0) | O_NONBLOCK);
+    fcntl(fd->get(), F_SETFL, fcntl(fd->get(), F_GETFL, 0) | O_NONBLOCK);
+    fcntl(toFd->get(), F_SETFL, fcntl(toFd->get(), F_GETFL, 0) | O_NONBLOCK);
+    fcntl(fromFd->get(), F_SETFL, fcntl(fromFd->get(), F_GETFL, 0) | O_NONBLOCK);
 
     // A circular buffer holds data read from fd and writes to parsing process
     uint8_t cirBuf[BUFFER_SIZE];
@@ -166,10 +166,10 @@
         for (int i = 0; i < 3; ++i) {
             if ((pfds[i].revents & POLLERR) != 0) {
                 if (i == 0 && isSysfs) {
-                    VLOG("fd %d is sysfs, ignore its POLLERR return value", fd);
+                    VLOG("fd %d is sysfs, ignore its POLLERR return value", fd->get());
                     continue;
                 }
-                VLOG("fd[%d]=%d returns error events: %s", i, fd, strerror(errno));
+                VLOG("fd[%d]=%d returns error events: %s", i, fd->get(), strerror(errno));
                 return errno != 0 ? -errno : UNKNOWN_ERROR;
             }
         }
@@ -178,17 +178,17 @@
         if (cirSize != BUFFER_SIZE && pfds[0].fd != -1) {
             ssize_t amt;
             if (rpos >= wpos) {
-                amt = ::read(fd, cirBuf + rpos, BUFFER_SIZE - rpos);
+                amt = ::read(fd->get(), cirBuf + rpos, BUFFER_SIZE - rpos);
             } else {
-                amt = ::read(fd, cirBuf + rpos, wpos - rpos);
+                amt = ::read(fd->get(), cirBuf + rpos, wpos - rpos);
             }
             if (amt < 0) {
                 if (!(errno == EAGAIN || errno == EWOULDBLOCK)) {
-                    VLOG("Fail to read fd %d: %s", fd, strerror(errno));
+                    VLOG("Fail to read fd %d: %s", fd->get(), strerror(errno));
                     return -errno;
                 }  // otherwise just continue
             } else if (amt == 0) {
-                VLOG("Reached EOF of input file %d", fd);
+                VLOG("Reached EOF of input file %d", fd->get());
                 pfds[0].fd = -1;  // reach EOF so don't have to poll pfds[0].
             } else {
                 rpos += amt;
@@ -200,13 +200,13 @@
         if (cirSize > 0 && pfds[1].fd != -1) {
             ssize_t amt;
             if (rpos > wpos) {
-                amt = ::write(toFd, cirBuf + wpos, rpos - wpos);
+                amt = ::write(toFd->get(), cirBuf + wpos, rpos - wpos);
             } else {
-                amt = ::write(toFd, cirBuf + wpos, BUFFER_SIZE - wpos);
+                amt = ::write(toFd->get(), cirBuf + wpos, BUFFER_SIZE - wpos);
             }
             if (amt < 0) {
                 if (!(errno == EAGAIN || errno == EWOULDBLOCK)) {
-                    VLOG("Fail to write toFd %d: %s", toFd, strerror(errno));
+                    VLOG("Fail to write toFd %d: %s", toFd->get(), strerror(errno));
                     return -errno;
                 }  // otherwise just continue
             } else {
@@ -217,8 +217,8 @@
 
         // if buffer is empty and fd is closed, close write fd.
         if (cirSize == 0 && pfds[0].fd == -1 && pfds[1].fd != -1) {
-            VLOG("Close write pipe %d", toFd);
-            ::close(pfds[1].fd);
+            VLOG("Close write pipe %d", toFd->get());
+            toFd->reset();
             pfds[1].fd = -1;
         }
 
@@ -231,14 +231,14 @@
         }
 
         // read from parsing process
-        ssize_t amt = ::read(fromFd, mBuffer.writeBuffer(), mBuffer.currentToWrite());
+        ssize_t amt = ::read(fromFd->get(), mBuffer.writeBuffer(), mBuffer.currentToWrite());
         if (amt < 0) {
             if (!(errno == EAGAIN || errno == EWOULDBLOCK)) {
-                VLOG("Fail to read fromFd %d: %s", fromFd, strerror(errno));
+                VLOG("Fail to read fromFd %d: %s", fromFd->get(), strerror(errno));
                 return -errno;
             }  // otherwise just continue
         } else if (amt == 0) {
-            VLOG("Reached EOF of fromFd %d", fromFd);
+            VLOG("Reached EOF of fromFd %d", fromFd->get());
             break;
         } else {
             mBuffer.wp()->move(amt);
diff --git a/cmds/incidentd/src/FdBuffer.h b/cmds/incidentd/src/FdBuffer.h
index 34ebcf5..db3a74b 100644
--- a/cmds/incidentd/src/FdBuffer.h
+++ b/cmds/incidentd/src/FdBuffer.h
@@ -18,10 +18,12 @@
 #ifndef FD_BUFFER_H
 #define FD_BUFFER_H
 
+#include <android-base/unique_fd.h>
 #include <android/util/EncodedBuffer.h>
 #include <utils/Errors.h>
 
 using namespace android;
+using namespace android::base;
 using namespace android::util;
 using namespace std;
 
@@ -38,13 +40,13 @@
      * Returns NO_ERROR if there were no errors or if we timed out.
      * Will mark the file O_NONBLOCK.
      */
-    status_t read(int fd, int64_t timeoutMs);
+    status_t read(unique_fd* fd, int64_t timeoutMs);
 
     /**
      * Read the data until we hit eof.
      * Returns NO_ERROR if there were no errors.
      */
-    status_t readFully(int fd);
+    status_t readFully(unique_fd* fd);
 
     /**
      * Read processed results by streaming data to a parsing process, e.g. incident helper.
@@ -56,8 +58,8 @@
      *
      * Poll will return POLLERR if fd is from sysfs, handle this edge case.
      */
-    status_t readProcessedDataInStream(int fd, int toFd, int fromFd, int64_t timeoutMs,
-                                       const bool isSysfs = false);
+    status_t readProcessedDataInStream(unique_fd* fd, unique_fd* toFd, unique_fd* fromFd,
+                                       int64_t timeoutMs, const bool isSysfs = false);
 
     /**
      * Whether we timed out.
diff --git a/cmds/incidentd/src/IncidentService.cpp b/cmds/incidentd/src/IncidentService.cpp
index d02b4dd..aeccefd 100644
--- a/cmds/incidentd/src/IncidentService.cpp
+++ b/cmds/incidentd/src/IncidentService.cpp
@@ -352,7 +352,8 @@
             printPrivacy(p, out, String8(""));
         } else if (opt == "parse") {
             FdBuffer buf;
-            status_t error = buf.read(fileno(in), 60000);
+            unique_fd infd(fileno(in));
+            status_t error = buf.read(&infd, 60000);
             if (error != NO_ERROR) {
                 fprintf(err, "Error reading from stdin\n");
                 return error;
diff --git a/cmds/incidentd/src/Section.cpp b/cmds/incidentd/src/Section.cpp
index 5cde5a9..ab4e764 100644
--- a/cmds/incidentd/src/Section.cpp
+++ b/cmds/incidentd/src/Section.cpp
@@ -277,8 +277,8 @@
 status_t FileSection::Execute(ReportRequestSet* requests) const {
     // read from mFilename first, make sure the file is available
     // add O_CLOEXEC to make sure it is closed when exec incident helper
-    int fd = open(mFilename, O_RDONLY | O_CLOEXEC);
-    if (fd == -1) {
+    unique_fd fd(open(mFilename, O_RDONLY | O_CLOEXEC));
+    if (fd.get() == -1) {
         ALOGW("FileSection '%s' failed to open file", this->name.string());
         return -errno;
     }
@@ -299,9 +299,8 @@
     }
 
     // parent process
-    status_t readStatus = buffer.readProcessedDataInStream(fd, p2cPipe.writeFd(), c2pPipe.readFd(),
-                                                           this->timeoutMs, mIsSysfs);
-    close(fd);  // close the fd anyway.
+    status_t readStatus = buffer.readProcessedDataInStream(
+            &fd, &p2cPipe.writeFd(), &c2pPipe.readFd(), this->timeoutMs, mIsSysfs);
 
     if (readStatus != NO_ERROR || buffer.timedOut()) {
         ALOGW("FileSection '%s' failed to read data from incident helper: %s, timedout: %s",
@@ -342,17 +341,17 @@
 status_t GZipSection::Execute(ReportRequestSet* requests) const {
     // Reads the files in order, use the first available one.
     int index = 0;
-    int fd = -1;
+    unique_fd fd;
     while (mFilenames[index] != NULL) {
-        fd = open(mFilenames[index], O_RDONLY | O_CLOEXEC);
-        if (fd != -1) {
+        fd.reset(open(mFilenames[index], O_RDONLY | O_CLOEXEC));
+        if (fd.get() != -1) {
             break;
         }
         ALOGW("GZipSection failed to open file %s", mFilenames[index]);
         index++;  // look at the next file.
     }
-    VLOG("GZipSection is using file %s, fd=%d", mFilenames[index], fd);
-    if (fd == -1) return -1;
+    VLOG("GZipSection is using file %s, fd=%d", mFilenames[index], fd.get());
+    if (fd.get() == -1) return -1;
 
     FdBuffer buffer;
     Fpipe p2cPipe;
@@ -388,9 +387,9 @@
     VLOG("GZipSection '%s' editPos=%zd, dataBeginAt=%zd", this->name.string(), editPos,
          dataBeginAt);
 
-    status_t readStatus = buffer.readProcessedDataInStream(
-            fd, p2cPipe.writeFd(), c2pPipe.readFd(), this->timeoutMs, isSysfs(mFilenames[index]));
-    close(fd);  // close the fd anyway.
+    status_t readStatus =
+            buffer.readProcessedDataInStream(&fd, &p2cPipe.writeFd(), &c2pPipe.readFd(),
+                                             this->timeoutMs, isSysfs(mFilenames[index]));
 
     if (readStatus != NO_ERROR || buffer.timedOut()) {
         ALOGW("GZipSection '%s' failed to read data from gzip: %s, timedout: %s",
@@ -424,7 +423,7 @@
 // ================================================================================
 struct WorkerThreadData : public virtual RefBase {
     const WorkerThreadSection* section;
-    int fds[2];
+    Fpipe pipe;
 
     // Lock protects these fields
     mutex lock;
@@ -433,16 +432,10 @@
 
     WorkerThreadData(const WorkerThreadSection* section);
     virtual ~WorkerThreadData();
-
-    int readFd() { return fds[0]; }
-    int writeFd() { return fds[1]; }
 };
 
 WorkerThreadData::WorkerThreadData(const WorkerThreadSection* sec)
-    : section(sec), workerDone(false), workerError(NO_ERROR) {
-    fds[0] = -1;
-    fds[1] = -1;
-}
+    : section(sec), workerDone(false), workerError(NO_ERROR) {}
 
 WorkerThreadData::~WorkerThreadData() {}
 
@@ -454,7 +447,7 @@
 
 static void* worker_thread_func(void* cookie) {
     WorkerThreadData* data = (WorkerThreadData*)cookie;
-    status_t err = data->section->BlockingCall(data->writeFd());
+    status_t err = data->section->BlockingCall(data->pipe.writeFd().get());
 
     {
         unique_lock<mutex> lock(data->lock);
@@ -462,7 +455,7 @@
         data->workerError = err;
     }
 
-    close(data->writeFd());
+    data->pipe.writeFd().reset();
     data->decStrong(data->section);
     // data might be gone now. don't use it after this point in this thread.
     return NULL;
@@ -479,8 +472,7 @@
     sp<WorkerThreadData> data = new WorkerThreadData(this);
 
     // Create the pipe
-    err = pipe(data->fds);
-    if (err != 0) {
+    if (!data->pipe.init()) {
         return -errno;
     }
 
@@ -507,7 +499,7 @@
     pthread_attr_destroy(&attr);
 
     // Loop reading until either the timeout or the worker side is done (i.e. eof).
-    err = buffer.read(data->readFd(), this->timeoutMs);
+    err = buffer.read(&data->pipe.readFd(), this->timeoutMs);
     if (err != NO_ERROR) {
         // TODO: Log this error into the incident report.
         ALOGW("WorkerThreadSection '%s' reader failed with error '%s'", this->name.string(),
@@ -516,7 +508,7 @@
 
     // Done with the read fd. The worker thread closes the write one so
     // we never race and get here first.
-    close(data->readFd());
+    data->pipe.readFd().reset();
 
     // If the worker side is finished, then return its error (which may overwrite
     // our possible error -- but it's more interesting anyway).  If not, then we timed out.
@@ -602,7 +594,8 @@
     // child process to execute the command as root
     if (cmdPid == 0) {
         // replace command's stdout with ihPipe's write Fd
-        if (dup2(cmdPipe.writeFd(), STDOUT_FILENO) != 1 || !ihPipe.close() || !cmdPipe.close()) {
+        if (dup2(cmdPipe.writeFd().get(), STDOUT_FILENO) != 1 || !ihPipe.close() ||
+            !cmdPipe.close()) {
             ALOGW("CommandSection '%s' failed to set up stdout: %s", this->name.string(),
                   strerror(errno));
             _exit(EXIT_FAILURE);
@@ -619,8 +612,8 @@
         return -errno;
     }
 
-    close(cmdPipe.writeFd());
-    status_t readStatus = buffer.read(ihPipe.readFd(), this->timeoutMs);
+    cmdPipe.writeFd().reset();
+    status_t readStatus = buffer.read(&ihPipe.readFd(), this->timeoutMs);
     if (readStatus != NO_ERROR || buffer.timedOut()) {
         ALOGW("CommandSection '%s' failed to read data from incident helper: %s, timedout: %s",
               this->name.string(), strerror(-readStatus), buffer.timedOut() ? "true" : "false");
@@ -921,10 +914,10 @@
             break;
         } else if (child == 0) {
             // This is the child process.
-            close(dumpPipe.readFd());
+            dumpPipe.readFd().reset();
             const int ret = dump_backtrace_to_file_timeout(
                     pid, is_java_process ? kDebuggerdJavaBacktrace : kDebuggerdNativeBacktrace,
-                    is_java_process ? 5 : 20, dumpPipe.writeFd());
+                    is_java_process ? 5 : 20, dumpPipe.writeFd().get());
             if (ret == -1) {
                 if (errno == 0) {
                     ALOGW("Dumping failed for pid '%d', likely due to a timeout\n", pid);
@@ -932,25 +925,17 @@
                     ALOGE("Dumping failed for pid '%d': %s\n", pid, strerror(errno));
                 }
             }
-            if (close(dumpPipe.writeFd()) != 0) {
-                ALOGW("TombstoneSection '%s' failed to close dump pipe writeFd: %d",
-                      this->name.string(), errno);
-                _exit(EXIT_FAILURE);
-            }
-
+            dumpPipe.writeFd().reset();
             _exit(EXIT_SUCCESS);
         }
-        close(dumpPipe.writeFd());
+        dumpPipe.writeFd().reset();
         // Parent process.
         // Read from the pipe concurrently to avoid blocking the child.
         FdBuffer buffer;
-        err = buffer.readFully(dumpPipe.readFd());
+        err = buffer.readFully(&dumpPipe.readFd());
         if (err != NO_ERROR) {
             ALOGW("TombstoneSection '%s' failed to read stack dump: %d", this->name.string(), err);
-            if (close(dumpPipe.readFd()) != 0) {
-                ALOGW("TombstoneSection '%s' failed to close dump pipe readFd: %s",
-                      this->name.string(), strerror(errno));
-            }
+            dumpPipe.readFd().reset();
             break;
         }
 
@@ -967,13 +952,7 @@
         proto.write(android::os::BackTraceProto::Stack::DUMP_DURATION_NS,
                     static_cast<long long>(Nanotime() - start));
         proto.end(token);
-
-        if (close(dumpPipe.readFd()) != 0) {
-            ALOGW("TombstoneSection '%s' failed to close dump pipe readFd: %d", this->name.string(),
-                  errno);
-            err = -errno;
-            break;
-        }
+        dumpPipe.readFd().reset();
     }
 
     proto.flush(pipeWriteFd);
diff --git a/cmds/incidentd/src/incidentd_util.cpp b/cmds/incidentd/src/incidentd_util.cpp
index c869c7a..d799513 100644
--- a/cmds/incidentd/src/incidentd_util.cpp
+++ b/cmds/incidentd/src/incidentd_util.cpp
@@ -53,16 +53,17 @@
 
 bool Fpipe::init() { return Pipe(&mRead, &mWrite); }
 
-int Fpipe::readFd() const { return mRead.get(); }
+unique_fd& Fpipe::readFd() { return mRead; }
 
-int Fpipe::writeFd() const { return mWrite.get(); }
+unique_fd& Fpipe::writeFd() { return mWrite; }
 
 pid_t fork_execute_cmd(const char* cmd, char* const argv[], Fpipe* input, Fpipe* output) {
     // fork used in multithreaded environment, avoid adding unnecessary code in child process
     pid_t pid = fork();
     if (pid == 0) {
-        if (TEMP_FAILURE_RETRY(dup2(input->readFd(), STDIN_FILENO)) < 0 || !input->close() ||
-            TEMP_FAILURE_RETRY(dup2(output->writeFd(), STDOUT_FILENO)) < 0 || !output->close()) {
+        if (TEMP_FAILURE_RETRY(dup2(input->readFd().get(), STDIN_FILENO)) < 0 || !input->close() ||
+            TEMP_FAILURE_RETRY(dup2(output->writeFd().get(), STDOUT_FILENO)) < 0 ||
+            !output->close()) {
             ALOGW("Can't setup stdin and stdout for command %s", cmd);
             _exit(EXIT_FAILURE);
         }
@@ -76,8 +77,8 @@
         _exit(EXIT_FAILURE);  // always exits with failure if any
     }
     // close the fds used in child process.
-    close(input->readFd());
-    close(output->writeFd());
+    input->readFd().reset();
+    output->writeFd().reset();
     return pid;
 }
 
diff --git a/cmds/incidentd/src/incidentd_util.h b/cmds/incidentd/src/incidentd_util.h
index 3f7df91..228d776 100644
--- a/cmds/incidentd/src/incidentd_util.h
+++ b/cmds/incidentd/src/incidentd_util.h
@@ -41,8 +41,8 @@
 
     bool init();
     bool close();
-    int readFd() const;
-    int writeFd() const;
+    unique_fd& readFd();
+    unique_fd& writeFd();
 
 private:
     unique_fd mRead;
diff --git a/cmds/incidentd/tests/FdBuffer_test.cpp b/cmds/incidentd/tests/FdBuffer_test.cpp
index 0e5eec6..bf77017 100644
--- a/cmds/incidentd/tests/FdBuffer_test.cpp
+++ b/cmds/incidentd/tests/FdBuffer_test.cpp
@@ -37,6 +37,7 @@
 public:
     virtual void SetUp() override {
         ASSERT_NE(tf.fd, -1);
+        tffd.reset(tf.fd);
         ASSERT_NE(p2cPipe.init(), -1);
         ASSERT_NE(c2pPipe.init(), -1);
     }
@@ -56,13 +57,13 @@
         EXPECT_EQ(expected[i], '\0');
     }
 
-    bool DoDataStream(int rFd, int wFd) {
+    bool DoDataStream(unique_fd* rFd, unique_fd* wFd) {
         char buf[BUFFER_SIZE];
         ssize_t nRead;
-        while ((nRead = read(rFd, buf, BUFFER_SIZE)) > 0) {
+        while ((nRead = read(rFd->get(), buf, BUFFER_SIZE)) > 0) {
             ssize_t nWritten = 0;
             while (nWritten < nRead) {
-                ssize_t amt = write(wFd, buf + nWritten, nRead - nWritten);
+                ssize_t amt = write(wFd->get(), buf + nWritten, nRead - nWritten);
                 if (amt < 0) {
                     return false;
                 }
@@ -75,6 +76,7 @@
 protected:
     FdBuffer buffer;
     TemporaryFile tf;
+    unique_fd tffd;
     Fpipe p2cPipe;
     Fpipe c2pPipe;
 
@@ -85,7 +87,7 @@
 TEST_F(FdBufferTest, ReadAndWrite) {
     std::string testdata = "FdBuffer test string";
     ASSERT_TRUE(WriteStringToFile(testdata, tf.path));
-    ASSERT_EQ(NO_ERROR, buffer.read(tf.fd, READ_TIMEOUT));
+    ASSERT_EQ(NO_ERROR, buffer.read(&tffd, READ_TIMEOUT));
     AssertBufferReadSuccessful(testdata.size());
     AssertBufferContent(testdata.c_str());
 }
@@ -98,7 +100,7 @@
 TEST_F(FdBufferTest, ReadAndIterate) {
     std::string testdata = "FdBuffer test string";
     ASSERT_TRUE(WriteStringToFile(testdata, tf.path));
-    ASSERT_EQ(NO_ERROR, buffer.read(tf.fd, READ_TIMEOUT));
+    ASSERT_EQ(NO_ERROR, buffer.read(&tffd, READ_TIMEOUT));
 
     int i = 0;
     EncodedBuffer::iterator it = buffer.data();
@@ -117,16 +119,16 @@
     ASSERT_TRUE(pid != -1);
 
     if (pid == 0) {
-        close(c2pPipe.readFd());
+        c2pPipe.readFd().reset();
         while (true) {
             write(c2pPipe.writeFd(), "poo", 3);
             sleep(1);
         }
         _exit(EXIT_FAILURE);
     } else {
-        close(c2pPipe.writeFd());
+        c2pPipe.writeFd().reset();
 
-        status_t status = buffer.read(c2pPipe.readFd(), QUICK_TIMEOUT_MS);
+        status_t status = buffer.read(&c2pPipe.readFd(), QUICK_TIMEOUT_MS);
         ASSERT_EQ(NO_ERROR, status);
         EXPECT_TRUE(buffer.timedOut());
 
@@ -143,20 +145,20 @@
     ASSERT_TRUE(pid != -1);
 
     if (pid == 0) {
-        close(p2cPipe.writeFd());
-        close(c2pPipe.readFd());
+        p2cPipe.writeFd().reset();
+        c2pPipe.readFd().reset();
         ASSERT_TRUE(WriteStringToFd(HEAD, c2pPipe.writeFd()));
-        ASSERT_TRUE(DoDataStream(p2cPipe.readFd(), c2pPipe.writeFd()));
-        close(p2cPipe.readFd());
-        close(c2pPipe.writeFd());
+        ASSERT_TRUE(DoDataStream(&p2cPipe.readFd(), &c2pPipe.writeFd()));
+        p2cPipe.readFd().reset();
+        c2pPipe.writeFd().reset();
         // Must exit here otherwise the child process will continue executing the test binary.
         _exit(EXIT_SUCCESS);
     } else {
-        close(p2cPipe.readFd());
-        close(c2pPipe.writeFd());
+        p2cPipe.readFd().reset();
+        c2pPipe.writeFd().reset();
 
-        ASSERT_EQ(NO_ERROR, buffer.readProcessedDataInStream(tf.fd, p2cPipe.writeFd(),
-                                                             c2pPipe.readFd(), READ_TIMEOUT));
+        ASSERT_EQ(NO_ERROR, buffer.readProcessedDataInStream(&tffd, &p2cPipe.writeFd(),
+                                                             &c2pPipe.readFd(), READ_TIMEOUT));
         AssertBufferReadSuccessful(HEAD.size() + testdata.size());
         AssertBufferContent(expected.c_str());
         wait(&pid);
@@ -172,23 +174,23 @@
     ASSERT_TRUE(pid != -1);
 
     if (pid == 0) {
-        close(p2cPipe.writeFd());
-        close(c2pPipe.readFd());
+        p2cPipe.writeFd().reset();
+        c2pPipe.readFd().reset();
         std::string data;
         // wait for read finishes then write.
         ASSERT_TRUE(ReadFdToString(p2cPipe.readFd(), &data));
         data = HEAD + data;
         ASSERT_TRUE(WriteStringToFd(data, c2pPipe.writeFd()));
-        close(p2cPipe.readFd());
-        close(c2pPipe.writeFd());
+        p2cPipe.readFd().reset();
+        c2pPipe.writeFd().reset();
         // Must exit here otherwise the child process will continue executing the test binary.
         _exit(EXIT_SUCCESS);
     } else {
-        close(p2cPipe.readFd());
-        close(c2pPipe.writeFd());
+        p2cPipe.readFd().reset();
+        c2pPipe.writeFd().reset();
 
-        ASSERT_EQ(NO_ERROR, buffer.readProcessedDataInStream(tf.fd, p2cPipe.writeFd(),
-                                                             c2pPipe.readFd(), READ_TIMEOUT));
+        ASSERT_EQ(NO_ERROR, buffer.readProcessedDataInStream(&tffd, &p2cPipe.writeFd(),
+                                                             &c2pPipe.readFd(), READ_TIMEOUT));
         AssertBufferReadSuccessful(HEAD.size() + testdata.size());
         AssertBufferContent(expected.c_str());
         wait(&pid);
@@ -202,18 +204,18 @@
     ASSERT_TRUE(pid != -1);
 
     if (pid == 0) {
-        close(p2cPipe.writeFd());
-        close(c2pPipe.readFd());
-        ASSERT_TRUE(DoDataStream(p2cPipe.readFd(), c2pPipe.writeFd()));
-        close(p2cPipe.readFd());
-        close(c2pPipe.writeFd());
+        p2cPipe.writeFd().reset();
+        c2pPipe.readFd().reset();
+        ASSERT_TRUE(DoDataStream(&p2cPipe.readFd(), &c2pPipe.writeFd()));
+        p2cPipe.readFd().reset();
+        c2pPipe.writeFd().reset();
         _exit(EXIT_SUCCESS);
     } else {
-        close(p2cPipe.readFd());
-        close(c2pPipe.writeFd());
+        p2cPipe.readFd().reset();
+        c2pPipe.writeFd().reset();
 
-        ASSERT_EQ(NO_ERROR, buffer.readProcessedDataInStream(tf.fd, p2cPipe.writeFd(),
-                                                             c2pPipe.readFd(), READ_TIMEOUT));
+        ASSERT_EQ(NO_ERROR, buffer.readProcessedDataInStream(&tffd, &p2cPipe.writeFd(),
+                                                             &c2pPipe.readFd(), READ_TIMEOUT));
         AssertBufferReadSuccessful(0);
         AssertBufferContent("");
         wait(&pid);
@@ -223,24 +225,24 @@
 TEST_F(FdBufferTest, ReadInStreamMoreThan4MB) {
     const std::string testFile = kTestDataPath + "morethan4MB.txt";
     size_t fourMB = (size_t)4 * 1024 * 1024;
-    int fd = open(testFile.c_str(), O_RDONLY | O_CLOEXEC);
-    ASSERT_NE(fd, -1);
+    unique_fd fd(open(testFile.c_str(), O_RDONLY | O_CLOEXEC));
+    ASSERT_NE(fd.get(), -1);
     int pid = fork();
     ASSERT_TRUE(pid != -1);
 
     if (pid == 0) {
-        close(p2cPipe.writeFd());
-        close(c2pPipe.readFd());
-        ASSERT_TRUE(DoDataStream(p2cPipe.readFd(), c2pPipe.writeFd()));
-        close(p2cPipe.readFd());
-        close(c2pPipe.writeFd());
+        p2cPipe.writeFd().reset();
+        c2pPipe.readFd().reset();
+        ASSERT_TRUE(DoDataStream(&p2cPipe.readFd(), &c2pPipe.writeFd()));
+        p2cPipe.readFd().reset();
+        c2pPipe.writeFd().reset();
         _exit(EXIT_SUCCESS);
     } else {
-        close(p2cPipe.readFd());
-        close(c2pPipe.writeFd());
+        p2cPipe.readFd().reset();
+        c2pPipe.writeFd().reset();
 
-        ASSERT_EQ(NO_ERROR, buffer.readProcessedDataInStream(fd, p2cPipe.writeFd(),
-                                                             c2pPipe.readFd(), READ_TIMEOUT));
+        ASSERT_EQ(NO_ERROR, buffer.readProcessedDataInStream(&fd, &p2cPipe.writeFd(),
+                                                             &c2pPipe.readFd(), READ_TIMEOUT));
         EXPECT_EQ(buffer.size(), fourMB);
         EXPECT_FALSE(buffer.timedOut());
         EXPECT_TRUE(buffer.truncated());
@@ -266,18 +268,18 @@
     ASSERT_TRUE(pid != -1);
 
     if (pid == 0) {
-        close(p2cPipe.writeFd());
-        close(c2pPipe.readFd());
+        p2cPipe.writeFd().reset();
+        c2pPipe.readFd().reset();
         while (true) {
             sleep(1);
         }
         _exit(EXIT_FAILURE);
     } else {
-        close(p2cPipe.readFd());
-        close(c2pPipe.writeFd());
+        p2cPipe.readFd().reset();
+        c2pPipe.writeFd().reset();
 
-        ASSERT_EQ(NO_ERROR, buffer.readProcessedDataInStream(tf.fd, p2cPipe.writeFd(),
-                                                             c2pPipe.readFd(), QUICK_TIMEOUT_MS));
+        ASSERT_EQ(NO_ERROR, buffer.readProcessedDataInStream(&tffd, &p2cPipe.writeFd(),
+                                                             &c2pPipe.readFd(), QUICK_TIMEOUT_MS));
         EXPECT_TRUE(buffer.timedOut());
         kill(pid, SIGKILL);  // reap the child process
     }
diff --git a/cmds/incidentd/tests/PrivacyBuffer_test.cpp b/cmds/incidentd/tests/PrivacyBuffer_test.cpp
index c7c69a7..5edc0c7 100644
--- a/cmds/incidentd/tests/PrivacyBuffer_test.cpp
+++ b/cmds/incidentd/tests/PrivacyBuffer_test.cpp
@@ -58,7 +58,8 @@
 
     void writeToFdBuffer(string str) {
         ASSERT_TRUE(WriteStringToFile(str, tf.path));
-        ASSERT_EQ(NO_ERROR, buffer.read(tf.fd, 10000));
+        unique_fd tffd(tf.fd);
+        ASSERT_EQ(NO_ERROR, buffer.read(&tffd, 10000));
         ASSERT_EQ(str.size(), buffer.size());
     }
 
diff --git a/cmds/statsd/Android.mk b/cmds/statsd/Android.mk
index 50a5ddd..5d6a1d1a 100644
--- a/cmds/statsd/Android.mk
+++ b/cmds/statsd/Android.mk
@@ -17,7 +17,6 @@
 statsd_common_src := \
     ../../core/java/android/os/IStatsCompanionService.aidl \
     ../../core/java/android/os/IStatsManager.aidl \
-    src/stats_log_common.proto \
     src/statsd_config.proto \
     src/FieldValue.cpp \
     src/stats_log_util.cpp \
@@ -224,7 +223,6 @@
 
 LOCAL_SRC_FILES := \
     src/stats_log.proto \
-    src/stats_log_common.proto \
     src/statsd_config.proto \
     src/perfetto/perfetto_config.proto \
     src/atoms.proto
diff --git a/cmds/statsd/src/StatsLogProcessor.cpp b/cmds/statsd/src/StatsLogProcessor.cpp
index 8f72a8f..652ec9d 100644
--- a/cmds/statsd/src/StatsLogProcessor.cpp
+++ b/cmds/statsd/src/StatsLogProcessor.cpp
@@ -270,11 +270,9 @@
     it->second->onDumpReport(dumpTimeStampNs, &proto);
 
     // Fill in UidMap.
-    auto uidMap = mUidMap->getOutput(key);
-    const int uidMapSize = uidMap.ByteSize();
-    char uidMapBuffer[uidMapSize];
-    uidMap.SerializeToArray(&uidMapBuffer[0], uidMapSize);
-    proto.write(FIELD_TYPE_MESSAGE | FIELD_ID_UID_MAP, uidMapBuffer, uidMapSize);
+    vector<uint8_t> uidMap;
+    mUidMap->getOutput(key, &uidMap);
+    proto.write(FIELD_TYPE_MESSAGE | FIELD_ID_UID_MAP, uidMap.data());
 
     // Fill in the timestamps.
     proto.write(FIELD_TYPE_INT64 | FIELD_ID_LAST_REPORT_ELAPSED_NANOS,
diff --git a/cmds/statsd/src/guardrail/StatsdStats.h b/cmds/statsd/src/guardrail/StatsdStats.h
index d05c91b..c42514a 100644
--- a/cmds/statsd/src/guardrail/StatsdStats.h
+++ b/cmds/statsd/src/guardrail/StatsdStats.h
@@ -16,7 +16,6 @@
 #pragma once
 
 #include "config/ConfigKey.h"
-#include "frameworks/base/cmds/statsd/src/stats_log_common.pb.h"
 #include "statslog.h"
 
 #include <gtest/gtest_prod.h>
diff --git a/cmds/statsd/src/matchers/matcher_util.h b/cmds/statsd/src/matchers/matcher_util.h
index ae946d1..15b4a97 100644
--- a/cmds/statsd/src/matchers/matcher_util.h
+++ b/cmds/statsd/src/matchers/matcher_util.h
@@ -24,7 +24,6 @@
 #include <string>
 #include <unordered_map>
 #include <vector>
-#include "frameworks/base/cmds/statsd/src/stats_log_common.pb.h"
 #include "frameworks/base/cmds/statsd/src/statsd_config.pb.h"
 #include "packages/UidMap.h"
 #include "stats_util.h"
diff --git a/cmds/statsd/src/packages/UidMap.cpp b/cmds/statsd/src/packages/UidMap.cpp
index e322ca4..efbe96e 100644
--- a/cmds/statsd/src/packages/UidMap.cpp
+++ b/cmds/statsd/src/packages/UidMap.cpp
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#define DEBUG true  // STOPSHIP if true
+#define DEBUG false  // STOPSHIP if true
 #include "Log.h"
 
 #include "stats_log_util.h"
@@ -28,10 +28,33 @@
 
 using namespace android;
 
+using android::base::StringPrintf;
+using android::util::FIELD_COUNT_REPEATED;
+using android::util::FIELD_TYPE_BOOL;
+using android::util::FIELD_TYPE_FLOAT;
+using android::util::FIELD_TYPE_INT32;
+using android::util::FIELD_TYPE_INT64;
+using android::util::FIELD_TYPE_MESSAGE;
+using android::util::FIELD_TYPE_STRING;
+using android::util::ProtoOutputStream;
+
 namespace android {
 namespace os {
 namespace statsd {
 
+const int FIELD_ID_SNAPSHOT_PACKAGE_NAME = 1;
+const int FIELD_ID_SNAPSHOT_PACKAGE_VERSION = 2;
+const int FIELD_ID_SNAPSHOT_PACKAGE_UID = 3;
+const int FIELD_ID_SNAPSHOT_TIMESTAMP = 1;
+const int FIELD_ID_SNAPSHOT_PACKAGE_INFO = 2;
+const int FIELD_ID_SNAPSHOTS = 1;
+const int FIELD_ID_CHANGES = 2;
+const int FIELD_ID_CHANGE_DELETION = 1;
+const int FIELD_ID_CHANGE_TIMESTAMP = 2;
+const int FIELD_ID_CHANGE_PACKAGE = 3;
+const int FIELD_ID_CHANGE_UID = 4;
+const int FIELD_ID_CHANGE_VERSION = 5;
+
 UidMap::UidMap() : mBytesUsed(0) {}
 
 UidMap::~UidMap() {}
@@ -93,23 +116,35 @@
         lock_guard<mutex> lock(mMutex);  // Exclusively lock for updates.
 
         mMap.clear();
+        ProtoOutputStream proto;
+        uint64_t token = proto.start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED |
+                                      FIELD_ID_SNAPSHOT_PACKAGE_INFO);
         for (size_t j = 0; j < uid.size(); j++) {
-            mMap.insert(make_pair(
-                    uid[j], AppData(string(String8(packageName[j]).string()), versionCode[j])));
+            string package = string(String8(packageName[j]).string());
+            mMap.insert(make_pair(uid[j], AppData(package, versionCode[j])));
+            proto.write(FIELD_TYPE_STRING | FIELD_ID_SNAPSHOT_PACKAGE_NAME, package);
+            proto.write(FIELD_TYPE_INT32 | FIELD_ID_SNAPSHOT_PACKAGE_VERSION, (int)versionCode[j]);
+            proto.write(FIELD_TYPE_INT32 | FIELD_ID_SNAPSHOT_PACKAGE_UID, (int)uid[j]);
         }
+        proto.end(token);
 
-        auto snapshot = mOutput.add_snapshots();
-        snapshot->set_elapsed_timestamp_nanos(timestamp);
-        for (size_t j = 0; j < uid.size(); j++) {
-            auto t = snapshot->add_package_info();
-            t->set_name(string(String8(packageName[j]).string()));
-            t->set_version(int(versionCode[j]));
-            t->set_uid(uid[j]);
+        // Copy ProtoOutputStream output to
+        auto iter = proto.data();
+        size_t pos = 0;
+        vector<char> outData(proto.size());
+        while (iter.readBuffer() != NULL) {
+            size_t toRead = iter.currentToRead();
+            std::memcpy(&(outData[pos]), iter.readBuffer(), toRead);
+            pos += toRead;
+            iter.rp()->move(toRead);
         }
-        mBytesUsed += snapshot->ByteSize();
+        SnapshotRecord record(timestamp, outData);
+        mSnapshots.push_back(record);
+
+        mBytesUsed += proto.size() + kBytesTimestampField;
         ensureBytesUsedBelowLimit();
         StatsdStats::getInstance().setCurrentUidMapMemory(mBytesUsed);
-        StatsdStats::getInstance().setUidMapSnapshots(mOutput.snapshots_size());
+        StatsdStats::getInstance().setUidMapSnapshots(mSnapshots.size());
         getListenerListCopyLocked(&broadcastList);
     }
     // To avoid invoking callback while holding the internal lock. we get a copy of the listener
@@ -136,16 +171,11 @@
     {
         lock_guard<mutex> lock(mMutex);
 
-        auto log = mOutput.add_changes();
-        log->set_deletion(false);
-        log->set_elapsed_timestamp_nanos(timestamp);
-        log->set_app(appName);
-        log->set_uid(uid);
-        log->set_version(versionCode);
-        mBytesUsed += log->ByteSize();
+        mChanges.emplace_back(false, timestamp, appName, uid, versionCode);
+        mBytesUsed += kBytesChangeRecord;
         ensureBytesUsedBelowLimit();
         StatsdStats::getInstance().setCurrentUidMapMemory(mBytesUsed);
-        StatsdStats::getInstance().setUidMapChanges(mOutput.changes_size());
+        StatsdStats::getInstance().setUidMapChanges(mChanges.size());
 
         auto range = mMap.equal_range(int(uid));
         bool found = false;
@@ -180,17 +210,16 @@
         limit = maxBytesOverride;
     }
     while (mBytesUsed > limit) {
-        VLOG("Bytes used %zu is above limit %zu, need to delete something", mBytesUsed, limit);
-        if (mOutput.snapshots_size() > 0) {
-            auto snapshots = mOutput.mutable_snapshots();
-            snapshots->erase(snapshots->begin());  // Remove first snapshot.
+        ALOGI("Bytes used %zu is above limit %zu, need to delete something", mBytesUsed, limit);
+        if (mSnapshots.size() > 0) {
+            mBytesUsed -= mSnapshots.front().bytes.size() + kBytesTimestampField;
+            mSnapshots.pop_front();
             StatsdStats::getInstance().noteUidMapDropped(1, 0);
-        } else if (mOutput.changes_size() > 0) {
-            auto changes = mOutput.mutable_changes();
-            changes->DeleteSubrange(0, 1);
+        } else if (mChanges.size() > 0) {
+            mBytesUsed -= kBytesChangeRecord;
+            mChanges.pop_front();
             StatsdStats::getInstance().noteUidMapDropped(0, 1);
         }
-        mBytesUsed = mOutput.ByteSize();
     }
 }
 
@@ -217,15 +246,11 @@
     {
         lock_guard<mutex> lock(mMutex);
 
-        auto log = mOutput.add_changes();
-        log->set_deletion(true);
-        log->set_elapsed_timestamp_nanos(timestamp);
-        log->set_app(app);
-        log->set_uid(uid);
-        mBytesUsed += log->ByteSize();
+        mChanges.emplace_back(true, timestamp, app, uid, 0);
+        mBytesUsed += kBytesChangeRecord;
         ensureBytesUsedBelowLimit();
         StatsdStats::getInstance().setCurrentUidMapMemory(mBytesUsed);
-        StatsdStats::getInstance().setUidMapChanges(mOutput.changes_size());
+        StatsdStats::getInstance().setUidMapChanges(mChanges.size());
 
         auto range = mMap.equal_range(int(uid));
         for (auto it = range.first; it != range.second; ++it) {
@@ -281,7 +306,8 @@
 }
 
 void UidMap::clearOutput() {
-    mOutput.Clear();
+    mSnapshots.clear();
+    mChanges.clear();
     // Also update the guardrail trackers.
     StatsdStats::getInstance().setUidMapChanges(0);
     StatsdStats::getInstance().setUidMapSnapshots(1);
@@ -305,59 +331,111 @@
     return mBytesUsed;
 }
 
-UidMapping UidMap::getOutput(const ConfigKey& key) {
-    return getOutput(getElapsedRealtimeNs(), key);
+void UidMap::getOutput(const ConfigKey& key, vector<uint8_t>* outData) {
+    getOutput(getElapsedRealtimeNs(), key, outData);
 }
 
-UidMapping UidMap::getOutput(const int64_t& timestamp, const ConfigKey& key) {
+void UidMap::getOutput(const int64_t& timestamp, const ConfigKey& key, vector<uint8_t>* outData) {
     lock_guard<mutex> lock(mMutex);  // Lock for updates
 
-    auto ret = UidMapping(mOutput);  // Copy that will be returned.
+    ProtoOutputStream proto;
+    for (const ChangeRecord& record : mChanges) {
+        if (record.timestampNs > mLastUpdatePerConfigKey[key]) {
+            uint64_t changesToken =
+                    proto.start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED | FIELD_ID_CHANGES);
+            proto.write(FIELD_TYPE_BOOL | FIELD_ID_CHANGE_DELETION, (bool)record.deletion);
+            proto.write(FIELD_TYPE_INT64 | FIELD_ID_CHANGE_TIMESTAMP,
+                        (long long)record.timestampNs);
+            proto.write(FIELD_TYPE_STRING | FIELD_ID_CHANGE_PACKAGE, record.package);
+            proto.write(FIELD_TYPE_INT32 | FIELD_ID_CHANGE_UID, (int)record.uid);
+            proto.write(FIELD_TYPE_INT32 | FIELD_ID_CHANGE_VERSION, (int)record.version);
+            proto.end(changesToken);
+        }
+    }
+
+    bool atLeastOneSnapshot = false;
+    unsigned int count = 0;
+    for (const SnapshotRecord& record : mSnapshots) {
+        // Ensure that we include at least the latest snapshot.
+        if ((count == mSnapshots.size() - 1 && !atLeastOneSnapshot) ||
+            record.timestampNs > mLastUpdatePerConfigKey[key]) {
+            uint64_t snapshotsToken =
+                    proto.start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED | FIELD_ID_SNAPSHOTS);
+            atLeastOneSnapshot = true;
+            count++;
+            proto.write(FIELD_TYPE_INT64 | FIELD_ID_SNAPSHOT_TIMESTAMP,
+                        (long long)record.timestampNs);
+            proto.write(FIELD_TYPE_MESSAGE | FIELD_ID_SNAPSHOT_PACKAGE_INFO, record.bytes.data());
+            proto.end(snapshotsToken);
+        }
+    }
+
     int64_t prevMin = getMinimumTimestampNs();
     mLastUpdatePerConfigKey[key] = timestamp;
     int64_t newMin = getMinimumTimestampNs();
 
-    if (newMin > prevMin) {  // Delete anything possible now that the minimum has moved forward.
+    if (newMin > prevMin) {  // Delete anything possible now that the minimum has
+                             // moved forward.
         int64_t cutoff_nanos = newMin;
-        auto snapshots = mOutput.mutable_snapshots();
-        auto it_snapshots = snapshots->cbegin();
-        while (it_snapshots != snapshots->cend()) {
-            if (it_snapshots->elapsed_timestamp_nanos() < cutoff_nanos) {
-                // it_snapshots points to the following element after erasing.
-                it_snapshots = snapshots->erase(it_snapshots);
-            } else {
-                ++it_snapshots;
+        for (auto it_snapshots = mSnapshots.begin(); it_snapshots != mSnapshots.end();
+             ++it_snapshots) {
+            if (it_snapshots->timestampNs < cutoff_nanos) {
+                mBytesUsed -= it_snapshots->bytes.size() + kBytesTimestampField;
+                mSnapshots.erase(it_snapshots);
             }
         }
-        auto deltas = mOutput.mutable_changes();
-        auto it_deltas = deltas->cbegin();
-        while (it_deltas != deltas->cend()) {
-            if (it_deltas->elapsed_timestamp_nanos() < cutoff_nanos) {
-                // it_snapshots points to the following element after erasing.
-                it_deltas = deltas->erase(it_deltas);
-            } else {
-                ++it_deltas;
+        for (auto it_changes = mChanges.begin(); it_changes != mChanges.end(); ++it_changes) {
+            if (it_changes->timestampNs < cutoff_nanos) {
+                mBytesUsed -= kBytesChangeRecord;
+                mChanges.erase(it_changes);
             }
         }
 
-        if (mOutput.snapshots_size() == 0) {
-            // Produce another snapshot. This results in extra data being uploaded but helps
-            // ensure we can re-construct the UID->app name, versionCode mapping in server.
-            auto snapshot = mOutput.add_snapshots();
-            snapshot->set_elapsed_timestamp_nanos(timestamp);
-            for (auto it : mMap) {
-                auto t = snapshot->add_package_info();
-                t->set_name(it.second.packageName);
-                t->set_version(it.second.versionCode);
-                t->set_uid(it.first);
+        if (mSnapshots.size() == 0) {
+            // Produce another snapshot. This results in extra data being uploaded but
+            // helps ensure we can re-construct the UID->app name, versionCode mapping
+            // in server.
+            ProtoOutputStream proto;
+            uint64_t token = proto.start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED |
+                                          FIELD_ID_SNAPSHOT_PACKAGE_INFO);
+            for (const auto& it : mMap) {
+                proto.write(FIELD_TYPE_STRING | FIELD_ID_SNAPSHOT_PACKAGE_NAME,
+                            it.second.packageName);
+                proto.write(FIELD_TYPE_INT32 | FIELD_ID_SNAPSHOT_PACKAGE_VERSION,
+                            (int)it.second.versionCode);
+                proto.write(FIELD_TYPE_INT32 | FIELD_ID_SNAPSHOT_PACKAGE_UID, (int)it.first);
             }
+            proto.end(token);
+
+            // Copy ProtoOutputStream output to
+            auto iter = proto.data();
+            vector<char> outData(proto.size());
+            size_t pos = 0;
+            while (iter.readBuffer() != NULL) {
+                size_t toRead = iter.currentToRead();
+                std::memcpy(&(outData[pos]), iter.readBuffer(), toRead);
+                pos += toRead;
+                iter.rp()->move(toRead);
+            }
+            mSnapshots.emplace_back(timestamp, outData);
+            mBytesUsed += kBytesTimestampField + outData.size();
         }
     }
-    mBytesUsed = mOutput.ByteSize();  // Compute actual size after potential deletions.
     StatsdStats::getInstance().setCurrentUidMapMemory(mBytesUsed);
-    StatsdStats::getInstance().setUidMapChanges(mOutput.changes_size());
-    StatsdStats::getInstance().setUidMapSnapshots(mOutput.snapshots_size());
-    return ret;
+    StatsdStats::getInstance().setUidMapChanges(mChanges.size());
+    StatsdStats::getInstance().setUidMapSnapshots(mSnapshots.size());
+    if (outData != nullptr) {
+        outData->clear();
+        outData->resize(proto.size());
+        size_t pos = 0;
+        auto iter = proto.data();
+        while (iter.readBuffer() != NULL) {
+            size_t toRead = iter.currentToRead();
+            std::memcpy(&((*outData)[pos]), iter.readBuffer(), toRead);
+            pos += toRead;
+            iter.rp()->move(toRead);
+        }
+    }
 }
 
 void UidMap::printUidMap(FILE* out) const {
@@ -374,7 +452,7 @@
 
     // Ensure there is at least one snapshot available since this configuration also needs to know
     // what all the uid's represent.
-    if (mOutput.snapshots_size() == 0) {
+    if (mSnapshots.size() == 0) {
         sp<IStatsCompanionService> statsCompanion = nullptr;
         // Get statscompanion service from service manager
         const sp<IServiceManager> sm(defaultServiceManager());
diff --git a/cmds/statsd/src/packages/UidMap.h b/cmds/statsd/src/packages/UidMap.h
index c41e0aa..b0181f7 100644
--- a/cmds/statsd/src/packages/UidMap.h
+++ b/cmds/statsd/src/packages/UidMap.h
@@ -18,7 +18,6 @@
 
 #include "config/ConfigKey.h"
 #include "config/ConfigListener.h"
-#include "frameworks/base/cmds/statsd/src/stats_log_common.pb.h"
 #include "packages/PackageInfoListener.h"
 
 #include <binder/IResultReceiver.h>
@@ -27,6 +26,7 @@
 #include <log/logprint.h>
 #include <stdio.h>
 #include <utils/RefBase.h>
+#include <list>
 #include <mutex>
 #include <set>
 #include <string>
@@ -45,6 +45,45 @@
     AppData(const string& a, const int64_t v) : packageName(a), versionCode(v){};
 };
 
+// When calling getOutput, we retrieve all the ChangeRecords since the last
+// timestamp we called getOutput for this configuration key.
+struct ChangeRecord {
+    const bool deletion;
+    const int64_t timestampNs;
+    const string package;
+    const int32_t uid;
+    const int32_t version;
+
+    ChangeRecord(const bool isDeletion, const int64_t timestampNs, const string& package,
+                 const int32_t uid, const int32_t version)
+        : deletion(isDeletion),
+          timestampNs(timestampNs),
+          package(package),
+          uid(uid),
+          version(version) {
+    }
+};
+
+const unsigned int kBytesChangeRecord = sizeof(struct ChangeRecord);
+
+// Storing the int64 for a timestamp is expected to take 10 bytes (could take
+// less because of varint encoding).
+const unsigned int kBytesTimestampField = 10;
+
+// When calling getOutput, we retrieve all the snapshots since the last
+// timestamp we called getOutput for this configuration key.
+struct SnapshotRecord {
+    const int64_t timestampNs;
+
+    // For performance reasons, we convert the package_info field (which is a
+    // repeated field of PackageInfo messages).
+    vector<char> bytes;
+
+    SnapshotRecord(const int64_t timestampNs, vector<char> bytes)
+        : timestampNs(timestampNs), bytes(bytes) {
+    }
+};
+
 // UidMap keeps track of what the corresponding app name (APK name) and version code for every uid
 // at any given moment. This map must be updated by StatsCompanionService.
 class UidMap : public virtual android::RefBase {
@@ -93,8 +132,10 @@
     // Returns the host uid if it exists. Otherwise, returns the same uid that was passed-in.
     virtual int getHostUidOrSelf(int uid) const;
 
-    // Gets the output. If every config key has received the output, then the output is cleared.
-    UidMapping getOutput(const ConfigKey& key);
+    // Gets all snapshots and changes that have occurred since the last output.
+    // If every config key has received a change or snapshot record, then this
+    // record is deleted.
+    void getOutput(const ConfigKey& key, vector<uint8_t>* outData);
 
     // Forces the output to be cleared. We still generate a snapshot based on the current state.
     // This results in extra data uploaded but helps us reconstruct the uid mapping on the server
@@ -117,7 +158,7 @@
                    const int64_t& versionCode);
     void removeApp(const int64_t& timestamp, const String16& packageName, const int32_t& uid);
 
-    UidMapping getOutput(const int64_t& timestamp, const ConfigKey& key);
+    void getOutput(const int64_t& timestamp, const ConfigKey& key, vector<uint8_t>* outData);
 
     void getListenerListCopyLocked(std::vector<wp<PackageInfoListener>>* output);
 
@@ -133,8 +174,11 @@
     // to the parent uid.
     std::unordered_map<int, int> mIsolatedUidMap;
 
-    // We prepare the output proto as apps are updated, so that we can grab the current output.
-    UidMapping mOutput;
+    // Record the changes that can be provided with the uploads.
+    std::list<ChangeRecord> mChanges;
+
+    // Record the snapshots that can be provided with the uploads.
+    std::list<SnapshotRecord> mSnapshots;
 
     // Metric producers that should be notified if there's an upgrade in any app.
     set<wp<PackageInfoListener>> mSubscribers;
diff --git a/cmds/statsd/src/stats_log.proto b/cmds/statsd/src/stats_log.proto
index 0412538..dd3b37c 100644
--- a/cmds/statsd/src/stats_log.proto
+++ b/cmds/statsd/src/stats_log.proto
@@ -22,7 +22,6 @@
 option java_outer_classname = "StatsLog";
 
 import "frameworks/base/cmds/statsd/src/atoms.proto";
-import "frameworks/base/cmds/statsd/src/stats_log_common.proto";
 
 message DimensionsValue {
   optional int32 field = 1;
@@ -148,6 +147,33 @@
   }
 }
 
+message UidMapping {
+    message PackageInfoSnapshot {
+        message PackageInfo {
+            optional string name = 1;
+
+            optional int64 version = 2;
+
+            optional int32 uid = 3;
+        }
+        optional int64 elapsed_timestamp_nanos = 1;
+
+        repeated PackageInfo package_info = 2;
+    }
+    repeated PackageInfoSnapshot snapshots = 1;
+
+    message Change {
+        optional bool deletion = 1;
+
+        optional int64 elapsed_timestamp_nanos = 2;
+        optional string app = 3;
+        optional int32 uid = 4;
+
+        optional int64 version = 5;
+    }
+    repeated Change changes = 2;
+}
+
 message ConfigMetricsReport {
   repeated StatsLogReport metrics = 1;
 
diff --git a/cmds/statsd/src/stats_log_common.proto b/cmds/statsd/src/stats_log_common.proto
deleted file mode 100644
index c41f31e..0000000
--- a/cmds/statsd/src/stats_log_common.proto
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.
- */
-
-syntax = "proto2";
-
-package android.os.statsd;
-
-option java_package = "com.android.os";
-option java_outer_classname = "StatsLogCommon";
-
-message UidMapping {
-    message PackageInfoSnapshot {
-        message PackageInfo {
-            optional string name = 1;
-
-            optional int64 version = 2;
-
-            optional int32 uid = 3;
-        }
-        optional int64 elapsed_timestamp_nanos = 1;
-
-        repeated PackageInfo package_info = 2;
-    }
-    repeated PackageInfoSnapshot snapshots = 1;
-
-    message Change {
-        optional bool deletion = 1;
-
-        optional int64 elapsed_timestamp_nanos = 2;
-        optional string app = 3;
-        optional int32 uid = 4;
-
-        optional int64 version = 5;
-    }
-    repeated Change changes = 2;
-}
\ No newline at end of file
diff --git a/cmds/statsd/src/stats_log_util.h b/cmds/statsd/src/stats_log_util.h
index c512e3c..9722050 100644
--- a/cmds/statsd/src/stats_log_util.h
+++ b/cmds/statsd/src/stats_log_util.h
@@ -19,7 +19,6 @@
 #include <android/util/ProtoOutputStream.h>
 #include "FieldValue.h"
 #include "HashableDimensionKey.h"
-#include "frameworks/base/cmds/statsd/src/stats_log_common.pb.h"
 #include "frameworks/base/cmds/statsd/src/statsd_config.pb.h"
 #include "guardrail/StatsdStats.h"
 
diff --git a/cmds/statsd/src/stats_util.h b/cmds/statsd/src/stats_util.h
index 80e46d6..e0206d1 100644
--- a/cmds/statsd/src/stats_util.h
+++ b/cmds/statsd/src/stats_util.h
@@ -17,7 +17,6 @@
 #pragma once
 
 #include "HashableDimensionKey.h"
-#include "frameworks/base/cmds/statsd/src/stats_log_common.pb.h"
 #include "logd/LogReader.h"
 
 #include <unordered_map>
diff --git a/cmds/statsd/tests/UidMap_test.cpp b/cmds/statsd/tests/UidMap_test.cpp
index ca656ed..ee7d770 100644
--- a/cmds/statsd/tests/UidMap_test.cpp
+++ b/cmds/statsd/tests/UidMap_test.cpp
@@ -174,41 +174,52 @@
     versions.push_back(4);
     versions.push_back(5);
     m.updateMap(1, uids, versions, apps);
-    EXPECT_EQ(1, m.mOutput.snapshots_size());
+    EXPECT_EQ(1U, m.mSnapshots.size());
 
-    UidMapping results = m.getOutput(2, config1);
+    vector<uint8_t> bytes;
+    m.getOutput(2, config1, &bytes);
+    UidMapping results;
+    results.ParseFromArray(bytes.data(), bytes.size());
     EXPECT_EQ(1, results.snapshots_size());
 
     // It should be cleared now
-    EXPECT_EQ(1, m.mOutput.snapshots_size());
-    results = m.getOutput(3, config1);
+    EXPECT_EQ(1U, m.mSnapshots.size());
+    bytes.clear();
+    m.getOutput(2, config1, &bytes);
+    results.ParseFromArray(bytes.data(), bytes.size());
     EXPECT_EQ(1, results.snapshots_size());
 
     // Now add another configuration.
     m.OnConfigUpdated(config2);
     m.updateApp(5, String16(kApp1.c_str()), 1000, 40);
-    EXPECT_EQ(1, m.mOutput.changes_size());
-    results = m.getOutput(6, config1);
+    EXPECT_EQ(1U, m.mChanges.size());
+    bytes.clear();
+    m.getOutput(6, config1, &bytes);
+    results.ParseFromArray(bytes.data(), bytes.size());
     EXPECT_EQ(1, results.snapshots_size());
     EXPECT_EQ(1, results.changes_size());
-    EXPECT_EQ(1, m.mOutput.changes_size());
+    EXPECT_EQ(1U, m.mChanges.size());
 
     // Add another delta update.
     m.updateApp(7, String16(kApp2.c_str()), 1001, 41);
-    EXPECT_EQ(2, m.mOutput.changes_size());
+    EXPECT_EQ(2U, m.mChanges.size());
 
     // We still can't remove anything.
-    results = m.getOutput(8, config1);
+    bytes.clear();
+    m.getOutput(8, config1, &bytes);
+    results.ParseFromArray(bytes.data(), bytes.size());
     EXPECT_EQ(1, results.snapshots_size());
-    EXPECT_EQ(2, results.changes_size());
-    EXPECT_EQ(2, m.mOutput.changes_size());
+    EXPECT_EQ(1, results.changes_size());
+    EXPECT_EQ(2U, m.mChanges.size());
 
-    results = m.getOutput(9, config2);
+    bytes.clear();
+    m.getOutput(9, config2, &bytes);
+    results.ParseFromArray(bytes.data(), bytes.size());
     EXPECT_EQ(1, results.snapshots_size());
     EXPECT_EQ(2, results.changes_size());
     // At this point both should be cleared.
-    EXPECT_EQ(1, m.mOutput.snapshots_size());
-    EXPECT_EQ(0, m.mOutput.changes_size());
+    EXPECT_EQ(1U, m.mSnapshots.size());
+    EXPECT_EQ(0U, m.mChanges.size());
 }
 
 TEST(UidMapTest, TestMemoryComputed) {
@@ -231,10 +242,11 @@
     m.updateApp(3, String16(kApp1.c_str()), 1000, 40);
     EXPECT_TRUE(m.mBytesUsed > snapshot_bytes);
 
-    m.getOutput(2, config1);
+    vector<uint8_t> bytes;
+    m.getOutput(2, config1, &bytes);
     size_t prevBytes = m.mBytesUsed;
 
-    m.getOutput(4, config1);
+    m.getOutput(4, config1, &bytes);
     EXPECT_TRUE(m.mBytesUsed < prevBytes);
 }
 
@@ -256,17 +268,17 @@
         versions.push_back(1);
     }
     m.updateMap(1, uids, versions, apps);
-    EXPECT_EQ(1, m.mOutput.snapshots_size());
+    EXPECT_EQ(1U, m.mSnapshots.size());
 
     m.updateApp(3, String16("EXTREMELY_LONG_STRING_FOR_APP_TO_WASTE_MEMORY.0"), 1000, 2);
-    EXPECT_EQ(1, m.mOutput.snapshots_size());
-    EXPECT_EQ(1, m.mOutput.changes_size());
+    EXPECT_EQ(1U, m.mSnapshots.size());
+    EXPECT_EQ(1U, m.mChanges.size());
 
     // Now force deletion by limiting the memory to hold one delta change.
     m.maxBytesOverride = 80; // Since the app string alone requires >45 characters.
     m.updateApp(5, String16("EXTREMELY_LONG_STRING_FOR_APP_TO_WASTE_MEMORY.0"), 1000, 4);
-    EXPECT_EQ(0, m.mOutput.snapshots_size());
-    EXPECT_EQ(1, m.mOutput.changes_size());
+    EXPECT_EQ(0U, m.mSnapshots.size());
+    EXPECT_EQ(1U, m.mChanges.size());
 }
 #else
 GTEST_LOG_(INFO) << "This test does nothing.\n";
diff --git a/config/hiddenapi-light-greylist.txt b/config/hiddenapi-light-greylist.txt
index 85f8684..444bdd5 100644
--- a/config/hiddenapi-light-greylist.txt
+++ b/config/hiddenapi-light-greylist.txt
@@ -11,6 +11,7 @@
 Landroid/app/ActivityManager;->getMaxRecentTasksStatic()I
 Landroid/app/ActivityManager;->getService()Landroid/app/IActivityManager;
 Landroid/app/ActivityManager;->IActivityManagerSingleton:Landroid/util/Singleton;
+Landroid/app/ActivityManager;->isHighEndGfx()Z
 Landroid/app/ActivityManager;->isLowRamDeviceStatic()Z
 Landroid/app/ActivityManager;->isUserRunning(I)Z
 Landroid/app/ActivityManager;->mContext:Landroid/content/Context;
@@ -96,6 +97,7 @@
 Landroid/app/ActivityThread;->mNumVisibleActivities:I
 Landroid/app/ActivityThread;->mPackages:Landroid/util/ArrayMap;
 Landroid/app/ActivityThread;->mProviderMap:Landroid/util/ArrayMap;
+Landroid/app/ActivityThread;->mResourcePackages:Landroid/util/ArrayMap;
 Landroid/app/ActivityThread;->mServices:Landroid/util/ArrayMap;
 Landroid/app/ActivityThread;->performNewIntents(Landroid/os/IBinder;Ljava/util/List;Z)V
 Landroid/app/ActivityThread;->performStopActivity(Landroid/os/IBinder;ZLjava/lang/String;)V
@@ -116,6 +118,7 @@
 Landroid/app/admin/DevicePolicyManager;->setActiveAdmin(Landroid/content/ComponentName;ZI)V
 Landroid/app/admin/DevicePolicyManager;->setActiveAdmin(Landroid/content/ComponentName;Z)V
 Landroid/app/admin/DevicePolicyManager;->throwIfParentInstance(Ljava/lang/String;)V
+Landroid/app/admin/DevicePolicyManager;->setDefaultSmsApplication(Landroid/content/ComponentName;Ljava/lang/String;)V
 Landroid/app/admin/IDevicePolicyManager$Stub;->TRANSACTION_packageHasActiveAdmins:I
 Landroid/app/admin/IDevicePolicyManager$Stub;->TRANSACTION_removeActiveAdmin:I
 Landroid/app/admin/SecurityLog$SecurityEvent;-><init>([B)V
@@ -230,6 +233,7 @@
 Landroid/app/IApplicationThread;->scheduleTrimMemory(I)V
 Landroid/app/INotificationManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/app/INotificationManager;
 Landroid/app/INotificationManager$Stub$Proxy;-><init>(Landroid/os/IBinder;)V
+Landroid/app/Instrumentation;->execStartActivities(Landroid/content/Context;Landroid/os/IBinder;Landroid/os/IBinder;Landroid/app/Activity;[Landroid/content/Intent;Landroid/os/Bundle;)V
 Landroid/app/Instrumentation;->execStartActivity(Landroid/content/Context;Landroid/os/IBinder;Landroid/os/IBinder;Landroid/app/Activity;Landroid/content/Intent;ILandroid/os/Bundle;)Landroid/app/Instrumentation$ActivityResult;
 Landroid/app/Instrumentation;->execStartActivity(Landroid/content/Context;Landroid/os/IBinder;Landroid/os/IBinder;Ljava/lang/String;Landroid/content/Intent;ILandroid/os/Bundle;)Landroid/app/Instrumentation$ActivityResult;
 Landroid/app/Instrumentation;->execStartActivity(Landroid/content/Context;Landroid/os/IBinder;Landroid/os/IBinder;Ljava/lang/String;Landroid/content/Intent;ILandroid/os/Bundle;Landroid/os/UserHandle;)Landroid/app/Instrumentation$ActivityResult;
@@ -309,6 +313,7 @@
 Landroid/app/trust/ITrustManager$Stub$Proxy;-><init>(Landroid/os/IBinder;)V
 Landroid/app/usage/UsageStatsManager;->mService:Landroid/app/usage/IUsageStatsManager;
 Landroid/app/usage/UsageStats;->mLastEvent:I
+Landroid/app/usage/UsageStats;->mTotalTimeInForeground:J
 Landroid/app/WallpaperColors;->getColorHints()I
 Landroid/app/WallpaperManager;->getBitmap()Landroid/graphics/Bitmap;
 Landroid/app/WallpaperManager;->getBitmap(Z)Landroid/graphics/Bitmap;
@@ -345,6 +350,7 @@
 Landroid/content/BroadcastReceiver;->setPendingResult(Landroid/content/BroadcastReceiver$PendingResult;)V
 Landroid/content/ContentProviderClient;->mContentProvider:Landroid/content/IContentProvider;
 Landroid/content/ContentProviderClient;->mPackageName:Ljava/lang/String;
+Landroid/content/ContentProvider;->coerceToLocalContentProvider(Landroid/content/IContentProvider;)Landroid/content/ContentProvider;
 Landroid/content/ContentProvider;->mContext:Landroid/content/Context;
 Landroid/content/ContentProvider;->mPathPermissions:[Landroid/content/pm/PathPermission;
 Landroid/content/ContentProvider;->mReadPermission:Ljava/lang/String;
@@ -354,11 +360,19 @@
 Landroid/content/ContentProviderOperation;->TYPE_DELETE:I
 Landroid/content/ContentProviderOperation;->TYPE_INSERT:I
 Landroid/content/ContentProviderOperation;->TYPE_UPDATE:I
+Landroid/content/ContentProvider;->setAppOps(II)V
+Landroid/content/ContentResolver;->acquireExistingProvider(Landroid/content/Context;Ljava/lang/String;)Landroid/content/IContentProvider;
+Landroid/content/ContentResolver;->acquireProvider(Landroid/content/Context;Ljava/lang/String;)Landroid/content/IContentProvider;
 Landroid/content/ContentResolver;->acquireProvider(Landroid/net/Uri;)Landroid/content/IContentProvider;
+Landroid/content/ContentResolver;->acquireProvider(Ljava/lang/String;)Landroid/content/IContentProvider;
+Landroid/content/ContentResolver;->acquireUnstableProvider(Landroid/content/Context;Ljava/lang/String;)Landroid/content/IContentProvider;
 Landroid/content/ContentResolver;->getContentService()Landroid/content/IContentService;
 Landroid/content/ContentResolver;->getSyncStatus(Landroid/accounts/Account;Ljava/lang/String;)Landroid/content/SyncStatusInfo;
 Landroid/content/ContentResolver;->mContext:Landroid/content/Context;
 Landroid/content/ContentResolver;->mPackageName:Ljava/lang/String;
+Landroid/content/ContentResolver;->releaseProvider(Landroid/content/IContentProvider;)Z
+Landroid/content/ContentResolver;->releaseUnstableProvider(Landroid/content/IContentProvider;)Z
+Landroid/content/ContentResolver;->unstableProviderDied(Landroid/content/IContentProvider;)V
 Landroid/content/ContentValues;-><init>(Ljava/util/HashMap;)V
 Landroid/content/ContentValues;->mValues:Ljava/util/HashMap;
 Landroid/content/Context;->getSharedPrefsFile(Ljava/lang/String;)Ljava/io/File;
@@ -391,6 +405,7 @@
 Landroid/content/pm/ApplicationInfo;->scanPublicSourceDir:Ljava/lang/String;
 Landroid/content/pm/ApplicationInfo;->scanSourceDir:Ljava/lang/String;
 Landroid/content/pm/ApplicationInfo;->secondaryNativeLibraryDir:Ljava/lang/String;
+Landroid/content/pm/ComponentInfo;->getComponentName()Landroid/content/ComponentName;
 Landroid/content/pm/IPackageManager;->getInstallLocation()I
 Landroid/content/pm/IPackageManager;->getLastChosenActivity(Landroid/content/Intent;Ljava/lang/String;I)Landroid/content/pm/ResolveInfo;
 Landroid/content/pm/IPackageManager;->setApplicationEnabledSetting(Ljava/lang/String;IIILjava/lang/String;)V
@@ -404,6 +419,7 @@
 Landroid/content/pm/LauncherActivityInfo;->mActivityInfo:Landroid/content/pm/ActivityInfo;
 Landroid/content/pm/LauncherApps;->mPm:Landroid/content/pm/PackageManager;
 Landroid/content/pm/LauncherApps;->startShortcut(Ljava/lang/String;Ljava/lang/String;Landroid/graphics/Rect;Landroid/os/Bundle;I)V
+Landroid/content/pm/PackageItemInfo;->setForceSafeLabels(Z)V
 Landroid/content/pm/PackageManager;->buildRequestPermissionsIntent([Ljava/lang/String;)Landroid/content/Intent;
 Landroid/content/pm/PackageManager;->freeStorageAndNotify(JLandroid/content/pm/IPackageDataObserver;)V
 Landroid/content/pm/PackageManager;->freeStorageAndNotify(Ljava/lang/String;JLandroid/content/pm/IPackageDataObserver;)V
@@ -502,6 +518,7 @@
 Landroid/content/res/Resources;->setCompatibilityInfo(Landroid/content/res/CompatibilityInfo;)V
 Landroid/content/res/Resources;->updateSystemConfiguration(Landroid/content/res/Configuration;Landroid/util/DisplayMetrics;Landroid/content/res/CompatibilityInfo;)V
 Landroid/content/res/StringBlock;-><init>(JZ)V
+Landroid/content/res/TypedArray;->extractThemeAttrs()[I
 Landroid/content/res/TypedArray;->getNonConfigurationString(II)Ljava/lang/String;
 Landroid/content/res/TypedArray;->getValueAt(ILandroid/util/TypedValue;)Z
 Landroid/content/res/TypedArray;->mAssets:Landroid/content/res/AssetManager;
@@ -518,6 +535,7 @@
 Landroid/content/res/XmlBlock;->newParser()Landroid/content/res/XmlResourceParser;
 Landroid/content/res/XmlBlock$Parser;->mBlock:Landroid/content/res/XmlBlock;
 Landroid/content/res/XmlBlock$Parser;->mParseState:J
+Landroid/content/SearchRecentSuggestionsProvider;->mSuggestionProjection:[Ljava/lang/String;
 Landroid/content/SyncStatusInfo;->lastSuccessTime:J
 Landroid/database/AbstractCursor;->mExtras:Landroid/os/Bundle;
 Landroid/database/AbstractCursor;->mNotifyUri:Landroid/net/Uri;
@@ -556,6 +574,7 @@
 Landroid/graphics/Camera;->native_instance:J
 Landroid/graphics/Canvas;-><init>(J)V
 Landroid/graphics/Canvas;->release()V
+Landroid/graphics/ColorMatrixColorFilter;->setColorMatrix(Landroid/graphics/ColorMatrix;)V
 Landroid/graphics/drawable/AnimatedImageDrawable;->onAnimationEnd()V
 Landroid/graphics/drawable/AnimatedStateListDrawable$AnimatedStateListState;->mStateIds:Landroid/util/SparseIntArray;
 Landroid/graphics/drawable/AnimatedStateListDrawable$AnimatedStateListState;->mTransitions:Landroid/util/LongSparseLongArray;
@@ -622,6 +641,8 @@
 Landroid/graphics/NinePatch$InsetStruct;-><init>(IIIIIIIIFIF)V
 Landroid/graphics/NinePatch;->mBitmap:Landroid/graphics/Bitmap;
 Landroid/graphics/Picture;->mNativePicture:J
+Landroid/graphics/PorterDuffColorFilter;->setColor(I)V
+Landroid/graphics/PorterDuffColorFilter;->setMode(Landroid/graphics/PorterDuff$Mode;)V
 Landroid/graphics/Region;-><init>(JI)V
 Landroid/graphics/Region;->mNativeRegion:J
 Landroid/graphics/SurfaceTexture;->mFrameAvailableListener:J
@@ -629,6 +650,7 @@
 Landroid/graphics/SurfaceTexture;->mSurfaceTexture:J
 Landroid/graphics/SurfaceTexture;->nativeDetachFromGLContext()I
 Landroid/graphics/SurfaceTexture;->postEventFromNative(Ljava/lang/ref/WeakReference;)V
+Landroid/graphics/Typeface;->createFromFamiliesWithDefault([Landroid/graphics/FontFamily;II)Landroid/graphics/Typeface;
 Landroid/graphics/Typeface;->createFromFamiliesWithDefault([Landroid/graphics/FontFamily;Ljava/lang/String;II)Landroid/graphics/Typeface;
 Landroid/graphics/Typeface;->mStyle:I
 Landroid/graphics/Typeface;->sDefaults:[Landroid/graphics/Typeface;
@@ -694,8 +716,13 @@
 Landroid/hardware/usb/UsbManager;->setCurrentFunction(Ljava/lang/String;Z)V
 Landroid/hardware/usb/UsbManager;->setPortRoles(Landroid/hardware/usb/UsbPort;II)V
 Landroid/hardware/usb/UsbPortStatus;->getCurrentDataRole()I
+Landroid/hardware/usb/UsbPortStatus;->getCurrentMode()I
+Landroid/hardware/usb/UsbPortStatus;->getCurrentPowerRole()I
+Landroid/hardware/usb/UsbPortStatus;->getSupportedRoleCombinations()I
 Landroid/hardware/usb/UsbPortStatus;->isConnected()Z
 Landroid/hardware/usb/UsbPortStatus;->isRoleCombinationSupported(II)Z
+Landroid/hardware/usb/UsbRequest;->mBuffer:Ljava/nio/ByteBuffer;
+Landroid/hardware/usb/UsbRequest;->mLength:I
 Landroid/hardware/usb/UsbRequest;->mNativeContext:J
 Landroid/icu/impl/CurrencyData;-><init>()V
 Landroid/icu/impl/number/DecimalFormatProperties;->readObject(Ljava/io/ObjectInputStream;)V
@@ -773,7 +800,9 @@
 Landroid/media/AudioFormat;->mSampleRate:I
 Landroid/media/audiofx/AudioEffect;->command(I[B[B)I
 Landroid/media/audiofx/AudioEffect;->getParameter([I[B)I
+Landroid/media/audiofx/AudioEffect;->getParameter([I[I)I
 Landroid/media/audiofx/AudioEffect;-><init>(Ljava/util/UUID;Ljava/util/UUID;II)V
+Landroid/media/audiofx/AudioEffect;->setParameter([I[S)I
 Landroid/media/AudioGainConfig;-><init>(ILandroid/media/AudioGain;II[II)V
 Landroid/media/AudioGainConfig;->mChannelMask:I
 Landroid/media/AudioGainConfig;->mIndex:I
@@ -833,6 +862,7 @@
 Landroid/media/AudioSystem;->getPrimaryOutputSamplingRate()I
 Landroid/media/AudioSystem;->recordingCallbackFromNative(IIII[I)V
 Landroid/media/AudioSystem;->setDeviceConnectionState(IILjava/lang/String;Ljava/lang/String;)I
+Landroid/media/AudioSystem;->setErrorCallback(Landroid/media/AudioSystem$ErrorCallback;)V
 Landroid/media/AudioTrack;->deferred_connect(J)V
 Landroid/media/AudioTrack;->getLatency()I
 Landroid/media/AudioTrack;->mJniData:J
@@ -840,6 +870,9 @@
 Landroid/media/AudioTrack;->mStreamType:I
 Landroid/media/AudioTrack;->native_release()V
 Landroid/media/AudioTrack;->postEventFromNative(Ljava/lang/Object;IIILjava/lang/Object;)V
+Landroid/media/IAudioService;->getStreamMaxVolume(I)I
+Landroid/media/IAudioService;->getStreamVolume(I)I
+Landroid/media/IAudioService;->setStreamVolume(IIILjava/lang/String;)V
 Landroid/media/IAudioService$Stub;->asInterface(Landroid/os/IBinder;)Landroid/media/IAudioService;
 Landroid/media/IAudioService$Stub$Proxy;-><init>(Landroid/os/IBinder;)V
 Landroid/media/JetPlayer;->mNativePlayerInJavaObj:J
@@ -894,6 +927,7 @@
 Landroid/media/RemoteDisplay;->notifyDisplayError(I)V
 Landroid/media/RingtoneManager;->getRingtone(Landroid/content/Context;Landroid/net/Uri;I)Landroid/media/Ringtone;
 Landroid/media/session/MediaSessionLegacyHelper;->getHelper(Landroid/content/Context;)Landroid/media/session/MediaSessionLegacyHelper;
+Landroid/media/session/MediaSession;->mCallback:Landroid/media/session/MediaSession$CallbackMessageHandler;
 Landroid/media/soundtrigger/SoundTriggerDetector$EventPayload;->getCaptureSession()Ljava/lang/Integer;
 Landroid/media/soundtrigger/SoundTriggerDetector$EventPayload;->getData()[B
 Landroid/media/soundtrigger/SoundTriggerManager;->loadSoundModel(Landroid/hardware/soundtrigger/SoundTrigger$SoundModel;)I
@@ -954,6 +988,7 @@
 Landroid/net/NetworkPolicyManager;->mService:Landroid/net/INetworkPolicyManager;
 Landroid/net/NetworkStats;->capacity:I
 Landroid/net/NetworkStats;->defaultNetwork:[I
+Landroid/net/NetworkStatsHistory$Entry;->rxBytes:J
 Landroid/net/NetworkStats;->iface:[Ljava/lang/String;
 Landroid/net/NetworkStats;->metered:[I
 Landroid/net/NetworkStats;->operations:[J
@@ -966,7 +1001,9 @@
 Landroid/net/NetworkStats;->txBytes:[J
 Landroid/net/NetworkStats;->txPackets:[J
 Landroid/net/NetworkStats;->uid:[I
+Landroid/net/NetworkTemplate;->buildTemplateWifi()Landroid/net/NetworkTemplate;
 Landroid/net/ProxyInfo;-><init>(Ljava/lang/String;ILjava/lang/String;)V
+Landroid/net/SntpClient;-><init>()V
 Landroid/net/SSLCertificateSocketFactory;->castToOpenSSLSocket(Ljava/net/Socket;)Lcom/android/org/conscrypt/OpenSSLSocketImpl;
 Landroid/net/SSLCertificateSocketFactory;->getAlpnSelectedProtocol(Ljava/net/Socket;)[B
 Landroid/net/SSLCertificateSocketFactory;->getDelegate()Ljavax/net/ssl/SSLSocketFactory;
@@ -1043,6 +1080,7 @@
 Landroid/os/BatteryStats;->getUidStats()Landroid/util/SparseArray;
 Landroid/os/BatteryStats$HistoryItem;->states2:I
 Landroid/os/BatteryStats;->NUM_DATA_CONNECTION_TYPES:I
+Landroid/os/BatteryStats;->startIteratingHistoryLocked()Z
 Landroid/os/BatteryStats$Timer;->getTotalTimeLocked(JI)J
 Landroid/os/BatteryStats$Uid;->getFullWifiLockTime(JI)J
 Landroid/os/BatteryStats$Uid;->getProcessStats()Landroid/util/ArrayMap;
@@ -1107,6 +1145,7 @@
 Landroid/os/FileUtils;->stringToFile(Ljava/lang/String;Ljava/lang/String;)V
 Landroid/os/Handler;->getIMessenger()Landroid/os/IMessenger;
 Landroid/os/Handler;->hasCallbacks(Ljava/lang/Runnable;)Z
+Landroid/os/Handler;-><init>(Z)V
 Landroid/os/Handler;->mCallback:Landroid/os/Handler$Callback;
 Landroid/os/Handler;->mMessenger:Landroid/os/IMessenger;
 Landroid/os/HwParcel;-><init>(Z)V
@@ -1220,14 +1259,31 @@
 Landroid/os/UpdateLock;->release()V
 Landroid/os/UpdateLock;->TIMESTAMP:Ljava/lang/String;
 Landroid/os/UpdateLock;->UPDATE_LOCK_CHANGED:Ljava/lang/String;
+Landroid/os/UserHandle;->AID_APP_END:I
+Landroid/os/UserHandle;->AID_APP_START:I
+Landroid/os/UserHandle;->AID_CACHE_GID_START:I
+Landroid/os/UserHandle;->AID_ROOT:I
+Landroid/os/UserHandle;->AID_SHARED_GID_START:I
 Landroid/os/UserHandle;->ALL:Landroid/os/UserHandle;
+Landroid/os/UserHandle;->CURRENT:Landroid/os/UserHandle;
+Landroid/os/UserHandle;->CURRENT_OR_SELF:Landroid/os/UserHandle;
+Landroid/os/UserHandle;->ERR_GID:I
 Landroid/os/UserHandle;->getAppIdFromSharedAppGid(I)I
 Landroid/os/UserHandle;->getCallingUserId()I
 Landroid/os/UserHandle;->getUid(II)I
 Landroid/os/UserHandle;->getUserId(I)I
 Landroid/os/UserHandle;-><init>(I)V
+Landroid/os/UserHandle;->MU_ENABLED:Z
+Landroid/os/UserHandle;->OWNER:Landroid/os/UserHandle;
 Landroid/os/UserHandle;->PER_USER_RANGE:I
+Landroid/os/UserHandle;->SYSTEM:Landroid/os/UserHandle;
+Landroid/os/UserHandle;->USER_ALL:I
+Landroid/os/UserHandle;->USER_CURRENT:I
+Landroid/os/UserHandle;->USER_CURRENT_OR_SELF:I
+Landroid/os/UserHandle;->USER_NULL:I
 Landroid/os/UserHandle;->USER_OWNER:I
+Landroid/os/UserHandle;->USER_SERIAL_SYSTEM:I
+Landroid/os/UserHandle;->USER_SYSTEM:I
 Landroid/os/UserManager;->getBadgedLabelForUser(Ljava/lang/CharSequence;Landroid/os/UserHandle;)Ljava/lang/CharSequence;
 Landroid/os/UserManager;->get(Landroid/content/Context;)Landroid/os/UserManager;
 Landroid/os/UserManager;->getMaxSupportedUsers()I
@@ -1238,10 +1294,23 @@
 Landroid/os/UserManager;->getUserInfo(I)Landroid/content/pm/UserInfo;
 Landroid/os/UserManager;->getUserSerialNumber(I)I
 Landroid/os/UserManager;->getUsers()Ljava/util/List;
+Landroid/os/UserManager;->getUserStartRealtime()J
+Landroid/os/UserManager;->getUserUnlockRealtime()J
 Landroid/os/UserManager;->hasBaseUserRestriction(Ljava/lang/String;Landroid/os/UserHandle;)Z
 Landroid/os/UserManager;->isLinkedUser()Z
 Landroid/os/UserManager;->isUserUnlocked(I)Z
+Landroid/os/VintfObject;->getHalNamesAndVersions()[Ljava/lang/String;
+Landroid/os/VintfObject;->getSepolicyVersion()Ljava/lang/String;
+Landroid/os/VintfObject;->getTargetFrameworkCompatibilityMatrixVersion()Ljava/lang/Long;
+Landroid/os/VintfObject;->getVndkSnapshots()Ljava/util/Map;
 Landroid/os/VintfObject;->report()[Ljava/lang/String;
+Landroid/os/VintfRuntimeInfo;->getCpuInfo()Ljava/lang/String;
+Landroid/os/VintfRuntimeInfo;->getHardwareId()Ljava/lang/String;
+Landroid/os/VintfRuntimeInfo;->getKernelVersion()Ljava/lang/String;
+Landroid/os/VintfRuntimeInfo;->getNodeName()Ljava/lang/String;
+Landroid/os/VintfRuntimeInfo;->getOsName()Ljava/lang/String;
+Landroid/os/VintfRuntimeInfo;->getOsRelease()Ljava/lang/String;
+Landroid/os/VintfRuntimeInfo;->getOsVersion()Ljava/lang/String;
 Landroid/os/WorkSource;->add(ILjava/lang/String;)Z
 Landroid/os/WorkSource;->add(I)Z
 Landroid/os/WorkSource;->addReturningNewbs(Landroid/os/WorkSource;)Landroid/os/WorkSource;
@@ -1296,6 +1365,8 @@
 Landroid/provider/Browser;->deleteFromHistory(Landroid/content/ContentResolver;Ljava/lang/String;)V
 Landroid/provider/Browser;->getVisitedHistory(Landroid/content/ContentResolver;)[Ljava/lang/String;
 Landroid/provider/Browser;->sendString(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V
+Landroid/provider/CalendarContract$CalendarAlerts;->findNextAlarmTime(Landroid/content/ContentResolver;J)J
+Landroid/provider/CalendarContract$CalendarAlerts;->rescheduleMissedAlarms(Landroid/content/ContentResolver;Landroid/content/Context;Landroid/app/AlarmManager;)V
 Landroid/provider/Settings$ContentProviderHolder;->mContentProvider:Landroid/content/IContentProvider;
 Landroid/provider/Settings$Global;->ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED:Ljava/lang/String;
 Landroid/provider/Settings$Global;->PACKAGE_VERIFIER_ENABLE:Ljava/lang/String;
@@ -1569,6 +1640,60 @@
 Landroid/service/wallpaper/WallpaperService$Engine;->setFixedSizeAllowed(Z)V
 Landroid/speech/tts/TextToSpeech;->getCurrentEngine()Ljava/lang/String;
 Landroid/system/Int32Ref;->value:I
+Landroid/system/OsConstants;->AF_NETLINK:I
+Landroid/system/OsConstants;->AF_PACKET:I
+Landroid/system/OsConstants;->ARPHRD_ETHER:I
+Landroid/system/OsConstants;->ARPHRD_LOOPBACK:I
+Landroid/system/OsConstants;->CAP_TO_INDEX(I)I
+Landroid/system/OsConstants;->CAP_TO_MASK(I)I
+Landroid/system/OsConstants;->ENONET:I
+Landroid/system/OsConstants;->ETH_P_ALL:I
+Landroid/system/OsConstants;->ETH_P_ARP:I
+Landroid/system/OsConstants;->ETH_P_IP:I
+Landroid/system/OsConstants;->ETH_P_IPV6:I
+Landroid/system/OsConstants;->EUSERS:I
+Landroid/system/OsConstants;->ICMP6_ECHO_REPLY:I
+Landroid/system/OsConstants;->ICMP6_ECHO_REQUEST:I
+Landroid/system/OsConstants;->ICMP_ECHO:I
+Landroid/system/OsConstants;->ICMP_ECHOREPLY:I
+Landroid/system/OsConstants;->initConstants()V
+Landroid/system/OsConstants;-><init>()V
+Landroid/system/OsConstants;->IP_MULTICAST_ALL:I
+Landroid/system/OsConstants;->IP_RECVTOS:I
+Landroid/system/OsConstants;->_LINUX_CAPABILITY_VERSION_3:I
+Landroid/system/OsConstants;->MAP_POPULATE:I
+Landroid/system/OsConstants;->NETLINK_NETFILTER:I
+Landroid/system/OsConstants;->NETLINK_ROUTE:I
+Landroid/system/OsConstants;->O_DIRECT:I
+Landroid/system/OsConstants;->placeholder()I
+Landroid/system/OsConstants;->PR_CAP_AMBIENT:I
+Landroid/system/OsConstants;->PR_CAP_AMBIENT_RAISE:I
+Landroid/system/OsConstants;->RLIMIT_NOFILE:I
+Landroid/system/OsConstants;->RTMGRP_IPV4_IFADDR:I
+Landroid/system/OsConstants;->RTMGRP_IPV4_MROUTE:I
+Landroid/system/OsConstants;->RTMGRP_IPV4_ROUTE:I
+Landroid/system/OsConstants;->RTMGRP_IPV4_RULE:I
+Landroid/system/OsConstants;->RTMGRP_IPV6_IFADDR:I
+Landroid/system/OsConstants;->RTMGRP_IPV6_IFINFO:I
+Landroid/system/OsConstants;->RTMGRP_IPV6_MROUTE:I
+Landroid/system/OsConstants;->RTMGRP_IPV6_PREFIX:I
+Landroid/system/OsConstants;->RTMGRP_IPV6_ROUTE:I
+Landroid/system/OsConstants;->RTMGRP_LINK:I
+Landroid/system/OsConstants;->RTMGRP_NEIGH:I
+Landroid/system/OsConstants;->RTMGRP_NOTIFY:I
+Landroid/system/OsConstants;->RTMGRP_TC:I
+Landroid/system/OsConstants;->SO_DOMAIN:I
+Landroid/system/OsConstants;->SO_PROTOCOL:I
+Landroid/system/OsConstants;->SPLICE_F_MORE:I
+Landroid/system/OsConstants;->SPLICE_F_MOVE:I
+Landroid/system/OsConstants;->SPLICE_F_NONBLOCK:I
+Landroid/system/OsConstants;->TIOCOUTQ:I
+Landroid/system/OsConstants;->UDP_ENCAP_ESPINUDP:I
+Landroid/system/OsConstants;->UDP_ENCAP_ESPINUDP_NON_IKE:I
+Landroid/system/OsConstants;->UDP_ENCAP:I
+Landroid/system/OsConstants;->UNIX_PATH_MAX:I
+Landroid/system/OsConstants;->XATTR_CREATE:I
+Landroid/system/OsConstants;->XATTR_REPLACE:I
 Landroid/system/StructTimeval;->fromMillis(J)Landroid/system/StructTimeval;
 Landroid/telecom/TelecomManager;->EXTRA_IS_HANDOVER:Ljava/lang/String;
 Landroid/telecom/TelecomManager;->getUserSelectedOutgoingPhoneAccount()Landroid/telecom/PhoneAccountHandle;
@@ -1591,6 +1716,7 @@
 Landroid/telephony/SignalStrength;->getLteRsrq()I
 Landroid/telephony/SignalStrength;->getLteRssnr()I
 Landroid/telephony/SignalStrength;->getLteSignalStrength()I
+Landroid/telephony/SignalStrength;-><init>()V
 Landroid/telephony/SignalStrength;->mGsmBitErrorRate:I
 Landroid/telephony/SignalStrength;->mGsmSignalStrength:I
 Landroid/telephony/SignalStrength;->mLteCqi:I
@@ -1726,7 +1852,9 @@
 Landroid/util/NtpTrustedTime;->getCachedNtpTimeReference()J
 Landroid/util/NtpTrustedTime;->getInstance(Landroid/content/Context;)Landroid/util/NtpTrustedTime;
 Landroid/util/NtpTrustedTime;->hasCache()Z
+Landroid/util/Pools$SimplePool;->mPool:[Ljava/lang/Object;
 Landroid/util/Pools$SynchronizedPool;->acquire()Ljava/lang/Object;
+Landroid/util/Pools$SynchronizedPool;-><init>(I)V
 Landroid/util/Rational;->mDenominator:I
 Landroid/util/Rational;->mNumerator:I
 Landroid/util/Rational;->readObject(Ljava/io/ObjectInputStream;)V
@@ -1909,6 +2037,7 @@
 Landroid/view/View;->fitsSystemWindows()Z
 Landroid/view/View;->getAccessibilityDelegate()Landroid/view/View$AccessibilityDelegate;
 Landroid/view/View;->getListenerInfo()Landroid/view/View$ListenerInfo;
+Landroid/view/View;->getLocationOnScreen()[I
 Landroid/view/View;->getTransitionAlpha()F
 Landroid/view/View;->getViewRootImpl()Landroid/view/ViewRootImpl;
 Landroid/view/ViewGroup;->dispatchViewAdded(Landroid/view/View;)V
@@ -2293,6 +2422,7 @@
 Lcom/android/ims/internal/uce/presence/PresTupleInfo;->setContactUri(Ljava/lang/String;)V
 Lcom/android/ims/internal/uce/presence/PresTupleInfo;->setFeatureTag(Ljava/lang/String;)V
 Lcom/android/ims/internal/uce/presence/PresTupleInfo;->setTimestamp(Ljava/lang/String;)V
+Lcom/android/ims/internal/uce/uceservice/IUceListener$Stub;-><init>()V
 Lcom/android/internal/app/AlertController$RecycleListView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
 Lcom/android/internal/app/IAppOpsService$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/app/IAppOpsService;
 Lcom/android/internal/app/IAppOpsService$Stub$Proxy;->checkOperation(IILjava/lang/String;)I
@@ -2300,6 +2430,7 @@
 Lcom/android/internal/app/IBatteryStats;->getStatistics()[B
 Lcom/android/internal/app/IBatteryStats$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/app/IBatteryStats;
 Lcom/android/internal/app/IBatteryStats$Stub$Proxy;-><init>(Landroid/os/IBinder;)V
+Lcom/android/internal/app/IVoiceInteractionManagerService;->getKeyphraseSoundModel(ILjava/lang/String;)Landroid/hardware/soundtrigger/SoundTrigger$KeyphraseSoundModel;
 Lcom/android/internal/app/IVoiceInteractionManagerService$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/app/IVoiceInteractionManagerService;
 Lcom/android/internal/app/IVoiceInteractionManagerService$Stub$Proxy;->showSessionFromSession(Landroid/os/IBinder;Landroid/os/Bundle;I)Z
 Lcom/android/internal/location/ILocationProvider$Stub;-><init>()V
@@ -2592,6 +2723,7 @@
 Ldalvik/system/DexFile;->loadClassBinaryName(Ljava/lang/String;Ljava/lang/ClassLoader;Ljava/util/List;)Ljava/lang/Class;
 Ldalvik/system/DexFile;->mCookie:Ljava/lang/Object;
 Ldalvik/system/DexFile;->mFileName:Ljava/lang/String;
+Ldalvik/system/DexFile;->mInternalCookie:Ljava/lang/Object;
 Ldalvik/system/DexFile;->openDexFile(Ljava/lang/String;Ljava/lang/String;ILjava/lang/ClassLoader;[Ldalvik/system/DexPathList$Element;)Ljava/lang/Object;
 Ldalvik/system/DexPathList;->addDexPath(Ljava/lang/String;Ljava/io/File;)V
 Ldalvik/system/DexPathList;->dexElements:[Ldalvik/system/DexPathList$Element;
diff --git a/config/hiddenapi-vendor-list.txt b/config/hiddenapi-vendor-list.txt
new file mode 100644
index 0000000..02d1ee0
--- /dev/null
+++ b/config/hiddenapi-vendor-list.txt
@@ -0,0 +1,552 @@
+Landroid/app/ActivityManager$RecentTaskInfo;->configuration:Landroid/content/res/Configuration;
+Landroid/app/ActivityManager$TaskDescription;->loadTaskDescriptionIcon(Ljava/lang/String;I)Landroid/graphics/Bitmap;
+Landroid/app/ActivityManager$TaskSnapshot;->getSnapshot()Landroid/graphics/GraphicBuffer;
+Landroid/app/ActivityOptions;->makeRemoteAnimation(Landroid/view/RemoteAnimationAdapter;)Landroid/app/ActivityOptions;
+Landroid/app/ActivityOptions;->setSplitScreenCreateMode(I)V
+Landroid/app/Activity;->registerRemoteAnimations(Landroid/view/RemoteAnimationDefinition;)V
+Landroid/app/IActivityController$Stub;-><init>()V
+Landroid/app/IActivityManager;->cancelRecentsAnimation()V
+Landroid/app/IActivityManager;->cancelTaskWindowTransition(I)V
+Landroid/app/IActivityManager;->closeSystemDialogs(Ljava/lang/String;)V
+Landroid/app/IActivityManager;->getCurrentUser()Landroid/content/pm/UserInfo;
+Landroid/app/IActivityManager;->getFilteredTasks(III)Ljava/util/List;
+Landroid/app/IActivityManager;->getLockTaskModeState()I
+Landroid/app/IActivityManager;->getRecentTasks(III)Landroid/content/pm/ParceledListSlice;
+Landroid/app/IActivityManager;->getTaskSnapshot(IZ)Landroid/app/ActivityManager$TaskSnapshot;
+Landroid/app/IActivityManager;->registerTaskStackListener(Landroid/app/ITaskStackListener;)V
+Landroid/app/IActivityManager;->removeTask(I)Z
+Landroid/app/IActivityManager;->startActivityFromRecents(ILandroid/os/Bundle;)I
+Landroid/app/IActivityManager;->startRecentsActivity(Landroid/content/Intent;Landroid/app/IAssistDataReceiver;Landroid/view/IRecentsAnimationRunner;)V
+Landroid/app/IAssistDataReceiver;->onHandleAssistData(Landroid/os/Bundle;)V
+Landroid/app/IAssistDataReceiver;->onHandleAssistScreenshot(Landroid/graphics/Bitmap;)V
+Landroid/app/IAssistDataReceiver$Stub;-><init>()V
+Landroid/app/KeyguardManager;->isDeviceLocked(I)Z
+Landroid/app/StatusBarManager;->removeIcon(Ljava/lang/String;)V
+Landroid/app/StatusBarManager;->setIcon(Ljava/lang/String;IILjava/lang/String;)V
+Landroid/app/TaskStackListener;->onActivityDismissingDockedStack()V
+Landroid/app/TaskStackListener;->onActivityForcedResizable(Ljava/lang/String;II)V
+Landroid/app/TaskStackListener;->onActivityLaunchOnSecondaryDisplayFailed()V
+Landroid/app/TaskStackListener;->onActivityPinned(Ljava/lang/String;III)V
+Landroid/app/TaskStackListener;->onActivityRequestedOrientationChanged(II)V
+Landroid/app/TaskStackListener;->onActivityUnpinned()V
+Landroid/app/TaskStackListener;->onPinnedActivityRestartAttempt(Z)V
+Landroid/app/TaskStackListener;->onPinnedStackAnimationEnded()V
+Landroid/app/TaskStackListener;->onPinnedStackAnimationStarted()V
+Landroid/app/TaskStackListener;->onTaskMovedToFront(I)V
+Landroid/app/TaskStackListener;->onTaskProfileLocked(II)V
+Landroid/app/TaskStackListener;->onTaskRemoved(I)V
+Landroid/app/TaskStackListener;->onTaskSnapshotChanged(ILandroid/app/ActivityManager$TaskSnapshot;)V
+Landroid/app/TaskStackListener;->onTaskStackChanged()V
+Landroid/app/VrStateCallback;-><init>()V
+Landroid/app/VrStateCallback;->onPersistentVrStateChanged(Z)V
+Landroid/app/WallpaperColors;-><init>(Landroid/graphics/Color;Landroid/graphics/Color;Landroid/graphics/Color;I)V
+Landroid/companion/AssociationRequest;->getDeviceFilters()Ljava/util/List;
+Landroid/companion/AssociationRequest;->isSingleDevice()Z
+Landroid/companion/BluetoothDeviceFilter;->getAddress()Ljava/lang/String;
+Landroid/companion/BluetoothDeviceFilterUtils;->getDeviceDisplayNameInternal(Landroid/bluetooth/BluetoothDevice;)Ljava/lang/String;
+Landroid/companion/BluetoothDeviceFilterUtils;->getDeviceDisplayNameInternal(Landroid/net/wifi/ScanResult;)Ljava/lang/String;
+Landroid/companion/BluetoothDeviceFilterUtils;->getDeviceMacAddress(Landroid/os/Parcelable;)Ljava/lang/String;
+Landroid/companion/BluetoothLeDeviceFilter;->getScanFilter()Landroid/bluetooth/le/ScanFilter;
+Landroid/companion/DeviceFilter;->getDeviceDisplayName(Landroid/os/Parcelable;)Ljava/lang/String;
+Landroid/companion/DeviceFilter;->matches(Landroid/os/Parcelable;)Z
+Landroid/companion/ICompanionDeviceDiscoveryServiceCallback;->onDeviceSelected(Ljava/lang/String;ILjava/lang/String;)V
+Landroid/companion/ICompanionDeviceDiscoveryServiceCallback;->onDeviceSelectionCancel()V
+Landroid/companion/ICompanionDeviceDiscoveryService$Stub;-><init>()V
+Landroid/companion/IFindDeviceCallback;->onSuccess(Landroid/app/PendingIntent;)V
+Landroid/content/Context;->getOpPackageName()Ljava/lang/String;
+Landroid/content/Context;->registerReceiverAsUser(Landroid/content/BroadcastReceiver;Landroid/os/UserHandle;Landroid/content/IntentFilter;Ljava/lang/String;Landroid/os/Handler;)Landroid/content/Intent;
+Landroid/content/Context;->startActivityAsUser(Landroid/content/Intent;Landroid/os/UserHandle;)V
+Landroid/content/Context;->startServiceAsUser(Landroid/content/Intent;Landroid/os/UserHandle;)Landroid/content/ComponentName;
+Landroid/content/ContextWrapper;->getThemeResId()I
+Landroid/content/pm/IPackageDataObserver;->onRemoveCompleted(Ljava/lang/String;Z)V
+Landroid/content/pm/IPackageDataObserver$Stub;-><init>()V
+Landroid/content/pm/IPackageDeleteObserver;->packageDeleted(Ljava/lang/String;I)V
+Landroid/content/pm/IPackageDeleteObserver$Stub;-><init>()V
+Landroid/content/pm/IPackageManager;->getActivityInfo(Landroid/content/ComponentName;II)Landroid/content/pm/ActivityInfo;
+Landroid/content/pm/IPackageManager;->getHomeActivities(Ljava/util/List;)Landroid/content/ComponentName;
+Landroid/content/pm/IPackageStatsObserver;->onGetStatsCompleted(Landroid/content/pm/PackageStats;Z)V
+Landroid/database/sqlite/SqliteWrapper;->insert(Landroid/content/Context;Landroid/content/ContentResolver;Landroid/net/Uri;Landroid/content/ContentValues;)Landroid/net/Uri;
+Landroid/graphics/AvoidXfermode;-><init>(IILandroid/graphics/AvoidXfermode$Mode;)V
+Landroid/graphics/Bitmap;->createGraphicBufferHandle()Landroid/graphics/GraphicBuffer;
+Landroid/graphics/Bitmap;->createHardwareBitmap(Landroid/graphics/GraphicBuffer;)Landroid/graphics/Bitmap;
+Landroid/graphics/Canvas;->clipRegion(Landroid/graphics/Region;Landroid/graphics/Region$Op;)Z
+Landroid/graphics/Canvas;->clipRegion(Landroid/graphics/Region;)Z
+Landroid/graphics/drawable/Drawable;->isProjected()Z
+Landroid/graphics/drawable/Drawable;->updateTintFilter(Landroid/graphics/PorterDuffColorFilter;Landroid/content/res/ColorStateList;Landroid/graphics/PorterDuff$Mode;)Landroid/graphics/PorterDuffColorFilter;
+Landroid/hardware/camera2/CaptureRequest$Key;-><init>(Ljava/lang/String;Ljava/lang/Class;)V
+Landroid/hardware/location/GeofenceHardware;-><init>(Landroid/hardware/location/IGeofenceHardware;)V
+Landroid/hardware/location/IActivityRecognitionHardwareClient;->onAvailabilityChanged(ZLandroid/hardware/location/IActivityRecognitionHardware;)V
+Landroid/location/IFusedProvider;->onFusedLocationHardwareChange(Landroid/hardware/location/IFusedLocationHardware;)V
+Landroid/location/IGeocodeProvider;->getFromLocation(DDILandroid/location/GeocoderParams;Ljava/util/List;)Ljava/lang/String;
+Landroid/location/IGeocodeProvider;->getFromLocationName(Ljava/lang/String;DDDDILandroid/location/GeocoderParams;Ljava/util/List;)Ljava/lang/String;
+Landroid/location/IGeofenceProvider;->setGeofenceHardware(Landroid/hardware/location/IGeofenceHardware;)V
+Landroid/location/ILocationManager;->reportLocation(Landroid/location/Location;Z)V
+Landroid/media/AudioManager;->registerAudioPortUpdateListener(Landroid/media/AudioManager$OnAudioPortUpdateListener;)V
+Landroid/media/AudioManager;->unregisterAudioPortUpdateListener(Landroid/media/AudioManager$OnAudioPortUpdateListener;)V
+Landroid/media/AudioSystem;->checkAudioFlinger()I
+Landroid/media/AudioSystem;->getParameters(Ljava/lang/String;)Ljava/lang/String;
+Landroid/media/AudioSystem;->setParameters(Ljava/lang/String;)I
+Landroid/media/MediaDrm$Certificate;->getContent()[B
+Landroid/media/MediaDrm$Certificate;->getWrappedPrivateKey()[B
+Landroid/media/MediaDrm$CertificateRequest;->getData()[B
+Landroid/media/MediaDrm$CertificateRequest;->getDefaultUrl()Ljava/lang/String;
+Landroid/media/MediaDrm;->getCertificateRequest(ILjava/lang/String;)Landroid/media/MediaDrm$CertificateRequest;
+Landroid/media/MediaDrm;->provideCertificateResponse([B)Landroid/media/MediaDrm$Certificate;
+Landroid/media/MediaDrm;->signRSA([BLjava/lang/String;[B[B)[B
+Landroid/media/tv/ITvRemoteProvider$Stub;-><init>()V
+Landroid/media/tv/ITvRemoteServiceInput;->clearInputBridge(Landroid/os/IBinder;)V
+Landroid/media/tv/ITvRemoteServiceInput;->closeInputBridge(Landroid/os/IBinder;)V
+Landroid/media/tv/ITvRemoteServiceInput;->openInputBridge(Landroid/os/IBinder;Ljava/lang/String;III)V
+Landroid/media/tv/ITvRemoteServiceInput;->sendKeyDown(Landroid/os/IBinder;I)V
+Landroid/media/tv/ITvRemoteServiceInput;->sendKeyUp(Landroid/os/IBinder;I)V
+Landroid/media/tv/ITvRemoteServiceInput;->sendPointerDown(Landroid/os/IBinder;III)V
+Landroid/media/tv/ITvRemoteServiceInput;->sendPointerSync(Landroid/os/IBinder;)V
+Landroid/media/tv/ITvRemoteServiceInput;->sendPointerUp(Landroid/os/IBinder;I)V
+Landroid/media/tv/ITvRemoteServiceInput;->sendTimestamp(Landroid/os/IBinder;J)V
+Landroid/net/ConnectivityManager$PacketKeepaliveCallback;-><init>()V
+Landroid/net/ConnectivityManager$PacketKeepaliveCallback;->onError(I)V
+Landroid/net/ConnectivityManager$PacketKeepaliveCallback;->onStarted()V
+Landroid/net/ConnectivityManager$PacketKeepaliveCallback;->onStopped()V
+Landroid/net/ConnectivityManager$PacketKeepalive;->stop()V
+Landroid/net/ConnectivityManager;->startNattKeepalive(Landroid/net/Network;ILandroid/net/ConnectivityManager$PacketKeepaliveCallback;Ljava/net/InetAddress;ILjava/net/InetAddress;)Landroid/net/ConnectivityManager$PacketKeepalive;
+Landroid/net/ConnectivityManager;->startUsingNetworkFeature(ILjava/lang/String;)I
+Landroid/net/ConnectivityManager;->stopUsingNetworkFeature(ILjava/lang/String;)I
+Landroid/net/DhcpResults;-><init>(Landroid/net/DhcpResults;)V
+Landroid/net/DhcpResults;-><init>(Landroid/net/StaticIpConfiguration;)V
+Landroid/net/DhcpResults;-><init>()V
+Landroid/net/DhcpResults;->leaseDuration:I
+Landroid/net/DhcpResults;->mtu:I
+Landroid/net/DhcpResults;->serverAddress:Ljava/net/Inet4Address;
+Landroid/net/DhcpResults;->vendorInfo:Ljava/lang/String;
+Landroid/net/IConnectivityManager;->getAllNetworkState()[Landroid/net/NetworkState;
+Landroid/net/INetd;->interfaceAddAddress(Ljava/lang/String;Ljava/lang/String;I)V
+Landroid/net/INetd$Stub;->asInterface(Landroid/os/IBinder;)Landroid/net/INetd;
+Landroid/net/INetworkPolicyManager;->getNetworkQuotaInfo(Landroid/net/NetworkState;)Landroid/net/NetworkQuotaInfo;
+Landroid/net/INetworkPolicyManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/net/INetworkPolicyManager;
+Landroid/net/INetworkStatsService;->openSession()Landroid/net/INetworkStatsSession;
+Landroid/net/INetworkStatsService$Stub;->asInterface(Landroid/os/IBinder;)Landroid/net/INetworkStatsService;
+Landroid/net/INetworkStatsSession;->getHistoryForNetwork(Landroid/net/NetworkTemplate;I)Landroid/net/NetworkStatsHistory;
+Landroid/net/INetworkStatsSession;->getHistoryForUid(Landroid/net/NetworkTemplate;IIII)Landroid/net/NetworkStatsHistory;
+Landroid/net/InterfaceConfiguration;-><init>()V
+Landroid/net/InterfaceConfiguration;->setLinkAddress(Landroid/net/LinkAddress;)V
+Landroid/net/LinkAddress;-><init>(Ljava/lang/String;)V
+Landroid/net/LinkAddress;-><init>(Ljava/net/InetAddress;I)V
+Landroid/net/LinkAddress;->isIPv6()Z
+Landroid/net/LinkAddress;->isSameAddressAs(Landroid/net/LinkAddress;)Z
+Landroid/net/LinkProperties;->addDnsServer(Ljava/net/InetAddress;)Z
+Landroid/net/LinkProperties;->addRoute(Landroid/net/RouteInfo;)Z
+Landroid/net/LinkProperties;->addStackedLink(Landroid/net/LinkProperties;)Z
+Landroid/net/LinkProperties;->clear()V
+Landroid/net/LinkProperties;->compareProvisioning(Landroid/net/LinkProperties;Landroid/net/LinkProperties;)Landroid/net/LinkProperties$ProvisioningChange;
+Landroid/net/LinkProperties;->getMtu()I
+Landroid/net/LinkProperties;->getStackedLinks()Ljava/util/List;
+Landroid/net/LinkProperties;->hasGlobalIPv6Address()Z
+Landroid/net/LinkProperties;->hasIPv4Address()Z
+Landroid/net/LinkProperties;->hasIPv4DefaultRoute()Z
+Landroid/net/LinkProperties;->hasIPv4DnsServer()Z
+Landroid/net/LinkProperties;->hasIPv6DefaultRoute()Z
+Landroid/net/LinkProperties;->hasIPv6DnsServer()Z
+Landroid/net/LinkProperties;-><init>(Landroid/net/LinkProperties;)V
+Landroid/net/LinkProperties;-><init>()V
+Landroid/net/LinkProperties;->isIdenticalAddresses(Landroid/net/LinkProperties;)Z
+Landroid/net/LinkProperties;->isIdenticalDnses(Landroid/net/LinkProperties;)Z
+Landroid/net/LinkProperties;->isIdenticalRoutes(Landroid/net/LinkProperties;)Z
+Landroid/net/LinkProperties;->isIdenticalStackedLinks(Landroid/net/LinkProperties;)Z
+Landroid/net/LinkProperties;->isIPv6Provisioned()Z
+Landroid/net/LinkProperties;->isProvisioned()Z
+Landroid/net/LinkProperties;->isReachable(Ljava/net/InetAddress;)Z
+Landroid/net/LinkProperties$ProvisioningChange;->GAINED_PROVISIONING:Landroid/net/LinkProperties$ProvisioningChange;
+Landroid/net/LinkProperties$ProvisioningChange;->LOST_PROVISIONING:Landroid/net/LinkProperties$ProvisioningChange;
+Landroid/net/LinkProperties$ProvisioningChange;->STILL_NOT_PROVISIONED:Landroid/net/LinkProperties$ProvisioningChange;
+Landroid/net/LinkProperties$ProvisioningChange;->STILL_PROVISIONED:Landroid/net/LinkProperties$ProvisioningChange;
+Landroid/net/LinkProperties$ProvisioningChange;->values()[Landroid/net/LinkProperties$ProvisioningChange;
+Landroid/net/LinkProperties;->removeDnsServer(Ljava/net/InetAddress;)Z
+Landroid/net/LinkProperties;->removeRoute(Landroid/net/RouteInfo;)Z
+Landroid/net/LinkProperties;->setDnsServers(Ljava/util/Collection;)V
+Landroid/net/LinkProperties;->setDomains(Ljava/lang/String;)V
+Landroid/net/LinkProperties;->setInterfaceName(Ljava/lang/String;)V
+Landroid/net/LinkProperties;->setLinkAddresses(Ljava/util/Collection;)V
+Landroid/net/LinkProperties;->setMtu(I)V
+Landroid/net/LinkProperties;->setTcpBufferSizes(Ljava/lang/String;)V
+Landroid/net/MacAddress;->ALL_ZEROS_ADDRESS:Landroid/net/MacAddress;
+Landroid/net/metrics/ApfProgramEvent;->actualLifetime:J
+Landroid/net/metrics/ApfProgramEvent;->currentRas:I
+Landroid/net/metrics/ApfProgramEvent;->filteredRas:I
+Landroid/net/metrics/ApfProgramEvent;->flagsFor(ZZ)I
+Landroid/net/metrics/ApfProgramEvent;->flags:I
+Landroid/net/metrics/ApfProgramEvent;-><init>()V
+Landroid/net/metrics/ApfProgramEvent;->lifetime:J
+Landroid/net/metrics/ApfProgramEvent;->programLength:I
+Landroid/net/metrics/ApfStats;->droppedRas:I
+Landroid/net/metrics/ApfStats;->durationMs:J
+Landroid/net/metrics/ApfStats;-><init>()V
+Landroid/net/metrics/ApfStats;->matchingRas:I
+Landroid/net/metrics/ApfStats;->maxProgramSize:I
+Landroid/net/metrics/ApfStats;->parseErrors:I
+Landroid/net/metrics/ApfStats;->programUpdatesAll:I
+Landroid/net/metrics/ApfStats;->programUpdatesAllowingMulticast:I
+Landroid/net/metrics/ApfStats;->programUpdates:I
+Landroid/net/metrics/ApfStats;->receivedRas:I
+Landroid/net/metrics/ApfStats;->zeroLifetimeRas:I
+Landroid/net/metrics/DhcpClientEvent;-><init>(Ljava/lang/String;I)V
+Landroid/net/metrics/DhcpErrorEvent;->BOOTP_TOO_SHORT:I
+Landroid/net/metrics/DhcpErrorEvent;->BUFFER_UNDERFLOW:I
+Landroid/net/metrics/DhcpErrorEvent;->DHCP_BAD_MAGIC_COOKIE:I
+Landroid/net/metrics/DhcpErrorEvent;->DHCP_INVALID_OPTION_LENGTH:I
+Landroid/net/metrics/DhcpErrorEvent;->DHCP_NO_COOKIE:I
+Landroid/net/metrics/DhcpErrorEvent;->DHCP_NO_MSG_TYPE:I
+Landroid/net/metrics/DhcpErrorEvent;->DHCP_UNKNOWN_MSG_TYPE:I
+Landroid/net/metrics/DhcpErrorEvent;->errorCodeWithOption(II)I
+Landroid/net/metrics/DhcpErrorEvent;-><init>(I)V
+Landroid/net/metrics/DhcpErrorEvent;->L2_TOO_SHORT:I
+Landroid/net/metrics/DhcpErrorEvent;->L2_WRONG_ETH_TYPE:I
+Landroid/net/metrics/DhcpErrorEvent;->L3_INVALID_IP:I
+Landroid/net/metrics/DhcpErrorEvent;->L3_NOT_IPV4:I
+Landroid/net/metrics/DhcpErrorEvent;->L3_TOO_SHORT:I
+Landroid/net/metrics/DhcpErrorEvent;->L4_NOT_UDP:I
+Landroid/net/metrics/DhcpErrorEvent;->L4_WRONG_PORT:I
+Landroid/net/metrics/DhcpErrorEvent;->PARSING_ERROR:I
+Landroid/net/metrics/DhcpErrorEvent;->RECEIVE_ERROR:I
+Landroid/net/metrics/IpConnectivityLog;-><init>()V
+Landroid/net/metrics/IpConnectivityLog;->log(Landroid/os/Parcelable;)Z
+Landroid/net/metrics/IpConnectivityLog;->log(Ljava/lang/String;Landroid/os/Parcelable;)Z
+Landroid/net/metrics/IpManagerEvent;-><init>(IJ)V
+Landroid/net/metrics/IpReachabilityEvent;-><init>(I)V
+Landroid/net/metrics/IpReachabilityEvent;->nudFailureEventType(ZZ)I
+Landroid/net/metrics/RaEvent$Builder;->build()Landroid/net/metrics/RaEvent;
+Landroid/net/metrics/RaEvent$Builder;-><init>()V
+Landroid/net/metrics/RaEvent$Builder;->updateDnsslLifetime(J)Landroid/net/metrics/RaEvent$Builder;
+Landroid/net/metrics/RaEvent$Builder;->updatePrefixPreferredLifetime(J)Landroid/net/metrics/RaEvent$Builder;
+Landroid/net/metrics/RaEvent$Builder;->updatePrefixValidLifetime(J)Landroid/net/metrics/RaEvent$Builder;
+Landroid/net/metrics/RaEvent$Builder;->updateRdnssLifetime(J)Landroid/net/metrics/RaEvent$Builder;
+Landroid/net/metrics/RaEvent$Builder;->updateRouteInfoLifetime(J)Landroid/net/metrics/RaEvent$Builder;
+Landroid/net/metrics/RaEvent$Builder;->updateRouterLifetime(J)Landroid/net/metrics/RaEvent$Builder;
+Landroid/net/NetworkCapabilities;->getNetworkSpecifier()Landroid/net/NetworkSpecifier;
+Landroid/net/NetworkCapabilities;->getSignalStrength()I
+Landroid/net/NetworkCapabilities;->hasSignalStrength()Z
+Landroid/net/NetworkCapabilities;->transportNamesOf([I)Ljava/lang/String;
+Landroid/net/Network;-><init>(I)V
+Landroid/net/NetworkQuotaInfo;->getEstimatedBytes()J
+Landroid/net/NetworkQuotaInfo;->getHardLimitBytes()J
+Landroid/net/NetworkQuotaInfo;->getSoftLimitBytes()J
+Landroid/net/NetworkRequest$Builder;->setSignalStrength(I)Landroid/net/NetworkRequest$Builder;
+Landroid/net/NetworkStats;->combineValues(Landroid/net/NetworkStats$Entry;)Landroid/net/NetworkStats;
+Landroid/net/NetworkStats$Entry;-><init>()V
+Landroid/net/NetworkStatsHistory$Entry;->txBytes:J
+Landroid/net/NetworkStatsHistory;->getStart()J
+Landroid/net/NetworkStatsHistory;->getValues(JJLandroid/net/NetworkStatsHistory$Entry;)Landroid/net/NetworkStatsHistory$Entry;
+Landroid/net/NetworkStats;-><init>(JI)V
+Landroid/net/NetworkTemplate;->buildTemplateMobileAll(Ljava/lang/String;)Landroid/net/NetworkTemplate;
+Landroid/net/NetworkUtils;->attachControlPacketFilter(Ljava/io/FileDescriptor;I)V
+Landroid/net/NetworkUtils;->attachDhcpFilter(Ljava/io/FileDescriptor;)V
+Landroid/net/NetworkUtils;->attachRaFilter(Ljava/io/FileDescriptor;I)V
+Landroid/net/NetworkUtils;->getImplicitNetmask(Ljava/net/Inet4Address;)I
+Landroid/net/NetworkUtils;->netmaskToPrefixLength(Ljava/net/Inet4Address;)I
+Landroid/net/NetworkUtils;->protectFromVpn(Ljava/io/FileDescriptor;)Z
+Landroid/net/RouteInfo;->hasGateway()Z
+Landroid/net/RouteInfo;-><init>(Landroid/net/IpPrefix;Ljava/net/InetAddress;Ljava/lang/String;)V
+Landroid/net/SntpClient;->getNtpTime()J
+Landroid/net/SntpClient;->requestTime(Ljava/lang/String;I)Z
+Landroid/net/StaticIpConfiguration;->dnsServers:Ljava/util/ArrayList;
+Landroid/net/StaticIpConfiguration;->domains:Ljava/lang/String;
+Landroid/net/StaticIpConfiguration;->gateway:Ljava/net/InetAddress;
+Landroid/net/StaticIpConfiguration;->getRoutes(Ljava/lang/String;)Ljava/util/List;
+Landroid/net/StaticIpConfiguration;->ipAddress:Landroid/net/LinkAddress;
+Landroid/net/StringNetworkSpecifier;->specifier:Ljava/lang/String;
+Landroid/net/TrafficStats;->getMobileTcpRxPackets()J
+Landroid/net/TrafficStats;->getMobileTcpTxPackets()J
+Landroid/net/wifi/WifiInfo;->is5GHz()Z
+Landroid/net/wifi/WifiInfo;->score:I
+Landroid/os/AsyncResult;->exception:Ljava/lang/Throwable;
+Landroid/os/AsyncResult;->forMessage(Landroid/os/Message;Ljava/lang/Object;Ljava/lang/Throwable;)Landroid/os/AsyncResult;
+Landroid/os/AsyncResult;-><init>(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Throwable;)V
+Landroid/os/AsyncResult;->result:Ljava/lang/Object;
+Landroid/os/AsyncResult;->userObj:Ljava/lang/Object;
+Landroid/os/BatteryStats;->getNextHistoryLocked(Landroid/os/BatteryStats$HistoryItem;)Z
+Landroid/os/BatteryStats$HistoryItem;->batteryLevel:B
+Landroid/os/BatteryStats$HistoryItem;->cmd:B
+Landroid/os/BatteryStats$HistoryItem;-><init>()V
+Landroid/os/BatteryStats$HistoryItem;->states:I
+Landroid/os/BatteryStats$HistoryItem;->time:J
+Landroid/os/BatteryStats$Uid;->getWifiRunningTime(JI)J
+Landroid/os/BatteryStats$Uid;-><init>()V
+Landroid/os/BatteryStats$Uid$Wakelock;->getWakeTime(I)Landroid/os/BatteryStats$Timer;
+Landroid/os/Handler;->getMain()Landroid/os/Handler;
+Landroid/os/Handler;-><init>(Landroid/os/Looper;Landroid/os/Handler$Callback;Z)V
+Landroid/os/HwBinder;->reportSyspropChanged()V
+Landroid/os/INetworkManagementService;->clearInterfaceAddresses(Ljava/lang/String;)V
+Landroid/os/INetworkManagementService;->disableIpv6(Ljava/lang/String;)V
+Landroid/os/INetworkManagementService;->enableIpv6(Ljava/lang/String;)V
+Landroid/os/INetworkManagementService;->registerObserver(Landroid/net/INetworkManagementEventObserver;)V
+Landroid/os/INetworkManagementService;->setInterfaceConfig(Ljava/lang/String;Landroid/net/InterfaceConfiguration;)V
+Landroid/os/INetworkManagementService;->setInterfaceIpv6PrivacyExtensions(Ljava/lang/String;Z)V
+Landroid/os/INetworkManagementService;->setIPv6AddrGenMode(Ljava/lang/String;I)V
+Landroid/os/INetworkManagementService$Stub;->asInterface(Landroid/os/IBinder;)Landroid/os/INetworkManagementService;
+Landroid/os/INetworkManagementService;->unregisterObserver(Landroid/net/INetworkManagementEventObserver;)V
+Landroid/os/IPowerManager;->reboot(ZLjava/lang/String;Z)V
+Landroid/os/IRemoteCallback$Stub;-><init>()V
+Landroid/os/Message;->setCallback(Ljava/lang/Runnable;)Landroid/os/Message;
+Landroid/os/Parcel;->readBlob()[B
+Landroid/os/Parcel;->readStringArray()[Ljava/lang/String;
+Landroid/os/Parcel;->writeBlob([B)V
+Landroid/os/PowerManager;->isScreenBrightnessBoosted()Z
+Landroid/os/Registrant;->clear()V
+Landroid/os/Registrant;-><init>(Landroid/os/Handler;ILjava/lang/Object;)V
+Landroid/os/RegistrantList;->add(Landroid/os/Registrant;)V
+Landroid/os/RegistrantList;->addUnique(Landroid/os/Handler;ILjava/lang/Object;)V
+Landroid/os/RegistrantList;-><init>()V
+Landroid/os/RegistrantList;->notifyRegistrants(Landroid/os/AsyncResult;)V
+Landroid/os/RegistrantList;->notifyRegistrants()V
+Landroid/os/RegistrantList;->removeCleared()V
+Landroid/os/RegistrantList;->remove(Landroid/os/Handler;)V
+Landroid/os/Registrant;->notifyRegistrant(Landroid/os/AsyncResult;)V
+Landroid/os/Registrant;->notifyRegistrant()V
+Landroid/os/RemoteException;->rethrowFromSystemServer()Ljava/lang/RuntimeException;
+Landroid/os/ServiceSpecificException;->errorCode:I
+Landroid/os/SystemProperties;->reportSyspropChanged()V
+Landroid/print/PrintDocumentAdapter$LayoutResultCallback;-><init>()V
+Landroid/print/PrintDocumentAdapter$WriteResultCallback;-><init>()V
+Landroid/provider/CalendarContract$Events;->PROVIDER_WRITABLE_COLUMNS:[Ljava/lang/String;
+Landroid/service/vr/VrListenerService;->onCurrentVrActivityChanged(Landroid/content/ComponentName;ZI)V
+Landroid/system/NetlinkSocketAddress;-><init>(II)V
+Landroid/system/Os;->bind(Ljava/io/FileDescriptor;Ljava/net/SocketAddress;)V
+Landroid/system/Os;->connect(Ljava/io/FileDescriptor;Ljava/net/SocketAddress;)V
+Landroid/system/Os;->sendto(Ljava/io/FileDescriptor;[BIIILjava/net/SocketAddress;)I
+Landroid/system/Os;->setsockoptIfreq(Ljava/io/FileDescriptor;IILjava/lang/String;)V
+Landroid/system/Os;->setsockoptTimeval(Ljava/io/FileDescriptor;IILandroid/system/StructTimeval;)V
+Landroid/system/PacketSocketAddress;-><init>(I[B)V
+Landroid/system/PacketSocketAddress;-><init>(SI)V
+Landroid/telecom/TelecomManager;->from(Landroid/content/Context;)Landroid/telecom/TelecomManager;
+Landroid/telecom/VideoProfile$CameraCapabilities;-><init>(IIZF)V
+Landroid/telephony/ims/compat/feature/MMTelFeature;-><init>()V
+Landroid/telephony/ims/compat/ImsService;-><init>()V
+Landroid/telephony/ims/compat/stub/ImsCallSessionImplBase;-><init>()V
+Landroid/telephony/ims/compat/stub/ImsConfigImplBase;-><init>(Landroid/content/Context;)V
+Landroid/telephony/ims/compat/stub/ImsUtListenerImplBase;-><init>()V
+Landroid/telephony/ims/ImsCallForwardInfo;-><init>()V
+Landroid/telephony/ims/ImsCallProfile;->presentationToOIR(I)I
+Landroid/telephony/ims/ImsExternalCallState;-><init>(ILandroid/net/Uri;ZIIZ)V
+Landroid/telephony/ims/ImsReasonInfo;-><init>(IILjava/lang/String;)V
+Landroid/telephony/ims/ImsReasonInfo;-><init>(II)V
+Landroid/telephony/ims/ImsStreamMediaProfile;-><init>()V
+Landroid/telephony/PhoneNumberUtils;->isEmergencyNumber(ILjava/lang/String;)Z
+Landroid/telephony/PhoneNumberUtils;->isPotentialEmergencyNumber(ILjava/lang/String;)Z
+Landroid/telephony/PhoneNumberUtils;->isPotentialLocalEmergencyNumber(Landroid/content/Context;ILjava/lang/String;)Z
+Landroid/telephony/PhoneStateListener;-><init>(Ljava/lang/Integer;Landroid/os/Looper;)V
+Landroid/telephony/PhoneStateListener;-><init>(Ljava/lang/Integer;)V
+Landroid/telephony/PreciseCallState;->getBackgroundCallState()I
+Landroid/telephony/PreciseCallState;->getForegroundCallState()I
+Landroid/telephony/RadioAccessFamily;->getRafFromNetworkType(I)I
+Landroid/telephony/RadioAccessFamily;-><init>(II)V
+Landroid/telephony/Rlog;->d(Ljava/lang/String;Ljava/lang/String;)I
+Landroid/telephony/Rlog;->e(Ljava/lang/String;Ljava/lang/String;)I
+Landroid/telephony/Rlog;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
+Landroid/telephony/Rlog;->i(Ljava/lang/String;Ljava/lang/String;)I
+Landroid/telephony/ServiceState;->getDataRoaming()Z
+Landroid/telephony/ServiceState;->getRilDataRadioTechnology()I
+Landroid/telephony/ServiceState;->getVoiceRegState()I
+Landroid/telephony/ServiceState;->isCdma(I)Z
+Landroid/telephony/ServiceState;->isEmergencyOnly()Z
+Landroid/telephony/ServiceState;->mergeServiceStates(Landroid/telephony/ServiceState;Landroid/telephony/ServiceState;)Landroid/telephony/ServiceState;
+Landroid/telephony/SubscriptionManager;->getResourcesForSubId(Landroid/content/Context;I)Landroid/content/res/Resources;
+Landroid/telephony/SubscriptionManager;->isActiveSubId(I)Z
+Landroid/telephony/SubscriptionManager;->isUsableSubIdValue(I)Z
+Landroid/telephony/SubscriptionManager;->isValidPhoneId(I)Z
+Landroid/telephony/SubscriptionManager;->isValidSlotIndex(I)Z
+Landroid/telephony/SubscriptionManager;->isValidSubscriptionId(I)Z
+Landroid/telephony/SubscriptionManager;->putPhoneIdAndSubIdExtra(Landroid/content/Intent;II)V
+Landroid/telephony/TelephonyManager;->getIntAtIndex(Landroid/content/ContentResolver;Ljava/lang/String;I)I
+Landroid/telephony/TelephonyManager;->getVoiceNetworkType(I)I
+Landroid/telephony/TelephonyManager;->putIntAtIndex(Landroid/content/ContentResolver;Ljava/lang/String;II)Z
+Landroid/util/FloatMath;->ceil(F)F
+Landroid/util/FloatMath;->cos(F)F
+Landroid/util/FloatMath;->exp(F)F
+Landroid/util/FloatMath;->floor(F)F
+Landroid/util/FloatMath;->sin(F)F
+Landroid/util/FloatMath;->sqrt(F)F
+Landroid/util/IconDrawableFactory;->getBadgedIcon(Landroid/content/pm/PackageItemInfo;Landroid/content/pm/ApplicationInfo;I)Landroid/graphics/drawable/Drawable;
+Landroid/util/IconDrawableFactory;->newInstance(Landroid/content/Context;)Landroid/util/IconDrawableFactory;
+Landroid/util/LocalLog;-><init>(I)V
+Landroid/util/LocalLog;->log(Ljava/lang/String;)V
+Landroid/util/LocalLog$ReadOnlyLocalLog;->dump(Ljava/io/FileDescriptor;Ljava/io/PrintWriter;[Ljava/lang/String;)V
+Landroid/util/LocalLog;->readOnlyLocalLog()Landroid/util/LocalLog$ReadOnlyLocalLog;
+Landroid/util/LongArray;->add(IJ)V
+Landroid/util/LongArray;->get(I)J
+Landroid/util/LongArray;-><init>()V
+Landroid/util/LongArray;->size()I
+Landroid/util/Slog;->wtf(Ljava/lang/String;Ljava/lang/String;)I
+Landroid/view/AppTransitionAnimationSpec;-><init>(ILandroid/graphics/GraphicBuffer;Landroid/graphics/Rect;)V
+Landroid/view/BatchedInputEventReceiver;-><init>(Landroid/view/InputChannel;Landroid/os/Looper;Landroid/view/Choreographer;)V
+Landroid/view/Choreographer;->getSfInstance()Landroid/view/Choreographer;
+Landroid/view/DisplayListCanvas;->drawRenderNode(Landroid/view/RenderNode;)V
+Landroid/view/IAppTransitionAnimationSpecsFuture$Stub;-><init>()V
+Landroid/view/InputEventReceiver;->onInputEvent(Landroid/view/InputEvent;)V
+Landroid/view/IRecentsAnimationController;->finish(Z)V
+Landroid/view/IRecentsAnimationController;->screenshotTask(I)Landroid/app/ActivityManager$TaskSnapshot;
+Landroid/view/IRecentsAnimationController;->setInputConsumerEnabled(Z)V
+Landroid/view/IRecentsAnimationRunner;->onAnimationCanceled()V
+Landroid/view/IRecentsAnimationRunner;->onAnimationStart(Landroid/view/IRecentsAnimationController;[Landroid/view/RemoteAnimationTarget;)V
+Landroid/view/IRecentsAnimationRunner;->onAnimationStart_New(Landroid/view/IRecentsAnimationController;[Landroid/view/RemoteAnimationTarget;Landroid/graphics/Rect;Landroid/graphics/Rect;)V
+Landroid/view/IRecentsAnimationRunner$Stub;-><init>()V
+Landroid/view/IRemoteAnimationFinishedCallback;->onAnimationFinished()V
+Landroid/view/IRemoteAnimationRunner;->onAnimationCancelled()V
+Landroid/view/IRemoteAnimationRunner;->onAnimationStart([Landroid/view/RemoteAnimationTarget;Landroid/view/IRemoteAnimationFinishedCallback;)V
+Landroid/view/IRemoteAnimationRunner$Stub;-><init>()V
+Landroid/view/IWindowManager;->createInputConsumer(Landroid/os/IBinder;Ljava/lang/String;Landroid/view/InputChannel;)V
+Landroid/view/IWindowManager;->destroyInputConsumer(Ljava/lang/String;)Z
+Landroid/view/IWindowManager;->endProlongedAnimations()V
+Landroid/view/IWindowManager;->getStableInsets(ILandroid/graphics/Rect;)V
+Landroid/view/IWindowManager;->overridePendingAppTransitionMultiThumbFuture(Landroid/view/IAppTransitionAnimationSpecsFuture;Landroid/os/IRemoteCallback;Z)V
+Landroid/view/IWindowManager;->overridePendingAppTransitionRemote(Landroid/view/RemoteAnimationAdapter;)V
+Landroid/view/IWindowManager;->setNavBarVirtualKeyHapticFeedbackEnabled(Z)V
+Landroid/view/RemoteAnimationAdapter;-><init>(Landroid/view/IRemoteAnimationRunner;JJ)V
+Landroid/view/RemoteAnimationDefinition;->addRemoteAnimation(ILandroid/view/RemoteAnimationAdapter;)V
+Landroid/view/RemoteAnimationDefinition;-><init>()V
+Landroid/view/RenderNode;->create(Ljava/lang/String;Landroid/view/View;)Landroid/view/RenderNode;
+Landroid/view/RenderNode;->end(Landroid/view/DisplayListCanvas;)V
+Landroid/view/RenderNode;->isValid()Z
+Landroid/view/RenderNode;->setClipToBounds(Z)Z
+Landroid/view/RenderNode;->setLeftTopRightBottom(IIII)Z
+Landroid/view/RenderNode;->start(II)Landroid/view/DisplayListCanvas;
+Landroid/view/SurfaceControl$Transaction;->apply()V
+Landroid/view/SurfaceControl$Transaction;->deferTransactionUntil(Landroid/view/SurfaceControl;Landroid/os/IBinder;J)Landroid/view/SurfaceControl$Transaction;
+Landroid/view/SurfaceControl$Transaction;->deferTransactionUntilSurface(Landroid/view/SurfaceControl;Landroid/view/Surface;J)Landroid/view/SurfaceControl$Transaction;
+Landroid/view/SurfaceControl$Transaction;->hide(Landroid/view/SurfaceControl;)Landroid/view/SurfaceControl$Transaction;
+Landroid/view/SurfaceControl$Transaction;-><init>()V
+Landroid/view/SurfaceControl$Transaction;->setAlpha(Landroid/view/SurfaceControl;F)Landroid/view/SurfaceControl$Transaction;
+Landroid/view/SurfaceControl$Transaction;->setColor(Landroid/view/SurfaceControl;[F)Landroid/view/SurfaceControl$Transaction;
+Landroid/view/SurfaceControl$Transaction;->setFinalCrop(Landroid/view/SurfaceControl;Landroid/graphics/Rect;)Landroid/view/SurfaceControl$Transaction;
+Landroid/view/SurfaceControl$Transaction;->setLayer(Landroid/view/SurfaceControl;I)Landroid/view/SurfaceControl$Transaction;
+Landroid/view/SurfaceControl$Transaction;->setMatrix(Landroid/view/SurfaceControl;FFFF)Landroid/view/SurfaceControl$Transaction;
+Landroid/view/SurfaceControl$Transaction;->setMatrix(Landroid/view/SurfaceControl;Landroid/graphics/Matrix;[F)Landroid/view/SurfaceControl$Transaction;
+Landroid/view/SurfaceControl$Transaction;->setPosition(Landroid/view/SurfaceControl;FF)Landroid/view/SurfaceControl$Transaction;
+Landroid/view/SurfaceControl$Transaction;->setSize(Landroid/view/SurfaceControl;II)Landroid/view/SurfaceControl$Transaction;
+Landroid/view/SurfaceControl$Transaction;->setWindowCrop(Landroid/view/SurfaceControl;Landroid/graphics/Rect;)Landroid/view/SurfaceControl$Transaction;
+Landroid/view/SurfaceControl$Transaction;->show(Landroid/view/SurfaceControl;)Landroid/view/SurfaceControl$Transaction;
+Landroid/view/Surface;->getNextFrameNumber()J
+Landroid/view/ThreadedRenderer;->createHardwareBitmap(Landroid/view/RenderNode;II)Landroid/graphics/Bitmap;
+Landroid/view/View;->hideTooltip()V
+Landroid/view/View;->setTooltip(Ljava/lang/CharSequence;)V
+Landroid/webkit/WebSettings;->getPluginsPath()Ljava/lang/String;
+Landroid/webkit/WebSettings;->getUseDoubleTree()Z
+Landroid/webkit/WebSettings;->setPluginsPath(Ljava/lang/String;)V
+Landroid/webkit/WebSettings;->setUseDoubleTree(Z)V
+Landroid/webkit/WebView;->getPluginList()Landroid/webkit/PluginList;
+Landroid/webkit/WebView;->getZoomControls()Landroid/view/View;
+Landroid/webkit/WebView;->refreshPlugins(Z)V
+Landroid/widget/ListView;->lookForSelectablePosition(IZ)I
+Lcom/android/ims/ImsConfigListener;->onSetFeatureResponse(IIII)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionConferenceStateUpdated(Lcom/android/ims/internal/IImsCallSession;Landroid/telephony/ims/ImsConferenceState;)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionHandoverFailed(Lcom/android/ims/internal/IImsCallSession;IILandroid/telephony/ims/ImsReasonInfo;)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionHandover(Lcom/android/ims/internal/IImsCallSession;IILandroid/telephony/ims/ImsReasonInfo;)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionHeld(Lcom/android/ims/internal/IImsCallSession;Landroid/telephony/ims/ImsCallProfile;)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionHoldFailed(Lcom/android/ims/internal/IImsCallSession;Landroid/telephony/ims/ImsReasonInfo;)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionHoldReceived(Lcom/android/ims/internal/IImsCallSession;Landroid/telephony/ims/ImsCallProfile;)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionInviteParticipantsRequestDelivered(Lcom/android/ims/internal/IImsCallSession;)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionInviteParticipantsRequestFailed(Lcom/android/ims/internal/IImsCallSession;Landroid/telephony/ims/ImsReasonInfo;)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionMergeComplete(Lcom/android/ims/internal/IImsCallSession;)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionMergeFailed(Lcom/android/ims/internal/IImsCallSession;Landroid/telephony/ims/ImsReasonInfo;)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionMergeStarted(Lcom/android/ims/internal/IImsCallSession;Lcom/android/ims/internal/IImsCallSession;Landroid/telephony/ims/ImsCallProfile;)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionMultipartyStateChanged(Lcom/android/ims/internal/IImsCallSession;Z)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionProgressing(Lcom/android/ims/internal/IImsCallSession;Landroid/telephony/ims/ImsStreamMediaProfile;)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionResumed(Lcom/android/ims/internal/IImsCallSession;Landroid/telephony/ims/ImsCallProfile;)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionResumeFailed(Lcom/android/ims/internal/IImsCallSession;Landroid/telephony/ims/ImsReasonInfo;)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionResumeReceived(Lcom/android/ims/internal/IImsCallSession;Landroid/telephony/ims/ImsCallProfile;)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionStarted(Lcom/android/ims/internal/IImsCallSession;Landroid/telephony/ims/ImsCallProfile;)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionStartFailed(Lcom/android/ims/internal/IImsCallSession;Landroid/telephony/ims/ImsReasonInfo;)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionSuppServiceReceived(Lcom/android/ims/internal/IImsCallSession;Landroid/telephony/ims/ImsSuppServiceNotification;)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionTerminated(Lcom/android/ims/internal/IImsCallSession;Landroid/telephony/ims/ImsReasonInfo;)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionTtyModeReceived(Lcom/android/ims/internal/IImsCallSession;I)V
+Lcom/android/ims/internal/IImsCallSessionListener;->callSessionUpdated(Lcom/android/ims/internal/IImsCallSession;Landroid/telephony/ims/ImsCallProfile;)V
+Lcom/android/ims/internal/IImsRegistrationListener;->registrationAssociatedUriChanged([Landroid/net/Uri;)V
+Lcom/android/ims/internal/IImsRegistrationListener;->registrationConnectedWithRadioTech(I)V
+Lcom/android/ims/internal/IImsRegistrationListener;->registrationDisconnected(Landroid/telephony/ims/ImsReasonInfo;)V
+Lcom/android/ims/internal/IImsRegistrationListener;->registrationFeatureCapabilityChanged(I[I[I)V
+Lcom/android/ims/internal/IImsRegistrationListener;->registrationProgressingWithRadioTech(I)V
+Lcom/android/ims/internal/IImsRegistrationListener;->voiceMessageCountUpdate(I)V
+Lcom/android/ims/internal/IImsUtListener;->utConfigurationCallBarringQueried(Lcom/android/ims/internal/IImsUt;I[Landroid/telephony/ims/ImsSsInfo;)V
+Lcom/android/ims/internal/IImsUtListener;->utConfigurationCallForwardQueried(Lcom/android/ims/internal/IImsUt;I[Landroid/telephony/ims/ImsCallForwardInfo;)V
+Lcom/android/ims/internal/IImsUtListener;->utConfigurationCallWaitingQueried(Lcom/android/ims/internal/IImsUt;I[Landroid/telephony/ims/ImsSsInfo;)V
+Lcom/android/ims/internal/IImsUtListener;->utConfigurationQueried(Lcom/android/ims/internal/IImsUt;ILandroid/os/Bundle;)V
+Lcom/android/ims/internal/IImsUtListener;->utConfigurationQueryFailed(Lcom/android/ims/internal/IImsUt;ILandroid/telephony/ims/ImsReasonInfo;)V
+Lcom/android/ims/internal/IImsUtListener;->utConfigurationUpdated(Lcom/android/ims/internal/IImsUt;I)V
+Lcom/android/ims/internal/IImsUtListener;->utConfigurationUpdateFailed(Lcom/android/ims/internal/IImsUt;ILandroid/telephony/ims/ImsReasonInfo;)V
+Lcom/android/ims/internal/uce/common/StatusCode;->getStatusCode()I
+Lcom/android/ims/internal/uce/common/UceLong;->getClientId()I
+Lcom/android/ims/internal/uce/common/UceLong;-><init>()V
+Lcom/android/ims/internal/uce/common/UceLong;->setClientId(I)V
+Lcom/android/ims/internal/uce/options/IOptionsListener;->cmdStatus(Lcom/android/ims/internal/uce/options/OptionsCmdStatus;)V
+Lcom/android/ims/internal/uce/options/IOptionsListener;->getVersionCb(Ljava/lang/String;)V
+Lcom/android/ims/internal/uce/options/IOptionsListener;->incomingOptions(Ljava/lang/String;Lcom/android/ims/internal/uce/options/OptionsCapInfo;I)V
+Lcom/android/ims/internal/uce/options/IOptionsListener;->serviceAvailable(Lcom/android/ims/internal/uce/common/StatusCode;)V
+Lcom/android/ims/internal/uce/options/IOptionsListener;->serviceUnavailable(Lcom/android/ims/internal/uce/common/StatusCode;)V
+Lcom/android/ims/internal/uce/options/IOptionsListener;->sipResponseReceived(Ljava/lang/String;Lcom/android/ims/internal/uce/options/OptionsSipResponse;Lcom/android/ims/internal/uce/options/OptionsCapInfo;)V
+Lcom/android/ims/internal/uce/options/IOptionsService;->addListener(ILcom/android/ims/internal/uce/options/IOptionsListener;Lcom/android/ims/internal/uce/common/UceLong;)Lcom/android/ims/internal/uce/common/StatusCode;
+Lcom/android/ims/internal/uce/options/IOptionsService;->getContactCap(ILjava/lang/String;I)Lcom/android/ims/internal/uce/common/StatusCode;
+Lcom/android/ims/internal/uce/options/IOptionsService;->getContactListCap(I[Ljava/lang/String;I)Lcom/android/ims/internal/uce/common/StatusCode;
+Lcom/android/ims/internal/uce/options/IOptionsService;->getMyInfo(II)Lcom/android/ims/internal/uce/common/StatusCode;
+Lcom/android/ims/internal/uce/options/IOptionsService;->getVersion(I)Lcom/android/ims/internal/uce/common/StatusCode;
+Lcom/android/ims/internal/uce/options/IOptionsService;->removeListener(ILcom/android/ims/internal/uce/common/UceLong;)Lcom/android/ims/internal/uce/common/StatusCode;
+Lcom/android/ims/internal/uce/options/IOptionsService;->responseIncomingOptions(IIILjava/lang/String;Lcom/android/ims/internal/uce/options/OptionsCapInfo;Z)Lcom/android/ims/internal/uce/common/StatusCode;
+Lcom/android/ims/internal/uce/options/IOptionsService;->setMyInfo(ILcom/android/ims/internal/uce/common/CapInfo;I)Lcom/android/ims/internal/uce/common/StatusCode;
+Lcom/android/ims/internal/uce/options/IOptionsService$Stub;-><init>()V
+Lcom/android/ims/internal/uce/presence/IPresenceListener;->capInfoReceived(Ljava/lang/String;[Lcom/android/ims/internal/uce/presence/PresTupleInfo;)V
+Lcom/android/ims/internal/uce/presence/IPresenceListener;->cmdStatus(Lcom/android/ims/internal/uce/presence/PresCmdStatus;)V
+Lcom/android/ims/internal/uce/presence/IPresenceListener;->getVersionCb(Ljava/lang/String;)V
+Lcom/android/ims/internal/uce/presence/IPresenceListener;->listCapInfoReceived(Lcom/android/ims/internal/uce/presence/PresRlmiInfo;[Lcom/android/ims/internal/uce/presence/PresResInfo;)V
+Lcom/android/ims/internal/uce/presence/IPresenceListener;->publishTriggering(Lcom/android/ims/internal/uce/presence/PresPublishTriggerType;)V
+Lcom/android/ims/internal/uce/presence/IPresenceListener;->serviceAvailable(Lcom/android/ims/internal/uce/common/StatusCode;)V
+Lcom/android/ims/internal/uce/presence/IPresenceListener;->serviceUnAvailable(Lcom/android/ims/internal/uce/common/StatusCode;)V
+Lcom/android/ims/internal/uce/presence/IPresenceListener;->sipResponseReceived(Lcom/android/ims/internal/uce/presence/PresSipResponse;)V
+Lcom/android/ims/internal/uce/presence/IPresenceListener;->unpublishMessageSent()V
+Lcom/android/ims/internal/uce/presence/IPresenceService;->addListener(ILcom/android/ims/internal/uce/presence/IPresenceListener;Lcom/android/ims/internal/uce/common/UceLong;)Lcom/android/ims/internal/uce/common/StatusCode;
+Lcom/android/ims/internal/uce/presence/IPresenceService;->getContactCap(ILjava/lang/String;I)Lcom/android/ims/internal/uce/common/StatusCode;
+Lcom/android/ims/internal/uce/presence/IPresenceService;->getContactListCap(I[Ljava/lang/String;I)Lcom/android/ims/internal/uce/common/StatusCode;
+Lcom/android/ims/internal/uce/presence/IPresenceService;->getVersion(I)Lcom/android/ims/internal/uce/common/StatusCode;
+Lcom/android/ims/internal/uce/presence/IPresenceService;->publishMyCap(ILcom/android/ims/internal/uce/presence/PresCapInfo;I)Lcom/android/ims/internal/uce/common/StatusCode;
+Lcom/android/ims/internal/uce/presence/IPresenceService;->reenableService(II)Lcom/android/ims/internal/uce/common/StatusCode;
+Lcom/android/ims/internal/uce/presence/IPresenceService;->removeListener(ILcom/android/ims/internal/uce/common/UceLong;)Lcom/android/ims/internal/uce/common/StatusCode;
+Lcom/android/ims/internal/uce/presence/IPresenceService;->setNewFeatureTag(ILjava/lang/String;Lcom/android/ims/internal/uce/presence/PresServiceInfo;I)Lcom/android/ims/internal/uce/common/StatusCode;
+Lcom/android/ims/internal/uce/presence/IPresenceService$Stub;-><init>()V
+Lcom/android/ims/internal/uce/presence/PresSipResponse;->getCmdId()Lcom/android/ims/internal/uce/presence/PresCmdId;
+Lcom/android/ims/internal/uce/presence/PresSipResponse;->getReasonPhrase()Ljava/lang/String;
+Lcom/android/ims/internal/uce/presence/PresSipResponse;->getRequestId()I
+Lcom/android/ims/internal/uce/presence/PresSipResponse;->getRetryAfter()I
+Lcom/android/ims/internal/uce/presence/PresSipResponse;->getSipResponseCode()I
+Lcom/android/ims/internal/uce/uceservice/IUceListener;->setStatus(I)V
+Lcom/android/ims/internal/uce/uceservice/IUceService;->createOptionsService(Lcom/android/ims/internal/uce/options/IOptionsListener;Lcom/android/ims/internal/uce/common/UceLong;)I
+Lcom/android/ims/internal/uce/uceservice/IUceService;->createPresenceService(Lcom/android/ims/internal/uce/presence/IPresenceListener;Lcom/android/ims/internal/uce/common/UceLong;)I
+Lcom/android/ims/internal/uce/uceservice/IUceService;->destroyOptionsService(I)V
+Lcom/android/ims/internal/uce/uceservice/IUceService;->destroyPresenceService(I)V
+Lcom/android/ims/internal/uce/uceservice/IUceService;->getOptionsService()Lcom/android/ims/internal/uce/options/IOptionsService;
+Lcom/android/ims/internal/uce/uceservice/IUceService;->getPresenceService()Lcom/android/ims/internal/uce/presence/IPresenceService;
+Lcom/android/ims/internal/uce/uceservice/IUceService;->getServiceStatus()Z
+Lcom/android/ims/internal/uce/uceservice/IUceService;->isServiceStarted()Z
+Lcom/android/ims/internal/uce/uceservice/IUceService;->startService(Lcom/android/ims/internal/uce/uceservice/IUceListener;)Z
+Lcom/android/ims/internal/uce/uceservice/IUceService;->stopService()Z
+Lcom/android/ims/internal/uce/uceservice/IUceService$Stub;-><init>()V
+Lcom/android/internal/location/ILocationProvider;->disable()V
+Lcom/android/internal/location/ILocationProvider;->enable()V
+Lcom/android/internal/location/ILocationProvider;->getProperties()Lcom/android/internal/location/ProviderProperties;
+Lcom/android/internal/location/ILocationProvider;->getStatus(Landroid/os/Bundle;)I
+Lcom/android/internal/location/ILocationProvider;->getStatusUpdateTime()J
+Lcom/android/internal/location/ILocationProvider;->sendExtraCommand(Ljava/lang/String;Landroid/os/Bundle;)Z
+Lcom/android/internal/location/ILocationProvider;->setRequest(Lcom/android/internal/location/ProviderRequest;Landroid/os/WorkSource;)V
+Lcom/android/internal/os/BatteryStatsImpl;->getDischargeCurrentLevel()I
+Lcom/android/internal/os/BatteryStatsImpl;->getDischargeStartLevel()I
+Lcom/android/internal/os/BatteryStatsImpl;->getPhoneOnTime(JI)J
+Lcom/android/internal/os/BatteryStatsImpl;->getPhoneSignalScanningTime(JI)J
+Lcom/android/internal/os/BatteryStatsImpl;->getPhoneSignalStrengthTime(IJI)J
+Lcom/android/internal/os/BatteryStatsImpl;->getScreenBrightnessTime(IJI)J
+Lcom/android/internal/os/BatteryStatsImpl;->getWifiOnTime(JI)J
+Lcom/android/internal/os/SomeArgs;->obtain()Lcom/android/internal/os/SomeArgs;
+Lcom/android/internal/os/SomeArgs;->recycle()V
+Lcom/android/internal/telephony/ITelephony;->getDataEnabled(I)Z
+Lcom/android/internal/util/IndentingPrintWriter;->decreaseIndent()Lcom/android/internal/util/IndentingPrintWriter;
+Lcom/android/internal/util/IndentingPrintWriter;->increaseIndent()Lcom/android/internal/util/IndentingPrintWriter;
+Lcom/android/internal/util/IndentingPrintWriter;-><init>(Ljava/io/Writer;Ljava/lang/String;)V
+Lcom/android/internal/util/XmlUtils;->beginDocument(Lorg/xmlpull/v1/XmlPullParser;Ljava/lang/String;)V
+Lcom/android/internal/util/XmlUtils;->nextElement(Lorg/xmlpull/v1/XmlPullParser;)V
+Ljava/lang/System;->arraycopy([BI[BII)V
+Ljava/net/Inet4Address;->ALL:Ljava/net/InetAddress;
+Ljava/net/Inet4Address;->ANY:Ljava/net/InetAddress;
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index afcd515..8dd0f42 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -704,7 +704,7 @@
                         streamingOutput);
                 profiling = true;
             } catch (RuntimeException e) {
-                Slog.w(TAG, "Profiling failed on path " + profileFile);
+                Slog.w(TAG, "Profiling failed on path " + profileFile, e);
                 try {
                     profileFd.close();
                     profileFd = null;
diff --git a/core/java/android/app/admin/DeviceAdminInfo.java b/core/java/android/app/admin/DeviceAdminInfo.java
index ed2aaf9..5fbe5b3 100644
--- a/core/java/android/app/admin/DeviceAdminInfo.java
+++ b/core/java/android/app/admin/DeviceAdminInfo.java
@@ -16,31 +16,31 @@
 
 package android.app.admin;
 
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlSerializer;
-
 import android.annotation.NonNull;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.pm.ActivityInfo;
-import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
 import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.pm.ResolveInfo;
 import android.content.res.Resources;
+import android.content.res.Resources.NotFoundException;
 import android.content.res.TypedArray;
 import android.content.res.XmlResourceParser;
-import android.content.res.Resources.NotFoundException;
 import android.graphics.drawable.Drawable;
 import android.os.Parcel;
 import android.os.Parcelable;
+import android.os.PersistableBundle;
 import android.util.AttributeSet;
 import android.util.Log;
 import android.util.Printer;
 import android.util.SparseArray;
 import android.util.Xml;
 
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlSerializer;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -266,6 +266,12 @@
      */
     int mUsesPolicies;
 
+    /**
+     * Whether this administrator can be a target in an ownership transfer.
+     *
+     * @see DevicePolicyManager#transferOwnership(ComponentName, ComponentName, PersistableBundle)
+     */
+    boolean mSupportsTransferOwnership;
 
     /**
      * Constructor.
@@ -347,6 +353,12 @@
                                     + getComponent() + ": " + policyName);
                         }
                     }
+                } else if (tagName.equals("support-transfer-ownership")) {
+                    if (parser.next() != XmlPullParser.END_TAG) {
+                        throw new XmlPullParserException(
+                                "support-transfer-ownership tag must be empty.");
+                    }
+                    mSupportsTransferOwnership = true;
                 }
             }
         } catch (NameNotFoundException e) {
@@ -360,6 +372,7 @@
     DeviceAdminInfo(Parcel source) {
         mActivityInfo = ActivityInfo.CREATOR.createFromParcel(source);
         mUsesPolicies = source.readInt();
+        mSupportsTransferOwnership = source.readBoolean();
     }
 
     /**
@@ -458,6 +471,13 @@
         return sRevKnownPolicies.get(policyIdent).tag;
     }
 
+    /**
+     * Return true if this administrator can be a target in an ownership transfer.
+     */
+    public boolean supportsTransferOwnership() {
+        return mSupportsTransferOwnership;
+    }
+
     /** @hide */
     public ArrayList<PolicyInfo> getUsedPolicies() {
         ArrayList<PolicyInfo> res = new ArrayList<PolicyInfo>();
@@ -502,6 +522,7 @@
     public void writeToParcel(Parcel dest, int flags) {
         mActivityInfo.writeToParcel(dest, flags);
         dest.writeInt(mUsesPolicies);
+        dest.writeBoolean(mSupportsTransferOwnership);
     }
 
     /**
diff --git a/core/java/android/app/admin/DeviceAdminReceiver.java b/core/java/android/app/admin/DeviceAdminReceiver.java
index 8c30fc4..1c9477d 100644
--- a/core/java/android/app/admin/DeviceAdminReceiver.java
+++ b/core/java/android/app/admin/DeviceAdminReceiver.java
@@ -505,31 +505,6 @@
     public static final String EXTRA_TRANSFER_OWNERSHIP_ADMIN_EXTRAS_BUNDLE =
             "android.app.extra.TRANSFER_OWNERSHIP_ADMIN_EXTRAS_BUNDLE";
 
-    /**
-     * Name under which a device administration component indicates whether it supports transfer of
-     * ownership. This meta-data is of type <code>boolean</code>. A value of <code>true</code>
-     * allows this administrator to be used as a target administrator for a transfer. If the value
-     * is <code>false</code>, ownership cannot be transferred to this administrator. The default
-     * value is <code>false</code>.
-     * <p>This metadata is used to avoid ownership transfer migration to an administrator with a
-     * version which does not yet support it.
-     * <p>Usage:
-     * <pre>
-     * &lt;receiver name="..." android:permission="android.permission.BIND_DEVICE_ADMIN"&gt;
-     *     &lt;meta-data
-     *         android:name="android.app.device_admin"
-     *         android:resource="@xml/..." /&gt;
-     *     &lt;meta-data
-     *         android:name="android.app.support_transfer_ownership"
-     *         android:value="true" /&gt;
-     * &lt;/receiver&gt;
-     * </pre>
-     *
-     * @see DevicePolicyManager#transferOwnership(ComponentName, ComponentName, PersistableBundle)
-     */
-    public static final String SUPPORT_TRANSFER_OWNERSHIP_META_DATA =
-            "android.app.support_transfer_ownership";
-
     private DevicePolicyManager mManager;
     private ComponentName mWho;
 
diff --git a/core/java/android/app/admin/DevicePolicyCache.java b/core/java/android/app/admin/DevicePolicyCache.java
new file mode 100644
index 0000000..fbb8ddf
--- /dev/null
+++ b/core/java/android/app/admin/DevicePolicyCache.java
@@ -0,0 +1,57 @@
+/*
+ * 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 android.app.admin;
+
+import android.annotation.UserIdInt;
+
+import com.android.server.LocalServices;
+
+/**
+ * Stores a copy of the set of device policies maintained by {@link DevicePolicyManager} that
+ * can be accessed from any place without risking dead locks.
+ *
+ * @hide
+ */
+public abstract class DevicePolicyCache {
+    protected DevicePolicyCache() {
+    }
+
+    /**
+     * @return the instance.
+     */
+    public static DevicePolicyCache getInstance() {
+        final DevicePolicyManagerInternal dpmi =
+                LocalServices.getService(DevicePolicyManagerInternal.class);
+        return (dpmi != null) ? dpmi.getDevicePolicyCache() : EmptyDevicePolicyCache.INSTANCE;
+    }
+
+    /**
+     * See {@link DevicePolicyManager#getScreenCaptureDisabled}
+     */
+    public abstract boolean getScreenCaptureDisabled(@UserIdInt int userHandle);
+
+    /**
+     * Empty implementation.
+     */
+    private static class EmptyDevicePolicyCache extends DevicePolicyCache {
+        private static final EmptyDevicePolicyCache INSTANCE = new EmptyDevicePolicyCache();
+
+        @Override
+        public boolean getScreenCaptureDisabled(int userHandle) {
+            return false;
+        }
+    }
+}
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index d42fa99..6511f21 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -9302,9 +9302,10 @@
      * after calling this method.
      *
      * <p>The incoming target administrator must have the
-     * {@link DeviceAdminReceiver#SUPPORT_TRANSFER_OWNERSHIP_META_DATA} <code>meta-data</code> tag
-     * included in its corresponding <code>receiver</code> component with a value of {@code true}.
-     * Otherwise an {@link IllegalArgumentException} will be thrown.
+     * <code>&lt;support-transfer-ownership /&gt;</code> tag inside the
+     * <code>&lt;device-admin&gt;&lt;/device-admin&gt;</code> tags in the xml file referenced by
+     * {@link DeviceAdminReceiver#DEVICE_ADMIN_META_DATA}. Otherwise an
+     * {@link IllegalArgumentException} will be thrown.
      *
      * @param admin which {@link DeviceAdminReceiver} this request is associated with
      * @param target which {@link DeviceAdminReceiver} we want the new administrator to be
diff --git a/core/java/android/app/admin/DevicePolicyManagerInternal.java b/core/java/android/app/admin/DevicePolicyManagerInternal.java
index ebaf464..de92978 100644
--- a/core/java/android/app/admin/DevicePolicyManagerInternal.java
+++ b/core/java/android/app/admin/DevicePolicyManagerInternal.java
@@ -141,4 +141,10 @@
      * @return localized error message
      */
     public abstract CharSequence getPrintingDisabledReasonForUser(@UserIdInt int userId);
+
+    /**
+     * @return cached version of DPM policies that can be accessed without risking deadlocks.
+     * Do not call it directly. Use {@link DevicePolicyCache#getInstance()} instead.
+     */
+    protected abstract DevicePolicyCache getDevicePolicyCache();
 }
diff --git a/core/java/android/app/slice/SliceManager.java b/core/java/android/app/slice/SliceManager.java
index c5ea9b2..67a72ec 100644
--- a/core/java/android/app/slice/SliceManager.java
+++ b/core/java/android/app/slice/SliceManager.java
@@ -273,7 +273,8 @@
      */
     public @Nullable Uri mapIntentToUri(@NonNull Intent intent) {
         Preconditions.checkNotNull(intent, "intent");
-        Preconditions.checkArgument(intent.getComponent() != null || intent.getPackage() != null,
+        Preconditions.checkArgument(intent.getComponent() != null || intent.getPackage() != null
+                || intent.getData() != null,
                 "Slice intent must be explicit %s", intent);
         ContentResolver resolver = mContext.getContentResolver();
 
@@ -337,7 +338,8 @@
     public @Nullable Slice bindSlice(@NonNull Intent intent,
             @NonNull List<SliceSpec> supportedSpecs) {
         Preconditions.checkNotNull(intent, "intent");
-        Preconditions.checkArgument(intent.getComponent() != null || intent.getPackage() != null,
+        Preconditions.checkArgument(intent.getComponent() != null || intent.getPackage() != null
+                || intent.getData() != null,
                 "Slice intent must be explicit %s", intent);
         ContentResolver resolver = mContext.getContentResolver();
 
diff --git a/core/java/android/appwidget/AppWidgetProviderInfo.java b/core/java/android/appwidget/AppWidgetProviderInfo.java
index 75ce4fb..6dd85ca 100644
--- a/core/java/android/appwidget/AppWidgetProviderInfo.java
+++ b/core/java/android/appwidget/AppWidgetProviderInfo.java
@@ -16,6 +16,7 @@
 
 package android.appwidget;
 
+import android.annotation.IntDef;
 import android.annotation.NonNull;
 import android.app.PendingIntent;
 import android.content.ComponentName;
@@ -32,6 +33,9 @@
 import android.util.DisplayMetrics;
 import android.util.TypedValue;
 
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
 /**
  * Describes the meta data for an installed AppWidget provider.  The fields in this class
  * correspond to the fields in the <code>&lt;appwidget-provider&gt;</code> xml tag.
@@ -55,6 +59,14 @@
      */
     public static final int RESIZE_BOTH = RESIZE_HORIZONTAL | RESIZE_VERTICAL;
 
+    /** @hide */
+    @IntDef(flag = true, prefix = { "FLAG_" }, value = {
+            RESIZE_HORIZONTAL,
+            RESIZE_VERTICAL,
+    })
+    @Retention(RetentionPolicy.SOURCE)
+    public @interface ResizeModeFlags {}
+
     /**
      * Indicates that the widget can be displayed on the home screen. This is the default value.
      */
@@ -70,6 +82,15 @@
      */
     public static final int WIDGET_CATEGORY_SEARCHBOX = 4;
 
+    /** @hide */
+    @IntDef(flag = true, prefix = { "FLAG_" }, value = {
+            WIDGET_CATEGORY_HOME_SCREEN,
+            WIDGET_CATEGORY_KEYGUARD,
+            WIDGET_CATEGORY_SEARCHBOX,
+    })
+    @Retention(RetentionPolicy.SOURCE)
+    public @interface CategoryFlags {}
+
     /**
      * The widget can be reconfigured anytime after it is bound by starting the
      * {@link #configure} activity.
@@ -87,6 +108,14 @@
      */
     public static final int WIDGET_FEATURE_HIDE_FROM_PICKER = 2;
 
+    /** @hide */
+    @IntDef(flag = true, prefix = { "FLAG_" }, value = {
+            WIDGET_FEATURE_RECONFIGURABLE,
+            WIDGET_FEATURE_HIDE_FROM_PICKER,
+    })
+    @Retention(RetentionPolicy.SOURCE)
+    public @interface FeatureFlags {}
+
     /**
      * Identity of this AppWidget component.  This component should be a {@link
      * android.content.BroadcastReceiver}, and it will be sent the AppWidget intents
@@ -215,6 +244,7 @@
      * <p>This field corresponds to the <code>android:resizeMode</code> attribute in
      * the AppWidget meta-data file.
      */
+    @ResizeModeFlags
     public int resizeMode;
 
     /**
@@ -226,6 +256,7 @@
      * <p>This field corresponds to the <code>widgetCategory</code> attribute in
      * the AppWidget meta-data file.
      */
+    @CategoryFlags
     public int widgetCategory;
 
     /**
@@ -235,6 +266,7 @@
      * @see #WIDGET_FEATURE_RECONFIGURABLE
      * @see #WIDGET_FEATURE_HIDE_FROM_PICKER
      */
+    @FeatureFlags
     public int widgetFeatures;
 
     /** @hide */
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index ee667c2..b9e80e4 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -680,6 +680,10 @@
         if (!getLeAccess()) {
             return null;
         }
+        if (!isMultipleAdvertisementSupported()) {
+            Log.e(TAG, "Bluetooth LE advertising not supported");
+            return null;
+        }
         synchronized (mLock) {
             if (sBluetoothLeAdvertiser == null) {
                 sBluetoothLeAdvertiser = new BluetoothLeAdvertiser(mManagerService);
diff --git a/core/java/android/hardware/camera2/CameraMetadata.java b/core/java/android/hardware/camera2/CameraMetadata.java
index 52aefcc..14c2865 100644
--- a/core/java/android/hardware/camera2/CameraMetadata.java
+++ b/core/java/android/hardware/camera2/CameraMetadata.java
@@ -1435,9 +1435,11 @@
      * for the external flash. Otherwise, this mode acts like ON.</p>
      * <p>When the external flash is turned off, AE mode should be changed to one of the
      * other available AE modes.</p>
-     * <p>If the camera device supports AE external flash mode, aeState must be
-     * FLASH_REQUIRED after the camera device finishes AE scan and it's too dark without
+     * <p>If the camera device supports AE external flash mode, {@link CaptureResult#CONTROL_AE_STATE android.control.aeState} must
+     * be FLASH_REQUIRED after the camera device finishes AE scan and it's too dark without
      * flash.</p>
+     *
+     * @see CaptureResult#CONTROL_AE_STATE
      * @see CaptureRequest#CONTROL_AE_MODE
      */
     public static final int CONTROL_AE_MODE_ON_EXTERNAL_FLASH = 5;
diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java
index e14dfa8..e84e48f 100644
--- a/core/java/android/hardware/camera2/CaptureResult.java
+++ b/core/java/android/hardware/camera2/CaptureResult.java
@@ -1001,8 +1001,8 @@
      * </tbody>
      * </table>
      * <p>If the camera device supports AE external flash mode (ON_EXTERNAL_FLASH is included in
-     * {@link CameraCharacteristics#CONTROL_AE_AVAILABLE_MODES android.control.aeAvailableModes}), aeState must be FLASH_REQUIRED after the camera device
-     * finishes AE scan and it's too dark without flash.</p>
+     * {@link CameraCharacteristics#CONTROL_AE_AVAILABLE_MODES android.control.aeAvailableModes}), {@link CaptureResult#CONTROL_AE_STATE android.control.aeState} must be FLASH_REQUIRED after
+     * the camera device finishes AE scan and it's too dark without flash.</p>
      * <p>For the above table, the camera device may skip reporting any state changes that happen
      * without application intervention (i.e. mode switch, trigger, locking). Any state that
      * can be skipped in that manner is called a transient state.</p>
@@ -1081,6 +1081,7 @@
      * @see CaptureRequest#CONTROL_AE_LOCK
      * @see CaptureRequest#CONTROL_AE_MODE
      * @see CaptureRequest#CONTROL_AE_PRECAPTURE_TRIGGER
+     * @see CaptureResult#CONTROL_AE_STATE
      * @see CaptureRequest#CONTROL_MODE
      * @see CaptureRequest#CONTROL_SCENE_MODE
      * @see CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index b3bf092..b4c8a5e 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -20,6 +20,8 @@
 import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
 import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
 
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
 import android.annotation.CallSuper;
 import android.annotation.DrawableRes;
 import android.annotation.IntDef;
@@ -239,19 +241,89 @@
     static final boolean DEBUG = false;
 
     /**
-     * The back button will close the input window.
+     * Allows the system to optimize the back button affordance based on the presence of software
+     * keyboard.
+     *
+     * <p>For instance, on devices that have navigation bar and software-rendered back button, the
+     * system may use a different icon while {@link #isInputViewShown()} returns {@code true}, to
+     * indicate that the back button has "dismiss" affordance.</p>
+     *
+     * <p>Note that {@link KeyEvent#KEYCODE_BACK} events continue to be sent to
+     * {@link #onKeyDown(int, KeyEvent)} even when this mode is specified. The default
+     * implementation of {@link #onKeyDown(int, KeyEvent)} for {@link KeyEvent#KEYCODE_BACK} does
+     * not take this mode into account.</p>
+     *
+     * <p>For API level {@link android.os.Build.VERSION_CODES#O_MR1} and lower devices, this is the
+     * only mode you can safely specify without worrying about the compatibility.</p>
+     *
+     * @see #setBackDisposition(int)
      */
-    public static final int BACK_DISPOSITION_DEFAULT = 0;  // based on window
+    public static final int BACK_DISPOSITION_DEFAULT = 0;
 
     /**
-     * This input method will not consume the back key.
+     * Deprecated flag.
+     *
+     * <p>To avoid compatibility issues, IME developers should not use this flag.</p>
+     *
+     * @deprecated on {@link android.os.Build.VERSION_CODES#P} and later devices, this flag is
+     *             handled as a synonym of {@link #BACK_DISPOSITION_DEFAULT}. On
+     *             {@link android.os.Build.VERSION_CODES#O_MR1} and prior devices, expected behavior
+     *             of this mode had not been well defined. Most likely the end result would be the
+     *             same as {@link #BACK_DISPOSITION_DEFAULT}. Either way it is not recommended to
+     *             use this mode
+     * @see #setBackDisposition(int)
      */
-    public static final int BACK_DISPOSITION_WILL_NOT_DISMISS = 1; // back
+    @Deprecated
+    public static final int BACK_DISPOSITION_WILL_NOT_DISMISS = 1;
 
     /**
-     * This input method will consume the back key.
+     * Deprecated flag.
+     *
+     * <p>To avoid compatibility issues, IME developers should not use this flag.</p>
+     *
+     * @deprecated on {@link android.os.Build.VERSION_CODES#P} and later devices, this flag is
+     *             handled as a synonym of {@link #BACK_DISPOSITION_DEFAULT}. On
+     *             {@link android.os.Build.VERSION_CODES#O_MR1} and prior devices, expected behavior
+     *             of this mode had not been well defined. In AOSP implementation running on devices
+     *             that have navigation bar, specifying this flag could change the software back
+     *             button to "Dismiss" icon no matter whether the software keyboard is shown or not,
+     *             but there would be no easy way to restore the icon state even after IME lost the
+     *             connection to the application. To avoid user confusions, do not specify this mode
+     *             anyway
+     * @see #setBackDisposition(int)
      */
-    public static final int BACK_DISPOSITION_WILL_DISMISS = 2; // down
+    @Deprecated
+    public static final int BACK_DISPOSITION_WILL_DISMISS = 2;
+
+    /**
+     * Asks the system to not adjust the back button affordance even when the software keyboard is
+     * shown.
+     *
+     * <p>This mode is useful for UI modes where IME's main soft input window is used for some
+     * supplemental UI, such as floating candidate window for languages such as Chinese and
+     * Japanese, where users expect the back button is, or at least looks to be, handled by the
+     * target application rather than the UI shown by the IME even while {@link #isInputViewShown()}
+     * returns {@code true}.</p>
+     *
+     * <p>Note that {@link KeyEvent#KEYCODE_BACK} events continue to be sent to
+     * {@link #onKeyDown(int, KeyEvent)} even when this mode is specified. The default
+     * implementation of {@link #onKeyDown(int, KeyEvent)} for {@link KeyEvent#KEYCODE_BACK} does
+     * not take this mode into account.</p>
+     *
+     * @see #setBackDisposition(int)
+     */
+    public static final int BACK_DISPOSITION_ADJUST_NOTHING = 3;
+
+    /**
+     * Enum flag to be used for {@link #setBackDisposition(int)}.
+     *
+     * @hide
+     */
+    @Retention(SOURCE)
+    @IntDef(value = {BACK_DISPOSITION_DEFAULT, BACK_DISPOSITION_WILL_NOT_DISMISS,
+            BACK_DISPOSITION_WILL_DISMISS, BACK_DISPOSITION_ADJUST_NOTHING},
+            prefix = "BACK_DISPOSITION_")
+    public @interface BackDispositionMode {}
 
     /**
      * @hide
@@ -267,7 +339,7 @@
 
     // Min and max values for back disposition.
     private static final int BACK_DISPOSITION_MIN = BACK_DISPOSITION_DEFAULT;
-    private static final int BACK_DISPOSITION_MAX = BACK_DISPOSITION_WILL_DISMISS;
+    private static final int BACK_DISPOSITION_MAX = BACK_DISPOSITION_ADJUST_NOTHING;
 
     InputMethodManager mImm;
     
@@ -331,6 +403,8 @@
     boolean mIsInputViewShown;
     
     int mStatusIcon;
+
+    @BackDispositionMode
     int mBackDisposition;
 
     /**
@@ -1015,8 +1089,19 @@
     public Dialog getWindow() {
         return mWindow;
     }
-    
-    public void setBackDisposition(int disposition) {
+
+    /**
+     * Sets the disposition mode that indicates the expected affordance for the back button.
+     *
+     * <p>Keep in mind that specifying this flag does not change the the default behavior of
+     * {@link #onKeyDown(int, KeyEvent)}.  It is IME developers' responsibility for making sure that
+     * their custom implementation of {@link #onKeyDown(int, KeyEvent)} is consistent with the mode
+     * specified to this API.</p>
+     *
+     * @see #getBackDisposition()
+     * @param disposition disposition mode to be set
+     */
+    public void setBackDisposition(@BackDispositionMode int disposition) {
         if (disposition == mBackDisposition) {
             return;
         }
@@ -1029,6 +1114,13 @@
                 mBackDisposition);
     }
 
+    /**
+     * Retrieves the current disposition mode that indicates the expected back button affordance.
+     *
+     * @see #setBackDisposition(int)
+     * @return currently selected disposition mode
+     */
+    @BackDispositionMode
     public int getBackDisposition() {
         return mBackDisposition;
     }
@@ -1894,7 +1986,6 @@
         mInputStarted = false;
         mStartedInputConnection = null;
         mCurCompletions = null;
-        mBackDisposition = BACK_DISPOSITION_DEFAULT;
     }
 
     void doStartInput(InputConnection ic, EditorInfo attribute, boolean restarting) {
@@ -2096,25 +2187,31 @@
         return mExtractEditText;
     }
 
+
     /**
-     * Override this to intercept key down events before they are processed by the
-     * application.  If you return true, the application will not 
-     * process the event itself.  If you return false, the normal application processing
-     * will occur as if the IME had not seen the event at all.
-     * 
-     * <p>The default implementation intercepts {@link KeyEvent#KEYCODE_BACK
-     * KeyEvent.KEYCODE_BACK} if the IME is currently shown, to
-     * possibly hide it when the key goes up (if not canceled or long pressed).  In
-     * addition, in fullscreen mode only, it will consume DPAD movement
-     * events to move the cursor in the extracted text view, not allowing
-     * them to perform navigation in the underlying application.
+     * Called back when a {@link KeyEvent} is forwarded from the target application.
+     *
+     * <p>The default implementation intercepts {@link KeyEvent#KEYCODE_BACK} if the IME is
+     * currently shown , to possibly hide it when the key goes up (if not canceled or long pressed).
+     * In addition, in fullscreen mode only, it will consume DPAD movement events to move the cursor
+     * in the extracted text view, not allowing them to perform navigation in the underlying
+     * application.</p>
+     *
+     * <p>The default implementation does not take flags specified to
+     * {@link #setBackDisposition(int)} into account, even on API version
+     * {@link android.os.Build.VERSION_CODES#P} and later devices.  IME developers are responsible
+     * for making sure that their special handling for {@link KeyEvent#KEYCODE_BACK} are consistent
+     * with the flag they specified to {@link #setBackDisposition(int)}.</p>
+     *
+     * @param keyCode The value in {@code event.getKeyCode()}
+     * @param event Description of the key event
+     *
+     * @return {@code true} if the event is consumed by the IME and the application no longer needs
+     *         to consume it.  Return {@code false} when the event should be handled as if the IME
+     *         had not seen the event at all.
      */
     public boolean onKeyDown(int keyCode, KeyEvent event) {
-
         if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
-            if (mBackDisposition == BACK_DISPOSITION_WILL_NOT_DISMISS) {
-                return false;
-            }
             final ExtractEditText eet = getExtractEditTextIfVisible();
             if (eet != null && eet.handleBackInTextActionModeIfNeeded(event)) {
                 return true;
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 1c24876..a13b167 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -12360,6 +12360,28 @@
          * @hide
          */
         public static final String SHOW_ZEN_UPGRADE_NOTIFICATION = "show_zen_upgrade_notification";
+
+        /**
+         * Backup and restore agent timeout parameters.
+         * These parameters are represented by a comma-delimited key-value list.
+         *
+         * The following strings are supported as keys:
+         * <pre>
+         *     kv_backup_agent_timeout_millis         (long)
+         *     full_backup_agent_timeout_millis       (long)
+         *     shared_backup_agent_timeout_millis     (long)
+         *     restore_agent_timeout_millis           (long)
+         *     restore_agent_finished_timeout_millis  (long)
+         * </pre>
+         *
+         * They map to milliseconds represented as longs.
+         *
+         * Ex: "kv_backup_agent_timeout_millis=30000,full_backup_agent_timeout_millis=300000"
+         *
+         * @hide
+         */
+        public static final String BACKUP_AGENT_TIMEOUT_PARAMETERS =
+                "backup_agent_timeout_parameters";
     }
 
     /**
diff --git a/core/java/android/security/keystore/recovery/BadCertificateFormatException.java b/core/java/android/security/keystore/recovery/BadCertificateFormatException.java
deleted file mode 100644
index 4275c29..0000000
--- a/core/java/android/security/keystore/recovery/BadCertificateFormatException.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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 android.security.keystore.recovery;
-
-/**
- * @deprecated Not used.
- * @hide
- */
-public class BadCertificateFormatException extends RecoveryControllerException {
-    public BadCertificateFormatException(String msg) {
-        super(msg);
-    }
-}
diff --git a/core/java/android/security/keystore/recovery/RecoveryControllerException.java b/core/java/android/security/keystore/recovery/RecoveryControllerException.java
deleted file mode 100644
index 1af61ce..0000000
--- a/core/java/android/security/keystore/recovery/RecoveryControllerException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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 android.security.keystore.recovery;
-
-import java.security.GeneralSecurityException;
-
-/**
- * @deprecated Not used.
- * @hide
- */
-public abstract class RecoveryControllerException extends GeneralSecurityException {
-    RecoveryControllerException() { }
-
-    RecoveryControllerException(String msg) {
-        super(msg);
-    }
-
-    public RecoveryControllerException(String message, Throwable cause) {
-        super(message, cause);
-    }
-}
diff --git a/core/java/android/util/StatsLog.java b/core/java/android/util/StatsLog.java
index 3350f3e..789131c 100644
--- a/core/java/android/util/StatsLog.java
+++ b/core/java/android/util/StatsLog.java
@@ -16,6 +16,8 @@
 
 package android.util;
 
+import android.os.Process;
+
 /**
  * StatsLog provides an API for developers to send events to statsd. The events can be used to
  * define custom metrics inside statsd. We will rate-limit how often the calls can be made inside
@@ -34,7 +36,8 @@
      */
     public static boolean logStart(int label) {
         if (label >= 0 && label < 16) {
-            StatsLog.write(APP_BREADCRUMB_REPORTED, label, APP_BREADCRUMB_REPORTED__STATE__START);
+            StatsLog.write(APP_BREADCRUMB_REPORTED, Process.myUid(),
+                    label, APP_BREADCRUMB_REPORTED__STATE__START);
             return true;
         }
         return false;
@@ -48,7 +51,8 @@
      */
     public static boolean logStop(int label) {
         if (label >= 0 && label < 16) {
-            StatsLog.write(APP_BREADCRUMB_REPORTED, label, APP_BREADCRUMB_REPORTED__STATE__STOP);
+            StatsLog.write(APP_BREADCRUMB_REPORTED, Process.myUid(),
+                    label, APP_BREADCRUMB_REPORTED__STATE__STOP);
             return true;
         }
         return false;
@@ -62,7 +66,7 @@
      */
     public static boolean logEvent(int label) {
         if (label >= 0 && label < 16) {
-            StatsLog.write(APP_BREADCRUMB_REPORTED, label,
+            StatsLog.write(APP_BREADCRUMB_REPORTED, Process.myUid(), label,
                     APP_BREADCRUMB_REPORTED__STATE__UNSPECIFIED);
             return true;
         }
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index 77a74e2..d172fb5 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -181,9 +181,10 @@
     void setStrictModeVisualIndicatorPreference(String enabled);
 
     /**
-     * Set whether screen capture is disabled for all windows of a specific user
+     * Set whether screen capture is disabled for all windows of a specific user from
+     * the device policy cache.
      */
-    void setScreenCaptureDisabled(int userId, boolean disabled);
+    void refreshScreenCaptureDisabled(int userId);
 
     // These can only be called with the SET_ORIENTATION permission.
     /**
diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java
index 75fc538..bbdf15c 100644
--- a/core/java/android/widget/RelativeLayout.java
+++ b/core/java/android/widget/RelativeLayout.java
@@ -1182,12 +1182,12 @@
      * determine where to position the view on the screen.  If the view is not contained
      * within a relative layout, these attributes are ignored.
      *
-     * See the <a href=“https://developer.android.com/guide/topics/ui/layout/relative.html”>
+     * See the <a href="/guide/topics/ui/layout/relative.html">
      * Relative Layout</a> guide for example code demonstrating how to use relative layout’s
      * layout parameters in a layout XML.
      *
      * To learn more about layout parameters and how they differ from typical view attributes,
-     * see the <a href=“https://developer.android.com/guide/topics/ui/declaring-layout.html#attributes”>
+     * see the <a href="/guide/topics/ui/declaring-layout.html#attributes">
      *     Layouts guide</a>.
      *
      *
diff --git a/core/java/android/widget/TextInputTimePickerView.java b/core/java/android/widget/TextInputTimePickerView.java
index e0261ad..9f905d1 100644
--- a/core/java/android/widget/TextInputTimePickerView.java
+++ b/core/java/android/widget/TextInputTimePickerView.java
@@ -24,6 +24,7 @@
 import android.util.AttributeSet;
 import android.util.MathUtils;
 import android.view.View;
+import android.view.accessibility.AccessibilityManager;
 
 import com.android.internal.R;
 
@@ -93,7 +94,13 @@
 
             @Override
             public void afterTextChanged(Editable editable) {
-                parseAndSetHourInternal(editable.toString());
+                if (parseAndSetHourInternal(editable.toString()) && editable.length() > 1) {
+                    AccessibilityManager am = (AccessibilityManager) context.getSystemService(
+                            context.ACCESSIBILITY_SERVICE);
+                    if (!am.isEnabled()) {
+                        mMinuteEditText.requestFocus();
+                    }
+                }
             }
         });
 
diff --git a/core/java/com/android/internal/os/FuseAppLoop.java b/core/java/com/android/internal/os/FuseAppLoop.java
index 12405eb..67fbe5e 100644
--- a/core/java/com/android/internal/os/FuseAppLoop.java
+++ b/core/java/com/android/internal/os/FuseAppLoop.java
@@ -138,7 +138,7 @@
     private static final int FUSE_FSYNC = 20;
 
     // Defined in FuseBuffer.h
-    private static final int FUSE_MAX_WRITE = 256 * 1024;
+    private static final int FUSE_MAX_WRITE = 128 * 1024;
 
     @Override
     public boolean handleMessage(Message msg) {
diff --git a/core/jni/android/graphics/BitmapRegionDecoder.cpp b/core/jni/android/graphics/BitmapRegionDecoder.cpp
index 3b081ef..f831c05 100644
--- a/core/jni/android/graphics/BitmapRegionDecoder.cpp
+++ b/core/jni/android/graphics/BitmapRegionDecoder.cpp
@@ -155,12 +155,6 @@
         env->SetObjectField(options, gOptions_outColorSpaceFieldID, 0);
     }
 
-    SkBitmapRegionDecoder* brd = reinterpret_cast<SkBitmapRegionDecoder*>(brdHandle);
-
-    SkColorType decodeColorType = brd->computeOutputColorType(colorType);
-    sk_sp<SkColorSpace> decodeColorSpace = brd->computeOutputColorSpace(
-            decodeColorType, colorSpace);
-
     // Recycle a bitmap if possible.
     android::Bitmap* recycledBitmap = nullptr;
     size_t recycledBytes = 0;
@@ -172,6 +166,9 @@
         recycledBytes = bitmap::getBitmapAllocationByteCount(env, javaBitmap);
     }
 
+    SkBitmapRegionDecoder* brd = reinterpret_cast<SkBitmapRegionDecoder*>(brdHandle);
+    SkColorType decodeColorType = brd->computeOutputColorType(colorType);
+
     // Set up the pixel allocator
     SkBRDAllocator* allocator = nullptr;
     RecyclingClippingPixelAllocator recycleAlloc(recycledBitmap, recycledBytes);
@@ -184,6 +181,9 @@
         allocator = &heapAlloc;
     }
 
+    sk_sp<SkColorSpace> decodeColorSpace = brd->computeOutputColorSpace(
+            decodeColorType, colorSpace);
+
     // Decode the region.
     SkIRect subset = SkIRect::MakeXYWH(inputX, inputY, inputWidth, inputHeight);
     SkBitmap bitmap;
diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp
index 8ca5062..a30b2ad 100644
--- a/core/jni/android_view_SurfaceControl.cpp
+++ b/core/jni/android_view_SurfaceControl.cpp
@@ -36,8 +36,9 @@
 #include <stdio.h>
 #include <system/graphics.h>
 #include <ui/DisplayInfo.h>
-#include <ui/HdrCapabilities.h>
 #include <ui/FrameStats.h>
+#include <ui/GraphicsTypes.h>
+#include <ui/HdrCapabilities.h>
 #include <ui/Rect.h>
 #include <ui/Region.h>
 #include <utils/Log.h>
@@ -290,7 +291,7 @@
     }
 
     sp<GraphicBuffer> buffer;
-    status_t res = ScreenshotClient::captureLayers(layerHandle, sourceCrop, frameScale, &buffer);
+    status_t res = ScreenshotClient::captureChildLayers(layerHandle, sourceCrop, frameScale, &buffer);
     if (res != NO_ERROR) {
         return NULL;
     }
@@ -593,7 +594,7 @@
 static jintArray nativeGetDisplayColorModes(JNIEnv* env, jclass, jobject tokenObj) {
     sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
     if (token == NULL) return NULL;
-    Vector<android_color_mode_t> colorModes;
+    Vector<ColorMode> colorModes;
     if (SurfaceComposerClient::getDisplayColorModes(token, &colorModes) != NO_ERROR ||
             colorModes.isEmpty()) {
         return NULL;
@@ -623,7 +624,7 @@
     sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
     if (token == NULL) return JNI_FALSE;
     status_t err = SurfaceComposerClient::setActiveColorMode(token,
-            static_cast<android_color_mode_t>(colorMode));
+            static_cast<ColorMode>(colorMode));
     return err == NO_ERROR ? JNI_TRUE : JNI_FALSE;
 }
 
diff --git a/core/jni/com_android_internal_os_FuseAppLoop.cpp b/core/jni/com_android_internal_os_FuseAppLoop.cpp
index 8837df5..fdc088e 100644
--- a/core/jni/com_android_internal_os_FuseAppLoop.cpp
+++ b/core/jni/com_android_internal_os_FuseAppLoop.cpp
@@ -166,8 +166,8 @@
 void com_android_internal_os_FuseAppLoop_replyRead(
         JNIEnv* env, jobject self, jlong ptr, jlong unique, jint size, jbyteArray data) {
     ScopedByteArrayRO array(env, data);
-    CHECK(size >= 0);
-    CHECK(static_cast<size_t>(size) < array.size());
+    CHECK_GE(size, 0);
+    CHECK_LE(static_cast<size_t>(size), array.size());
     if (!reinterpret_cast<fuse::FuseAppLoop*>(ptr)->ReplyRead(unique, size, array.get())) {
         reinterpret_cast<fuse::FuseAppLoop*>(ptr)->Break();
     }
diff --git a/core/proto/android/providers/settings.proto b/core/proto/android/providers/settings.proto
index 23c5661..a818e20 100644
--- a/core/proto/android/providers/settings.proto
+++ b/core/proto/android/providers/settings.proto
@@ -502,9 +502,10 @@
     optional SettingProto show_restart_in_crash_dialog = 383 [ (android.privacy).dest = DEST_AUTOMATIC ];
     optional SettingProto show_mute_in_crash_dialog = 384 [ (android.privacy).dest = DEST_AUTOMATIC ];
     optional SettingsProto show_zen_upgrade_notification = 385  [ (android.privacy).dest = DEST_AUTOMATIC ];
+    optional SettingsProto backup_agent_timeout_parameters = 386;
     // Please insert fields in the same order as in
     // frameworks/base/core/java/android/provider/Settings.java.
-    // Next tag = 386;
+    // Next tag = 387;
 }
 
 message SecureSettingsProto {
diff --git a/core/proto/android/service/diskstats.proto b/core/proto/android/service/diskstats.proto
index 3d7ee91..e5bdc8b 100644
--- a/core/proto/android/service/diskstats.proto
+++ b/core/proto/android/service/diskstats.proto
@@ -55,25 +55,25 @@
     option (android.msg_privacy).dest = DEST_AUTOMATIC;
 
     // Total app code size, in kilobytes
-    optional int64 agg_apps_size = 1;
+    optional int64 agg_apps_size_kb = 1;
     // Total app cache size, in kilobytes
-    optional int64 agg_apps_cache_size = 2;
+    optional int64 agg_apps_cache_size_kb = 2;
     // Size of image files, in kilobytes
-    optional int64 photos_size = 3;
+    optional int64 photos_size_kb = 3;
     // Size of video files, in kilobytes
-    optional int64 videos_size = 4;
+    optional int64 videos_size_kb = 4;
     // Size of audio files, in kilobytes
-    optional int64 audio_size = 5;
+    optional int64 audio_size_kb = 5;
     // Size of downloads, in kilobytes
-    optional int64 downloads_size = 6;
+    optional int64 downloads_size_kb = 6;
     // Size of system directory, in kilobytes
-    optional int64 system_size = 7;
+    optional int64 system_size_kb = 7;
     // Size of other files, in kilobytes
-    optional int64 other_size = 8;
+    optional int64 other_size_kb = 8;
     // Sizes of individual packages
     repeated DiskStatsAppSizesProto app_sizes = 9;
     // Total app data size, in kilobytes
-    optional int64 agg_apps_data_size = 10;
+    optional int64 agg_apps_data_size_kb = 10;
 }
 
 message DiskStatsAppSizesProto {
@@ -82,11 +82,11 @@
     // Name of the package
     optional string package_name = 1;
     // App's code size in kilobytes
-    optional int64 app_size = 2;
+    optional int64 app_size_kb = 2;
     // App's cache size in kilobytes
-    optional int64 cache_size = 3;
+    optional int64 cache_size_kb = 3;
     // App's data size in kilobytes
-    optional int64 app_data_size = 4;
+    optional int64 app_data_size_kb = 4;
 }
 
 message DiskStatsFreeSpaceProto {
@@ -103,7 +103,7 @@
     // Which folder?
     optional Folder folder = 1;
     // Available space, in kilobytes
-    optional int64 available_space = 2;
+    optional int64 available_space_kb = 2;
     // Total space, in kilobytes
-    optional int64 total_space = 3;
+    optional int64 total_space_kb = 3;
 }
diff --git a/core/proto/android/service/graphicsstats.proto b/core/proto/android/service/graphicsstats.proto
index f422065..c2fedf5 100644
--- a/core/proto/android/service/graphicsstats.proto
+++ b/core/proto/android/service/graphicsstats.proto
@@ -56,7 +56,7 @@
     // Number of "missed vsync" events.
     optional int32 missed_vsync_count = 3;
 
-    // Number of "high input latency" events.
+    // Number of frames in triple-buffering scenario (high input latency)
     optional int32 high_input_latency_count = 4;
 
     // Number of "slow UI thread" events.
@@ -67,6 +67,9 @@
 
     // Number of "slow draw" events.
     optional int32 slow_draw_count = 7;
+
+    // Number of frames that missed their deadline (aka, visibly janked)
+    optional int32 missed_deadline_count = 8;
 }
 
 message GraphicsStatsHistogramBucketProto {
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 6c0be1b..daad866 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -160,13 +160,13 @@
     <string name="RestrictedStateContent">Temporarily turned off by your carrier</string>
 
     <!-- Displayed to tell the user that they should switch their network preference. -->
-    <string name="NetworkPreferenceSwitchTitle">Can\u2019t reach network</string>
+    <string name="NetworkPreferenceSwitchTitle">Can\u2019t reach mobile network</string>
     <!-- Displayed to tell the user that they should switch their network preference. -->
-    <string name="NetworkPreferenceSwitchSummary">To improve reception, try changing the type selected at Settings &gt; Network &amp; internet &gt; Mobile networks &gt; Preferred network type."</string>
+    <string name="NetworkPreferenceSwitchSummary">Try changing preferred network. Tap to change.</string>
     <!-- Displayed to tell the user that emergency calls might not be available. -->
-    <string name="EmergencyCallWarningTitle">Wi\u2011Fi calling is active</string>
+    <string name="EmergencyCallWarningTitle">Emergency calling unavailable</string>
     <!-- Displayed to tell the user that emergency calls might not be available. -->
-    <string name="EmergencyCallWarningSummary">Emergency calls require a mobile network.</string>
+    <string name="EmergencyCallWarningSummary">Can\u2019t make emergency calls over Wi\u2011Fi</string>
 
     <!-- Telephony notification channel name for a channel containing network alert notifications. -->
     <string name="notification_channel_network_alert">Alerts</string>
@@ -3279,7 +3279,7 @@
     <!-- USB_PREFERENCES: Notification for when the user connects the phone to a computer via USB in MIDI mode.  This is the title -->
     <string name="usb_midi_notification_title">MIDI via USB turned on</string>
     <!-- USB_PREFERENCES: Notification for when a USB accessory is attached.  This is the title -->
-    <string name="usb_accessory_notification_title">USB accessory mode turned on</string>
+    <string name="usb_accessory_notification_title">USB accessory connected</string>
     <!-- See USB_PREFERENCES. This is the message. -->
     <string name="usb_notification_message">Tap for more options.</string>
     <!-- See USB_PREFERENCES. This is the message when a data mode is turned on (mtp, ptp, midi) and the device is supplying power.. -->
@@ -3293,7 +3293,7 @@
     <!-- Title of notification shown when ADB is actively connected to the phone. -->
     <string name="adb_active_notification_title">USB debugging connected</string>
     <!-- Message of notification shown when ADB is actively connected to the phone. -->
-    <string name="adb_active_notification_message">Tap to disable USB debugging.</string>
+    <string name="adb_active_notification_message">Tap to turn off USB debugging</string>
     <string name="adb_active_notification_message" product="tv">Select to disable USB debugging.</string>
 
     <!-- Title of notification shown to indicate that bug report is being collected. -->
diff --git a/core/tests/coretests/BinderProxyCountingTestApp/Android.mk b/core/tests/coretests/BinderProxyCountingTestApp/Android.mk
index c3af6bd..4642694 100644
--- a/core/tests/coretests/BinderProxyCountingTestApp/Android.mk
+++ b/core/tests/coretests/BinderProxyCountingTestApp/Android.mk
@@ -24,5 +24,6 @@
 LOCAL_SDK_VERSION := current
 LOCAL_CERTIFICATE := platform
 
+LOCAL_COMPATIBILITY_SUITE := device-tests
 include $(BUILD_PACKAGE)
 
diff --git a/core/tests/coretests/BinderProxyCountingTestService/Android.mk b/core/tests/coretests/BinderProxyCountingTestService/Android.mk
index 34016ed..f852c7a 100644
--- a/core/tests/coretests/BinderProxyCountingTestService/Android.mk
+++ b/core/tests/coretests/BinderProxyCountingTestService/Android.mk
@@ -24,5 +24,6 @@
 LOCAL_PRIVATE_PLATFORM_APIS := true
 LOCAL_CERTIFICATE := platform
 
+LOCAL_COMPATIBILITY_SUITE := device-tests
 include $(BUILD_PACKAGE)
 
diff --git a/core/tests/coretests/BstatsTestApp/Android.mk b/core/tests/coretests/BstatsTestApp/Android.mk
index e04536b..a5872a5 100644
--- a/core/tests/coretests/BstatsTestApp/Android.mk
+++ b/core/tests/coretests/BstatsTestApp/Android.mk
@@ -30,4 +30,5 @@
 LOCAL_DEX_PREOPT := false
 LOCAL_PROGUARD_ENABLED := disabled
 
-include $(BUILD_PACKAGE)
\ No newline at end of file
+LOCAL_COMPATIBILITY_SUITE := device-tests
+include $(BUILD_PACKAGE)
diff --git a/core/tests/coretests/src/android/provider/SettingsBackupTest.java b/core/tests/coretests/src/android/provider/SettingsBackupTest.java
index a3155d5..aa11cd5 100644
--- a/core/tests/coretests/src/android/provider/SettingsBackupTest.java
+++ b/core/tests/coretests/src/android/provider/SettingsBackupTest.java
@@ -464,8 +464,8 @@
                     Settings.Global.ZRAM_ENABLED,
                     Settings.Global.OVERRIDE_SETTINGS_PROVIDER_RESTORE_ANY_VERSION,
                     Settings.Global.CHAINED_BATTERY_ATTRIBUTION_ENABLED,
-                    Settings.Global.HIDDEN_API_BLACKLIST_EXEMPTIONS);
-
+                    Settings.Global.HIDDEN_API_BLACKLIST_EXEMPTIONS,
+                    Settings.Global.BACKUP_AGENT_TIMEOUT_PARAMETERS);
     private static final Set<String> BACKUP_BLACKLISTED_SECURE_SETTINGS =
              newHashSet(
                  Settings.Secure.ACCESSIBILITY_SOFT_KEYBOARD_MODE,
diff --git a/core/tests/featureflagtests/AndroidTest.xml b/core/tests/featureflagtests/AndroidTest.xml
index 44f9c3e..38c048a 100644
--- a/core/tests/featureflagtests/AndroidTest.xml
+++ b/core/tests/featureflagtests/AndroidTest.xml
@@ -15,14 +15,16 @@
   limitations under the License.
   -->
 <configuration description="Runs Frameworks Utility Tests.">
-    <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
+    <option name="test-suite-tag" value="apct" />
+    <option name="test-suite-tag" value="apct-instrumentation" />
+
+    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+        <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="FrameworksCoreFeatureFlagTests.apk" />
     </target_preparer>
 
-    <option name="test-suite-tag" value="apct" />
     <option name="test-tag" value="FrameworksCoreFeatureFlagTests" />
     <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
         <option name="package" value="com.android.frameworks.coretests.featureflagtests" />
-        <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
     </test>
 </configuration>
diff --git a/core/tests/overlaytests/device/AndroidTest.xml b/core/tests/overlaytests/device/AndroidTest.xml
index f069835..6507839 100644
--- a/core/tests/overlaytests/device/AndroidTest.xml
+++ b/core/tests/overlaytests/device/AndroidTest.xml
@@ -17,8 +17,10 @@
 <configuration description="Test module config for OverlayDeviceTests">
     <option name="test-tag" value="OverlayDeviceTests" />
     <option name="test-suite-tag" value="apct" />
+    <option name="test-suite-tag" value="apct-instrumentation" />
 
     <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
+        <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="OverlayDeviceTests.apk" />
         <option name="test-file-name" value="OverlayDeviceTests_AppOverlayOne.apk" />
         <option name="test-file-name" value="OverlayDeviceTests_AppOverlayTwo.apk" />
@@ -42,6 +44,5 @@
 
     <test class="com.android.tradefed.testtype.AndroidJUnitTest">
         <option name="package" value="com.android.overlaytest" />
-        <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
     </test>
 </configuration>
diff --git a/core/tests/privacytests/AndroidTest.xml b/core/tests/privacytests/AndroidTest.xml
index a43f48e..8098c14 100644
--- a/core/tests/privacytests/AndroidTest.xml
+++ b/core/tests/privacytests/AndroidTest.xml
@@ -14,12 +14,14 @@
      limitations under the License.
 -->
 <configuration description="Runs Privacy Tests.">
-    <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
+    <option name="test-suite-tag" value="apct" />
+    <option name="test-suite-tag" value="apct-instrumentation" />
+    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+        <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="FrameworksPrivacyLibraryTests.apk" />
     </target_preparer>
 
     <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
         <option name="package" value="com.android.frameworks.coretests.privacy" />
-        <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
     </test>
-</configuration>
\ No newline at end of file
+</configuration>
diff --git a/core/tests/utiltests/AndroidTest.xml b/core/tests/utiltests/AndroidTest.xml
index 65bb8de..270d773 100644
--- a/core/tests/utiltests/AndroidTest.xml
+++ b/core/tests/utiltests/AndroidTest.xml
@@ -14,14 +14,16 @@
      limitations under the License.
 -->
 <configuration description="Runs Frameworks Utility Tests.">
-    <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
+    <option name="test-suite-tag" value="apct" />
+    <option name="test-suite-tag" value="apct-instrumentation" />
+
+    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+        <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="FrameworksUtilTests.apk" />
     </target_preparer>
 
-    <option name="test-suite-tag" value="apct" />
     <option name="test-tag" value="FrameworksUtilTests" />
     <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
         <option name="package" value="com.android.frameworks.utiltests" />
-        <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
     </test>
 </configuration>
diff --git a/core/tests/webkit/AndroidTest.xml b/core/tests/webkit/AndroidTest.xml
index 78cfa46..4c50b7d 100644
--- a/core/tests/webkit/AndroidTest.xml
+++ b/core/tests/webkit/AndroidTest.xml
@@ -14,7 +14,9 @@
      limitations under the License.
 -->
 <configuration description="Runs Frameworks WebView Loading Tests.">
-    <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
+    <option name="test-suite-tag" value="apct" />
+    <option name="test-suite-tag" value="apct-instrumentation" />
+    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="test-file-name" value="WebViewLoadingTests.apk" />
         <option name="test-file-name" value="WebViewLoadingOnDiskTestApk.apk" />
         <option name="test-file-name" value="WebViewLoadingFromApkTestApk.apk" />
@@ -24,6 +26,5 @@
 
     <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
         <option name="package" value="com.android.webkit.tests" />
-        <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
     </test>
 </configuration>
diff --git a/core/tests/webkit/apk_with_native_libs/Android.mk b/core/tests/webkit/apk_with_native_libs/Android.mk
index c51de6a..e18a7e0 100644
--- a/core/tests/webkit/apk_with_native_libs/Android.mk
+++ b/core/tests/webkit/apk_with_native_libs/Android.mk
@@ -45,6 +45,7 @@
 LOCAL_SDK_VERSION := $(MY_SDK_VERSION)
 LOCAL_PROGUARD_ENABLED := $(MY_PROGUARD_ENABLED)
 LOCAL_MULTILIB := $(MY_MULTILIB)
+LOCAL_COMPATIBILITY_SUITE := device-tests
 
 include $(BUILD_PACKAGE)
 
@@ -65,5 +66,6 @@
 LOCAL_SDK_VERSION := $(MY_SDK_VERSION)
 LOCAL_PROGUARD_ENABLED := $(MY_PROGUARD_ENABLED)
 LOCAL_MULTILIB := $(MY_MULTILIB)
+LOCAL_COMPATIBILITY_SUITE := device-tests
 
 include $(BUILD_PACKAGE)
diff --git a/data/etc/hiddenapi-package-whitelist.xml b/data/etc/hiddenapi-package-whitelist.xml
index be0372d..bacddf14 100644
--- a/data/etc/hiddenapi-package-whitelist.xml
+++ b/data/etc/hiddenapi-package-whitelist.xml
@@ -25,42 +25,50 @@
   <hidden-api-whitelisted-app package="android.car.input.service" />
   <hidden-api-whitelisted-app package="android.car.usb.handler" />
   <hidden-api-whitelisted-app package="android.ext.services" />
-  <hidden-api-whitelisted-app package="android.ext.shared" />
+  <hidden-api-whitelisted-app package="com.android.apps.tag" />
   <hidden-api-whitelisted-app package="com.android.backupconfirm" />
+  <hidden-api-whitelisted-app package="com.android.basicsmsreceiver" />
   <hidden-api-whitelisted-app package="com.android.bluetooth" />
   <hidden-api-whitelisted-app package="com.android.bluetoothdebug" />
   <hidden-api-whitelisted-app package="com.android.bluetoothmidiservice" />
+  <hidden-api-whitelisted-app package="com.android.bookmarkprovider" />
   <hidden-api-whitelisted-app package="com.android.calllogbackup" />
+  <hidden-api-whitelisted-app package="com.android.camera" />
   <hidden-api-whitelisted-app package="com.android.captiveportallogin" />
   <hidden-api-whitelisted-app package="com.android.car" />
+  <hidden-api-whitelisted-app package="com.android.car.dialer" />
   <hidden-api-whitelisted-app package="com.android.car.hvac" />
   <hidden-api-whitelisted-app package="com.android.car.mapsplaceholder" />
   <hidden-api-whitelisted-app package="com.android.car.media" />
   <hidden-api-whitelisted-app package="com.android.car.media.localmediaplayer" />
+  <hidden-api-whitelisted-app package="com.android.car.messenger" />
+  <hidden-api-whitelisted-app package="com.android.car.overview" />
   <hidden-api-whitelisted-app package="com.android.car.radio" />
   <hidden-api-whitelisted-app package="com.android.car.settings" />
+  <hidden-api-whitelisted-app package="com.android.car.stream" />
   <hidden-api-whitelisted-app package="com.android.car.systemupdater" />
   <hidden-api-whitelisted-app package="com.android.car.trust" />
   <hidden-api-whitelisted-app package="com.android.carrierconfig" />
   <hidden-api-whitelisted-app package="com.android.carrierdefaultapp" />
   <hidden-api-whitelisted-app package="com.android.cellbroadcastreceiver" />
   <hidden-api-whitelisted-app package="com.android.certinstaller" />
+  <hidden-api-whitelisted-app package="com.android.companiondevicemanager" />
   <hidden-api-whitelisted-app package="com.android.customlocale2" />
   <hidden-api-whitelisted-app package="com.android.defcontainer" />
   <hidden-api-whitelisted-app package="com.android.documentsui" />
+  <hidden-api-whitelisted-app package="com.android.dreams.basic" />
   <hidden-api-whitelisted-app package="com.android.egg" />
-  <hidden-api-whitelisted-app package="com.android.email.policy" />
   <hidden-api-whitelisted-app package="com.android.emergency" />
   <hidden-api-whitelisted-app package="com.android.externalstorage" />
   <hidden-api-whitelisted-app package="com.android.fakeoemfeatures" />
   <hidden-api-whitelisted-app package="com.android.gallery" />
   <hidden-api-whitelisted-app package="com.android.hotspot2" />
-  <hidden-api-whitelisted-app package="com.android.inputdevices" />
   <hidden-api-whitelisted-app package="com.android.keychain" />
   <hidden-api-whitelisted-app package="com.android.location.fused" />
   <hidden-api-whitelisted-app package="com.android.managedprovisioning" />
   <hidden-api-whitelisted-app package="com.android.mms.service" />
   <hidden-api-whitelisted-app package="com.android.mtp" />
+  <hidden-api-whitelisted-app package="com.android.musicfx" />
   <hidden-api-whitelisted-app package="com.android.nfc" />
   <hidden-api-whitelisted-app package="com.android.osu" />
   <hidden-api-whitelisted-app package="com.android.packageinstaller" />
@@ -70,12 +78,14 @@
   <hidden-api-whitelisted-app package="com.android.printservice.recommendation" />
   <hidden-api-whitelisted-app package="com.android.printspooler" />
   <hidden-api-whitelisted-app package="com.android.providers.blockednumber" />
+  <hidden-api-whitelisted-app package="com.android.providers.calendar" />
   <hidden-api-whitelisted-app package="com.android.providers.contacts" />
   <hidden-api-whitelisted-app package="com.android.providers.downloads" />
   <hidden-api-whitelisted-app package="com.android.providers.downloads.ui" />
   <hidden-api-whitelisted-app package="com.android.providers.media" />
   <hidden-api-whitelisted-app package="com.android.providers.settings" />
   <hidden-api-whitelisted-app package="com.android.providers.telephony" />
+  <hidden-api-whitelisted-app package="com.android.providers.tv" />
   <hidden-api-whitelisted-app package="com.android.providers.userdictionary" />
   <hidden-api-whitelisted-app package="com.android.provision" />
   <hidden-api-whitelisted-app package="com.android.proxyhandler" />
@@ -87,10 +97,15 @@
   <hidden-api-whitelisted-app package="com.android.settings" />
   <hidden-api-whitelisted-app package="com.android.sharedstoragebackup" />
   <hidden-api-whitelisted-app package="com.android.shell" />
+  <hidden-api-whitelisted-app package="com.android.smspush" />
+  <hidden-api-whitelisted-app package="com.android.spare_parts" />
+  <hidden-api-whitelisted-app package="com.android.statementservice" />
   <hidden-api-whitelisted-app package="com.android.stk" />
+  <hidden-api-whitelisted-app package="com.android.storagemanager" />
   <hidden-api-whitelisted-app package="com.android.support.car.lenspicker" />
   <hidden-api-whitelisted-app package="com.android.systemui" />
-  <hidden-api-whitelisted-app package="com.android.systemui.theme.dark" />
+  <hidden-api-whitelisted-app package="com.android.systemui.plugins" />
+  <hidden-api-whitelisted-app package="com.android.terminal" />
   <hidden-api-whitelisted-app package="com.android.timezone.updater" />
   <hidden-api-whitelisted-app package="com.android.traceur" />
   <hidden-api-whitelisted-app package="com.android.tv.settings" />
@@ -99,5 +114,5 @@
   <hidden-api-whitelisted-app package="com.android.wallpaperbackup" />
   <hidden-api-whitelisted-app package="com.android.wallpapercropper" />
   <hidden-api-whitelisted-app package="com.googlecode.android_scripting" />
+  <hidden-api-whitelisted-app package="jp.co.omronsoft.openwnn" />
 </config>
-
diff --git a/libs/hwui/JankTracker.cpp b/libs/hwui/JankTracker.cpp
index cf29e43..8110664 100644
--- a/libs/hwui/JankTracker.cpp
+++ b/libs/hwui/JankTracker.cpp
@@ -129,22 +129,42 @@
             totalDuration -= forgiveAmount;
         }
     }
+
     LOG_ALWAYS_FATAL_IF(totalDuration <= 0, "Impossible totalDuration %" PRId64, totalDuration);
     mData->reportFrame(totalDuration);
     (*mGlobalData)->reportFrame(totalDuration);
 
-    // Keep the fast path as fast as possible.
-    if (CC_LIKELY(totalDuration < mFrameInterval)) {
-        return;
-    }
-
     // Only things like Surface.lockHardwareCanvas() are exempt from tracking
-    if (frame[FrameInfoIndex::Flags] & EXEMPT_FRAMES_FLAGS) {
+    if (CC_UNLIKELY(frame[FrameInfoIndex::Flags] & EXEMPT_FRAMES_FLAGS)) {
         return;
     }
 
-    mData->reportJank();
-    (*mGlobalData)->reportJank();
+    if (totalDuration > mFrameInterval) {
+        mData->reportJank();
+        (*mGlobalData)->reportJank();
+    }
+
+    bool isTripleBuffered = mSwapDeadline > frame[FrameInfoIndex::IntendedVsync];
+
+    mSwapDeadline = std::max(mSwapDeadline + mFrameInterval,
+                             frame[FrameInfoIndex::IntendedVsync] + mFrameInterval);
+
+    // If we hit the deadline, cool!
+    if (frame[FrameInfoIndex::FrameCompleted] < mSwapDeadline) {
+        if (isTripleBuffered) {
+            mData->reportJankType(JankType::kHighInputLatency);
+            (*mGlobalData)->reportJankType(JankType::kHighInputLatency);
+        }
+        return;
+    }
+
+    mData->reportJankType(JankType::kMissedDeadline);
+    (*mGlobalData)->reportJankType(JankType::kMissedDeadline);
+
+    // Janked, reset the swap deadline
+    nsecs_t jitterNanos = frame[FrameInfoIndex::FrameCompleted] - frame[FrameInfoIndex::Vsync];
+    nsecs_t lastFrameOffset = jitterNanos % mFrameInterval;
+    mSwapDeadline = frame[FrameInfoIndex::FrameCompleted] - lastFrameOffset + mFrameInterval;
 
     for (int i = 0; i < NUM_BUCKETS; i++) {
         int64_t delta = frame.duration(COMPARISONS[i].start, COMPARISONS[i].end);
diff --git a/libs/hwui/JankTracker.h b/libs/hwui/JankTracker.h
index dc6a7ff..110211e 100644
--- a/libs/hwui/JankTracker.h
+++ b/libs/hwui/JankTracker.h
@@ -75,6 +75,7 @@
 
     std::array<int64_t, NUM_BUCKETS> mThresholds;
     int64_t mFrameInterval;
+    nsecs_t mSwapDeadline;
     // The amount of time we will erase from the total duration to account
     // for SF vsync offsets with HWC2 blocking dequeueBuffers.
     // (Vsync + mDequeueBlockTolerance) is the point at which we expect
diff --git a/libs/hwui/ProfileData.cpp b/libs/hwui/ProfileData.cpp
index b392ecd..f9cf549 100644
--- a/libs/hwui/ProfileData.cpp
+++ b/libs/hwui/ProfileData.cpp
@@ -23,8 +23,7 @@
 
 static const char* JANK_TYPE_NAMES[] = {
         "Missed Vsync",        "High input latency",       "Slow UI thread",
-        "Slow bitmap uploads", "Slow issue draw commands",
-};
+        "Slow bitmap uploads", "Slow issue draw commands", "Frame deadline missed"};
 
 // The bucketing algorithm controls so to speak
 // If a frame is <= to this it goes in bucket 0
diff --git a/libs/hwui/ProfileData.h b/libs/hwui/ProfileData.h
index 1e688ab..564920b 100644
--- a/libs/hwui/ProfileData.h
+++ b/libs/hwui/ProfileData.h
@@ -33,6 +33,7 @@
     kSlowUI,
     kSlowSync,
     kSlowRT,
+    kMissedDeadline,
 
     // must be last
     NUM_BUCKETS,
diff --git a/libs/hwui/pipeline/skia/SkiaRecordingCanvas.cpp b/libs/hwui/pipeline/skia/SkiaRecordingCanvas.cpp
index 25c76eb..62d78e7 100644
--- a/libs/hwui/pipeline/skia/SkiaRecordingCanvas.cpp
+++ b/libs/hwui/pipeline/skia/SkiaRecordingCanvas.cpp
@@ -148,31 +148,6 @@
 // Recording Canvas draw operations: Bitmaps
 // ----------------------------------------------------------------------------
 
-inline static const SkPaint* bitmapPaint(const SkPaint* origPaint, SkPaint* tmpPaint,
-                                         sk_sp<SkColorFilter> colorSpaceFilter) {
-    if ((origPaint && origPaint->isAntiAlias()) || colorSpaceFilter) {
-        if (origPaint) {
-            *tmpPaint = *origPaint;
-        }
-
-        if (colorSpaceFilter) {
-            if (tmpPaint->getColorFilter()) {
-                tmpPaint->setColorFilter(
-                        SkColorFilter::MakeComposeFilter(tmpPaint->refColorFilter(), colorSpaceFilter));
-            } else {
-                tmpPaint->setColorFilter(colorSpaceFilter);
-            }
-            LOG_ALWAYS_FATAL_IF(!tmpPaint->getColorFilter());
-        }
-
-
-        // disabling AA on bitmap draws matches legacy HWUI behavior
-        tmpPaint->setAntiAlias(false);
-        return tmpPaint;
-    } else {
-        return origPaint;
-    }
-}
 
 void SkiaRecordingCanvas::drawBitmap(Bitmap& bitmap, float left, float top, const SkPaint* paint) {
     SkPaint tmpPaint;
diff --git a/libs/hwui/pipeline/skia/SkiaRecordingCanvas.h b/libs/hwui/pipeline/skia/SkiaRecordingCanvas.h
index 0e5dbdb..93807a5 100644
--- a/libs/hwui/pipeline/skia/SkiaRecordingCanvas.h
+++ b/libs/hwui/pipeline/skia/SkiaRecordingCanvas.h
@@ -88,6 +88,45 @@
      *  @param height used to calculate recording bounds.
      */
     void initDisplayList(uirenderer::RenderNode* renderNode, int width, int height);
+
+    inline static const SkPaint* bitmapPaint(const SkPaint* origPaint, SkPaint* tmpPaint,
+                                             sk_sp<SkColorFilter> colorSpaceFilter) {
+        bool fixBlending = false;
+        bool fixAA = false;
+        if (origPaint) {
+            // kClear blend mode is drawn as kDstOut on HW for compatibility with Android O and
+            // older.
+            fixBlending = sApiLevel <= 27 && origPaint->getBlendMode() == SkBlendMode::kClear;
+            fixAA = origPaint->isAntiAlias();
+        }
+
+        if (fixBlending || fixAA || colorSpaceFilter) {
+            if (origPaint) {
+                *tmpPaint = *origPaint;
+            }
+
+            if (fixBlending) {
+                tmpPaint->setBlendMode(SkBlendMode::kDstOut);
+            }
+
+            if (colorSpaceFilter) {
+                if (tmpPaint->getColorFilter()) {
+                    tmpPaint->setColorFilter(SkColorFilter::MakeComposeFilter(
+                            tmpPaint->refColorFilter(), colorSpaceFilter));
+                } else {
+                    tmpPaint->setColorFilter(colorSpaceFilter);
+                }
+                LOG_ALWAYS_FATAL_IF(!tmpPaint->getColorFilter());
+            }
+
+            // disabling AA on bitmap draws matches legacy HWUI behavior
+            tmpPaint->setAntiAlias(false);
+            return tmpPaint;
+        } else {
+            return origPaint;
+        }
+    }
+
 };
 
 };  // namespace skiapipeline
diff --git a/libs/hwui/service/GraphicsStatsService.cpp b/libs/hwui/service/GraphicsStatsService.cpp
index e0303a8..599226b 100644
--- a/libs/hwui/service/GraphicsStatsService.cpp
+++ b/libs/hwui/service/GraphicsStatsService.cpp
@@ -176,6 +176,8 @@
     summary->set_slow_bitmap_upload_count(summary->slow_bitmap_upload_count() +
                                           data->jankTypeCount(kSlowSync));
     summary->set_slow_draw_count(summary->slow_draw_count() + data->jankTypeCount(kSlowRT));
+    summary->set_missed_deadline_count(summary->missed_deadline_count()
+            + data->jankTypeCount(kMissedDeadline));
 
     bool creatingHistogram = false;
     if (proto->histogram_size() == 0) {
@@ -246,6 +248,7 @@
     dprintf(fd, "\nNumber Slow UI thread: %d", summary.slow_ui_thread_count());
     dprintf(fd, "\nNumber Slow bitmap uploads: %d", summary.slow_bitmap_upload_count());
     dprintf(fd, "\nNumber Slow issue draw commands: %d", summary.slow_draw_count());
+    dprintf(fd, "\nNumber Frame deadline missed: %d", summary.missed_deadline_count());
     dprintf(fd, "\nHISTOGRAM:");
     for (const auto& it : proto->histogram()) {
         dprintf(fd, " %dms=%d", it.render_millis(), it.frame_count());
diff --git a/libs/hwui/tests/common/scenes/JankyScene.cpp b/libs/hwui/tests/common/scenes/JankyScene.cpp
new file mode 100644
index 0000000..f5e6b31
--- /dev/null
+++ b/libs/hwui/tests/common/scenes/JankyScene.cpp
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+#include "TestSceneBase.h"
+
+#include <unistd.h>
+
+class JankyScene;
+
+static TestScene::Registrar _JankyScene(TestScene::Info{
+        "janky",
+        "A scene that intentionally janks just enough to stay in "
+        "triple buffering.",
+        TestScene::simpleCreateScene<JankyScene>});
+
+class JankyScene : public TestScene {
+public:
+    sp<RenderNode> card;
+
+    void createContent(int width, int height, Canvas& canvas) override {
+        card = TestUtils::createNode(0, 0, 200, 200, [](RenderProperties& props, Canvas& canvas) {
+            canvas.drawColor(0xFF0000FF, SkBlendMode::kSrcOver);
+        });
+        canvas.drawColor(0xFFFFFFFF, SkBlendMode::kSrcOver);  // background
+        canvas.drawRenderNode(card.get());
+    }
+
+    void doFrame(int frameNr) override {
+        int curFrame = frameNr % 150;
+        if (curFrame & 1) {
+            usleep(15000);
+        }
+        // we animate left and top coordinates, which in turn animates width and
+        // height (bottom/right coordinates are fixed)
+        card->mutateStagingProperties().setLeftTop(curFrame, curFrame);
+        card->setPropertyFieldsDirty(RenderNode::X | RenderNode::Y);
+    }
+};
\ No newline at end of file
diff --git a/libs/incident/proto/android/privacy.proto b/libs/incident/proto/android/privacy.proto
index 7590b22..f29f57f 100644
--- a/libs/incident/proto/android/privacy.proto
+++ b/libs/incident/proto/android/privacy.proto
@@ -23,13 +23,10 @@
 
 package android;
 
-// TODO: It's better to track this by semantic types and set policy for those.
-// Do this for now to bootstrap the tools.
 enum Destination {
     // Fields or messages annotated with DEST_LOCAL must never be
     // extracted from the device automatically. They can be accessed
-    // by tools on the developer's workstation, and if they are sent
-    // to another device that must be by the user, with a PII warning. (TBD)
+    // by tools on the developer's workstation or test lab devices.
     DEST_LOCAL = 0;
 
     // Fields or messages annotated with DEST_EXPLICIT can be sent
@@ -43,25 +40,27 @@
     DEST_AUTOMATIC = 200;
 
     // This is the default value, which could be overridden by other values.
-    // The reason to pick 255 is it fits into one byte.
+    // The reason to pick 255 is it fits into one byte. UNSET fields are treated
+    // as EXPLICIT.
     DEST_UNSET = 255;
 
     // Currently use 0, 100, 200 and 255, values in between are reserved for futures.
 }
 
 message PrivacyFlags {
-  optional Destination dest = 1 [ default = DEST_UNSET ];
+    optional Destination dest = 1 [ default = DEST_UNSET ];
 
-  // regex to filter pii sensitive info from a string field type
-  repeated string patterns = 2;
+    // regex to filter pii sensitive info from a string field type.
+    repeated string patterns = 2;
 }
 
 extend google.protobuf.FieldOptions {
-    // Flags for automatically filtering statistics
+    // Flags used to annotate a field with right privacy level.
     optional PrivacyFlags privacy = 102672883;
 }
 
 extend google.protobuf.MessageOptions {
-    // Flags used to annotate a message which all its unset primitive types inhert this tag.
+    // Flags used to annotate a message which all its unset primitive fields inhert this tag.
     optional PrivacyFlags msg_privacy = 102672883;
 }
+
diff --git a/media/OWNERS b/media/OWNERS
index f198f43..182f661 100644
--- a/media/OWNERS
+++ b/media/OWNERS
@@ -4,3 +4,6 @@
 marcone@google.com
 sungsoo@google.com
 wjia@google.com
+jaewan@google.com
+chz@google.com
+
diff --git a/media/java/android/media/MediaController2.java b/media/java/android/media/MediaController2.java
index b51c662..20c3209 100644
--- a/media/java/android/media/MediaController2.java
+++ b/media/java/android/media/MediaController2.java
@@ -28,7 +28,6 @@
 import android.media.MediaSession2.CommandGroup;
 import android.media.MediaSession2.ControllerInfo;
 import android.media.MediaSession2.ErrorCode;
-import android.media.MediaSession2.PlaylistParams;
 import android.media.session.MediaSessionManager;
 import android.media.update.ApiLoader;
 import android.media.update.MediaController2Provider;
@@ -139,23 +138,6 @@
                 @Nullable ResultReceiver receiver) { }
 
         /**
-         * Called when the playlist is changed.
-         * <p>
-         * If the previously playing media item is gone, you should invalidate previous playback
-         * information and wait for later callbacks.
-         *
-         * @param controller the controller for this event
-         * @param playlist A new playlist set by the session.
-         * @see #onPositionChanged(MediaController2, long, long)
-         * @see #onBufferedPositionChanged(MediaController2, long)
-         * @see #onCurrentMediaItemChanged(MediaController2, MediaItem2)
-         * @hide
-         */
-        // TODO(jaewan): Remove (b/74174728)
-        public void onPlaylistChanged(@NonNull MediaController2 controller,
-                @NonNull List<MediaItem2> playlist) { }
-
-        /**
          * Called when the player state is changed.
          *
          * @param controller the controller for this event
@@ -266,17 +248,6 @@
         public void onRepeatModeChanged(@NonNull MediaController2 controller,
                 @NonNull MediaPlaylistAgent playlistAgent,
                 @MediaPlaylistAgent.RepeatMode int repeatMode) { }
-
-        /**
-         * Called when the playlist parameters are changed.
-         *
-         * @param controller the controller for this event
-         * @param params The new play list parameters.
-         * @hide
-         */
-        // TODO(jaewan): Remove (b/74116823)
-        public void onPlaylistParamsChanged(@NonNull MediaController2 controller,
-                @NonNull PlaylistParams params) { }
     }
 
     /**
@@ -478,19 +449,6 @@
     }
 
     /**
-     * Sets the {@link PlaylistParams} for the current play list. Repeat/shuffle mode and metadata
-     * for the list can be set by calling this method.
-     *
-     * @param params A {@link PlaylistParams} object to set.
-     * @throws IllegalArgumentException if given {@param param} is null.
-     * @hide
-     */
-    // TODO(jaewan): Remove (b/74116823)
-    public void setPlaylistParams(@NonNull PlaylistParams params) {
-        mProvider.setPlaylistParams_impl(params);
-    }
-
-    /**
      * @hide
      */
     public void skipForward() {
@@ -778,17 +736,6 @@
     }
 
     /**
-     * Returns the {@link PlaylistParams} for the current play list.
-     * Can return {@code null} if the controller doesn't have enough permission, or if the session
-     * has not set the parameters.
-     * @hide
-     */
-    // TODO(jaewan): Remove (b/74116823)
-    public @Nullable PlaylistParams getPlaylistParams() {
-        return mProvider.getPlaylistParams_impl();
-    }
-
-    /**
      * Inserts the media item to the playlist at position index.
      * <p>
      * This will not change the currently playing media item.
@@ -836,39 +783,83 @@
     }
 
     /**
-     * Sets the index of current DataSourceDesc in the play list to be played.
+     * Skips to the previous item in the playlist.
+     * <p>
+     * This calls {@link MediaPlaylistAgent#skipToPreviousItem()}.
+     */
+     public void skipToPreviousItem() {
+         mProvider.skipToPreviousItem_impl();
+     }
+
+    /**
+     * Skips to the next item in the playlist.
+     * <p>
+     * This calls {@link MediaPlaylistAgent#skipToNextItem()}.
+     */
+    public void skipToNextItem() {
+        mProvider.skipToNextItem_impl();
+    }
+
+    /**
+     * Skips to the item in the playlist.
+     * <p>
+     * This calls {@link MediaPlaylistAgent#skipToPlaylistItem(MediaItem2)}.
      *
-     * @param item the index of DataSourceDesc in the play list you want to play
-     * @throws IllegalArgumentException if the play list is null
-     * @throws NullPointerException if index is outside play list range
+     * @param item The item in the playlist you want to play
      */
     public void skipToPlaylistItem(@NonNull MediaItem2 item) {
         mProvider.skipToPlaylistItem_impl(item);
     }
 
-    public void skipToPreviousItem() {
-        mProvider.skipToPreviousItem_impl();
-    }
-
-    public void skipToNextItem() {
-        mProvider.skipToNextItem_impl();
-    }
-
+    /**
+     * Gets the cached repeat mode from the {@link ControllerCallback#onRepeatModeChanged(
+     * MediaController2, MediaPlaylistAgent, int)}.
+     *
+     * @return repeat mode
+     * @see MediaPlaylistAgent#REPEAT_MODE_NONE
+     * @see MediaPlaylistAgent#REPEAT_MODE_ONE
+     * @see MediaPlaylistAgent#REPEAT_MODE_ALL
+     * @see MediaPlaylistAgent#REPEAT_MODE_GROUP
+     */
     public @RepeatMode int getRepeatMode() {
-        // TODO(jaewan): Implement (b/74118768)
-        return 0;
+        return mProvider.getRepeatMode_impl();
     }
 
+    /**
+     * Sets the repeat mode.
+     *
+     * @param repeatMode repeat mode
+     * @see MediaPlaylistAgent#REPEAT_MODE_NONE
+     * @see MediaPlaylistAgent#REPEAT_MODE_ONE
+     * @see MediaPlaylistAgent#REPEAT_MODE_ALL
+     * @see MediaPlaylistAgent#REPEAT_MODE_GROUP
+     */
     public void setRepeatMode(@RepeatMode int repeatMode) {
-        // TODO(jaewan): Implement (b/74118768)
+        mProvider.setRepeatMode_impl(repeatMode);
     }
 
+    /**
+     * Gets the cached shuffle mode from the {@link ControllerCallback#onShuffleModeChanged(
+     * MediaController2, MediaPlaylistAgent, int)}.
+     *
+     * @return The shuffle mode
+     * @see MediaPlaylistAgent#SHUFFLE_MODE_NONE
+     * @see MediaPlaylistAgent#SHUFFLE_MODE_ALL
+     * @see MediaPlaylistAgent#SHUFFLE_MODE_GROUP
+     */
     public @ShuffleMode int getShuffleMode() {
-        // TODO(jaewan): Implement (b/74118768)
-        return 0;
+        return mProvider.getShuffleMode_impl();
     }
 
+    /**
+     * Sets the shuffle mode.
+     *
+     * @param shuffleMode The shuffle mode
+     * @see MediaPlaylistAgent#SHUFFLE_MODE_NONE
+     * @see MediaPlaylistAgent#SHUFFLE_MODE_ALL
+     * @see MediaPlaylistAgent#SHUFFLE_MODE_GROUP
+     */
     public void setShuffleMode(@ShuffleMode int shuffleMode) {
-        // TODO(jaewan): Implement (b/74118768)
+        mProvider.setShuffleMode_impl(shuffleMode);
     }
 }
diff --git a/media/java/android/media/MediaPlayer2Impl.java b/media/java/android/media/MediaPlayer2Impl.java
index 1c4d898..56423fd 100644
--- a/media/java/android/media/MediaPlayer2Impl.java
+++ b/media/java/android/media/MediaPlayer2Impl.java
@@ -82,7 +82,6 @@
 import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicInteger;
 
-
 /**
  * @hide
  */
@@ -116,8 +115,9 @@
     private boolean mNextSourcePlayPending = false;
     //--- guarded by |mSrcLock| end
 
-    private AtomicInteger mBufferedPercentageCurrent;
-    private AtomicInteger mBufferedPercentageNext;
+    private AtomicInteger mBufferedPercentageCurrent = new AtomicInteger(0);
+    private AtomicInteger mBufferedPercentageNext = new AtomicInteger(0);
+    private volatile float mVolume = 1.0f;
 
     // Modular DRM
     private final Object mDrmLock = new Object();
@@ -553,6 +553,7 @@
         addTask(new Task(CALL_COMPLETED_SET_PLAYER_VOLUME, false) {
             @Override
             void process() {
+                mVolume = volume;
                 _setVolume(volume, volume);
             }
         });
@@ -567,8 +568,7 @@
      */
     @Override
     public float getPlayerVolume() {
-        // TODO: get real volume
-        return 1.0f;
+        return mVolume;
     }
 
     /**
@@ -3227,9 +3227,7 @@
     @Override
     public void clearMediaPlayer2EventCallback() {
         synchronized (mEventCbLock) {
-            for (Pair<Executor, MediaPlayer2EventCallback> cb : mEventCallbackRecords) {
-                mEventCallbackRecords.remove(cb);
-            }
+            mEventCallbackRecords.clear();
         }
     }
 
@@ -3300,9 +3298,7 @@
     @Override
     public void clearDrmEventCallback() {
         synchronized (mDrmEventCbLock) {
-            for (Pair<Executor, DrmEventCallback> cb : mDrmEventCallbackRecords) {
-                mDrmEventCallbackRecords.remove(cb);
-            }
+            mDrmEventCallbackRecords.clear();
         }
     }
 
diff --git a/media/java/android/media/MediaPlayerBase.java b/media/java/android/media/MediaPlayerBase.java
index 70a36bf..f18e347 100644
--- a/media/java/android/media/MediaPlayerBase.java
+++ b/media/java/android/media/MediaPlayerBase.java
@@ -132,8 +132,8 @@
     public static final long UNKNOWN_TIME = -1;
 
     /**
-     * Returns the current playback head position.
-     * @return the current play position in ms, or {@link #UNKNOWN_TIME} if unknown.
+     * Gets the current playback head position.
+     * @return the current playback position in ms, or {@link #UNKNOWN_TIME} if unknown.
      */
     public long getCurrentPosition() { return UNKNOWN_TIME; }
 
@@ -144,8 +144,8 @@
     public long getDuration() { return UNKNOWN_TIME; }
 
     /**
-     * Returns the duration of the current data source, or {@link #UNKNOWN_TIME} if unknown.
-     * @return the duration in ms, or {@link #UNKNOWN_TIME}.
+     * Gets the buffered position of current playback, or {@link #UNKNOWN_TIME} if unknown.
+     * @return the buffered position in ms, or {@link #UNKNOWN_TIME}.
      */
     public long getBufferedPosition() { return UNKNOWN_TIME; }
 
diff --git a/media/java/android/media/MediaPlaylistAgent.java b/media/java/android/media/MediaPlaylistAgent.java
index 1d7520f..6b3620b 100644
--- a/media/java/android/media/MediaPlaylistAgent.java
+++ b/media/java/android/media/MediaPlaylistAgent.java
@@ -46,7 +46,7 @@
     @IntDef({REPEAT_MODE_NONE, REPEAT_MODE_ONE, REPEAT_MODE_ALL,
             REPEAT_MODE_GROUP})
     @Retention(RetentionPolicy.SOURCE)
-    @interface RepeatMode {}
+    public @interface RepeatMode {}
 
     /**
      * Playback will be stopped at the end of the playing media list.
@@ -75,7 +75,7 @@
      */
     @IntDef({SHUFFLE_MODE_NONE, SHUFFLE_MODE_ALL, SHUFFLE_MODE_GROUP})
     @Retention(RetentionPolicy.SOURCE)
-    @interface ShuffleMode {}
+    public @interface ShuffleMode {}
 
     /**
      * Media list will be played in order.
@@ -266,16 +266,22 @@
         mProvider.skipToPlaylistItem_impl(item);
     }
 
+    /**
+     * Skips to the previous item in the playlist.
+     */
     public void skipToPreviousItem() {
         mProvider.skipToPreviousItem_impl();
     }
 
+    /**
+     * Skips to the next item in the playlist.
+     */
     public void skipToNextItem() {
         mProvider.skipToNextItem_impl();
     }
 
     /**
-     * Get repeat mode
+     * Gets the repeat mode
      *
      * @return repeat mode
      * @see #REPEAT_MODE_NONE
@@ -288,7 +294,7 @@
     }
 
     /**
-     * Set repeat mode
+     * Sets the repeat mode
      *
      * @param repeatMode repeat mode
      * @see #REPEAT_MODE_NONE
@@ -301,9 +307,9 @@
     }
 
     /**
-     * Get shuffle mode
+     * Gets the shuffle mode
      *
-     * @return shuffle mode
+     * @return The shuffle mode
      * @see #SHUFFLE_MODE_NONE
      * @see #SHUFFLE_MODE_ALL
      * @see #SHUFFLE_MODE_GROUP
@@ -313,9 +319,9 @@
     }
 
     /**
-     * Set shuffle mode
+     * Sets the shuffle mode
      *
-     * @param shuffleMode shuffle mode
+     * @param shuffleMode The shuffle mode
      * @see #SHUFFLE_MODE_NONE
      * @see #SHUFFLE_MODE_ALL
      * @see #SHUFFLE_MODE_GROUP
@@ -323,4 +329,19 @@
     public void setShuffleMode(@ShuffleMode int shuffleMode) {
         mProvider.setShuffleMode_impl(shuffleMode);
     }
+
+    /**
+     * Gets a {@link MediaItem2} in the playlist that matches given {@code dsd}.
+     * You can override this method to have more finer control of updating {@link DataSourceDesc}
+     * on items in the playlist.
+     *
+     * @return A {@link MediaItem2} object in the playlist that matches given {@code dsd}.
+     *         {@code null} if playlist is not set, or if the playlist has no matching item.
+     * @throws IllegalArgumentException if {@code dsd} is null
+     * @hide
+     */
+    // TODO(jaewan): Unhide
+    public @Nullable MediaItem2 getMediaItem(@NonNull DataSourceDesc dsd) {
+        return mProvider.getMediaItem_impl(dsd);
+    }
 }
diff --git a/media/java/android/media/MediaSession2.java b/media/java/android/media/MediaSession2.java
index 91bface..60714df 100644
--- a/media/java/android/media/MediaSession2.java
+++ b/media/java/android/media/MediaSession2.java
@@ -28,8 +28,8 @@
 import android.media.MediaPlayerBase.BuffState;
 import android.media.MediaPlayerBase.PlayerEventCallback;
 import android.media.MediaPlayerBase.PlayerState;
-import android.media.MediaSession2.PlaylistParams.RepeatMode;
-import android.media.MediaSession2.PlaylistParams.ShuffleMode;
+import android.media.MediaPlaylistAgent.RepeatMode;
+import android.media.MediaPlaylistAgent.ShuffleMode;
 import android.media.update.ApiLoader;
 import android.media.update.MediaSession2Provider;
 import android.media.update.MediaSession2Provider.BuilderBaseProvider;
@@ -40,7 +40,6 @@
 import android.media.update.ProviderCreator;
 import android.net.Uri;
 import android.os.Bundle;
-import android.os.Handler;
 import android.os.IInterface;
 import android.os.ResultReceiver;
 
@@ -1224,134 +1223,6 @@
     }
 
     /**
-     * Parameter for the playlist.
-     * @hide
-     */
-    // TODO(jaewan): Remove (b/74116823)
-    public final static class PlaylistParams {
-        /**
-         * @hide
-         */
-        @IntDef({REPEAT_MODE_NONE, REPEAT_MODE_ONE, REPEAT_MODE_ALL,
-                REPEAT_MODE_GROUP})
-        @Retention(RetentionPolicy.SOURCE)
-        public @interface RepeatMode {}
-
-        /**
-         * Playback will be stopped at the end of the playing media list.
-         */
-        public static final int REPEAT_MODE_NONE = 0;
-
-        /**
-         * Playback of the current playing media item will be repeated.
-         */
-        public static final int REPEAT_MODE_ONE = 1;
-
-        /**
-         * Playing media list will be repeated.
-         */
-        public static final int REPEAT_MODE_ALL = 2;
-
-        /**
-         * Playback of the playing media group will be repeated.
-         * A group is a logical block of media items which is specified in the section 5.7 of the
-         * Bluetooth AVRCP 1.6.
-         */
-        public static final int REPEAT_MODE_GROUP = 3;
-
-        /**
-         * @hide
-         */
-        @IntDef({SHUFFLE_MODE_NONE, SHUFFLE_MODE_ALL, SHUFFLE_MODE_GROUP})
-        @Retention(RetentionPolicy.SOURCE)
-        public @interface ShuffleMode {}
-
-        /**
-         * Media list will be played in order.
-         */
-        public static final int SHUFFLE_MODE_NONE = 0;
-
-        /**
-         * Media list will be played in shuffled order.
-         */
-        public static final int SHUFFLE_MODE_ALL = 1;
-
-        /**
-         * Media group will be played in shuffled order.
-         * A group is a logical block of media items which is specified in the section 5.7 of the
-         * Bluetooth AVRCP 1.6.
-         */
-        public static final int SHUFFLE_MODE_GROUP = 2;
-
-
-        private final MediaSession2Provider.PlaylistParamsProvider mProvider;
-
-        /**
-         * Instantiate {@link PlaylistParams}
-         *
-         * @param context context
-         * @param repeatMode repeat mode
-         * @param shuffleMode shuffle mode
-         * @param playlistMetadata metadata for the list
-         */
-        public PlaylistParams(@NonNull Context context, @RepeatMode int repeatMode,
-                @ShuffleMode int shuffleMode, @Nullable MediaMetadata2 playlistMetadata) {
-            mProvider = ApiLoader.getProvider(context).createMediaSession2PlaylistParams(
-                    context, this, repeatMode, shuffleMode, playlistMetadata);
-        }
-
-        /**
-         * Create a new bundle for this object.
-         *
-         * @return
-         */
-        public @NonNull Bundle toBundle() {
-            return mProvider.toBundle_impl();
-        }
-
-        /**
-         * Create a new playlist params from the bundle that was previously returned by
-         * {@link #toBundle}.
-         *
-         * @param context context
-         * @return a new playlist params. Can be {@code null} for error.
-         */
-        public static @Nullable PlaylistParams fromBundle(
-                @NonNull Context context, @Nullable Bundle bundle) {
-            return ApiLoader.getProvider(context).fromBundle_PlaylistParams(context, bundle);
-        }
-
-        /**
-         * Get repeat mode
-         *
-         * @return repeat mode
-         * @see #REPEAT_MODE_NONE, #REPEAT_MODE_ONE, #REPEAT_MODE_ALL, #REPEAT_MODE_GROUP
-         */
-        public @RepeatMode int getRepeatMode() {
-            return mProvider.getRepeatMode_impl();
-        }
-
-        /**
-         * Get shuffle mode
-         *
-         * @return shuffle mode
-         * @see #SHUFFLE_MODE_NONE, #SHUFFLE_MODE_ALL, #SHUFFLE_MODE_GROUP
-         */
-        public @ShuffleMode int getShuffleMode() {
-            return mProvider.getShuffleMode_impl();
-        }
-
-        /**
-         * Get metadata for the playlist
-         *
-         * @return metadata. Can be {@code null}
-         */
-        public @Nullable MediaMetadata2 getPlaylistMetadata() {
-            return mProvider.getPlaylistMetadata_impl();
-        }
-    }
-
-    /**
      * Constructor is hidden and apps can only instantiate indirectly through {@link Builder}.
      * <p>
      * This intended behavior and here's the reasons.
@@ -1584,29 +1455,6 @@
     }
 
     /**
-     * Sets the {@link PlaylistParams} for the current play list. Repeat/shuffle mode and metadata
-     * for the list can be set by calling this method.
-     *
-     * @param params A {@link PlaylistParams} object to set.
-     * @throws IllegalArgumentException if given {@param param} is null.
-     * @hide
-     */
-    // TODO(jaewan): Remove (b/74116823)
-    public void setPlaylistParams(PlaylistParams params) {
-        mProvider.setPlaylistParams_impl(params);
-    }
-
-    /**
-     * Returns the {@link PlaylistParams} for the current play list.
-     * Returns {@code null} if not set.
-     * @hide
-     */
-    // TODO(jaewan): Remove (b/74116823)
-    public PlaylistParams getPlaylistParams() {
-        return mProvider.getPlaylistParams_impl();
-    }
-
-    /**
      * Notify errors to the connected controllers
      *
      * @param errorCode error code
@@ -1617,65 +1465,37 @@
     }
 
     /**
-     * Register {@link PlayerEventCallback} to listen changes in the underlying
-     * {@link MediaPlayerBase}, regardless of the change in the underlying player.
-     * <p>
-     * Registered callbacks will be also called when the underlying player is changed.
+     * Gets the current player state.
      *
-     * @param executor a callback Executor
-     * @param callback a EventCallback
-     * @throws IllegalArgumentException if executor or callback is {@code null}.
+     * @return the current player state
      * @hide
      */
-    // TODO(jaewan): Remove (b/74157064)
-    public void registerPlayerEventCallback(@NonNull @CallbackExecutor Executor executor,
-            @NonNull PlayerEventCallback callback) {
-        mProvider.registerPlayerEventCallback_impl(executor, callback);
-    }
-
-    /**
-     * Unregister the previously registered {@link PlayerEventCallback}.
-     *
-     * @param callback the callback to be removed
-     * @throws IllegalArgumentException if the callback is {@code null}.
-     * @hide
-     */
-    // TODO(jaewan): Remove (b/74157064)
-    public void unregisterPlayerEventCallback(@NonNull PlayerEventCallback callback) {
-        mProvider.unregisterPlayerEventCallback_impl(callback);
-    }
-
-    /**
-     * Get the player state.
-     *
-     * @return player state
-     * @hide
-     */
+    // TODO(jaewan): Unhide (b/74578458)
     public @PlayerState int getPlayerState() {
-        // TODO(jaewan): implement this (b/74578458)
-        return PLAYER_STATE_IDLE;
+        return mProvider.getPlayerState_impl();
     }
 
     /**
-     * Get the current position.
+     * Gets the current position.
      *
-     * @return position
+     * @return the current playback position in ms, or {@link MediaPlayerBase#UNKNOWN_TIME} if
+     *         unknown.
      * @hide
      */
-    public long getCurrentPosition() {
-        // TODO(jaewan): implement this (b/74578458)
-        return -1;
+    // TODO(jaewan): Unhide (b/74578458)
+    public long getPosition() {
+        return mProvider.getPosition_impl();
     }
 
     /**
-     * Get the buffered position.
+     * Gets the buffered position, or {@link MediaPlayerBase#UNKNOWN_TIME} if unknown.
      *
-     * @return buffered position
+     * @return the buffered position in ms, or {@link MediaPlayerBase#UNKNOWN_TIME}.
      * @hide
      */
+    // TODO(jaewan): Unhide (b/74578458)
     public long getBufferedPosition() {
-        // TODO(jaewan): implement this (b/74578458)
-        return -1;
+        return mProvider.getBufferedPosition_impl();
     }
 
     /**
@@ -1779,20 +1599,41 @@
     }
 
     /**
-     * Skip to the item in the play list.
+     * Skips to the item in the playlist.
+     * <p>
+     * This calls {@link MediaPlaylistAgent#skipToPlaylistItem(MediaItem2)} and the behavior depends
+     * on the playlist agent implementation, especially with the shuffle/repeat mode.
      *
-     * @param item item in the play list you want to play
-     * @throws IllegalArgumentException if the play list is null
-     * @throws NullPointerException if index is outside play list range
+     * @param item The item in the playlist you want to play
+     * @see #getShuffleMode()
+     * @see #getRepeatMode()
      */
     public void skipToPlaylistItem(@NonNull MediaItem2 item) {
         mProvider.skipToPlaylistItem_impl(item);
     }
 
+    /**
+     * Skips to the previous item.
+     * <p>
+     * This calls {@link MediaPlaylistAgent#skipToPreviousItem()} and the behavior depends on the
+     * playlist agent implementation, especially with the shuffle/repeat mode.
+     *
+     * @see #getShuffleMode()
+     * @see #getRepeatMode()
+     **/
     public void skipToPreviousItem() {
         mProvider.skipToPreviousItem_impl();
     }
 
+    /**
+     * Skips to the next item.
+     * <p>
+     * This calls {@link MediaPlaylistAgent#skipToNextItem()} and the behavior depends on the
+     * playlist agent implementation, especially with the shuffle/repeat mode.
+     *
+     * @see #getShuffleMode()
+     * @see #getRepeatMode()
+     */
     public void skipToNextItem() {
         mProvider.skipToNextItem_impl();
     }
@@ -1862,21 +1703,53 @@
         mProvider.updatePlaylistMetadata_impl(metadata);
     }
 
+    /**
+     * Gets the repeat mode from the {@link MediaPlaylistAgent}.
+     *
+     * @return repeat mode
+     * @see MediaPlaylistAgent#REPEAT_MODE_NONE
+     * @see MediaPlaylistAgent#REPEAT_MODE_ONE
+     * @see MediaPlaylistAgent#REPEAT_MODE_ALL
+     * @see MediaPlaylistAgent#REPEAT_MODE_GROUP
+     */
     public @RepeatMode int getRepeatMode() {
-        // TODO(jaewan): Implement (b/74118768)
-        return 0;
+        return mProvider.getRepeatMode_impl();
     }
 
+    /**
+     * Sets the repeat mode to the {@link MediaPlaylistAgent}.
+     *
+     * @param repeatMode repeat mode
+     * @see MediaPlaylistAgent#REPEAT_MODE_NONE
+     * @see MediaPlaylistAgent#REPEAT_MODE_ONE
+     * @see MediaPlaylistAgent#REPEAT_MODE_ALL
+     * @see MediaPlaylistAgent#REPEAT_MODE_GROUP
+     */
     public void setRepeatMode(@RepeatMode int repeatMode) {
-        // TODO(jaewan): Implement (b/74118768)
+        mProvider.setRepeatMode_impl(repeatMode);
     }
 
+    /**
+     * Gets the shuffle mode from the {@link MediaPlaylistAgent}.
+     *
+     * @return The shuffle mode
+     * @see MediaPlaylistAgent#SHUFFLE_MODE_NONE
+     * @see MediaPlaylistAgent#SHUFFLE_MODE_ALL
+     * @see MediaPlaylistAgent#SHUFFLE_MODE_GROUP
+     */
     public @ShuffleMode int getShuffleMode() {
-        // TODO(jaewan): Implement (b/74118768)
-        return 0;
+        return mProvider.getShuffleMode_impl();
     }
 
+    /**
+     * Sets the shuffle mode to the {@link MediaPlaylistAgent}.
+     *
+     * @param shuffleMode The shuffle mode
+     * @see MediaPlaylistAgent#SHUFFLE_MODE_NONE
+     * @see MediaPlaylistAgent#SHUFFLE_MODE_ALL
+     * @see MediaPlaylistAgent#SHUFFLE_MODE_GROUP
+     */
     public void setShuffleMode(@ShuffleMode int shuffleMode) {
-        // TODO(jaewan): Implement (b/74118768)
+        mProvider.setShuffleMode_impl(shuffleMode);
     }
 }
diff --git a/media/java/android/media/update/MediaController2Provider.java b/media/java/android/media/update/MediaController2Provider.java
index 55672b6..22e5b18 100644
--- a/media/java/android/media/update/MediaController2Provider.java
+++ b/media/java/android/media/update/MediaController2Provider.java
@@ -22,7 +22,6 @@
 import android.media.MediaItem2;
 import android.media.MediaMetadata2;
 import android.media.MediaSession2.Command;
-import android.media.MediaSession2.PlaylistParams;
 import android.media.Rating2;
 import android.media.SessionToken2;
 import android.net.Uri;
@@ -65,8 +64,6 @@
     void replacePlaylistItem_impl(int index, MediaItem2 item);
     void removePlaylistItem_impl(MediaItem2 item);
 
-    PlaylistParams getPlaylistParams_impl();
-    void setPlaylistParams_impl(PlaylistParams params);
     int getPlayerState_impl();
     long getPosition_impl();
     float getPlaybackSpeed_impl();
diff --git a/media/java/android/media/update/MediaPlaylistAgentProvider.java b/media/java/android/media/update/MediaPlaylistAgentProvider.java
index b27d5a1..e1522cf 100644
--- a/media/java/android/media/update/MediaPlaylistAgentProvider.java
+++ b/media/java/android/media/update/MediaPlaylistAgentProvider.java
@@ -16,6 +16,7 @@
 
 package android.media.update;
 
+import android.media.DataSourceDesc;
 import android.media.MediaItem2;
 import android.media.MediaMetadata2;
 import android.media.MediaPlaylistAgent.PlaylistEventCallback;
@@ -50,4 +51,5 @@
     void setRepeatMode_impl(int repeatMode);
     int getShuffleMode_impl();
     void setShuffleMode_impl(int shuffleMode);
+    MediaItem2 getMediaItem_impl(DataSourceDesc dsd);
 }
diff --git a/media/java/android/media/update/MediaSession2Provider.java b/media/java/android/media/update/MediaSession2Provider.java
index 84ea369..e5ea386 100644
--- a/media/java/android/media/update/MediaSession2Provider.java
+++ b/media/java/android/media/update/MediaSession2Provider.java
@@ -29,7 +29,6 @@
 import android.media.MediaSession2.CommandButton.Builder;
 import android.media.MediaSession2.CommandGroup;
 import android.media.MediaSession2.ControllerInfo;
-import android.media.MediaSession2.PlaylistParams;
 import android.media.MediaSession2.SessionCallback;
 import android.media.SessionToken2;
 import android.media.VolumeProvider2;
@@ -65,11 +64,10 @@
     List<MediaItem2> getPlaylist_impl();
     void setPlaylist_impl(List<MediaItem2> list, MediaMetadata2 metadata);
     MediaItem2 getCurrentPlaylistItem_impl();
-    void setPlaylistParams_impl(PlaylistParams params);
-    PlaylistParams getPlaylistParams_impl();
     void notifyError_impl(int errorCode, Bundle extras);
-    void registerPlayerEventCallback_impl(Executor executor, PlayerEventCallback callback);
-    void unregisterPlayerEventCallback_impl(PlayerEventCallback callback);
+    int getPlayerState_impl();
+    long getPosition_impl();
+    long getBufferedPosition_impl();
 
     interface CommandProvider {
         int getCommandCode_impl();
@@ -117,13 +115,6 @@
         String toString_impl();
     }
 
-    interface PlaylistParamsProvider {
-        int getRepeatMode_impl();
-        int getShuffleMode_impl();
-        MediaMetadata2 getPlaylistMetadata_impl();
-        Bundle toBundle_impl();
-    }
-
     interface BuilderBaseProvider<T extends MediaSession2, C extends SessionCallback> {
         void setPlayer_impl(MediaPlayerBase player);
         void setPlaylistAgent_impl(MediaPlaylistAgent playlistAgent);
diff --git a/media/java/android/media/update/StaticProvider.java b/media/java/android/media/update/StaticProvider.java
index f78d4a4..1c0e255 100644
--- a/media/java/android/media/update/StaticProvider.java
+++ b/media/java/android/media/update/StaticProvider.java
@@ -31,7 +31,6 @@
 import android.media.MediaMetadata2;
 import android.media.MediaPlaylistAgent;
 import android.media.MediaSession2;
-import android.media.MediaSession2.PlaylistParams;
 import android.media.MediaSession2.SessionCallback;
 import android.media.MediaSessionService2;
 import android.media.MediaSessionService2.MediaNotification;
@@ -44,7 +43,6 @@
 import android.media.update.MediaSession2Provider.CommandGroupProvider;
 import android.media.update.MediaSession2Provider.CommandProvider;
 import android.media.update.MediaSession2Provider.ControllerInfoProvider;
-import android.media.update.MediaSession2Provider.PlaylistParamsProvider;
 import android.media.update.MediaSessionService2Provider.MediaNotificationProvider;
 import android.os.Bundle;
 import android.os.IInterface;
@@ -78,10 +76,6 @@
     ControllerInfoProvider createMediaSession2ControllerInfo(Context context,
             MediaSession2.ControllerInfo instance, int uid, int pid,
             String packageName, IInterface callback);
-    PlaylistParamsProvider createMediaSession2PlaylistParams(Context context,
-            PlaylistParams playlistParams, int repeatMode, int shuffleMode,
-            MediaMetadata2 playlistMetadata);
-    PlaylistParams fromBundle_PlaylistParams(Context context, Bundle bundle);
     CommandButtonProvider.BuilderProvider createMediaSession2CommandButtonBuilder(Context context,
             MediaSession2.CommandButton.Builder instance);
     BuilderBaseProvider<MediaSession2, SessionCallback> createMediaSession2Builder(
diff --git a/media/java/android/media/update/TransportControlProvider.java b/media/java/android/media/update/TransportControlProvider.java
index eb03ca7..03944d2 100644
--- a/media/java/android/media/update/TransportControlProvider.java
+++ b/media/java/android/media/update/TransportControlProvider.java
@@ -33,4 +33,9 @@
     void rewind_impl();
     void seekTo_impl(long pos);
     void skipToPlaylistItem_impl(MediaItem2 item);
+
+    int getRepeatMode_impl();
+    void setRepeatMode_impl(int repeatMode);
+    int getShuffleMode_impl();
+    void setShuffleMode_impl(int shuffleMode);
 }
diff --git a/media/jni/Android.bp b/media/jni/Android.bp
index 44e5d61..0ba45f13 100644
--- a/media/jni/Android.bp
+++ b/media/jni/Android.bp
@@ -128,7 +128,6 @@
         "libcutils",
         "libdexfile",
         "liblzma",
-        "libmedia",
         "libmedia_helper",
         "libmedia_player2_util",
         "libmediadrm",
@@ -149,7 +148,6 @@
         "libstagefright_timedtext",
         "libunwindstack",
         "libutilscallstack",
-        "libvndksupport",
         "libz",
         "libziparchive",
     ],
diff --git a/packages/ExtServices/src/android/ext/services/autofill/AutofillFieldClassificationServiceImpl.java b/packages/ExtServices/src/android/ext/services/autofill/AutofillFieldClassificationServiceImpl.java
index 4709d35..9ba7e09 100644
--- a/packages/ExtServices/src/android/ext/services/autofill/AutofillFieldClassificationServiceImpl.java
+++ b/packages/ExtServices/src/android/ext/services/autofill/AutofillFieldClassificationServiceImpl.java
@@ -15,6 +15,8 @@
  */
 package android.ext.services.autofill;
 
+import static android.ext.services.autofill.EditDistanceScorer.DEFAULT_ALGORITHM;
+
 import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.os.Bundle;
@@ -29,8 +31,6 @@
 public class AutofillFieldClassificationServiceImpl extends AutofillFieldClassificationService {
 
     private static final String TAG = "AutofillFieldClassificationServiceImpl";
-    // TODO(b/70291841): set to false before launching
-    private static final boolean DEBUG = true;
 
     @Nullable
     @Override
@@ -40,30 +40,13 @@
         if (ArrayUtils.isEmpty(actualValues) || ArrayUtils.isEmpty(userDataValues)) {
             Log.w(TAG, "getScores(): empty currentvalues (" + actualValues + ") or userValues ("
                     + userDataValues + ")");
-            // TODO(b/70939974): add unit test
             return null;
         }
-        if (algorithmName != null && !algorithmName.equals(EditDistanceScorer.NAME)) {
+        if (algorithmName != null && !algorithmName.equals(DEFAULT_ALGORITHM)) {
             Log.w(TAG, "Ignoring invalid algorithm (" + algorithmName + ") and using "
-                    + EditDistanceScorer.NAME + " instead");
+                    + DEFAULT_ALGORITHM + " instead");
         }
 
-        final String actualAlgorithmName = EditDistanceScorer.NAME;
-        final int actualValuesSize = actualValues.size();
-        final int userDataValuesSize = userDataValues.size();
-        if (DEBUG) {
-            Log.d(TAG, "getScores() will return a " + actualValuesSize + "x"
-                    + userDataValuesSize + " matrix for " + actualAlgorithmName);
-        }
-        final float[][] scores = new float[actualValuesSize][userDataValuesSize];
-
-        final EditDistanceScorer algorithm = EditDistanceScorer.getInstance();
-        for (int i = 0; i < actualValuesSize; i++) {
-            for (int j = 0; j < userDataValuesSize; j++) {
-                final float score = algorithm.getScore(actualValues.get(i), userDataValues.get(j));
-                scores[i][j] = score;
-            }
-        }
-        return scores;
+        return EditDistanceScorer.getScores(actualValues, userDataValues);
     }
 }
diff --git a/packages/ExtServices/src/android/ext/services/autofill/EditDistanceScorer.java b/packages/ExtServices/src/android/ext/services/autofill/EditDistanceScorer.java
index d2e804a..302b160 100644
--- a/packages/ExtServices/src/android/ext/services/autofill/EditDistanceScorer.java
+++ b/packages/ExtServices/src/android/ext/services/autofill/EditDistanceScorer.java
@@ -16,53 +16,133 @@
 package android.ext.services.autofill;
 
 import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.util.Log;
 import android.view.autofill.AutofillValue;
 
-/**
- * Helper used to calculate the classification score between an actual {@link AutofillValue} filled
- * by the user and the expected value predicted by an autofill service.
- */
-// TODO(b/70291841): explain algorithm once it's fully implemented
+import com.android.internal.annotations.VisibleForTesting;
+
+import java.util.List;
+
 final class EditDistanceScorer {
 
-    private static final EditDistanceScorer sInstance = new EditDistanceScorer();
+    private static final String TAG = "EditDistanceScorer";
 
-    public static final String NAME = "EDIT_DISTANCE";
+    // TODO(b/70291841): STOPSHIP - set to false before launching
+    private static final boolean DEBUG = true;
+
+    static final String DEFAULT_ALGORITHM = "EDIT_DISTANCE";
 
     /**
-     * Gets the singleton instance.
-     */
-    public static EditDistanceScorer getInstance() {
-        return sInstance;
-    }
-
-    private EditDistanceScorer() {
-    }
-
-    /**
-     * Returns the classification score between an actual {@link AutofillValue} filled
-     * by the user and the expected value predicted by an autofill service.
+     * Gets the field classification score of 2 values based on the edit distance between them.
      *
-     * <p>A full-match is {@code 1.0} (representing 100%), a full mismatch is {@code 0.0} and
-     * partial mathces are something in between, typically using edit-distance algorithms.
-     *
+     * <p>The score is defined as: @(max_length - edit_distance) / max_length
      */
-    public float getScore(@NonNull AutofillValue actualValue, @NonNull String userDataValue) {
+    @VisibleForTesting
+    static float getScore(@Nullable AutofillValue actualValue, @Nullable String userDataValue) {
         if (actualValue == null || !actualValue.isText() || userDataValue == null) return 0;
-        // TODO(b/70291841): implement edit distance - currently it's returning either 0, 100%, or
-        // partial match when number of chars match
-        final String textValue = actualValue.getTextValue().toString();
-        final int total = textValue.length();
-        if (total != userDataValue.length()) return 0F;
 
-        int matches = 0;
-        for (int i = 0; i < total; i++) {
-            if (Character.toLowerCase(textValue.charAt(i)) == Character
-                    .toLowerCase(userDataValue.charAt(i))) {
-                matches++;
+        final String actualValueText = actualValue.getTextValue().toString();
+        final int actualValueLength = actualValueText.length();
+        final int userDatalength = userDataValue.length();
+        if (userDatalength == 0) {
+            return (actualValueLength == 0) ? 1 : 0;
+        }
+
+        final int distance = editDistance(actualValueText.toLowerCase(),
+                userDataValue.toLowerCase());
+        final int maxLength = Math.max(actualValueLength, userDatalength);
+        return ((float) maxLength - distance) / maxLength;
+    }
+
+    /**
+     * Computes the edit distance (number of insertions, deletions or substitutions to edit one
+     * string into the other) between two strings. In particular, this will compute the Levenshtein
+     * distance.
+     *
+     * <p>See http://en.wikipedia.org/wiki/Levenshtein_distance for details.
+     *
+     * @param s the first string to compare
+     * @param t the second string to compare
+     * @return the edit distance between the two strings
+     */
+    // Note: copied verbatim from com.android.tools.lint.detector.api.LintUtils.java
+    public static int editDistance(@NonNull String s, @NonNull String t) {
+        return editDistance(s, t, Integer.MAX_VALUE);
+    }
+
+    /**
+     * Computes the edit distance (number of insertions, deletions or substitutions to edit one
+     * string into the other) between two strings. In particular, this will compute the Levenshtein
+     * distance.
+     *
+     * <p>See http://en.wikipedia.org/wiki/Levenshtein_distance for details.
+     *
+     * @param s the first string to compare
+     * @param t the second string to compare
+     * @param max the maximum edit distance that we care about; if for example the string length
+     *     delta is greater than this we don't bother computing the exact edit distance since the
+     *     caller has indicated they're not interested in the result
+     * @return the edit distance between the two strings, or some other value greater than that if
+     *     the edit distance is at least as big as the {@code max} parameter
+     */
+    // Note: copied verbatim from com.android.tools.lint.detector.api.LintUtils.java
+    private static int editDistance(@NonNull String s, @NonNull String t, int max) {
+        if (s.equals(t)) {
+            return 0;
+        }
+
+        if (Math.abs(s.length() - t.length()) > max) {
+            // The string lengths differ more than the allowed edit distance;
+            // no point in even attempting to compute the edit distance (requires
+            // O(n*m) storage and O(n*m) speed, where n and m are the string lengths)
+            return Integer.MAX_VALUE;
+        }
+
+        int m = s.length();
+        int n = t.length();
+        int[][] d = new int[m + 1][n + 1];
+        for (int i = 0; i <= m; i++) {
+            d[i][0] = i;
+        }
+        for (int j = 0; j <= n; j++) {
+            d[0][j] = j;
+        }
+        for (int j = 1; j <= n; j++) {
+            for (int i = 1; i <= m; i++) {
+                if (s.charAt(i - 1) == t.charAt(j - 1)) {
+                    d[i][j] = d[i - 1][j - 1];
+                } else {
+                    int deletion = d[i - 1][j] + 1;
+                    int insertion = d[i][j - 1] + 1;
+                    int substitution = d[i - 1][j - 1] + 1;
+                    d[i][j] = Math.min(deletion, Math.min(insertion, substitution));
+                }
             }
         }
 
-        return ((float) matches) / total;
+        return d[m][n];
     }
+    /**
+     * Gets the scores in a batch.
+     */
+    static float[][] getScores(@NonNull List<AutofillValue> actualValues,
+            @NonNull List<String> userDataValues) {
+        final int actualValuesSize = actualValues.size();
+        final int userDataValuesSize = userDataValues.size();
+        if (DEBUG) {
+            Log.d(TAG, "getScores() will return a " + actualValuesSize + "x"
+                    + userDataValuesSize + " matrix for " + DEFAULT_ALGORITHM);
+        }
+        final float[][] scores = new float[actualValuesSize][userDataValuesSize];
+
+        for (int i = 0; i < actualValuesSize; i++) {
+            for (int j = 0; j < userDataValuesSize; j++) {
+                final float score = getScore(actualValues.get(i), userDataValues.get(j));
+                scores[i][j] = score;
+            }
+        }
+        return scores;
+    }
+
 }
diff --git a/packages/ExtServices/tests/src/android/ext/services/autofill/AutofillFieldClassificationServiceImplTest.java b/packages/ExtServices/tests/src/android/ext/services/autofill/AutofillFieldClassificationServiceImplTest.java
new file mode 100644
index 0000000..48c076e
--- /dev/null
+++ b/packages/ExtServices/tests/src/android/ext/services/autofill/AutofillFieldClassificationServiceImplTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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 android.ext.services.autofill;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.view.autofill.AutofillValue;
+
+/**
+ * Contains the base tests that does not rely on the specific algorithm implementation.
+ */
+public class AutofillFieldClassificationServiceImplTest {
+
+    private final AutofillFieldClassificationServiceImpl mService =
+            new AutofillFieldClassificationServiceImpl();
+
+    @Test
+    public void testOnGetScores_nullActualValues() {
+        assertThat(mService.onGetScores(null, null, null, Arrays.asList("whatever"))).isNull();
+    }
+
+    @Test
+    public void testOnGetScores_emptyActualValues() {
+        assertThat(mService.onGetScores(null, null, Collections.emptyList(),
+                Arrays.asList("whatever"))).isNull();
+    }
+
+    @Test
+    public void testOnGetScores_nullUserDataValues() {
+        assertThat(mService.onGetScores(null, null,
+                Arrays.asList(AutofillValue.forText("whatever")), null)).isNull();
+    }
+
+    @Test
+    public void testOnGetScores_emptyUserDataValues() {
+        assertThat(mService.onGetScores(null, null,
+                Arrays.asList(AutofillValue.forText("whatever")), Collections.emptyList()))
+                        .isNull();
+    }
+}
diff --git a/packages/ExtServices/tests/src/android/ext/services/autofill/EditDistanceScorerTest.java b/packages/ExtServices/tests/src/android/ext/services/autofill/EditDistanceScorerTest.java
index cc15719..afe2236 100644
--- a/packages/ExtServices/tests/src/android/ext/services/autofill/EditDistanceScorerTest.java
+++ b/packages/ExtServices/tests/src/android/ext/services/autofill/EditDistanceScorerTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * 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.
@@ -13,65 +13,109 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package android.ext.services.autofill;
 
-import static com.google.common.truth.Truth.assertThat;
+import static android.ext.services.autofill.EditDistanceScorer.getScore;
+import static android.ext.services.autofill.EditDistanceScorer.getScores;
+import static android.view.autofill.AutofillValue.forText;
 
-import android.support.test.runner.AndroidJUnit4;
+import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assertWithMessage;
+
 import android.view.autofill.AutofillValue;
 
 import org.junit.Test;
-import org.junit.runner.RunWith;
 
-@RunWith(AndroidJUnit4.class)
+import java.util.Arrays;
+import java.util.List;
+
 public class EditDistanceScorerTest {
 
-    private final EditDistanceScorer mScorer = EditDistanceScorer.getInstance();
-
     @Test
     public void testGetScore_nullValue() {
-        assertFloat(mScorer.getScore(null, "D'OH!"), 0);
+        assertFloat(getScore(null, "D'OH!"), 0);
     }
 
     @Test
     public void testGetScore_nonTextValue() {
-        assertFloat(mScorer.getScore(AutofillValue.forToggle(true), "D'OH!"), 0);
+        assertFloat(getScore(AutofillValue.forToggle(true), "D'OH!"), 0);
     }
 
     @Test
     public void testGetScore_nullUserData() {
-        assertFloat(mScorer.getScore(AutofillValue.forText("D'OH!"), null), 0);
+        assertFloat(getScore(AutofillValue.forText("D'OH!"), null), 0);
     }
 
     @Test
     public void testGetScore_fullMatch() {
-        assertFloat(mScorer.getScore(AutofillValue.forText("D'OH!"), "D'OH!"), 1);
+        assertFloat(getScore(AutofillValue.forText("D'OH!"), "D'OH!"), 1);
+        assertFloat(getScore(AutofillValue.forText(""), ""), 1);
     }
 
     @Test
     public void testGetScore_fullMatchMixedCase() {
-        assertFloat(mScorer.getScore(AutofillValue.forText("D'OH!"), "D'oH!"), 1);
+        assertFloat(getScore(AutofillValue.forText("D'OH!"), "D'oH!"), 1);
     }
 
-    // TODO(b/70291841): might need to change it once it supports different sizes
     @Test
     public void testGetScore_mismatchDifferentSizes() {
-        assertFloat(mScorer.getScore(AutofillValue.forText("One"), "MoreThanOne"), 0);
-        assertFloat(mScorer.getScore(AutofillValue.forText("MoreThanOne"), "One"), 0);
+        assertFloat(getScore(AutofillValue.forText("X"), "Xy"), 0.50F);
+        assertFloat(getScore(AutofillValue.forText("Xy"), "X"), 0.50F);
+        assertFloat(getScore(AutofillValue.forText("One"), "MoreThanOne"), 0.27F);
+        assertFloat(getScore(AutofillValue.forText("MoreThanOne"), "One"), 0.27F);
+        assertFloat(getScore(AutofillValue.forText("1600 Amphitheatre Parkway"),
+                "1600 Amphitheatre Pkwy"), 0.88F);
+        assertFloat(getScore(AutofillValue.forText("1600 Amphitheatre Pkwy"),
+                "1600 Amphitheatre Parkway"), 0.88F);
     }
 
     @Test
     public void testGetScore_partialMatch() {
-        assertFloat(mScorer.getScore(AutofillValue.forText("Dude"), "Dxxx"), 0.25F);
-        assertFloat(mScorer.getScore(AutofillValue.forText("Dude"), "DUxx"), 0.50F);
-        assertFloat(mScorer.getScore(AutofillValue.forText("Dude"), "DUDx"), 0.75F);
-        assertFloat(mScorer.getScore(AutofillValue.forText("Dxxx"), "Dude"), 0.25F);
-        assertFloat(mScorer.getScore(AutofillValue.forText("DUxx"), "Dude"), 0.50F);
-        assertFloat(mScorer.getScore(AutofillValue.forText("DUDx"), "Dude"), 0.75F);
+        assertFloat(getScore(AutofillValue.forText("Dude"), "Dxxx"), 0.25F);
+        assertFloat(getScore(AutofillValue.forText("Dude"), "DUxx"), 0.50F);
+        assertFloat(getScore(AutofillValue.forText("Dude"), "DUDx"), 0.75F);
+        assertFloat(getScore(AutofillValue.forText("Dxxx"), "Dude"), 0.25F);
+        assertFloat(getScore(AutofillValue.forText("DUxx"), "Dude"), 0.50F);
+        assertFloat(getScore(AutofillValue.forText("DUDx"), "Dude"), 0.75F);
+    }
+
+    @Test
+    public void testGetScores() {
+        final List<AutofillValue> actualValues = Arrays.asList(forText("A"), forText("b"));
+        final List<String> userDataValues = Arrays.asList("a", "B", "ab", "c");
+        final float[][] expectedScores = new float[][] {
+            new float[] { 1F, 0F, 0.5F, 0F },
+            new float[] { 0F, 1F, 0.5F, 0F }
+        };
+        final float[][] actualScores = getScores(actualValues, userDataValues);
+
+        // Unfortunately, Truth does not have an easy way to compare float matrices and show useful
+        // messages in case of error, so we need to check.
+        assertWithMessage("actual=%s, expected=%s", toString(actualScores),
+                toString(expectedScores)).that(actualScores.length).isEqualTo(2);
+        assertWithMessage("actual=%s, expected=%s", toString(actualScores),
+                toString(expectedScores)).that(actualScores[0].length).isEqualTo(4);
+        assertWithMessage("actual=%s, expected=%s", toString(actualScores),
+                toString(expectedScores)).that(actualScores[1].length).isEqualTo(4);
+        for (int i = 0; i < actualScores.length; i++) {
+            final float[] line = actualScores[i];
+            for (int j = 0; j < line.length; j++) {
+                float cell = line[j];
+                assertWithMessage("wrong score at [%s, %s]", i, j).that(cell).isWithin(0.01F)
+                        .of(expectedScores[i][j]);
+            }
+        }
     }
 
     public static void assertFloat(float actualValue, float expectedValue) {
-        assertThat(actualValue).isWithin(1.0e-10f).of(expectedValue);
+        assertThat(actualValue).isWithin(0.01F).of(expectedValue);
+    }
+
+    public static String toString(float[][] matrix) {
+        final StringBuilder string = new StringBuilder("[ ");
+        for (int i = 0; i < matrix.length; i++) {
+            string.append(Arrays.toString(matrix[i])).append(" ");
+        }
+        return string.append(" ]").toString();
     }
 }
diff --git a/packages/SettingsLib/common.mk b/packages/SettingsLib/common.mk
index 15b50d7..28f97d1 100644
--- a/packages/SettingsLib/common.mk
+++ b/packages/SettingsLib/common.mk
@@ -16,11 +16,11 @@
 ifeq ($(LOCAL_USE_AAPT2),true)
 LOCAL_STATIC_JAVA_LIBRARIES += \
     android-support-annotations \
-    apptoolkit-lifecycle-common
+    android-arch-lifecycle-common
 
 LOCAL_STATIC_ANDROID_LIBRARIES += \
     android-support-v4 \
-    apptoolkit-lifecycle-runtime \
+    android-arch-lifecycle-runtime \
     android-support-v7-recyclerview \
     android-support-v7-preference \
     android-support-v7-appcompat \
diff --git a/packages/SettingsLib/res/layout/preference_access_point.xml b/packages/SettingsLib/res/layout/preference_access_point.xml
new file mode 100644
index 0000000..62173da
--- /dev/null
+++ b/packages/SettingsLib/res/layout/preference_access_point.xml
@@ -0,0 +1,96 @@
+<?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.
+  -->
+
+<!-- Based off preference_two_target.xml with Material ripple moved to parent for full ripple. -->
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:minHeight="?android:attr/listPreferredItemHeightSmall"
+    android:gravity="center_vertical"
+    android:background="?android:attr/selectableItemBackground"
+    android:clipToPadding="false">
+
+    <LinearLayout
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:layout_weight="1"
+        android:gravity="start|center_vertical"
+        android:clipToPadding="false"
+        android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+        android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
+
+        <LinearLayout
+            android:id="@+id/icon_frame"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:gravity="start|center_vertical"
+            android:minWidth="56dp"
+            android:orientation="horizontal"
+            android:clipToPadding="false"
+            android:paddingTop="4dp"
+            android:paddingBottom="4dp">
+            <android.support.v7.internal.widget.PreferenceImageView
+                android:id="@android:id/icon"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                settings:maxWidth="48dp"
+                settings:maxHeight="48dp" />
+        </LinearLayout>
+
+        <RelativeLayout
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:paddingTop="16dp"
+            android:paddingBottom="16dp">
+
+            <TextView
+                android:id="@android:id/title"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:singleLine="true"
+                android:textAppearance="?android:attr/textAppearanceListItem"
+                android:ellipsize="marquee" />
+
+            <TextView
+                android:id="@android:id/summary"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@android:id/title"
+                android:layout_alignStart="@android:id/title"
+                android:textAppearance="?android:attr/textAppearanceListItemSecondary"
+                android:textColor="?android:attr/textColorSecondary"
+                android:maxLines="10" />
+
+        </RelativeLayout>
+
+    </LinearLayout>
+
+    <include layout="@layout/preference_two_target_divider" />
+
+    <!-- Preference should place its actual preference widget here. -->
+    <LinearLayout
+        android:id="@android:id/widget_frame"
+        android:layout_width="wrap_content"
+        android:layout_height="match_parent"
+        android:minWidth="64dp"
+        android:gravity="center"
+        android:orientation="vertical" />
+
+</LinearLayout>
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPointPreference.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPointPreference.java
index 8115ede2..26f3683 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPointPreference.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPointPreference.java
@@ -68,6 +68,7 @@
     private final UserBadgeCache mBadgeCache;
     private final IconInjector mIconInjector;
     private TextView mTitleView;
+    private boolean mShowDivider;
 
     private boolean mForSavedNetworks = false;
     private AccessPoint mAccessPoint;
@@ -115,7 +116,8 @@
                           int iconResId, boolean forSavedNetworks, StateListDrawable frictionSld,
                           int level, IconInjector iconInjector) {
         super(context);
-        setWidgetLayoutResource(R.layout.access_point_friction_widget);
+        setLayoutResource(R.layout.preference_access_point);
+        setWidgetLayoutResource(getWidgetLayoutResourceId());
         mBadgeCache = cache;
         mAccessPoint = accessPoint;
         mForSavedNetworks = forSavedNetworks;
@@ -128,6 +130,10 @@
                 .getDimensionPixelSize(R.dimen.wifi_preference_badge_padding);
     }
 
+    protected int getWidgetLayoutResourceId() {
+        return R.layout.access_point_friction_widget;
+    }
+
     public AccessPoint getAccessPoint() {
         return mAccessPoint;
     }
@@ -154,6 +160,18 @@
 
         ImageView frictionImageView = (ImageView) view.findViewById(R.id.friction_icon);
         bindFrictionImage(frictionImageView);
+
+        final View divider = view.findViewById(R.id.two_target_divider);
+        divider.setVisibility(shouldShowDivider() ? View.VISIBLE : View.INVISIBLE);
+    }
+
+    public boolean shouldShowDivider() {
+        return mShowDivider;
+    }
+
+    public void setShowDivider(boolean showDivider) {
+        mShowDivider = showDivider;
+        notifyChanged();
     }
 
     protected void updateIcon(int level, Context context) {
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index 1cd02f4..ecda53a 100644
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -207,4 +207,7 @@
         Else (if negative), turning on dnd manually will surface a dialog that prompts
             user to specify a duration.-->
     <integer name="def_zen_duration">0</integer>
+
+    <!-- Default for Settings.Global.BACKUP_AGENT_TIMEOUT_PARAMETERS -->
+    <string name="def_backup_agent_timeout_parameters"></string>
 </resources>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
index 53cff4e..9a43839 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
@@ -1253,6 +1253,9 @@
         dumpSetting(s, p,
                 Settings.Global.SHOW_ZEN_UPGRADE_NOTIFICATION,
                 GlobalSettingsProto.SHOW_ZEN_UPGRADE_NOTIFICATION);
+        dumpSetting(s, p,
+                Settings.Global.BACKUP_AGENT_TIMEOUT_PARAMETERS,
+                GlobalSettingsProto.BACKUP_AGENT_TIMEOUT_PARAMETERS);
         // Please insert new settings using the same order as in Settings.Global.
 
         p.end(token);
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index 6398858..da62d94 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -2938,7 +2938,7 @@
         }
 
         private final class UpgradeController {
-            private static final int SETTINGS_VERSION = 157;
+            private static final int SETTINGS_VERSION = 158;
 
             private final int mUserId;
 
@@ -3584,7 +3584,7 @@
                 }
 
                 if (currentVersion == 155) {
-                    // Version 155: Set the default value for CHARGING_STARTED_SOUND.
+                    // Version 156: Set the default value for CHARGING_STARTED_SOUND.
                     final SettingsState globalSettings = getGlobalSettingsLocked();
                     final String oldValue = globalSettings.getSettingLocked(
                             Global.CHARGING_STARTED_SOUND).getValue();
@@ -3605,7 +3605,7 @@
                 }
 
                 if (currentVersion == 156) {
-                    // Version 156: Set a default value for zen duration
+                    // Version 157: Set a default value for zen duration
                     final SettingsState globalSettings = getGlobalSettingsLocked();
                     final Setting currentSetting = globalSettings.getSettingLocked(
                             Global.ZEN_DURATION);
@@ -3616,9 +3616,26 @@
                                 Global.ZEN_DURATION, defaultZenDuration,
                                 null, true, SettingsState.SYSTEM_PACKAGE_NAME);
                     }
-
                     currentVersion = 157;
                 }
+
+                if (currentVersion == 157) {
+                    // Version 158: Set default value for BACKUP_AGENT_TIMEOUT_PARAMETERS.
+                    final SettingsState globalSettings = getGlobalSettingsLocked();
+                    final String oldValue = globalSettings.getSettingLocked(
+                            Settings.Global.BACKUP_AGENT_TIMEOUT_PARAMETERS).getValue();
+                    if (TextUtils.equals(null, oldValue)) {
+                        final String defaultValue = getContext().getResources().getString(
+                                R.string.def_backup_agent_timeout_parameters);
+                        if (!TextUtils.isEmpty(defaultValue)) {
+                            globalSettings.insertSettingLocked(
+                                    Settings.Global.BACKUP_AGENT_TIMEOUT_PARAMETERS, defaultValue,
+                                    null, true,
+                                    SettingsState.SYSTEM_PACKAGE_NAME);
+                        }
+                    }
+                    currentVersion = 158;
+                }
                 // vXXX: Add new settings above this point.
 
                 if (currentVersion != newVersion) {
diff --git a/packages/SystemUI/res/drawable/ic_sysbar_rotate_button.xml b/packages/SystemUI/res/drawable/ic_sysbar_rotate_button.xml
index 93df340..461d62e 100644
--- a/packages/SystemUI/res/drawable/ic_sysbar_rotate_button.xml
+++ b/packages/SystemUI/res/drawable/ic_sysbar_rotate_button.xml
@@ -24,7 +24,7 @@
             <group android:name="icon" android:pivotX="12" android:pivotY="12">
                 <!-- Tint color to be set directly -->
                 <path android:fillColor="#FFFFFFFF"
-                      android:pathData="M17,1.01L7,1c-1.1,0 -2,0.9 -2,2v18c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2V3c0,-1.1 -0.9,-1.99 -2,-1.99zM17,19H7V5h10v14z"/>
+                    android:pathData="M17,1.01L7,1C5.9,1 5,1.9 5,3v18c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2V3C19,1.9 18.1,1.01 17,1.01zM17,21H7l0,-1h10V21zM17,18H7V6h10V18zM7,4V3h10v1H7z"/>
             </group>
         </vector>
     </aapt:attr>
diff --git a/packages/SystemUI/res/layout/wireless_charging_layout.xml b/packages/SystemUI/res/layout/wireless_charging_layout.xml
index 113282b..85a325a 100644
--- a/packages/SystemUI/res/layout/wireless_charging_layout.xml
+++ b/packages/SystemUI/res/layout/wireless_charging_layout.xml
@@ -44,13 +44,6 @@
             android:layout_gravity="center"
             android:textSize="32sp"
             android:textColor="?attr/wallpaperTextColor"/>
-
-        <TextView
-            android:id="@+id/wireless_charging_secondary_text"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center"
-            android:textColor="?attr/wallpaperTextColor"/>
     </LinearLayout>
 
 </FrameLayout>
\ No newline at end of file
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 2c73f1e..1db9050 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -88,13 +88,13 @@
     support charging on it.  That is, a charger that fits into the USB port and goes into
     a wall socket, not into a computer. (This happens because some devices require more
     current than the USB spec allows.  [CHAR LIMIT=NONE] -->
-    <string name="invalid_charger">USB charging not supported.\nUse only the supplied charger.</string>
+    <string name="invalid_charger">Can\'t charge via USB. Use the charger that came with your device.</string>
 
     <!-- First line of invalid_charger, used in the notification form.  [CHAR LIMIT=NONE]-->
-    <string name="invalid_charger_title">USB charging not supported.</string>
+    <string name="invalid_charger_title">Can\'t charge via USB</string>
 
     <!-- Second line of invalid_charger, used in the notification form.  [CHAR LIMIT=NONE]-->
-    <string name="invalid_charger_text">Use only the supplied charger.</string>
+    <string name="invalid_charger_text">Use the charger that came with your device</string>
 
     <!-- When the battery is low, this is the label of the button to go to the
          power usage activity to find out what drained the battery.  [CHAR LIMIT=30] -->
@@ -519,8 +519,8 @@
     <string name="accessibility_quick_settings_airplane_changed_off">Airplane mode turned off.</string>
     <!-- Announcement made when the airplane mode changes to on (not shown on the screen). [CHAR LIMIT=NONE] -->
     <string name="accessibility_quick_settings_airplane_changed_on">Airplane mode turned on.</string>
-    <!-- Content description of the do not disturb tile in quick settings when on in priority (not shown on the screen). [CHAR LIMIT=NONE] -->
-    <string name="accessibility_quick_settings_dnd_priority_on">Do not disturb on, priority only.</string>
+    <!-- Content description of the do not disturb tile in quick settings when on in the default priority mode (not shown on the screen). [CHAR LIMIT=NONE] -->
+    <string name="accessibility_quick_settings_dnd_priority_on">Do not disturb on.</string>
     <!-- Content description of the do not disturb tile in quick settings when on in none (not shown on the screen). [CHAR LIMIT=NONE] -->
     <string name="accessibility_quick_settings_dnd_none_on">Do not disturb on, total silence.</string>
     <!-- Content description of the do not disturb tile in quick settings when on in alarms only (not shown on the screen). [CHAR LIMIT=NONE] -->
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardEsimArea.java b/packages/SystemUI/src/com/android/keyguard/KeyguardEsimArea.java
index b8a07cd..63b7ae2 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardEsimArea.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardEsimArea.java
@@ -60,7 +60,7 @@
                                         .setMessage(R.string.error_disable_esim_msg)
                                         .setTitle(R.string.error_disable_esim_title)
                                         .setCancelable(false /* cancelable */)
-                                        .setNeutralButton(R.string.ok, null /* listener */);
+                                        .setPositiveButton(R.string.ok, null /* listener */);
                         AlertDialog alertDialog = builder.create();
                         alertDialog.getWindow().setType(
                                 WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
index e790061..9a20c81 100644
--- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
+++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
@@ -388,6 +388,7 @@
                 mBounds.set(mInfo.displayCutout.getBounds());
                 localBounds(mBoundingRect);
                 mInfo.displayCutout.getBounds().getBoundaryPath(mBoundingPath);
+                invalidate();
                 newVisible = VISIBLE;
             } else {
                 newVisible = GONE;
diff --git a/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingLayout.java b/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingLayout.java
index 8f87d64..9887533 100644
--- a/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingLayout.java
@@ -65,9 +65,6 @@
         // amount of battery:
         final TextView mPercentage = findViewById(R.id.wireless_charging_percentage);
 
-        // (optional) time until full charge if available
-        final TextView mSecondaryText = findViewById(R.id.wireless_charging_secondary_text);
-
         if (batteryLevel != UNKNOWN_BATTERY_LEVEL) {
             mPercentage.setText(NumberFormat.getPercentInstance().format(mBatteryLevel / 100f));
             mPercentage.setAlpha(0);
@@ -110,17 +107,10 @@
         circleFadeAnimator.setInterpolator(Interpolators.LINEAR);
         circleFadeAnimator.setStartDelay(chargingAnimationFadeStartOffset);
 
-        // Animation Opacity: secondary text animation fades from 1 to 0 opacity
-        ValueAnimator secondaryTextFadeAnimator = ObjectAnimator.ofFloat(mSecondaryText, "alpha",
-                1, 0);
-        circleFadeAnimator.setDuration(chargingAnimationFadeDuration);
-        secondaryTextFadeAnimator.setInterpolator(Interpolators.LINEAR);
-        secondaryTextFadeAnimator.setStartDelay(chargingAnimationFadeStartOffset);
-
         // play all animations together
         AnimatorSet animatorSet = new AnimatorSet();
         animatorSet.playTogether(textSizeAnimator, textOpacityAnimator, textFadeAnimator,
-                circleFadeAnimator, secondaryTextFadeAnimator);
+                circleFadeAnimator);
         animatorSet.start();
     }
 }
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java
index f3a2ae3..8427e32 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java
@@ -215,15 +215,18 @@
         switch (zen) {
             case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
                 state.contentDescription = mContext.getString(
-                        R.string.accessibility_quick_settings_dnd_priority_on);
+                        R.string.accessibility_quick_settings_dnd_priority_on) + ", "
+                        + state.secondaryLabel;
                 break;
             case Global.ZEN_MODE_NO_INTERRUPTIONS:
                 state.contentDescription = mContext.getString(
-                        R.string.accessibility_quick_settings_dnd_none_on);
+                        R.string.accessibility_quick_settings_dnd_none_on) + ", "
+                        + state.secondaryLabel;
                 break;
             case ZEN_MODE_ALARMS:
                 state.contentDescription = mContext.getString(
-                        R.string.accessibility_quick_settings_dnd_alarms_on);
+                        R.string.accessibility_quick_settings_dnd_alarms_on) + ", "
+                        + state.secondaryLabel;
                 break;
             default:
                 state.contentDescription = mContext.getString(
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/VibratorHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/VibratorHelper.java
index 5c21fd1..6560f8f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/VibratorHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/VibratorHelper.java
@@ -18,6 +18,7 @@
 
 import android.content.Context;
 import android.database.ContentObserver;
+import android.media.AudioAttributes;
 import android.os.AsyncTask;
 import android.os.Handler;
 import android.os.UserHandle;
@@ -30,6 +31,11 @@
     private final Vibrator mVibrator;
     private final Context mContext;
     private boolean mHapticFeedbackEnabled;
+    private static final AudioAttributes STATUS_BAR_VIBRATION_ATTRIBUTES =
+            new AudioAttributes.Builder()
+                    .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
+                    .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
+                    .build();
 
     final private ContentObserver mVibrationObserver = new ContentObserver(Handler.getMain()) {
         @Override
@@ -51,7 +57,8 @@
     public void vibrate(final int effectId) {
         if (mHapticFeedbackEnabled) {
             AsyncTask.execute(() ->
-                    mVibrator.vibrate(VibrationEffect.get(effectId, false /* fallback */)));
+                    mVibrator.vibrate(VibrationEffect.get(effectId, false /* fallback */),
+                            STATUS_BAR_VIBRATION_ATTRIBUTES));
         }
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
index ce8e746..91483bc 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
@@ -112,6 +112,7 @@
 
     public static final String TAG = "NavigationBar";
     private static final boolean DEBUG = false;
+    private static final boolean DEBUG_ROTATION = true;
     private static final String EXTRA_DISABLE_STATE = "disabled_state";
 
     private final static int BUTTON_FADE_IN_OUT_DURATION_MS = 100;
@@ -343,10 +344,19 @@
             boolean showImeSwitcher) {
         boolean imeShown = (vis & InputMethodService.IME_VISIBLE) != 0;
         int hints = mNavigationIconHints;
-        if (imeShown && backDisposition != InputMethodService.BACK_DISPOSITION_WILL_NOT_DISMISS) {
-            hints |= NAVIGATION_HINT_BACK_ALT;
-        } else {
-            hints &= ~NAVIGATION_HINT_BACK_ALT;
+        switch (backDisposition) {
+            case InputMethodService.BACK_DISPOSITION_DEFAULT:
+            case InputMethodService.BACK_DISPOSITION_WILL_NOT_DISMISS:
+            case InputMethodService.BACK_DISPOSITION_WILL_DISMISS:
+                if (imeShown) {
+                    hints |= NAVIGATION_HINT_BACK_ALT;
+                } else {
+                    hints &= ~NAVIGATION_HINT_BACK_ALT;
+                }
+                break;
+            case InputMethodService.BACK_DISPOSITION_ADJUST_NOTHING:
+                hints &= ~NAVIGATION_HINT_BACK_ALT;
+                break;
         }
         if (showImeSwitcher) {
             hints |= NAVIGATION_HINT_IME_SHOWN;
@@ -387,6 +397,16 @@
 
     @Override
     public void onRotationProposal(final int rotation, boolean isValid) {
+        final int winRotation = mWindowManager.getDefaultDisplay().getRotation();
+        if (DEBUG_ROTATION) {
+            Log.v(TAG, "onRotationProposal proposedRotation=" + Surface.rotationToString(rotation)
+                    + ", winRotation=" + Surface.rotationToString(winRotation)
+                    + ", isValid=" + isValid + ", mNavBarWindowState="
+                    + StatusBarManager.windowStateToString(mNavigationBarWindowState)
+                    + ", isRotateButtonVisible=" + (mNavigationBarView == null ? "null" :
+                        mNavigationBarView.isRotateButtonVisible()));
+        }
+
         // This method will be called on rotation suggestion changes even if the proposed rotation
         // is not valid for the top app. Use invalid rotation choices as a signal to remove the
         // rotate button if shown.
@@ -396,7 +416,6 @@
         }
 
         // If window rotation matches suggested rotation, remove any current suggestions
-        final int winRotation = mWindowManager.getDefaultDisplay().getRotation();
         if (rotation == winRotation) {
             getView().removeCallbacks(mRemoveRotationProposal);
             setRotateSuggestionButtonState(false);
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogControllerImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogControllerImpl.java
index 89e7dd1..ee6748e 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogControllerImpl.java
@@ -26,8 +26,7 @@
 import android.content.pm.PackageManager;
 import android.content.pm.PackageManager.NameNotFoundException;
 import android.database.ContentObserver;
-import android.media.AudioDeviceCallback;
-import android.media.AudioDeviceInfo;
+import android.media.AudioAttributes;
 import android.media.AudioManager;
 import android.media.AudioSystem;
 import android.media.IVolumeController;
@@ -40,6 +39,7 @@
 import android.os.Looper;
 import android.os.Message;
 import android.os.RemoteException;
+import android.os.VibrationEffect;
 import android.os.Vibrator;
 import android.provider.Settings;
 import android.service.notification.Condition;
@@ -59,9 +59,7 @@
 
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 
@@ -77,6 +75,11 @@
 
     private static final int DYNAMIC_STREAM_START_INDEX = 100;
     private static final int VIBRATE_HINT_DURATION = 50;
+    private static final AudioAttributes SONFICIATION_VIBRATION_ATTRIBUTES =
+            new AudioAttributes.Builder()
+                    .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
+                    .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
+                    .build();
 
     static final ArrayMap<Integer, Integer> STREAMS = new ArrayMap<>();
     static {
@@ -299,7 +302,8 @@
 
     public void vibrate() {
         if (mHasVibrator) {
-            mVibrator.vibrate(VIBRATE_HINT_DURATION);
+            mVibrator.vibrate(VibrationEffect.createOneShot(VIBRATE_HINT_DURATION,
+                    VibrationEffect.DEFAULT_AMPLITUDE), SONFICIATION_VIBRATION_ATTRIBUTES);
         }
     }
 
@@ -308,7 +312,7 @@
     }
 
     private void onNotifyVisibleW(boolean visible) {
-        if (mDestroyed) return;
+        if (mDestroyed) return; 
         mAudio.notifyVolumeControllerVisible(mVolumeController, visible);
         if (!visible) {
             if (updateActiveStreamW(-1)) {
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
index 91314fe..e94d6bd 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
@@ -897,6 +897,9 @@
     }
 
     private String getStreamLabelH(StreamState ss) {
+        if (ss == null) {
+            return "";
+        }
         if (ss.remoteLabel != null) {
             return ss.remoteLabel;
         }
diff --git a/proto/src/wifi.proto b/proto/src/wifi.proto
index 74efec9..0763fa1 100644
--- a/proto/src/wifi.proto
+++ b/proto/src/wifi.proto
@@ -926,6 +926,34 @@
   // total time within the logging window that aware was enabled
   optional int64 enabled_time_ms = 40;
 
+  // maximum number of concurrent publish sessions enabling ranging in a single app
+  optional int32 max_concurrent_publish_with_ranging_in_app = 41;
+
+  // maximum number of concurrent subscribe sessions specifying a geofence in a single app
+  optional int32 max_concurrent_subscribe_with_ranging_in_app = 42;
+
+  // maximum number of concurrent publish sessions enabling ranging in the system
+  optional int32 max_concurrent_publish_with_ranging_in_system = 43;
+
+  // maximum number of concurrent subscribe sessions specifying a geofence in the system
+  optional int32 max_concurrent_subscribe_with_ranging_in_system = 44;
+
+  // histogram of subscribe session geofence minimum (only when specified)
+  repeated HistogramBucket histogram_subscribe_geofence_min = 45;
+
+  // histogram of subscribe session geofence maximum (only when specified)
+  repeated HistogramBucket histogram_subscribe_geofence_max = 46;
+
+  // total number of subscribe sessions which enabled ranging
+  optional int32 num_subscribes_with_ranging = 47;
+
+  // total number of matches (service discovery indication) with ranging provided
+  optional int32 num_matches_with_ranging = 48;
+
+  // total number of matches (service discovery indication) for service discovery with ranging
+  // enabled which did not trigger ranging
+  optional int32 num_matches_without_ranging_for_ranging_enabled_subscribes = 49;
+
   // Histogram bucket for Wi-Fi Aware logs. Range is [start, end)
   message HistogramBucket {
     // lower range of the bucket (inclusive)
diff --git a/services/backup/java/com/android/server/backup/BackupAgentTimeoutParameters.java b/services/backup/java/com/android/server/backup/BackupAgentTimeoutParameters.java
new file mode 100644
index 0000000..4de2c9b
--- /dev/null
+++ b/services/backup/java/com/android/server/backup/BackupAgentTimeoutParameters.java
@@ -0,0 +1,150 @@
+/*
+ * 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.server.backup;
+
+import android.content.ContentResolver;
+import android.os.Handler;
+import android.provider.Settings;
+import android.util.KeyValueListParser;
+import android.util.KeyValueSettingObserver;
+import com.android.internal.annotations.GuardedBy;
+import com.android.internal.annotations.VisibleForTesting;
+
+/**
+ * Configure backup and restore agent timeouts.
+ *
+ * <p>These timeout parameters are stored in Settings.Global to be configurable flags with P/H. They
+ * are represented as a comma-delimited key value list.
+ */
+public class BackupAgentTimeoutParameters extends KeyValueSettingObserver {
+    @VisibleForTesting
+    public static final String SETTING = Settings.Global.BACKUP_AGENT_TIMEOUT_PARAMETERS;
+
+    @VisibleForTesting
+    public static final String SETTING_KV_BACKUP_AGENT_TIMEOUT_MILLIS =
+            "kv_backup_agent_timeout_millis";
+
+    @VisibleForTesting
+    public static final String SETTING_FULL_BACKUP_AGENT_TIMEOUT_MILLIS =
+            "full_backup_agent_timeout_millis";
+
+    @VisibleForTesting
+    public static final String SETTING_SHARED_BACKUP_AGENT_TIMEOUT_MILLIS =
+            "shared_backup_agent_timeout_millis";
+
+    @VisibleForTesting
+    public static final String SETTING_RESTORE_AGENT_TIMEOUT_MILLIS =
+            "restore_agent_timeout_millis";
+
+    @VisibleForTesting
+    public static final String SETTING_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS =
+            "restore_agent_finished_timeout_millis";
+
+    // Default values
+    @VisibleForTesting public static final long DEFAULT_KV_BACKUP_AGENT_TIMEOUT_MILLIS = 30 * 1000;
+
+    @VisibleForTesting
+    public static final long DEFAULT_FULL_BACKUP_AGENT_TIMEOUT_MILLIS = 5 * 60 * 1000;
+
+    @VisibleForTesting
+    public static final long DEFAULT_SHARED_BACKUP_AGENT_TIMEOUT_MILLIS = 30 * 60 * 1000;
+
+    @VisibleForTesting public static final long DEFAULT_RESTORE_AGENT_TIMEOUT_MILLIS = 60 * 1000;
+
+    @VisibleForTesting
+    public static final long DEFAULT_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS = 30 * 1000;
+
+    @GuardedBy("mLock")
+    private long mKvBackupAgentTimeoutMillis;
+
+    @GuardedBy("mLock")
+    private long mFullBackupAgentTimeoutMillis;
+
+    @GuardedBy("mLock")
+    private long mSharedBackupAgentTimeoutMillis;
+
+    @GuardedBy("mLock")
+    private long mRestoreAgentTimeoutMillis;
+
+    @GuardedBy("mLock")
+    private long mRestoreAgentFinishedTimeoutMillis;
+
+    private final Object mLock = new Object();
+
+    public BackupAgentTimeoutParameters(Handler handler, ContentResolver resolver) {
+        super(handler, resolver, Settings.Global.getUriFor(SETTING));
+    }
+
+    public String getSettingValue(ContentResolver resolver) {
+        return Settings.Global.getString(resolver, SETTING);
+    }
+
+    public void update(KeyValueListParser parser) {
+        synchronized (mLock) {
+            mKvBackupAgentTimeoutMillis =
+                    parser.getLong(
+                            SETTING_KV_BACKUP_AGENT_TIMEOUT_MILLIS,
+                            DEFAULT_KV_BACKUP_AGENT_TIMEOUT_MILLIS);
+            mFullBackupAgentTimeoutMillis =
+                    parser.getLong(
+                            SETTING_FULL_BACKUP_AGENT_TIMEOUT_MILLIS,
+                            DEFAULT_FULL_BACKUP_AGENT_TIMEOUT_MILLIS);
+            mSharedBackupAgentTimeoutMillis =
+                    parser.getLong(
+                            SETTING_SHARED_BACKUP_AGENT_TIMEOUT_MILLIS,
+                            DEFAULT_SHARED_BACKUP_AGENT_TIMEOUT_MILLIS);
+            mRestoreAgentTimeoutMillis =
+                    parser.getLong(
+                            SETTING_RESTORE_AGENT_TIMEOUT_MILLIS,
+                            DEFAULT_RESTORE_AGENT_TIMEOUT_MILLIS);
+            mRestoreAgentFinishedTimeoutMillis =
+                    parser.getLong(
+                            SETTING_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS,
+                            DEFAULT_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS);
+        }
+    }
+
+    public long getKvBackupAgentTimeoutMillis() {
+        synchronized (mLock) {
+            return mKvBackupAgentTimeoutMillis;
+        }
+    }
+
+    public long getFullBackupAgentTimeoutMillis() {
+        synchronized (mLock) {
+            return mFullBackupAgentTimeoutMillis;
+        }
+    }
+
+    public long getSharedBackupAgentTimeoutMillis() {
+        synchronized (mLock) {
+            return mSharedBackupAgentTimeoutMillis;
+        }
+    }
+
+    public long getRestoreAgentTimeoutMillis() {
+        synchronized (mLock) {
+            return mRestoreAgentTimeoutMillis;
+        }
+    }
+
+    public long getRestoreAgentFinishedTimeoutMillis() {
+        synchronized (mLock) {
+            return mRestoreAgentFinishedTimeoutMillis;
+        }
+    }
+}
diff --git a/services/core/java/com/android/server/AppOpsService.java b/services/core/java/com/android/server/AppOpsService.java
index ecf80ba..9756d17 100644
--- a/services/core/java/com/android/server/AppOpsService.java
+++ b/services/core/java/com/android/server/AppOpsService.java
@@ -1346,8 +1346,9 @@
                 return;
             }
             if (!client.mStartedOps.remove(op)) {
-                throw new IllegalStateException("Operation not started: uid" + op.uid
+                Slog.wtf(TAG, "Operation not started: uid" + op.uid
                         + " pkg=" + op.packageName + " op=" + op.op);
+                return;
             }
             finishOperationLocked(op, /*finishNested*/ false);
             if (op.nesting <= 0) {
diff --git a/services/core/java/com/android/server/DiskStatsService.java b/services/core/java/com/android/server/DiskStatsService.java
index e884de0..8ea3dd6 100644
--- a/services/core/java/com/android/server/DiskStatsService.java
+++ b/services/core/java/com/android/server/DiskStatsService.java
@@ -171,8 +171,8 @@
             if (proto != null) {
                 long freeSpaceToken = proto.start(DiskStatsServiceDumpProto.PARTITIONS_FREE_SPACE);
                 proto.write(DiskStatsFreeSpaceProto.FOLDER, folderType);
-                proto.write(DiskStatsFreeSpaceProto.AVAILABLE_SPACE, avail * bsize / 1024);
-                proto.write(DiskStatsFreeSpaceProto.TOTAL_SPACE, total * bsize / 1024);
+                proto.write(DiskStatsFreeSpaceProto.AVAILABLE_SPACE_KB, avail * bsize / 1024);
+                proto.write(DiskStatsFreeSpaceProto.TOTAL_SPACE_KB, total * bsize / 1024);
                 proto.end(freeSpaceToken);
             } else {
                 pw.print(name);
@@ -247,23 +247,23 @@
             JSONObject json = new JSONObject(jsonString);
             long cachedValuesToken = proto.start(DiskStatsServiceDumpProto.CACHED_FOLDER_SIZES);
 
-            proto.write(DiskStatsCachedValuesProto.AGG_APPS_SIZE,
+            proto.write(DiskStatsCachedValuesProto.AGG_APPS_SIZE_KB,
                     json.getLong(DiskStatsFileLogger.APP_SIZE_AGG_KEY));
-            proto.write(DiskStatsCachedValuesProto.AGG_APPS_DATA_SIZE,
+            proto.write(DiskStatsCachedValuesProto.AGG_APPS_DATA_SIZE_KB,
                     json.getLong(DiskStatsFileLogger.APP_DATA_SIZE_AGG_KEY));
-            proto.write(DiskStatsCachedValuesProto.AGG_APPS_CACHE_SIZE,
+            proto.write(DiskStatsCachedValuesProto.AGG_APPS_CACHE_SIZE_KB,
                     json.getLong(DiskStatsFileLogger.APP_CACHE_AGG_KEY));
-            proto.write(DiskStatsCachedValuesProto.PHOTOS_SIZE,
+            proto.write(DiskStatsCachedValuesProto.PHOTOS_SIZE_KB,
                     json.getLong(DiskStatsFileLogger.PHOTOS_KEY));
-            proto.write(DiskStatsCachedValuesProto.VIDEOS_SIZE,
+            proto.write(DiskStatsCachedValuesProto.VIDEOS_SIZE_KB,
                     json.getLong(DiskStatsFileLogger.VIDEOS_KEY));
-            proto.write(DiskStatsCachedValuesProto.AUDIO_SIZE,
+            proto.write(DiskStatsCachedValuesProto.AUDIO_SIZE_KB,
                     json.getLong(DiskStatsFileLogger.AUDIO_KEY));
-            proto.write(DiskStatsCachedValuesProto.DOWNLOADS_SIZE,
+            proto.write(DiskStatsCachedValuesProto.DOWNLOADS_SIZE_KB,
                     json.getLong(DiskStatsFileLogger.DOWNLOADS_KEY));
-            proto.write(DiskStatsCachedValuesProto.SYSTEM_SIZE,
+            proto.write(DiskStatsCachedValuesProto.SYSTEM_SIZE_KB,
                     json.getLong(DiskStatsFileLogger.SYSTEM_KEY));
-            proto.write(DiskStatsCachedValuesProto.OTHER_SIZE,
+            proto.write(DiskStatsCachedValuesProto.OTHER_SIZE_KB,
                     json.getLong(DiskStatsFileLogger.MISC_KEY));
 
             JSONArray packageNamesArray = json.getJSONArray(DiskStatsFileLogger.PACKAGE_NAMES_KEY);
@@ -279,9 +279,9 @@
 
                     proto.write(DiskStatsAppSizesProto.PACKAGE_NAME,
                             packageNamesArray.getString(i));
-                    proto.write(DiskStatsAppSizesProto.APP_SIZE, appSizesArray.getLong(i));
-                    proto.write(DiskStatsAppSizesProto.APP_DATA_SIZE, appDataSizesArray.getLong(i));
-                    proto.write(DiskStatsAppSizesProto.CACHE_SIZE, cacheSizesArray.getLong(i));
+                    proto.write(DiskStatsAppSizesProto.APP_SIZE_KB, appSizesArray.getLong(i));
+                    proto.write(DiskStatsAppSizesProto.APP_DATA_SIZE_KB, appDataSizesArray.getLong(i));
+                    proto.write(DiskStatsAppSizesProto.CACHE_SIZE_KB, cacheSizesArray.getLong(i));
 
                     proto.end(packageToken);
                 }
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 1b0bd50..eec9c06 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -256,6 +256,7 @@
 import android.app.WaitResult;
 import android.app.WindowConfiguration.ActivityType;
 import android.app.WindowConfiguration.WindowingMode;
+import android.app.admin.DevicePolicyCache;
 import android.app.admin.DevicePolicyManager;
 import android.app.assist.AssistContent;
 import android.app.assist.AssistStructure;
@@ -13733,9 +13734,7 @@
             }
             userId = activity.userId;
         }
-        DevicePolicyManager dpm = (DevicePolicyManager) mContext.getSystemService(
-                Context.DEVICE_POLICY_SERVICE);
-        return (dpm == null) || (!dpm.getScreenCaptureDisabled(null, userId));
+        return !DevicePolicyCache.getInstance().getScreenCaptureDisabled(userId);
     }
 
     @Override
@@ -25384,6 +25383,14 @@
                     } catch (IOException e) {
                     }
                     mProfilerInfo.profileFd = null;
+
+                    if (proc.pid == MY_PID) {
+                        // When profiling the system server itself, avoid closing the file
+                        // descriptor, as profilerControl will not create a copy.
+                        // Note: it is also not correct to just set profileFd to null, as the
+                        //       whole ProfilerInfo instance is passed down!
+                        profilerInfo = null;
+                    }
                 } else {
                     stopProfilerLocked(proc, profileType);
                     if (profilerInfo != null && profilerInfo.profileFd != null) {
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 2c4eac0..a24f84a 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -195,8 +195,12 @@
 
     // How long we wait for the activity to tell us it has stopped before
     // giving up.  This is a good amount of time because we really need this
-    // from the application in order to get its saved state.
-    private static final int STOP_TIMEOUT = 10 * 1000;
+    // from the application in order to get its saved state. Once the stop
+    // is complete we may start destroying client resources triggering
+    // crashes if the UI thread was hung. We put this timeout one second behind
+    // the ANR timeout so these situations will generate ANR instead of
+    // Surface lost or other errors.
+    private static final int STOP_TIMEOUT = 11 * 1000;
 
     // How long we wait until giving up on an activity telling us it has
     // finished destroying itself.
diff --git a/services/core/java/com/android/server/media/OWNERS b/services/core/java/com/android/server/media/OWNERS
index 755c1d6..8adea0e 100644
--- a/services/core/java/com/android/server/media/OWNERS
+++ b/services/core/java/com/android/server/media/OWNERS
@@ -1,3 +1,4 @@
 lajos@google.com
 elaurent@google.com
 sungsoo@google.com
+jaewan@google.com
diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
index ab55553..efca159 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -2852,6 +2852,32 @@
                                 ZonedDateTime.now().minusHours(1).toInstant().toEpochMilli())
                         .build());
 
+            } else if ("month_over".equals(fake)) {
+                plans.add(SubscriptionPlan.Builder
+                        .createRecurringMonthly(ZonedDateTime.parse("2007-03-14T00:00:00.000Z"))
+                        .setTitle("G-Mobile is the carriers name who this plan belongs to")
+                        .setDataLimit(5 * TrafficStats.GB_IN_BYTES,
+                                SubscriptionPlan.LIMIT_BEHAVIOR_THROTTLED)
+                        .setDataUsage(6 * TrafficStats.GB_IN_BYTES,
+                                ZonedDateTime.now().minusHours(1).toInstant().toEpochMilli())
+                        .build());
+                plans.add(SubscriptionPlan.Builder
+                        .createRecurringMonthly(ZonedDateTime.parse("2017-03-14T00:00:00.000Z"))
+                        .setTitle("G-Mobile, Throttled after limit")
+                        .setDataLimit(5 * TrafficStats.GB_IN_BYTES,
+                                SubscriptionPlan.LIMIT_BEHAVIOR_THROTTLED)
+                        .setDataUsage(5 * TrafficStats.GB_IN_BYTES,
+                                ZonedDateTime.now().minusHours(1).toInstant().toEpochMilli())
+                        .build());
+                plans.add(SubscriptionPlan.Builder
+                        .createRecurringMonthly(ZonedDateTime.parse("2017-03-14T00:00:00.000Z"))
+                        .setTitle("G-Mobile, No data connection after limit")
+                        .setDataLimit(5 * TrafficStats.GB_IN_BYTES,
+                                SubscriptionPlan.LIMIT_BEHAVIOR_DISABLED)
+                        .setDataUsage(5 * TrafficStats.GB_IN_BYTES,
+                                ZonedDateTime.now().minusHours(1).toInstant().toEpochMilli())
+                        .build());
+
             } else if ("month_none".equals(fake)) {
                 plans.add(SubscriptionPlan.Builder
                         .createRecurringMonthly(ZonedDateTime.parse("2007-03-14T00:00:00.000Z"))
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index b9fb2e0..b911c7b 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -256,6 +256,9 @@
     static final int LONG_DELAY = PhoneWindowManager.TOAST_WINDOW_TIMEOUT;
     static final int SHORT_DELAY = 2000; // 2 seconds
 
+    // 1 second past the ANR timeout.
+    static final int FINISH_TOKEN_TIMEOUT = 11 * 1000;
+
     static final long[] DEFAULT_VIBRATE_PATTERN = {0, 250, 250, 250};
 
     static final long SNOOZE_UNTIL_UNSPECIFIED = -1;
@@ -4804,7 +4807,7 @@
     {
         mHandler.removeCallbacksAndMessages(token);
         Message m = Message.obtain(mHandler, MESSAGE_FINISH_TOKEN_TIMEOUT, token);
-        mHandler.sendMessageDelayed(m, 5);
+        mHandler.sendMessageDelayed(m, FINISH_TOKEN_TIMEOUT);
     }
 
     private void handleKillTokenTimeout(IBinder token)
diff --git a/services/core/java/com/android/server/power/BatterySaverPolicy.java b/services/core/java/com/android/server/power/BatterySaverPolicy.java
index 16336b3..483f974 100644
--- a/services/core/java/com/android/server/power/BatterySaverPolicy.java
+++ b/services/core/java/com/android/server/power/BatterySaverPolicy.java
@@ -69,6 +69,7 @@
     private static final String KEY_FORCE_BACKGROUND_CHECK = "force_background_check";
     private static final String KEY_OPTIONAL_SENSORS_DISABLED = "optional_sensors_disabled";
     private static final String KEY_AOD_DISABLED = "aod_disabled";
+    private static final String KEY_SEND_TRON_LOG = "send_tron_log";
 
     private static final String KEY_CPU_FREQ_INTERACTIVE = "cpufreq-i";
     private static final String KEY_CPU_FREQ_NONINTERACTIVE = "cpufreq-n";
@@ -212,6 +213,12 @@
     @GuardedBy("mLock")
     private boolean mAodDisabled;
 
+    /**
+     * Whether BatterySavingStats should send tron events.
+     */
+    @GuardedBy("mLock")
+    private boolean mSendTronLog;
+
     @GuardedBy("mLock")
     private Context mContext;
 
@@ -347,6 +354,7 @@
         mForceBackgroundCheck = parser.getBoolean(KEY_FORCE_BACKGROUND_CHECK, true);
         mOptionalSensorsDisabled = parser.getBoolean(KEY_OPTIONAL_SENSORS_DISABLED, true);
         mAodDisabled = parser.getBoolean(KEY_AOD_DISABLED, true);
+        mSendTronLog = parser.getBoolean(KEY_SEND_TRON_LOG, true);
 
         // Get default value from Settings.Secure
         final int defaultGpsMode = Settings.Secure.getInt(mContentResolver, SECURE_KEY_GPS_MODE,
@@ -384,10 +392,13 @@
         if (mLaunchBoostDisabled) sb.append("l");
         if (mOptionalSensorsDisabled) sb.append("S");
         if (mAodDisabled) sb.append("o");
+        if (mSendTronLog) sb.append("t");
 
         sb.append(mGpsMode);
 
         mEventLogKeys = sb.toString();
+
+        BatterySavingStats.getInstance().setSendTronLog(mSendTronLog);
     }
 
     /**
@@ -483,7 +494,10 @@
     public void dump(PrintWriter pw) {
         synchronized (mLock) {
             pw.println();
-            pw.println("Battery saver policy");
+            BatterySavingStats.getInstance().dump(pw, "");
+
+            pw.println();
+            pw.println("Battery saver policy (*NOTE* they only apply when battery saver is ON):");
             pw.println("  Settings: " + Settings.Global.BATTERY_SAVER_CONSTANTS);
             pw.println("    value: " + mSettings);
             pw.println("  Settings: " + mDeviceSpecificSettingsSource);
@@ -504,6 +518,7 @@
             pw.println("  " + KEY_FORCE_BACKGROUND_CHECK + "=" + mForceBackgroundCheck);
             pw.println("  " + KEY_OPTIONAL_SENSORS_DISABLED + "=" + mOptionalSensorsDisabled);
             pw.println("  " + KEY_AOD_DISABLED + "=" + mAodDisabled);
+            pw.println("  " + KEY_SEND_TRON_LOG + "=" + mSendTronLog);
             pw.println();
 
             pw.print("  Interactive File values:\n");
@@ -512,9 +527,6 @@
 
             pw.print("  Noninteractive File values:\n");
             dumpMap(pw, "    ", mFilesForNoninteractive);
-            pw.println();
-            pw.println();
-            BatterySavingStats.getInstance().dump(pw, "  ");
         }
     }
 
diff --git a/services/core/java/com/android/server/power/batterysaver/BatterySavingStats.java b/services/core/java/com/android/server/power/batterysaver/BatterySavingStats.java
index 5d76329..4fd8686 100644
--- a/services/core/java/com/android/server/power/batterysaver/BatterySavingStats.java
+++ b/services/core/java/com/android/server/power/batterysaver/BatterySavingStats.java
@@ -20,6 +20,7 @@
 import android.os.SystemClock;
 import android.util.ArrayMap;
 import android.util.Slog;
+import android.util.TimeUtils;
 
 import com.android.internal.annotations.GuardedBy;
 import com.android.internal.annotations.VisibleForTesting;
@@ -31,6 +32,8 @@
 import com.android.server.power.BatterySaverPolicy;
 
 import java.io.PrintWriter;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 /**
  * This class keeps track of battery drain rate.
@@ -46,9 +49,6 @@
 
     private static final boolean DEBUG = BatterySaverPolicy.DEBUG;
 
-    @VisibleForTesting
-    static final boolean SEND_TRON_EVENTS = true;
-
     private final Object mLock = new Object();
 
     /** Whether battery saver is on or off. */
@@ -159,8 +159,18 @@
     @GuardedBy("mLock")
     final ArrayMap<Integer, Stat> mStats = new ArrayMap<>();
 
+    @GuardedBy("mLock")
+    private int mBatterySaverEnabledCount = 0;
+
+    @GuardedBy("mLock")
+    private long mLastBatterySaverEnabledTime = 0;
+
     private final MetricsLoggerHelper mMetricsLoggerHelper = new MetricsLoggerHelper();
 
+    @VisibleForTesting
+    @GuardedBy("mLock")
+    private boolean mSendTronLog;
+
     /**
      * Don't call it directly -- use {@link #getInstance()}. Not private for testing.
      * @param metricsLogger
@@ -178,6 +188,12 @@
         return sInstance;
     }
 
+    public void setSendTronLog(boolean send) {
+        synchronized (mLock) {
+            mSendTronLog = send;
+        }
+    }
+
     private BatteryManagerInternal getBatteryManagerInternal() {
         if (mBatteryManagerInternal == null) {
             mBatteryManagerInternal = LocalServices.getService(BatteryManagerInternal.class);
@@ -291,9 +307,22 @@
         final int batteryLevel = injectBatteryLevel();
         final int batteryPercent = injectBatteryPercent();
 
+        final boolean oldBatterySaverEnabled =
+                BatterySaverState.fromIndex(mCurrentState) != BatterySaverState.OFF;
+        final boolean newBatterySaverEnabled =
+                BatterySaverState.fromIndex(newState) != BatterySaverState.OFF;
+        if (oldBatterySaverEnabled != newBatterySaverEnabled) {
+            if (newBatterySaverEnabled) {
+                mBatterySaverEnabledCount++;
+                mLastBatterySaverEnabledTime = injectCurrentTime();
+            } else {
+                mLastBatterySaverEnabledTime = 0;
+            }
+        }
+
         endLastStateLocked(now, batteryLevel, batteryPercent);
         startNewStateLocked(newState, now, batteryLevel, batteryPercent);
-        mMetricsLoggerHelper.transitionState(newState, now, batteryLevel, batteryPercent);
+        mMetricsLoggerHelper.transitionStateLocked(newState, now, batteryLevel, batteryPercent);
     }
 
     @GuardedBy("mLock")
@@ -358,12 +387,39 @@
     public void dump(PrintWriter pw, String indent) {
         synchronized (mLock) {
             pw.print(indent);
-            pw.println("Battery Saving Stats:");
+            pw.println("Battery saving stats:");
 
             indent = indent + "  ";
 
             pw.print(indent);
-            pw.println("Battery Saver:     w/Off                                      w/On");
+            pw.print("Battery Saver state: ");
+            if (mLastBatterySaverEnabledTime == 0) {
+                pw.print("OFF");
+            } else {
+                pw.print("ON since ");
+
+                final long now = System.currentTimeMillis();
+                final long nowElapsed = injectCurrentTime();
+
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+                pw.print(sdf.format(new Date(now - nowElapsed + mLastBatterySaverEnabledTime)));
+
+                pw.print(" ");
+                TimeUtils.formatDuration(mLastBatterySaverEnabledTime, nowElapsed, pw);
+            }
+            pw.println();
+
+            pw.print(indent);
+            pw.print("Times enabled: ");
+            pw.println(mBatterySaverEnabledCount);
+
+            pw.println();
+
+            pw.print(indent);
+            pw.println("Drain stats:");
+
+            pw.print(indent);
+            pw.println("                   Battery saver OFF                          ON");
             dumpLineLocked(pw, indent, InteractiveState.NON_INTERACTIVE, "NonIntr",
                     DozeState.NOT_DOZING, "NonDoze");
             dumpLineLocked(pw, indent, InteractiveState.INTERACTIVE, "   Intr",
@@ -378,8 +434,6 @@
                     DozeState.LIGHT, "Light  ");
             dumpLineLocked(pw, indent, InteractiveState.INTERACTIVE, "   Intr",
                     DozeState.LIGHT, "       ");
-
-            pw.println();
         }
     }
 
@@ -395,7 +449,7 @@
         final Stat offStat = getStat(BatterySaverState.OFF, interactiveState, dozeState);
         final Stat onStat = getStat(BatterySaverState.ON, interactiveState, dozeState);
 
-        pw.println(String.format("%6dm %6dmA (%3d%%) %8.1fmA/h      %6dm %6dmA (%3d%%) %8.1fmA/h",
+        pw.println(String.format("%6dm %6dmAh(%3d%%) %8.1fmAh/h     %6dm %6dmAh(%3d%%) %8.1fmAh/h",
                 offStat.totalMinutes(),
                 offStat.totalBatteryDrain / 1000,
                 offStat.totalBatteryDrainPercent,
@@ -417,7 +471,8 @@
                 (BatterySaverState.MASK << BatterySaverState.SHIFT) |
                 (InteractiveState.MASK << InteractiveState.SHIFT);
 
-        public void transitionState(int newState, long now, int batteryLevel, int batteryPercent) {
+        public void transitionStateLocked(
+                int newState, long now, int batteryLevel, int batteryPercent) {
             final boolean stateChanging =
                     ((mLastState >= 0) ^ (newState >= 0)) ||
                     (((mLastState ^ newState) & STATE_CHANGE_DETECT_MASK) != 0);
@@ -425,7 +480,7 @@
                 if (mLastState >= 0) {
                     final long deltaTime = now - mStartTime;
 
-                    report(mLastState, deltaTime, mStartBatteryLevel, mStartPercent,
+                    reportLocked(mLastState, deltaTime, mStartBatteryLevel, mStartPercent,
                             batteryLevel, batteryPercent);
                 }
                 mStartTime = now;
@@ -435,10 +490,10 @@
             mLastState = newState;
         }
 
-        void report(int state, long deltaTimeMs,
+        void reportLocked(int state, long deltaTimeMs,
                 int startBatteryLevelUa, int startBatteryLevelPercent,
                 int endBatteryLevelUa, int endBatteryLevelPercent) {
-            if (!SEND_TRON_EVENTS) {
+            if (!mSendTronLog) {
                 return;
             }
             final boolean batterySaverOn =
diff --git a/services/core/java/com/android/server/stats/StatsCompanionService.java b/services/core/java/com/android/server/stats/StatsCompanionService.java
index 954627b..afcedcc 100644
--- a/services/core/java/com/android/server/stats/StatsCompanionService.java
+++ b/services/core/java/com/android/server/stats/StatsCompanionService.java
@@ -720,11 +720,13 @@
         long elapsedNanos = SystemClock.elapsedRealtimeNanos();
         mKernelUidCpuFreqTimeReader.readAbsolute((uid, cpuFreqTimeMs) -> {
             for (int freqIndex = 0; freqIndex < cpuFreqTimeMs.length; ++freqIndex) {
-                StatsLogEventWrapper e = new StatsLogEventWrapper(elapsedNanos, tagId, 3);
-                e.writeInt(uid);
-                e.writeInt(freqIndex);
-                e.writeLong(cpuFreqTimeMs[freqIndex]);
-                pulledData.add(e);
+                if(cpuFreqTimeMs[freqIndex] != 0) {
+                    StatsLogEventWrapper e = new StatsLogEventWrapper(elapsedNanos, tagId, 3);
+                    e.writeInt(uid);
+                    e.writeInt(freqIndex);
+                    e.writeLong(cpuFreqTimeMs[freqIndex]);
+                    pulledData.add(e);
+                }
             }
         });
     }
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index be009d2..c2cc191 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -25,7 +25,6 @@
 import static android.app.AppOpsManager.OP_SYSTEM_ALERT_WINDOW;
 import static android.app.StatusBarManager.DISABLE_MASK;
 import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED;
-import static android.content.Intent.ACTION_USER_REMOVED;
 import static android.content.Intent.EXTRA_USER_HANDLE;
 import static android.content.pm.PackageManager.PERMISSION_GRANTED;
 import static android.os.Process.SYSTEM_UID;
@@ -122,6 +121,7 @@
 import android.app.AppOpsManager;
 import android.app.IActivityManager;
 import android.app.IAssistDataReceiver;
+import android.app.admin.DevicePolicyCache;
 import android.content.BroadcastReceiver;
 import android.content.ContentResolver;
 import android.content.Context;
@@ -380,14 +380,6 @@
                 case ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED:
                     mKeyguardDisableHandler.sendEmptyMessage(KEYGUARD_POLICY_CHANGED);
                     break;
-                case ACTION_USER_REMOVED:
-                    final int userId = intent.getIntExtra(EXTRA_USER_HANDLE, USER_NULL);
-                    if (userId != USER_NULL) {
-                        synchronized (mWindowMap) {
-                            mScreenCaptureDisabled.remove(userId);
-                        }
-                    }
-                    break;
             }
         }
     };
@@ -519,13 +511,6 @@
     /** List of window currently causing non-system overlay windows to be hidden. */
     private ArrayList<WindowState> mHidingNonSystemOverlayWindows = new ArrayList<>();
 
-    /**
-     * Stores for each user whether screencapture is disabled
-     * This array is essentially a cache for all userId for
-     * {@link android.app.admin.DevicePolicyManager#getScreenCaptureDisabled}
-     */
-    private SparseArray<Boolean> mScreenCaptureDisabled = new SparseArray<>();
-
     IInputMethodManager mInputMethodManager;
 
     AccessibilityController mAccessibilityController;
@@ -1039,8 +1024,6 @@
         IntentFilter filter = new IntentFilter();
         // Track changes to DevicePolicyManager state so we can enable/disable keyguard.
         filter.addAction(ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
-        // Listen to user removal broadcasts so that we can remove the user-specific data.
-        filter.addAction(Intent.ACTION_USER_REMOVED);
         mContext.registerReceiver(mBroadcastReceiver, filter);
 
         mLatencyTracker = LatencyTracker.getInstance(context);
@@ -1572,41 +1555,32 @@
         }
     }
 
-    /**
-     * Returns whether screen capture is disabled for all windows of a specific user.
-     */
-    boolean isScreenCaptureDisabledLocked(int userId) {
-        Boolean disabled = mScreenCaptureDisabled.get(userId);
-        if (disabled == null) {
-            return false;
-        }
-        return disabled;
-    }
-
     boolean isSecureLocked(WindowState w) {
         if ((w.mAttrs.flags&WindowManager.LayoutParams.FLAG_SECURE) != 0) {
             return true;
         }
-        if (isScreenCaptureDisabledLocked(UserHandle.getUserId(w.mOwnerUid))) {
+        if (DevicePolicyCache.getInstance().getScreenCaptureDisabled(
+                UserHandle.getUserId(w.mOwnerUid))) {
             return true;
         }
         return false;
     }
 
     /**
-     * Set mScreenCaptureDisabled for specific user
+     * Set whether screen capture is disabled for all windows of a specific user from
+     * the device policy cache.
      */
     @Override
-    public void setScreenCaptureDisabled(int userId, boolean disabled) {
+    public void refreshScreenCaptureDisabled(int userId) {
         int callingUid = Binder.getCallingUid();
         if (callingUid != SYSTEM_UID) {
-            throw new SecurityException("Only system can call setScreenCaptureDisabled.");
+            throw new SecurityException("Only system can call refreshScreenCaptureDisabled.");
         }
 
         synchronized(mWindowMap) {
-            mScreenCaptureDisabled.put(userId, disabled);
             // Update secure surface for all windows belonging to this user.
-            mRoot.setSecureSurfaceState(userId, disabled);
+            mRoot.setSecureSurfaceState(userId,
+                    DevicePolicyCache.getInstance().getScreenCaptureDisabled(userId));
         }
     }
 
diff --git a/services/core/java/com/android/server/wm/WindowManagerShellCommand.java b/services/core/java/com/android/server/wm/WindowManagerShellCommand.java
index ab139db..6e0ccfd 100644
--- a/services/core/java/com/android/server/wm/WindowManagerShellCommand.java
+++ b/services/core/java/com/android/server/wm/WindowManagerShellCommand.java
@@ -70,8 +70,6 @@
                     return runDisplayOverscan(pw);
                 case "scaling":
                     return runDisplayScaling(pw);
-                case "screen-capture":
-                    return runSetScreenCapture(pw);
                 case "dismiss-keyguard":
                     return runDismissKeyguard(pw);
                 case "tracing":
@@ -210,24 +208,6 @@
         return 0;
     }
 
-    private int runSetScreenCapture(PrintWriter pw) throws RemoteException {
-        String userIdStr = getNextArg();
-        String enableStr = getNextArg();
-        int userId;
-        boolean disable;
-
-        try {
-            userId = Integer.parseInt(userIdStr);
-        } catch (NumberFormatException e) {
-            getErrPrintWriter().println("Error: bad number " + e);
-            return -1;
-        }
-
-        disable = !Boolean.parseBoolean(enableStr);
-        mInternal.setScreenCaptureDisabled(userId, disable);
-        return 0;
-    }
-
     private int runDismissKeyguard(PrintWriter pw) throws RemoteException {
         mInterface.dismissKeyguard(null /* callback */, null /* message */);
         return 0;
@@ -265,8 +245,6 @@
         pw.println("    Set overscan area for display.");
         pw.println("  scaling [off|auto]");
         pw.println("    Set display scaling mode.");
-        pw.println("  screen-capture [userId] [true|false]");
-        pw.println("    Enable or disable screen capture.");
         pw.println("  dismiss-keyguard");
         pw.println("    Dismiss the keyguard, prompting user for auth if necessary.");
         if (!IS_USER) {
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index f917841..05d5d0e 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -4297,6 +4297,15 @@
         final boolean wasVisible = isVisibleLw();
 
         result |= (!wasVisible || !isDrawnLw()) ? RELAYOUT_RES_FIRST_TIME : 0;
+
+        if (mWinAnimator.mChildrenDetached) {
+            // If there are detached children hanging around we need to force
+            // the client receiving a new Surface.
+            mWinAnimator.preserveSurfaceLocked();
+            result |= RELAYOUT_RES_SURFACE_CHANGED
+                    | RELAYOUT_RES_FIRST_TIME;
+        }
+
         if (mAnimatingExit) {
             Slog.d(TAG, "relayoutVisibleWindow: " + this + " mAnimatingExit=true, mRemoveOnExit="
                     + mRemoveOnExit + ", mDestroying=" + mDestroying);
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index 46a9961..410eddf 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -221,6 +221,10 @@
 
     private final SurfaceControl.Transaction mReparentTransaction = new SurfaceControl.Transaction();
 
+    // Used to track whether we have called detach children on the way to invisibility, in which
+    // case we need to give the client a new Surface if it lays back out to a visible state.
+    boolean mChildrenDetached = false;
+
     WindowStateAnimator(final WindowState win) {
         final WindowManagerService service = win.mService;
 
@@ -430,6 +434,7 @@
         if (mSurfaceController != null) {
             return mSurfaceController;
         }
+        mChildrenDetached = false;
 
         if ((mWin.mAttrs.privateFlags & PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY) != 0) {
             windowType = SurfaceControl.WINDOW_TYPE_DONT_SCREENSHOT;
@@ -981,7 +986,7 @@
             mForceScaleUntilResize = true;
         } else {
             if (!w.mSeamlesslyRotated) {
-                mSurfaceController.setPositionInTransaction(0, 0, recoveringMemory);
+                mSurfaceController.setPositionInTransaction(mXOffset, mYOffset, recoveringMemory);
             }
         }
 
@@ -1478,6 +1483,7 @@
         if (mSurfaceController != null) {
             mSurfaceController.detachChildren();
         }
+        mChildrenDetached = true;
     }
 
     int getLayer() {
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyCacheImpl.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyCacheImpl.java
new file mode 100644
index 0000000..37b5ad1
--- /dev/null
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyCacheImpl.java
@@ -0,0 +1,57 @@
+/*
+ * 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.server.devicepolicy;
+
+import android.app.admin.DevicePolicyCache;
+import android.util.SparseBooleanArray;
+
+import com.android.internal.annotations.GuardedBy;
+
+/**
+ * Implementation of {@link DevicePolicyCache}, to which {@link DevicePolicyManagerService} pushes
+ * policies.
+ *
+ * TODO Move other copies of policies into this class too.
+ */
+public class DevicePolicyCacheImpl extends DevicePolicyCache {
+    /**
+     * Lock object. For simplicity we just always use this as the lock. We could use each object
+     * as a lock object to make it more fine-grained, but that'd make copy-paste error-prone.
+     */
+    private final Object mLock = new Object();
+
+    @GuardedBy("mLock")
+    private final SparseBooleanArray mScreenCaptureDisabled = new SparseBooleanArray();
+
+    public void onUserRemoved(int userHandle) {
+        synchronized (mLock) {
+            mScreenCaptureDisabled.delete(userHandle);
+        }
+    }
+
+    @Override
+    public boolean getScreenCaptureDisabled(int userHandle) {
+        synchronized (mLock) {
+            return mScreenCaptureDisabled.get(userHandle);
+        }
+    }
+
+    public void setScreenCaptureDisabled(int userHandle, boolean disabled) {
+        synchronized (mLock) {
+            mScreenCaptureDisabled.put(userHandle, disabled);
+        }
+    }
+}
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index ab8a6c4..c7ae570 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -98,6 +98,7 @@
 import android.app.StatusBarManager;
 import android.app.admin.DeviceAdminInfo;
 import android.app.admin.DeviceAdminReceiver;
+import android.app.admin.DevicePolicyCache;
 import android.app.admin.DevicePolicyManager;
 import android.app.admin.DevicePolicyManagerInternal;
 import android.app.admin.NetworkEvent;
@@ -436,6 +437,8 @@
     private final DeviceAdminServiceController mDeviceAdminServiceController;
     private final OverlayPackagesProvider mOverlayPackagesProvider;
 
+    private final DevicePolicyCacheImpl mPolicyCache = new DevicePolicyCacheImpl();
+
     /**
      * Contains (package-user) pairs to remove. An entry (p, u) implies that removal of package p
      * is requested for user u.
@@ -2176,6 +2179,8 @@
                 Slog.w(LOG_TAG, "Tried to remove device policy file for user 0! Ignoring.");
                 return;
             }
+            mPolicyCache.onUserRemoved(userHandle);
+
             mOwners.removeProfileOwner(userHandle);
             mOwners.writeProfileOwner(userHandle);
 
@@ -2188,7 +2193,6 @@
             policyFile.delete();
             Slog.i(LOG_TAG, "Removed device policy file " + policyFile.getAbsolutePath());
         }
-        updateScreenCaptureDisabledInWindowManager(userHandle, false /* default value */);
     }
 
     void loadOwners() {
@@ -3395,7 +3399,7 @@
 
     @Override
     void handleStartUser(int userId) {
-        updateScreenCaptureDisabledInWindowManager(userId,
+        updateScreenCaptureDisabled(userId,
                 getScreenCaptureDisabled(null, userId));
         pushUserRestrictions(userId);
 
@@ -6632,7 +6636,7 @@
             if (ap.disableScreenCapture != disabled) {
                 ap.disableScreenCapture = disabled;
                 saveSettingsLocked(userHandle);
-                updateScreenCaptureDisabledInWindowManager(userHandle, disabled);
+                updateScreenCaptureDisabled(userHandle, disabled);
             }
         }
     }
@@ -6664,13 +6668,13 @@
         }
     }
 
-    private void updateScreenCaptureDisabledInWindowManager(final int userHandle,
-            final boolean disabled) {
+    private void updateScreenCaptureDisabled(int userHandle, boolean disabled) {
+        mPolicyCache.setScreenCaptureDisabled(userHandle, disabled);
         mHandler.post(new Runnable() {
             @Override
             public void run() {
                 try {
-                    mInjector.getIWindowManager().setScreenCaptureDisabled(userHandle, disabled);
+                    mInjector.getIWindowManager().refreshScreenCaptureDisabled(userHandle);
                 } catch (RemoteException e) {
                     Log.w(LOG_TAG, "Unable to notify WindowManager.", e);
                 }
@@ -10502,6 +10506,11 @@
                         .getResources().getString(R.string.printing_disabled_by, appLabel);
             }
         }
+
+        @Override
+        protected DevicePolicyCache getDevicePolicyCache() {
+            return mPolicyCache;
+        }
     }
 
     private Intent createShowAdminSupportIntent(ComponentName admin, int userId) {
@@ -12658,8 +12667,7 @@
         final DeviceAdminInfo incomingDeviceInfo = findAdmin(target, callingUserId,
                 /* throwForMissingPermission= */ true);
         checkActiveAdminPrecondition(target, incomingDeviceInfo, policy);
-        if (!incomingDeviceInfo.getActivityInfo().metaData
-                .getBoolean(DeviceAdminReceiver.SUPPORT_TRANSFER_OWNERSHIP_META_DATA, false)) {
+        if (!incomingDeviceInfo.supportsTransferOwnership()) {
             throw new IllegalArgumentException("Provided target does not support "
                     + "ownership transfer.");
         }
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 165aaac..70abf80 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -685,11 +685,6 @@
      * Starts some essential services that are not tangled up in the bootstrap process.
      */
     private void startCoreServices() {
-        // Records errors and logs, for example wtf()
-        traceBeginAndSlog("StartDropBoxManager");
-        mSystemServiceManager.startService(DropBoxManagerService.class);
-        traceEnd();
-
         traceBeginAndSlog("StartBatteryService");
         // Tracks the battery level.  Requires LightService.
         mSystemServiceManager.startService(BatteryService.class);
@@ -816,6 +811,13 @@
             SQLiteCompatibilityWalFlags.reset();
             traceEnd();
 
+            // Records errors and logs, for example wtf()
+            // Currently this service indirectly depends on SettingsProvider so do this after
+            // InstallSystemProviders.
+            traceBeginAndSlog("StartDropBoxManager");
+            mSystemServiceManager.startService(DropBoxManagerService.class);
+            traceEnd();
+
             traceBeginAndSlog("StartVibratorService");
             vibrator = new VibratorService(context);
             ServiceManager.addService("vibrator", vibrator);
diff --git a/services/robotests/src/com/android/server/backup/BackupAgentTimeoutParametersTest.java b/services/robotests/src/com/android/server/backup/BackupAgentTimeoutParametersTest.java
new file mode 100644
index 0000000..801451e
--- /dev/null
+++ b/services/robotests/src/com/android/server/backup/BackupAgentTimeoutParametersTest.java
@@ -0,0 +1,140 @@
+/*
+ * 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.server.backup;
+
+import static org.junit.Assert.assertEquals;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.os.Handler;
+import android.platform.test.annotations.Presubmit;
+import android.provider.Settings;
+import android.util.KeyValueSettingObserver;
+import com.android.server.testing.FrameworkRobolectricTestRunner;
+import com.android.server.testing.SystemLoaderClasses;
+import com.android.server.testing.SystemLoaderPackages;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+/** Tests for {@link BackupAgentTimeoutParameters}. */
+@RunWith(FrameworkRobolectricTestRunner.class)
+@Config(manifest = Config.NONE, sdk = 26)
+@SystemLoaderPackages({"com.android.server.backup"})
+@SystemLoaderClasses({KeyValueSettingObserver.class})
+@Presubmit
+public class BackupAgentTimeoutParametersTest {
+    private ContentResolver mContentResolver;
+    private BackupAgentTimeoutParameters mParameters;
+
+    /** Initialize timeout parameters and start observing changes. */
+    @Before
+    public void setUp() {
+        Context context = RuntimeEnvironment.application.getApplicationContext();
+
+        mContentResolver = context.getContentResolver();
+        mParameters = new BackupAgentTimeoutParameters(new Handler(), mContentResolver);
+        mParameters.start();
+    }
+
+    /** Stop observing changes to the setting. */
+    @After
+    public void tearDown() {
+        mParameters.stop();
+    }
+
+    /** Tests that timeout parameters are initialized with default values on creation. */
+    @Test
+    public void testGetParameters_afterConstructorWithStart_returnsDefaultValues() {
+        long kvBackupAgentTimeoutMillis = mParameters.getKvBackupAgentTimeoutMillis();
+        long fullBackupAgentTimeoutMillis = mParameters.getFullBackupAgentTimeoutMillis();
+        long sharedBackupAgentTimeoutMillis = mParameters.getSharedBackupAgentTimeoutMillis();
+        long restoreAgentTimeoutMillis = mParameters.getRestoreAgentTimeoutMillis();
+        long restoreAgentFinishedTimeoutMillis = mParameters.getRestoreAgentFinishedTimeoutMillis();
+
+        assertEquals(
+                BackupAgentTimeoutParameters.DEFAULT_KV_BACKUP_AGENT_TIMEOUT_MILLIS,
+                kvBackupAgentTimeoutMillis);
+        assertEquals(
+                BackupAgentTimeoutParameters.DEFAULT_FULL_BACKUP_AGENT_TIMEOUT_MILLIS,
+                fullBackupAgentTimeoutMillis);
+        assertEquals(
+                BackupAgentTimeoutParameters.DEFAULT_SHARED_BACKUP_AGENT_TIMEOUT_MILLIS,
+                sharedBackupAgentTimeoutMillis);
+        assertEquals(
+                BackupAgentTimeoutParameters.DEFAULT_RESTORE_AGENT_TIMEOUT_MILLIS,
+                restoreAgentTimeoutMillis);
+        assertEquals(
+                BackupAgentTimeoutParameters.DEFAULT_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS,
+                restoreAgentFinishedTimeoutMillis);
+    }
+
+    /**
+     * Tests that timeout parameters are updated when we call start, even when a setting change
+     * occurs while we are not observing.
+     */
+    @Test
+    public void testGetParameters_withSettingChangeBeforeStart_updatesValues() {
+        mParameters.stop();
+        long testTimeout = BackupAgentTimeoutParameters.DEFAULT_KV_BACKUP_AGENT_TIMEOUT_MILLIS * 2;
+        final String setting =
+                BackupAgentTimeoutParameters.SETTING_KV_BACKUP_AGENT_TIMEOUT_MILLIS
+                        + "="
+                        + testTimeout;
+        putStringAndNotify(setting);
+        mParameters.start();
+
+        long kvBackupAgentTimeoutMillis = mParameters.getKvBackupAgentTimeoutMillis();
+
+        assertEquals(testTimeout, kvBackupAgentTimeoutMillis);
+    }
+
+    /**
+     * Tests that timeout parameters are updated when a setting change occurs while we are observing
+     * changes.
+     */
+    @Test
+    public void testGetParameters_withSettingChangeAfterStart_updatesValues() {
+        long testTimeout = BackupAgentTimeoutParameters.DEFAULT_KV_BACKUP_AGENT_TIMEOUT_MILLIS * 2;
+        final String setting =
+                BackupAgentTimeoutParameters.SETTING_KV_BACKUP_AGENT_TIMEOUT_MILLIS
+                        + "="
+                        + testTimeout;
+        putStringAndNotify(setting);
+
+        long kvBackupAgentTimeoutMillis = mParameters.getKvBackupAgentTimeoutMillis();
+
+        assertEquals(testTimeout, kvBackupAgentTimeoutMillis);
+    }
+
+    /**
+     * Robolectric does not notify observers of changes to settings so we have to trigger it here.
+     * Currently, the mock of {@link Settings.Secure#putString(ContentResolver, String, String)}
+     * only stores the value. TODO: Implement properly in ShadowSettings.
+     */
+    private void putStringAndNotify(String value) {
+        Settings.Global.putString(mContentResolver, BackupAgentTimeoutParameters.SETTING, value);
+
+        // We pass null as the observer since notifyChange iterates over all available observers and
+        // we don't have access to the local observer.
+        mContentResolver.notifyChange(
+                Settings.Global.getUriFor(BackupAgentTimeoutParameters.SETTING), /*observer*/ null);
+    }
+}
diff --git a/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySavingStatsTest.java b/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySavingStatsTest.java
index f7112d4..0f3ca03 100644
--- a/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySavingStatsTest.java
+++ b/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySavingStatsTest.java
@@ -15,8 +15,6 @@
  */
 package com.android.server.power.batterysaver;
 
-import static com.android.server.power.batterysaver.BatterySavingStats.SEND_TRON_EVENTS;
-
 import static org.junit.Assert.assertEquals;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
@@ -105,9 +103,23 @@
 
     public MetricsLogger mMetricsLogger = mock(MetricsLogger.class);
 
+    private boolean sendTronEvents;
+
     @Test
-    public void testAll() {
+    public void testAll_withTron() {
+        sendTronEvents = true;
+        checkAll();
+    }
+
+    @Test
+    public void testAll_noTron() {
+        sendTronEvents = false;
+        checkAll();
+    }
+
+    private void checkAll() {
         final BatterySavingStatsTestable target = new BatterySavingStatsTestable();
+        target.setSendTronLog(sendTronEvents);
 
         target.assertDumpable();
 
@@ -229,7 +241,7 @@
 
     private void assertLog(boolean batterySaver, boolean interactive, long deltaTimeMs,
             int deltaBatteryLevelUa, int deltaBatteryLevelPercent) {
-        if (SEND_TRON_EVENTS) {
+        if (sendTronEvents) {
             ArgumentCaptor<LogMaker> ac = ArgumentCaptor.forClass(LogMaker.class);
             verify(mMetricsLogger, times(1)).write(ac.capture());
 
@@ -251,9 +263,22 @@
         }
     }
 
+
     @Test
-    public void testMetricsLogger() {
+    public void testMetricsLogger_withTron() {
+        sendTronEvents = true;
+        checkMetricsLogger();
+    }
+
+    @Test
+    public void testMetricsLogger_noTron() {
+        sendTronEvents = false;
+        checkMetricsLogger();
+    }
+
+    private void checkMetricsLogger() {
         final BatterySavingStatsTestable target = new BatterySavingStatsTestable();
+        target.setSendTronLog(sendTronEvents);
 
         target.advanceClock(1);
         target.drainBattery(1000);
diff --git a/services/tests/servicestests/src/com/android/server/wm/SurfaceAnimationRunnerTest.java b/services/tests/servicestests/src/com/android/server/wm/SurfaceAnimationRunnerTest.java
index b36c7d9..edac8a5 100644
--- a/services/tests/servicestests/src/com/android/server/wm/SurfaceAnimationRunnerTest.java
+++ b/services/tests/servicestests/src/com/android/server/wm/SurfaceAnimationRunnerTest.java
@@ -169,6 +169,7 @@
         verify(mMockAnimationSpec, atLeastOnce()).apply(any(), any(), eq(0L));
     }
 
+    @FlakyTest(bugId = 74780584)
     @Test
     public void testDeferStartingAnimations() throws Exception {
         mSurfaceAnimationRunner.deferStartingAnimations();
diff --git a/telephony/java/android/telephony/LocationAccessPolicy.java b/telephony/java/android/telephony/LocationAccessPolicy.java
index 26ffe32..6480aab 100644
--- a/telephony/java/android/telephony/LocationAccessPolicy.java
+++ b/telephony/java/android/telephony/LocationAccessPolicy.java
@@ -21,31 +21,25 @@
 import android.annotation.UserIdInt;
 import android.app.ActivityManager;
 import android.app.AppOpsManager;
-import android.content.BroadcastReceiver;
 import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
 import android.content.pm.PackageManager;
 import android.content.pm.UserInfo;
 import android.location.LocationManager;
 import android.os.Binder;
-import android.os.Build;
 import android.os.Process;
 import android.os.Trace;
 import android.os.UserHandle;
 import android.os.UserManager;
-import android.provider.Settings;
-import android.util.SparseBooleanArray;
+import android.util.Log;
 
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 /**
  * Helper for performing location access checks.
  * @hide
  */
 public final class LocationAccessPolicy {
+    private static final String LOG_TAG = LocationAccessPolicy.class.getSimpleName();
     /**
      * API to determine if the caller has permissions to get cell location.
      *
@@ -94,10 +88,12 @@
     }
 
     private static boolean isLocationModeEnabled(@NonNull Context context, @UserIdInt int userId) {
-        int locationMode = Settings.Secure.getIntForUser(context.getContentResolver(),
-                Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF, userId);
-        return locationMode != Settings.Secure.LOCATION_MODE_OFF
-                && locationMode != Settings.Secure.LOCATION_MODE_SENSORS_ONLY;
+        LocationManager locationManager = context.getSystemService(LocationManager.class);
+        if (locationManager == null) {
+            Log.w(LOG_TAG, "Couldn't get location manager, denying location access");
+            return false;
+        }
+        return locationManager.isLocationEnabledForUser(UserHandle.of(userId));
     }
 
     private static boolean checkInteractAcrossUsersFull(@NonNull Context context) {
diff --git a/tools/incident_section_gen/main.cpp b/tools/incident_section_gen/main.cpp
index 8219150..7e922e6 100644
--- a/tools/incident_section_gen/main.cpp
+++ b/tools/incident_section_gen/main.cpp
@@ -427,6 +427,7 @@
                 printf("    new GZipSection(%d,", field->number());
                 splitAndPrint(s.args());
                 printf(" NULL),\n");
+                break;
             case SECTION_TOMBSTONE:
                 printf("    new TombstoneSection(%d, \"%s\"),\n", field->number(), s.args().c_str());
                 break;