Merge "MediaPlayer2Impl: fix null object reference." into pi-dev
diff --git a/api/current.txt b/api/current.txt
index 8321c18..59e7c46 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 {
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/config/hiddenapi-light-greylist.txt b/config/hiddenapi-light-greylist.txt
index 06e108c..99d871e 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;
@@ -232,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;
@@ -311,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;
@@ -347,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;
@@ -356,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;
@@ -393,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
@@ -406,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
@@ -636,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;
@@ -785,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
@@ -845,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
@@ -852,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
@@ -906,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
@@ -966,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
@@ -978,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;
@@ -1055,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;
@@ -1119,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
@@ -1232,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
@@ -1250,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;
@@ -1308,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;
@@ -1581,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;
@@ -1603,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
@@ -1923,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
@@ -2307,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
@@ -2314,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
@@ -2606,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/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>
- * <receiver name="..." android:permission="android.permission.BIND_DEVICE_ADMIN">
- * <meta-data
- * android:name="android.app.device_admin"
- * android:resource="@xml/..." />
- * <meta-data
- * android:name="android.app.support_transfer_ownership"
- * android:value="true" />
- * </receiver>
- * </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><support-transfer-ownership /></code> tag inside the
+ * <code><device-admin></device-admin></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/SliceSpec.java b/core/java/android/app/slice/SliceSpec.java
index 03ffe6d..8cc0384 100644
--- a/core/java/android/app/slice/SliceSpec.java
+++ b/core/java/android/app/slice/SliceSpec.java
@@ -89,7 +89,7 @@
*
* @param candidate candidate format of data.
* @return true if versions are compatible.
- * @see androidx.slice.widget.SliceView
+ * @see androidx.app.slice.widget.SliceView
*/
public boolean canRender(@NonNull SliceSpec candidate) {
if (!mType.equals(candidate.mType)) return false;
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><appwidget-provider></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/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/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/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/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..0a56ef7 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 > Network & internet > Mobile networks > 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>
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 3e9a25e..182f661 100644
--- a/media/OWNERS
+++ b/media/OWNERS
@@ -5,3 +5,5 @@
sungsoo@google.com
wjia@google.com
jaewan@google.com
+chz@google.com
+
diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java
index 3d5f6bc..8a742b7 100644
--- a/media/java/android/media/MediaCodec.java
+++ b/media/java/android/media/MediaCodec.java
@@ -1602,7 +1602,9 @@
private EventHandler mCallbackHandler;
private Callback mCallback;
private OnFrameRenderedListener mOnFrameRenderedListener;
- private Object mListenerLock = new Object();
+ private final Object mListenerLock = new Object();
+ private MediaCodecInfo mCodecInfo;
+ private final Object mCodecInfoLock = new Object();
private static final int EVENT_CALLBACK = 1;
private static final int EVENT_SET_CALLBACK = 2;
@@ -3469,10 +3471,26 @@
*/
@NonNull
public MediaCodecInfo getCodecInfo() {
- return MediaCodecList.getInfoFor(getName());
+ // Get the codec name first. If the codec is already released,
+ // IllegalStateException will be thrown here.
+ String name = getName();
+ synchronized (mCodecInfoLock) {
+ if (mCodecInfo == null) {
+ // Get the codec info for this codec itself first. Only initialize
+ // the full codec list if this somehow fails because it can be slow.
+ mCodecInfo = getOwnCodecInfo();
+ if (mCodecInfo == null) {
+ mCodecInfo = MediaCodecList.getInfoFor(name);
+ }
+ }
+ return mCodecInfo;
+ }
}
@NonNull
+ private native final MediaCodecInfo getOwnCodecInfo();
+
+ @NonNull
private native final ByteBuffer[] getBuffers(boolean input);
@Nullable
diff --git a/media/java/android/media/MediaCodecInfo.java b/media/java/android/media/MediaCodecInfo.java
index 3dd6879..2a601f9 100644
--- a/media/java/android/media/MediaCodecInfo.java
+++ b/media/java/android/media/MediaCodecInfo.java
@@ -829,14 +829,24 @@
/** @hide */
public CodecCapabilities dup() {
- return new CodecCapabilities(
- // clone writable arrays
- Arrays.copyOf(profileLevels, profileLevels.length),
- Arrays.copyOf(colorFormats, colorFormats.length),
- isEncoder(),
- mFlagsVerified,
- mDefaultFormat,
- mCapabilitiesInfo);
+ CodecCapabilities caps = new CodecCapabilities();
+
+ // profileLevels and colorFormats may be modified by client.
+ caps.profileLevels = Arrays.copyOf(profileLevels, profileLevels.length);
+ caps.colorFormats = Arrays.copyOf(colorFormats, colorFormats.length);
+
+ caps.mMime = mMime;
+ caps.mMaxSupportedInstances = mMaxSupportedInstances;
+ caps.mFlagsRequired = mFlagsRequired;
+ caps.mFlagsSupported = mFlagsSupported;
+ caps.mFlagsVerified = mFlagsVerified;
+ caps.mAudioCaps = mAudioCaps;
+ caps.mVideoCaps = mVideoCaps;
+ caps.mEncoderCaps = mEncoderCaps;
+ caps.mDefaultFormat = mDefaultFormat;
+ caps.mCapabilitiesInfo = mCapabilitiesInfo;
+
+ return caps;
}
/**
@@ -898,13 +908,13 @@
if (mMime.toLowerCase().startsWith("audio/")) {
mAudioCaps = AudioCapabilities.create(info, this);
- mAudioCaps.setDefaultFormat(mDefaultFormat);
+ mAudioCaps.getDefaultFormat(mDefaultFormat);
} else if (mMime.toLowerCase().startsWith("video/")) {
mVideoCaps = VideoCapabilities.create(info, this);
}
if (encoder) {
mEncoderCaps = EncoderCapabilities.create(info, this);
- mEncoderCaps.setDefaultFormat(mDefaultFormat);
+ mEncoderCaps.getDefaultFormat(mDefaultFormat);
}
final Map<String, Object> global = MediaCodecList.getGlobalSettings();
@@ -990,8 +1000,7 @@
return caps;
}
- /** @hide */
- public void init(MediaFormat info, CodecCapabilities parent) {
+ private void init(MediaFormat info, CodecCapabilities parent) {
mParent = parent;
initWithPlatformLimits();
applyLevelLimits();
@@ -1171,7 +1180,7 @@
}
/** @hide */
- public void setDefaultFormat(MediaFormat format) {
+ public void getDefaultFormat(MediaFormat format) {
// report settings that have only a single choice
if (mBitrateRange.getLower().equals(mBitrateRange.getUpper())) {
format.setInteger(MediaFormat.KEY_BIT_RATE, mBitrateRange.getLower());
@@ -1585,8 +1594,7 @@
return caps;
}
- /** @hide */
- public void init(MediaFormat info, CodecCapabilities parent) {
+ private void init(MediaFormat info, CodecCapabilities parent) {
mParent = parent;
initWithPlatformLimits();
applyLevelLimits();
@@ -2707,8 +2715,7 @@
return caps;
}
- /** @hide */
- public void init(MediaFormat info, CodecCapabilities parent) {
+ private void init(MediaFormat info, CodecCapabilities parent) {
// no support for complexity or quality yet
mParent = parent;
mComplexityRange = Range.create(0, 0);
@@ -2789,7 +2796,7 @@
}
/** @hide */
- public void setDefaultFormat(MediaFormat format) {
+ public void getDefaultFormat(MediaFormat format) {
// don't list trivial quality/complexity as default for now
if (!mQualityRange.getUpper().equals(mQualityRange.getLower())
&& mDefaultQuality != null) {
diff --git a/media/jni/android_media_MediaCodec.cpp b/media/jni/android_media_MediaCodec.cpp
index a1022c0..000317e 100644
--- a/media/jni/android_media_MediaCodec.cpp
+++ b/media/jni/android_media_MediaCodec.cpp
@@ -29,6 +29,7 @@
#include "android_util_Binder.h"
#include "jni.h"
#include <nativehelper/JNIHelp.h>
+#include <nativehelper/ScopedLocalRef.h>
#include <android/hardware/cas/native/1.0/IDescrambler.h>
@@ -98,6 +99,13 @@
jint AesCbc;
} gCryptoModes;
+static struct {
+ jclass capsClazz;
+ jmethodID capsCtorId;
+ jclass profileLevelClazz;
+ jfieldID profileField;
+ jfieldID levelField;
+} gCodecInfo;
struct fields_t {
jfieldID context;
@@ -625,6 +633,103 @@
return OK;
}
+static jobject getCodecCapabilitiesObject(
+ JNIEnv *env, const char *mime, bool isEncoder,
+ const sp<MediaCodecInfo::Capabilities> &capabilities) {
+ Vector<MediaCodecInfo::ProfileLevel> profileLevels;
+ Vector<uint32_t> colorFormats;
+
+ sp<AMessage> defaultFormat = new AMessage();
+ defaultFormat->setString("mime", mime);
+
+ capabilities->getSupportedColorFormats(&colorFormats);
+ capabilities->getSupportedProfileLevels(&profileLevels);
+ uint32_t flags = capabilities->getFlags();
+ sp<AMessage> details = capabilities->getDetails();
+
+ jobject defaultFormatObj = NULL;
+ if (ConvertMessageToMap(env, defaultFormat, &defaultFormatObj)) {
+ return NULL;
+ }
+ ScopedLocalRef<jobject> defaultFormatRef(env, defaultFormatObj);
+
+ jobject detailsObj = NULL;
+ if (ConvertMessageToMap(env, details, &detailsObj)) {
+ return NULL;
+ }
+ ScopedLocalRef<jobject> detailsRef(env, detailsObj);
+
+ ScopedLocalRef<jobjectArray> profileLevelArray(env, env->NewObjectArray(
+ profileLevels.size(), gCodecInfo.profileLevelClazz, NULL));
+
+ for (size_t i = 0; i < profileLevels.size(); ++i) {
+ const MediaCodecInfo::ProfileLevel &src = profileLevels.itemAt(i);
+
+ ScopedLocalRef<jobject> srcRef(env, env->AllocObject(
+ gCodecInfo.profileLevelClazz));
+
+ env->SetIntField(srcRef.get(), gCodecInfo.profileField, src.mProfile);
+ env->SetIntField(srcRef.get(), gCodecInfo.levelField, src.mLevel);
+
+ env->SetObjectArrayElement(profileLevelArray.get(), i, srcRef.get());
+ }
+
+ ScopedLocalRef<jintArray> colorFormatsArray(
+ env, env->NewIntArray(colorFormats.size()));
+ for (size_t i = 0; i < colorFormats.size(); ++i) {
+ jint val = colorFormats.itemAt(i);
+ env->SetIntArrayRegion(colorFormatsArray.get(), i, 1, &val);
+ }
+
+ return env->NewObject(
+ gCodecInfo.capsClazz, gCodecInfo.capsCtorId,
+ profileLevelArray.get(), colorFormatsArray.get(), isEncoder, flags,
+ defaultFormatRef.get(), detailsRef.get());
+}
+
+status_t JMediaCodec::getCodecInfo(JNIEnv *env, jobject *codecInfoObject) const {
+ sp<MediaCodecInfo> codecInfo;
+
+ status_t err = mCodec->getCodecInfo(&codecInfo);
+
+ if (err != OK) {
+ return err;
+ }
+
+ ScopedLocalRef<jstring> nameObject(env,
+ env->NewStringUTF(codecInfo->getCodecName()));
+
+ bool isEncoder = codecInfo->isEncoder();
+
+ Vector<AString> mimes;
+ codecInfo->getSupportedMimes(&mimes);
+
+ ScopedLocalRef<jobjectArray> capsArrayObj(env,
+ env->NewObjectArray(mimes.size(), gCodecInfo.capsClazz, NULL));
+
+ for (size_t i = 0; i < mimes.size(); i++) {
+ const sp<MediaCodecInfo::Capabilities> caps =
+ codecInfo->getCapabilitiesFor(mimes[i].c_str());
+
+ ScopedLocalRef<jobject> capsObj(env, getCodecCapabilitiesObject(
+ env, mimes[i].c_str(), isEncoder, caps));
+
+ env->SetObjectArrayElement(capsArrayObj.get(), i, capsObj.get());
+ }
+
+ ScopedLocalRef<jclass> codecInfoClazz(env,
+ env->FindClass("android/media/MediaCodecInfo"));
+ CHECK(codecInfoClazz.get() != NULL);
+
+ jmethodID codecInfoCtorID = env->GetMethodID(codecInfoClazz.get(), "<init>",
+ "(Ljava/lang/String;Z[Landroid/media/MediaCodecInfo$CodecCapabilities;)V");
+
+ *codecInfoObject = env->NewObject(codecInfoClazz.get(), codecInfoCtorID,
+ nameObject.get(), isEncoder, capsArrayObj.get());
+
+ return OK;
+}
+
status_t JMediaCodec::getMetrics(JNIEnv *, MediaAnalyticsItem * &reply) const {
status_t status = mCodec->getMetrics(reply);
@@ -1665,6 +1770,29 @@
return NULL;
}
+static jobject android_media_MediaCodec_getOwnCodecInfo(
+ JNIEnv *env, jobject thiz) {
+ ALOGV("android_media_MediaCodec_getOwnCodecInfo");
+
+ sp<JMediaCodec> codec = getMediaCodec(env, thiz);
+
+ if (codec == NULL) {
+ throwExceptionAsNecessary(env, INVALID_OPERATION);
+ return NULL;
+ }
+
+ jobject codecInfoObj;
+ status_t err = codec->getCodecInfo(env, &codecInfoObj);
+
+ if (err == OK) {
+ return codecInfoObj;
+ }
+
+ throwExceptionAsNecessary(env, err);
+
+ return NULL;
+}
+
static jobject
android_media_MediaCodec_native_getMetrics(JNIEnv *env, jobject thiz)
{
@@ -1877,6 +2005,28 @@
field = env->GetFieldID(clazz.get(), "mPersistentObject", "J");
CHECK(field != NULL);
gPersistentSurfaceClassInfo.mPersistentObject = field;
+
+ clazz.reset(env->FindClass("android/media/MediaCodecInfo$CodecCapabilities"));
+ CHECK(clazz.get() != NULL);
+ gCodecInfo.capsClazz = (jclass)env->NewGlobalRef(clazz.get());
+
+ method = env->GetMethodID(clazz.get(), "<init>",
+ "([Landroid/media/MediaCodecInfo$CodecProfileLevel;[IZI"
+ "Ljava/util/Map;Ljava/util/Map;)V");
+ CHECK(method != NULL);
+ gCodecInfo.capsCtorId = method;
+
+ clazz.reset(env->FindClass("android/media/MediaCodecInfo$CodecProfileLevel"));
+ CHECK(clazz.get() != NULL);
+ gCodecInfo.profileLevelClazz = (jclass)env->NewGlobalRef(clazz.get());
+
+ field = env->GetFieldID(clazz.get(), "profile", "I");
+ CHECK(field != NULL);
+ gCodecInfo.profileField = field;
+
+ field = env->GetFieldID(clazz.get(), "level", "I");
+ CHECK(field != NULL);
+ gCodecInfo.levelField = field;
}
static void android_media_MediaCodec_native_setup(
@@ -2002,6 +2152,9 @@
{ "getName", "()Ljava/lang/String;",
(void *)android_media_MediaCodec_getName },
+ { "getOwnCodecInfo", "()Landroid/media/MediaCodecInfo;",
+ (void *)android_media_MediaCodec_getOwnCodecInfo },
+
{ "native_getMetrics", "()Landroid/os/PersistableBundle;",
(void *)android_media_MediaCodec_native_getMetrics},
diff --git a/media/jni/android_media_MediaCodec.h b/media/jni/android_media_MediaCodec.h
index 2ec8703..985f55a 100644
--- a/media/jni/android_media_MediaCodec.h
+++ b/media/jni/android_media_MediaCodec.h
@@ -120,6 +120,8 @@
status_t getName(JNIEnv *env, jstring *name) const;
+ status_t getCodecInfo(JNIEnv *env, jobject *codecInfo) const;
+
status_t getMetrics(JNIEnv *env, MediaAnalyticsItem * &reply) const;
status_t setParameters(const sp<AMessage> ¶ms);
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/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..60129e6 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -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/KeyguardSliceView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSliceView.java
index 10ba7f6..08b4fee 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSliceView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSliceView.java
@@ -47,12 +47,12 @@
import java.util.List;
import java.util.function.Consumer;
-import androidx.slice.Slice;
-import androidx.slice.SliceItem;
-import androidx.slice.core.SliceQuery;
-import androidx.slice.widget.ListContent;
-import androidx.slice.widget.RowContent;
-import androidx.slice.widget.SliceLiveData;
+import androidx.app.slice.Slice;
+import androidx.app.slice.SliceItem;
+import androidx.app.slice.core.SliceQuery;
+import androidx.app.slice.widget.ListContent;
+import androidx.app.slice.widget.RowContent;
+import androidx.app.slice.widget.SliceLiveData;
/**
* View visible under the clock on the lock screen and AoD.
@@ -117,7 +117,7 @@
private void showSlice(Slice slice) {
- ListContent lc = new ListContent(getContext(), slice);
+ ListContent lc = new ListContent(slice);
mHasHeader = lc.hasHeader();
List<SliceItem> subItems = lc.getRowItems();
if (!mHasHeader) {
@@ -125,8 +125,7 @@
} else {
mTitle.setVisibility(VISIBLE);
// If there's a header it'll be the first subitem
- RowContent header = new RowContent(getContext(), subItems.get(0),
- true /* showStartItem */);
+ RowContent header = new RowContent(subItems.get(0), true /* showStartItem */);
SliceItem mainTitle = header.getTitleItem();
CharSequence title = mainTitle != null ? mainTitle.getText() : null;
mTitle.setText(title);
@@ -150,7 +149,7 @@
final int startIndex = mHasHeader ? 1 : 0; // First item is header; skip it
for (int i = startIndex; i < subItemsCount; i++) {
SliceItem item = subItems.get(i);
- RowContent rc = new RowContent(getContext(), item, true /* showStartItem */);
+ RowContent rc = new RowContent(item, true /* showStartItem */);
final Uri itemTag = item.getSlice().getUri();
// Try to reuse the view if already exists in the layout
KeyguardSliceButton button = mRow.findViewWithTag(itemTag);
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/keyguard/KeyguardSliceProvider.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardSliceProvider.java
index d81b32b..26618bf 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardSliceProvider.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardSliceProvider.java
@@ -40,10 +40,10 @@
import java.util.Locale;
import java.util.concurrent.TimeUnit;
-import androidx.slice.Slice;
-import androidx.slice.SliceProvider;
-import androidx.slice.builders.ListBuilder;
-import androidx.slice.builders.ListBuilder.RowBuilder;
+import androidx.app.slice.Slice;
+import androidx.app.slice.SliceProvider;
+import androidx.app.slice.builders.ListBuilder;
+import androidx.app.slice.builders.ListBuilder.RowBuilder;
/**
* Simple Slice provider that shows the current date.
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/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
index c5781d9..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;
@@ -396,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.
@@ -405,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/tests/src/com/android/systemui/keyguard/KeyguardSliceProviderTest.java b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardSliceProviderTest.java
index 5812da2..b6116e0 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardSliceProviderTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardSliceProviderTest.java
@@ -21,7 +21,7 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
-import androidx.slice.Slice;
+import androidx.app.slice.Slice;
import android.app.AlarmManager;
import android.content.ContentResolver;
@@ -45,10 +45,10 @@
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
-import androidx.slice.SliceItem;
-import androidx.slice.SliceProvider;
-import androidx.slice.SliceSpecs;
-import androidx.slice.core.SliceQuery;
+import androidx.app.slice.SliceItem;
+import androidx.app.slice.SliceProvider;
+import androidx.app.slice.SliceSpecs;
+import androidx.app.slice.core.SliceQuery;
@SmallTest
@RunWith(AndroidTestingRunner.class)
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/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 96633da..31ae472 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;
@@ -13727,9 +13728,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
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/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 5430d44..f4360e4 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -4087,14 +4087,24 @@
@Nullable ComponentName component, @ComponentType int type) {
if (type == TYPE_ACTIVITY) {
final PackageParser.Activity activity = mActivities.mActivities.get(component);
- return activity != null
- ? (activity.info.flags & ActivityInfo.FLAG_VISIBLE_TO_INSTANT_APP) != 0
- : false;
+ if (activity == null) {
+ return false;
+ }
+ final boolean visibleToInstantApp =
+ (activity.info.flags & ActivityInfo.FLAG_VISIBLE_TO_INSTANT_APP) != 0;
+ final boolean explicitlyVisibleToInstantApp =
+ (activity.info.flags & ActivityInfo.FLAG_IMPLICITLY_VISIBLE_TO_INSTANT_APP) == 0;
+ return visibleToInstantApp && explicitlyVisibleToInstantApp;
} else if (type == TYPE_RECEIVER) {
final PackageParser.Activity activity = mReceivers.mActivities.get(component);
- return activity != null
- ? (activity.info.flags & ActivityInfo.FLAG_VISIBLE_TO_INSTANT_APP) != 0
- : false;
+ if (activity == null) {
+ return false;
+ }
+ final boolean visibleToInstantApp =
+ (activity.info.flags & ActivityInfo.FLAG_VISIBLE_TO_INSTANT_APP) != 0;
+ final boolean explicitlyVisibleToInstantApp =
+ (activity.info.flags & ActivityInfo.FLAG_IMPLICITLY_VISIBLE_TO_INSTANT_APP) == 0;
+ return visibleToInstantApp && !explicitlyVisibleToInstantApp;
} else if (type == TYPE_SERVICE) {
final PackageParser.Service service = mServices.mServices.get(component);
return service != null
@@ -4139,6 +4149,10 @@
return false;
}
if (callerIsInstantApp) {
+ // both caller and target are both instant, but, different applications, filter
+ if (ps.getInstantApp(userId)) {
+ return true;
+ }
// request for a specific component; if it hasn't been explicitly exposed through
// property or instrumentation target, filter
if (component != null) {
@@ -4151,7 +4165,7 @@
return !isComponentVisibleToInstantApp(component, componentType);
}
// request for application; if no components have been explicitly exposed, filter
- return ps.getInstantApp(userId) || !ps.pkg.visibleToInstantApps;
+ return !ps.pkg.visibleToInstantApps;
}
if (ps.getInstantApp(userId)) {
// caller can see all components of all instant applications, don't filter
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/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/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/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;