diff options
68 files changed, 885 insertions, 179 deletions
diff --git a/Android.bp b/Android.bp index c568d3676916..34162d1fcc1d 100644 --- a/Android.bp +++ b/Android.bp @@ -732,6 +732,7 @@ java_defaults { "android.hardware.radio-V1.4-java", "android.hardware.usb.gadget-V1.0-java", "netd_aidl_interface-java", + "devicepolicyprotosnano", ], required: [ diff --git a/cmds/incidentd/Android.bp b/cmds/incidentd/Android.bp index 1e970f46b01d..40da583e4f6c 100644 --- a/cmds/incidentd/Android.bp +++ b/cmds/incidentd/Android.bp @@ -53,6 +53,7 @@ cc_binary { "libprotoutil", "libservices", "libutils", + "libprotobuf-cpp-lite", ], init_rc: ["incidentd.rc"], diff --git a/cmds/incidentd/src/FdBuffer.cpp b/cmds/incidentd/src/FdBuffer.cpp index a8ef8311720d..74cda1da7216 100644 --- a/cmds/incidentd/src/FdBuffer.cpp +++ b/cmds/incidentd/src/FdBuffer.cpp @@ -47,9 +47,13 @@ status_t FdBuffer::read(int fd, int64_t timeout) { while (true) { if (mBuffer.size() >= MAX_BUFFER_COUNT * BUFFER_SIZE) { mTruncated = true; + VLOG("Truncating data"); break; } - if (mBuffer.writeBuffer() == NULL) return NO_MEMORY; + if (mBuffer.writeBuffer() == NULL) { + VLOG("No memory"); + return NO_MEMORY; + } int64_t remainingTime = (mStartTime + timeout) - uptimeMillis(); if (remainingTime <= 0) { @@ -58,7 +62,7 @@ status_t FdBuffer::read(int fd, int64_t timeout) { break; } - int count = poll(&pfds, 1, remainingTime); + int count = TEMP_FAILURE_RETRY(poll(&pfds, 1, remainingTime)); if (count == 0) { VLOG("timed out due to block calling poll"); mTimedOut = true; @@ -102,7 +106,10 @@ status_t FdBuffer::readFully(int fd) { VLOG("Truncating data"); break; } - if (mBuffer.writeBuffer() == NULL) return NO_MEMORY; + if (mBuffer.writeBuffer() == NULL) { + VLOG("No memory"); + return NO_MEMORY; + } ssize_t amt = TEMP_FAILURE_RETRY(::read(fd, mBuffer.writeBuffer(), mBuffer.currentToWrite())); @@ -144,10 +151,14 @@ status_t FdBuffer::readProcessedDataInStream(int fd, unique_fd toFd, unique_fd f // This is the buffer used to store processed data while (true) { if (mBuffer.size() >= MAX_BUFFER_COUNT * BUFFER_SIZE) { + VLOG("Truncating data"); mTruncated = true; break; } - if (mBuffer.writeBuffer() == NULL) return NO_MEMORY; + if (mBuffer.writeBuffer() == NULL) { + VLOG("No memory"); + return NO_MEMORY; + } int64_t remainingTime = (mStartTime + timeoutMs) - uptimeMillis(); if (remainingTime <= 0) { @@ -157,7 +168,7 @@ status_t FdBuffer::readProcessedDataInStream(int fd, unique_fd toFd, unique_fd f } // wait for any pfds to be ready to perform IO - int count = poll(pfds, 3, remainingTime); + int count = TEMP_FAILURE_RETRY(poll(pfds, 3, remainingTime)); if (count == 0) { VLOG("timed out due to block calling poll"); mTimedOut = true; diff --git a/cmds/incidentd/src/IncidentService.cpp b/cmds/incidentd/src/IncidentService.cpp index b23c1eda87b3..3d892adcb195 100644 --- a/cmds/incidentd/src/IncidentService.cpp +++ b/cmds/incidentd/src/IncidentService.cpp @@ -42,13 +42,11 @@ enum { WHAT_RUN_REPORT = 1, WHAT_SEND_BACKLOG_TO_DROPBOX = 2 }; #define DEFAULT_BYTES_SIZE_LIMIT (20 * 1024 * 1024) // 20MB #define DEFAULT_REFACTORY_PERIOD_MS (24 * 60 * 60 * 1000) // 1 Day -// Skip logs (1100 - 1108) because they are already in the bug report -// Skip 1200, 1201, 1202, 3018 because they take too long -// TODO(120079956): Skip 3008, 3015 because of error +// Skip these sections for dumpstate only. Dumpstate allows 10s max for each service to dump. +// Skip logs (1100 - 1108) and traces (1200 - 1202) because they are already in the bug report. +// Skip 3018 because it takes too long. #define SKIPPED_SECTIONS { 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, /* Logs */ \ 1200, 1201, 1202, /* Native, hal, java traces */ \ - 3008, /* "package --proto" */ \ - 3015, /* "activity --proto processes" */ \ 3018 /* "meminfo -a --proto" */ } namespace android { diff --git a/cmds/incidentd/src/PrivacyBuffer.cpp b/cmds/incidentd/src/PrivacyBuffer.cpp index 7a8ebe394d51..6967e3391fb8 100644 --- a/cmds/incidentd/src/PrivacyBuffer.cpp +++ b/cmds/incidentd/src/PrivacyBuffer.cpp @@ -96,7 +96,12 @@ status_t PrivacyBuffer::stripField(const Privacy* parentPolicy, const PrivacySpe uint64_t token = mProto.start(encode_field_id(policy)); while (mData.rp()->pos() - start != msgSize) { status_t err = stripField(policy, spec, depth + 1); - if (err != NO_ERROR) return err; + if (err != NO_ERROR) { + VLOG("Bad value when stripping id %d, wiretype %d, tag %#x, depth %d, size %d, " + "relative pos %zu, ", fieldId, read_wire_type(fieldTag), fieldTag, depth, + msgSize, mData.rp()->pos() - start); + return err; + } } mProto.end(token); return NO_ERROR; @@ -117,9 +122,13 @@ status_t PrivacyBuffer::strip(const PrivacySpec& spec) { } while (mData.hasNext()) { status_t err = stripField(mPolicy, spec, 0); - if (err != NO_ERROR) return err; + if (err != NO_ERROR) return err; // Error logged in stripField. + } + if (mData.bytesRead() != mData.size()) { + VLOG("Buffer corrupted: expect %zu bytes, read %zu bytes", + mData.size(), mData.bytesRead()); + return BAD_VALUE; } - if (mData.bytesRead() != mData.size()) return BAD_VALUE; mSize = mProto.size(); mData.rp()->rewind(); // rewind the read pointer back to beginning after the strip. return NO_ERROR; diff --git a/cmds/incidentd/src/Reporter.cpp b/cmds/incidentd/src/Reporter.cpp index b3bab0cfb4dc..8f62da202606 100644 --- a/cmds/incidentd/src/Reporter.cpp +++ b/cmds/incidentd/src/Reporter.cpp @@ -129,6 +129,7 @@ Reporter::run_report_status_t Reporter::runReport(size_t* reportByteSize) { bool needMainFd = false; int mainFd = -1; int mainDest = -1; + int sectionCount = 0; HeaderSection headers; MetadataSection metadataSection; std::string buildType = android::base::GetProperty("ro.build.type", ""); @@ -180,12 +181,12 @@ Reporter::run_report_status_t Reporter::runReport(size_t* reportByteSize) { for (const Section** section = SECTION_LIST; *section; section++) { const int id = (*section)->id; if ((*section)->userdebugAndEngOnly && !isUserdebugOrEng) { - ALOGD("Skipping incident report section %d '%s' because it's limited to userdebug/eng", + VLOG("Skipping incident report section %d '%s' because it's limited to userdebug/eng", id, (*section)->name.string()); continue; } if (this->batch.containsSection(id)) { - ALOGD("Taking incident report section %d '%s'", id, (*section)->name.string()); + VLOG("Taking incident report section %d '%s'", id, (*section)->name.string()); for (ReportRequestSet::iterator it = batch.begin(); it != batch.end(); it++) { if ((*it)->listener != NULL && (*it)->args.containsSection(id)) { (*it)->listener->onReportSectionStatus( @@ -198,11 +199,12 @@ Reporter::run_report_status_t Reporter::runReport(size_t* reportByteSize) { int64_t startTime = uptimeMillis(); err = (*section)->Execute(&batch); int64_t endTime = uptimeMillis(); - stats->set_success(err == NO_ERROR); stats->set_exec_duration_ms(endTime - startTime); if (err != NO_ERROR) { ALOGW("Incident section %s (%d) failed: %s. Stopping report.", (*section)->name.string(), id, strerror(-err)); + // Execute() has already recorded this status. Only update if there's new failure. + stats->set_success(false); goto DONE; } (*reportByteSize) += stats->report_size_bytes(); @@ -214,11 +216,13 @@ Reporter::run_report_status_t Reporter::runReport(size_t* reportByteSize) { id, IIncidentReportStatusListener::STATUS_FINISHED); } } - ALOGD("Finish incident report section %d '%s'", id, (*section)->name.string()); + VLOG("Finish incident report section %d '%s'", id, (*section)->name.string()); + sectionCount++; } } DONE: + ALOGD("Incident reporting took %d sections.", sectionCount); // Reports the metdadata when taking the incident report. if (!isTest) metadataSection.Execute(&batch); diff --git a/cmds/incidentd/src/Section.cpp b/cmds/incidentd/src/Section.cpp index cd48af95d08a..10d226822331 100644 --- a/cmds/incidentd/src/Section.cpp +++ b/cmds/incidentd/src/Section.cpp @@ -75,6 +75,7 @@ static void write_section_stats(IncidentMetadata::SectionStats* stats, const FdB stats->set_dump_duration_ms(buffer.durationMs()); stats->set_timed_out(buffer.timedOut()); stats->set_is_truncated(buffer.truncated()); + stats->set_success(!buffer.timedOut() && !buffer.truncated()); } // Reads data from FdBuffer and writes it to the requests file descriptor. @@ -83,7 +84,8 @@ static status_t write_report_requests(const int id, const FdBuffer& buffer, status_t err = -EBADF; EncodedBuffer::iterator data = buffer.data(); PrivacyBuffer privacyBuffer(get_privacy_of_section(id), data); - int writeable = 0; + IncidentMetadata::SectionStats* stats = requests->sectionStats(id); + int nPassed = 0; // The streaming ones, group requests by spec in order to save unnecessary strip operations map<PrivacySpec, vector<sp<ReportRequest>>> requestsBySpec; @@ -99,7 +101,18 @@ static status_t write_report_requests(const int id, const FdBuffer& buffer, for (auto mit = requestsBySpec.begin(); mit != requestsBySpec.end(); mit++) { PrivacySpec spec = mit->first; err = privacyBuffer.strip(spec); - if (err != NO_ERROR) return err; // it means the privacyBuffer data is corrupted. + if (err != NO_ERROR) { + // Privacy Buffer is corrupted, probably due to an ill-formatted proto. This is a + // non-fatal error. The whole report is still valid. So just log the failure. + ALOGW("Failed to strip section %d with spec %d: %s", + id, spec.dest, strerror(-err)); + stats->set_success(false); + stats->set_error_msg("Failed to strip section: privacy buffer corrupted, probably " + "due to an ill-formatted proto"); + nPassed++; + continue; + } + if (privacyBuffer.size() == 0) continue; for (auto it = mit->second.begin(); it != mit->second.end(); it++) { @@ -114,7 +127,7 @@ static status_t write_report_requests(const int id, const FdBuffer& buffer, request->err = err; continue; } - writeable++; + nPassed++; VLOG("Section %d flushed %zu bytes to fd %d with spec %d", id, privacyBuffer.size(), request->fd, spec.dest); } @@ -125,7 +138,15 @@ static status_t write_report_requests(const int id, const FdBuffer& buffer, if (requests->mainFd() >= 0) { PrivacySpec spec = PrivacySpec::new_spec(requests->mainDest()); err = privacyBuffer.strip(spec); - if (err != NO_ERROR) return err; // the buffer data is corrupted. + if (err != NO_ERROR) { + ALOGW("Failed to strip section %d with spec %d for dropbox: %s", + id, spec.dest, strerror(-err)); + stats->set_success(false); + stats->set_error_msg("Failed to strip section: privacy buffer corrupted, probably " + "due to an ill-formatted proto"); + nPassed++; + goto DONE; + } if (privacyBuffer.size() == 0) goto DONE; err = write_section_header(requests->mainFd(), id, privacyBuffer.size()); @@ -138,7 +159,7 @@ static status_t write_report_requests(const int id, const FdBuffer& buffer, requests->setMainFd(-1); goto DONE; } - writeable++; + nPassed++; VLOG("Section %d flushed %zu bytes to dropbox %d with spec %d", id, privacyBuffer.size(), requests->mainFd(), spec.dest); // Reports bytes of the section uploaded via dropbox after filtering. @@ -147,7 +168,7 @@ static status_t write_report_requests(const int id, const FdBuffer& buffer, DONE: // only returns error if there is no fd to write to. - return writeable > 0 ? NO_ERROR : err; + return nPassed > 0 ? NO_ERROR : err; } // ================================================================================ @@ -213,6 +234,8 @@ status_t MetadataSection::Execute(ReportRequestSet* requests) const { stats.timed_out()); proto.write(FIELD_TYPE_BOOL | IncidentMetadata::SectionStats::kIsTruncatedFieldNumber, stats.is_truncated()); + proto.write(FIELD_TYPE_STRING | IncidentMetadata::SectionStats::kErrorMsgFieldNumber, + stats.error_msg()); proto.end(token); } @@ -439,8 +462,9 @@ status_t WorkerThreadSection::Execute(ReportRequestSet* requests) const { status_t err = NO_ERROR; pthread_t thread; pthread_attr_t attr; - bool timedOut = false; + bool workerDone = false; FdBuffer buffer; + IncidentMetadata::SectionStats* stats = requests->sectionStats(this->id); // Data shared between this thread and the worker thread. sp<WorkerThreadData> data = new WorkerThreadData(this); @@ -475,8 +499,7 @@ status_t WorkerThreadSection::Execute(ReportRequestSet* requests) const { // Loop reading until either the timeout or the worker side is done (i.e. eof). err = buffer.read(data->pipe.readFd().get(), this->timeoutMs); if (err != NO_ERROR) { - // TODO: Log this error into the incident report. - ALOGW("[%s] reader failed with error '%s'", this->name.string(), strerror(-err)); + ALOGE("[%s] reader failed with error '%s'", this->name.string(), strerror(-err)); } // Done with the read fd. The worker thread closes the write one so @@ -484,31 +507,32 @@ status_t WorkerThreadSection::Execute(ReportRequestSet* requests) const { 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. + // our possible error -- but it's more interesting anyway). If not, then we timed out. { unique_lock<mutex> lock(data->lock); - if (!data->workerDone) { - // We timed out - timedOut = true; - } else { - if (data->workerError != NO_ERROR) { - err = data->workerError; - // TODO: Log this error into the incident report. - ALOGW("[%s] worker failed with error '%s'", this->name.string(), strerror(-err)); - } + if (data->workerError != NO_ERROR) { + err = data->workerError; + ALOGE("[%s] worker failed with error '%s'", this->name.string(), strerror(-err)); } + workerDone = data->workerDone; } - write_section_stats(requests->sectionStats(this->id), buffer); - if (timedOut || buffer.timedOut()) { - ALOGW("[%s] timed out", this->name.string()); + write_section_stats(stats, buffer); + if (err != NO_ERROR) { + char errMsg[128]; + snprintf(errMsg, 128, "[%s] failed with error '%s'", + this->name.string(), strerror(-err)); + stats->set_success(false); + stats->set_error_msg(errMsg); return NO_ERROR; } - - // TODO: There was an error with the command or buffering. Report that. For now - // just exit with a log messasge. - if (err != NO_ERROR) { - ALOGW("[%s] failed with error '%s'", this->name.string(), strerror(-err)); + if (buffer.truncated()) { + ALOGW("[%s] too large, truncating", this->name.string()); + // Do not write a truncated section. It won't pass through the PrivacyBuffer. + return NO_ERROR; + } + if (!workerDone || buffer.timedOut()) { + ALOGW("[%s] timed out", this->name.string()); return NO_ERROR; } @@ -617,14 +641,8 @@ status_t DumpsysSection::BlockingCall(int pipeWriteFd) const { sp<IBinder> service = defaultServiceManager()->checkService(mService); if (service == NULL) { - // Returning an error interrupts the entire incident report, so just - // log the failure. - // TODO: have a meta record inside the report that would log this - // failure inside the report, because the fact that we can't find - // the service is good data in and of itself. This is running in - // another thread so lock that carefully... ALOGW("DumpsysSection: Can't lookup service: %s", String8(mService).string()); - return NO_ERROR; + return NAME_NOT_FOUND; } service->dump(pipeWriteFd, mArgs); diff --git a/core/java/android/app/admin/DevicePolicyEventLogger.java b/core/java/android/app/admin/DevicePolicyEventLogger.java new file mode 100644 index 000000000000..f39a5f4480a8 --- /dev/null +++ b/core/java/android/app/admin/DevicePolicyEventLogger.java @@ -0,0 +1,209 @@ +/* + * 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.stats.devicepolicy.nano.StringList; +import android.util.StatsLog; + +import com.android.framework.protobuf.nano.MessageNano; +import com.android.internal.annotations.VisibleForTesting; +import com.android.internal.util.Preconditions; + +/** + * A wrapper for logging managed device events using {@link StatsLog}. + * <p/> + * This class allows chaining - each of its methods returns a reference to the current instance. + * <p/> + * Example usage: + * <code><pre> + * import android.stats.devicepolicy.DevicePolicyEnums; + * + * DevicePolicyEventLogger + * .createEvent(DevicePolicyEnums.USER_RESTRICTION_CHANGED) + * .setAdminPackageName(who) + * .setString(key) + * .setBoolean(enabledFromThisOwner) + * .write(); + * </pre></code> + * + * @see StatsLog + * @hide + */ +public final class DevicePolicyEventLogger { + private final int mEventId; + private int mIntValue; + private boolean mBooleanValue; + private long mTimePeriodMs; + private String[] mStringArrayValue; + private String mAdminPackageName; + + private DevicePolicyEventLogger(int eventId) { + mEventId = eventId; + } + + /** + * Creates a new {@link DevicePolicyEventLogger} instance for the specified + * <code>eventId</code>. + * + * @param eventId one of {@link android.stats.devicepolicy.DevicePolicyEnums} as defined in + * <code>core/proto/android/stats/devicepolicy/device_policy_enums.proto</code> + */ + public static DevicePolicyEventLogger createEvent(int eventId) { + return new DevicePolicyEventLogger(eventId); + } + + /** + * Returns the event id. + */ + @VisibleForTesting + public int getEventId() { + return mEventId; + } + + /** + * Sets a generic <code>int</code> value. + */ + public DevicePolicyEventLogger setInt(int value) { + mIntValue = value; + return this; + } + + /** + * Returns the generic <code>int</code> value. + */ + @VisibleForTesting + public int getInt() { + return mIntValue; + } + + /** + * Sets a generic <code>boolean</code> value. + */ + public DevicePolicyEventLogger setBoolean(boolean value) { + mBooleanValue = value; + return this; + } + + /** + * Returns the generic <code>boolean</code> value. + */ + @VisibleForTesting + public boolean getBoolean() { + return mBooleanValue; + } + + /** + * Sets a time period in milliseconds. + */ + public DevicePolicyEventLogger setTimePeriod(long timePeriodMillis) { + mTimePeriodMs = timePeriodMillis; + return this; + } + + /** + * Returns the time period in milliseconds. + */ + @VisibleForTesting + public long getTimePeriod() { + return mTimePeriodMs; + } + + /** + * Sets generic <code>String</code> values. + */ + public DevicePolicyEventLogger setStrings(String... values) { + mStringArrayValue = values; + return this; + } + + /** + * Sets generic <code>String</code> values. + * <p/> + * {@link #write()} logs the concatenation of <code>value</code> and <code>values</code>, + * in that order. + */ + public DevicePolicyEventLogger setStrings(String value, String[] values) { + Preconditions.checkNotNull(values, "values parameter cannot be null"); + mStringArrayValue = new String[values.length + 1]; + mStringArrayValue[0] = value; + System.arraycopy(values, 0, mStringArrayValue, 1, values.length); + return this; + } + + /** + * Sets generic <code>String</code> values. + * <p/> + * {@link #write()} logs the concatenation of <code>value1</code>, <code>value2</code> + * and <code>values</code>, in that order. + */ + public DevicePolicyEventLogger setStrings(String value1, String value2, String[] values) { + Preconditions.checkNotNull(values, "values parameter cannot be null"); + mStringArrayValue = new String[values.length + 2]; + mStringArrayValue[0] = value1; + mStringArrayValue[1] = value2; + System.arraycopy(values, 0, mStringArrayValue, 2, values.length); + return this; + } + + /** + * Returns the generic <code>String[]</code> value. + */ + @VisibleForTesting + public String[] getStringArray() { + return mStringArrayValue; + } + + /** + * Sets the package name of the admin application. + */ + public DevicePolicyEventLogger setAdminPackageName(String packageName) { + mAdminPackageName = packageName; + return this; + } + + /** + * Returns the package name of the admin application. + */ + @VisibleForTesting + public String getAdminPackageName() { + return mAdminPackageName; + } + + /** + * Writes the metric to {@link StatsLog}. + */ + public void write() { + byte[] bytes = stringArrayValueToBytes(mStringArrayValue); + StatsLog.write(StatsLog.DEVICE_POLICY_EVENT, mEventId, mAdminPackageName, mIntValue, + mBooleanValue, mTimePeriodMs, bytes); + } + + /** + * Converts the <code>String[] array</code> to <code>byte[]</code>. + * <p/> + * We can't log <code>String[]</code> using {@link StatsLog}. The convention is to assign + * the array to a proto object and convert it to <code>byte[]</code>. + */ + private static byte[] stringArrayValueToBytes(String[] array) { + if (array == null) { + return null; + } + StringList stringList = new StringList(); + stringList.stringValue = array; + return MessageNano.toByteArray(stringList); + } +} diff --git a/core/proto/android/app/settings_enums.proto b/core/proto/android/app/settings_enums.proto index 3a908dc28e4c..8e4eb0018999 100644 --- a/core/proto/android/app/settings_enums.proto +++ b/core/proto/android/app/settings_enums.proto @@ -38,6 +38,12 @@ enum PageId { // Unknown page. Should not be used in production code. PAGE_UNKNOWN = 0; + // OPEN: Settings > Connected Devices > Bluetooth > (click on details link for a paired device) + BLUETOOTH_DEVICE_DETAILS = 1009; + + // OPEN: Settings > Connected devices > Bluetooth > Pair new device + BLUETOOTH_PAIRING = 1018; + // OPEN: Settings homepage SETTINGS_HOMEPAGE = 1502; diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index f55e48e5b140..8dbea3896217 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -6034,7 +6034,7 @@ <attr name="insetBottom" format="fraction|dimension" /> </declare-styleable> - <!-- Drawable used to draw animated images (gif) --> + <!-- Drawable used to draw animated images (gif). --> <declare-styleable name="AnimatedImageDrawable"> <!-- Identifier of the image file. This attribute is mandatory. It must be an image file with multiple frames, e.g. gif or webp --> @@ -8918,8 +8918,8 @@ <attr name="name" /> </declare-styleable> - <!-- Attributes that are read when parsing a <font> tag, which is a child of - <font-family>. This represents an actual font file and its attributes. --> + <!-- Attributes that are read when parsing a <font> tag, which is a child of + <font-family>. This represents an actual font file and its attributes. --> <declare-styleable name="FontFamilyFont"> <!-- The style of the given font file. This will be used when the font is being loaded into the font stack and will override any style information in the font's header tables. If @@ -8950,7 +8950,7 @@ <attr name="fontVariationSettings" format="string" /> </declare-styleable> - <!-- Attributes that are read when parsing a <fontfamily> tag. --> + <!-- Attributes that are read when parsing a <fontfamily> tag. --> <declare-styleable name="FontFamily"> <!-- The authority of the Font Provider to be used for the request. --> <attr name="fontProviderAuthority" format="string" /> diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp index 4a639102192f..00ce28ad196f 100644 --- a/libs/hwui/RenderNode.cpp +++ b/libs/hwui/RenderNode.cpp @@ -454,6 +454,9 @@ const SkPath* RenderNode::getClippedOutline(const SkRect& clipRect) const { using StringBuffer = FatVector<char, 128>; template <typename... T> +// TODO:__printflike(2, 3) +// Doesn't work because the warning doesn't understand string_view and doesn't like that +// it's not a C-style variadic function. static void format(StringBuffer& buffer, const std::string_view& format, T... args) { buffer.resize(buffer.capacity()); while (1) { @@ -468,19 +471,20 @@ static void format(StringBuffer& buffer, const std::string_view& format, T... ar buffer.resize(needed + 1); return; } - buffer.resize(buffer.size() * 2); + // If we're doing a heap alloc anyway might as well give it some slop + buffer.resize(needed + 100); } } void RenderNode::markDrawStart(SkCanvas& canvas) { StringBuffer buffer; - format(buffer, "RenderNode(id=%d, name='%s')", uniqueId(), getName()); + format(buffer, "RenderNode(id=%" PRId64 ", name='%s')", uniqueId(), getName()); canvas.drawAnnotation(SkRect::MakeWH(getWidth(), getHeight()), buffer.data(), nullptr); } void RenderNode::markDrawEnd(SkCanvas& canvas) { StringBuffer buffer; - format(buffer, "/RenderNode(id=%d, name='%s')", uniqueId(), getName()); + format(buffer, "/RenderNode(id=%" PRId64 ", name='%s')", uniqueId(), getName()); canvas.drawAnnotation(SkRect::MakeWH(getWidth(), getHeight()), buffer.data(), nullptr); } diff --git a/libs/incident/proto/android/os/metadata.proto b/libs/incident/proto/android/os/metadata.proto index f8f4e36b1e89..3b0e9c9aa17a 100644 --- a/libs/incident/proto/android/os/metadata.proto +++ b/libs/incident/proto/android/os/metadata.proto @@ -61,8 +61,10 @@ message IncidentMetadata { optional bool timed_out = 7; // true if the section is truncated. optional bool is_truncated = 8; + // message for debugging if there is an error. + optional string error_msg = 9; - // Next Tag: 9 + // Next Tag: 10; } repeated SectionStats sections = 6; diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java index e2e943a369c2..d7d3981d05d1 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java @@ -79,7 +79,7 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic mFooterIcon = (ImageView) mRootView.findViewById(R.id.footer_icon); mFooterIconId = R.drawable.ic_info_outline; mContext = context; - mMainHandler = new Handler(Looper.getMainLooper()); + mMainHandler = new Handler(Looper.myLooper()); mActivityStarter = Dependency.get(ActivityStarter.class); mSecurityController = Dependency.get(SecurityController.class); mHandler = new H(Dependency.get(Dependency.BG_LOOPER)); diff --git a/packages/SystemUI/src/com/android/systemui/util/Assert.java b/packages/SystemUI/src/com/android/systemui/util/Assert.java index 0f7c9a462c0a..096ac3fcee1d 100644 --- a/packages/SystemUI/src/com/android/systemui/util/Assert.java +++ b/packages/SystemUI/src/com/android/systemui/util/Assert.java @@ -18,19 +18,24 @@ package com.android.systemui.util; import android.os.Looper; +import com.android.internal.annotations.VisibleForTesting; + /** * Helper providing common assertions. */ public class Assert { + @VisibleForTesting + public static Looper sMainLooper = Looper.getMainLooper(); + public static void isMainThread() { - if (!Looper.getMainLooper().isCurrentThread()) { + if (!sMainLooper.isCurrentThread()) { throw new IllegalStateException("should be called from the main thread."); } } public static void isNotMainThread() { - if (Looper.getMainLooper().isCurrentThread()) { + if (sMainLooper.isCurrentThread()) { throw new IllegalStateException("should not be called from the main thread."); } } diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchTest.java index 9cbe4152b5c4..7ca54231fe7b 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchTest.java @@ -51,7 +51,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; @SmallTest -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper @RunWith(AndroidTestingRunner.class) public class KeyguardClockSwitchTest extends SysuiTestCase { private PluginManager mPluginManager; diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinBasedInputViewTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinBasedInputViewTest.java index 359832f7a542..58870e4acbd0 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinBasedInputViewTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinBasedInputViewTest.java @@ -38,7 +38,7 @@ import org.mockito.MockitoAnnotations; @SmallTest @RunWith(AndroidTestingRunner.class) -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper public class KeyguardPinBasedInputViewTest extends SysuiTestCase { @Mock diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSliceViewTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSliceViewTest.java index b98ce39f5ed3..77895c97051c 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSliceViewTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSliceViewTest.java @@ -19,9 +19,14 @@ import android.graphics.Color; import android.net.Uri; import android.test.suitebuilder.annotation.SmallTest; import android.testing.AndroidTestingRunner; +import android.testing.TestableLooper; import android.testing.TestableLooper.RunWithLooper; import android.view.LayoutInflater; +import androidx.slice.SliceProvider; +import androidx.slice.SliceSpecs; +import androidx.slice.builders.ListBuilder; + import com.android.systemui.SysuiTestCase; import com.android.systemui.keyguard.KeyguardSliceProvider; @@ -34,12 +39,8 @@ import java.util.Collections; import java.util.HashSet; import java.util.concurrent.atomic.AtomicBoolean; -import androidx.slice.SliceProvider; -import androidx.slice.SliceSpecs; -import androidx.slice.builders.ListBuilder; - @SmallTest -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper @RunWith(AndroidTestingRunner.class) public class KeyguardSliceViewTest extends SysuiTestCase { private KeyguardSliceView mKeyguardSliceView; @@ -47,6 +48,7 @@ public class KeyguardSliceViewTest extends SysuiTestCase { @Before public void setUp() throws Exception { + com.android.systemui.util.Assert.sMainLooper = TestableLooper.get(this).getLooper(); mKeyguardSliceView = (KeyguardSliceView) LayoutInflater.from(getContext()) .inflate(R.layout.keyguard_status_area, null); mSliceUri = Uri.parse(KeyguardSliceProvider.KEYGUARD_SLICE_URI); diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewTest.java index 9e96df2c30cf..3582ab010413 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewTest.java @@ -20,10 +20,12 @@ import static org.mockito.Mockito.verify; import android.test.suitebuilder.annotation.SmallTest; import android.testing.AndroidTestingRunner; +import android.testing.TestableLooper; import android.testing.TestableLooper.RunWithLooper; import android.view.LayoutInflater; import com.android.systemui.SysuiTestCase; +import com.android.systemui.util.Assert; import org.junit.Before; import org.junit.Test; @@ -32,7 +34,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; @SmallTest -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper @RunWith(AndroidTestingRunner.class) public class KeyguardStatusViewTest extends SysuiTestCase { @@ -45,6 +47,7 @@ public class KeyguardStatusViewTest extends SysuiTestCase { @Before public void setUp() { + Assert.sMainLooper = TestableLooper.get(this).getLooper(); LayoutInflater layoutInflater = LayoutInflater.from(getContext()); mKeyguardStatusView = (KeyguardStatusView) layoutInflater.inflate(R.layout.keyguard_status_view, null); diff --git a/packages/SystemUI/tests/src/com/android/systemui/ExpandHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/ExpandHelperTest.java index c180ff8fd30c..948e0014a451 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/ExpandHelperTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/ExpandHelperTest.java @@ -16,29 +16,29 @@ package com.android.systemui; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import android.animation.ObjectAnimator; import android.content.Context; -import android.support.test.InstrumentationRegistry; import android.support.test.annotation.UiThreadTest; import android.support.test.filters.SmallTest; -import android.support.test.runner.AndroidJUnit4; import android.testing.AndroidTestingRunner; +import android.testing.TestableLooper; import android.testing.TestableLooper.RunWithLooper; -import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.NotificationTestHelper; +import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; +import com.android.systemui.util.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - @SmallTest @RunWith(AndroidTestingRunner.class) -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper public class ExpandHelperTest extends SysuiTestCase { private ExpandableNotificationRow mRow; @@ -47,6 +47,7 @@ public class ExpandHelperTest extends SysuiTestCase { @Before public void setUp() throws Exception { + Assert.sMainLooper = TestableLooper.get(this).getLooper(); Context context = getContext(); mRow = new NotificationTestHelper(context).createRow(); mCallback = mock(ExpandHelper.Callback.class); diff --git a/packages/SystemUI/tests/src/com/android/systemui/SysuiTestCase.java b/packages/SystemUI/tests/src/com/android/systemui/SysuiTestCase.java index a58bc8548bd4..9c5a59243d05 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/SysuiTestCase.java +++ b/packages/SystemUI/tests/src/com/android/systemui/SysuiTestCase.java @@ -29,6 +29,7 @@ import android.testing.LeakCheck; import android.util.Log; import com.android.keyguard.KeyguardUpdateMonitor; +import com.android.systemui.util.Assert; import org.junit.After; import org.junit.Before; @@ -78,6 +79,8 @@ public abstract class SysuiTestCase { public void SysuiTeardown() { InstrumentationRegistry.registerInstance(mRealInstrumentation, InstrumentationRegistry.getArguments()); + // Reset the assert's main looper. + Assert.sMainLooper = Looper.getMainLooper(); } protected LeakCheck getLeakCheck() { diff --git a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java index 368c814f8e0a..e1c481e4ef28 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java @@ -28,8 +28,8 @@ import static com.android.systemui.doze.DozeMachine.State.UNINITIALIZED; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; @@ -40,14 +40,12 @@ import static org.mockito.Mockito.when; import android.support.test.filters.SmallTest; import android.testing.AndroidTestingRunner; -import android.view.Display; +import android.testing.UiThreadTest; import com.android.internal.hardware.AmbientDisplayConfiguration; import com.android.systemui.SysuiTestCase; import com.android.systemui.util.wakelock.WakeLockFake; -import android.testing.UiThreadTest; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java index 5c8336c8dee1..31fc625d34dd 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java @@ -48,7 +48,7 @@ import org.junit.runner.RunWith; @SmallTest @Ignore("failing") @RunWith(AndroidTestingRunner.class) -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper public class DozeTriggersTest extends SysuiTestCase { private DozeTriggers mTriggers; private DozeMachine mMachine; 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 095395185f86..c1c80ce4a70a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardSliceProviderTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardSliceProviderTest.java @@ -55,7 +55,7 @@ import java.util.concurrent.TimeUnit; @SmallTest @RunWith(AndroidTestingRunner.class) -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper public class KeyguardSliceProviderTest extends SysuiTestCase { @Mock diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java index 4e24354d9878..bc7d9836d6f8 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java @@ -18,39 +18,32 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; -import android.app.FragmentController; -import android.app.FragmentManagerNonConfig; +import android.content.Context; import android.os.Looper; -import android.support.test.filters.FlakyTest; +import android.support.test.filters.SmallTest; +import android.testing.AndroidTestingRunner; +import android.testing.LayoutInflaterBuilder; +import android.testing.TestableLooper; +import android.testing.TestableLooper.RunWithLooper; +import android.view.View; +import android.widget.FrameLayout; import com.android.internal.logging.MetricsLogger; import com.android.keyguard.CarrierText; import com.android.systemui.Dependency; import com.android.systemui.R; - -import android.os.Parcelable; -import android.support.test.filters.SmallTest; -import android.testing.AndroidTestingRunner; - import com.android.systemui.SysuiBaseFragmentTest; import com.android.systemui.statusbar.phone.StatusBarIconController; import com.android.systemui.statusbar.policy.Clock; import com.android.systemui.statusbar.policy.UserSwitcherController; -import android.testing.LayoutInflaterBuilder; -import android.testing.TestableLooper; -import android.testing.TestableLooper.RunWithLooper; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; -import android.content.Context; -import android.view.View; -import android.widget.FrameLayout; - @RunWith(AndroidTestingRunner.class) -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper @SmallTest @Ignore public class QSFragmentTest extends SysuiBaseFragmentTest { diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java index 33b347a66b33..fd31013db429 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java @@ -22,7 +22,6 @@ import static org.mockito.Mockito.when; import android.content.Context; import android.content.pm.UserInfo; -import android.os.Looper; import android.os.UserManager; import android.provider.Settings; import android.test.suitebuilder.annotation.SmallTest; @@ -58,7 +57,7 @@ import org.mockito.Mockito; @SmallTest @RunWith(AndroidTestingRunner.class) -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper public class QSSecurityFooterTest extends SysuiTestCase { private final String MANAGING_ORGANIZATION = "organization"; @@ -76,7 +75,8 @@ public class QSSecurityFooterTest extends SysuiTestCase { @Before public void setUp() { mDependency.injectTestDependency(SecurityController.class, mSecurityController); - mDependency.injectTestDependency(Dependency.BG_LOOPER, Looper.getMainLooper()); + mDependency.injectTestDependency(Dependency.BG_LOOPER, + TestableLooper.get(this).getLooper()); mContext.addMockSystemService(Context.LAYOUT_INFLATER_SERVICE, new LayoutInflaterBuilder(mContext) .replace("ImageView", TestableImageView.class) diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServicesTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServicesTest.java index c016a851010a..c6597b9bd534 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServicesTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServicesTest.java @@ -24,16 +24,15 @@ import android.content.ComponentName; import android.os.Looper; import android.service.quicksettings.Tile; import android.test.suitebuilder.annotation.SmallTest; - import android.testing.AndroidTestingRunner; +import android.testing.TestableLooper; +import android.testing.TestableLooper.RunWithLooper; + import com.android.systemui.SysuiTestCase; import com.android.systemui.qs.QSTileHost; import com.android.systemui.statusbar.phone.StatusBarIconController; import com.android.systemui.statusbar.policy.BluetoothController; -import android.testing.TestableLooper; -import android.testing.TestableLooper.RunWithLooper; - import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -45,7 +44,7 @@ import java.util.ArrayList; @SmallTest @RunWith(AndroidTestingRunner.class) -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper public class TileServicesTest extends SysuiTestCase { private static int NUM_FAKES = TileServices.DEFAULT_MAX_BOUND * 2; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java index 2e280d336aab..9449e297fcc5 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java @@ -50,7 +50,7 @@ import org.mockito.MockitoAnnotations; */ @SmallTest @RunWith(AndroidTestingRunner.class) -@TestableLooper.RunWithLooper(setAsMainLooper = true) +@TestableLooper.RunWithLooper @Ignore("b/118400112") public class NonPhoneDependencyTest extends SysuiTestCase { @Mock private NotificationPresenter mPresenter; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java index 63ececbe2994..65c04fe4bcd3 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java @@ -16,15 +16,12 @@ package com.android.systemui.statusbar; -import static junit.framework.Assert.assertTrue; - import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.Notification; import android.os.Handler; -import android.os.Looper; import android.os.UserHandle; import android.service.notification.NotificationListenerService; import android.service.notification.StatusBarNotification; @@ -45,7 +42,7 @@ import org.mockito.MockitoAnnotations; @SmallTest @RunWith(AndroidTestingRunner.class) -@TestableLooper.RunWithLooper(setAsMainLooper = true) +@TestableLooper.RunWithLooper public class NotificationListenerTest extends SysuiTestCase { private static final String TEST_PACKAGE_NAME = "test"; private static final int TEST_UID = 0; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java index 72d6cd8eaeea..520a927d1ab0 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java @@ -46,6 +46,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableView; import com.android.systemui.statusbar.notification.stack.NotificationListContainer; import com.android.systemui.statusbar.phone.NotificationGroupManager; import com.android.systemui.statusbar.phone.ShadeController; +import com.android.systemui.util.Assert; import com.google.android.collect.Lists; @@ -60,7 +61,7 @@ import java.util.List; @SmallTest @RunWith(AndroidTestingRunner.class) -@TestableLooper.RunWithLooper(setAsMainLooper = true) +@TestableLooper.RunWithLooper public class NotificationViewHierarchyManagerTest extends SysuiTestCase { @Mock private NotificationPresenter mPresenter; @Mock private NotificationData mNotificationData; @@ -79,6 +80,7 @@ public class NotificationViewHierarchyManagerTest extends SysuiTestCase { @Before public void setUp() { MockitoAnnotations.initMocks(this); + Assert.sMainLooper = TestableLooper.get(this).getLooper(); mDependency.injectTestDependency(NotificationEntryManager.class, mEntryManager); mDependency.injectTestDependency(NotificationLockscreenUserManager.class, mLockscreenUserManager); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/AboveShelfObserverTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/AboveShelfObserverTest.java index b7aa21b86d33..db2c8780e783 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/AboveShelfObserverTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/AboveShelfObserverTest.java @@ -19,15 +19,15 @@ package com.android.systemui.statusbar.notification; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import android.support.test.runner.AndroidJUnit4; import android.test.suitebuilder.annotation.SmallTest; import android.testing.AndroidTestingRunner; +import android.testing.TestableLooper; import android.testing.TestableLooper.RunWithLooper; import android.widget.FrameLayout; import com.android.systemui.SysuiTestCase; -import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.NotificationTestHelper; +import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import org.junit.Assert; import org.junit.Before; @@ -36,7 +36,7 @@ import org.junit.runner.RunWith; @SmallTest @RunWith(AndroidTestingRunner.class) -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper public class AboveShelfObserverTest extends SysuiTestCase { private AboveShelfObserver mObserver; @@ -46,6 +46,7 @@ public class AboveShelfObserverTest extends SysuiTestCase { @Before public void setUp() throws Exception { + com.android.systemui.util.Assert.sMainLooper = TestableLooper.get(this).getLooper(); mNotificationTestHelper = new NotificationTestHelper(getContext()); mHostLayout = new FrameLayout(getContext()); mObserver = new AboveShelfObserver(mHostLayout); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationDataTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationDataTest.java index f94ba95999bf..8e88ed0556bf 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationDataTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationDataTest.java @@ -53,6 +53,7 @@ import android.service.notification.StatusBarNotification; import android.support.test.annotation.UiThreadTest; import android.support.test.filters.SmallTest; import android.testing.AndroidTestingRunner; +import android.testing.TestableLooper; import android.testing.TestableLooper.RunWithLooper; import android.util.ArraySet; @@ -78,7 +79,7 @@ import java.util.List; @SmallTest @RunWith(AndroidTestingRunner.class) -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper public class NotificationDataTest extends SysuiTestCase { private static final int UID_NORMAL = 123; @@ -101,6 +102,7 @@ public class NotificationDataTest extends SysuiTestCase { @Before public void setUp() throws Exception { + com.android.systemui.util.Assert.sMainLooper = TestableLooper.get(this).getLooper(); MockitoAnnotations.initMocks(this); when(mMockStatusBarNotification.getUid()).thenReturn(UID_NORMAL); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationViewWrapperTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationViewWrapperTest.java index 63d1e8dbc954..24aa772e2fc1 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationViewWrapperTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationViewWrapperTest.java @@ -17,28 +17,29 @@ package com.android.systemui.statusbar.notification; import android.content.Context; -import android.support.test.InstrumentationRegistry; import android.support.test.filters.SmallTest; -import android.support.test.runner.AndroidJUnit4; import android.testing.AndroidTestingRunner; +import android.testing.TestableLooper; import android.testing.TestableLooper.RunWithLooper; import android.view.View; import com.android.systemui.SysuiTestCase; -import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.NotificationTestHelper; +import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.wrapper.NotificationViewWrapper; +import com.android.systemui.util.Assert; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(AndroidTestingRunner.class) @SmallTest -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper public class NotificationViewWrapperTest extends SysuiTestCase { @Test public void constructor_doesntUseViewContext() throws Exception { + Assert.sMainLooper = TestableLooper.get(this).getLooper(); new TestableNotificationViewWrapper(mContext, new View(mContext), new NotificationTestHelper(getContext()).createRow()); @@ -50,4 +51,4 @@ public class NotificationViewWrapperTest extends SysuiTestCase { super(ctx, view, row); } } -}
\ No newline at end of file +} diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationLoggerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationLoggerTest.java index 3710fa833d50..512acd073a84 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationLoggerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationLoggerTest.java @@ -37,13 +37,13 @@ import android.testing.TestableLooper; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.statusbar.NotificationVisibility; import com.android.systemui.SysuiTestCase; - -import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.NotificationListener; import com.android.systemui.statusbar.NotificationPresenter; import com.android.systemui.statusbar.notification.NotificationData; +import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.stack.NotificationListContainer; + import com.google.android.collect.Lists; import org.junit.Before; @@ -58,7 +58,7 @@ import java.util.concurrent.ConcurrentLinkedQueue; @SmallTest @RunWith(AndroidTestingRunner.class) -@TestableLooper.RunWithLooper(setAsMainLooper = true) +@TestableLooper.RunWithLooper public class NotificationLoggerTest extends SysuiTestCase { private static final String TEST_PACKAGE_NAME = "test"; private static final int TEST_UID = 0; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java index 2da72e7858c8..6d3553912701 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java @@ -40,6 +40,7 @@ import android.app.AppOpsManager; import android.app.NotificationChannel; import android.support.test.filters.SmallTest; import android.testing.AndroidTestingRunner; +import android.testing.TestableLooper; import android.testing.TestableLooper.RunWithLooper; import android.util.ArraySet; import android.view.NotificationHeaderView; @@ -64,7 +65,7 @@ import java.util.List; @SmallTest @RunWith(AndroidTestingRunner.class) -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper public class ExpandableNotificationRowTest extends SysuiTestCase { private ExpandableNotificationRow mGroupRow; @@ -77,6 +78,7 @@ public class ExpandableNotificationRowTest extends SysuiTestCase { @Before public void setUp() throws Exception { + com.android.systemui.util.Assert.sMainLooper = TestableLooper.get(this).getLooper(); mNotificationTestHelper = new NotificationTestHelper(mContext); mGroupRow = mNotificationTestHelper.createGroup(); mGroupRow.setHeadsUpAnimatingAwayListener( diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManagerTest.java index 4efab5385c0a..669b98e1b279 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManagerTest.java @@ -16,10 +16,18 @@ package com.android.systemui.statusbar.notification.row; -import com.android.systemui.SysuiTestCase; -import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; -import com.android.systemui.statusbar.notification.NotificationEntryManager; -import com.android.systemui.statusbar.NotificationTestHelper; +import static android.service.notification.NotificationListenerService.Ranking.USER_SENTIMENT_NEGATIVE; +import static android.service.notification.NotificationListenerService.Ranking.USER_SENTIMENT_NEUTRAL; +import static android.service.notification.NotificationListenerService.Ranking.USER_SENTIMENT_POSITIVE; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import android.content.Context; import android.support.test.filters.FlakyTest; @@ -28,30 +36,24 @@ import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.view.View; +import com.android.systemui.SysuiTestCase; +import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; +import com.android.systemui.statusbar.NotificationTestHelper; +import com.android.systemui.statusbar.notification.NotificationEntryManager; +import com.android.systemui.util.Assert; + import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import static android.service.notification.NotificationListenerService.Ranking.USER_SENTIMENT_NEGATIVE; -import static android.service.notification.NotificationListenerService.Ranking.USER_SENTIMENT_NEUTRAL; -import static android.service.notification.NotificationListenerService.Ranking.USER_SENTIMENT_POSITIVE; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - /** * Tests for {@link NotificationBlockingHelperManager}. */ @SmallTest @FlakyTest @org.junit.runner.RunWith(AndroidTestingRunner.class) -@TestableLooper.RunWithLooper(setAsMainLooper = true) +@TestableLooper.RunWithLooper public class NotificationBlockingHelperManagerTest extends SysuiTestCase { private NotificationBlockingHelperManager mBlockingHelperManager; @@ -65,6 +67,7 @@ public class NotificationBlockingHelperManagerTest extends SysuiTestCase { @Before public void setUp() { + Assert.sMainLooper = TestableLooper.get(this).getLooper(); MockitoAnnotations.initMocks(this); when(mGutsManager.openGuts( any(View.class), diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java index 766c5d2377c6..8966aca3069c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java @@ -64,6 +64,7 @@ import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.row.NotificationGutsManager.OnSettingsClickListener; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; import com.android.systemui.statusbar.policy.DeviceProvisionedController; +import com.android.systemui.util.Assert; import org.junit.Before; import org.junit.Rule; @@ -79,7 +80,7 @@ import org.mockito.junit.MockitoRule; */ @SmallTest @RunWith(AndroidTestingRunner.class) -@TestableLooper.RunWithLooper(setAsMainLooper = true) +@TestableLooper.RunWithLooper public class NotificationGutsManagerTest extends SysuiTestCase { private static final String TEST_CHANNEL_ID = "NotificationManagerServiceTestChannelId"; @@ -101,6 +102,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase { @Before public void setUp() { mTestableLooper = TestableLooper.get(this); + Assert.sMainLooper = TestableLooper.get(this).getLooper(); mDependency.injectTestDependency(DeviceProvisionedController.class, mDeviceProvisionedController); mHandler = Handler.createAsync(mTestableLooper.getLooper()); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java index bb9911b24f0a..e4d019656072 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java @@ -44,7 +44,7 @@ import org.junit.runner.RunWith; import org.mockito.Mockito; @RunWith(AndroidTestingRunner.class) -@RunWithLooper() +@RunWithLooper @SmallTest public class NotificationMenuRowTest extends LeakCheckedTest { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCustomViewWrapperTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCustomViewWrapperTest.java index 4b94a2523cfe..fed66af07bcc 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCustomViewWrapperTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCustomViewWrapperTest.java @@ -18,6 +18,7 @@ package com.android.systemui.statusbar.notification.row.wrapper; import android.support.test.filters.SmallTest; import android.testing.AndroidTestingRunner; +import android.testing.TestableLooper; import android.testing.TestableLooper.RunWithLooper; import android.view.View; import android.widget.RemoteViews; @@ -34,13 +35,14 @@ import org.junit.runner.RunWith; @SmallTest @RunWith(AndroidTestingRunner.class) -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper public class NotificationCustomViewWrapperTest extends SysuiTestCase { private ExpandableNotificationRow mRow; @Before public void setUp() throws Exception { + com.android.systemui.util.Assert.sMainLooper = TestableLooper.get(this).getLooper(); mRow = new NotificationTestHelper(mContext).createRow(); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java index 272845396e27..bbafb4e4a211 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java @@ -18,13 +18,14 @@ package com.android.systemui.statusbar.notification.stack; import android.support.test.filters.SmallTest; import android.testing.AndroidTestingRunner; +import android.testing.TestableLooper; import android.testing.TestableLooper.RunWithLooper; import android.view.NotificationHeaderView; import android.view.View; import com.android.systemui.SysuiTestCase; -import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.NotificationTestHelper; +import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import org.junit.Assert; import org.junit.Before; @@ -33,16 +34,16 @@ import org.junit.runner.RunWith; @SmallTest @RunWith(AndroidTestingRunner.class) -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper public class NotificationChildrenContainerTest extends SysuiTestCase { private ExpandableNotificationRow mGroup; - private int mId; private NotificationTestHelper mNotificationTestHelper; private NotificationChildrenContainer mChildrenContainer; @Before public void setUp() throws Exception { + com.android.systemui.util.Assert.sMainLooper = TestableLooper.get(this).getLooper(); mNotificationTestHelper = new NotificationTestHelper(mContext); mGroup = mNotificationTestHelper.createGroup(); mChildrenContainer = mGroup.getChildrenContainer(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManagerTest.java index 662e016b77ff..8ae7d52a5da5 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManagerTest.java @@ -25,6 +25,7 @@ import static org.mockito.Mockito.when; import android.support.test.filters.SmallTest; import android.testing.AndroidTestingRunner; +import android.testing.TestableLooper; import android.testing.TestableLooper.RunWithLooper; import com.android.systemui.SysuiTestCase; @@ -41,7 +42,7 @@ import java.util.HashSet; @SmallTest @RunWith(AndroidTestingRunner.class) -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper public class NotificationRoundnessManagerTest extends SysuiTestCase { private NotificationRoundnessManager mRoundnessManager = new NotificationRoundnessManager(); @@ -52,6 +53,7 @@ public class NotificationRoundnessManagerTest extends SysuiTestCase { @Before public void setUp() throws Exception { + com.android.systemui.util.Assert.sMainLooper = TestableLooper.get(this).getLooper(); NotificationTestHelper testHelper = new NotificationTestHelper(getContext()); mFirst = testHelper.createRow(); mFirst.setHeadsUpAnimatingAwayListener(animatingAway diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java index c99e766ac697..4f6329cb0c57 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java @@ -23,18 +23,18 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.support.test.filters.SmallTest; -import android.support.test.runner.AndroidJUnit4; import android.testing.AndroidTestingRunner; +import android.testing.TestableLooper; import android.testing.TestableLooper.RunWithLooper; import android.view.View; import android.widget.TextView; import com.android.systemui.SysuiTestCase; -import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.HeadsUpStatusBarView; import com.android.systemui.statusbar.NotificationTestHelper; -import com.android.systemui.statusbar.policy.DarkIconDispatcher; +import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; +import com.android.systemui.statusbar.policy.DarkIconDispatcher; import org.junit.Assert; import org.junit.Before; @@ -43,7 +43,7 @@ import org.junit.runner.RunWith; @SmallTest @RunWith(AndroidTestingRunner.class) -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper public class HeadsUpAppearanceControllerTest extends SysuiTestCase { private final NotificationStackScrollLayout mStackScroller = @@ -58,6 +58,7 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase { @Before public void setUp() throws Exception { + com.android.systemui.util.Assert.sMainLooper = TestableLooper.get(this).getLooper(); NotificationTestHelper testHelper = new NotificationTestHelper(getContext()); mFirst = testHelper.createRow(); mDependency.injectTestDependency(DarkIconDispatcher.class, mDarkIconDispatcher); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java index 7f8668fa064c..f7a95c50fee8 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java @@ -28,6 +28,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; +import android.content.res.ColorStateList; import android.graphics.Color; import android.support.test.filters.SmallTest; import android.testing.AndroidTestingRunner; @@ -35,7 +36,6 @@ import android.testing.TestableLooper; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.widget.FrameLayout; -import android.content.res.ColorStateList; import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardHostView; @@ -56,7 +56,7 @@ import org.mockito.MockitoAnnotations; @SmallTest @RunWith(AndroidTestingRunner.class) -@TestableLooper.RunWithLooper(setAsMainLooper = true) +@TestableLooper.RunWithLooper public class KeyguardBouncerTest extends SysuiTestCase { @Mock @@ -78,6 +78,7 @@ public class KeyguardBouncerTest extends SysuiTestCase { @Before public void setup() { + com.android.systemui.util.Assert.sMainLooper = TestableLooper.get(this).getLooper(); MockitoAnnotations.initMocks(this); DejankUtils.setImmediate(true); final ViewGroup container = new FrameLayout(getContext()); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java index 31014b8a62e9..27ed9c5a14c8 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java @@ -30,7 +30,7 @@ import org.junit.runner.RunWith; @SmallTest @RunWith(AndroidTestingRunner.class) -@TestableLooper.RunWithLooper(setAsMainLooper = true) +@TestableLooper.RunWithLooper public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { private static final int SCREEN_HEIGHT = 2000; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardPresentationTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardPresentationTest.java index 54291536093c..c5875554b073 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardPresentationTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardPresentationTest.java @@ -20,21 +20,20 @@ import android.support.test.filters.SmallTest; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.view.LayoutInflater; -import android.view.View; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; -import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @SmallTest @RunWith(AndroidTestingRunner.class) -@TestableLooper.RunWithLooper(setAsMainLooper = true) +@TestableLooper.RunWithLooper public class KeyguardPresentationTest extends SysuiTestCase { @Test public void testInflation_doesntCrash() { + com.android.systemui.util.Assert.sMainLooper = TestableLooper.get(this).getLooper(); LayoutInflater inflater = LayoutInflater.from(getContext()); inflater.inflate(R.layout.keyguard_presentation, null); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/QuickStepControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/QuickStepControllerTest.java index 1783d0cf2519..cdaa2420186f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/QuickStepControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/QuickStepControllerTest.java @@ -29,7 +29,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.anyFloat; -import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -38,11 +37,6 @@ import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import com.android.systemui.R; -import com.android.systemui.recents.OverviewProxyService; -import com.android.systemui.shared.recents.IOverviewProxy; -import com.android.systemui.SysuiTestCase; - import android.content.Context; import android.content.res.Resources; import android.support.test.filters.SmallTest; @@ -51,6 +45,11 @@ import android.testing.TestableLooper.RunWithLooper; import android.view.MotionEvent; import android.view.View; +import com.android.systemui.R; +import com.android.systemui.SysuiTestCase; +import com.android.systemui.recents.OverviewProxyService; +import com.android.systemui.shared.recents.IOverviewProxy; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -59,7 +58,7 @@ import org.mockito.MockitoAnnotations; /** atest QuickStepControllerTest */ @RunWith(AndroidTestingRunner.class) -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper @SmallTest public class QuickStepControllerTest extends SysuiTestCase { private QuickStepController mController; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/SystemUIDialogTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/SystemUIDialogTest.java index dcd531dc9eb7..090963be7ac7 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/SystemUIDialogTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/SystemUIDialogTest.java @@ -15,6 +15,7 @@ package com.android.systemui.statusbar.phone; import static junit.framework.Assert.assertTrue; + import static org.mockito.Matchers.any; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; @@ -35,7 +36,7 @@ import org.mockito.ArgumentCaptor; @RunWith(AndroidTestingRunner.class) -@RunWithLooper(setAsMainLooper = true) +@RunWithLooper @SmallTest public class SystemUIDialogTest extends SysuiTestCase { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java index 3164c0469c40..b3ac6be65d36 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java @@ -32,9 +32,10 @@ import android.widget.ImageButton; import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; -import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.NotificationTestHelper; import com.android.systemui.statusbar.RemoteInputController; +import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; +import com.android.systemui.util.Assert; import org.junit.After; import org.junit.Before; @@ -44,7 +45,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; @RunWith(AndroidTestingRunner.class) -@TestableLooper.RunWithLooper(setAsMainLooper = true) +@TestableLooper.RunWithLooper @SmallTest public class RemoteInputViewTest extends SysuiTestCase { @@ -60,6 +61,7 @@ public class RemoteInputViewTest extends SysuiTestCase { @Before public void setUp() throws Exception { + Assert.sMainLooper = TestableLooper.get(this).getLooper(); MockitoAnnotations.initMocks(this); mDependency.injectTestDependency(RemoteInputQuickSettingsDisabler.class, diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/wakelock/KeepAwakeAnimationListenerTest.java b/packages/SystemUI/tests/src/com/android/systemui/util/wakelock/KeepAwakeAnimationListenerTest.java index 43942f72993e..ab9b0c979fd3 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/util/wakelock/KeepAwakeAnimationListenerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/util/wakelock/KeepAwakeAnimationListenerTest.java @@ -20,11 +20,13 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import android.animation.Animator; +import android.os.Looper; import android.support.test.filters.SmallTest; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import com.android.systemui.SysuiTestCase; +import com.android.systemui.util.Assert; import org.junit.Before; import org.junit.Test; @@ -33,7 +35,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; @SmallTest -@TestableLooper.RunWithLooper(setAsMainLooper = true) +@TestableLooper.RunWithLooper @RunWith(AndroidTestingRunner.class) public class KeepAwakeAnimationListenerTest extends SysuiTestCase { @Mock WakeLock mWakeLock; @@ -41,6 +43,7 @@ public class KeepAwakeAnimationListenerTest extends SysuiTestCase { @Before public void setup() { + Assert.sMainLooper = TestableLooper.get(this).getLooper(); MockitoAnnotations.initMocks(this); KeepAwakeAnimationListener.sWakeLock = mWakeLock; mKeepAwakeAnimationListener = new KeepAwakeAnimationListener(getContext()); @@ -55,4 +58,10 @@ public class KeepAwakeAnimationListenerTest extends SysuiTestCase { mKeepAwakeAnimationListener.onAnimationEnd((Animator) null); verify(mWakeLock).release(); } + + @Test(expected = IllegalStateException.class) + public void initThrows_onNonMainThread() { + Assert.sMainLooper = Looper.getMainLooper(); + new KeepAwakeAnimationListener(getContext()); + } } diff --git a/packages/overlays/IconShapeRoundedRectOverlay/Android.mk b/packages/overlays/IconShapeRoundedRectOverlay/Android.mk new file mode 100644 index 000000000000..a734a6b46947 --- /dev/null +++ b/packages/overlays/IconShapeRoundedRectOverlay/Android.mk @@ -0,0 +1,30 @@ +# +# Copyright 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. +# + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_RRO_THEME := IconShapeRoundedRect +LOCAL_CERTIFICATE := platform + +LOCAL_SRC_FILES := $(call all-subdir-java-files) + +LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res + +LOCAL_PACKAGE_NAME := IconShapeRoundedRectOverlay +LOCAL_SDK_VERSION := current + +include $(BUILD_RRO_PACKAGE) diff --git a/packages/overlays/IconShapeRoundedRectOverlay/AndroidManifest.xml b/packages/overlays/IconShapeRoundedRectOverlay/AndroidManifest.xml new file mode 100644 index 000000000000..39c082b59604 --- /dev/null +++ b/packages/overlays/IconShapeRoundedRectOverlay/AndroidManifest.xml @@ -0,0 +1,27 @@ +<!-- +/** + * 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. + */ +--> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.theme.icon.roundedrect" + android:versionCode="1" + android:versionName="1.0"> + <overlay android:targetPackage="android" + android:category="android.theme.customization.adaptive_icon_shape" + android:priority="1"/> + + <application android:label="@string/icon_shape_roundedrect_overlay" android:hasCode="false"/> +</manifest> diff --git a/packages/overlays/IconShapeRoundedRectOverlay/res/values/config.xml b/packages/overlays/IconShapeRoundedRectOverlay/res/values/config.xml new file mode 100644 index 000000000000..f024615190ab --- /dev/null +++ b/packages/overlays/IconShapeRoundedRectOverlay/res/values/config.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 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. +*/ +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- Specifies the path that is used by AdaptiveIconDrawable class to crop launcher icons. --> + <string name="config_icon_mask" translatable="false">"M50,0L92,0C96.42,0 100,4.58 100 8L100,92C100, 96.42 96.42 100 92 100L8 100C4.58, 100 0 96.42 0 92L0 8 C 0 4.42 4.42 0 8 0L50 0Z"</string> + <!-- Flag indicating whether round icons should be parsed from the application manifest. --> + <bool name="config_useRoundIcon">false</bool> + +</resources> + diff --git a/packages/overlays/IconShapeRoundedRectOverlay/res/values/strings.xml b/packages/overlays/IconShapeRoundedRectOverlay/res/values/strings.xml new file mode 100644 index 000000000000..dc5c196c97aa --- /dev/null +++ b/packages/overlays/IconShapeRoundedRectOverlay/res/values/strings.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * 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. + */ +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- Rounded corner rectangle overlay --> + <string name="icon_shape_roundedrect_overlay" translatable="false">RoundedRectangle Icons</string> + +</resources> diff --git a/packages/overlays/AdaptiveIconChangeOverlay/Android.mk b/packages/overlays/IconShapeSquareOverlay/Android.mk index 6e3b8cbbcf2f..217da9feb534 100644 --- a/packages/overlays/AdaptiveIconChangeOverlay/Android.mk +++ b/packages/overlays/IconShapeSquareOverlay/Android.mk @@ -17,14 +17,14 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) -LOCAL_RRO_THEME := SquareIcon +LOCAL_RRO_THEME := IconShapeSquare LOCAL_CERTIFICATE := platform LOCAL_SRC_FILES := $(call all-subdir-java-files) LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res -LOCAL_PACKAGE_NAME := SquareIconOverlay +LOCAL_PACKAGE_NAME := IconShapeSquareOverlay LOCAL_SDK_VERSION := current include $(BUILD_RRO_PACKAGE) diff --git a/packages/overlays/AdaptiveIconChangeOverlay/AndroidManifest.xml b/packages/overlays/IconShapeSquareOverlay/AndroidManifest.xml index 33da51047bf0..235fdeb22648 100644 --- a/packages/overlays/AdaptiveIconChangeOverlay/AndroidManifest.xml +++ b/packages/overlays/IconShapeSquareOverlay/AndroidManifest.xml @@ -23,5 +23,5 @@ android:category="android.theme.customization.adaptive_icon_shape" android:priority="1"/> - <application android:label="@string/square_icon_overlay" android:hasCode="false"/> + <application android:label="@string/icon_shape_square_overlay" android:hasCode="false"/> </manifest> diff --git a/packages/overlays/AdaptiveIconChangeOverlay/res/values/config.xml b/packages/overlays/IconShapeSquareOverlay/res/values/config.xml index 54623f5c9fb0..54623f5c9fb0 100644 --- a/packages/overlays/AdaptiveIconChangeOverlay/res/values/config.xml +++ b/packages/overlays/IconShapeSquareOverlay/res/values/config.xml diff --git a/packages/overlays/AdaptiveIconChangeOverlay/res/values/strings.xml b/packages/overlays/IconShapeSquareOverlay/res/values/strings.xml index 64b7d0dc16b5..4fd39ff26bae 100644 --- a/packages/overlays/AdaptiveIconChangeOverlay/res/values/strings.xml +++ b/packages/overlays/IconShapeSquareOverlay/res/values/strings.xml @@ -17,7 +17,7 @@ */ --> <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <!-- Square icon overlay [DO NOT TRANSLATE] --> - <string name="square_icon_overlay">Square Icons</string> + <!-- Square icon overlay --> + <string name="icon_shape_square_overlay" translatable="false">Square Icons</string> </resources> diff --git a/packages/overlays/IconShapeSquircleOverlay/Android.mk b/packages/overlays/IconShapeSquircleOverlay/Android.mk new file mode 100644 index 000000000000..fd3bfa06de83 --- /dev/null +++ b/packages/overlays/IconShapeSquircleOverlay/Android.mk @@ -0,0 +1,30 @@ +# +# Copyright 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. +# + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_RRO_THEME := IconShapeSquircle +LOCAL_CERTIFICATE := platform + +LOCAL_SRC_FILES := $(call all-subdir-java-files) + +LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res + +LOCAL_PACKAGE_NAME := IconShapeSquircleOverlay +LOCAL_SDK_VERSION := current + +include $(BUILD_RRO_PACKAGE) diff --git a/packages/overlays/IconShapeSquircleOverlay/AndroidManifest.xml b/packages/overlays/IconShapeSquircleOverlay/AndroidManifest.xml new file mode 100644 index 000000000000..ca618e4142b9 --- /dev/null +++ b/packages/overlays/IconShapeSquircleOverlay/AndroidManifest.xml @@ -0,0 +1,27 @@ +<!-- +/** + * 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. + */ +--> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.theme.icon.squircle" + android:versionCode="1" + android:versionName="1.0"> + <overlay android:targetPackage="android" + android:category="android.theme.customization.adaptive_icon_shape" + android:priority="1"/> + + <application android:label="@string/icon_shape_squircle_overlay" android:hasCode="false"/> +</manifest> diff --git a/packages/overlays/IconShapeSquircleOverlay/res/values/config.xml b/packages/overlays/IconShapeSquircleOverlay/res/values/config.xml new file mode 100644 index 000000000000..eaf7de3b153d --- /dev/null +++ b/packages/overlays/IconShapeSquircleOverlay/res/values/config.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 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. +*/ +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- Specifies the path that is used by AdaptiveIconDrawable class to crop launcher icons. --> + <string name="config_icon_mask" translatable="false">"M50,0 C10,0 0,10 0,50 0,90 10,100 50,100 90,100 100,90 100,50 100,10 90,0 50,0 Z"</string> + <!-- Flag indicating whether round icons should be parsed from the application manifest. --> + <bool name="config_useRoundIcon">false</bool> + +</resources> + diff --git a/packages/overlays/IconShapeSquircleOverlay/res/values/strings.xml b/packages/overlays/IconShapeSquircleOverlay/res/values/strings.xml new file mode 100644 index 000000000000..b7c001c68a30 --- /dev/null +++ b/packages/overlays/IconShapeSquircleOverlay/res/values/strings.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * 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. + */ +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- Squircle icon shape overlay --> + <string name="icon_shape_squircle_overlay" translatable="false">Square Icons</string> + +</resources> diff --git a/packages/overlays/IconShapeTeardropOverlay/Android.mk b/packages/overlays/IconShapeTeardropOverlay/Android.mk new file mode 100644 index 000000000000..ea43423f93ba --- /dev/null +++ b/packages/overlays/IconShapeTeardropOverlay/Android.mk @@ -0,0 +1,30 @@ +# +# Copyright 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. +# + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_RRO_THEME := IconShapeTeardrop +LOCAL_CERTIFICATE := platform + +LOCAL_SRC_FILES := $(call all-subdir-java-files) + +LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res + +LOCAL_PACKAGE_NAME := IconShapeTeardropOverlay +LOCAL_SDK_VERSION := current + +include $(BUILD_RRO_PACKAGE) diff --git a/packages/overlays/IconShapeTeardropOverlay/AndroidManifest.xml b/packages/overlays/IconShapeTeardropOverlay/AndroidManifest.xml new file mode 100644 index 000000000000..b7d5ecb820d9 --- /dev/null +++ b/packages/overlays/IconShapeTeardropOverlay/AndroidManifest.xml @@ -0,0 +1,27 @@ +<!-- +/** + * 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. + */ +--> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.theme.icon.teardrop" + android:versionCode="1" + android:versionName="1.0"> + <overlay android:targetPackage="android" + android:category="android.theme.customization.adaptive_icon_shape" + android:priority="1"/> + + <application android:label="@string/icon_shape_teardrop_overlay" android:hasCode="false"/> +</manifest> diff --git a/packages/overlays/IconShapeTeardropOverlay/res/values/config.xml b/packages/overlays/IconShapeTeardropOverlay/res/values/config.xml new file mode 100644 index 000000000000..43ad04d69c73 --- /dev/null +++ b/packages/overlays/IconShapeTeardropOverlay/res/values/config.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 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. +*/ +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- Specifies the path that is used by AdaptiveIconDrawable class to crop launcher icons. --> + <string name="config_icon_mask" translatable="false">"M50,0A50,50,0,0 1 100,50 L100,85 A15,15,0,0 1 85,100 L50,100 A50,50,0,0 1 50,0z"</string> + <!-- Flag indicating whether round icons should be parsed from the application manifest. --> + <bool name="config_useRoundIcon">false</bool> + +</resources> + diff --git a/packages/overlays/IconShapeTeardropOverlay/res/values/strings.xml b/packages/overlays/IconShapeTeardropOverlay/res/values/strings.xml new file mode 100644 index 000000000000..d946ee8f97f2 --- /dev/null +++ b/packages/overlays/IconShapeTeardropOverlay/res/values/strings.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * 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. + */ +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- Teardrop icon overlay --> + <string name="icon_shape_teardrop_overlay" translatable="false">Teardrop Icons</string> + +</resources> diff --git a/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java b/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java index 0e195bcc98e0..d32c299074a9 100644 --- a/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java +++ b/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java @@ -29,7 +29,6 @@ import android.hardware.weaver.V1_0.WeaverStatus; import android.os.RemoteException; import android.os.UserManager; import android.security.GateKeeper; -import android.security.Scrypt; import android.service.gatekeeper.GateKeeperResponse; import android.service.gatekeeper.IGateKeeperService; import android.util.ArrayMap; @@ -1174,10 +1173,11 @@ public class SyntheticPasswordManager { } protected byte[] scrypt(String password, byte[] salt, int N, int r, int p, int outLen) { - return new Scrypt().scrypt(password.getBytes(), salt, N, r, p, outLen); + return nativeScrypt(password.getBytes(), salt, N, r, p, outLen); } native long nativeSidFromPasswordHandle(byte[] handle); + native byte[] nativeScrypt(byte[] password, byte[] salt, int N, int r, int p, int outLen); protected static ArrayList<Byte> toByteArrayList(byte[] data) { ArrayList<Byte> result = new ArrayList<Byte>(data.length); diff --git a/services/core/jni/Android.bp b/services/core/jni/Android.bp index 5ffcda614770..b85489a92464 100644 --- a/services/core/jni/Android.bp +++ b/services/core/jni/Android.bp @@ -31,6 +31,7 @@ cc_library_static { "com_android_server_input_InputManagerService.cpp", "com_android_server_lights_LightsService.cpp", "com_android_server_location_GnssLocationProvider.cpp", + "com_android_server_locksettings_SyntheticPasswordManager.cpp", "com_android_server_net_NetworkStatsService.cpp", "com_android_server_power_PowerManagerService.cpp", "com_android_server_security_VerityUtils.cpp", @@ -125,6 +126,7 @@ cc_defaults { static_libs: [ "android.hardware.broadcastradio@common-utils-1x-lib", + "libscrypt_static", ], product_variables: { diff --git a/services/core/jni/com_android_server_locksettings_SyntheticPasswordManager.cpp b/services/core/jni/com_android_server_locksettings_SyntheticPasswordManager.cpp new file mode 100644 index 000000000000..bc13fdec6cbc --- /dev/null +++ b/services/core/jni/com_android_server_locksettings_SyntheticPasswordManager.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2016 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. + */ + +#define LOG_TAG "SyntheticPasswordManager" + +#include <nativehelper/JNIHelp.h> +#include "jni.h" + +#include <android_runtime/Log.h> +#include <utils/Timers.h> +#include <utils/misc.h> +#include <utils/String8.h> +#include <utils/Log.h> +#include <gatekeeper/password_handle.h> + + +extern "C" { +#include "crypto_scrypt.h" +} + +namespace android { + +static jlong android_server_SyntheticPasswordManager_nativeSidFromPasswordHandle(JNIEnv* env, jobject, jbyteArray handleArray) { + + jbyte* data = (jbyte*)env->GetPrimitiveArrayCritical(handleArray, NULL); + + if (data != NULL) { + const gatekeeper::password_handle_t *handle = + reinterpret_cast<const gatekeeper::password_handle_t *>(data); + jlong sid = handle->user_id; + env->ReleasePrimitiveArrayCritical(handleArray, data, JNI_ABORT); + return sid; + } else { + return 0; + } +} + +static jbyteArray android_server_SyntheticPasswordManager_nativeScrypt(JNIEnv* env, jobject, jbyteArray password, jbyteArray salt, jint N, jint r, jint p, jint outLen) { + if (!password || !salt) { + return NULL; + } + + int passwordLen = env->GetArrayLength(password); + int saltLen = env->GetArrayLength(salt); + jbyteArray ret = env->NewByteArray(outLen); + + jbyte* passwordPtr = (jbyte*)env->GetByteArrayElements(password, NULL); + jbyte* saltPtr = (jbyte*)env->GetByteArrayElements(salt, NULL); + jbyte* retPtr = (jbyte*)env->GetByteArrayElements(ret, NULL); + + int rc = crypto_scrypt((const uint8_t *)passwordPtr, passwordLen, + (const uint8_t *)saltPtr, saltLen, N, r, p, (uint8_t *)retPtr, + outLen); + env->ReleaseByteArrayElements(password, passwordPtr, JNI_ABORT); + env->ReleaseByteArrayElements(salt, saltPtr, JNI_ABORT); + env->ReleaseByteArrayElements(ret, retPtr, 0); + + if (!rc) { + return ret; + } else { + SLOGE("scrypt failed"); + return NULL; + } +} + +static const JNINativeMethod sMethods[] = { + /* name, signature, funcPtr */ + {"nativeSidFromPasswordHandle", "([B)J", (void*)android_server_SyntheticPasswordManager_nativeSidFromPasswordHandle}, + {"nativeScrypt", "([B[BIIII)[B", (void*)android_server_SyntheticPasswordManager_nativeScrypt}, +}; + +int register_android_server_SyntheticPasswordManager(JNIEnv* env) { + return jniRegisterNativeMethods(env, "com/android/server/locksettings/SyntheticPasswordManager", + sMethods, NELEM(sMethods)); +} + +} /* namespace android */ diff --git a/services/core/jni/onload.cpp b/services/core/jni/onload.cpp index 55cd852af5e9..918f57e2945e 100644 --- a/services/core/jni/onload.cpp +++ b/services/core/jni/onload.cpp @@ -50,6 +50,7 @@ int register_android_server_tv_TvInputHal(JNIEnv* env); int register_android_server_PersistentDataBlockService(JNIEnv* env); int register_android_server_Watchdog(JNIEnv* env); int register_android_server_HardwarePropertiesManagerService(JNIEnv* env); +int register_android_server_SyntheticPasswordManager(JNIEnv* env); int register_android_server_GraphicsStatsService(JNIEnv* env); int register_android_hardware_display_DisplayViewport(JNIEnv* env); int register_android_server_net_NetworkStatsService(JNIEnv* env); @@ -97,6 +98,7 @@ extern "C" jint JNI_OnLoad(JavaVM* vm, void* /* reserved */) register_android_server_PersistentDataBlockService(env); register_android_server_HardwarePropertiesManagerService(env); register_android_server_storage_AppFuse(env); + register_android_server_SyntheticPasswordManager(env); register_android_server_GraphicsStatsService(env); register_android_hardware_display_DisplayViewport(env); register_android_server_net_NetworkStatsService(env); |