Merge "Set each function as default in BluetoothCallback"
diff --git a/Android.bp b/Android.bp
index 6815a0d..29b6bc7 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1173,6 +1173,8 @@
srcs_lib_whitelist_dirs: frameworks_base_subdirs,
srcs_lib_whitelist_pkgs: packages_to_document,
libs: [
+ "conscrypt",
+ "bouncycastle",
"voip-common",
"android.test.mock",
"android-support-annotations",
@@ -1569,7 +1571,7 @@
metalava_annotations_enabled: true,
metalava_previous_api: ":public-api-for-metalava-annotations",
metalava_merge_annotations_dirs: [
- "tools/metalava/manual",
+ "metalava-manual",
],
}
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index 2df7042..ae42882 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -1,8 +1,7 @@
[Hook Scripts]
checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT}
- -fw core/java/android/
+ -fw core/
graphics/java/android
- core/tests/coretests/src/android/
packages/PrintRecommendationService/
packages/PrintSpooler/
packages/PackageInstaller/
diff --git a/apct-tests/perftests/core/src/android/app/ResourcesPerfTest.java b/apct-tests/perftests/core/src/android/app/ResourcesPerfTest.java
new file mode 100644
index 0000000..9cdeb48
--- /dev/null
+++ b/apct-tests/perftests/core/src/android/app/ResourcesPerfTest.java
@@ -0,0 +1,107 @@
+/*
+ * 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;
+
+import static org.junit.Assert.fail;
+
+import android.content.res.AssetManager;
+import android.content.res.Resources;
+import android.content.res.XmlResourceParser;
+import android.perftests.utils.BenchmarkState;
+import android.perftests.utils.PerfStatusReporter;
+import android.support.test.filters.LargeTest;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.IOException;
+
+/**
+ * Benchmarks for {@link android.content.res.Resources}.
+ */
+@LargeTest
+public class ResourcesPerfTest {
+ @Rule
+ public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
+
+ private AssetManager mAsset;
+ private Resources mRes;
+
+ private int mTextId;
+ private int mColorId;
+ private int mIntegerId;
+ private int mLayoutId;
+
+ @Before
+ public void setUp() {
+ mAsset = new AssetManager();
+ mAsset.addAssetPath("/system/framework/framework-res.apk");
+ mRes = new Resources(mAsset, null, null);
+
+ mTextId = mRes.getIdentifier("cancel", "string", "android");
+ mColorId = mRes.getIdentifier("transparent", "color", "android");
+ mIntegerId = mRes.getIdentifier("config_shortAnimTime", "integer", "android");
+ mLayoutId = mRes.getIdentifier("two_line_list_item", "layout", "android");
+ }
+
+ @After
+ public void tearDown() {
+ mAsset.close();
+ }
+
+ @Test
+ public void getText() {
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ while (state.keepRunning()) {
+ mRes.getText(mTextId);
+ }
+ }
+
+ @Test
+ public void getColor() {
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ while (state.keepRunning()) {
+ mRes.getColor(mColorId, null);
+ }
+ }
+
+ @Test
+ public void getInteger() {
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ while (state.keepRunning()) {
+ mRes.getInteger(mIntegerId);
+ }
+ }
+
+ @Test
+ public void getLayoutAndTravese() {
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ while (state.keepRunning()) {
+ try (XmlResourceParser parser = mRes.getLayout(mLayoutId)) {
+ while (parser.next() != XmlPullParser.END_DOCUMENT) {
+ // Walk the entire tree
+ }
+ } catch (IOException | XmlPullParserException exception) {
+ fail("Parsing of the layout failed. Something is really broken");
+ }
+ }
+ }
+}
diff --git a/api/current.txt b/api/current.txt
index d70d1e7..d554d77 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -1323,7 +1323,7 @@
field public static final int targetName = 16843853; // 0x101044d
field public static final int targetPackage = 16842785; // 0x1010021
field public static final int targetProcesses = 16844097; // 0x1010541
- field public static final int targetSandboxVersion = 16844108; // 0x101054c
+ field public static final deprecated int targetSandboxVersion = 16844108; // 0x101054c
field public static final int targetSdkVersion = 16843376; // 0x1010270
field public static final int taskAffinity = 16842770; // 0x1010012
field public static final int taskCloseEnterAnimation = 16842942; // 0x10100be
@@ -27716,6 +27716,7 @@
method public java.util.Date getValidNotAfterDate();
method public deprecated java.lang.String getValidNotBefore();
method public java.util.Date getValidNotBeforeDate();
+ method public java.security.cert.X509Certificate getX509Certificate();
method public static android.net.http.SslCertificate restoreState(android.os.Bundle);
method public static android.os.Bundle saveState(android.net.http.SslCertificate);
}
@@ -35621,11 +35622,11 @@
protected static abstract interface ContactsContract.ContactOptionsColumns {
field public static final java.lang.String CUSTOM_RINGTONE = "custom_ringtone";
- field public static final java.lang.String LAST_TIME_CONTACTED = "last_time_contacted";
+ field public static final deprecated java.lang.String LAST_TIME_CONTACTED = "last_time_contacted";
field public static final java.lang.String PINNED = "pinned";
field public static final java.lang.String SEND_TO_VOICEMAIL = "send_to_voicemail";
field public static final java.lang.String STARRED = "starred";
- field public static final java.lang.String TIMES_CONTACTED = "times_contacted";
+ field public static final deprecated java.lang.String TIMES_CONTACTED = "times_contacted";
}
protected static abstract interface ContactsContract.ContactStatusColumns {
@@ -35647,7 +35648,7 @@
method public static java.io.InputStream openContactPhotoInputStream(android.content.ContentResolver, android.net.Uri, boolean);
method public static java.io.InputStream openContactPhotoInputStream(android.content.ContentResolver, android.net.Uri);
field public static final android.net.Uri CONTENT_FILTER_URI;
- field public static final android.net.Uri CONTENT_FREQUENT_URI;
+ field public static final deprecated android.net.Uri CONTENT_FREQUENT_URI;
field public static final android.net.Uri CONTENT_GROUP_URI;
field public static final java.lang.String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact";
field public static final android.net.Uri CONTENT_LOOKUP_URI;
@@ -35755,7 +35756,7 @@
protected static abstract interface ContactsContract.DataColumnsWithJoins implements android.provider.BaseColumns android.provider.ContactsContract.ContactNameColumns android.provider.ContactsContract.ContactOptionsColumns android.provider.ContactsContract.ContactStatusColumns android.provider.ContactsContract.ContactsColumns android.provider.ContactsContract.DataColumns android.provider.ContactsContract.DataUsageStatColumns android.provider.ContactsContract.RawContactsColumns android.provider.ContactsContract.StatusColumns {
}
- public static final class ContactsContract.DataUsageFeedback {
+ public static final deprecated class ContactsContract.DataUsageFeedback {
ctor public ContactsContract.DataUsageFeedback();
field public static final android.net.Uri DELETE_USAGE_URI;
field public static final android.net.Uri FEEDBACK_URI;
@@ -35766,8 +35767,8 @@
}
protected static abstract interface ContactsContract.DataUsageStatColumns {
- field public static final java.lang.String LAST_TIME_USED = "last_time_used";
- field public static final java.lang.String TIMES_USED = "times_used";
+ field public static final deprecated java.lang.String LAST_TIME_USED = "last_time_used";
+ field public static final deprecated java.lang.String TIMES_USED = "times_used";
}
public static final class ContactsContract.DeletedContacts implements android.provider.ContactsContract.DeletedContactsColumns {
diff --git a/api/system-current.txt b/api/system-current.txt
index 01f4709..6a00815 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -4371,7 +4371,10 @@
field public static final java.lang.String AUTOFILL_USER_DATA_MAX_USER_DATA_SIZE = "autofill_user_data_max_user_data_size";
field public static final java.lang.String AUTOFILL_USER_DATA_MAX_VALUE_LENGTH = "autofill_user_data_max_value_length";
field public static final java.lang.String AUTOFILL_USER_DATA_MIN_VALUE_LENGTH = "autofill_user_data_min_value_length";
+ field public static final java.lang.String HUSH_GESTURE_USED = "hush_gesture_used";
field public static final java.lang.String INSTANT_APPS_ENABLED = "instant_apps_enabled";
+ field public static final java.lang.String MANUAL_RINGER_TOGGLE_COUNT = "manual_ringer_toggle_count";
+ field public static final java.lang.String VOLUME_HUSH_GESTURE = "volume_hush_gesture";
}
public final class TimeZoneRulesDataContract {
diff --git a/cmds/incident_helper/src/ih_util.cpp b/cmds/incident_helper/src/ih_util.cpp
index 4c4d1b9..012310c 100644
--- a/cmds/incident_helper/src/ih_util.cpp
+++ b/cmds/incident_helper/src/ih_util.cpp
@@ -97,7 +97,7 @@
size_t lastIndex = 0;
int i = 0;
- while (headerNames[i] != NULL) {
+ while (headerNames[i] != nullptr) {
std::string s = headerNames[i];
lastIndex = line.find(s, lastIndex);
if (lastIndex == std::string::npos) {
@@ -237,18 +237,18 @@
Reader::Reader(const int fd)
{
mFile = fdopen(fd, "r");
- mStatus = mFile == NULL ? "Invalid fd " + std::to_string(fd) : "";
+ mStatus = mFile == nullptr ? "Invalid fd " + std::to_string(fd) : "";
}
Reader::~Reader()
{
- if (mFile != NULL) fclose(mFile);
+ if (mFile != nullptr) fclose(mFile);
}
bool Reader::readLine(std::string* line) {
- if (mFile == NULL) return false;
+ if (mFile == nullptr) return false;
- char* buf = NULL;
+ char* buf = nullptr;
size_t len = 0;
ssize_t read = getline(&buf, &len, mFile);
if (read != -1) {
diff --git a/cmds/incident_helper/src/main.cpp b/cmds/incident_helper/src/main.cpp
index 5b6ac7a..809a771 100644
--- a/cmds/incident_helper/src/main.cpp
+++ b/cmds/incident_helper/src/main.cpp
@@ -98,7 +98,7 @@
fprintf(stderr, "Pasring section %d...\n", sectionID);
TextParserBase* parser = selectParser(sectionID);
- if (parser != NULL) {
+ if (parser != nullptr) {
fprintf(stderr, "Running parser: %s\n", parser->name.string());
status_t err = parser->Parse(STDIN_FILENO, STDOUT_FILENO);
if (err != NO_ERROR) {
diff --git a/cmds/incident_helper/src/parsers/CpuInfoParser.cpp b/cmds/incident_helper/src/parsers/CpuInfoParser.cpp
index eed68b9..21ced9c 100644
--- a/cmds/incident_helper/src/parsers/CpuInfoParser.cpp
+++ b/cmds/incident_helper/src/parsers/CpuInfoParser.cpp
@@ -109,7 +109,7 @@
nextToUsage = false;
// NAME is not in the list since we need to modify the end of the CMD index.
- const char* headerNames[] = { "PID", "TID", "USER", "PR", "NI", "CPU", "S", "VIRT", "RES", "PCY", "CMD", NULL };
+ const char* headerNames[] = { "PID", "TID", "USER", "PR", "NI", "CPU", "S", "VIRT", "RES", "PCY", "CMD", nullptr };
if (!getColumnIndices(columnIndices, headerNames, line)) {
return -1;
}
diff --git a/cmds/incident_helper/src/parsers/PageTypeInfoParser.cpp b/cmds/incident_helper/src/parsers/PageTypeInfoParser.cpp
index 0615c74..2a89c920 100644
--- a/cmds/incident_helper/src/parsers/PageTypeInfoParser.cpp
+++ b/cmds/incident_helper/src/parsers/PageTypeInfoParser.cpp
@@ -75,18 +75,13 @@
} else return BAD_VALUE;
// expect part 2 starts with "type"
if (stripPrefix(&record[2], "type")) {
- // expect the rest of part 2 has number of (pageBlockOrder + 2) parts
// An example looks like:
// header line: type 0 1 2 3 4 5 6 7 8 9 10
// record line: Unmovable 426 279 226 1 1 1 0 0 2 2 0
- // The pageBlockOrder = 10 and it's zero-indexed. so total parts
- // are 10 + 1(zero-indexed) + 1(the type part) = 12.
record_t pageCounts = parseRecord(record[2]);
- int pageCountsSize = pageBlockOrder + 2;
- if ((int)pageCounts.size() != pageCountsSize) return BAD_VALUE;
proto.write(PageTypeInfoProto::MigrateType::TYPE, pageCounts[0]);
- for (auto i=1; i<pageCountsSize; i++) {
+ for (size_t i=1; i<pageCounts.size(); i++) {
proto.write(PageTypeInfoProto::MigrateType::FREE_PAGES_COUNT, toInt(pageCounts[i]));
}
} else return BAD_VALUE;
@@ -125,4 +120,4 @@
fprintf(stderr, "[%s]Proto size: %zu bytes\n", this->name.string(), proto.size());
return NO_ERROR;
-}
\ No newline at end of file
+}
diff --git a/cmds/incident_helper/src/parsers/PsParser.cpp b/cmds/incident_helper/src/parsers/PsParser.cpp
index 8d64064..d3cb4be 100644
--- a/cmds/incident_helper/src/parsers/PsParser.cpp
+++ b/cmds/incident_helper/src/parsers/PsParser.cpp
@@ -48,7 +48,7 @@
if (nline++ == 0) {
header = parseHeader(line, DEFAULT_WHITESPACE);
- const char* headerNames[] = { "LABEL", "USER", "PID", "TID", "PPID", "VSZ", "RSS", "WCHAN", "ADDR", "S", "PRI", "NI", "RTPRIO", "SCH", "PCY", "TIME", "CMD", NULL };
+ const char* headerNames[] = { "LABEL", "USER", "PID", "TID", "PPID", "VSZ", "RSS", "WCHAN", "ADDR", "S", "PRI", "NI", "RTPRIO", "SCH", "PCY", "TIME", "CMD", nullptr };
if (!getColumnIndices(columnIndices, headerNames, line)) {
return -1;
}
diff --git a/cmds/incident_helper/testdata/pagetypeinfo.txt b/cmds/incident_helper/testdata/pagetypeinfo.txt
index d45ddc4..c65b5a1 100644
--- a/cmds/incident_helper/testdata/pagetypeinfo.txt
+++ b/cmds/incident_helper/testdata/pagetypeinfo.txt
@@ -1,5 +1,5 @@
-Page block order: 10
-Pages per block: 1024
+Page block order: 9
+Pages per block: 512
Free pages count per migrate type at order 0 1 2 3 4 5 6 7 8 9 10
Node 0, zone DMA, type Unmovable 426 279 226 1 1 1 0 0 2 2 0
diff --git a/cmds/incident_helper/tests/PageTypeInfoParser_test.cpp b/cmds/incident_helper/tests/PageTypeInfoParser_test.cpp
index 9bad7be..5688681 100644
--- a/cmds/incident_helper/tests/PageTypeInfoParser_test.cpp
+++ b/cmds/incident_helper/tests/PageTypeInfoParser_test.cpp
@@ -54,8 +54,8 @@
PageTypeInfoParser parser;
PageTypeInfoProto expected;
- expected.set_page_block_order(10);
- expected.set_pages_per_block(1024);
+ expected.set_page_block_order(9);
+ expected.set_pages_per_block(512);
PageTypeInfoProto::MigrateType* mt1 = expected.add_migrate_types();
mt1->set_node(0);
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index 203a8e9b..d7a926f 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -1727,6 +1727,17 @@
optional uint64 timestamp_millis = 1 [(stateFieldOption).option = EXCLUSIVE];
}
+/**
+ * An atom for generic metrics logging. Available from Android Q.
+ */
+message GenericAtom {
+ // The uid of the application that sent this custom atom.
+ optional int32 uid = 1 [(is_uid) = true];
+
+ // An event_id indicates the type of event.
+ optional int32 event_id = 2;
+}
+
//////////////////////////////////////////////////////////////////////
// Pulled atoms below this line //
//////////////////////////////////////////////////////////////////////
@@ -2156,14 +2167,3 @@
// Total number of exceptions.
optional int64 exception_count = 2;
}
-
-/**
- * An atom for generic metrics logging. Available from Android Q.
- */
-message GenericAtom {
- // The uid of the application that sent this custom atom.
- optional int32 uid = 1 [(is_uid) = true];
-
- // An event_id indicates the type of event.
- optional int32 event_id = 2;
-}
diff --git a/config/hiddenapi-light-greylist.txt b/config/hiddenapi-light-greylist.txt
index 022745f..c30f2f5 100644
--- a/config/hiddenapi-light-greylist.txt
+++ b/config/hiddenapi-light-greylist.txt
@@ -4212,96 +4212,6 @@
Landroid/R$styleable;->Window:[I
Landroid/R$styleable;->Window_windowBackground:I
Landroid/R$styleable;->Window_windowFrame:I
-Landroid/renderscript/BaseObj;->mRS:Landroid/renderscript/RenderScript;
-Landroid/renderscript/Element;->createUser(Landroid/renderscript/RenderScript;Landroid/renderscript/Element$DataType;)Landroid/renderscript/Element;
-Landroid/renderscript/FileA3D$EntryType;->MESH:Landroid/renderscript/FileA3D$EntryType;
-Landroid/renderscript/FileA3D$IndexEntry;->getEntryType()Landroid/renderscript/FileA3D$EntryType;
-Landroid/renderscript/FileA3D$IndexEntry;->getObject()Landroid/renderscript/BaseObj;
-Landroid/renderscript/FileA3D;->createFromResource(Landroid/renderscript/RenderScript;Landroid/content/res/Resources;I)Landroid/renderscript/FileA3D;
-Landroid/renderscript/FileA3D;->getIndexEntry(I)Landroid/renderscript/FileA3D$IndexEntry;
-Landroid/renderscript/Font$Style;->ITALIC:Landroid/renderscript/Font$Style;
-Landroid/renderscript/Font;->create(Landroid/renderscript/RenderScript;Landroid/content/res/Resources;Ljava/lang/String;Landroid/renderscript/Font$Style;F)Landroid/renderscript/Font;
-Landroid/renderscript/Matrix4f;->mMat:[F
-Landroid/renderscript/Mesh$AllocationBuilder;-><init>(Landroid/renderscript/RenderScript;)V
-Landroid/renderscript/Mesh$AllocationBuilder;->addIndexSetAllocation(Landroid/renderscript/Allocation;Landroid/renderscript/Mesh$Primitive;)Landroid/renderscript/Mesh$AllocationBuilder;
-Landroid/renderscript/Mesh$AllocationBuilder;->addIndexSetType(Landroid/renderscript/Mesh$Primitive;)Landroid/renderscript/Mesh$AllocationBuilder;
-Landroid/renderscript/Mesh$AllocationBuilder;->addVertexAllocation(Landroid/renderscript/Allocation;)Landroid/renderscript/Mesh$AllocationBuilder;
-Landroid/renderscript/Mesh$AllocationBuilder;->create()Landroid/renderscript/Mesh;
-Landroid/renderscript/Mesh$Primitive;->POINT:Landroid/renderscript/Mesh$Primitive;
-Landroid/renderscript/Mesh$Primitive;->TRIANGLE:Landroid/renderscript/Mesh$Primitive;
-Landroid/renderscript/Mesh$TriangleMeshBuilder;-><init>(Landroid/renderscript/RenderScript;II)V
-Landroid/renderscript/Mesh$TriangleMeshBuilder;->addTriangle(III)Landroid/renderscript/Mesh$TriangleMeshBuilder;
-Landroid/renderscript/Mesh$TriangleMeshBuilder;->addVertex(FF)Landroid/renderscript/Mesh$TriangleMeshBuilder;
-Landroid/renderscript/Mesh$TriangleMeshBuilder;->create(Z)Landroid/renderscript/Mesh;
-Landroid/renderscript/Mesh;->getVertexAllocation(I)Landroid/renderscript/Allocation;
-Landroid/renderscript/Program$BaseProgramBuilder;-><init>(Landroid/renderscript/RenderScript;)V
-Landroid/renderscript/Program$BaseProgramBuilder;->mConstantCount:I
-Landroid/renderscript/Program$BaseProgramBuilder;->mConstants:[Landroid/renderscript/Type;
-Landroid/renderscript/Program$BaseProgramBuilder;->mInputCount:I
-Landroid/renderscript/Program$BaseProgramBuilder;->mInputs:[Landroid/renderscript/Element;
-Landroid/renderscript/Program$BaseProgramBuilder;->mOutputCount:I
-Landroid/renderscript/Program$BaseProgramBuilder;->mOutputs:[Landroid/renderscript/Element;
-Landroid/renderscript/Program$BaseProgramBuilder;->mRS:Landroid/renderscript/RenderScript;
-Landroid/renderscript/Program$BaseProgramBuilder;->mShader:Ljava/lang/String;
-Landroid/renderscript/Program$BaseProgramBuilder;->mTextureCount:I
-Landroid/renderscript/Program$TextureType;->TEXTURE_2D:Landroid/renderscript/Program$TextureType;
-Landroid/renderscript/ProgramFragment$Builder;-><init>(Landroid/renderscript/RenderScript;)V
-Landroid/renderscript/ProgramFragment$Builder;->create()Landroid/renderscript/ProgramFragment;
-Landroid/renderscript/ProgramFragmentFixedFunction$Builder$EnvMode;->MODULATE:Landroid/renderscript/ProgramFragmentFixedFunction$Builder$EnvMode;
-Landroid/renderscript/ProgramFragmentFixedFunction$Builder$EnvMode;->REPLACE:Landroid/renderscript/ProgramFragmentFixedFunction$Builder$EnvMode;
-Landroid/renderscript/ProgramFragmentFixedFunction$Builder$Format;->ALPHA:Landroid/renderscript/ProgramFragmentFixedFunction$Builder$Format;
-Landroid/renderscript/ProgramFragmentFixedFunction$Builder$Format;->RGB:Landroid/renderscript/ProgramFragmentFixedFunction$Builder$Format;
-Landroid/renderscript/ProgramFragmentFixedFunction$Builder$Format;->RGBA:Landroid/renderscript/ProgramFragmentFixedFunction$Builder$Format;
-Landroid/renderscript/ProgramFragmentFixedFunction$Builder;-><init>(Landroid/renderscript/RenderScript;)V
-Landroid/renderscript/ProgramFragmentFixedFunction$Builder;->create()Landroid/renderscript/ProgramFragmentFixedFunction;
-Landroid/renderscript/ProgramFragmentFixedFunction$Builder;->setTexture(Landroid/renderscript/ProgramFragmentFixedFunction$Builder$EnvMode;Landroid/renderscript/ProgramFragmentFixedFunction$Builder$Format;I)Landroid/renderscript/ProgramFragmentFixedFunction$Builder;
-Landroid/renderscript/ProgramFragmentFixedFunction$Builder;->setVaryingColor(Z)Landroid/renderscript/ProgramFragmentFixedFunction$Builder;
-Landroid/renderscript/ProgramRaster$Builder;-><init>(Landroid/renderscript/RenderScript;)V
-Landroid/renderscript/ProgramRaster$Builder;->create()Landroid/renderscript/ProgramRaster;
-Landroid/renderscript/ProgramRaster$Builder;->setPointSpriteEnabled(Z)Landroid/renderscript/ProgramRaster$Builder;
-Landroid/renderscript/ProgramStore$BlendDstFunc;->ONE:Landroid/renderscript/ProgramStore$BlendDstFunc;
-Landroid/renderscript/ProgramStore$BlendDstFunc;->ONE_MINUS_SRC_ALPHA:Landroid/renderscript/ProgramStore$BlendDstFunc;
-Landroid/renderscript/ProgramStore$BlendDstFunc;->ZERO:Landroid/renderscript/ProgramStore$BlendDstFunc;
-Landroid/renderscript/ProgramStore$BlendSrcFunc;->ONE:Landroid/renderscript/ProgramStore$BlendSrcFunc;
-Landroid/renderscript/ProgramStore$BlendSrcFunc;->SRC_ALPHA:Landroid/renderscript/ProgramStore$BlendSrcFunc;
-Landroid/renderscript/ProgramStore$Builder;-><init>(Landroid/renderscript/RenderScript;)V
-Landroid/renderscript/ProgramStore$Builder;->create()Landroid/renderscript/ProgramStore;
-Landroid/renderscript/ProgramStore$Builder;->setBlendFunc(Landroid/renderscript/ProgramStore$BlendSrcFunc;Landroid/renderscript/ProgramStore$BlendDstFunc;)Landroid/renderscript/ProgramStore$Builder;
-Landroid/renderscript/ProgramStore$Builder;->setDepthFunc(Landroid/renderscript/ProgramStore$DepthFunc;)Landroid/renderscript/ProgramStore$Builder;
-Landroid/renderscript/ProgramStore$Builder;->setDepthMaskEnabled(Z)Landroid/renderscript/ProgramStore$Builder;
-Landroid/renderscript/ProgramStore$Builder;->setDitherEnabled(Z)Landroid/renderscript/ProgramStore$Builder;
-Landroid/renderscript/ProgramStore$DepthFunc;->ALWAYS:Landroid/renderscript/ProgramStore$DepthFunc;
-Landroid/renderscript/ProgramStore$DepthFunc;->LESS:Landroid/renderscript/ProgramStore$DepthFunc;
-Landroid/renderscript/ProgramStore;->BLEND_ALPHA_DEPTH_NONE(Landroid/renderscript/RenderScript;)Landroid/renderscript/ProgramStore;
-Landroid/renderscript/ProgramVertex$Builder;-><init>(Landroid/renderscript/RenderScript;)V
-Landroid/renderscript/ProgramVertex$Builder;->addInput(Landroid/renderscript/Element;)Landroid/renderscript/ProgramVertex$Builder;
-Landroid/renderscript/ProgramVertex$Builder;->create()Landroid/renderscript/ProgramVertex;
-Landroid/renderscript/ProgramVertexFixedFunction$Builder;-><init>(Landroid/renderscript/RenderScript;)V
-Landroid/renderscript/ProgramVertexFixedFunction$Builder;->create()Landroid/renderscript/ProgramVertexFixedFunction;
-Landroid/renderscript/ProgramVertexFixedFunction$Constants;-><init>(Landroid/renderscript/RenderScript;)V
-Landroid/renderscript/ProgramVertexFixedFunction$Constants;->setProjection(Landroid/renderscript/Matrix4f;)V
-Landroid/renderscript/ProgramVertexFixedFunction;->bindConstants(Landroid/renderscript/ProgramVertexFixedFunction$Constants;)V
-Landroid/renderscript/RenderScript;->create(Landroid/content/Context;I)Landroid/renderscript/RenderScript;
-Landroid/renderscript/RenderScript;->create(Landroid/content/Context;ILandroid/renderscript/RenderScript$ContextType;I)Landroid/renderscript/RenderScript;
-Landroid/renderscript/RenderScript;->getMinorID()J
-Landroid/renderscript/RenderScript;->mMessageCallback:Landroid/renderscript/RenderScript$RSMessageHandler;
-Landroid/renderscript/RenderScript;->nScriptCCreate(Ljava/lang/String;Ljava/lang/String;[BI)J
-Landroid/renderscript/RenderScript;->sPointerSize:I
-Landroid/renderscript/RenderScript;->validate()V
-Landroid/renderscript/RenderScriptCacheDir;->mCacheDir:Ljava/io/File;
-Landroid/renderscript/RenderScriptCacheDir;->setupDiskCache(Ljava/io/File;)V
-Landroid/renderscript/RenderScriptGL$SurfaceConfig;-><init>()V
-Landroid/renderscript/RenderScriptGL$SurfaceConfig;->setDepth(II)V
-Landroid/renderscript/RenderScriptGL;-><init>(Landroid/content/Context;Landroid/renderscript/RenderScriptGL$SurfaceConfig;)V
-Landroid/renderscript/RenderScriptGL;->bindProgramRaster(Landroid/renderscript/ProgramRaster;)V
-Landroid/renderscript/RenderScriptGL;->bindProgramStore(Landroid/renderscript/ProgramStore;)V
-Landroid/renderscript/RenderScriptGL;->bindProgramVertex(Landroid/renderscript/ProgramVertex;)V
-Landroid/renderscript/RenderScriptGL;->bindRootScript(Landroid/renderscript/Script;)V
-Landroid/renderscript/RenderScriptGL;->setSurface(Landroid/view/SurfaceHolder;II)V
-Landroid/renderscript/RSSurfaceView;-><init>(Landroid/content/Context;)V
-Landroid/renderscript/RSSurfaceView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
-Landroid/renderscript/Script$Builder;-><init>(Landroid/renderscript/RenderScript;)V
-Landroid/renderscript/Script$Builder;->mRS:Landroid/renderscript/RenderScript;
Landroid/security/Credentials;->convertToPem([Ljava/security/cert/Certificate;)[B
Landroid/security/Credentials;->getInstance()Landroid/security/Credentials;
Landroid/security/Credentials;->install(Landroid/content/Context;Ljava/lang/String;[B)V
@@ -4439,17 +4349,6 @@
Landroid/service/wallpaper/WallpaperService$Engine;->setFixedSizeAllowed(Z)V
Landroid/service/wallpaper/WallpaperService;->MSG_WINDOW_RESIZED:I
Landroid/speech/IRecognitionListener;->onEvent(ILandroid/os/Bundle;)V
-Landroid/speech/tts/TextToSpeech;->getCurrentEngine()Ljava/lang/String;
-Landroid/speech/tts/TextToSpeech;->mConnectingServiceConnection:Landroid/speech/tts/TextToSpeech$Connection;
-Landroid/speech/tts/TextToSpeech;->mCurrentEngine:Ljava/lang/String;
-Landroid/speech/tts/TextToSpeech;->mInitListener:Landroid/speech/tts/TextToSpeech$OnInitListener;
-Landroid/speech/tts/TtsEngines;-><init>(Landroid/content/Context;)V
-Landroid/speech/tts/TtsEngines;->getEngines()Ljava/util/List;
-Landroid/speech/tts/TtsEngines;->getLocalePrefForEngine(Ljava/lang/String;)Ljava/util/Locale;
-Landroid/speech/tts/TtsEngines;->getSettingsIntent(Ljava/lang/String;)Landroid/content/Intent;
-Landroid/speech/tts/TtsEngines;->normalizeTTSLocale(Ljava/util/Locale;)Ljava/util/Locale;
-Landroid/speech/tts/TtsEngines;->parseLocaleString(Ljava/lang/String;)Ljava/util/Locale;
-Landroid/speech/tts/TtsEngines;->updateLocalePrefForEngine(Ljava/lang/String;Ljava/util/Locale;)V
Landroid/system/Int32Ref;->value:I
Landroid/system/OsConstants;-><init>()V
Landroid/system/OsConstants;->AF_NETLINK:I
@@ -4506,26 +4405,6 @@
Landroid/system/OsConstants;->XATTR_REPLACE:I
Landroid/system/OsConstants;->_LINUX_CAPABILITY_VERSION_3:I
Landroid/system/StructTimeval;->fromMillis(J)Landroid/system/StructTimeval;
-Landroid/telecom/AudioState;->isMuted:Z
-Landroid/telecom/AudioState;->route:I
-Landroid/telecom/AudioState;->supportedRouteMask:I
-Landroid/telecom/Call$Details;->CAPABILITY_CAN_UPGRADE_TO_VIDEO:I
-Landroid/telecom/Connection$VideoProvider;-><init>(Landroid/os/Looper;)V
-Landroid/telecom/Phone;->setProximitySensorOff(Z)V
-Landroid/telecom/Phone;->setProximitySensorOn()V
-Landroid/telecom/PhoneAccountHandle;-><init>(Landroid/os/Parcel;)V
-Landroid/telecom/PhoneAccountHandle;->mComponentName:Landroid/content/ComponentName;
-Landroid/telecom/PhoneAccountHandle;->mId:Ljava/lang/String;
-Landroid/telecom/TelecomManager;->EXTRA_IS_HANDOVER:Ljava/lang/String;
-Landroid/telecom/TelecomManager;->getCallCapablePhoneAccounts(Z)Ljava/util/List;
-Landroid/telecom/TelecomManager;->getCurrentTtyMode()I
-Landroid/telecom/TelecomManager;->getSimCallManager(I)Landroid/telecom/PhoneAccountHandle;
-Landroid/telecom/TelecomManager;->getSystemDialerPackage()Ljava/lang/String;
-Landroid/telecom/TelecomManager;->getUserSelectedOutgoingPhoneAccount()Landroid/telecom/PhoneAccountHandle;
-Landroid/telecom/TelecomManager;->setDefaultDialer(Ljava/lang/String;)Z
-Landroid/telecom/TelecomManager;->setUserSelectedOutgoingPhoneAccount(Landroid/telecom/PhoneAccountHandle;)V
-Landroid/telecom/TelecomManager;->TTY_MODE_OFF:I
-Landroid/telecom/VideoCallImpl;->destroy()V
Landroid/telephony/CarrierConfigManager;->KEY_CARRIER_DEFAULT_ACTIONS_ON_REDIRECTION_STRING_ARRAY:Ljava/lang/String;
Landroid/telephony/CarrierConfigManager;->KEY_DISABLE_VOICE_BARRING_NOTIFICATION_BOOL:Ljava/lang/String;
Landroid/telephony/CarrierMessagingServiceManager;-><init>()V
@@ -4947,7 +4826,6 @@
Landroid/text/SpannableStringBuilder;->sendToSpanWatchers(III)V
Landroid/text/SpannableStringBuilder;->substring(II)Ljava/lang/String;
Landroid/text/SpannableStringInternal;-><init>(Ljava/lang/CharSequence;II)V
-Landroid/text/SpannableStringInternal;->charAt(I)C
Landroid/text/SpannableStringInternal;->checkRange(Ljava/lang/String;II)V
Landroid/text/SpannableStringInternal;->COLUMNS:I
Landroid/text/SpannableStringInternal;->copySpans(Landroid/text/SpannableStringInternal;II)V
@@ -4955,14 +4833,12 @@
Landroid/text/SpannableStringInternal;->EMPTY:[Ljava/lang/Object;
Landroid/text/SpannableStringInternal;->END:I
Landroid/text/SpannableStringInternal;->FLAGS:I
-Landroid/text/SpannableStringInternal;->getChars(II[CI)V
Landroid/text/SpannableStringInternal;->getSpanEnd(Ljava/lang/Object;)I
Landroid/text/SpannableStringInternal;->getSpanFlags(Ljava/lang/Object;)I
Landroid/text/SpannableStringInternal;->getSpans(IILjava/lang/Class;)[Ljava/lang/Object;
Landroid/text/SpannableStringInternal;->getSpanStart(Ljava/lang/Object;)I
Landroid/text/SpannableStringInternal;->isIndexFollowsNextLine(I)Z
Landroid/text/SpannableStringInternal;->isOutOfCopyRange(IIII)Z
-Landroid/text/SpannableStringInternal;->length()I
Landroid/text/SpannableStringInternal;->mSpanCount:I
Landroid/text/SpannableStringInternal;->mSpanData:[I
Landroid/text/SpannableStringInternal;->mSpans:[Ljava/lang/Object;
diff --git a/config/hiddenapi-vendor-list.txt b/config/hiddenapi-vendor-list.txt
index 66f28a9..0353e65 100644
--- a/config/hiddenapi-vendor-list.txt
+++ b/config/hiddenapi-vendor-list.txt
@@ -389,13 +389,6 @@
Landroid/system/Os;->setsockoptTimeval(Ljava/io/FileDescriptor;IILandroid/system/StructTimeval;)V
Landroid/system/PacketSocketAddress;-><init>(I[B)V
Landroid/system/PacketSocketAddress;-><init>(SI)V
-Landroid/telecom/ParcelableCall;->CREATOR:Landroid/os/Parcelable$Creator;
-Landroid/telecom/ParcelableCall;->getConnectTimeMillis()J
-Landroid/telecom/ParcelableCall;->getDisconnectCause()Landroid/telecom/DisconnectCause;
-Landroid/telecom/ParcelableCall;->getHandle()Landroid/net/Uri;
-Landroid/telecom/ParcelableCall;->getId()Ljava/lang/String;
-Landroid/telecom/TelecomManager;->from(Landroid/content/Context;)Landroid/telecom/TelecomManager;
-Landroid/telecom/VideoProfile$CameraCapabilities;-><init>(IIZF)V
Landroid/telephony/euicc/DownloadableSubscription;->encodedActivationCode:Ljava/lang/String;
Landroid/telephony/euicc/DownloadableSubscription;->setAccessRules([Landroid/telephony/UiccAccessRule;)V
Landroid/telephony/euicc/DownloadableSubscription;->setCarrierName(Ljava/lang/String;)V
diff --git a/core/java/android/app/JobSchedulerImpl.java b/core/java/android/app/JobSchedulerImpl.java
index 4ac44f7..5494e2a 100644
--- a/core/java/android/app/JobSchedulerImpl.java
+++ b/core/java/android/app/JobSchedulerImpl.java
@@ -17,16 +17,15 @@
// in android.app so ContextImpl has package access
package android.app;
+import android.app.job.IJobScheduler;
import android.app.job.JobInfo;
import android.app.job.JobScheduler;
-import android.app.job.IJobScheduler;
+import android.app.job.JobSnapshot;
import android.app.job.JobWorkItem;
-import android.content.Intent;
import android.os.RemoteException;
import java.util.List;
-
/**
* Concrete implementation of the JobScheduler interface
* @hide
@@ -98,4 +97,22 @@
return null;
}
}
+
+ @Override
+ public List<JobInfo> getStartedJobs() {
+ try {
+ return mBinder.getStartedJobs();
+ } catch (RemoteException e) {
+ return null;
+ }
+ }
+
+ @Override
+ public List<JobSnapshot> getAllJobSnapshots() {
+ try {
+ return mBinder.getAllJobSnapshots();
+ } catch (RemoteException e) {
+ return null;
+ }
+ }
}
diff --git a/core/java/android/app/job/IJobScheduler.aidl b/core/java/android/app/job/IJobScheduler.aidl
index e94da0c..53b33c2 100644
--- a/core/java/android/app/job/IJobScheduler.aidl
+++ b/core/java/android/app/job/IJobScheduler.aidl
@@ -17,6 +17,7 @@
package android.app.job;
import android.app.job.JobInfo;
+import android.app.job.JobSnapshot;
import android.app.job.JobWorkItem;
/**
@@ -31,4 +32,6 @@
void cancelAll();
List<JobInfo> getAllPendingJobs();
JobInfo getPendingJob(int jobId);
+ List<JobInfo> getStartedJobs();
+ List<JobSnapshot> getAllJobSnapshots();
}
diff --git a/core/java/android/app/job/JobScheduler.java b/core/java/android/app/job/JobScheduler.java
index 0deb2e1..08b1c2b 100644
--- a/core/java/android/app/job/JobScheduler.java
+++ b/core/java/android/app/job/JobScheduler.java
@@ -172,4 +172,20 @@
* if the supplied job ID does not correspond to any job.
*/
public abstract @Nullable JobInfo getPendingJob(int jobId);
-}
+
+ /**
+ * <b>For internal system callers only!</b>
+ * Returns a list of all currently-executing jobs.
+ * @hide
+ */
+ public abstract List<JobInfo> getStartedJobs();
+
+ /**
+ * <b>For internal system callers only!</b>
+ * Returns a snapshot of the state of all jobs known to the system.
+ *
+ * <p class="note">This is a slow operation, so it should be called sparingly.
+ * @hide
+ */
+ public abstract List<JobSnapshot> getAllJobSnapshots();
+}
\ No newline at end of file
diff --git a/core/java/android/app/job/JobSnapshot.aidl b/core/java/android/app/job/JobSnapshot.aidl
new file mode 100644
index 0000000..d40f4e3
--- /dev/null
+++ b/core/java/android/app/job/JobSnapshot.aidl
@@ -0,0 +1,19 @@
+/**
+ * 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.job;
+
+parcelable JobSnapshot;
diff --git a/core/java/android/app/job/JobSnapshot.java b/core/java/android/app/job/JobSnapshot.java
new file mode 100644
index 0000000..d6cc70d
--- /dev/null
+++ b/core/java/android/app/job/JobSnapshot.java
@@ -0,0 +1,111 @@
+/*
+ * 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.job;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Current-state snapshot of a scheduled job. These snapshots are not used in apps;
+ * they exist only within the system process across the local call surface where JobStatus
+ * is not directly accessible at build time.
+ *
+ * Constraints that the underlying job does not require are always reported as
+ * being currently satisfied.
+ * @hide
+ */
+public class JobSnapshot implements Parcelable {
+ private final JobInfo mJob;
+ private final int mSatisfiedConstraints;
+ private final boolean mIsRunnable;
+
+ public JobSnapshot(JobInfo info, int satisfiedMask, boolean runnable) {
+ mJob = info;
+ mSatisfiedConstraints = satisfiedMask;
+ mIsRunnable = runnable;
+ }
+
+ public JobSnapshot(Parcel in) {
+ mJob = JobInfo.CREATOR.createFromParcel(in);
+ mSatisfiedConstraints = in.readInt();
+ mIsRunnable = in.readBoolean();
+ }
+
+ private boolean satisfied(int flag) {
+ return (mSatisfiedConstraints & flag) != 0;
+ }
+
+ /**
+ * Is this job actually runnable at this moment?
+ */
+ public boolean isRunnable() {
+ return mIsRunnable;
+ }
+
+ /**
+ * @see JobInfo.Builder#setRequiresCharging(boolean)
+ */
+ public boolean isChargingSatisfied() {
+ return !mJob.isRequireCharging()
+ || satisfied(JobInfo.CONSTRAINT_FLAG_CHARGING);
+ }
+
+ /**
+ * @see JobInfo.Builder#setRequiresBatteryNotLow(boolean)
+ */
+ public boolean isBatteryNotLowSatisfied() {
+ return !mJob.isRequireBatteryNotLow()
+ || satisfied(JobInfo.CONSTRAINT_FLAG_BATTERY_NOT_LOW);
+ }
+
+ /**
+ * @see JobInfo.Builder#setRequiresDeviceIdle(boolean)
+ */
+ public boolean isRequireDeviceIdleSatisfied() {
+ return !mJob.isRequireDeviceIdle()
+ || satisfied(JobInfo.CONSTRAINT_FLAG_BATTERY_NOT_LOW);
+ }
+
+ public boolean isRequireStorageNotLowSatisfied() {
+ return !mJob.isRequireStorageNotLow()
+ || satisfied(JobInfo.CONSTRAINT_FLAG_STORAGE_NOT_LOW);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ mJob.writeToParcel(out, flags);
+ out.writeInt(mSatisfiedConstraints);
+ out.writeBoolean(mIsRunnable);
+ }
+
+ public static final Creator<JobSnapshot> CREATOR = new Creator<JobSnapshot>() {
+ @Override
+ public JobSnapshot createFromParcel(Parcel in) {
+ return new JobSnapshot(in);
+ }
+
+ @Override
+ public JobSnapshot[] newArray(int size) {
+ return new JobSnapshot[size];
+ }
+ };
+}
diff --git a/core/java/android/content/ContentProvider.java b/core/java/android/content/ContentProvider.java
index cdeaea3..7bde871 100644
--- a/core/java/android/content/ContentProvider.java
+++ b/core/java/android/content/ContentProvider.java
@@ -21,6 +21,7 @@
import static android.app.AppOpsManager.MODE_ERRORED;
import static android.app.AppOpsManager.MODE_IGNORED;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
+import static android.os.Trace.TRACE_TAG_DATABASE;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -42,6 +43,7 @@
import android.os.ParcelFileDescriptor;
import android.os.Process;
import android.os.RemoteException;
+import android.os.Trace;
import android.os.UserHandle;
import android.os.storage.StorageManager;
import android.text.TextUtils;
@@ -235,6 +237,7 @@
// Return an empty cursor for all columns.
return new MatrixCursor(cursor.getColumnNames(), 0);
}
+ Trace.traceBegin(TRACE_TAG_DATABASE, "query");
final String original = setCallingPackage(callingPkg);
try {
return ContentProvider.this.query(
@@ -242,6 +245,7 @@
CancellationSignal.fromTransport(cancellationSignal));
} finally {
setCallingPackage(original);
+ Trace.traceEnd(TRACE_TAG_DATABASE);
}
}
@@ -249,7 +253,12 @@
public String getType(Uri uri) {
validateIncomingUri(uri);
uri = maybeGetUriWithoutUserId(uri);
- return ContentProvider.this.getType(uri);
+ Trace.traceBegin(TRACE_TAG_DATABASE, "getType");
+ try {
+ return ContentProvider.this.getType(uri);
+ } finally {
+ Trace.traceEnd(TRACE_TAG_DATABASE);
+ }
}
@Override
@@ -260,11 +269,13 @@
if (enforceWritePermission(callingPkg, uri, null) != AppOpsManager.MODE_ALLOWED) {
return rejectInsert(uri, initialValues);
}
+ Trace.traceBegin(TRACE_TAG_DATABASE, "insert");
final String original = setCallingPackage(callingPkg);
try {
return maybeAddUserId(ContentProvider.this.insert(uri, initialValues), userId);
} finally {
setCallingPackage(original);
+ Trace.traceEnd(TRACE_TAG_DATABASE);
}
}
@@ -275,11 +286,13 @@
if (enforceWritePermission(callingPkg, uri, null) != AppOpsManager.MODE_ALLOWED) {
return 0;
}
+ Trace.traceBegin(TRACE_TAG_DATABASE, "bulkInsert");
final String original = setCallingPackage(callingPkg);
try {
return ContentProvider.this.bulkInsert(uri, initialValues);
} finally {
setCallingPackage(original);
+ Trace.traceEnd(TRACE_TAG_DATABASE);
}
}
@@ -312,6 +325,7 @@
}
}
}
+ Trace.traceBegin(TRACE_TAG_DATABASE, "applyBatch");
final String original = setCallingPackage(callingPkg);
try {
ContentProviderResult[] results = ContentProvider.this.applyBatch(operations);
@@ -326,6 +340,7 @@
return results;
} finally {
setCallingPackage(original);
+ Trace.traceEnd(TRACE_TAG_DATABASE);
}
}
@@ -336,11 +351,13 @@
if (enforceWritePermission(callingPkg, uri, null) != AppOpsManager.MODE_ALLOWED) {
return 0;
}
+ Trace.traceBegin(TRACE_TAG_DATABASE, "delete");
final String original = setCallingPackage(callingPkg);
try {
return ContentProvider.this.delete(uri, selection, selectionArgs);
} finally {
setCallingPackage(original);
+ Trace.traceEnd(TRACE_TAG_DATABASE);
}
}
@@ -352,11 +369,13 @@
if (enforceWritePermission(callingPkg, uri, null) != AppOpsManager.MODE_ALLOWED) {
return 0;
}
+ Trace.traceBegin(TRACE_TAG_DATABASE, "update");
final String original = setCallingPackage(callingPkg);
try {
return ContentProvider.this.update(uri, values, selection, selectionArgs);
} finally {
setCallingPackage(original);
+ Trace.traceEnd(TRACE_TAG_DATABASE);
}
}
@@ -367,12 +386,14 @@
validateIncomingUri(uri);
uri = maybeGetUriWithoutUserId(uri);
enforceFilePermission(callingPkg, uri, mode, callerToken);
+ Trace.traceBegin(TRACE_TAG_DATABASE, "openFile");
final String original = setCallingPackage(callingPkg);
try {
return ContentProvider.this.openFile(
uri, mode, CancellationSignal.fromTransport(cancellationSignal));
} finally {
setCallingPackage(original);
+ Trace.traceEnd(TRACE_TAG_DATABASE);
}
}
@@ -383,12 +404,14 @@
validateIncomingUri(uri);
uri = maybeGetUriWithoutUserId(uri);
enforceFilePermission(callingPkg, uri, mode, null);
+ Trace.traceBegin(TRACE_TAG_DATABASE, "openAssetFile");
final String original = setCallingPackage(callingPkg);
try {
return ContentProvider.this.openAssetFile(
uri, mode, CancellationSignal.fromTransport(cancellationSignal));
} finally {
setCallingPackage(original);
+ Trace.traceEnd(TRACE_TAG_DATABASE);
}
}
@@ -396,11 +419,13 @@
public Bundle call(
String callingPkg, String method, @Nullable String arg, @Nullable Bundle extras) {
Bundle.setDefusable(extras, true);
+ Trace.traceBegin(TRACE_TAG_DATABASE, "call");
final String original = setCallingPackage(callingPkg);
try {
return ContentProvider.this.call(method, arg, extras);
} finally {
setCallingPackage(original);
+ Trace.traceEnd(TRACE_TAG_DATABASE);
}
}
@@ -408,7 +433,12 @@
public String[] getStreamTypes(Uri uri, String mimeTypeFilter) {
validateIncomingUri(uri);
uri = maybeGetUriWithoutUserId(uri);
- return ContentProvider.this.getStreamTypes(uri, mimeTypeFilter);
+ Trace.traceBegin(TRACE_TAG_DATABASE, "getStreamTypes");
+ try {
+ return ContentProvider.this.getStreamTypes(uri, mimeTypeFilter);
+ } finally {
+ Trace.traceEnd(TRACE_TAG_DATABASE);
+ }
}
@Override
@@ -418,12 +448,14 @@
validateIncomingUri(uri);
uri = maybeGetUriWithoutUserId(uri);
enforceFilePermission(callingPkg, uri, "r", null);
+ Trace.traceBegin(TRACE_TAG_DATABASE, "openTypedAssetFile");
final String original = setCallingPackage(callingPkg);
try {
return ContentProvider.this.openTypedAssetFile(
uri, mimeType, opts, CancellationSignal.fromTransport(cancellationSignal));
} finally {
setCallingPackage(original);
+ Trace.traceEnd(TRACE_TAG_DATABASE);
}
}
@@ -440,11 +472,13 @@
if (enforceReadPermission(callingPkg, uri, null) != AppOpsManager.MODE_ALLOWED) {
return null;
}
+ Trace.traceBegin(TRACE_TAG_DATABASE, "canonicalize");
final String original = setCallingPackage(callingPkg);
try {
return maybeAddUserId(ContentProvider.this.canonicalize(uri), userId);
} finally {
setCallingPackage(original);
+ Trace.traceEnd(TRACE_TAG_DATABASE);
}
}
@@ -456,11 +490,13 @@
if (enforceReadPermission(callingPkg, uri, null) != AppOpsManager.MODE_ALLOWED) {
return null;
}
+ Trace.traceBegin(TRACE_TAG_DATABASE, "uncanonicalize");
final String original = setCallingPackage(callingPkg);
try {
return maybeAddUserId(ContentProvider.this.uncanonicalize(uri), userId);
} finally {
setCallingPackage(original);
+ Trace.traceEnd(TRACE_TAG_DATABASE);
}
}
@@ -472,12 +508,14 @@
if (enforceReadPermission(callingPkg, uri, null) != AppOpsManager.MODE_ALLOWED) {
return false;
}
+ Trace.traceBegin(TRACE_TAG_DATABASE, "refresh");
final String original = setCallingPackage(callingPkg);
try {
return ContentProvider.this.refresh(uri, args,
CancellationSignal.fromTransport(cancellationSignal));
} finally {
setCallingPackage(original);
+ Trace.traceEnd(TRACE_TAG_DATABASE);
}
}
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 54d383a..b4e9ad1 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -1982,7 +1982,7 @@
String str = sa.getNonConfigurationString(
com.android.internal.R.styleable.AndroidManifest_sharedUserId, 0);
if (str != null && str.length() > 0) {
- String nameError = validateName(str, true, false);
+ String nameError = validateName(str, true, true);
if (nameError != null && !"android".equals(pkg.packageName)) {
outError[0] = "<manifest> specifies bad sharedUserId name \""
+ str + "\": " + nameError;
diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java
index 60e4ce2..d027fd9 100644
--- a/core/java/android/hardware/camera2/CameraCharacteristics.java
+++ b/core/java/android/hardware/camera2/CameraCharacteristics.java
@@ -1249,7 +1249,9 @@
* <p>If this device is the largest or only camera device with a given facing, then this
* position will be <code>(0, 0, 0)</code>; a camera device with a lens optical center located 3 cm
* from the main sensor along the +X axis (to the right from the user's perspective) will
- * report <code>(0.03, 0, 0)</code>.</p>
+ * report <code>(0.03, 0, 0)</code>. Note that this means that, for many computer vision
+ * applications, the position needs to be negated to convert it to a translation from the
+ * camera to the origin.</p>
* <p>To transform a pixel coordinates between two cameras facing the same direction, first
* the source camera {@link CameraCharacteristics#LENS_DISTORTION android.lens.distortion} must be corrected for. Then the source
* camera {@link CameraCharacteristics#LENS_INTRINSIC_CALIBRATION android.lens.intrinsicCalibration} needs to be applied, followed by the
@@ -1261,7 +1263,8 @@
* <p>To compare this against a real image from the destination camera, the destination camera
* image then needs to be corrected for radial distortion before comparison or sampling.</p>
* <p>When {@link CameraCharacteristics#LENS_POSE_REFERENCE android.lens.poseReference} is GYROSCOPE, then this position is relative to
- * the center of the primary gyroscope on the device.</p>
+ * the center of the primary gyroscope on the device. The axis definitions are the same as
+ * with PRIMARY_CAMERA.</p>
* <p><b>Units</b>: Meters</p>
* <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
*
@@ -1293,13 +1296,15 @@
* </code></pre>
* <p>which can then be combined with the camera pose rotation
* <code>R</code> and translation <code>t</code> ({@link CameraCharacteristics#LENS_POSE_ROTATION android.lens.poseRotation} and
- * {@link CameraCharacteristics#LENS_POSE_TRANSLATION android.lens.poseTranslation}, respective) to calculate the
+ * {@link CameraCharacteristics#LENS_POSE_TRANSLATION android.lens.poseTranslation}, respectively) to calculate the
* complete transform from world coordinates to pixel
* coordinates:</p>
- * <pre><code>P = [ K 0 * [ R t
- * 0 1 ] 0 1 ]
+ * <pre><code>P = [ K 0 * [ R -Rt
+ * 0 1 ] 0 1 ]
* </code></pre>
- * <p>and with <code>p_w</code> being a point in the world coordinate system
+ * <p>(Note the negation of poseTranslation when mapping from camera
+ * to world coordinates, and multiplication by the rotation).</p>
+ * <p>With <code>p_w</code> being a point in the world coordinate system
* and <code>p_s</code> being a point in the camera active pixel array
* coordinate system, and with the mapping including the
* homogeneous division by z:</p>
@@ -1321,6 +1326,13 @@
* activeArraySize rectangle), to determine the final pixel
* coordinate of the world point for processed (non-RAW)
* output buffers.</p>
+ * <p>For camera devices, the center of pixel <code>(x,y)</code> is located at
+ * coordinate <code>(x + 0.5, y + 0.5)</code>. So on a device with a
+ * precorrection active array of size <code>(10,10)</code>, the valid pixel
+ * indices go from <code>(0,0)-(9,9)</code>, and an perfectly-built camera would
+ * have an optical center at the exact center of the pixel grid, at
+ * coordinates <code>(5.0, 5.0)</code>, which is the top-left corner of pixel
+ * <code>(5,5)</code>.</p>
* <p><b>Units</b>:
* Pixels in the
* {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}
diff --git a/core/java/android/hardware/camera2/CaptureRequest.java b/core/java/android/hardware/camera2/CaptureRequest.java
index aca77a5..0c3fe77 100644
--- a/core/java/android/hardware/camera2/CaptureRequest.java
+++ b/core/java/android/hardware/camera2/CaptureRequest.java
@@ -2522,7 +2522,7 @@
* outputs will crop horizontally (pillarbox), and 16:9
* streams will match exactly. These additional crops will
* be centered within the crop region.</p>
- * <p>If the coordinate system is android.sensor.info.activeArraysSize, the width and height
+ * <p>If the coordinate system is {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, the width and height
* of the crop region cannot be set to be smaller than
* <code>floor( activeArraySize.width / {@link CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM android.scaler.availableMaxDigitalZoom} )</code> and
* <code>floor( activeArraySize.height / {@link CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM android.scaler.availableMaxDigitalZoom} )</code>, respectively.</p>
@@ -2863,8 +2863,14 @@
new Key<Integer>("android.statistics.lensShadingMapMode", int.class);
/**
- * <p>A control for selecting whether OIS position information is included in output
- * result metadata.</p>
+ * <p>A control for selecting whether optical stabilization (OIS) position
+ * information is included in output result metadata.</p>
+ * <p>Since optical image stabilization generally involves motion much faster than the duration
+ * of individualq image exposure, multiple OIS samples can be included for a single capture
+ * result. For example, if the OIS reporting operates at 200 Hz, a typical camera operating
+ * at 30fps may have 6-7 OIS samples per capture result. This information can be combined
+ * with the rolling shutter skew to account for lens motion during image exposure in
+ * post-processing algorithms.</p>
* <p><b>Possible values:</b>
* <ul>
* <li>{@link #STATISTICS_OIS_DATA_MODE_OFF OFF}</li>
@@ -3264,14 +3270,28 @@
* any correction at all would slow down capture rate. Every output stream will have a
* similar amount of enhancement applied.</p>
* <p>The correction only applies to processed outputs such as YUV, JPEG, or DEPTH16; it is not
- * applied to any RAW output. Metadata coordinates such as face rectangles or metering
- * regions are also not affected by correction.</p>
+ * applied to any RAW output.</p>
* <p>This control will be on by default on devices that support this control. Applications
* disabling distortion correction need to pay extra attention with the coordinate system of
* metering regions, crop region, and face rectangles. When distortion correction is OFF,
* metadata coordinates follow the coordinate system of
* {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}. When distortion is not OFF, metadata
- * coordinates follow the coordinate system of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.</p>
+ * coordinates follow the coordinate system of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}. The
+ * camera device will map these metadata fields to match the corrected image produced by the
+ * camera device, for both capture requests and results. However, this mapping is not very
+ * precise, since rectangles do not generally map to rectangles when corrected. Only linear
+ * scaling between the active array and precorrection active array coordinates is
+ * performed. Applications that require precise correction of metadata need to undo that
+ * linear scaling, and apply a more complete correction that takes into the account the app's
+ * own requirements.</p>
+ * <p>The full list of metadata that is affected in this way by distortion correction is:</p>
+ * <ul>
+ * <li>{@link CaptureRequest#CONTROL_AF_REGIONS android.control.afRegions}</li>
+ * <li>{@link CaptureRequest#CONTROL_AE_REGIONS android.control.aeRegions}</li>
+ * <li>{@link CaptureRequest#CONTROL_AWB_REGIONS android.control.awbRegions}</li>
+ * <li>{@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion}</li>
+ * <li>{@link CaptureResult#STATISTICS_FACES android.statistics.faces}</li>
+ * </ul>
* <p><b>Possible values:</b>
* <ul>
* <li>{@link #DISTORTION_CORRECTION_MODE_OFF OFF}</li>
@@ -3282,10 +3302,15 @@
* {@link CameraCharacteristics#DISTORTION_CORRECTION_AVAILABLE_MODES android.distortionCorrection.availableModes}</p>
* <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
*
+ * @see CaptureRequest#CONTROL_AE_REGIONS
+ * @see CaptureRequest#CONTROL_AF_REGIONS
+ * @see CaptureRequest#CONTROL_AWB_REGIONS
* @see CameraCharacteristics#DISTORTION_CORRECTION_AVAILABLE_MODES
* @see CameraCharacteristics#LENS_DISTORTION
+ * @see CaptureRequest#SCALER_CROP_REGION
* @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE
* @see CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE
+ * @see CaptureResult#STATISTICS_FACES
* @see #DISTORTION_CORRECTION_MODE_OFF
* @see #DISTORTION_CORRECTION_MODE_FAST
* @see #DISTORTION_CORRECTION_MODE_HIGH_QUALITY
diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java
index d003f9a..5836288 100644
--- a/core/java/android/hardware/camera2/CaptureResult.java
+++ b/core/java/android/hardware/camera2/CaptureResult.java
@@ -2852,7 +2852,9 @@
* <p>If this device is the largest or only camera device with a given facing, then this
* position will be <code>(0, 0, 0)</code>; a camera device with a lens optical center located 3 cm
* from the main sensor along the +X axis (to the right from the user's perspective) will
- * report <code>(0.03, 0, 0)</code>.</p>
+ * report <code>(0.03, 0, 0)</code>. Note that this means that, for many computer vision
+ * applications, the position needs to be negated to convert it to a translation from the
+ * camera to the origin.</p>
* <p>To transform a pixel coordinates between two cameras facing the same direction, first
* the source camera {@link CameraCharacteristics#LENS_DISTORTION android.lens.distortion} must be corrected for. Then the source
* camera {@link CameraCharacteristics#LENS_INTRINSIC_CALIBRATION android.lens.intrinsicCalibration} needs to be applied, followed by the
@@ -2864,7 +2866,8 @@
* <p>To compare this against a real image from the destination camera, the destination camera
* image then needs to be corrected for radial distortion before comparison or sampling.</p>
* <p>When {@link CameraCharacteristics#LENS_POSE_REFERENCE android.lens.poseReference} is GYROSCOPE, then this position is relative to
- * the center of the primary gyroscope on the device.</p>
+ * the center of the primary gyroscope on the device. The axis definitions are the same as
+ * with PRIMARY_CAMERA.</p>
* <p><b>Units</b>: Meters</p>
* <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
*
@@ -2896,13 +2899,15 @@
* </code></pre>
* <p>which can then be combined with the camera pose rotation
* <code>R</code> and translation <code>t</code> ({@link CameraCharacteristics#LENS_POSE_ROTATION android.lens.poseRotation} and
- * {@link CameraCharacteristics#LENS_POSE_TRANSLATION android.lens.poseTranslation}, respective) to calculate the
+ * {@link CameraCharacteristics#LENS_POSE_TRANSLATION android.lens.poseTranslation}, respectively) to calculate the
* complete transform from world coordinates to pixel
* coordinates:</p>
- * <pre><code>P = [ K 0 * [ R t
- * 0 1 ] 0 1 ]
+ * <pre><code>P = [ K 0 * [ R -Rt
+ * 0 1 ] 0 1 ]
* </code></pre>
- * <p>and with <code>p_w</code> being a point in the world coordinate system
+ * <p>(Note the negation of poseTranslation when mapping from camera
+ * to world coordinates, and multiplication by the rotation).</p>
+ * <p>With <code>p_w</code> being a point in the world coordinate system
* and <code>p_s</code> being a point in the camera active pixel array
* coordinate system, and with the mapping including the
* homogeneous division by z:</p>
@@ -2924,6 +2929,13 @@
* activeArraySize rectangle), to determine the final pixel
* coordinate of the world point for processed (non-RAW)
* output buffers.</p>
+ * <p>For camera devices, the center of pixel <code>(x,y)</code> is located at
+ * coordinate <code>(x + 0.5, y + 0.5)</code>. So on a device with a
+ * precorrection active array of size <code>(10,10)</code>, the valid pixel
+ * indices go from <code>(0,0)-(9,9)</code>, and an perfectly-built camera would
+ * have an optical center at the exact center of the pixel grid, at
+ * coordinates <code>(5.0, 5.0)</code>, which is the top-left corner of pixel
+ * <code>(5,5)</code>.</p>
* <p><b>Units</b>:
* Pixels in the
* {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}
@@ -3188,7 +3200,7 @@
* outputs will crop horizontally (pillarbox), and 16:9
* streams will match exactly. These additional crops will
* be centered within the crop region.</p>
- * <p>If the coordinate system is android.sensor.info.activeArraysSize, the width and height
+ * <p>If the coordinate system is {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, the width and height
* of the crop region cannot be set to be smaller than
* <code>floor( activeArraySize.width / {@link CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM android.scaler.availableMaxDigitalZoom} )</code> and
* <code>floor( activeArraySize.height / {@link CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM android.scaler.availableMaxDigitalZoom} )</code>, respectively.</p>
@@ -4077,8 +4089,14 @@
new Key<Integer>("android.statistics.lensShadingMapMode", int.class);
/**
- * <p>A control for selecting whether OIS position information is included in output
- * result metadata.</p>
+ * <p>A control for selecting whether optical stabilization (OIS) position
+ * information is included in output result metadata.</p>
+ * <p>Since optical image stabilization generally involves motion much faster than the duration
+ * of individualq image exposure, multiple OIS samples can be included for a single capture
+ * result. For example, if the OIS reporting operates at 200 Hz, a typical camera operating
+ * at 30fps may have 6-7 OIS samples per capture result. This information can be combined
+ * with the rolling shutter skew to account for lens motion during image exposure in
+ * post-processing algorithms.</p>
* <p><b>Possible values:</b>
* <ul>
* <li>{@link #STATISTICS_OIS_DATA_MODE_OFF OFF}</li>
@@ -4112,11 +4130,15 @@
/**
* <p>An array of shifts of OIS samples, in x direction.</p>
* <p>The array contains the amount of shifts in x direction, in pixels, based on OIS samples.
- * A positive value is a shift from left to right in active array coordinate system. For
- * example, if the optical center is (1000, 500) in active array coordinates, a shift of
- * (3, 0) puts the new optical center at (1003, 500).</p>
+ * A positive value is a shift from left to right in the pre-correction active array
+ * coordinate system. For example, if the optical center is (1000, 500) in pre-correction
+ * active array coordinates, a shift of (3, 0) puts the new optical center at (1003, 500).</p>
* <p>The number of shifts must match the number of timestamps in
* android.statistics.oisTimestamps.</p>
+ * <p>The OIS samples are not affected by whether lens distortion correction is enabled (on
+ * supporting devices). They are always reported in pre-correction active array coordinates,
+ * since the scaling of OIS shifts would depend on the specific spot on the sensor the shift
+ * is needed.</p>
* <p><b>Units</b>: Pixels in active array.</p>
* <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
* @hide
@@ -4127,11 +4149,15 @@
/**
* <p>An array of shifts of OIS samples, in y direction.</p>
* <p>The array contains the amount of shifts in y direction, in pixels, based on OIS samples.
- * A positive value is a shift from top to bottom in active array coordinate system. For
- * example, if the optical center is (1000, 500) in active array coordinates, a shift of
- * (0, 5) puts the new optical center at (1000, 505).</p>
+ * A positive value is a shift from top to bottom in pre-correction active array coordinate
+ * system. For example, if the optical center is (1000, 500) in active array coordinates, a
+ * shift of (0, 5) puts the new optical center at (1000, 505).</p>
* <p>The number of shifts must match the number of timestamps in
* android.statistics.oisTimestamps.</p>
+ * <p>The OIS samples are not affected by whether lens distortion correction is enabled (on
+ * supporting devices). They are always reported in pre-correction active array coordinates,
+ * since the scaling of OIS shifts would depend on the specific spot on the sensor the shift
+ * is needed.</p>
* <p><b>Units</b>: Pixels in active array.</p>
* <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
* @hide
@@ -4140,15 +4166,21 @@
new Key<float[]>("android.statistics.oisYShifts", float[].class);
/**
- * <p>An array of OIS samples.</p>
+ * <p>An array of optical stabilization (OIS) position samples.</p>
* <p>Each OIS sample contains the timestamp and the amount of shifts in x and y direction,
* in pixels, of the OIS sample.</p>
- * <p>A positive value for a shift in x direction is a shift from left to right in active array
- * coordinate system. For example, if the optical center is (1000, 500) in active array
- * coordinates, a shift of (3, 0) puts the new optical center at (1003, 500).</p>
- * <p>A positive value for a shift in y direction is a shift from top to bottom in active array
- * coordinate system. For example, if the optical center is (1000, 500) in active array
- * coordinates, a shift of (0, 5) puts the new optical center at (1000, 505).</p>
+ * <p>A positive value for a shift in x direction is a shift from left to right in the
+ * pre-correction active array coordinate system. For example, if the optical center is
+ * (1000, 500) in pre-correction active array coordinates, a shift of (3, 0) puts the new
+ * optical center at (1003, 500).</p>
+ * <p>A positive value for a shift in y direction is a shift from top to bottom in
+ * pre-correction active array coordinate system. For example, if the optical center is
+ * (1000, 500) in active array coordinates, a shift of (0, 5) puts the new optical center at
+ * (1000, 505).</p>
+ * <p>The OIS samples are not affected by whether lens distortion correction is enabled (on
+ * supporting devices). They are always reported in pre-correction active array coordinates,
+ * since the scaling of OIS shifts would depend on the specific spot on the sensor the shift
+ * is needed.</p>
* <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
*/
@PublicKey
@@ -4578,14 +4610,28 @@
* any correction at all would slow down capture rate. Every output stream will have a
* similar amount of enhancement applied.</p>
* <p>The correction only applies to processed outputs such as YUV, JPEG, or DEPTH16; it is not
- * applied to any RAW output. Metadata coordinates such as face rectangles or metering
- * regions are also not affected by correction.</p>
+ * applied to any RAW output.</p>
* <p>This control will be on by default on devices that support this control. Applications
* disabling distortion correction need to pay extra attention with the coordinate system of
* metering regions, crop region, and face rectangles. When distortion correction is OFF,
* metadata coordinates follow the coordinate system of
* {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}. When distortion is not OFF, metadata
- * coordinates follow the coordinate system of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.</p>
+ * coordinates follow the coordinate system of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}. The
+ * camera device will map these metadata fields to match the corrected image produced by the
+ * camera device, for both capture requests and results. However, this mapping is not very
+ * precise, since rectangles do not generally map to rectangles when corrected. Only linear
+ * scaling between the active array and precorrection active array coordinates is
+ * performed. Applications that require precise correction of metadata need to undo that
+ * linear scaling, and apply a more complete correction that takes into the account the app's
+ * own requirements.</p>
+ * <p>The full list of metadata that is affected in this way by distortion correction is:</p>
+ * <ul>
+ * <li>{@link CaptureRequest#CONTROL_AF_REGIONS android.control.afRegions}</li>
+ * <li>{@link CaptureRequest#CONTROL_AE_REGIONS android.control.aeRegions}</li>
+ * <li>{@link CaptureRequest#CONTROL_AWB_REGIONS android.control.awbRegions}</li>
+ * <li>{@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion}</li>
+ * <li>{@link CaptureResult#STATISTICS_FACES android.statistics.faces}</li>
+ * </ul>
* <p><b>Possible values:</b>
* <ul>
* <li>{@link #DISTORTION_CORRECTION_MODE_OFF OFF}</li>
@@ -4596,10 +4642,15 @@
* {@link CameraCharacteristics#DISTORTION_CORRECTION_AVAILABLE_MODES android.distortionCorrection.availableModes}</p>
* <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
*
+ * @see CaptureRequest#CONTROL_AE_REGIONS
+ * @see CaptureRequest#CONTROL_AF_REGIONS
+ * @see CaptureRequest#CONTROL_AWB_REGIONS
* @see CameraCharacteristics#DISTORTION_CORRECTION_AVAILABLE_MODES
* @see CameraCharacteristics#LENS_DISTORTION
+ * @see CaptureRequest#SCALER_CROP_REGION
* @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE
* @see CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE
+ * @see CaptureResult#STATISTICS_FACES
* @see #DISTORTION_CORRECTION_MODE_OFF
* @see #DISTORTION_CORRECTION_MODE_FAST
* @see #DISTORTION_CORRECTION_MODE_HIGH_QUALITY
diff --git a/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java b/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java
index 5423ca9..8822f71 100644
--- a/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java
+++ b/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java
@@ -781,6 +781,7 @@
CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE ,
CameraCharacteristics.SENSOR_INFO_PHYSICAL_SIZE ,
CameraCharacteristics.SENSOR_INFO_PIXEL_ARRAY_SIZE ,
+ CameraCharacteristics.SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE ,
CameraCharacteristics.SENSOR_INFO_TIMESTAMP_SOURCE ,
CameraCharacteristics.SENSOR_ORIENTATION ,
CameraCharacteristics.STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES ,
@@ -941,11 +942,12 @@
// Use the largest jpeg size (by area) for both active array and pixel array
Size largestJpegSize = getLargestSupportedJpegSizeByArea(p);
/*
- * sensor.info.activeArraySize
+ * sensor.info.activeArraySize, and preCorrectionActiveArraySize
*/
{
Rect activeArrayRect = ParamsUtils.createRect(largestJpegSize);
m.set(SENSOR_INFO_ACTIVE_ARRAY_SIZE, activeArrayRect);
+ m.set(SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE, activeArrayRect);
}
/*
diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java
index 6ae7a14..4d2841d 100644
--- a/core/java/android/hardware/input/InputManager.java
+++ b/core/java/android/hardware/input/InputManager.java
@@ -1191,8 +1191,8 @@
* @hide
*/
@Override
- public void vibrate(int uid, String opPkg,
- VibrationEffect effect, AudioAttributes attributes) {
+ public void vibrate(int uid, String opPkg, VibrationEffect effect,
+ String reason, AudioAttributes attributes) {
long[] pattern;
int repeat;
if (effect instanceof VibrationEffect.OneShot) {
diff --git a/core/java/android/net/NetworkUtils.java b/core/java/android/net/NetworkUtils.java
index 9a5d502..dc1f805 100644
--- a/core/java/android/net/NetworkUtils.java
+++ b/core/java/android/net/NetworkUtils.java
@@ -126,51 +126,122 @@
public native static boolean queryUserAccess(int uid, int netId);
/**
- * Convert a IPv4 address from an integer to an InetAddress.
- * @param hostAddress an int corresponding to the IPv4 address in network byte order
+ * @see #intToInet4AddressHTL(int)
+ * @deprecated Use either {@link #intToInet4AddressHTH(int)}
+ * or {@link #intToInet4AddressHTL(int)}
*/
+ @Deprecated
public static InetAddress intToInetAddress(int hostAddress) {
- byte[] addressBytes = { (byte)(0xff & hostAddress),
- (byte)(0xff & (hostAddress >> 8)),
- (byte)(0xff & (hostAddress >> 16)),
- (byte)(0xff & (hostAddress >> 24)) };
+ return intToInet4AddressHTL(hostAddress);
+ }
+
+ /**
+ * Convert a IPv4 address from an integer to an InetAddress (0x04030201 -> 1.2.3.4)
+ *
+ * <p>This method uses the higher-order int bytes as the lower-order IPv4 address bytes,
+ * which is an unusual convention. Consider {@link #intToInet4AddressHTH(int)} instead.
+ * @param hostAddress an int coding for an IPv4 address, where higher-order int byte is
+ * lower-order IPv4 address byte
+ */
+ public static InetAddress intToInet4AddressHTL(int hostAddress) {
+ return intToInet4AddressHTH(Integer.reverseBytes(hostAddress));
+ }
+
+ /**
+ * Convert a IPv4 address from an integer to an InetAddress (0x01020304 -> 1.2.3.4)
+ * @param hostAddress an int coding for an IPv4 address
+ */
+ public static InetAddress intToInet4AddressHTH(int hostAddress) {
+ byte[] addressBytes = { (byte) (0xff & (hostAddress >> 24)),
+ (byte) (0xff & (hostAddress >> 16)),
+ (byte) (0xff & (hostAddress >> 8)),
+ (byte) (0xff & hostAddress) };
try {
- return InetAddress.getByAddress(addressBytes);
+ return InetAddress.getByAddress(addressBytes);
} catch (UnknownHostException e) {
- throw new AssertionError();
+ throw new AssertionError();
}
}
/**
- * Convert a IPv4 address from an InetAddress to an integer
- * @param inetAddr is an InetAddress corresponding to the IPv4 address
- * @return the IP address as an integer in network byte order
+ * @see #inet4AddressToIntHTL(Inet4Address)
+ * @deprecated Use either {@link #inet4AddressToIntHTH(Inet4Address)}
+ * or {@link #inet4AddressToIntHTL(Inet4Address)}
*/
+ @Deprecated
public static int inetAddressToInt(Inet4Address inetAddr)
throws IllegalArgumentException {
- byte [] addr = inetAddr.getAddress();
- return ((addr[3] & 0xff) << 24) | ((addr[2] & 0xff) << 16) |
- ((addr[1] & 0xff) << 8) | (addr[0] & 0xff);
+ return inet4AddressToIntHTL(inetAddr);
}
/**
- * Convert a network prefix length to an IPv4 netmask integer
- * @param prefixLength
- * @return the IPv4 netmask as an integer in network byte order
+ * Convert an IPv4 address from an InetAddress to an integer (1.2.3.4 -> 0x01020304)
+ *
+ * <p>This conversion can help order IP addresses: considering the ordering
+ * 192.0.2.1 < 192.0.2.2 < ..., resulting ints will follow that ordering if read as unsigned
+ * integers with {@link Integer#toUnsignedLong}.
+ * @param inetAddr is an InetAddress corresponding to the IPv4 address
+ * @return the IP address as integer
*/
+ public static int inet4AddressToIntHTH(Inet4Address inetAddr)
+ throws IllegalArgumentException {
+ byte [] addr = inetAddr.getAddress();
+ return ((addr[0] & 0xff) << 24) | ((addr[1] & 0xff) << 16)
+ | ((addr[2] & 0xff) << 8) | (addr[3] & 0xff);
+ }
+
+ /**
+ * Convert a IPv4 address from an InetAddress to an integer (1.2.3.4 -> 0x04030201)
+ *
+ * <p>This method stores the higher-order IPv4 address bytes in the lower-order int bytes,
+ * which is an unusual convention. Consider {@link #inet4AddressToIntHTH(Inet4Address)} instead.
+ * @param inetAddr is an InetAddress corresponding to the IPv4 address
+ * @return the IP address as integer
+ */
+ public static int inet4AddressToIntHTL(Inet4Address inetAddr) {
+ return Integer.reverseBytes(inet4AddressToIntHTH(inetAddr));
+ }
+
+ /**
+ * @see #prefixLengthToV4NetmaskIntHTL(int)
+ * @deprecated Use either {@link #prefixLengthToV4NetmaskIntHTH(int)}
+ * or {@link #prefixLengthToV4NetmaskIntHTL(int)}
+ */
+ @Deprecated
public static int prefixLengthToNetmaskInt(int prefixLength)
throws IllegalArgumentException {
+ return prefixLengthToV4NetmaskIntHTL(prefixLength);
+ }
+
+ /**
+ * Convert a network prefix length to an IPv4 netmask integer (prefixLength 17 -> 0xffff8000)
+ * @return the IPv4 netmask as an integer
+ */
+ public static int prefixLengthToV4NetmaskIntHTH(int prefixLength)
+ throws IllegalArgumentException {
if (prefixLength < 0 || prefixLength > 32) {
throw new IllegalArgumentException("Invalid prefix length (0 <= prefix <= 32)");
}
- int value = 0xffffffff << (32 - prefixLength);
- return Integer.reverseBytes(value);
+ // (int)a << b is equivalent to a << (b & 0x1f): can't shift by 32 (-1 << 32 == -1)
+ return prefixLength == 0 ? 0 : 0xffffffff << (32 - prefixLength);
+ }
+
+ /**
+ * Convert a network prefix length to an IPv4 netmask integer (prefixLength 17 -> 0x0080ffff).
+ *
+ * <p>This method stores the higher-order IPv4 address bytes in the lower-order int bytes,
+ * which is an unusual convention. Consider {@link #prefixLengthToV4NetmaskIntHTH(int)} instead.
+ * @return the IPv4 netmask as an integer
+ */
+ public static int prefixLengthToV4NetmaskIntHTL(int prefixLength)
+ throws IllegalArgumentException {
+ return Integer.reverseBytes(prefixLengthToV4NetmaskIntHTH(prefixLength));
}
/**
* Convert a IPv4 netmask integer to a prefix length
- * @param netmask as an integer in network byte order
+ * @param netmask as an integer (0xff000000 for a /8 subnet)
* @return the network prefix length
*/
public static int netmaskIntToPrefixLength(int netmask) {
diff --git a/core/java/android/net/OWNERS b/core/java/android/net/OWNERS
index 3cd37bf..cea480f 100644
--- a/core/java/android/net/OWNERS
+++ b/core/java/android/net/OWNERS
@@ -6,3 +6,13 @@
lorenzo@google.com
satk@google.com
silberst@google.com
+
+per-file SSL*=flooey@google.com
+per-file SSL*=narayan@google.com
+per-file SSL*=tobiast@google.com
+per-file Uri*=flooey@google.com
+per-file Uri*=narayan@google.com
+per-file Uri*=tobiast@google.com
+per-file Url*=flooey@google.com
+per-file Url*=narayan@google.com
+per-file Url*=tobiast@google.com
diff --git a/core/java/android/net/SSLCertificateSocketFactory.java b/core/java/android/net/SSLCertificateSocketFactory.java
index 1f53587..d7eb477 100644
--- a/core/java/android/net/SSLCertificateSocketFactory.java
+++ b/core/java/android/net/SSLCertificateSocketFactory.java
@@ -73,10 +73,14 @@
* Updating Your Security Provider to Protect Against SSL Exploits</a>
* for further information.</p>
*
- * <p>One way to verify the server's identity is to use
+ * <p>The recommended way to verify the server's identity is to use
* {@link HttpsURLConnection#getDefaultHostnameVerifier()} to get a
* {@link HostnameVerifier} to verify the certificate hostname.
*
+ * <p><b>Warning</b>: Some methods on this class return connected sockets and some return
+ * unconnected sockets. For the methods that return connected sockets, setting
+ * connection- or handshake-related properties on those sockets will have no effect.
+ *
* <p>On development devices, "setprop socket.relaxsslcheck yes" bypasses all
* SSL certificate and hostname checks for testing purposes. This setting
* requires root access.
@@ -442,8 +446,10 @@
/**
* {@inheritDoc}
*
- * <p>This method verifies the peer's certificate hostname after connecting
- * (unless created with {@link #getInsecure(int, SSLSessionCache)}).
+ * <p>By default, this method returns a <i>connected</i> socket and verifies the peer's
+ * certificate hostname after connecting; if this instance was created with
+ * {@link #getInsecure(int, SSLSessionCache)}, it returns a socket that is <i>not connected</i>
+ * instead.
*/
@Override
public Socket createSocket(Socket k, String host, int port, boolean close) throws IOException {
@@ -459,7 +465,7 @@
}
/**
- * Creates a new socket which is not connected to any remote host.
+ * Creates a new socket which is <i>not connected</i> to any remote host.
* You must use {@link Socket#connect} to connect the socket.
*
* <p class="caution"><b>Warning:</b> Hostname verification is not performed
@@ -479,6 +485,8 @@
/**
* {@inheritDoc}
*
+ * <p>This method returns a socket that is <i>not connected</i>.
+ *
* <p class="caution"><b>Warning:</b> Hostname verification is not performed
* with this method. You MUST verify the server's identity after connecting
* the socket to avoid man-in-the-middle attacks.</p>
@@ -498,6 +506,8 @@
/**
* {@inheritDoc}
*
+ * <p>This method returns a socket that is <i>not connected</i>.
+ *
* <p class="caution"><b>Warning:</b> Hostname verification is not performed
* with this method. You MUST verify the server's identity after connecting
* the socket to avoid man-in-the-middle attacks.</p>
@@ -515,8 +525,10 @@
/**
* {@inheritDoc}
*
- * <p>This method verifies the peer's certificate hostname after connecting
- * (unless created with {@link #getInsecure(int, SSLSessionCache)}).
+ * <p>By default, this method returns a <i>connected</i> socket and verifies the peer's
+ * certificate hostname after connecting; if this instance was created with
+ * {@link #getInsecure(int, SSLSessionCache)}, it returns a socket that is <i>not connected</i>
+ * instead.
*/
@Override
public Socket createSocket(String host, int port, InetAddress localAddr, int localPort)
@@ -536,8 +548,10 @@
/**
* {@inheritDoc}
*
- * <p>This method verifies the peer's certificate hostname after connecting
- * (unless created with {@link #getInsecure(int, SSLSessionCache)}).
+ * <p>By default, this method returns a <i>connected</i> socket and verifies the peer's
+ * certificate hostname after connecting; if this instance was created with
+ * {@link #getInsecure(int, SSLSessionCache)}, it returns a socket that is <i>not connected</i>
+ * instead.
*/
@Override
public Socket createSocket(String host, int port) throws IOException {
diff --git a/core/java/android/net/http/OWNERS b/core/java/android/net/http/OWNERS
new file mode 100644
index 0000000..6b8c9ed
--- /dev/null
+++ b/core/java/android/net/http/OWNERS
@@ -0,0 +1,3 @@
+flooey@google.com
+narayan@google.com
+tobiast@google.com
diff --git a/core/java/android/net/http/SslCertificate.java b/core/java/android/net/http/SslCertificate.java
index 4c0f418..21ada36 100644
--- a/core/java/android/net/http/SslCertificate.java
+++ b/core/java/android/net/http/SslCertificate.java
@@ -16,8 +16,6 @@
package android.net.http;
-import com.android.internal.util.HexDump;
-
import android.content.Context;
import android.os.Bundle;
import android.text.format.DateFormat;
@@ -25,6 +23,9 @@
import android.view.View;
import android.widget.TextView;
+import com.android.internal.util.HexDump;
+import com.android.org.bouncycastle.asn1.x509.X509Name;
+
import java.io.ByteArrayInputStream;
import java.math.BigInteger;
import java.security.MessageDigest;
@@ -39,8 +40,6 @@
import java.util.Date;
import java.util.Vector;
-import com.android.org.bouncycastle.asn1.x509.X509Name;
-
/**
* SSL certificate info (certificate details) class
*/
@@ -248,6 +247,14 @@
}
/**
+ * @return The {@code X509Certificate} used to create this {@code SslCertificate} or
+ * {@code null} if no certificate was provided.
+ */
+ public X509Certificate getX509Certificate() {
+ return mX509Certificate;
+ }
+
+ /**
* Convenience for UI presentation, not intended as public API.
*/
private static String getSerialNumber(X509Certificate x509Certificate) {
diff --git a/core/java/android/net/metrics/ValidationProbeEvent.java b/core/java/android/net/metrics/ValidationProbeEvent.java
index 1ad0929..12c2305 100644
--- a/core/java/android/net/metrics/ValidationProbeEvent.java
+++ b/core/java/android/net/metrics/ValidationProbeEvent.java
@@ -37,6 +37,7 @@
public static final int PROBE_HTTPS = 2;
public static final int PROBE_PAC = 3;
public static final int PROBE_FALLBACK = 4;
+ public static final int PROBE_PRIVDNS = 5;
public static final int DNS_FAILURE = 0;
public static final int DNS_SUCCESS = 1;
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index 25a5e91..6bd2e76 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -631,7 +631,8 @@
* October 2013: Android 4.4, KitKat, another tasty treat.
*
* <p>Applications targeting this or a later release will get these
- * new changes in behavior:</p>
+ * new changes in behavior. For more information about this release, see the
+ * <a href="/about/versions/kitkat/">Android KitKat overview</a>.</p>
* <ul>
* <li> The default result of
* {@link android.preference.PreferenceActivity#isValidFragment(String)
@@ -681,7 +682,8 @@
* November 2014: Lollipop. A flat one with beautiful shadows. But still tasty.
*
* <p>Applications targeting this or a later release will get these
- * new changes in behavior:</p>
+ * new changes in behavior. For more information about this release, see the
+ * <a href="/about/versions/lollipop/">Android Lollipop overview</a>.</p>
* <ul>
* <li> {@link android.content.Context#bindService Context.bindService} now
* requires an explicit Intent, and will throw an exception if given an implicit
@@ -710,6 +712,8 @@
/**
* March 2015: Lollipop with an extra sugar coating on the outside!
+ * For more information about this release, see the
+ * <a href="/about/versions/android-5.1">Android 5.1 APIs</a>.
*/
public static final int LOLLIPOP_MR1 = 22;
@@ -717,7 +721,8 @@
* M is for Marshmallow!
*
* <p>Applications targeting this or a later release will get these
- * new changes in behavior:</p>
+ * new changes in behavior. For more information about this release, see the
+ * <a href="/about/versions/marshmallow/">Android 6.0 Marshmallow overview</a>.</p>
* <ul>
* <li> Runtime permissions. Dangerous permissions are no longer granted at
* install time, but must be requested by the application at runtime through
@@ -748,7 +753,8 @@
* N is for Nougat.
*
* <p>Applications targeting this or a later release will get these
- * new changes in behavior:</p>
+ * new changes in behavior. For more information about this release, see
+ * the <a href="/about/versions/nougat/">Android Nougat overview</a>.</p>
* <ul>
* <li> {@link android.app.DownloadManager.Request#setAllowedNetworkTypes
* DownloadManager.Request.setAllowedNetworkTypes}
@@ -798,7 +804,9 @@
public static final int N = 24;
/**
- * N MR1: Nougat++.
+ * N MR1: Nougat++. For more information about this release, see
+ * <a href="/about/versions/nougat/android-7.1">Android 7.1 for
+ * Developers</a>.
*/
public static final int N_MR1 = 25;
@@ -806,7 +814,8 @@
* O.
*
* <p>Applications targeting this or a later release will get these
- * new changes in behavior:</p>
+ * new changes in behavior. For more information about this release, see
+ * the <a href="/about/versions/oreo/">Android Oreo overview</a>.</p>
* <ul>
* <li><a href="{@docRoot}about/versions/oreo/background.html">Background execution limits</a>
* are applied to the application.</li>
@@ -895,13 +904,16 @@
* O MR1.
*
* <p>Applications targeting this or a later release will get these
- * new changes in behavior:</p>
+ * new changes in behavior. For more information about this release, see
+ * <a href="/about/versions/oreo/android-8.1">Android 8.1 features and
+ * APIs</a>.</p>
* <ul>
* <li>Apps exporting and linking to apk shared libraries must explicitly
* enumerate all signing certificates in a consistent order.</li>
* <li>{@link android.R.attr#screenOrientation} can not be used to request a fixed
* orientation if the associated activity is not fullscreen and opaque.</li>
* </ul>
+ *
*/
public static final int O_MR1 = 27;
@@ -909,7 +921,8 @@
* P.
*
* <p>Applications targeting this or a later release will get these
- * new changes in behavior:</p>
+ * new changes in behavior. For more information about this release, see the
+ * <a href="/about/versions/pie/">Android 9 Pie overview</a>.</p>
* <ul>
* <li>{@link android.app.Service#startForeground Service.startForeground} requires
* that apps hold the permission
@@ -917,6 +930,7 @@
* <li>{@link android.widget.LinearLayout} will always remeasure weighted children,
* even if there is no excess space.</li>
* </ul>
+ *
*/
public static final int P = 28;
diff --git a/core/java/android/os/IVibratorService.aidl b/core/java/android/os/IVibratorService.aidl
index e59c3ae..e8b3ca6 100644
--- a/core/java/android/os/IVibratorService.aidl
+++ b/core/java/android/os/IVibratorService.aidl
@@ -23,7 +23,8 @@
{
boolean hasVibrator();
boolean hasAmplitudeControl();
- void vibrate(int uid, String opPkg, in VibrationEffect effect, int usageHint, IBinder token);
+ void vibrate(int uid, String opPkg, in VibrationEffect effect, int usageHint, String reason,
+ IBinder token);
void cancelVibrate(IBinder token);
}
diff --git a/core/java/android/os/NullVibrator.java b/core/java/android/os/NullVibrator.java
index b8bdc89..1d0f9d3 100644
--- a/core/java/android/os/NullVibrator.java
+++ b/core/java/android/os/NullVibrator.java
@@ -44,8 +44,8 @@
}
@Override
- public void vibrate(int uid, String opPkg,
- VibrationEffect effect, AudioAttributes attributes) {
+ public void vibrate(int uid, String opPkg, VibrationEffect effect,
+ String reason, AudioAttributes attributes) {
}
@Override
diff --git a/core/java/android/os/SystemVibrator.java b/core/java/android/os/SystemVibrator.java
index f776c17..c989197 100644
--- a/core/java/android/os/SystemVibrator.java
+++ b/core/java/android/os/SystemVibrator.java
@@ -67,14 +67,14 @@
}
@Override
- public void vibrate(int uid, String opPkg,
- VibrationEffect effect, AudioAttributes attributes) {
+ public void vibrate(int uid, String opPkg, VibrationEffect effect,
+ String reason, AudioAttributes attributes) {
if (mService == null) {
Log.w(TAG, "Failed to vibrate; no vibrator service.");
return;
}
try {
- mService.vibrate(uid, opPkg, effect, usageForAttributes(attributes), mToken);
+ mService.vibrate(uid, opPkg, effect, usageForAttributes(attributes), reason, mToken);
} catch (RemoteException e) {
Log.w(TAG, "Failed to vibrate.", e);
}
diff --git a/core/java/android/os/Vibrator.java b/core/java/android/os/Vibrator.java
index d2d8f1e..b5aeba0 100644
--- a/core/java/android/os/Vibrator.java
+++ b/core/java/android/os/Vibrator.java
@@ -248,17 +248,17 @@
@RequiresPermission(android.Manifest.permission.VIBRATE)
public void vibrate(VibrationEffect vibe, AudioAttributes attributes) {
- vibrate(Process.myUid(), mPackageName, vibe, attributes);
+ vibrate(Process.myUid(), mPackageName, vibe, null, attributes);
}
/**
- * Like {@link #vibrate(VibrationEffect, AudioAttributes)}, but allowing the caller to specify
- * that the vibration is owned by someone else.
+ * Like {@link #vibrate(int, String, VibrationEffect, AudioAttributes)}, but allows the
+ * caller to specify the vibration is owned by someone else and set reason for vibration.
* @hide
*/
@RequiresPermission(android.Manifest.permission.VIBRATE)
- public abstract void vibrate(int uid, String opPkg,
- VibrationEffect vibe, AudioAttributes attributes);
+ public abstract void vibrate(int uid, String opPkg, VibrationEffect vibe,
+ String reason, AudioAttributes attributes);
/**
* Turn the vibrator off.
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index f7409d0..14a4509 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -187,8 +187,7 @@
/**
* A boolean parameter for {@link Contacts#CONTENT_STREQUENT_URI} and
* {@link Contacts#CONTENT_STREQUENT_FILTER_URI}, which requires the ContactsProvider to
- * return only phone-related results. For example, frequently contacted person list should
- * include persons contacted via phone (not email, sms, etc.)
+ * return only phone-related results.
*/
public static final String STREQUENT_PHONE_ONLY = "strequent_phone_only";
@@ -870,13 +869,23 @@
/**
* The number of times a contact has been contacted
* <P>Type: INTEGER</P>
+ *
+ * @deprecated Contacts affinity information is no longer supported as of
+ * Android version {@link android.os.Build.VERSION_CODES#Q}. This column
+ * always contains 0.
*/
+ @Deprecated
public static final String TIMES_CONTACTED = "times_contacted";
/**
* The last time a contact was contacted.
* <P>Type: INTEGER</P>
+ *
+ * @deprecated Contacts affinity information is no longer supported as of
+ * Android version {@link android.os.Build.VERSION_CODES#Q}. This column
+ * always contains 0.
*/
+ @Deprecated
public static final String LAST_TIME_CONTACTED = "last_time_contacted";
/** @hide Raw value. */
@@ -1313,8 +1322,7 @@
* of the newly inserted raw contact.</dd>
* <dt><b>Update</b></dt>
* <dd>Only certain columns of Contact are modifiable:
- * {@link #TIMES_CONTACTED}, {@link #LAST_TIME_CONTACTED}, {@link #STARRED},
- * {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of
+ * {@link #STARRED}, {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of
* these columns on the Contact also changes them on all constituent raw
* contacts.</dd>
* <dt><b>Delete</b></dt>
@@ -1415,27 +1423,6 @@
* </tr>
* <tr>
* <td>int</td>
- * <td>{@link #TIMES_CONTACTED}</td>
- * <td>read/write</td>
- * <td>The number of times the contact has been contacted. See
- * {@link #markAsContacted}. When raw contacts are aggregated, this field is
- * computed automatically as the maximum number of times contacted among all
- * constituent raw contacts. Setting this field automatically changes the
- * corresponding field on all constituent raw contacts.</td>
- * </tr>
- * <tr>
- * <td>long</td>
- * <td>{@link #LAST_TIME_CONTACTED}</td>
- * <td>read/write</td>
- * <td>The timestamp of the last time the contact was contacted. See
- * {@link #markAsContacted}. Setting this field also automatically
- * increments {@link #TIMES_CONTACTED}. When raw contacts are aggregated,
- * this field is computed automatically as the latest time contacted of all
- * constituent raw contacts. Setting this field automatically changes the
- * corresponding field on all constituent raw contacts.</td>
- * </tr>
- * <tr>
- * <td>int</td>
* <td>{@link #STARRED}</td>
* <td>read/write</td>
* <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
@@ -1696,16 +1683,12 @@
* @param resolver the ContentResolver to use
* @param contactId the person who was contacted
*
- * @deprecated The class DataUsageStatUpdater of the Android support library should
- * be used instead.
+ * @deprecated Contacts affinity information is no longer supported as of
+ * Android version {@link android.os.Build.VERSION_CODES#Q}. This method
+ * is no-op.
*/
@Deprecated
public static void markAsContacted(ContentResolver resolver, long contactId) {
- Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId);
- ContentValues values = new ContentValues();
- // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified.
- values.put(LR_LAST_TIME_CONTACTED, System.currentTimeMillis());
- resolver.update(uri, values, null, null);
}
/**
@@ -1727,15 +1710,21 @@
/**
* The content:// style URI for this table joined with useful data from
- * {@link ContactsContract.Data}, filtered to include only starred contacts
- * and the most frequently contacted contacts.
+ * {@link ContactsContract.Data}, filtered to include only starred contacts.
+ * Frequent contacts are no longer included in the result as of
+ * Android version {@link android.os.Build.VERSION_CODES#Q}.
*/
public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath(
CONTENT_URI, "strequent");
/**
* The content:// style URI for showing a list of frequently contacted people.
+ *
+ * @deprecated Frequent contacts are no longer supported as of
+ * Android version {@link android.os.Build.VERSION_CODES#Q}.
+ * This URI always returns an empty cursor.
*/
+ @Deprecated
public static final Uri CONTENT_FREQUENT_URI = Uri.withAppendedPath(
CONTENT_URI, "frequent");
@@ -2631,27 +2620,6 @@
* </tr>
* <tr>
* <td>int</td>
- * <td>{@link #TIMES_CONTACTED}</td>
- * <td>read/write</td>
- * <td>The number of times the contact has been contacted. To have an effect
- * on the corresponding value of the aggregate contact, this field
- * should be set at the time the raw contact is inserted.
- * After that, this value is typically updated via
- * {@link ContactsContract.Contacts#markAsContacted}.</td>
- * </tr>
- * <tr>
- * <td>long</td>
- * <td>{@link #LAST_TIME_CONTACTED}</td>
- * <td>read/write</td>
- * <td>The timestamp of the last time the contact was contacted. To have an effect
- * on the corresponding value of the aggregate contact, this field
- * should be set at the time the raw contact is inserted.
- * After that, this value is typically updated via
- * {@link ContactsContract.Contacts#markAsContacted}.
- * </td>
- * </tr>
- * <tr>
- * <td>int</td>
* <td>{@link #STARRED}</td>
* <td>read/write</td>
* <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
@@ -4286,10 +4254,22 @@
* Columns in the Data_Usage_Stat table
*/
protected interface DataUsageStatColumns {
- /** The last time (in milliseconds) this {@link Data} was used. */
+ /**
+ * The last time (in milliseconds) this {@link Data} was used.
+ * @deprecated Contacts affinity information is no longer supported as of
+ * Android version {@link android.os.Build.VERSION_CODES#Q}.
+ * This column always contains 0.
+ */
+ @Deprecated
public static final String LAST_TIME_USED = "last_time_used";
- /** The number of times the referenced {@link Data} has been used. */
+ /**
+ * The number of times the referenced {@link Data} has been used.
+ * @deprecated Contacts affinity information is no longer supported as of
+ * Android version {@link android.os.Build.VERSION_CODES#Q}.
+ * This column always contains 0.
+ */
+ @Deprecated
public static final String TIMES_USED = "times_used";
/** @hide Raw value. */
@@ -4765,18 +4745,6 @@
* </tr>
* <tr>
* <td>int</td>
- * <td>{@link #TIMES_CONTACTED}</td>
- * <td>read-only</td>
- * <td>See {@link ContactsContract.Contacts}.</td>
- * </tr>
- * <tr>
- * <td>long</td>
- * <td>{@link #LAST_TIME_CONTACTED}</td>
- * <td>read-only</td>
- * <td>See {@link ContactsContract.Contacts}.</td>
- * </tr>
- * <tr>
- * <td>int</td>
* <td>{@link #STARRED}</td>
* <td>read-only</td>
* <td>See {@link ContactsContract.Contacts}.</td>
@@ -5221,18 +5189,6 @@
* </tr>
* <tr>
* <td>int</td>
- * <td>{@link #TIMES_CONTACTED}</td>
- * <td>read-only</td>
- * <td>See {@link ContactsContract.Contacts}.</td>
- * </tr>
- * <tr>
- * <td>long</td>
- * <td>{@link #LAST_TIME_CONTACTED}</td>
- * <td>read-only</td>
- * <td>See {@link ContactsContract.Contacts}.</td>
- * </tr>
- * <tr>
- * <td>int</td>
* <td>{@link #STARRED}</td>
* <td>read-only</td>
* <td>See {@link ContactsContract.Contacts}.</td>
@@ -8305,7 +8261,12 @@
* boolean successful = resolver.delete(DataUsageFeedback.DELETE_USAGE_URI, null, null) > 0;
* </pre>
* </p>
+ *
+ * @deprecated Contacts affinity information is no longer supported as of
+ * Android version {@link android.os.Build.VERSION_CODES#Q}.
+ * Both update and delete calls are always ignored.
*/
+ @Deprecated
public static final class DataUsageFeedback {
/**
@@ -8925,10 +8886,6 @@
* +<phone>", etc. If you must show the prefix text in the Contacts App, please use a
* different DATA# column, and update your contacts.xml to point to this new column. </em>
* </li>
- * <li>Everytime the user sends a message to a contact, your app may choose to update the
- * {@link ContactOptionsColumns#TIMES_CONTACTED} entry through DataUsageFeedback class.
- * Doing this will allow Voice Assistant to bias speech recognition to contacts frequently
- * contacted, this is particularly useful for contact names that are hard to pronounce.</li>
* </ul>
* If the app chooses not to integrate with the Contacts Provider (in particular, when
* either METADATA_ACCOUNT_TYPE or METADATA_MIMETYPE field is missing), Voice Assistant
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 6cf67de..788579f 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -6017,6 +6017,7 @@
* Whether the hush gesture has ever been used
* @hide
*/
+ @SystemApi
public static final String HUSH_GESTURE_USED = "hush_gesture_used";
private static final Validator HUSH_GESTURE_USED_VALIDATOR = BOOLEAN_VALIDATOR;
@@ -6025,6 +6026,7 @@
* Number of times the user has manually clicked the ringer toggle
* @hide
*/
+ @SystemApi
public static final String MANUAL_RINGER_TOGGLE_COUNT = "manual_ringer_toggle_count";
private static final Validator MANUAL_RINGER_TOGGLE_COUNT_VALIDATOR =
@@ -7942,6 +7944,7 @@
*
* @hide
*/
+ @SystemApi
public static final String VOLUME_HUSH_GESTURE = "volume_hush_gesture";
/** @hide */ public static final int VOLUME_HUSH_OFF = 0;
diff --git a/core/java/android/security/net/config/ManifestConfigSource.java b/core/java/android/security/net/config/ManifestConfigSource.java
index 79115a5..b885e72 100644
--- a/core/java/android/security/net/config/ManifestConfigSource.java
+++ b/core/java/android/security/net/config/ManifestConfigSource.java
@@ -75,7 +75,7 @@
// should use the network security config.
boolean usesCleartextTraffic =
(mApplicationInfo.flags & ApplicationInfo.FLAG_USES_CLEARTEXT_TRAFFIC) != 0
- && mApplicationInfo.targetSandboxVersion < 2;
+ && !mApplicationInfo.isInstantApp();
source = new DefaultConfigSource(usesCleartextTraffic, mApplicationInfo);
}
mConfigSource = source;
diff --git a/core/java/android/security/net/config/NetworkSecurityConfig.java b/core/java/android/security/net/config/NetworkSecurityConfig.java
index 52f48ef..57068fa 100644
--- a/core/java/android/security/net/config/NetworkSecurityConfig.java
+++ b/core/java/android/security/net/config/NetworkSecurityConfig.java
@@ -185,7 +185,7 @@
.addCertificatesEntryRef(
new CertificatesEntryRef(SystemCertificateSource.getInstance(), false));
final boolean cleartextTrafficPermitted = info.targetSdkVersion < Build.VERSION_CODES.P
- && info.targetSandboxVersion < 2;
+ && !info.isInstantApp();
builder.setCleartextTrafficPermitted(cleartextTrafficPermitted);
// Applications targeting N and above must opt in into trusting the user added certificate
// store.
diff --git a/core/java/android/speech/tts/TextToSpeech.java b/core/java/android/speech/tts/TextToSpeech.java
index 6f1bd78..83f14d1 100644
--- a/core/java/android/speech/tts/TextToSpeech.java
+++ b/core/java/android/speech/tts/TextToSpeech.java
@@ -20,6 +20,7 @@
import android.annotation.RawRes;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
+import android.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
@@ -668,8 +669,10 @@
}
private final Context mContext;
+ @UnsupportedAppUsage
private Connection mConnectingServiceConnection;
private Connection mServiceConnection;
+ @UnsupportedAppUsage
private OnInitListener mInitListener;
// Written from an unspecified application thread, read from
// a binder thread.
@@ -686,6 +689,7 @@
private final Map<CharSequence, Uri> mUtterances;
private final Bundle mParams = new Bundle();
private final TtsEngines mEnginesHelper;
+ @UnsupportedAppUsage
private volatile String mCurrentEngine = null;
/**
@@ -1425,6 +1429,7 @@
* @return the engine currently in use by this TextToSpeech instance.
* @hide
*/
+ @UnsupportedAppUsage
public String getCurrentEngine() {
return mCurrentEngine;
}
diff --git a/core/java/android/speech/tts/TtsEngines.java b/core/java/android/speech/tts/TtsEngines.java
index a8c3453..a7b280b 100644
--- a/core/java/android/speech/tts/TtsEngines.java
+++ b/core/java/android/speech/tts/TtsEngines.java
@@ -30,6 +30,7 @@
import static android.provider.Settings.Secure.getString;
+import android.annotation.UnsupportedAppUsage;
import android.provider.Settings;
import android.speech.tts.TextToSpeech.Engine;
import android.speech.tts.TextToSpeech.EngineInfo;
@@ -101,6 +102,7 @@
sNormalizeCountry = Collections.unmodifiableMap(normalizeCountry);
}
+ @UnsupportedAppUsage
public TtsEngines(Context ctx) {
mContext = ctx;
}
@@ -155,6 +157,7 @@
*
* @return A list of engine info objects. The list can be empty, but never {@code null}.
*/
+ @UnsupportedAppUsage
public List<EngineInfo> getEngines() {
PackageManager pm = mContext.getPackageManager();
Intent intent = new Intent(Engine.INTENT_ACTION_TTS_SERVICE);
@@ -194,6 +197,7 @@
/**
* @return an intent that can launch the settings activity for a given tts engine.
*/
+ @UnsupportedAppUsage
public Intent getSettingsIntent(String engine) {
PackageManager pm = mContext.getPackageManager();
Intent intent = new Intent(Engine.INTENT_ACTION_TTS_SERVICE);
@@ -327,6 +331,7 @@
* @param engineName the engine to return the locale for.
* @return the locale preference for this engine. Will be non null.
*/
+ @UnsupportedAppUsage
public Locale getLocalePrefForEngine(String engineName) {
return getLocalePrefForEngine(engineName,
getString(mContext.getContentResolver(), Settings.Secure.TTS_DEFAULT_LOCALE));
@@ -376,6 +381,7 @@
* country codes ({@link Locale#getISO3Language()} and {@link Locale#getISO3Country()}),
* if it fails to do so, we return null.
*/
+ @UnsupportedAppUsage
public Locale parseLocaleString(String localeString) {
String language = "", country = "", variant = "";
if (!TextUtils.isEmpty(localeString)) {
@@ -436,6 +442,7 @@
* This method tries to convert three-letter language and country codes into their two-letter
* equivalents. If it fails to do so, it keeps the value from the TTS locale.
*/
+ @UnsupportedAppUsage
public static Locale normalizeTTSLocale(Locale ttsLocale) {
String language = ttsLocale.getLanguage();
if (!TextUtils.isEmpty(language)) {
@@ -514,6 +521,7 @@
* the passed locale is null, an empty string will be serialized; that empty string, when
* read back, will evaluate to {@link Locale#getDefault()}.
*/
+ @UnsupportedAppUsage
public synchronized void updateLocalePrefForEngine(String engineName, Locale newLocale) {
final String prefList = Settings.Secure.getString(mContext.getContentResolver(),
Settings.Secure.TTS_DEFAULT_LOCALE);
diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java
index 6dad238..cc2869f 100644
--- a/core/java/android/text/StaticLayout.java
+++ b/core/java/android/text/StaticLayout.java
@@ -313,10 +313,17 @@
/**
* Set break strategy, useful for selecting high quality or balanced paragraph
* layout options. The default is {@link Layout#BREAK_STRATEGY_SIMPLE}.
+ * <p/>
+ * Enabling hyphenation with either using {@link Layout#HYPHENATION_FREQUENCY_NORMAL} or
+ * {@link Layout#HYPHENATION_FREQUENCY_FULL} while line breaking is set to one of
+ * {@link Layout#BREAK_STRATEGY_BALANCED}, {@link Layout#BREAK_STRATEGY_HIGH_QUALITY}
+ * improves the structure of text layout however has performance impact and requires more
+ * time to do the text layout.
*
* @param breakStrategy break strategy for paragraph layout
* @return this builder, useful for chaining
* @see android.widget.TextView#setBreakStrategy
+ * @see #setHyphenationFrequency(int)
*/
@NonNull
public Builder setBreakStrategy(@BreakStrategy int breakStrategy) {
@@ -329,10 +336,17 @@
* possible values are defined in {@link Layout}, by constants named with the pattern
* {@code HYPHENATION_FREQUENCY_*}. The default is
* {@link Layout#HYPHENATION_FREQUENCY_NONE}.
+ * <p/>
+ * Enabling hyphenation with either using {@link Layout#HYPHENATION_FREQUENCY_NORMAL} or
+ * {@link Layout#HYPHENATION_FREQUENCY_FULL} while line breaking is set to one of
+ * {@link Layout#BREAK_STRATEGY_BALANCED}, {@link Layout#BREAK_STRATEGY_HIGH_QUALITY}
+ * improves the structure of text layout however has performance impact and requires more
+ * time to do the text layout.
*
* @param hyphenationFrequency hyphenation frequency for the paragraph
* @return this builder, useful for chaining
* @see android.widget.TextView#setHyphenationFrequency
+ * @see #setBreakStrategy(int)
*/
@NonNull
public Builder setHyphenationFrequency(@HyphenationFrequency int hyphenationFrequency) {
diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java
index 2c00391..0115d26 100644
--- a/core/java/android/view/KeyEvent.java
+++ b/core/java/android/view/KeyEvent.java
@@ -2920,6 +2920,9 @@
* such as "KEYCODE_A", "KEYCODE_DPAD_UP", or an equivalent numeric constant
* such as "1001" if unknown.
*
+ * This function is intended to be used mostly for debugging, logging, and testing. It is not
+ * locale-specific and is not intended to be used in a user-facing manner.
+ *
* @param keyCode The key code.
* @return The symbolic name of the specified keycode.
*
diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java
index 78e4204..b9f9e5e 100644
--- a/core/java/android/view/Window.java
+++ b/core/java/android/view/Window.java
@@ -854,7 +854,7 @@
}
/**
- * Set an observer to collect frame stats for each frame rendererd in this window.
+ * Set an observer to collect frame stats for each frame rendered in this window.
*
* Must be in hardware rendering mode.
*/
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index ea54696..5cadbe4 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -4106,9 +4106,16 @@
* TextView is {@link Layout#BREAK_STRATEGY_HIGH_QUALITY}, and the default value for
* EditText is {@link Layout#BREAK_STRATEGY_SIMPLE}, the latter to avoid the
* text "dancing" when being edited.
+ * <p/>
+ * Enabling hyphenation with either using {@link Layout#HYPHENATION_FREQUENCY_NORMAL} or
+ * {@link Layout#HYPHENATION_FREQUENCY_FULL} while line breaking is set to one of
+ * {@link Layout#BREAK_STRATEGY_BALANCED}, {@link Layout#BREAK_STRATEGY_HIGH_QUALITY}
+ * improves the structure of text layout however has performance impact and requires more time
+ * to do the text layout.
*
* @attr ref android.R.styleable#TextView_breakStrategy
* @see #getBreakStrategy()
+ * @see #setHyphenationFrequency(int)
*/
public void setBreakStrategy(@Layout.BreakStrategy int breakStrategy) {
mBreakStrategy = breakStrategy;
@@ -4134,12 +4141,26 @@
/**
* Sets the frequency of automatic hyphenation to use when determining word breaks.
* The default value for both TextView and {@link EditText} is
- * {@link Layout#HYPHENATION_FREQUENCY_NORMAL}.
- * Note that the default hyphenation frequency value is set from the theme.
+ * {@link Layout#HYPHENATION_FREQUENCY_NONE}. Note that the default hyphenation frequency value
+ * is set from the theme.
+ * <p/>
+ * Enabling hyphenation with either using {@link Layout#HYPHENATION_FREQUENCY_NORMAL} or
+ * {@link Layout#HYPHENATION_FREQUENCY_FULL} while line breaking is set to one of
+ * {@link Layout#BREAK_STRATEGY_BALANCED}, {@link Layout#BREAK_STRATEGY_HIGH_QUALITY}
+ * improves the structure of text layout however has performance impact and requires more time
+ * to do the text layout.
+ * <p/>
+ * Note: Before Android Q, in the theme hyphenation frequency is set to
+ * {@link Layout#HYPHENATION_FREQUENCY_NORMAL}. The default value is changed into
+ * {@link Layout#HYPHENATION_FREQUENCY_NONE} on Q.
*
- * @param hyphenationFrequency The hyphenation frequency to use.
+ * @param hyphenationFrequency the hyphenation frequency to use, one of
+ * {@link Layout#HYPHENATION_FREQUENCY_NONE},
+ * {@link Layout#HYPHENATION_FREQUENCY_NORMAL},
+ * {@link Layout#HYPHENATION_FREQUENCY_FULL}
* @attr ref android.R.styleable#TextView_hyphenationFrequency
* @see #getHyphenationFrequency()
+ * @see #getBreakStrategy()
*/
public void setHyphenationFrequency(@Layout.HyphenationFrequency int hyphenationFrequency) {
mHyphenationFrequency = hyphenationFrequency;
diff --git a/core/java/com/android/internal/app/IntentForwarderActivity.java b/core/java/com/android/internal/app/IntentForwarderActivity.java
index abb9321..ae9c5c4 100644
--- a/core/java/com/android/internal/app/IntentForwarderActivity.java
+++ b/core/java/com/android/internal/app/IntentForwarderActivity.java
@@ -16,6 +16,10 @@
package com.android.internal.app;
+import static android.content.pm.PackageManager.MATCH_DEFAULT_ONLY;
+
+import android.annotation.Nullable;
+import android.annotation.StringRes;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityTaskManager;
@@ -23,8 +27,11 @@
import android.app.AppGlobals;
import android.app.admin.DevicePolicyManager;
import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
import android.os.Bundle;
import android.os.RemoteException;
@@ -32,12 +39,11 @@
import android.os.UserManager;
import android.util.Slog;
import android.widget.Toast;
-
import com.android.internal.annotations.VisibleForTesting;
-
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
-
-import static android.content.pm.PackageManager.MATCH_DEFAULT_ONLY;
+import java.util.Set;
/**
* This is used in conjunction with
@@ -45,7 +51,6 @@
* be passed in and out of a managed profile.
*/
public class IntentForwarderActivity extends Activity {
-
public static String TAG = "IntentForwarderActivity";
public static String FORWARD_INTENT_TO_PARENT
@@ -54,6 +59,9 @@
public static String FORWARD_INTENT_TO_MANAGED_PROFILE
= "com.android.internal.app.ForwardIntentToManagedProfile";
+ private static final Set<String> ALLOWED_TEXT_MESSAGE_SCHEME
+ = new HashSet<>(Arrays.asList("sms", "smsto", "mms", "mmsto"));
+
private Injector mInjector;
@Override
@@ -94,19 +102,8 @@
newIntent.prepareToLeaveUser(callingUserId);
}
- final android.content.pm.ResolveInfo ri =
- mInjector.getPackageManager().resolveActivityAsUser(
- newIntent,
- MATCH_DEFAULT_ONLY,
- targetUserId);
-
- // Don't show the disclosure if next activity is ResolverActivity or ChooserActivity
- // as those will already have shown work / personal as neccesary etc.
- final boolean shouldShowDisclosure = ri == null || ri.activityInfo == null ||
- !"android".equals(ri.activityInfo.packageName) ||
- !(ResolverActivity.class.getName().equals(ri.activityInfo.name)
- || ChooserActivity.class.getName().equals(ri.activityInfo.name));
-
+ final ResolveInfo ri = mInjector.resolveActivityAsUser(newIntent, MATCH_DEFAULT_ONLY,
+ targetUserId);
try {
startActivityAsCaller(newIntent, null, false, targetUserId);
} catch (RuntimeException e) {
@@ -125,8 +122,8 @@
+ ActivityThread.currentProcessName(), e);
}
- if (shouldShowDisclosure) {
- Toast.makeText(this, getString(userMessageId), Toast.LENGTH_LONG).show();
+ if (shouldShowDisclosure(ri, intentReceived)) {
+ mInjector.showToast(userMessageId, Toast.LENGTH_LONG);
}
} else {
Slog.wtf(TAG, "the intent: " + intentReceived + " cannot be forwarded from user "
@@ -135,6 +132,35 @@
finish();
}
+ private boolean shouldShowDisclosure(@Nullable ResolveInfo ri, Intent intent) {
+ if (ri == null || ri.activityInfo == null) {
+ return true;
+ }
+ if (ri.activityInfo.applicationInfo.isSystemApp()
+ && (isDialerIntent(intent) || isTextMessageIntent(intent))) {
+ return false;
+ }
+ return !isTargetResolverOrChooserActivity(ri.activityInfo);
+ }
+
+ private boolean isTextMessageIntent(Intent intent) {
+ return Intent.ACTION_SENDTO.equals(intent.getAction()) && intent.getData() != null
+ && ALLOWED_TEXT_MESSAGE_SCHEME.contains(intent.getData().getScheme());
+ }
+
+ private boolean isDialerIntent(Intent intent) {
+ return Intent.ACTION_DIAL.equals(intent.getAction())
+ || Intent.ACTION_CALL.equals(intent.getAction());
+ }
+
+ private boolean isTargetResolverOrChooserActivity(ActivityInfo activityInfo) {
+ if (!"android".equals(activityInfo.packageName)) {
+ return false;
+ }
+ return ResolverActivity.class.getName().equals(activityInfo.name)
+ || ChooserActivity.class.getName().equals(activityInfo.name);
+ }
+
/**
* Check whether the intent can be forwarded to target user. Return the intent used for
* forwarding if it can be forwarded, {@code null} otherwise.
@@ -242,6 +268,16 @@
public PackageManager getPackageManager() {
return IntentForwarderActivity.this.getPackageManager();
}
+
+ @Override
+ public ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId) {
+ return getPackageManager().resolveActivityAsUser(intent, flags, userId);
+ }
+
+ @Override
+ public void showToast(int messageId, int duration) {
+ Toast.makeText(IntentForwarderActivity.this, getString(messageId), duration).show();
+ }
}
public interface Injector {
@@ -250,5 +286,9 @@
UserManager getUserManager();
PackageManager getPackageManager();
+
+ ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId);
+
+ void showToast(@StringRes int messageId, int duration);
}
}
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 76f9a8d..f314872 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -36,7 +36,6 @@
import android.os.BatteryManager;
import android.os.BatteryStats;
import android.os.Build;
-import android.os.FileUtils;
import android.os.Handler;
import android.os.IBatteryPropertiesRegistrar;
import android.os.Looper;
@@ -109,7 +108,9 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -623,11 +624,11 @@
// These are the objects that will want to do something when the device
// is unplugged from power.
- protected final TimeBase mOnBatteryTimeBase = new TimeBase();
+ protected final TimeBase mOnBatteryTimeBase = new TimeBase(true);
// These are the objects that will want to do something when the device
// is unplugged from power *and* the screen is off or doze.
- protected final TimeBase mOnBatteryScreenOffTimeBase = new TimeBase();
+ protected final TimeBase mOnBatteryScreenOffTimeBase = new TimeBase(true);
// Set to true when we want to distribute CPU across wakelocks for the next
// CPU update, even if we aren't currently running wake locks.
@@ -1054,15 +1055,29 @@
mClocks = clocks;
}
+ /**
+ * TimeBase observer.
+ */
public interface TimeBaseObs {
void onTimeStarted(long elapsedRealtime, long baseUptime, long baseRealtime);
void onTimeStopped(long elapsedRealtime, long baseUptime, long baseRealtime);
+
+ /**
+ * Reset the observer's state, returns true if the timer/counter is inactive
+ * so it can be destroyed.
+ * @param detachIfReset detach if true, no-op if false.
+ * @return Returns true if the timer/counter is inactive and can be destroyed.
+ */
+ boolean reset(boolean detachIfReset);
+ /**
+ * Detach the observer from TimeBase.
+ */
+ void detach();
}
// methods are protected not private to be VisibleForTesting
public static class TimeBase {
- protected final ArrayList<TimeBaseObs> mObservers = new ArrayList<>();
-
+ protected final Collection<TimeBaseObs> mObservers;
protected long mUptime;
protected long mRealtime;
@@ -1103,15 +1118,29 @@
sb.append("mUnpluggedRealtime="); formatTimeMs(sb, mUnpluggedRealtime / 1000);
pw.println(sb.toString());
}
+ /**
+ * The mObservers of TimeBase in BatteryStatsImpl object can contain up to 20k entries.
+ * The mObservers of TimeBase in BatteryStatsImpl.Uid object only contains a few or tens of
+ * entries.
+ * mObservers must have good performance on add(), remove(), also be memory efficient.
+ * This is why we provide isLongList parameter for long and short list user cases.
+ * @param isLongList If true, use HashSet for mObservers list.
+ * If false, use ArrayList for mObservers list.
+ */
+ public TimeBase(boolean isLongList) {
+ mObservers = isLongList ? new HashSet<>() : new ArrayList<>();
+ }
+
+ public TimeBase() {
+ this(false);
+ }
public void add(TimeBaseObs observer) {
mObservers.add(observer);
}
public void remove(TimeBaseObs observer) {
- if (!mObservers.remove(observer)) {
- Slog.wtf(TAG, "Removed unknown observer: " + observer);
- }
+ mObservers.remove(observer);
}
public boolean hasObserver(TimeBaseObs observer) {
@@ -1204,19 +1233,24 @@
mRealtimeStart = realtime;
long batteryUptime = mUnpluggedUptime = getUptime(uptime);
long batteryRealtime = mUnpluggedRealtime = getRealtime(realtime);
-
- for (int i = mObservers.size() - 1; i >= 0; i--) {
- mObservers.get(i).onTimeStarted(realtime, batteryUptime, batteryRealtime);
+ // Normally we do not use Iterator in framework code to avoid alloc/dealloc
+ // Iterator object, here is an exception because mObservers' type is Collection
+ // instead of list.
+ final Iterator<TimeBaseObs> iter = mObservers.iterator();
+ while (iter.hasNext()) {
+ iter.next().onTimeStarted(realtime, batteryUptime, batteryRealtime);
}
} else {
mPastUptime += uptime - mUptimeStart;
mPastRealtime += realtime - mRealtimeStart;
-
long batteryUptime = getUptime(uptime);
long batteryRealtime = getRealtime(realtime);
-
- for (int i = mObservers.size() - 1; i >= 0; i--) {
- mObservers.get(i).onTimeStopped(realtime, batteryUptime, batteryRealtime);
+ // Normally we do not use Iterator in framework code to avoid alloc/dealloc
+ // Iterator object, here is an exception because mObservers' type is Collection
+ // instead of list.
+ final Iterator<TimeBaseObs> iter = mObservers.iterator();
+ while (iter.hasNext()) {
+ iter.next().onTimeStopped(realtime, batteryUptime, batteryRealtime);
}
}
return true;
@@ -1364,15 +1398,18 @@
/**
* Clear state of this counter.
*/
- void reset(boolean detachIfReset) {
+ @Override
+ public boolean reset(boolean detachIfReset) {
mCount.set(0);
mLoadedCount = mPluggedCount = mUnpluggedCount = 0;
if (detachIfReset) {
detach();
}
+ return true;
}
- void detach() {
+ @Override
+ public void detach() {
mTimeBase.remove(this);
}
@@ -1468,15 +1505,18 @@
/**
* Clear state of this counter.
*/
- public void reset(boolean detachIfReset) {
+ @Override
+ public boolean reset(boolean detachIfReset) {
fillArray(mCounts, 0);
fillArray(mLoadedCounts, 0);
fillArray(mUnpluggedCounts, 0);
if (detachIfReset) {
detach();
}
+ return true;
}
+ @Override
public void detach() {
mTimeBase.remove(this);
}
@@ -1639,14 +1679,17 @@
/**
* Clear state of this counter.
*/
- public void reset(boolean detachIfReset) {
+ @Override
+ public boolean reset(boolean detachIfReset) {
mCount = 0;
mLoadedCount = mUnpluggedCount = 0;
if (detachIfReset) {
detach();
}
+ return true;
}
+ @Override
public void detach() {
mTimeBase.remove(this);
}
@@ -1747,6 +1790,7 @@
* Clear state of this timer. Returns true if the timer is inactive
* so can be completely dropped.
*/
+ @Override
public boolean reset(boolean detachIfReset) {
mTotalTime = mLoadedTime = mLastTime = mTimeBeforeMark = 0;
mCount = mLoadedCount = mLastCount = 0;
@@ -1756,6 +1800,7 @@
return true;
}
+ @Override
public void detach() {
mTimeBase.remove(this);
}
@@ -6547,38 +6592,69 @@
return mUidStats;
}
- private static void detachTimerIfNotNull(BatteryStatsImpl.Timer timer) {
- if (timer != null) {
- timer.detach();
- }
- }
-
- private static boolean resetTimerIfNotNull(BatteryStatsImpl.Timer timer,
- boolean detachIfReset) {
- if (timer != null) {
- return timer.reset(detachIfReset);
+ private static <T extends TimeBaseObs> boolean resetIfNotNull(T t, boolean detachIfReset) {
+ if (t != null) {
+ return t.reset(detachIfReset);
}
return true;
}
- private static boolean resetTimerIfNotNull(DualTimer timer, boolean detachIfReset) {
- if (timer != null) {
- return timer.reset(detachIfReset);
+ private static <T extends TimeBaseObs> boolean resetIfNotNull(T[] t, boolean detachIfReset) {
+ if (t != null) {
+ boolean ret = true;
+ for (int i = 0; i < t.length; i++) {
+ ret &= resetIfNotNull(t[i], detachIfReset);
+ }
+ return ret;
}
return true;
}
- private static void detachLongCounterIfNotNull(LongSamplingCounter counter) {
- if (counter != null) {
- counter.detach();
+ private static <T extends TimeBaseObs> boolean resetIfNotNull(T[][] t, boolean detachIfReset) {
+ if (t != null) {
+ boolean ret = true;
+ for (int i = 0; i < t.length; i++) {
+ ret &= resetIfNotNull(t[i], detachIfReset);
+ }
+ return ret;
}
+ return true;
}
- private static void resetLongCounterIfNotNull(LongSamplingCounter counter,
+ private static boolean resetIfNotNull(ControllerActivityCounterImpl counter,
boolean detachIfReset) {
if (counter != null) {
counter.reset(detachIfReset);
}
+ return true;
+ }
+
+ private static <T extends TimeBaseObs> void detachIfNotNull(T t) {
+ if (t != null) {
+ t.detach();
+ }
+ }
+
+ private static <T extends TimeBaseObs> void detachIfNotNull(T[] t) {
+ if (t != null) {
+ for (int i = 0; i < t.length; i++) {
+ detachIfNotNull(t[i]);
+ }
+ }
+ }
+
+ private static <T extends TimeBaseObs> void detachIfNotNull(T[][] t) {
+ if (t != null) {
+ for (int i = 0; i < t.length; i++) {
+ detachIfNotNull(t[i]);
+ }
+ }
+ }
+
+ private static void detachIfNotNull(ControllerActivityCounterImpl counter) {
+ if (counter != null) {
+ counter.detach();
+ }
}
/**
@@ -6758,11 +6834,12 @@
mBsi = bsi;
mUid = uid;
- mOnBatteryBackgroundTimeBase = new TimeBase();
+ /* Observer list of TimeBase object in Uid is short */
+ mOnBatteryBackgroundTimeBase = new TimeBase(false);
mOnBatteryBackgroundTimeBase.init(mBsi.mClocks.uptimeMillis() * 1000,
mBsi.mClocks.elapsedRealtime() * 1000);
-
- mOnBatteryScreenOffBackgroundTimeBase = new TimeBase();
+ /* Observer list of TimeBase object in Uid is short */
+ mOnBatteryScreenOffBackgroundTimeBase = new TimeBase(false);
mOnBatteryScreenOffBackgroundTimeBase.init(mBsi.mClocks.uptimeMillis() * 1000,
mBsi.mClocks.elapsedRealtime() * 1000);
@@ -6901,6 +6978,7 @@
}
if (mProcStateTimeMs[procState] == null
|| mProcStateTimeMs[procState].getSize() != cpuTimesMs.length) {
+ detachIfNotNull(mProcStateTimeMs[procState]);
mProcStateTimeMs[procState] = new LongSamplingCounterArray(
mBsi.mOnBatteryTimeBase);
}
@@ -6914,6 +6992,7 @@
}
if (mProcStateScreenOffTimeMs[procState] == null
|| mProcStateScreenOffTimeMs[procState].getSize() != cpuTimesMs.length) {
+ detachIfNotNull(mProcStateScreenOffTimeMs[procState]);
mProcStateScreenOffTimeMs[procState] = new LongSamplingCounterArray(
mBsi.mOnBatteryScreenOffTimeBase);
}
@@ -7518,6 +7597,7 @@
void makeProcessState(int i, Parcel in) {
if (i < 0 || i >= NUM_PROCESS_STATE) return;
+ detachIfNotNull(mProcessStateTimer[i]);
if (in == null) {
mProcessStateTimer[i] = new StopwatchTimer(mBsi.mClocks, this, PROCESS_STATE, null,
mBsi.mOnBatteryTimeBase);
@@ -7581,6 +7661,7 @@
collected = new ArrayList<StopwatchTimer>();
mBsi.mWifiBatchedScanTimers.put(i, collected);
}
+ detachIfNotNull(mWifiBatchedScanTimer[i]);
if (in == null) {
mWifiBatchedScanTimer[i] = new StopwatchTimer(mBsi.mClocks, this, WIFI_BATCHED_SCAN,
collected, mBsi.mOnBatteryTimeBase);
@@ -7592,6 +7673,7 @@
void initUserActivityLocked() {
+ detachIfNotNull(mUserActivityCounters);
mUserActivityCounters = new Counter[NUM_USER_ACTIVITY_TYPES];
for (int i=0; i<NUM_USER_ACTIVITY_TYPES; i++) {
mUserActivityCounters[i] = new Counter(mBsi.mOnBatteryTimeBase);
@@ -7760,13 +7842,17 @@
}
void initNetworkActivityLocked() {
+ detachIfNotNull(mNetworkByteActivityCounters);
mNetworkByteActivityCounters = new LongSamplingCounter[NUM_NETWORK_ACTIVITY_TYPES];
+ detachIfNotNull(mNetworkPacketActivityCounters);
mNetworkPacketActivityCounters = new LongSamplingCounter[NUM_NETWORK_ACTIVITY_TYPES];
for (int i = 0; i < NUM_NETWORK_ACTIVITY_TYPES; i++) {
mNetworkByteActivityCounters[i] = new LongSamplingCounter(mBsi.mOnBatteryTimeBase);
mNetworkPacketActivityCounters[i] = new LongSamplingCounter(mBsi.mOnBatteryTimeBase);
}
+ detachIfNotNull(mMobileRadioActiveTime);
mMobileRadioActiveTime = new LongSamplingCounter(mBsi.mOnBatteryTimeBase);
+ detachIfNotNull(mMobileRadioActiveCount);
mMobileRadioActiveCount = new LongSamplingCounter(mBsi.mOnBatteryTimeBase);
}
@@ -7806,27 +7892,22 @@
active |= mWifiMulticastEnabled;
}
- active |= !resetTimerIfNotNull(mAudioTurnedOnTimer, false);
- active |= !resetTimerIfNotNull(mVideoTurnedOnTimer, false);
- active |= !resetTimerIfNotNull(mFlashlightTurnedOnTimer, false);
- active |= !resetTimerIfNotNull(mCameraTurnedOnTimer, false);
- active |= !resetTimerIfNotNull(mForegroundActivityTimer, false);
- active |= !resetTimerIfNotNull(mForegroundServiceTimer, false);
- active |= !resetTimerIfNotNull(mAggregatedPartialWakelockTimer, false);
- active |= !resetTimerIfNotNull(mBluetoothScanTimer, false);
- active |= !resetTimerIfNotNull(mBluetoothUnoptimizedScanTimer, false);
- if (mBluetoothScanResultCounter != null) {
- mBluetoothScanResultCounter.reset(false);
- }
- if (mBluetoothScanResultBgCounter != null) {
- mBluetoothScanResultBgCounter.reset(false);
- }
+ active |= !resetIfNotNull(mAudioTurnedOnTimer, false);
+ active |= !resetIfNotNull(mVideoTurnedOnTimer, false);
+ active |= !resetIfNotNull(mFlashlightTurnedOnTimer, false);
+ active |= !resetIfNotNull(mCameraTurnedOnTimer, false);
+ active |= !resetIfNotNull(mForegroundActivityTimer, false);
+ active |= !resetIfNotNull(mForegroundServiceTimer, false);
+ active |= !resetIfNotNull(mAggregatedPartialWakelockTimer, false);
+ active |= !resetIfNotNull(mBluetoothScanTimer, false);
+ active |= !resetIfNotNull(mBluetoothUnoptimizedScanTimer, false);
+
+ resetIfNotNull(mBluetoothScanResultCounter, false);
+ resetIfNotNull(mBluetoothScanResultBgCounter, false);
if (mProcessStateTimer != null) {
for (int i = 0; i < NUM_PROCESS_STATE; i++) {
- if (mProcessStateTimer[i] != null) {
- active |= !mProcessStateTimer[i].reset(false);
- }
+ active |= !resetIfNotNull(mProcessStateTimer[i], false);
}
active |= (mProcessState != ActivityManager.PROCESS_STATE_NONEXISTENT);
}
@@ -7839,75 +7920,37 @@
}
}
- if (mUserActivityCounters != null) {
- for (int i=0; i<NUM_USER_ACTIVITY_TYPES; i++) {
- mUserActivityCounters[i].reset(false);
- }
- }
+ resetIfNotNull(mUserActivityCounters, false);
- if (mNetworkByteActivityCounters != null) {
- for (int i = 0; i < NUM_NETWORK_ACTIVITY_TYPES; i++) {
- mNetworkByteActivityCounters[i].reset(false);
- mNetworkPacketActivityCounters[i].reset(false);
- }
- mMobileRadioActiveTime.reset(false);
- mMobileRadioActiveCount.reset(false);
- }
+ resetIfNotNull(mNetworkByteActivityCounters, false);
+ resetIfNotNull(mNetworkPacketActivityCounters, false);
+ resetIfNotNull(mMobileRadioActiveTime, false);
+ resetIfNotNull(mMobileRadioActiveCount, false);
- if (mWifiControllerActivity != null) {
- mWifiControllerActivity.reset(false);
- }
+ resetIfNotNull(mWifiControllerActivity, false);
+ resetIfNotNull(mBluetoothControllerActivity, false);
+ resetIfNotNull(mModemControllerActivity, false);
- if (mBluetoothControllerActivity != null) {
- mBluetoothControllerActivity.reset(false);
- }
+ resetIfNotNull(mUserCpuTime, false);
+ resetIfNotNull(mSystemCpuTime, false);
- if (mModemControllerActivity != null) {
- mModemControllerActivity.reset(false);
- }
+ resetIfNotNull(mCpuClusterSpeedTimesUs, false);
- mUserCpuTime.reset(false);
- mSystemCpuTime.reset(false);
+ resetIfNotNull(mCpuFreqTimeMs, false);
+ resetIfNotNull(mScreenOffCpuFreqTimeMs, false);
- if (mCpuClusterSpeedTimesUs != null) {
- for (LongSamplingCounter[] speeds : mCpuClusterSpeedTimesUs) {
- if (speeds != null) {
- for (LongSamplingCounter speed : speeds) {
- if (speed != null) {
- speed.reset(false);
- }
- }
- }
- }
- }
- if (mCpuFreqTimeMs != null) {
- mCpuFreqTimeMs.reset(false);
- }
- if (mScreenOffCpuFreqTimeMs != null) {
- mScreenOffCpuFreqTimeMs.reset(false);
- }
+ resetIfNotNull(mCpuActiveTimeMs, false);
+ resetIfNotNull(mCpuClusterTimesMs, false);
- mCpuActiveTimeMs.reset(false);
- mCpuClusterTimesMs.reset(false);
+ resetIfNotNull(mProcStateTimeMs, false);
- if (mProcStateTimeMs != null) {
- for (LongSamplingCounterArray counters : mProcStateTimeMs) {
- if (counters != null) {
- counters.reset(false);
- }
- }
- }
- if (mProcStateScreenOffTimeMs != null) {
- for (LongSamplingCounterArray counters : mProcStateScreenOffTimeMs) {
- if (counters != null) {
- counters.reset(false);
- }
- }
- }
+ resetIfNotNull(mProcStateScreenOffTimeMs, false);
- resetLongCounterIfNotNull(mMobileRadioApWakeupCount, false);
- resetLongCounterIfNotNull(mWifiRadioApWakeupCount, false);
+ resetIfNotNull(mMobileRadioApWakeupCount, false);
+
+ resetIfNotNull(mWifiRadioApWakeupCount, false);
+
final ArrayMap<String, Wakelock> wakeStats = mWakelockStats.getMap();
for (int iw=wakeStats.size()-1; iw>=0; iw--) {
@@ -7943,16 +7986,12 @@
mJobStats.cleanup();
mJobCompletions.clear();
- mJobsDeferredEventCount.reset(false);
- mJobsDeferredCount.reset(false);
- mJobsFreshnessTimeMs.reset(false);
- for (int ij = 0; ij < JOB_FRESHNESS_BUCKETS.length; ij++) {
- if (mJobsFreshnessBuckets[ij] != null) {
- mJobsFreshnessBuckets[ij].reset(false);
- }
- }
+ resetIfNotNull(mJobsDeferredEventCount, false);
+ resetIfNotNull(mJobsDeferredCount, false);
+ resetIfNotNull(mJobsFreshnessTimeMs, false);
+ resetIfNotNull(mJobsFreshnessBuckets, false);
- for (int ise=mSensorStats.size()-1; ise>=0; ise--) {
+ for (int ise = mSensorStats.size() - 1; ise >= 0; ise--) {
Sensor s = mSensorStats.valueAt(ise);
if (s.reset()) {
mSensorStats.removeAt(ise);
@@ -7961,173 +8000,135 @@
}
}
- for (int ip=mProcessStats.size()-1; ip>=0; ip--) {
+ for (int ip = mProcessStats.size() - 1; ip >= 0; ip--) {
Proc proc = mProcessStats.valueAt(ip);
proc.detach();
}
mProcessStats.clear();
- if (mPids.size() > 0) {
- for (int i=mPids.size()-1; i>=0; i--) {
- Pid pid = mPids.valueAt(i);
- if (pid.mWakeNesting > 0) {
- active = true;
- } else {
- mPids.removeAt(i);
- }
+
+ for (int i = mPids.size() - 1; i >= 0; i--) {
+ Pid pid = mPids.valueAt(i);
+ if (pid.mWakeNesting > 0) {
+ active = true;
+ } else {
+ mPids.removeAt(i);
}
}
- if (mPackageStats.size() > 0) {
- Iterator<Map.Entry<String, Pkg>> it = mPackageStats.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry<String, Pkg> pkgEntry = it.next();
- Pkg p = pkgEntry.getValue();
- p.detach();
- if (p.mServiceStats.size() > 0) {
- Iterator<Map.Entry<String, Pkg.Serv>> it2
- = p.mServiceStats.entrySet().iterator();
- while (it2.hasNext()) {
- Map.Entry<String, Pkg.Serv> servEntry = it2.next();
- servEntry.getValue().detach();
- }
- }
- }
- mPackageStats.clear();
+
+
+ for(int i = mPackageStats.size() - 1; i >= 0; i--) {
+ Pkg p = mPackageStats.valueAt(i);
+ p.detach();
}
+ mPackageStats.clear();
mLastStepUserTime = mLastStepSystemTime = 0;
mCurStepUserTime = mCurStepSystemTime = 0;
- if (!active) {
- if (mWifiRunningTimer != null) {
- mWifiRunningTimer.detach();
- }
- if (mFullWifiLockTimer != null) {
- mFullWifiLockTimer.detach();
- }
- if (mWifiScanTimer != null) {
- mWifiScanTimer.detach();
- }
- for (int i = 0; i < NUM_WIFI_BATCHED_SCAN_BINS; i++) {
- if (mWifiBatchedScanTimer[i] != null) {
- mWifiBatchedScanTimer[i].detach();
- }
- }
- if (mWifiMulticastTimer != null) {
- mWifiMulticastTimer.detach();
- }
- if (mAudioTurnedOnTimer != null) {
- mAudioTurnedOnTimer.detach();
- mAudioTurnedOnTimer = null;
- }
- if (mVideoTurnedOnTimer != null) {
- mVideoTurnedOnTimer.detach();
- mVideoTurnedOnTimer = null;
- }
- if (mFlashlightTurnedOnTimer != null) {
- mFlashlightTurnedOnTimer.detach();
- mFlashlightTurnedOnTimer = null;
- }
- if (mCameraTurnedOnTimer != null) {
- mCameraTurnedOnTimer.detach();
- mCameraTurnedOnTimer = null;
- }
- if (mForegroundActivityTimer != null) {
- mForegroundActivityTimer.detach();
- mForegroundActivityTimer = null;
- }
- if (mForegroundServiceTimer != null) {
- mForegroundServiceTimer.detach();
- mForegroundServiceTimer = null;
- }
- if (mAggregatedPartialWakelockTimer != null) {
- mAggregatedPartialWakelockTimer.detach();
- mAggregatedPartialWakelockTimer = null;
- }
- if (mBluetoothScanTimer != null) {
- mBluetoothScanTimer.detach();
- mBluetoothScanTimer = null;
- }
- if (mBluetoothUnoptimizedScanTimer != null) {
- mBluetoothUnoptimizedScanTimer.detach();
- mBluetoothUnoptimizedScanTimer = null;
- }
- if (mBluetoothScanResultCounter != null) {
- mBluetoothScanResultCounter.detach();
- mBluetoothScanResultCounter = null;
- }
- if (mBluetoothScanResultBgCounter != null) {
- mBluetoothScanResultBgCounter.detach();
- mBluetoothScanResultBgCounter = null;
- }
- if (mUserActivityCounters != null) {
- for (int i=0; i<NUM_USER_ACTIVITY_TYPES; i++) {
- mUserActivityCounters[i].detach();
- }
- }
- if (mNetworkByteActivityCounters != null) {
- for (int i = 0; i < NUM_NETWORK_ACTIVITY_TYPES; i++) {
- mNetworkByteActivityCounters[i].detach();
- mNetworkPacketActivityCounters[i].detach();
- }
- }
+ return !active;
+ }
- if (mWifiControllerActivity != null) {
- mWifiControllerActivity.detach();
- }
+ /**
+ * This method MUST be called whenever the Uid object is destructed, otherwise it is a
+ * memory leak in {@link TimeBase#mObservers} list.
+ * Typically the Uid object is destructed when it is removed from
+ * {@link BatteryStatsImpl#mUidStats}
+ */
+ void detachFromTimeBase() {
+ detachIfNotNull(mWifiRunningTimer);
+ detachIfNotNull(mFullWifiLockTimer);
+ detachIfNotNull(mWifiScanTimer);
+ detachIfNotNull(mWifiBatchedScanTimer);
+ detachIfNotNull(mWifiMulticastTimer);
+ detachIfNotNull(mAudioTurnedOnTimer);
+ detachIfNotNull(mVideoTurnedOnTimer);
+ detachIfNotNull(mFlashlightTurnedOnTimer);
- if (mBluetoothControllerActivity != null) {
- mBluetoothControllerActivity.detach();
- }
+ detachIfNotNull(mCameraTurnedOnTimer);
+ detachIfNotNull(mForegroundActivityTimer);
+ detachIfNotNull(mForegroundServiceTimer);
- if (mModemControllerActivity != null) {
- mModemControllerActivity.detach();
- }
+ detachIfNotNull(mAggregatedPartialWakelockTimer);
- mPids.clear();
+ detachIfNotNull(mBluetoothScanTimer);
+ detachIfNotNull(mBluetoothUnoptimizedScanTimer);
+ detachIfNotNull(mBluetoothScanResultCounter);
+ detachIfNotNull(mBluetoothScanResultBgCounter);
- mUserCpuTime.detach();
- mSystemCpuTime.detach();
+ detachIfNotNull(mProcessStateTimer);
- if (mCpuClusterSpeedTimesUs != null) {
- for (LongSamplingCounter[] cpuSpeeds : mCpuClusterSpeedTimesUs) {
- if (cpuSpeeds != null) {
- for (LongSamplingCounter c : cpuSpeeds) {
- if (c != null) {
- c.detach();
- }
- }
- }
- }
- }
+ detachIfNotNull(mVibratorOnTimer);
- if (mCpuFreqTimeMs != null) {
- mCpuFreqTimeMs.detach();
- }
- if (mScreenOffCpuFreqTimeMs != null) {
- mScreenOffCpuFreqTimeMs.detach();
- }
- mCpuActiveTimeMs.detach();
- mCpuClusterTimesMs.detach();
+ detachIfNotNull(mUserActivityCounters);
- if (mProcStateTimeMs != null) {
- for (LongSamplingCounterArray counters : mProcStateTimeMs) {
- if (counters != null) {
- counters.detach();
- }
- }
- }
- if (mProcStateScreenOffTimeMs != null) {
- for (LongSamplingCounterArray counters : mProcStateScreenOffTimeMs) {
- if (counters != null) {
- counters.detach();
- }
- }
- }
- detachLongCounterIfNotNull(mMobileRadioApWakeupCount);
- detachLongCounterIfNotNull(mWifiRadioApWakeupCount);
+ detachIfNotNull(mNetworkByteActivityCounters);
+ detachIfNotNull(mNetworkPacketActivityCounters);
+
+ detachIfNotNull(mMobileRadioActiveTime);
+ detachIfNotNull(mMobileRadioActiveCount);
+ detachIfNotNull(mMobileRadioApWakeupCount);
+ detachIfNotNull(mWifiRadioApWakeupCount);
+
+ detachIfNotNull(mWifiControllerActivity);
+ detachIfNotNull(mBluetoothControllerActivity);
+ detachIfNotNull(mModemControllerActivity);
+
+ mPids.clear();
+
+ detachIfNotNull(mUserCpuTime);
+ detachIfNotNull(mSystemCpuTime);
+
+ detachIfNotNull(mCpuClusterSpeedTimesUs);
+
+ detachIfNotNull(mCpuActiveTimeMs);
+ detachIfNotNull(mCpuFreqTimeMs);
+
+ detachIfNotNull(mScreenOffCpuFreqTimeMs);
+
+ detachIfNotNull(mCpuClusterTimesMs);
+
+ detachIfNotNull(mProcStateTimeMs);
+
+ detachIfNotNull(mProcStateScreenOffTimeMs);
+
+ final ArrayMap<String, Wakelock> wakeStats = mWakelockStats.getMap();
+ for (int iw = wakeStats.size() - 1; iw >= 0; iw--) {
+ Wakelock wl = wakeStats.valueAt(iw);
+ wl.detachFromTimeBase();
+ }
+ final ArrayMap<String, DualTimer> syncStats = mSyncStats.getMap();
+ for (int is = syncStats.size() - 1; is >= 0; is--) {
+ DualTimer timer = syncStats.valueAt(is);
+ detachIfNotNull(timer);
+ }
+ final ArrayMap<String, DualTimer> jobStats = mJobStats.getMap();
+ for (int ij = jobStats.size() - 1; ij >= 0; ij--) {
+ DualTimer timer = jobStats.valueAt(ij);
+ detachIfNotNull(timer);
}
- return !active;
+ detachIfNotNull(mJobsDeferredEventCount);
+ detachIfNotNull(mJobsDeferredCount);
+ detachIfNotNull(mJobsFreshnessTimeMs);
+ detachIfNotNull(mJobsFreshnessBuckets);
+
+
+ for (int ise = mSensorStats.size() - 1; ise >= 0; ise--) {
+ Sensor s = mSensorStats.valueAt(ise);
+ s.detachFromTimeBase();
+ }
+
+ for (int ip= mProcessStats.size() - 1; ip >= 0; ip--) {
+ Proc proc = mProcessStats.valueAt(ip);
+ proc.detach();
+ }
+ mProcessStats.clear();
+
+ for(int i = mPackageStats.size() - 1; i >= 0; i--) {
+ Pkg p = mPackageStats.valueAt(i);
+ p.detach();
+ }
+ mPackageStats.clear();
}
void writeJobCompletionsToParcelLocked(Parcel out) {
@@ -8850,35 +8851,24 @@
boolean reset() {
boolean wlactive = false;
- if (mTimerFull != null) {
- wlactive |= !mTimerFull.reset(false);
- }
- if (mTimerPartial != null) {
- wlactive |= !mTimerPartial.reset(false);
- }
- if (mTimerWindow != null) {
- wlactive |= !mTimerWindow.reset(false);
- }
- if (mTimerDraw != null) {
- wlactive |= !mTimerDraw.reset(false);
- }
+
+ wlactive |= !resetIfNotNull(mTimerFull,false);
+ wlactive |= !resetIfNotNull(mTimerPartial,false);
+ wlactive |= !resetIfNotNull(mTimerWindow,false);
+ wlactive |= !resetIfNotNull(mTimerDraw,false);
+
if (!wlactive) {
- if (mTimerFull != null) {
- mTimerFull.detach();
- mTimerFull = null;
- }
- if (mTimerPartial != null) {
- mTimerPartial.detach();
- mTimerPartial = null;
- }
- if (mTimerWindow != null) {
- mTimerWindow.detach();
- mTimerWindow = null;
- }
- if (mTimerDraw != null) {
- mTimerDraw.detach();
- mTimerDraw = null;
- }
+ detachIfNotNull(mTimerFull);
+ mTimerFull = null;
+
+ detachIfNotNull(mTimerPartial);
+ mTimerPartial = null;
+
+ detachIfNotNull(mTimerWindow);
+ mTimerWindow = null;
+
+ detachIfNotNull(mTimerDraw);
+ mTimerDraw = null;
}
return !wlactive;
}
@@ -8912,6 +8902,13 @@
default: throw new IllegalArgumentException("type = " + type);
}
}
+
+ public void detachFromTimeBase() {
+ detachIfNotNull(mTimerPartial);
+ detachIfNotNull(mTimerFull);
+ detachIfNotNull(mTimerWindow);
+ detachIfNotNull(mTimerDraw);
+ }
}
public static class Sensor extends BatteryStats.Uid.Sensor {
@@ -8981,6 +8978,10 @@
public int getHandle() {
return mHandle;
}
+
+ public void detachFromTimeBase() {
+ detachIfNotNull(mTimer);
+ }
}
/**
@@ -9112,7 +9113,16 @@
public void onTimeStopped(long elapsedRealtime, long baseUptime, long baseRealtime) {
}
- void detach() {
+ @Override
+ public boolean reset(boolean detachIfReset) {
+ if (detachIfReset) {
+ this.detach();
+ }
+ return true;
+ }
+
+ @Override
+ public void detach() {
mActive = false;
mBsi.mOnBatteryTimeBase.remove(this);
}
@@ -9351,8 +9361,23 @@
public void onTimeStopped(long elapsedRealtime, long baseUptime, long baseRealtime) {
}
- void detach() {
+ @Override
+ public boolean reset(boolean detachIfReset) {
+ if (detachIfReset) {
+ this.detach();
+ }
+ return true;
+ }
+
+ @Override
+ public void detach() {
mBsi.mOnBatteryScreenOffTimeBase.remove(this);
+ for (int j = mWakeupAlarms.size() - 1; j >= 0; j--) {
+ detachIfNotNull(mWakeupAlarms.valueAt(j));
+ }
+ for (int j = mServiceStats.size() - 1; j >= 0; j--) {
+ detachIfNotNull(mServiceStats.valueAt(j));
+ }
}
void readFromParcelLocked(Parcel in) {
@@ -9533,9 +9558,18 @@
long baseRealtime) {
}
+ @Override
+ public boolean reset(boolean detachIfReset) {
+ if (detachIfReset) {
+ this.detach();
+ }
+ return true;
+ }
+
/**
* Remove this Serv as a listener from the time base.
*/
+ @Override
public void detach() {
mBsi.mOnBatteryTimeBase.remove(this);
}
@@ -10795,6 +10829,7 @@
for (int i=0; i<mUidStats.size(); i++) {
if (mUidStats.valueAt(i).reset(uptimeMillis * 1000, elapsedRealtimeMillis * 1000)) {
+ mUidStats.valueAt(i).detachFromTimeBase();
mUidStats.remove(mUidStats.keyAt(i));
i--;
}
@@ -12101,11 +12136,13 @@
}
final Uid u = getUidStatsLocked(uid);
if (u.mCpuFreqTimeMs == null || u.mCpuFreqTimeMs.getSize() != cpuFreqTimeMs.length) {
+ detachIfNotNull(u.mCpuFreqTimeMs);
u.mCpuFreqTimeMs = new LongSamplingCounterArray(mOnBatteryTimeBase);
}
u.mCpuFreqTimeMs.addCountLocked(cpuFreqTimeMs, onBattery);
if (u.mScreenOffCpuFreqTimeMs == null ||
u.mScreenOffCpuFreqTimeMs.getSize() != cpuFreqTimeMs.length) {
+ detachIfNotNull(u.mScreenOffCpuFreqTimeMs);
u.mScreenOffCpuFreqTimeMs = new LongSamplingCounterArray(
mOnBatteryScreenOffTimeBase);
}
@@ -12114,6 +12151,7 @@
if (perClusterTimesAvailable) {
if (u.mCpuClusterSpeedTimesUs == null ||
u.mCpuClusterSpeedTimesUs.length != numClusters) {
+ detachIfNotNull(u.mCpuClusterSpeedTimesUs);
u.mCpuClusterSpeedTimesUs = new LongSamplingCounter[numClusters][];
}
if (numWakelocks > 0 && mWakeLockAllocationsUs == null) {
@@ -12125,6 +12163,7 @@
final int speedsInCluster = mPowerProfile.getNumSpeedStepsInCpuCluster(cluster);
if (u.mCpuClusterSpeedTimesUs[cluster] == null ||
u.mCpuClusterSpeedTimesUs[cluster].length != speedsInCluster) {
+ detachIfNotNull(u.mCpuClusterSpeedTimesUs[cluster]);
u.mCpuClusterSpeedTimesUs[cluster]
= new LongSamplingCounter[speedsInCluster];
}
@@ -12162,6 +12201,7 @@
final Uid u = partialTimers.get(i).mUid;
if (u.mCpuClusterSpeedTimesUs == null ||
u.mCpuClusterSpeedTimesUs.length != numClusters) {
+ detachIfNotNull(u.mCpuClusterSpeedTimesUs);
u.mCpuClusterSpeedTimesUs = new LongSamplingCounter[numClusters][];
}
@@ -12169,6 +12209,7 @@
final int speedsInCluster = mPowerProfile.getNumSpeedStepsInCpuCluster(cluster);
if (u.mCpuClusterSpeedTimesUs[cluster] == null ||
u.mCpuClusterSpeedTimesUs[cluster].length != speedsInCluster) {
+ detachIfNotNull(u.mCpuClusterSpeedTimesUs[cluster]);
u.mCpuClusterSpeedTimesUs[cluster]
= new LongSamplingCounter[speedsInCluster];
}
@@ -13106,6 +13147,12 @@
mUidStats.put(lastUidForUser, null);
final int firstIndex = mUidStats.indexOfKey(firstUidForUser);
final int lastIndex = mUidStats.indexOfKey(lastUidForUser);
+ for (int i = firstIndex; i <= lastIndex; i++) {
+ final Uid uid = mUidStats.valueAt(i);
+ if (uid != null) {
+ uid.detachFromTimeBase();
+ }
+ }
mUidStats.removeAtRange(firstIndex, lastIndex - firstIndex + 1);
}
@@ -13113,6 +13160,10 @@
* Remove the statistics object for a particular uid.
*/
public void removeUidStatsLocked(int uid) {
+ final Uid u = mUidStats.get(uid);
+ if (u != null) {
+ u.detachFromTimeBase();
+ }
mUidStats.remove(uid);
mPendingRemovedUids.add(new UidToRemove(uid, mClocks.elapsedRealtime()));
}
@@ -13978,7 +14029,7 @@
if (mPowerProfile != null && mPowerProfile.getNumCpuClusters() != numClusters) {
throw new ParcelFormatException("Incompatible cpu cluster arrangement");
}
-
+ detachIfNotNull(u.mCpuClusterSpeedTimesUs);
u.mCpuClusterSpeedTimesUs = new LongSamplingCounter[numClusters][];
for (int cluster = 0; cluster < numClusters; cluster++) {
if (in.readInt() != 0) {
@@ -14002,11 +14053,14 @@
}
}
} else {
+ detachIfNotNull(u.mCpuClusterSpeedTimesUs);
u.mCpuClusterSpeedTimesUs = null;
}
+ detachIfNotNull(u.mCpuFreqTimeMs);
u.mCpuFreqTimeMs = LongSamplingCounterArray.readSummaryFromParcelLocked(
in, mOnBatteryTimeBase);
+ detachIfNotNull(u.mScreenOffCpuFreqTimeMs);
u.mScreenOffCpuFreqTimeMs = LongSamplingCounterArray.readSummaryFromParcelLocked(
in, mOnBatteryScreenOffTimeBase);
@@ -14015,6 +14069,7 @@
int length = in.readInt();
if (length == Uid.NUM_PROCESS_STATE) {
+ detachIfNotNull(u.mProcStateTimeMs);
u.mProcStateTimeMs = new LongSamplingCounterArray[length];
for (int procState = 0; procState < length; ++procState) {
u.mProcStateTimeMs[procState]
@@ -14022,10 +14077,12 @@
in, mOnBatteryTimeBase);
}
} else {
+ detachIfNotNull(u.mProcStateTimeMs);
u.mProcStateTimeMs = null;
}
length = in.readInt();
if (length == Uid.NUM_PROCESS_STATE) {
+ detachIfNotNull(u.mProcStateScreenOffTimeMs);
u.mProcStateScreenOffTimeMs = new LongSamplingCounterArray[length];
for (int procState = 0; procState < length; ++procState) {
u.mProcStateScreenOffTimeMs[procState]
@@ -14033,20 +14090,25 @@
in, mOnBatteryScreenOffTimeBase);
}
} else {
+ detachIfNotNull(u.mProcStateScreenOffTimeMs);
u.mProcStateScreenOffTimeMs = null;
}
if (in.readInt() != 0) {
+ detachIfNotNull(u.mMobileRadioApWakeupCount);
u.mMobileRadioApWakeupCount = new LongSamplingCounter(mOnBatteryTimeBase);
u.mMobileRadioApWakeupCount.readSummaryFromParcelLocked(in);
} else {
+ detachIfNotNull(u.mMobileRadioApWakeupCount);
u.mMobileRadioApWakeupCount = null;
}
if (in.readInt() != 0) {
+ detachIfNotNull(u.mWifiRadioApWakeupCount);
u.mWifiRadioApWakeupCount = new LongSamplingCounter(mOnBatteryTimeBase);
u.mWifiRadioApWakeupCount.readSummaryFromParcelLocked(in);
} else {
+ detachIfNotNull(u.mWifiRadioApWakeupCount);
u.mWifiRadioApWakeupCount = null;
}
@@ -14082,6 +14144,7 @@
u.mJobsDeferredEventCount.readSummaryFromParcelLocked(in);
u.mJobsDeferredCount.readSummaryFromParcelLocked(in);
u.mJobsFreshnessTimeMs.readSummaryFromParcelLocked(in);
+ detachIfNotNull(u.mJobsFreshnessBuckets);
for (int i = 0; i < JOB_FRESHNESS_BUCKETS.length; i++) {
if (in.readInt() != 0) {
u.mJobsFreshnessBuckets[i] = new Counter(u.mBsi.mOnBatteryTimeBase);
@@ -14122,6 +14185,7 @@
}
for (int ip = 0; ip < NP; ip++) {
String pkgName = in.readString();
+ detachIfNotNull(u.mPackageStats.get(pkgName));
Uid.Pkg p = u.getPackageStatsLocked(pkgName);
final int NWA = in.readInt();
if (NWA > 10000) {
diff --git a/core/java/com/android/internal/os/BinderCallsStats.java b/core/java/com/android/internal/os/BinderCallsStats.java
index eb369e1..4aa30f6 100644
--- a/core/java/com/android/internal/os/BinderCallsStats.java
+++ b/core/java/com/android/internal/os/BinderCallsStats.java
@@ -37,7 +37,6 @@
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.BinderInternal.CallSession;
-import com.android.internal.util.Preconditions;
import com.android.server.LocalServices;
import java.io.PrintWriter;
@@ -45,15 +44,12 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Random;
-import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.function.Function;
import java.util.function.ToDoubleFunction;
/**
@@ -63,7 +59,7 @@
public class BinderCallsStats implements BinderInternal.Observer {
public static final boolean ENABLED_DEFAULT = false;
public static final boolean DETAILED_TRACKING_DEFAULT = true;
- public static final int PERIODIC_SAMPLING_INTERVAL_DEFAULT = 10;
+ public static final int PERIODIC_SAMPLING_INTERVAL_DEFAULT = 100;
private static final String TAG = "BinderCallsStats";
private static final int CALL_SESSIONS_POOL_SIZE = 100;
@@ -71,7 +67,10 @@
private static final int MAX_EXCEPTION_COUNT_SIZE = 50;
private static final String EXCEPTION_COUNT_OVERFLOW_NAME = "overflow";
+ // Whether to collect all the data: cpu + exceptions + reply/request sizes.
private boolean mDetailedTracking = DETAILED_TRACKING_DEFAULT;
+ // Sampling period to control how often to track CPU usage. 1 means all calls, 100 means ~1 out
+ // of 100 requests.
private int mPeriodicSamplingInterval = PERIODIC_SAMPLING_INTERVAL_DEFAULT;
@GuardedBy("mLock")
private final SparseArray<UidEntry> mUidEntries = new SparseArray<>();
@@ -181,7 +180,7 @@
s.exceptionThrown = false;
s.cpuTimeStarted = -1;
s.timeStarted = -1;
- if (mDetailedTracking || shouldRecordDetailedData()) {
+ if (shouldRecordDetailedData()) {
s.cpuTimeStarted = getThreadTimeMicro();
s.timeStarted = getElapsedRealtimeMicro();
}
@@ -228,14 +227,14 @@
final UidEntry uidEntry = getUidEntry(callingUid);
uidEntry.callCount++;
- final CallStat callStat = uidEntry.getOrCreate(
- s.binderClass, s.transactionCode, mScreenInteractive);
- callStat.callCount++;
if (recordCall) {
uidEntry.cpuTimeMicros += duration;
uidEntry.recordedCallCount++;
+ final CallStat callStat = uidEntry.getOrCreate(
+ s.binderClass, s.transactionCode, mScreenInteractive);
+ callStat.callCount++;
callStat.recordedCallCount++;
callStat.cpuTimeMicros += duration;
callStat.maxCpuTimeMicros = Math.max(callStat.maxCpuTimeMicros, duration);
@@ -249,6 +248,14 @@
callStat.maxReplySizeBytes =
Math.max(callStat.maxReplySizeBytes, parcelReplySize);
}
+ } else {
+ // Only record the total call count if we already track data for this key.
+ // It helps to keep the memory usage down when sampling is enabled.
+ final CallStat callStat = uidEntry.get(
+ s.binderClass, s.transactionCode, mScreenInteractive);
+ if (callStat != null) {
+ callStat.callCount++;
+ }
}
}
}
@@ -463,7 +470,7 @@
pw.println(String.format(" %6d %s", entry.second, entry.first));
}
- if (!mDetailedTracking && mPeriodicSamplingInterval != 1) {
+ if (mPeriodicSamplingInterval != 1) {
pw.println("");
pw.println("/!\\ Displayed data is sampled. See sampling interval at the top.");
}
@@ -492,6 +499,9 @@
return mRandom.nextInt() % mPeriodicSamplingInterval == 0;
}
+ /**
+ * Sets to true to collect all the data.
+ */
public void setDetailedTracking(boolean enabled) {
synchronized (mLock) {
if (enabled != mDetailedTracking) {
@@ -550,7 +560,8 @@
// Number of calls for which we collected data for. We do not record data for all the calls
// when sampling is on.
public long recordedCallCount;
- // Real number of total calls.
+ // Roughly the real number of total calls. We only track only track the API call count once
+ // at least one non-sampled count happened.
public long callCount;
// Total CPU of all for all the recorded calls.
// Approximate total CPU usage can be computed by
@@ -624,13 +635,19 @@
private Map<CallStatKey, CallStat> mCallStats = new ArrayMap<>();
private CallStatKey mTempKey = new CallStatKey();
- CallStat getOrCreate(Class<? extends Binder> binderClass, int transactionCode,
+ @Nullable
+ CallStat get(Class<? extends Binder> binderClass, int transactionCode,
boolean screenInteractive) {
// Use a global temporary key to avoid creating new objects for every lookup.
mTempKey.binderClass = binderClass;
mTempKey.transactionCode = transactionCode;
mTempKey.screenInteractive = screenInteractive;
- CallStat mapCallStat = mCallStats.get(mTempKey);
+ return mCallStats.get(mTempKey);
+ }
+
+ CallStat getOrCreate(Class<? extends Binder> binderClass, int transactionCode,
+ boolean screenInteractive) {
+ CallStat mapCallStat = get(binderClass, transactionCode, screenInteractive);
// Only create CallStat if it's a new entry, otherwise update existing instance
if (mapCallStat == null) {
mapCallStat = new CallStat(binderClass, transactionCode, screenInteractive);
diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp
index e5aea97..02076bd 100755
--- a/core/jni/android/graphics/Bitmap.cpp
+++ b/core/jni/android/graphics/Bitmap.cpp
@@ -437,6 +437,10 @@
return NULL;
}
+static bool IsColorSpaceSRGB(SkColorSpace* colorSpace) {
+ return colorSpace == nullptr || colorSpace->isSRGB();
+}
+
bool GraphicsJNI::SetPixels(JNIEnv* env, jintArray srcColors, int srcOffset, int srcStride,
int x, int y, int width, int height, const SkBitmap& dstBitmap) {
void* dst = dstBitmap.getPixels();
@@ -453,8 +457,7 @@
dst = dstBitmap.getAddr(x, y);
SkColorSpace* colorSpace = dstBitmap.colorSpace();
- if (dstBitmap.colorType() == kRGBA_F16_SkColorType ||
- GraphicsJNI::isColorSpaceSRGB(colorSpace)) {
+ if (dstBitmap.colorType() == kRGBA_F16_SkColorType || IsColorSpaceSRGB(colorSpace)) {
// now copy/convert each scanline
for (int y = 0; y < height; y++) {
proc(dst, src, width, x, y);
@@ -673,8 +676,8 @@
SkBitmap bitmap;
sk_sp<SkColorSpace> colorSpace;
- if (colorType != kN32_SkColorType || xyzD50 == nullptr || transferParameters == nullptr) {
- colorSpace = GraphicsJNI::colorSpaceForType(colorType);
+ if (xyzD50 == nullptr || transferParameters == nullptr) {
+ colorSpace = SkColorSpace::MakeSRGB();
} else {
SkColorSpaceTransferFn p = GraphicsJNI::getNativeTransferParameters(env, transferParameters);
SkMatrix44 xyzMatrix = GraphicsJNI::getNativeXYZMatrix(env, xyzD50);
@@ -1268,7 +1271,7 @@
if (!bitmapHolder.valid()) return JNI_TRUE;
SkColorSpace* colorSpace = bitmapHolder->info().colorSpace();
- return GraphicsJNI::isColorSpaceSRGB(colorSpace);
+ return IsColorSpaceSRGB(colorSpace);
}
static jboolean Bitmap_isSRGBLinear(JNIEnv* env, jobject, jlong bitmapHandle) {
@@ -1340,8 +1343,7 @@
proc(dst, src, 1);
SkColorSpace* colorSpace = bitmap.colorSpace();
- if (bitmap.colorType() != kRGBA_F16_SkColorType &&
- !GraphicsJNI::isColorSpaceSRGB(colorSpace)) {
+ if (bitmap.colorType() != kRGBA_F16_SkColorType && !IsColorSpaceSRGB(colorSpace)) {
auto sRGB = SkColorSpace::MakeSRGB();
auto xform = SkColorSpaceXform::New(colorSpace, sRGB.get());
xform->apply(SkColorSpaceXform::kBGRA_8888_ColorFormat, &dst[0],
@@ -1371,8 +1373,7 @@
SkColor* d = (SkColor*)dst + offset;
SkColorSpace* colorSpace = bitmap.colorSpace();
- if (bitmap.colorType() == kRGBA_F16_SkColorType ||
- GraphicsJNI::isColorSpaceSRGB(colorSpace)) {
+ if (bitmap.colorType() == kRGBA_F16_SkColorType || IsColorSpaceSRGB(colorSpace)) {
while (--height >= 0) {
proc(d, src, width);
d += stride;
@@ -1414,8 +1415,7 @@
}
SkColorSpace* colorSpace = bitmap.colorSpace();
- if (bitmap.colorType() != kRGBA_F16_SkColorType &&
- !GraphicsJNI::isColorSpaceSRGB(colorSpace)) {
+ if (bitmap.colorType() != kRGBA_F16_SkColorType && !IsColorSpaceSRGB(colorSpace)) {
auto sRGB = SkColorSpace::MakeSRGB();
auto xform = SkColorSpaceXform::New(sRGB.get(), colorSpace);
xform->apply(SkColorSpaceXform::kBGRA_8888_ColorFormat, &color,
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp
index 685fcaf..9ae05f4 100644
--- a/core/jni/android/graphics/BitmapFactory.cpp
+++ b/core/jni/android/graphics/BitmapFactory.cpp
@@ -360,7 +360,7 @@
// use the default.
SkImageInfo bitmapInfo = decodeInfo;
if (decodeInfo.colorSpace() && decodeInfo.colorSpace()->isSRGB()) {
- bitmapInfo = bitmapInfo.makeColorSpace(GraphicsJNI::colorSpaceForType(decodeColorType));
+ bitmapInfo = bitmapInfo.makeColorSpace(decodeInfo.refColorSpace());
}
if (decodeColorType == kGray_8_SkColorType) {
diff --git a/core/jni/android/graphics/GraphicBuffer.cpp b/core/jni/android/graphics/GraphicBuffer.cpp
index ae6fd38..344e22c 100644
--- a/core/jni/android/graphics/GraphicBuffer.cpp
+++ b/core/jni/android/graphics/GraphicBuffer.cpp
@@ -196,8 +196,7 @@
SkBitmap bitmap;
bitmap.setInfo(SkImageInfo::Make(buffer->getWidth(), buffer->getHeight(),
convertPixelFormat(buffer->getPixelFormat()),
- kPremul_SkAlphaType,
- GraphicsJNI::defaultColorSpace()),
+ kPremul_SkAlphaType),
bytesCount);
if (buffer->getWidth() > 0 && buffer->getHeight() > 0) {
diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp
index 5d65aee..26af15e 100644
--- a/core/jni/android/graphics/Graphics.cpp
+++ b/core/jni/android/graphics/Graphics.cpp
@@ -454,31 +454,6 @@
return wrapper;
}
-sk_sp<SkColorSpace> GraphicsJNI::defaultColorSpace() {
-#ifdef ANDROID_ENABLE_LINEAR_BLENDING
- return SkColorSpace::MakeSRGB();
-#else
- return nullptr;
-#endif
-}
-
-sk_sp<SkColorSpace> GraphicsJNI::linearColorSpace() {
- return SkColorSpace::MakeSRGBLinear();
-}
-
-sk_sp<SkColorSpace> GraphicsJNI::colorSpaceForType(SkColorType type) {
- switch (type) {
- case kRGBA_F16_SkColorType:
- return linearColorSpace();
- default:
- return defaultColorSpace();
- }
-}
-
-bool GraphicsJNI::isColorSpaceSRGB(SkColorSpace* colorSpace) {
- return colorSpace == nullptr || colorSpace->isSRGB();
-}
-
SkColorSpaceTransferFn GraphicsJNI::getNativeTransferParameters(JNIEnv* env, jobject transferParams) {
SkColorSpaceTransferFn p;
p.fA = (float) env->GetDoubleField(transferParams, gTransferParams_aFieldID);
diff --git a/core/jni/android/graphics/GraphicsJNI.h b/core/jni/android/graphics/GraphicsJNI.h
index 7825f1d..9d85cc2 100644
--- a/core/jni/android/graphics/GraphicsJNI.h
+++ b/core/jni/android/graphics/GraphicsJNI.h
@@ -104,11 +104,6 @@
int srcStride, int x, int y, int width, int height,
const SkBitmap& dstBitmap);
- static sk_sp<SkColorSpace> defaultColorSpace();
- static sk_sp<SkColorSpace> linearColorSpace();
- static sk_sp<SkColorSpace> colorSpaceForType(SkColorType type);
- static bool isColorSpaceSRGB(SkColorSpace* colorSpace);
-
static SkColorSpaceTransferFn getNativeTransferParameters(JNIEnv* env, jobject transferParams);
static SkMatrix44 getNativeXYZMatrix(JNIEnv* env, jfloatArray xyzD50);
static sk_sp<SkColorSpace> getNativeColorSpace(JNIEnv* env, jobject colorSpace);
diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp
index f70cf07..f512ce4 100644
--- a/core/jni/android_view_Surface.cpp
+++ b/core/jni/android_view_Surface.cpp
@@ -332,8 +332,7 @@
SkImageInfo info = SkImageInfo::Make(outBuffer.width, outBuffer.height,
convertPixelFormat(outBuffer.format),
outBuffer.format == PIXEL_FORMAT_RGBX_8888
- ? kOpaque_SkAlphaType : kPremul_SkAlphaType,
- GraphicsJNI::defaultColorSpace());
+ ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
SkBitmap bitmap;
ssize_t bpr = outBuffer.stride * bytesPerPixel(outBuffer.format);
diff --git a/core/jni/android_view_TextureView.cpp b/core/jni/android_view_TextureView.cpp
index 2921b37..15319ad 100644
--- a/core/jni/android_view_TextureView.cpp
+++ b/core/jni/android_view_TextureView.cpp
@@ -94,8 +94,7 @@
default:
break;
}
- return SkImageInfo::Make(buffer.width, buffer.height, colorType, alphaType,
- GraphicsJNI::defaultColorSpace());
+ return SkImageInfo::Make(buffer.width, buffer.height, colorType, alphaType);
}
/**
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp
index 7380692..19691e2 100644
--- a/core/jni/com_android_internal_os_Zygote.cpp
+++ b/core/jni/com_android_internal_os_Zygote.cpp
@@ -386,7 +386,7 @@
// Create /mnt/user/0/package/<package-name>
userid_t user_id = multiuser_get_user_id(uid);
StringAppendF(&pkg_sandbox_dir, "/%d", user_id);
- if (fs_prepare_dir(pkg_sandbox_dir.c_str(), 0700, AID_ROOT, AID_ROOT) != 0) {
+ if (fs_prepare_dir(pkg_sandbox_dir.c_str(), 0751, AID_ROOT, AID_ROOT) != 0) {
*error_msg = CREATE_ERROR("fs_prepare_dir failed on %s", pkg_sandbox_dir.c_str());
return false;
}
diff --git a/core/res/res/anim/keyguard_occlude_open_enter.xml b/core/res/res/anim/keyguard_occlude_open_enter.xml
new file mode 100644
index 0000000..e742616
--- /dev/null
+++ b/core/res/res/anim/keyguard_occlude_open_enter.xml
@@ -0,0 +1,30 @@
+<?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
+ -->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shareInterpolator="false">
+ <translate
+ android:fromYDelta="90%"
+ android:toYDelta="0%"
+ android:interpolator="@interpolator/fast_out_slow_in"
+ android:duration="400"/>
+ <alpha
+ android:fromAlpha="0.0"
+ android:toAlpha="1.0"
+ android:interpolator="@interpolator/fast_out_slow_in"
+ android:duration="300"/>
+</set>
diff --git a/core/res/res/values-mcc214/config.xml b/core/res/res/values-mcc214/config.xml
new file mode 100644
index 0000000..9410848
--- /dev/null
+++ b/core/res/res/values-mcc214/config.xml
@@ -0,0 +1,28 @@
+<?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 my 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.
+*/
+-->
+
+<!-- These resources are around just to allow their values to be customized
+ for different hardware and product builds. -->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- String array containing numbers that shouldn't be logged
+ 016 present here for Spain's gender violence number -->
+ <string-array translatable="false" name="unloggable_phone_numbers">
+ <item>016</item>
+ </string-array>
+</resources>
diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml
index 4c96c1b..74663c9 100644
--- a/core/res/res/values/attrs_manifest.xml
+++ b/core/res/res/values/attrs_manifest.xml
@@ -1358,7 +1358,10 @@
<!-- Specifies the target sandbox this app wants to use. Higher sandbox versions
will have increasing levels of security.
- <p>The default value of this attribute is <code>1</code>. -->
+ <p>The default value of this attribute is <code>1</code>.
+ <p>
+ @deprecated The security properties have been moved to
+ {@link android.os.Build.VERSION Build.VERSION} 27 and 28. -->
<attr name="targetSandboxVersion" format="integer" />
<!-- The user-visible SDK version (ex. 26) of the framework against which the application was
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 474c62d..fddb904 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -2729,6 +2729,9 @@
empty string is passed in -->
<string name="config_ims_package"/>
+ <!-- String array containing numbers that shouldn't be logged. Country-specific. -->
+ <string-array name="unloggable_phone_numbers" />
+
<!-- Flag specifying whether or not IMS will use the dynamic ImsResolver -->
<bool name="config_dynamic_bind_ims">false</bool>
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 50a6ff3..e1db71f 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -506,13 +506,13 @@
<item name="textEditSuggestionHighlightStyle">?attr/textEditSuggestionHighlightStyle</item>
<item name="textCursorDrawable">?attr/textCursorDrawable</item>
<item name="breakStrategy">high_quality</item>
- <item name="hyphenationFrequency">normal</item>
+ <item name="hyphenationFrequency">none</item>
</style>
<style name="Widget.CheckedTextView">
<item name="textAlignment">viewStart</item>
<item name="breakStrategy">high_quality</item>
- <item name="hyphenationFrequency">normal</item>
+ <item name="hyphenationFrequency">none</item>
</style>
<style name="Widget.TextView.ListSeparator">
@@ -540,7 +540,7 @@
<item name="textColor">?attr/editTextColor</item>
<item name="gravity">center_vertical</item>
<item name="breakStrategy">simple</item>
- <item name="hyphenationFrequency">normal</item>
+ <item name="hyphenationFrequency">none</item>
<item name="defaultFocusHighlightEnabled">false</item>
</style>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index e47ea71..140bb7d8 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2156,6 +2156,7 @@
<java-symbol type="anim" name="push_down_out" />
<java-symbol type="anim" name="push_up_in" />
<java-symbol type="anim" name="push_up_out" />
+ <java-symbol type="anim" name="keyguard_occlude_open_enter" />
<java-symbol type="anim" name="lock_screen_behind_enter" />
<java-symbol type="anim" name="lock_screen_behind_enter_wallpaper" />
<java-symbol type="anim" name="lock_screen_behind_enter_fade_in" />
@@ -2235,6 +2236,7 @@
<java-symbol type="drawable" name="decor_maximize_button_light" />
<java-symbol type="color" name="decor_button_dark_color" />
<java-symbol type="color" name="decor_button_light_color" />
+ <java-symbol type="array" name="unloggable_phone_numbers" />
<!-- From TelephonyProvider -->
<java-symbol type="xml" name="apns" />
diff --git a/core/tests/benchmarks/src/android/content/res/ResourcesBenchmark.java b/core/tests/benchmarks/src/android/content/res/ResourcesBenchmark.java
deleted file mode 100644
index 426b0dc..0000000
--- a/core/tests/benchmarks/src/android/content/res/ResourcesBenchmark.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2015 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.content.res;
-
-import android.util.AttributeSet;
-import android.util.Xml;
-
-import com.android.internal.R;
-
-import org.xmlpull.v1.XmlPullParser;
-
-import com.google.caliper.AfterExperiment;
-import com.google.caliper.BeforeExperiment;
-
-public class ResourcesBenchmark {
-
- private AssetManager mAsset;
- private Resources mRes;
-
- private int mTextId;
- private int mColorId;
- private int mIntegerId;
- private int mLayoutId;
-
- @BeforeExperiment
- protected void setUp() {
- mAsset = new AssetManager();
- mAsset.addAssetPath("/system/framework/framework-res.apk");
- mRes = new Resources(mAsset, null, null);
-
- mTextId = mRes.getIdentifier("cancel", "string", "android");
- mColorId = mRes.getIdentifier("transparent", "color", "android");
- mIntegerId = mRes.getIdentifier("config_shortAnimTime", "integer", "android");
- mLayoutId = mRes.getIdentifier("two_line_list_item", "layout", "android");
- }
-
- @AfterExperiment
- protected void tearDown() {
- mAsset.close();
- }
-
- public void timeGetString(int reps) {
- for (int i = 0; i < reps; i++) {
- mRes.getText(mTextId);
- }
- }
-
- public void timeGetColor(int reps) {
- for (int i = 0; i < reps; i++) {
- mRes.getColor(mColorId, null);
- }
- }
-
- public void timeGetInteger(int reps) {
- for (int i = 0; i < reps; i++) {
- mRes.getInteger(mIntegerId);
- }
- }
-
- public void timeGetLayoutAndTraverse(int reps) throws Exception {
- for (int i = 0; i < reps; i++) {
- final XmlResourceParser parser = mRes.getLayout(mLayoutId);
- try {
- while (parser.next() != XmlPullParser.END_DOCUMENT) {
- // Walk the entire tree
- }
- } finally {
- parser.close();
- }
- }
- }
-}
diff --git a/core/tests/coretests/src/com/android/internal/app/IntentForwarderActivityTest.java b/core/tests/coretests/src/com/android/internal/app/IntentForwarderActivityTest.java
index b18fa74..c165b6b 100644
--- a/core/tests/coretests/src/com/android/internal/app/IntentForwarderActivityTest.java
+++ b/core/tests/coretests/src/com/android/internal/app/IntentForwarderActivityTest.java
@@ -16,33 +16,6 @@
package com.android.internal.app;
-import android.annotation.Nullable;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.IPackageManager;
-import android.content.pm.PackageManager;
-import android.content.pm.UserInfo;
-import android.os.Bundle;
-import android.os.UserHandle;
-import android.os.UserManager;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
-import android.util.Log;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-
-import java.util.ArrayList;
-import java.util.List;
-
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
@@ -51,11 +24,42 @@
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.annotation.Nullable;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.IPackageManager;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.content.pm.UserInfo;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
@RunWith(AndroidJUnit4.class)
public class IntentForwarderActivityTest {
+
private static final ComponentName FORWARD_TO_MANAGED_PROFILE_COMPONENT_NAME =
new ComponentName(
"android",
@@ -77,22 +81,26 @@
private static IntentForwarderActivity.Injector sInjector;
private static ComponentName sComponentName;
+ private static String sActivityName;
+ private static String sPackageName;
@Mock private IPackageManager mIPm;
@Mock private PackageManager mPm;
@Mock private UserManager mUserManager;
+ @Mock private ApplicationInfo mApplicationInfo;
@Rule
public ActivityTestRule<IntentForwarderWrapperActivity> mActivityRule =
new ActivityTestRule<>(IntentForwarderWrapperActivity.class, true, false);
private Context mContext;
+ public static final String PHONE_NUMBER = "123-456-789";
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mContext = InstrumentationRegistry.getTargetContext();
- sInjector = new TestInjector();
+ sInjector = spy(new TestInjector());
}
@Test
@@ -252,6 +260,149 @@
assertEquals(MANAGED_PROFILE_INFO.id, activity.mUserIdActivityLaunchedIn);
}
+ @Test
+ public void shouldSkipDisclosure_notWhitelisted() throws RemoteException {
+ setupShouldSkipDisclosureTest();
+ Intent intent = new Intent(mContext, IntentForwarderWrapperActivity.class)
+ .setAction(Intent.ACTION_SEND)
+ .setType(TYPE_PLAIN_TEXT);
+
+ mActivityRule.launchActivity(intent);
+
+ verify(mIPm).canForwardTo(any(), any(), anyInt(), anyInt());
+ verify(sInjector).showToast(anyInt(), anyInt());
+ }
+
+ @Test
+ public void shouldSkipDisclosure_withResolverActivity() throws RemoteException {
+ setupShouldSkipDisclosureTest();
+ sActivityName = ResolverActivity.class.getName();
+ sPackageName = "android";
+ Intent intent = new Intent(mContext, IntentForwarderWrapperActivity.class)
+ .setAction(Intent.ACTION_SEND)
+ .setType(TYPE_PLAIN_TEXT);
+
+ mActivityRule.launchActivity(intent);
+
+ verify(mIPm).canForwardTo(any(), any(), anyInt(), anyInt());
+ verify(sInjector, never()).showToast(anyInt(), anyInt());
+ }
+
+ @Test
+ public void shouldSkipDisclosure_callIntent_call() throws RemoteException {
+ setupShouldSkipDisclosureTest();
+ Intent intent = new Intent(mContext, IntentForwarderWrapperActivity.class)
+ .setAction(Intent.ACTION_CALL);
+
+ mActivityRule.launchActivity(intent);
+
+ verify(mIPm).canForwardTo(any(), any(), anyInt(), anyInt());
+ verify(sInjector, never()).showToast(anyInt(), anyInt());
+ }
+
+ @Test
+ public void shouldSkipDisclosure_callIntent_dial() throws RemoteException {
+ setupShouldSkipDisclosureTest();
+ Intent intent = new Intent(mContext, IntentForwarderWrapperActivity.class)
+ .setAction(Intent.ACTION_DIAL);
+
+ mActivityRule.launchActivity(intent);
+
+ verify(mIPm).canForwardTo(any(), any(), anyInt(), anyInt());
+ verify(sInjector, never()).showToast(anyInt(), anyInt());
+ }
+
+ @Test
+ public void shouldSkipDisclosure_callIntent_notCallOrDial() throws RemoteException {
+ setupShouldSkipDisclosureTest();
+ Intent intent = new Intent(mContext, IntentForwarderWrapperActivity.class)
+ .setAction(Intent.ACTION_ALARM_CHANGED);
+
+ mActivityRule.launchActivity(intent);
+
+ verify(mIPm).canForwardTo(any(), any(), anyInt(), anyInt());
+ verify(sInjector).showToast(anyInt(), anyInt());
+ }
+
+ @Test
+ public void shouldSkipDisclosure_textMessageIntent_sms() throws RemoteException {
+ setupShouldSkipDisclosureTest();
+ Intent intent = new Intent(mContext, IntentForwarderWrapperActivity.class)
+ .setAction(Intent.ACTION_SENDTO)
+ .setData(Uri.fromParts("sms", PHONE_NUMBER, null));
+
+ mActivityRule.launchActivity(intent);
+
+ verify(mIPm).canForwardTo(any(), any(), anyInt(), anyInt());
+ verify(sInjector, never()).showToast(anyInt(), anyInt());
+ }
+
+ @Test
+ public void shouldSkipDisclosure_textMessageIntent_smsto() throws RemoteException {
+ setupShouldSkipDisclosureTest();
+ Intent intent = new Intent(mContext, IntentForwarderWrapperActivity.class)
+ .setAction(Intent.ACTION_SENDTO)
+ .setData(Uri.fromParts("smsto", PHONE_NUMBER, null));
+
+ mActivityRule.launchActivity(intent);
+
+ verify(mIPm).canForwardTo(any(), any(), anyInt(), anyInt());
+ verify(sInjector, never()).showToast(anyInt(), anyInt());
+ }
+
+ @Test
+ public void shouldSkipDisclosure_textMessageIntent_mms() throws RemoteException {
+ setupShouldSkipDisclosureTest();
+ Intent intent = new Intent(mContext, IntentForwarderWrapperActivity.class)
+ .setAction(Intent.ACTION_SENDTO)
+ .setData(Uri.fromParts("mms", PHONE_NUMBER, null));
+
+ mActivityRule.launchActivity(intent);
+
+ verify(mIPm).canForwardTo(any(), any(), anyInt(), anyInt());
+ verify(sInjector, never()).showToast(anyInt(), anyInt());
+ }
+
+ @Test
+ public void shouldSkipDisclosure_textMessageIntent_mmsto() throws RemoteException {
+ setupShouldSkipDisclosureTest();
+ Intent intent = new Intent(mContext, IntentForwarderWrapperActivity.class)
+ .setAction(Intent.ACTION_SENDTO)
+ .setData(Uri.fromParts("mmsto", PHONE_NUMBER, null));
+
+ mActivityRule.launchActivity(intent);
+
+ verify(mIPm).canForwardTo(any(), any(), anyInt(), anyInt());
+ verify(sInjector, never()).showToast(anyInt(), anyInt());
+ }
+
+ @Test
+ public void shouldSkipDisclosure_textMessageIntent_invalidUri() throws RemoteException {
+ setupShouldSkipDisclosureTest();
+ Intent intent = new Intent(mContext, IntentForwarderWrapperActivity.class)
+ .setAction(Intent.ACTION_SENDTO)
+ .setData(Uri.fromParts("invalid", PHONE_NUMBER, null));
+
+ mActivityRule.launchActivity(intent);
+
+ verify(mIPm).canForwardTo(any(), any(), anyInt(), anyInt());
+ verify(sInjector).showToast(anyInt(), anyInt());
+ }
+
+ private void setupShouldSkipDisclosureTest() throws RemoteException {
+ sComponentName = FORWARD_TO_MANAGED_PROFILE_COMPONENT_NAME;
+ sActivityName = "MyTestActivity";
+ sPackageName = "test.package.name";
+ when(mApplicationInfo.isSystemApp()).thenReturn(true);
+ // Managed profile exists.
+ List<UserInfo> profiles = new ArrayList<>();
+ profiles.add(CURRENT_USER_INFO);
+ profiles.add(MANAGED_PROFILE_INFO);
+ when(mUserManager.getProfiles(anyInt())).thenReturn(profiles);
+ // Intent can be forwarded.
+ when(mIPm.canForwardTo(
+ any(Intent.class), nullable(String.class), anyInt(), anyInt())).thenReturn(true);
+ }
public static class IntentForwarderWrapperActivity extends IntentForwarderActivity {
private Intent mStartActivityIntent;
@@ -276,7 +427,7 @@
}
}
- class TestInjector implements IntentForwarderActivity.Injector {
+ public class TestInjector implements IntentForwarderActivity.Injector {
@Override
public IPackageManager getIPackageManager() {
@@ -292,5 +443,21 @@
public PackageManager getPackageManager() {
return mPm;
}
+
+ @Override
+ public ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId) {
+ ActivityInfo activityInfo = new ActivityInfo();
+ activityInfo.packageName = sPackageName;
+ activityInfo.name = sActivityName;
+ activityInfo.applicationInfo = mApplicationInfo;
+
+ ResolveInfo resolveInfo = new ResolveInfo();
+ resolveInfo.activityInfo = activityInfo;
+
+ return resolveInfo;
+ }
+
+ @Override
+ public void showToast(int messageId, int duration) {}
}
}
\ No newline at end of file
diff --git a/core/tests/coretests/src/com/android/internal/os/BinderCallsStatsTest.java b/core/tests/coretests/src/com/android/internal/os/BinderCallsStatsTest.java
index 2f83190..ace6b2d 100644
--- a/core/tests/coretests/src/com/android/internal/os/BinderCallsStatsTest.java
+++ b/core/tests/coretests/src/com/android/internal/os/BinderCallsStatsTest.java
@@ -16,7 +16,8 @@
package com.android.internal.os;
-import android.content.Context;
+import static org.junit.Assert.assertEquals;
+
import android.content.Intent;
import android.os.BatteryManager;
import android.os.Binder;
@@ -33,17 +34,15 @@
import org.junit.Test;
import org.junit.runner.RunWith;
+
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.Random;
-import static org.junit.Assert.assertEquals;
-
@SmallTest
@RunWith(AndroidJUnit4.class)
@Presubmit
@@ -91,7 +90,7 @@
assertEquals(1, uidEntry.recordedCallCount);
// Still sampled even for another API.
callStatsList = new ArrayList(uidEntry.getCallStatsList());
- assertEquals(2, callStatsList.size());
+ assertEquals(1, callStatsList.size());
}
@Test
@@ -222,20 +221,13 @@
assertEquals(10, uidEntry.cpuTimeMicros);
List<BinderCallsStats.CallStat> callStatsList = new ArrayList(uidEntry.getCallStatsList());
- assertEquals(2, callStatsList.size());
+ assertEquals(1, callStatsList.size());
BinderCallsStats.CallStat callStats = callStatsList.get(0);
assertEquals(1, callStats.callCount);
assertEquals(1, callStats.recordedCallCount);
assertEquals(10, callStats.cpuTimeMicros);
assertEquals(10, callStats.maxCpuTimeMicros);
-
- // Only call count should is tracked, rest is sampled.
- callStats = callStatsList.get(1);
- assertEquals(1, callStats.callCount);
- assertEquals(0, callStats.recordedCallCount);
- assertEquals(0, callStats.cpuTimeMicros);
- assertEquals(0, callStats.maxCpuTimeMicros);
}
private static class BinderWithGetTransactionName extends Binder {
@@ -587,6 +579,7 @@
};
}
});
+ setSamplingInterval(1);
}
@Override
diff --git a/data/keyboards/Vendor_054c_Product_0268.kl b/data/keyboards/Vendor_054c_Product_0268.kl
index 7c60137..522db3c 100644
--- a/data/keyboards/Vendor_054c_Product_0268.kl
+++ b/data/keyboards/Vendor_054c_Product_0268.kl
@@ -35,7 +35,7 @@
key 0x122 BUTTON_THUMBR
# PS key
-key 0x2d0 HOME
+key 0x2d0 BUTTON_MODE
# Left Analog Stick
axis 0x00 X
diff --git a/graphics/java/android/graphics/drawable/VectorDrawable.java b/graphics/java/android/graphics/drawable/VectorDrawable.java
index 040601c..7325b85 100644
--- a/graphics/java/android/graphics/drawable/VectorDrawable.java
+++ b/graphics/java/android/graphics/drawable/VectorDrawable.java
@@ -2033,7 +2033,7 @@
if (fillColors instanceof GradientColor) {
mFillColors = fillColors;
fillGradient = ((GradientColor) fillColors).getShader();
- } else if (fillColors.isStateful()) {
+ } else if (fillColors.isStateful() || fillColors.canApplyTheme()) {
mFillColors = fillColors;
} else {
mFillColors = null;
@@ -2049,7 +2049,7 @@
if (strokeColors instanceof GradientColor) {
mStrokeColors = strokeColors;
strokeGradient = ((GradientColor) strokeColors).getShader();
- } else if (strokeColors.isStateful()) {
+ } else if (strokeColors.isStateful() || strokeColors.canApplyTheme()) {
mStrokeColors = strokeColors;
} else {
mStrokeColors = null;
diff --git a/libs/hwui/Android.bp b/libs/hwui/Android.bp
index 8d0b615..83e90b6 100644
--- a/libs/hwui/Android.bp
+++ b/libs/hwui/Android.bp
@@ -72,7 +72,6 @@
"libft2",
"libminikin",
"libandroidfw",
- "libRScpp",
],
static_libs: [
"libEGL_blobCache",
@@ -242,7 +241,6 @@
},
export_include_dirs: ["."],
- export_shared_lib_headers: ["libRScpp"],
}
cc_library {
diff --git a/packages/CarSystemUI/res/layout/car_top_navigation_bar.xml b/packages/CarSystemUI/res/layout/car_top_navigation_bar.xml
index 55d50a0..7b3333e 100644
--- a/packages/CarSystemUI/res/layout/car_top_navigation_bar.xml
+++ b/packages/CarSystemUI/res/layout/car_top_navigation_bar.xml
@@ -54,7 +54,7 @@
android:gravity="center_vertical|start"
android:minEms="4"
android:textAppearance="@style/TextAppearance.Car.Status"
- systemui:hvacAreaId="1"
+ systemui:hvacAreaId="49"
systemui:hvacMaxText="@string/hvac_max_text"
systemui:hvacMaxValue="@dimen/hvac_max_value"
systemui:hvacMinText="@string/hvac_min_text"
@@ -136,7 +136,7 @@
android:gravity="center_vertical|end"
android:minEms="4"
android:textAppearance="@style/TextAppearance.Car.Status"
- systemui:hvacAreaId="4"
+ systemui:hvacAreaId="68"
systemui:hvacMaxText="@string/hvac_max_text"
systemui:hvacMaxValue="@dimen/hvac_max_value"
systemui:hvacMinText="@string/hvac_min_text"
diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml
index 04f2411..6bc07c2 100644
--- a/packages/SettingsLib/res/values/strings.xml
+++ b/packages/SettingsLib/res/values/strings.xml
@@ -1117,6 +1117,8 @@
<string name="zen_mode_duration_settings_title">Duration</string>
<!-- Do not disturb: Duration option to always prompt for the duration of dnd -->
<string name="zen_mode_duration_always_prompt_title">Ask every time</string>
+ <!-- Do not disturb: Duration option to always have DND on until it is manually turned off [CHAR LIMIT=60] -->
+ <string name="zen_mode_forever">Until you turn off</string>
<!-- time label for event have that happened very recently [CHAR LIMIT=60] -->
<string name="time_unit_just_now">Just now</string>
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java
index 01efda5..1ce4484 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java
@@ -71,7 +71,7 @@
// we may add a new device here, but generally this should not happen
if (device == null) {
Log.w(TAG, "A2dpProfile found new device: " + nextDevice);
- device = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, nextDevice);
+ device = mDeviceManager.addDevice(mLocalAdapter, nextDevice);
}
device.onProfileStateChanged(A2dpProfile.this, BluetoothProfile.STATE_CONNECTED);
device.refresh();
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java
index 2cf1d58..6a4aa0a 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java
@@ -67,7 +67,7 @@
// we may add a new device here, but generally this should not happen
if (device == null) {
Log.w(TAG, "A2dpSinkProfile found new device: " + nextDevice);
- device = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, nextDevice);
+ device = mDeviceManager.addDevice(mLocalAdapter, nextDevice);
}
device.onProfileStateChanged(A2dpSinkProfile.this, BluetoothProfile.STATE_CONNECTED);
device.refresh();
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java
index 6ab221e..a3f3b59 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java
@@ -55,7 +55,6 @@
private final BroadcastReceiver mProfileBroadcastReceiver = new BluetoothBroadcastReceiver();
private final Collection<BluetoothCallback> mCallbacks = new ArrayList<>();
- private LocalBluetoothProfileManager mProfileManager;
private android.os.Handler mReceiverHandler;
private Context mContext;
@@ -141,11 +140,6 @@
mProfileIntentFilter.addAction(action);
}
- // Set profile manager after construction due to circular dependency
- void setProfileManager(LocalBluetoothProfileManager manager) {
- mProfileManager = manager;
- }
-
boolean readPairedDevices() {
Set<BluetoothDevice> bondedDevices = mLocalAdapter.getBondedDevices();
if (bondedDevices == null) {
@@ -156,7 +150,7 @@
for (BluetoothDevice device : bondedDevices) {
CachedBluetoothDevice cachedDevice = mDeviceManager.findDevice(device);
if (cachedDevice == null) {
- cachedDevice = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, device);
+ cachedDevice = mDeviceManager.addDevice(mLocalAdapter, device);
dispatchDeviceAdded(cachedDevice);
deviceAdded = true;
}
@@ -288,7 +282,7 @@
// Skip for now, there's a bluez problem and we are not getting uuids even for 2.1.
CachedBluetoothDevice cachedDevice = mDeviceManager.findDevice(device);
if (cachedDevice == null) {
- cachedDevice = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, device);
+ cachedDevice = mDeviceManager.addDevice(mLocalAdapter, device);
Log.d(TAG, "DeviceFoundHandler created new CachedBluetoothDevice: "
+ cachedDevice);
}
@@ -355,7 +349,7 @@
Log.w(TAG, "Got bonding state changed for " + device +
", but we have no record of that device.");
- cachedDevice = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, device);
+ cachedDevice = mDeviceManager.addDevice(mLocalAdapter, device);
dispatchDeviceAdded(cachedDevice);
}
}
@@ -472,4 +466,4 @@
dispatchAudioModeChanged();
}
}
-}
\ No newline at end of file
+}
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java
index 4104e2f..475ece8 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java
@@ -107,9 +107,8 @@
* @param device the address of the new Bluetooth device
* @return the newly created CachedBluetoothDevice object
*/
- public CachedBluetoothDevice addDevice(LocalBluetoothAdapter adapter,
- LocalBluetoothProfileManager profileManager,
- BluetoothDevice device) {
+ public CachedBluetoothDevice addDevice(LocalBluetoothAdapter adapter, BluetoothDevice device) {
+ LocalBluetoothProfileManager profileManager = mBtManager.getProfileManager();
CachedBluetoothDevice newDevice = new CachedBluetoothDevice(mContext, adapter,
profileManager, device);
if (profileManager.getHearingAidProfile() != null
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HeadsetProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HeadsetProfile.java
index 6a4d978..e284382 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HeadsetProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HeadsetProfile.java
@@ -70,7 +70,7 @@
// we may add a new device here, but generally this should not happen
if (device == null) {
Log.w(TAG, "HeadsetProfile found new device: " + nextDevice);
- device = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, nextDevice);
+ device = mDeviceManager.addDevice(mLocalAdapter, nextDevice);
}
device.onProfileStateChanged(HeadsetProfile.this,
BluetoothProfile.STATE_CONNECTED);
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java
index 1747d28..a0cf105 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java
@@ -64,7 +64,7 @@
if (V) {
Log.d(TAG, "HearingAidProfile found new device: " + nextDevice);
}
- device = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, nextDevice);
+ device = mDeviceManager.addDevice(mLocalAdapter, nextDevice);
}
device.onProfileStateChanged(HearingAidProfile.this,
BluetoothProfile.STATE_CONNECTED);
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java
index 94c84b9..b8c72fb 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java
@@ -71,7 +71,7 @@
// we may add a new device here, but generally this should not happen
if (device == null) {
Log.w(TAG, "HfpClient profile found new device: " + nextDevice);
- device = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, nextDevice);
+ device = mDeviceManager.addDevice(mLocalAdapter, nextDevice);
}
device.onProfileStateChanged(
HfpClientProfile.this, BluetoothProfile.STATE_CONNECTED);
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidDeviceProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidDeviceProfile.java
index 179a60d..f9da109 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidDeviceProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidDeviceProfile.java
@@ -73,7 +73,7 @@
// we may add a new device here, but generally this should not happen
if (device == null) {
Log.w(TAG, "HidProfile found new device: " + nextDevice);
- device = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, nextDevice);
+ device = mDeviceManager.addDevice(mLocalAdapter, nextDevice);
}
Log.d(TAG, "Connection status changed: " + device);
device.onProfileStateChanged(HidDeviceProfile.this,
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidProfile.java
index da348f9..c5ba58c 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HidProfile.java
@@ -62,7 +62,7 @@
// we may add a new device here, but generally this should not happen
if (device == null) {
Log.w(TAG, "HidProfile found new device: " + nextDevice);
- device = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, nextDevice);
+ device = mDeviceManager.addDevice(mLocalAdapter, nextDevice);
}
device.onProfileStateChanged(HidProfile.this, BluetoothProfile.STATE_CONNECTED);
device.refresh();
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java
index f91dbcf..3ebbf7e 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java
@@ -37,6 +37,8 @@
import androidx.annotation.VisibleForTesting;
import android.util.Log;
import com.android.internal.R;
+import com.android.internal.util.CollectionUtils;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -87,12 +89,12 @@
private HfpClientProfile mHfpClientProfile;
private MapProfile mMapProfile;
private MapClientProfile mMapClientProfile;
- private final HidProfile mHidProfile;
+ private HidProfile mHidProfile;
private HidDeviceProfile mHidDeviceProfile;
private OppProfile mOppProfile;
- private final PanProfile mPanProfile;
+ private PanProfile mPanProfile;
private PbapClientProfile mPbapClientProfile;
- private final PbapServerProfile mPbapProfile;
+ private PbapServerProfile mPbapProfile;
private final boolean mUsePbapPce;
private final boolean mUseMapClient;
private HearingAidProfile mHearingAidProfile;
@@ -117,179 +119,107 @@
mUseMapClient = mContext.getResources().getBoolean(R.bool.enable_pbap_pce_profile);
// pass this reference to adapter and event manager (circular dependency)
mLocalAdapter.setProfileManager(this);
- mEventManager.setProfileManager(this);
- ParcelUuid[] uuids = adapter.getUuids();
-
- // uuids may be null if Bluetooth is turned off
- if (uuids != null) {
- updateLocalProfiles(uuids);
- }
-
- // Always add HID host, HID device, and PAN profiles
- mHidProfile = new HidProfile(context, mLocalAdapter, mDeviceManager, this);
- addProfile(mHidProfile, HidProfile.NAME,
- BluetoothHidHost.ACTION_CONNECTION_STATE_CHANGED);
-
- mPanProfile = new PanProfile(context, mLocalAdapter);
- addPanProfile(mPanProfile, PanProfile.NAME,
- BluetoothPan.ACTION_CONNECTION_STATE_CHANGED);
-
- mHidDeviceProfile = new HidDeviceProfile(context, mLocalAdapter, mDeviceManager, this);
- addProfile(mHidDeviceProfile, HidDeviceProfile.NAME,
- BluetoothHidDevice.ACTION_CONNECTION_STATE_CHANGED);
-
- if(DEBUG) Log.d(TAG, "Adding local MAP profile");
- if (mUseMapClient) {
- mMapClientProfile = new MapClientProfile(mContext, mLocalAdapter, mDeviceManager, this);
- addProfile(mMapClientProfile, MapClientProfile.NAME,
- BluetoothMapClient.ACTION_CONNECTION_STATE_CHANGED);
- } else {
- mMapProfile = new MapProfile(mContext, mLocalAdapter, mDeviceManager, this);
- addProfile(mMapProfile, MapProfile.NAME,
- BluetoothMap.ACTION_CONNECTION_STATE_CHANGED);
- }
-
- //Create PBAP server profile
- if(DEBUG) Log.d(TAG, "Adding local PBAP profile");
-
- mPbapProfile = new PbapServerProfile(context);
- addProfile(mPbapProfile, PbapServerProfile.NAME,
- BluetoothPbap.ACTION_CONNECTION_STATE_CHANGED);
-
- List<Integer> supportedList = mLocalAdapter.getSupportedProfiles();
- if (supportedList.contains(BluetoothProfile.HEARING_AID)) {
- mHearingAidProfile = new HearingAidProfile(mContext, mLocalAdapter, mDeviceManager,
- this);
- addProfile(mHearingAidProfile, HearingAidProfile.NAME,
- BluetoothHearingAid.ACTION_CONNECTION_STATE_CHANGED);
- }
+ updateLocalProfiles();
if (DEBUG) Log.d(TAG, "LocalBluetoothProfileManager construction complete");
}
/**
- * Initialize or update the local profile objects. If a UUID was previously
- * present but has been removed, we print a warning but don't remove the
- * profile object as it might be referenced elsewhere, or the UUID might
- * come back and we don't want multiple copies of the profile objects.
- * @param uuids
+ * create profile instance according to bluetooth supported profile list
*/
- void updateLocalProfiles(ParcelUuid[] uuids) {
- // A2DP SRC
- if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.AudioSource)) {
- if (mA2dpProfile == null) {
- if(DEBUG) Log.d(TAG, "Adding local A2DP SRC profile");
- mA2dpProfile = new A2dpProfile(mContext, mLocalAdapter, mDeviceManager, this);
- addProfile(mA2dpProfile, A2dpProfile.NAME,
- BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED);
- }
- } else if (mA2dpProfile != null) {
- Log.w(TAG, "Warning: A2DP profile was previously added but the UUID is now missing.");
+ void updateLocalProfiles() {
+ List<Integer> supportedList = mLocalAdapter.getSupportedProfiles();
+ if (CollectionUtils.isEmpty(supportedList)) {
+ if(DEBUG) Log.d(TAG, "supportedList is null");
+ return;
}
-
- // A2DP SINK
- if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.AudioSink)) {
- if (mA2dpSinkProfile == null) {
- if(DEBUG) Log.d(TAG, "Adding local A2DP Sink profile");
- mA2dpSinkProfile = new A2dpSinkProfile(mContext, mLocalAdapter, mDeviceManager, this);
- addProfile(mA2dpSinkProfile, A2dpSinkProfile.NAME,
- BluetoothA2dpSink.ACTION_CONNECTION_STATE_CHANGED);
- }
- } else if (mA2dpSinkProfile != null) {
- Log.w(TAG, "Warning: A2DP Sink profile was previously added but the UUID is now missing.");
+ if (mA2dpProfile == null && supportedList.contains(BluetoothProfile.A2DP)) {
+ if(DEBUG) Log.d(TAG, "Adding local A2DP profile");
+ mA2dpProfile = new A2dpProfile(mContext, mLocalAdapter, mDeviceManager, this);
+ addProfile(mA2dpProfile, A2dpProfile.NAME,
+ BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED);
}
-
- // Headset / Handsfree
- if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Handsfree_AG) ||
- BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.HSP_AG)) {
- if (mHeadsetProfile == null) {
- if (DEBUG) Log.d(TAG, "Adding local HEADSET profile");
- mHeadsetProfile = new HeadsetProfile(mContext, mLocalAdapter,
- mDeviceManager, this);
- addHeadsetProfile(mHeadsetProfile, HeadsetProfile.NAME,
- BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED,
- BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED,
- BluetoothHeadset.STATE_AUDIO_DISCONNECTED);
- }
- } else if (mHeadsetProfile != null) {
- Log.w(TAG, "Warning: HEADSET profile was previously added but the UUID is now missing.");
+ if (mA2dpSinkProfile == null && supportedList.contains(BluetoothProfile.A2DP_SINK)) {
+ if(DEBUG) Log.d(TAG, "Adding local A2DP SINK profile");
+ mA2dpSinkProfile = new A2dpSinkProfile(mContext, mLocalAdapter, mDeviceManager, this);
+ addProfile(mA2dpSinkProfile, A2dpSinkProfile.NAME,
+ BluetoothA2dpSink.ACTION_CONNECTION_STATE_CHANGED);
}
-
- // Headset HF
- if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Handsfree)) {
- if (mHfpClientProfile == null) {
- if(DEBUG) Log.d(TAG, "Adding local HfpClient profile");
- mHfpClientProfile =
- new HfpClientProfile(mContext, mLocalAdapter, mDeviceManager, this);
- addHeadsetProfile(mHfpClientProfile, HfpClientProfile.NAME,
- BluetoothHeadsetClient.ACTION_CONNECTION_STATE_CHANGED,
- BluetoothHeadsetClient.ACTION_AUDIO_STATE_CHANGED,
- BluetoothHeadsetClient.STATE_AUDIO_DISCONNECTED);
- }
- } else if (mHfpClientProfile != null) {
- Log.w(TAG,
- "Warning: Hfp Client profile was previously added but the UUID is now missing.");
- } else {
- Log.d(TAG, "Handsfree Uuid not found.");
+ if (mHeadsetProfile == null && supportedList.contains(BluetoothProfile.HEADSET)) {
+ if (DEBUG) Log.d(TAG, "Adding local HEADSET profile");
+ mHeadsetProfile = new HeadsetProfile(mContext, mLocalAdapter, mDeviceManager, this);
+ addHeadsetProfile(mHeadsetProfile, HeadsetProfile.NAME,
+ BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED,
+ BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED,
+ BluetoothHeadset.STATE_AUDIO_DISCONNECTED);
}
-
- // Message Access Profile Client
- if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.MNS)) {
- if (mMapClientProfile == null) {
- if(DEBUG) Log.d(TAG, "Adding local Map Client profile");
+ if (mHfpClientProfile == null && supportedList.contains(BluetoothProfile.HEADSET_CLIENT)) {
+ if(DEBUG) Log.d(TAG, "Adding local HfpClient profile");
+ mHfpClientProfile = new HfpClientProfile(mContext, mLocalAdapter, mDeviceManager, this);
+ addHeadsetProfile(mHfpClientProfile, HfpClientProfile.NAME,
+ BluetoothHeadsetClient.ACTION_CONNECTION_STATE_CHANGED,
+ BluetoothHeadsetClient.ACTION_AUDIO_STATE_CHANGED,
+ BluetoothHeadsetClient.STATE_AUDIO_DISCONNECTED);
+ }
+ if (mUseMapClient) {
+ if (mMapClientProfile == null && supportedList.contains(BluetoothProfile.MAP_CLIENT)) {
+ if(DEBUG) Log.d(TAG, "Adding local MAP CLIENT profile");
mMapClientProfile =
- new MapClientProfile(mContext, mLocalAdapter, mDeviceManager, this);
+ new MapClientProfile(mContext, mLocalAdapter, mDeviceManager,this);
addProfile(mMapClientProfile, MapClientProfile.NAME,
BluetoothMapClient.ACTION_CONNECTION_STATE_CHANGED);
}
- } else if (mMapClientProfile != null) {
- Log.w(TAG,
- "Warning: MAP Client profile was previously added but the UUID is now missing.");
- } else {
- Log.d(TAG, "MAP Client Uuid not found.");
+ } else if (mMapProfile == null && supportedList.contains(BluetoothProfile.MAP)) {
+ if(DEBUG) Log.d(TAG, "Adding local MAP profile");
+ mMapProfile = new MapProfile(mContext, mLocalAdapter, mDeviceManager, this);
+ addProfile(mMapProfile, MapProfile.NAME, BluetoothMap.ACTION_CONNECTION_STATE_CHANGED);
}
-
- // OPP
- if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.ObexObjectPush)) {
- if (mOppProfile == null) {
- if(DEBUG) Log.d(TAG, "Adding local OPP profile");
- mOppProfile = new OppProfile();
- // Note: no event handler for OPP, only name map.
- mProfileNameMap.put(OppProfile.NAME, mOppProfile);
- }
- } else if (mOppProfile != null) {
- Log.w(TAG, "Warning: OPP profile was previously added but the UUID is now missing.");
+ if (mOppProfile == null && supportedList.contains(BluetoothProfile.OPP)) {
+ if(DEBUG) Log.d(TAG, "Adding local OPP profile");
+ mOppProfile = new OppProfile();
+ // Note: no event handler for OPP, only name map.
+ mProfileNameMap.put(OppProfile.NAME, mOppProfile);
}
-
- //PBAP Client
- if (mUsePbapPce) {
- if (mPbapClientProfile == null) {
- if(DEBUG) Log.d(TAG, "Adding local PBAP Client profile");
- mPbapClientProfile = new PbapClientProfile(mContext, mLocalAdapter, mDeviceManager,
- this);
- addProfile(mPbapClientProfile, PbapClientProfile.NAME,
- BluetoothPbapClient.ACTION_CONNECTION_STATE_CHANGED);
- }
- } else if (mPbapClientProfile != null) {
- Log.w(TAG,
- "Warning: PBAP Client profile was previously added but the UUID is now missing.");
+ if (mHearingAidProfile == null && supportedList.contains(BluetoothProfile.HEARING_AID)) {
+ if(DEBUG) Log.d(TAG, "Adding local Hearing Aid profile");
+ mHearingAidProfile = new HearingAidProfile(mContext, mLocalAdapter, mDeviceManager,
+ this);
+ addProfile(mHearingAidProfile, HearingAidProfile.NAME,
+ BluetoothHearingAid.ACTION_CONNECTION_STATE_CHANGED);
}
-
- //Hearing Aid Client
- if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.HearingAid)) {
- if (mHearingAidProfile == null) {
- if(DEBUG) Log.d(TAG, "Adding local Hearing Aid profile");
- mHearingAidProfile = new HearingAidProfile(mContext, mLocalAdapter, mDeviceManager, this);
- addProfile(mHearingAidProfile, HearingAidProfile.NAME,
- BluetoothHearingAid.ACTION_CONNECTION_STATE_CHANGED);
- }
- } else if (mHearingAidProfile != null) {
- Log.w(TAG, "Warning: Hearing Aid profile was previously added but the UUID is now missing.");
+ if (mHidProfile == null && supportedList.contains(BluetoothProfile.HID_HOST)) {
+ if(DEBUG) Log.d(TAG, "Adding local HID_HOST profile");
+ mHidProfile = new HidProfile(mContext, mLocalAdapter, mDeviceManager, this);
+ addProfile(mHidProfile, HidProfile.NAME,
+ BluetoothHidHost.ACTION_CONNECTION_STATE_CHANGED);
}
-
+ if (mHidDeviceProfile == null && supportedList.contains(BluetoothProfile.HID_DEVICE)) {
+ if(DEBUG) Log.d(TAG, "Adding local HID_DEVICE profile");
+ mHidDeviceProfile = new HidDeviceProfile(mContext, mLocalAdapter, mDeviceManager, this);
+ addProfile(mHidDeviceProfile, HidDeviceProfile.NAME,
+ BluetoothHidDevice.ACTION_CONNECTION_STATE_CHANGED);
+ }
+ if (mPanProfile == null && supportedList.contains(BluetoothProfile.PAN)) {
+ if(DEBUG) Log.d(TAG, "Adding local PAN profile");
+ mPanProfile = new PanProfile(mContext, mLocalAdapter);
+ addPanProfile(mPanProfile, PanProfile.NAME,
+ BluetoothPan.ACTION_CONNECTION_STATE_CHANGED);
+ }
+ if (mPbapProfile == null && supportedList.contains(BluetoothProfile.PBAP)) {
+ if(DEBUG) Log.d(TAG, "Adding local PBAP profile");
+ mPbapProfile = new PbapServerProfile(mContext);
+ addProfile(mPbapProfile, PbapServerProfile.NAME,
+ BluetoothPbap.ACTION_CONNECTION_STATE_CHANGED);
+ }
+ if (mUsePbapPce && mPbapClientProfile == null && supportedList.contains(
+ BluetoothProfile.PBAP_CLIENT)) {
+ if(DEBUG) Log.d(TAG, "Adding local PBAP Client profile");
+ mPbapClientProfile = new PbapClientProfile(mContext, mLocalAdapter, mDeviceManager,
+ this);
+ addProfile(mPbapClientProfile, PbapClientProfile.NAME,
+ BluetoothPbapClient.ACTION_CONNECTION_STATE_CHANGED);
+ }
mEventManager.registerProfileIntentReceiver();
-
- // There is no local SDP record for HID and Settings app doesn't control PBAP Server.
}
private void addHeadsetProfile(LocalBluetoothProfile profile, String profileName,
@@ -323,10 +253,7 @@
// Called from LocalBluetoothAdapter when state changes to ON
void setBluetoothStateOn() {
- ParcelUuid[] uuids = mLocalAdapter.getUuids();
- if (uuids != null) {
- updateLocalProfiles(uuids);
- }
+ updateLocalProfiles();
mEventManager.readPairedDevices();
}
@@ -344,8 +271,7 @@
CachedBluetoothDevice cachedDevice = mDeviceManager.findDevice(device);
if (cachedDevice == null) {
Log.w(TAG, "StateChangedHandler found new device: " + device);
- cachedDevice = mDeviceManager.addDevice(mLocalAdapter,
- LocalBluetoothProfileManager.this, device);
+ cachedDevice = mDeviceManager.addDevice(mLocalAdapter, device);
}
onReceiveInternal(intent, cachedDevice);
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapClientProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapClientProfile.java
index 6aa32fc..63af24c 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapClientProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapClientProfile.java
@@ -71,7 +71,7 @@
// we may add a new device here, but generally this should not happen
if (device == null) {
Log.w(TAG, "MapProfile found new device: " + nextDevice);
- device = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, nextDevice);
+ device = mDeviceManager.addDevice(mLocalAdapter, nextDevice);
}
device.onProfileStateChanged(MapClientProfile.this,
BluetoothProfile.STATE_CONNECTED);
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapProfile.java
index c53cacc..2c63d50 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapProfile.java
@@ -70,7 +70,7 @@
// we may add a new device here, but generally this should not happen
if (device == null) {
Log.w(TAG, "MapProfile found new device: " + nextDevice);
- device = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, nextDevice);
+ device = mDeviceManager.addDevice(mLocalAdapter, nextDevice);
}
device.onProfileStateChanged(MapProfile.this,
BluetoothProfile.STATE_CONNECTED);
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapClientProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapClientProfile.java
index b735c23..d34ad30 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapClientProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapClientProfile.java
@@ -69,7 +69,7 @@
// we may add a new device here, but generally this should not happen
if (device == null) {
Log.w(TAG, "PbapClientProfile found new device: " + nextDevice);
- device = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, nextDevice);
+ device = mDeviceManager.addDevice(mLocalAdapter, nextDevice);
}
device.onProfileStateChanged(PbapClientProfile.this, BluetoothProfile.STATE_CONNECTED);
device.refresh();
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/SapProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/SapProfile.java
index 60985f3..f1d73ed 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/SapProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/SapProfile.java
@@ -69,7 +69,7 @@
// we may add a new device here, but generally this should not happen
if (device == null) {
Log.w(TAG, "SapProfile found new device: " + nextDevice);
- device = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, nextDevice);
+ device = mDeviceManager.addDevice(mLocalAdapter, nextDevice);
}
device.onProfileStateChanged(SapProfile.this,
BluetoothProfile.STATE_CONNECTED);
diff --git a/packages/SettingsLib/src/com/android/settingslib/drawer/DashboardCategory.java b/packages/SettingsLib/src/com/android/settingslib/drawer/DashboardCategory.java
index 2e0a94c..4cfaad6 100644
--- a/packages/SettingsLib/src/com/android/settingslib/drawer/DashboardCategory.java
+++ b/packages/SettingsLib/src/com/android/settingslib/drawer/DashboardCategory.java
@@ -31,19 +31,26 @@
/**
* Key used for placing external tiles.
*/
- public String key;
+ public final String key;
/**
* List of the category's children
*/
private List<Tile> mTiles = new ArrayList<>();
- public DashboardCategory() {
- // Empty
+ public DashboardCategory(String key) {
+ this.key = key;
}
DashboardCategory(Parcel in) {
- readFromParcel(in);
+ key = in.readString();
+
+ final int count = in.readInt();
+
+ for (int n = 0; n < count; n++) {
+ Tile tile = Tile.CREATOR.createFromParcel(in);
+ mTiles.add(tile);
+ }
}
/**
@@ -89,8 +96,8 @@
public synchronized void sortTiles(String skipPackageName) {
// Sort mTiles based on [priority, package within priority]
Collections.sort(mTiles, (tile1, tile2) -> {
- final String package1 = tile1.intent.getComponent().getPackageName();
- final String package2 = tile2.intent.getComponent().getPackageName();
+ final String package1 = tile1.getPackageName();
+ final String package2 = tile2.getPackageName();
final int packageCompare = CASE_INSENSITIVE_ORDER.compare(package1, package2);
// First sort by priority
final int priorityCompare = tile2.priority - tile1.priority;
@@ -128,18 +135,6 @@
}
}
- public void readFromParcel(Parcel in) {
- key = in.readString();
-
- final int count = in.readInt();
-
- for (int n = 0; n < count; n++) {
- Tile tile = Tile.CREATOR.createFromParcel(in);
- mTiles.add(tile);
- }
- }
-
-
public static final Creator<DashboardCategory> CREATOR = new Creator<DashboardCategory>() {
public DashboardCategory createFromParcel(Parcel source) {
return new DashboardCategory(source);
diff --git a/packages/SettingsLib/src/com/android/settingslib/drawer/Tile.java b/packages/SettingsLib/src/com/android/settingslib/drawer/Tile.java
index 18f94b7..18936ee 100644
--- a/packages/SettingsLib/src/com/android/settingslib/drawer/Tile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/drawer/Tile.java
@@ -60,50 +60,54 @@
public CharSequence summary;
/**
- * Whether the icon can be tinted. This should be set to true for monochrome (single-color)
- * icons that can be tinted to match the design.
- */
- public boolean isIconTintable;
-
- /**
- * Intent to launch when the preference is selected.
- */
- public Intent intent;
-
- /**
* Optional list of user handles which the intent should be launched on.
*/
public ArrayList<UserHandle> userHandle = new ArrayList<>();
/**
- * Category in which the tile should be placed.
- */
- public String category;
-
- /**
* Priority of the intent filter that created this tile, used for display ordering.
*/
public int priority;
/**
- * The metaData from the activity that defines this tile.
- */
- public Bundle metaData;
-
- /**
* Optional key to use for this tile.
*/
public String key;
-
+ /**
+ * The metaData from the activity that defines this tile.
+ */
+ private final Bundle mMetaData;
private final String mActivityPackage;
private final String mActivityName;
- private ActivityInfo mActivityInfo;
+ private final Intent mIntent;
- public Tile(ActivityInfo activityInfo) {
+ private ActivityInfo mActivityInfo;
+ private String mCategory;
+
+ public Tile(ActivityInfo activityInfo, String category) {
mActivityInfo = activityInfo;
mActivityPackage = mActivityInfo.packageName;
mActivityName = mActivityInfo.name;
+ mMetaData = activityInfo.metaData;
+ mCategory = category;
+ mIntent = new Intent().setClassName(mActivityPackage, mActivityName);
+ }
+
+ Tile(Parcel in) {
+ mActivityPackage = in.readString();
+ mActivityName = in.readString();
+ mIntent = new Intent().setClassName(mActivityPackage, mActivityName);
+ title = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
+ summary = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
+ final int N = in.readInt();
+ for (int i = 0; i < N; i++) {
+ userHandle.add(UserHandle.CREATOR.createFromParcel(in));
+ }
+ mCategory = in.readString();
+ priority = in.readInt();
+ mMetaData = in.readBundle();
+ key = in.readString();
}
@Override
@@ -117,22 +121,48 @@
dest.writeString(mActivityName);
TextUtils.writeToParcel(title, dest, flags);
TextUtils.writeToParcel(summary, dest, flags);
- if (intent != null) {
- dest.writeByte((byte) 1);
- intent.writeToParcel(dest, flags);
- } else {
- dest.writeByte((byte) 0);
- }
final int N = userHandle.size();
dest.writeInt(N);
for (int i = 0; i < N; i++) {
userHandle.get(i).writeToParcel(dest, flags);
}
- dest.writeString(category);
+ dest.writeString(mCategory);
dest.writeInt(priority);
- dest.writeBundle(metaData);
+ dest.writeBundle(mMetaData);
dest.writeString(key);
- dest.writeBoolean(isIconTintable);
+ }
+
+ public String getPackageName() {
+ return mActivityPackage;
+ }
+
+ /**
+ * Intent to launch when the preference is selected.
+ */
+ public Intent getIntent() {
+ return mIntent;
+ }
+
+ /**
+ * Category in which the tile should be placed.
+ */
+ public String getCategory() {
+ return mCategory;
+ }
+
+ public void setCategory(String newCategoryKey) {
+ mCategory = newCategoryKey;
+ }
+
+ /**
+ * Priority of the intent filter that created this tile, used for display ordering.
+ */
+ public int getPriority() {
+ return 0;
+ }
+
+ public Bundle getMetaData() {
+ return mMetaData;
}
/**
@@ -141,17 +171,17 @@
* @attr ref android.R.styleable#PreferenceHeader_icon
*/
public Icon getIcon(Context context) {
- if (context == null || metaData == null) {
+ if (context == null || mMetaData == null) {
return null;
}
- int iconResId = metaData.getInt(META_DATA_PREFERENCE_ICON);
+ int iconResId = mMetaData.getInt(META_DATA_PREFERENCE_ICON);
// Set the icon
if (iconResId == 0) {
// Only fallback to activityinfo.icon if metadata does not contain ICON_URI.
// ICON_URI should be loaded in app UI when need the icon object. Handling IPC at this
// level is too complex because we don't have a strong threading contract for this class
- if (!metaData.containsKey(META_DATA_PREFERENCE_ICON_URI)) {
+ if (!mMetaData.containsKey(META_DATA_PREFERENCE_ICON_URI)) {
iconResId = getActivityInfo(context).icon;
}
}
@@ -162,23 +192,19 @@
}
}
- Tile(Parcel in) {
- mActivityPackage = in.readString();
- mActivityName = in.readString();
- title = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
- summary = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
- if (in.readByte() != 0) {
- intent = Intent.CREATOR.createFromParcel(in);
+ /**
+ * Whether the icon can be tinted. This is true when icon needs to be monochrome (single-color)
+ */
+ public boolean isIconTintable(Context context) {
+ if (mMetaData != null
+ && mMetaData.containsKey(TileUtils.META_DATA_PREFERENCE_ICON_TINTABLE)) {
+ return mMetaData.getBoolean(TileUtils.META_DATA_PREFERENCE_ICON_TINTABLE);
}
- final int N = in.readInt();
- for (int i = 0; i < N; i++) {
- userHandle.add(UserHandle.CREATOR.createFromParcel(in));
- }
- category = in.readString();
- priority = in.readInt();
- metaData = in.readBundle();
- key = in.readString();
- isIconTintable = in.readBoolean();
+ final String pkgName = context.getPackageName();
+ // If this drawable is coming from outside Settings, tint it to match the color.
+ final ActivityInfo activityInfo = getActivityInfo(context);
+ return activityInfo != null
+ && !TextUtils.equals(pkgName, activityInfo.packageName);
}
private ActivityInfo getActivityInfo(Context context) {
@@ -205,8 +231,8 @@
};
public boolean isPrimaryProfileOnly() {
- String profile = metaData != null ?
- metaData.getString(META_DATA_KEY_PROFILE) : PROFILE_ALL;
+ String profile = mMetaData != null ?
+ mMetaData.getString(META_DATA_KEY_PROFILE) : PROFILE_ALL;
profile = (profile != null ? profile : PROFILE_ALL);
return TextUtils.equals(profile, PROFILE_PRIMARY);
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/drawer/TileUtils.java b/packages/SettingsLib/src/com/android/settingslib/drawer/TileUtils.java
index 6b9a08e..946fc637 100644
--- a/packages/SettingsLib/src/com/android/settingslib/drawer/TileUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/drawer/TileUtils.java
@@ -228,16 +228,16 @@
HashMap<String, DashboardCategory> categoryMap = new HashMap<>();
for (Tile tile : tiles) {
- DashboardCategory category = categoryMap.get(tile.category);
+ final String categoryKey = tile.getCategory();
+ DashboardCategory category = categoryMap.get(categoryKey);
if (category == null) {
- category = new DashboardCategory();
- category.key = tile.category;
+ category = new DashboardCategory(categoryKey);
if (category == null) {
- Log.w(LOG_TAG, "Couldn't find category " + tile.category);
+ Log.w(LOG_TAG, "Couldn't find category " + categoryKey);
continue;
}
- categoryMap.put(category.key, category);
+ categoryMap.put(categoryKey, category);
}
category.addTile(tile);
}
@@ -269,13 +269,13 @@
intent.setPackage(SETTING_PKG);
}
getTilesForIntent(context, user, intent, addedCache, defaultCategory, outTiles,
- usePriority, true);
+ usePriority);
}
public static void getTilesForIntent(
Context context, UserHandle user, Intent intent,
Map<Pair<String, String>, Tile> addedCache, String defaultCategory, List<Tile> outTiles,
- boolean usePriority, boolean checkCategory) {
+ boolean usePriority) {
PackageManager pm = context.getPackageManager();
List<ResolveInfo> results = pm.queryIntentActivitiesAsUser(intent,
PackageManager.GET_META_DATA, user.getIdentifier());
@@ -289,7 +289,7 @@
String categoryKey = defaultCategory;
// Load category
- if (checkCategory && ((metaData == null) || !metaData.containsKey(EXTRA_CATEGORY_KEY))
+ if ((metaData == null || !metaData.containsKey(EXTRA_CATEGORY_KEY))
&& categoryKey == null) {
Log.w(LOG_TAG, "Found " + resolved.activityInfo.name + " for intent "
+ intent + " missing metadata "
@@ -302,12 +302,8 @@
Pair<String, String> key = new Pair<>(activityInfo.packageName, activityInfo.name);
Tile tile = addedCache.get(key);
if (tile == null) {
- tile = new Tile(activityInfo);
- tile.intent = new Intent().setClassName(
- activityInfo.packageName, activityInfo.name);
- tile.category = categoryKey;
+ tile = new Tile(activityInfo, categoryKey);
tile.priority = usePriority ? resolved.priority : 0;
- tile.metaData = activityInfo.metaData;
updateTileData(context, tile, activityInfo, activityInfo.applicationInfo, pm);
if (DEBUG) Log.d(LOG_TAG, "Adding tile " + tile.title);
addedCache.put(key, tile);
@@ -325,31 +321,16 @@
private static boolean updateTileData(Context context, Tile tile,
ActivityInfo activityInfo, ApplicationInfo applicationInfo, PackageManager pm) {
if (applicationInfo.isSystemApp()) {
- boolean forceTintIcon = false;
CharSequence title = null;
String summary = null;
String keyHint = null;
- boolean isIconTintable = false;
// Get the activity's meta-data
try {
Resources res = pm.getResourcesForApplication(applicationInfo.packageName);
Bundle metaData = activityInfo.metaData;
- if (!context.getPackageName().equals(applicationInfo.packageName)) {
- isIconTintable = true;
- forceTintIcon = true;
- }
-
if (res != null && metaData != null) {
- if (metaData.containsKey(META_DATA_PREFERENCE_ICON_TINTABLE)) {
- if (forceTintIcon) {
- Log.w(LOG_TAG, "Ignoring icon tintable for " + activityInfo);
- } else {
- isIconTintable =
- metaData.getBoolean(META_DATA_PREFERENCE_ICON_TINTABLE);
- }
- }
if (metaData.containsKey(META_DATA_PREFERENCE_TITLE)) {
if (metaData.get(META_DATA_PREFERENCE_TITLE) instanceof Integer) {
title = res.getString(metaData.getInt(META_DATA_PREFERENCE_TITLE));
@@ -385,13 +366,8 @@
// Set title and summary for the preference
tile.title = title;
tile.summary = summary;
- // Replace the intent with this specific activity
- tile.intent = new Intent().setClassName(activityInfo.packageName,
- activityInfo.name);
// Suggest a key for this tile
tile.key = keyHint;
- tile.isIconTintable = isIconTintable;
-
return true;
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/notification/ZenDurationDialog.java b/packages/SettingsLib/src/com/android/settingslib/notification/ZenDurationDialog.java
index fd9d02b..0ef46a1 100644
--- a/packages/SettingsLib/src/com/android/settingslib/notification/ZenDurationDialog.java
+++ b/packages/SettingsLib/src/com/android/settingslib/notification/ZenDurationDialog.java
@@ -17,7 +17,6 @@
package com.android.settingslib.notification;
import android.app.ActivityManager;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -42,6 +41,7 @@
import java.util.Arrays;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
public class ZenDurationDialog {
private static final int[] MINUTE_BUCKETS = ZenModeConfig.MINUTE_BUCKETS;
@@ -67,12 +67,17 @@
}
public Dialog createDialog() {
+ final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
+ setupDialog(builder);
+ return builder.create();
+ }
+
+ public void setupDialog(AlertDialog.Builder builder) {
int zenDuration = Settings.Secure.getInt(
mContext.getContentResolver(), Settings.Secure.ZEN_DURATION,
Settings.Secure.ZEN_DURATION_FOREVER);
- final AlertDialog.Builder builder = new AlertDialog.Builder(mContext)
- .setTitle(R.string.zen_mode_duration_settings_title)
+ builder.setTitle(R.string.zen_mode_duration_settings_title)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.okay,
new DialogInterface.OnClickListener() {
@@ -85,7 +90,6 @@
View contentView = getContentView();
setupRadioButtons(zenDuration);
builder.setView(contentView);
- return builder.create();
}
@VisibleForTesting
@@ -270,8 +274,7 @@
String radioContentText = "";
switch (rowIndex) {
case FOREVER_CONDITION_INDEX:
- radioContentText = mContext.getString(
- com.android.internal.R.string.zen_mode_forever);
+ radioContentText = mContext.getString(R.string.zen_mode_forever);
break;
case COUNTDOWN_CONDITION_INDEX:
Condition condition = ZenModeConfig.toTimeCondition(mContext,
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java
index c904384..b33e9c3 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java
@@ -109,6 +109,7 @@
when(mDevice3.getBluetoothClass()).thenReturn(DEVICE_CLASS_2);
when(mLocalBluetoothManager.getEventManager()).thenReturn(mBluetoothEventManager);
+ when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalProfileManager);
when(mLocalAdapter.getBluetoothState()).thenReturn(BluetoothAdapter.STATE_ON);
when(mHfpProfile.isProfileReady()).thenReturn(true);
when(mA2dpProfile.isProfileReady()).thenReturn(true);
@@ -129,10 +130,10 @@
@Test
public void testAddDevice_validCachedDevices_devicesAdded() {
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice1);
+ mDevice1);
assertThat(cachedDevice1).isNotNull();
CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice2);
+ mDevice2);
assertThat(cachedDevice2).isNotNull();
Collection<CachedBluetoothDevice> devices = mCachedDeviceManager.getCachedDevicesCopy();
@@ -149,7 +150,7 @@
@Test
public void testGetName_validCachedDevice_nameFound() {
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice1);
+ mDevice1);
assertThat(cachedDevice1).isNotNull();
assertThat(mCachedDeviceManager.getName(mDevice1)).isEqualTo(DEVICE_ALIAS_1);
}
@@ -160,7 +161,7 @@
@Test
public void testOnDeviceNameUpdated_validName_nameUpdated() {
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice1);
+ mDevice1);
assertThat(cachedDevice1).isNotNull();
assertThat(cachedDevice1.getName()).isEqualTo(DEVICE_ALIAS_1);
@@ -176,10 +177,10 @@
@Test
public void testClearNonBondedDevices_bondedAndNonBondedDevices_nonBondedDevicesCleared() {
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice1);
+ mDevice1);
assertThat(cachedDevice1).isNotNull();
CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice2);
+ mDevice2);
assertThat(cachedDevice2).isNotNull();
when(mDevice1.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
@@ -231,10 +232,10 @@
@Test
public void testOnHiSyncIdChanged_sameHiSyncId_populateInDifferentLists() {
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice1);
+ mDevice1);
assertThat(cachedDevice1).isNotNull();
CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice2);
+ mDevice2);
assertThat(cachedDevice2).isNotNull();
// Since both devices do not have hiSyncId, they should be added in mCachedDevices.
@@ -266,10 +267,10 @@
@Test
public void testOnHiSyncIdChanged_sameHiSyncIdAndOneConnected_chooseConnectedDevice() {
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice1);
+ mDevice1);
assertThat(cachedDevice1).isNotNull();
CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice2);
+ mDevice2);
assertThat(cachedDevice2).isNotNull();
cachedDevice1.onProfileStateChanged(mHearingAidProfile, BluetoothProfile.STATE_CONNECTED);
cachedDevice2.onProfileStateChanged(mHearingAidProfile, BluetoothProfile.STATE_CONNECTED);
@@ -303,10 +304,10 @@
@Test
public void testOnHiSyncIdChanged_differentHiSyncId_populateInSameList() {
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice1);
+ mDevice1);
assertThat(cachedDevice1).isNotNull();
CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice2);
+ mDevice2);
assertThat(cachedDevice2).isNotNull();
// Since both devices do not have hiSyncId, they should be added in mCachedDevices.
@@ -339,7 +340,7 @@
@Test
public void testOnProfileConnectionStateChanged_singleDeviceConnected_visible() {
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice1);
+ mDevice1);
assertThat(cachedDevice1).isNotNull();
cachedDevice1.onProfileStateChanged(mHearingAidProfile, BluetoothProfile.STATE_CONNECTED);
@@ -377,10 +378,10 @@
@Test
public void testOnProfileConnectionStateChanged_twoDevicesConnected_oneDeviceVisible() {
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice1);
+ mDevice1);
assertThat(cachedDevice1).isNotNull();
CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice2);
+ mDevice2);
assertThat(cachedDevice2).isNotNull();
cachedDevice1.onProfileStateChanged(mHearingAidProfile, BluetoothProfile.STATE_CONNECTED);
cachedDevice2.onProfileStateChanged(mHearingAidProfile, BluetoothProfile.STATE_CONNECTED);
@@ -431,10 +432,10 @@
@Test
public void testOnProfileConnectionStateChanged_twoDevicesDisconnected_oneDeviceVisible() {
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice1);
+ mDevice1);
assertThat(cachedDevice1).isNotNull();
CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice2);
+ mDevice2);
assertThat(cachedDevice2).isNotNull();
cachedDevice1.onProfileStateChanged(mHearingAidProfile, BluetoothProfile.STATE_CONNECTED);
cachedDevice2.onProfileStateChanged(mHearingAidProfile, BluetoothProfile.STATE_CONNECTED);
@@ -486,10 +487,10 @@
@Test
public void testOnDeviceUnpaired_bothHearingAidsPaired_removesItsPairFromList() {
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice1);
+ mDevice1);
assertThat(cachedDevice1).isNotNull();
CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice2);
+ mDevice2);
assertThat(cachedDevice2).isNotNull();
cachedDevice1.setHiSyncId(HISYNCID1);
@@ -518,13 +519,13 @@
@Test
public void testOnDeviceUnpaired_bothHearingAidsNotPaired_doesNotRemoveAnyDeviceFromList() {
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice1);
+ mDevice1);
assertThat(cachedDevice1).isNotNull();
CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice2);
+ mDevice2);
assertThat(cachedDevice2).isNotNull();
CachedBluetoothDevice cachedDevice3 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice3);
+ mDevice3);
assertThat(cachedDevice2).isNotNull();
cachedDevice1.setHiSyncId(HISYNCID1);
@@ -570,7 +571,7 @@
doAnswer((invocation) -> HISYNCID1).when(mHearingAidProfile).getHiSyncId(mDevice2);
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice1);
+ mDevice1);
assertThat(cachedDevice1).isNotNull();
// The first hearing aid device should be populated in mCachedDevice and
// mCachedDevicesMapForHearingAids.
@@ -581,7 +582,7 @@
.contains(cachedDevice1);
CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice2);
+ mDevice2);
assertThat(cachedDevice2).isNotNull();
// The second hearing aid device should be populated in mHearingAidDevicesNotAddedInCache.
assertThat(mCachedDeviceManager.getCachedDevicesCopy()).hasSize(1);
@@ -599,7 +600,7 @@
doAnswer((invocation) -> HISYNCID1).when(mHearingAidProfile).getHiSyncId(mDevice1);
doAnswer((invocation) -> HISYNCID2).when(mHearingAidProfile).getHiSyncId(mDevice2);
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice1);
+ mDevice1);
assertThat(cachedDevice1).isNotNull();
// The first hearing aid device should be populated in mCachedDevice and
// mCachedDevicesMapForHearingAids.
@@ -610,7 +611,7 @@
.contains(cachedDevice1);
CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice2);
+ mDevice2);
assertThat(cachedDevice2).isNotNull();
// The second hearing aid device should also be populated in mCachedDevice
// and mCachedDevicesMapForHearingAids as its not a pair of the first one.
@@ -680,7 +681,7 @@
@Test
public void testOnBtClassChanged_validBtClass_classChanged() {
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice1);
+ mDevice1);
assertThat(cachedDevice1).isNotNull();
assertThat(cachedDevice1.getBtClass()).isEqualTo(DEVICE_CLASS_1);
@@ -696,7 +697,7 @@
@Test
public void testOnDeviceDisappeared_deviceBondedUnbonded_unbondedDeviceDisappeared() {
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice1);
+ mDevice1);
assertThat(cachedDevice1).isNotNull();
when(mDevice1.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
@@ -712,10 +713,10 @@
@Test
public void testOnActiveDeviceChanged_connectedDevices_activeDeviceChanged() {
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice1);
+ mDevice1);
assertThat(cachedDevice1).isNotNull();
CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice2);
+ mDevice2);
assertThat(cachedDevice2).isNotNull();
when(mDevice1.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
@@ -777,10 +778,10 @@
@Test
public void testOnActiveDeviceChanged_withA2dpAndHearingAid() {
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice1);
+ mDevice1);
assertThat(cachedDevice1).isNotNull();
CachedBluetoothDevice cachedDevice2 = mCachedDeviceManager.addDevice(mLocalAdapter,
- mLocalProfileManager, mDevice2);
+ mDevice2);
assertThat(cachedDevice2).isNotNull();
when(mDevice1.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManagerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManagerTest.java
index 77fb272..af66f7a 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManagerTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManagerTest.java
@@ -20,6 +20,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -80,6 +81,10 @@
*/
@Test
public void constructor_initiateHidAndHidDeviceProfile() {
+ when(mAdapter.getSupportedProfiles()).thenReturn(
+ generateList(new int[] {BluetoothProfile.HID_HOST}));
+ when(mAdapter.getSupportedProfiles()).thenReturn(
+ generateList(new int[] {BluetoothProfile.HID_HOST, BluetoothProfile.HID_DEVICE}));
mProfileManager =
new LocalBluetoothProfileManager(mContext, mAdapter, mDeviceManager, mEventManager);
@@ -94,12 +99,12 @@
public void updateLocalProfiles_addA2dpToLocalProfiles() {
mProfileManager =
new LocalBluetoothProfileManager(mContext, mAdapter, mDeviceManager, mEventManager);
- when(mAdapter.getUuids()).thenReturn(new ParcelUuid[]{BluetoothUuid.AudioSource});
assertThat(mProfileManager.getA2dpProfile()).isNull();
assertThat(mProfileManager.getHeadsetProfile()).isNull();
- ParcelUuid[] uuids = mAdapter.getUuids();
- mProfileManager.updateLocalProfiles(uuids);
+ when(mAdapter.getSupportedProfiles()).thenReturn(generateList(
+ new int[] {BluetoothProfile.A2DP}));
+ mProfileManager.updateLocalProfiles();
assertThat(mProfileManager.getA2dpProfile()).isNotNull();
assertThat(mProfileManager.getHeadsetProfile()).isNull();
@@ -110,6 +115,8 @@
*/
@Test
public void updateProfiles_addHidProfileForRemoteDevice() {
+ when(mAdapter.getSupportedProfiles()).thenReturn(generateList(
+ new int[] {BluetoothProfile.HID_HOST}));
mProfileManager =
new LocalBluetoothProfileManager(mContext, mAdapter, mDeviceManager, mEventManager);
ParcelUuid[] uuids = new ParcelUuid[]{BluetoothUuid.Hid};
@@ -131,7 +138,8 @@
*/
@Test
public void stateChangedHandler_receiveA2dpConnectionStateChanged_shouldDispatchCallback() {
- when(mAdapter.getUuids()).thenReturn(new ParcelUuid[]{BluetoothUuid.AudioSource});
+ when(mAdapter.getSupportedProfiles()).thenReturn(generateList(
+ new int[] {BluetoothProfile.A2DP}));
mProfileManager = new LocalBluetoothProfileManager(mContext, mAdapter, mDeviceManager,
mEventManager);
// Refer to BluetoothControllerImpl, it will call setReceiverHandler after
@@ -154,7 +162,8 @@
*/
@Test
public void stateChangedHandler_receiveHeadsetConnectionStateChanged_shouldDispatchCallback() {
- when(mAdapter.getUuids()).thenReturn(new ParcelUuid[]{BluetoothUuid.Handsfree_AG});
+ when(mAdapter.getSupportedProfiles()).thenReturn(generateList(
+ new int[] {BluetoothProfile.HEADSET}));
mProfileManager = new LocalBluetoothProfileManager(mContext, mAdapter, mDeviceManager,
mEventManager);
// Refer to BluetoothControllerImpl, it will call setReceiverHandler after
@@ -203,7 +212,8 @@
*/
@Test
public void stateChangedHandler_receivePanConnectionStateChanged_shouldNotDispatchCallback() {
- when(mAdapter.getUuids()).thenReturn(new ParcelUuid[]{BluetoothUuid.AudioSource});
+ when(mAdapter.getSupportedProfiles()).thenReturn(
+ generateList(new int[] {BluetoothProfile.PAN}));
mProfileManager = new LocalBluetoothProfileManager(mContext, mAdapter, mDeviceManager,
mEventManager);
// Refer to BluetoothControllerImpl, it will call setReceiverHandler after
@@ -225,8 +235,32 @@
* handler and refresh CachedBluetoothDevice
*/
@Test
- public void stateChangedHandler_receivePanConnectionStateChangedWithoutUuid_shouldNotRefresh() {
- when(mAdapter.getUuids()).thenReturn(null);
+ public void stateChangedHandler_receivePanConnectionStateChangedWithoutProfile_shouldNotRefresh
+ () {
+ when(mAdapter.getSupportedProfiles()).thenReturn(null);
+ mProfileManager = new LocalBluetoothProfileManager(mContext, mAdapter, mDeviceManager,
+ mEventManager);
+ // Refer to BluetoothControllerImpl, it will call setReceiverHandler after
+ // LocalBluetoothProfileManager created.
+ mEventManager.setReceiverHandler(null);
+ mIntent = new Intent(BluetoothPan.ACTION_CONNECTION_STATE_CHANGED);
+ mIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
+ mIntent.putExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, BluetoothProfile.STATE_CONNECTING);
+ mIntent.putExtra(BluetoothProfile.EXTRA_STATE, BluetoothProfile.STATE_CONNECTED);
+
+ mContext.sendBroadcast(mIntent);
+
+ verify(mCachedBluetoothDevice, never()).refresh();
+ }
+
+ /**
+ * Verify BluetoothPan.ACTION_CONNECTION_STATE_CHANGED intent with uuids will dispatch to
+ * handler and refresh CachedBluetoothDevice
+ */
+ @Test
+ public void stateChangedHandler_receivePanConnectionStateChangedWithProfile_shouldRefresh() {
+ when(mAdapter.getSupportedProfiles()).thenReturn(generateList(
+ new int[] {BluetoothProfile.PAN}));
mProfileManager = new LocalBluetoothProfileManager(mContext, mAdapter, mDeviceManager,
mEventManager);
// Refer to BluetoothControllerImpl, it will call setReceiverHandler after
@@ -242,25 +276,14 @@
verify(mCachedBluetoothDevice).refresh();
}
- /**
- * Verify BluetoothPan.ACTION_CONNECTION_STATE_CHANGED intent with uuids will dispatch to
- * handler and refresh CachedBluetoothDevice
- */
- @Test
- public void stateChangedHandler_receivePanConnectionStateChangedWithUuids_shouldRefresh() {
- when(mAdapter.getUuids()).thenReturn(new ParcelUuid[]{BluetoothUuid.AudioSource});
- mProfileManager = new LocalBluetoothProfileManager(mContext, mAdapter, mDeviceManager,
- mEventManager);
- // Refer to BluetoothControllerImpl, it will call setReceiverHandler after
- // LocalBluetoothProfileManager created.
- mEventManager.setReceiverHandler(null);
- mIntent = new Intent(BluetoothPan.ACTION_CONNECTION_STATE_CHANGED);
- mIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
- mIntent.putExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, BluetoothProfile.STATE_CONNECTING);
- mIntent.putExtra(BluetoothProfile.EXTRA_STATE, BluetoothProfile.STATE_CONNECTED);
-
- mContext.sendBroadcast(mIntent);
-
- verify(mCachedBluetoothDevice).refresh();
+ private List<Integer> generateList(int[] profile) {
+ if (profile == null) {
+ return null;
+ }
+ final List<Integer> profileList = new ArrayList<>(profile.length);
+ for(int i = 0; i < profile.length; i++) {
+ profileList.add(profile[i]);
+ }
+ return profileList;
}
}
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/drawer/TileTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/drawer/TileTest.java
index a9e5aae..e8d37a9 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/drawer/TileTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/drawer/TileTest.java
@@ -30,20 +30,21 @@
public void setUp() {
mActivityInfo = new ActivityInfo();
mActivityInfo.packageName = RuntimeEnvironment.application.getPackageName();
+ mActivityInfo.name = "abc";
mActivityInfo.icon = R.drawable.ic_plus;
- mTile = new Tile(mActivityInfo);
- mTile.metaData = new Bundle();
+ mActivityInfo.metaData = new Bundle();
+ mTile = new Tile(mActivityInfo, "category");
}
@Test
public void isPrimaryProfileOnly_profilePrimary_shouldReturnTrue() {
- mTile.metaData.putString(META_DATA_KEY_PROFILE, PROFILE_PRIMARY);
+ mActivityInfo.metaData.putString(META_DATA_KEY_PROFILE, PROFILE_PRIMARY);
assertThat(mTile.isPrimaryProfileOnly()).isTrue();
}
@Test
public void isPrimaryProfileOnly_profileAll_shouldReturnFalse() {
- mTile.metaData.putString(META_DATA_KEY_PROFILE, PROFILE_ALL);
+ mActivityInfo.metaData.putString(META_DATA_KEY_PROFILE, PROFILE_ALL);
assertThat(mTile.isPrimaryProfileOnly()).isFalse();
}
@@ -54,27 +55,28 @@
@Test
public void isPrimaryProfileOnly_nullMetadata_shouldReturnFalse() {
- mTile.metaData = null;
+ mActivityInfo.metaData = null;
assertThat(mTile.isPrimaryProfileOnly()).isFalse();
}
@Test
public void getIcon_noContextOrMetadata_returnNull() {
- final Tile tile = new Tile(new ActivityInfo());
+ mActivityInfo.metaData = null;
+ final Tile tile = new Tile(mActivityInfo, "category");
assertThat(tile.getIcon(null)).isNull();
assertThat(tile.getIcon(RuntimeEnvironment.application)).isNull();
}
@Test
public void getIcon_providedByUri_returnNull() {
- mTile.metaData.putString(META_DATA_PREFERENCE_ICON_URI, "content://foobar/icon");
+ mActivityInfo.metaData.putString(META_DATA_PREFERENCE_ICON_URI, "content://foobar/icon");
assertThat(mTile.getIcon(RuntimeEnvironment.application)).isNull();
}
@Test
public void getIcon_hasIconMetadata_returnIcon() {
- mTile.metaData.putInt(META_DATA_PREFERENCE_ICON, R.drawable.ic_info);
+ mActivityInfo.metaData.putInt(META_DATA_PREFERENCE_ICON, R.drawable.ic_info);
assertThat(mTile.getIcon(RuntimeEnvironment.application).getResId())
.isEqualTo(R.drawable.ic_info);
@@ -82,9 +84,40 @@
@Test
public void getIcon_noIconMetadata_returnActivityIcon() {
- mTile.metaData.putInt(META_DATA_PREFERENCE_ICON, 0);
+ mActivityInfo.metaData.putInt(META_DATA_PREFERENCE_ICON, 0);
assertThat(mTile.getIcon(RuntimeEnvironment.application).getResId())
.isEqualTo(mActivityInfo.icon);
}
+
+ @Test
+ public void isIconTintable_hasMetadata_shouldReturnIconTintableMetadata() {
+ final Tile tile = new Tile(mActivityInfo, "category");
+
+ mActivityInfo.metaData.putBoolean(TileUtils.META_DATA_PREFERENCE_ICON_TINTABLE, false);
+ assertThat(tile.isIconTintable(RuntimeEnvironment.application)).isFalse();
+
+ mActivityInfo.metaData.putBoolean(TileUtils.META_DATA_PREFERENCE_ICON_TINTABLE, true);
+ assertThat(tile.isIconTintable(RuntimeEnvironment.application)).isTrue();
+ }
+
+ @Test
+ public void isIconTintable_noIcon_shouldReturnFalse() {
+ final Tile tile = new Tile(mActivityInfo, "category");
+
+ assertThat(tile.isIconTintable(RuntimeEnvironment.application)).isFalse();
+ }
+
+ @Test
+ public void isIconTintable_noMetadata_shouldReturnPackageNameCheck() {
+ final Tile tile1 = new Tile(mActivityInfo, "category");
+ assertThat(tile1.isIconTintable(RuntimeEnvironment.application)).isFalse();
+
+ final ActivityInfo activityInfo = new ActivityInfo();
+ activityInfo.packageName = "blah";
+ activityInfo.name = "abc";
+
+ final Tile tile2 = new Tile(activityInfo, "category");
+ assertThat(tile2.isIconTintable(RuntimeEnvironment.application)).isTrue();
+ }
}
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/drawer/TileUtilsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/drawer/TileUtilsTest.java
index 0b6acde..9fda8564 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/drawer/TileUtilsTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/drawer/TileUtilsTest.java
@@ -108,11 +108,10 @@
.thenReturn(info);
TileUtils.getTilesForIntent(mContext, UserHandle.CURRENT, intent, addedCache,
- null /* defaultCategory */, outTiles, false /* usePriority */,
- false /* checkCategory */);
+ null /* defaultCategory */, outTiles, false /* usePriority */);
assertThat(outTiles.size()).isEqualTo(1);
- assertThat(outTiles.get(0).category).isEqualTo(testCategory);
+ assertThat(outTiles.get(0).getCategory()).isEqualTo(testCategory);
}
@Test
@@ -129,8 +128,7 @@
.thenReturn(info);
TileUtils.getTilesForIntent(mContext, UserHandle.CURRENT, intent, addedCache,
- null /* defaultCategory */, outTiles, false /* usePriority */,
- false /* checkCategory */);
+ null /* defaultCategory */, outTiles, false /* usePriority */);
assertThat(outTiles.size()).isEqualTo(1);
assertThat(outTiles.get(0).key).isEqualTo(keyHint);
@@ -149,8 +147,7 @@
.thenReturn(info);
TileUtils.getTilesForIntent(mContext, UserHandle.CURRENT, intent, addedCache,
- null /* defaultCategory */, outTiles, false /* usePriority */,
- false /* checkCategory */);
+ null /* defaultCategory */, outTiles, false /* usePriority */);
assertThat(outTiles.isEmpty()).isTrue();
}
@@ -173,7 +170,7 @@
.thenReturn(info);
List<DashboardCategory> categoryList = TileUtils.getCategories(mContext, cache, testAction);
- assertThat(categoryList.get(0).getTile(0).category).isEqualTo(testCategory);
+ assertThat(categoryList.get(0).getTile(0).getCategory()).isEqualTo(testCategory);
}
@Test
@@ -209,8 +206,7 @@
.thenReturn(info);
TileUtils.getTilesForIntent(mContext, UserHandle.CURRENT, intent, addedCache,
- null /* defaultCategory */, outTiles, false /* usePriority */,
- false /* checkCategory */);
+ null /* defaultCategory */, outTiles, false /* usePriority */);
assertThat(outTiles.size()).isEqualTo(1);
assertThat(outTiles.get(0).title).isEqualTo("my title");
@@ -233,15 +229,13 @@
.thenReturn("my localized title");
TileUtils.getTilesForIntent(mContext, UserHandle.CURRENT, intent, addedCache,
- null /* defaultCategory */, outTiles, false /* usePriority */,
- false /* checkCategory */);
-
+ null /* defaultCategory */, outTiles, false /* usePriority */);
assertThat(outTiles.size()).isEqualTo(1);
assertThat(outTiles.get(0).title).isEqualTo("my localized title");
// Icon should be tintable because the tile is not from settings package, and
// "forceTintExternalIcon" is set
- assertThat(outTiles.get(0).isIconTintable).isTrue();
+ assertThat(outTiles.get(0).isIconTintable(mContext)).isTrue();
}
@Test
@@ -260,11 +254,9 @@
.thenReturn(info);
TileUtils.getTilesForIntent(mContext, UserHandle.CURRENT, intent, addedCache,
- null /* defaultCategory */, outTiles, false /* usePriority */,
- false /* checkCategory */);
+ null /* defaultCategory */, outTiles, false /* usePriority */);
- assertThat(outTiles.size()).isEqualTo(1);
- assertThat(outTiles.get(0).isIconTintable).isFalse();
+ assertThat(outTiles.get(0).isIconTintable(mContext)).isFalse();
}
@Test
@@ -283,11 +275,9 @@
.thenReturn(info);
TileUtils.getTilesForIntent(mContext, UserHandle.CURRENT, intent, addedCache,
- null /* defaultCategory */, outTiles, false /* usePriority */,
- false /* checkCategory */);
+ null /* defaultCategory */, outTiles, false /* usePriority */);
- assertThat(outTiles.size()).isEqualTo(1);
- assertThat(outTiles.get(0).isIconTintable).isTrue();
+ assertThat(outTiles.get(0).isIconTintable(mContext)).isTrue();
}
@Test
@@ -305,8 +295,7 @@
// Case 1: No provider associated with the uri specified.
TileUtils.getTilesForIntent(mContext, UserHandle.CURRENT, intent, addedCache,
- null /* defaultCategory */, outTiles, false /* usePriority */,
- false /* checkCategory */);
+ null /* defaultCategory */, outTiles, false /* usePriority */);
assertThat(outTiles.size()).isEqualTo(1);
assertThat(outTiles.get(0).getIcon(mContext).getResId()).isEqualTo(314159);
@@ -323,8 +312,7 @@
.thenReturn(mIContentProvider);
TileUtils.getTilesForIntent(mContext, UserHandle.CURRENT, intent, addedCache,
- null /* defaultCategory */, outTiles, false /* usePriority */,
- false /* checkCategory */);
+ null /* defaultCategory */, outTiles, false /* usePriority */);
assertThat(outTiles.size()).isEqualTo(1);
assertThat(outTiles.get(0).getIcon(mContext).getResId()).isEqualTo(314159);
@@ -345,8 +333,7 @@
.thenReturn(info);
TileUtils.getTilesForIntent(mContext, UserHandle.CURRENT, intent, addedCache,
- null /* defaultCategory */, outTiles, false /* usePriority */,
- false /* checkCategory */);
+ null /* defaultCategory */, outTiles, false /* usePriority */);
assertThat(outTiles.size()).isEqualTo(1);
}
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/ZenDurationDialogTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/ZenDurationDialogTest.java
index c8619d8..f47f41c 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/ZenDurationDialogTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/ZenDurationDialogTest.java
@@ -26,7 +26,7 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
-import android.app.AlertDialog;
+import android.app.Activity;
import android.app.Fragment;
import android.app.NotificationManager;
import android.content.Context;
@@ -40,6 +40,8 @@
import android.view.View;
import android.widget.Button;
+import androidx.appcompat.app.AlertDialog;
+
import com.android.settingslib.SettingsLibRobolectricTestRunner;
import org.junit.Before;
@@ -47,6 +49,7 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.robolectric.Robolectric;
import org.robolectric.RuntimeEnvironment;
@RunWith(SettingsLibRobolectricTestRunner.class)
@@ -58,6 +61,7 @@
private Condition mCountdownCondition;
private Condition mAlarmCondition;
private ContentResolver mContentResolver;
+ private AlertDialog.Builder mBuilder;
@Before
public void setup() {
@@ -68,13 +72,14 @@
mController = spy(new ZenDurationDialog(mContext));
mController.mLayoutInflater = mLayoutInflater;
mController.getContentView();
+ mBuilder = new AlertDialog.Builder(mContext);
}
@Test
public void testAlwaysPrompt() {
Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION,
Settings.Global.ZEN_DURATION_PROMPT);
- mController.createDialog();
+ mController.setupDialog(mBuilder);
assertFalse(mController.getConditionTagAt(ZenDurationDialog.FOREVER_CONDITION_INDEX).rb
.isChecked());
@@ -88,7 +93,7 @@
public void testForever() {
Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION,
Settings.Secure.ZEN_DURATION_FOREVER);
- mController.createDialog();
+ mController.setupDialog(mBuilder);
assertTrue(mController.getConditionTagAt(ZenDurationDialog.FOREVER_CONDITION_INDEX).rb
.isChecked());
@@ -101,7 +106,7 @@
@Test
public void testSpecificDuration() {
Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION, 45);
- mController.createDialog();
+ mController.setupDialog(mBuilder);
assertFalse(mController.getConditionTagAt(ZenDurationDialog.FOREVER_CONDITION_INDEX).rb
.isChecked());
@@ -117,7 +122,7 @@
Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION,
Settings.Secure.ZEN_DURATION_FOREVER);
- AlertDialog dialog = (AlertDialog) mController.createDialog();
+ mController.setupDialog(mBuilder);
mController.getConditionTagAt(ZenDurationDialog.ALWAYS_ASK_CONDITION_INDEX).rb.setChecked(
true);
mController.updateZenDuration(Settings.Secure.ZEN_DURATION_FOREVER);
@@ -131,7 +136,7 @@
Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION,
Settings.Secure.ZEN_DURATION_PROMPT);
- AlertDialog dialog = (AlertDialog) mController.createDialog();
+ mController.setupDialog(mBuilder);
mController.getConditionTagAt(ZenDurationDialog.FOREVER_CONDITION_INDEX).rb.setChecked(
true);
mController.updateZenDuration(Settings.Secure.ZEN_DURATION_PROMPT);
@@ -145,7 +150,7 @@
Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION,
Settings.Secure.ZEN_DURATION_PROMPT);
- AlertDialog dialog = (AlertDialog) mController.createDialog();
+ mController.setupDialog(mBuilder);
mController.getConditionTagAt(ZenDurationDialog.COUNTDOWN_CONDITION_INDEX).rb.setChecked(
true);
mController.updateZenDuration(Settings.Secure.ZEN_DURATION_PROMPT);
@@ -160,7 +165,7 @@
Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION,
Settings.Secure.ZEN_DURATION_PROMPT);
- AlertDialog dialog = (AlertDialog) mController.createDialog();
+ mController.setupDialog(mBuilder);
// click time button starts at 60 minutes
// - 1 hour to MAX_BUCKET_MINUTES (12 hours), increments by 1 hour
// - 0-60 minutes increments by 15 minutes
diff --git a/packages/SystemUI/res-keyguard/values/attrs.xml b/packages/SystemUI/res-keyguard/values/attrs.xml
index e2ce210..293b683 100644
--- a/packages/SystemUI/res-keyguard/values/attrs.xml
+++ b/packages/SystemUI/res-keyguard/values/attrs.xml
@@ -38,9 +38,5 @@
<attr name="android:textColor" format="color" />
</declare-styleable>
- <declare-styleable name="CarrierText">
- <attr name="allCaps" format="boolean" />
- </declare-styleable>
-
<attr name="passwordStyle" format="reference" />
</resources>
diff --git a/packages/SystemUI/res/layout/keyguard_status_bar.xml b/packages/SystemUI/res/layout/keyguard_status_bar.xml
index 8e491dc..5b9816d 100644
--- a/packages/SystemUI/res/layout/keyguard_status_bar.xml
+++ b/packages/SystemUI/res/layout/keyguard_status_bar.xml
@@ -18,7 +18,7 @@
<!-- Extends RelativeLayout -->
<com.android.systemui.statusbar.phone.KeyguardStatusBarView
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
+ xmlns:systemui="http://schemas.android.com/apk/res-auto"
android:id="@+id/keyguard_header"
android:layout_width="match_parent"
android:layout_height="@dimen/status_bar_header_height_keyguard"
@@ -73,6 +73,8 @@
android:textDirection="locale"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/wallpaperTextColorSecondary"
- android:singleLine="true" />
+ android:singleLine="true"
+ systemui:showMissingSim="true"
+ systemui:showAirplaneMode="true" />
</com.android.systemui.statusbar.phone.KeyguardStatusBarView>
diff --git a/packages/SystemUI/res/values/attrs.xml b/packages/SystemUI/res/values/attrs.xml
index 49ee952..f50ef82 100644
--- a/packages/SystemUI/res/values/attrs.xml
+++ b/packages/SystemUI/res/values/attrs.xml
@@ -146,5 +146,12 @@
<!-- Used to style charging animation AVD animation -->
<attr name="chargingAnimColor" format="color" />
+ <!-- Used display CarrierText in Keyguard or QS Footer -->
+ <declare-styleable name="CarrierText">
+ <attr name="allCaps" format="boolean" />
+ <attr name="showMissingSim" format="boolean" />
+ <attr name="showAirplaneMode" format="boolean" />
+ </declare-styleable>
+
</resources>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index a9d995c..ca6b2d9 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -236,6 +236,9 @@
<!-- Height of search panel including navigation bar height -->
<dimen name="navbar_search_panel_height">230dip</dimen>
+ <!-- Move the back button drawable for 3 button layout upwards in ime mode and in portrait -->
+ <dimen name="navbar_back_button_ime_offset">2dp</dimen>
+
<!-- Height of the draggable handle at the bottom of the phone notification panel -->
<dimen name="close_handle_height">36dp</dimen>
diff --git a/packages/SystemUI/res/values/strings_car.xml b/packages/SystemUI/res/values/strings_car.xml
index 61d734f..2890cf2 100644
--- a/packages/SystemUI/res/values/strings_car.xml
+++ b/packages/SystemUI/res/values/strings_car.xml
@@ -19,7 +19,9 @@
<resources>
<!-- Name of Guest Profile. [CHAR LIMIT=30] -->
<string name="car_guest">Guest</string>
- <!-- Name of Add User Profile. [CHAR LIMIT=30] -->
+ <!-- Title for button that starts a guest session. [CHAR LIMIT=30] -->
+ <string name="start_guest_session">Guest</string>
+ <!-- Title for button that adds a new user. [CHAR LIMIT=30] -->
<string name="car_add_user">Add User</string>
<!-- Default name of the new user created. [CHAR LIMIT=30] -->
<string name="car_new_user">New User</string>
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/DockedStackListenerCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/DockedStackListenerCompat.java
new file mode 100644
index 0000000..bb319e6
--- /dev/null
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/DockedStackListenerCompat.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.shared.system;
+
+import android.view.IDockedStackListener;
+
+/**
+ * An interface to track docked stack changes.
+ */
+public class DockedStackListenerCompat {
+
+ IDockedStackListener.Stub mListener = new IDockedStackListener.Stub() {
+ @Override
+ public void onDividerVisibilityChanged(boolean visible) {}
+
+ @Override
+ public void onDockedStackExistsChanged(boolean exists) {
+ DockedStackListenerCompat.this.onDockedStackExistsChanged(exists);
+ }
+
+ @Override
+ public void onDockedStackMinimizedChanged(boolean minimized, long animDuration,
+ boolean isHomeStackResizable) {
+ DockedStackListenerCompat.this.onDockedStackMinimizedChanged(minimized, animDuration,
+ isHomeStackResizable);
+ }
+
+ @Override
+ public void onAdjustedForImeChanged(boolean adjustedForIme, long animDuration) {}
+
+ @Override
+ public void onDockSideChanged(final int newDockSide) {
+ DockedStackListenerCompat.this.onDockSideChanged(newDockSide);
+ }
+ };
+
+ public void onDockedStackExistsChanged(boolean exists) {
+ // To be overridden
+ }
+
+ public void onDockedStackMinimizedChanged(boolean minimized, long animDuration,
+ boolean isHomeStackResizable) {
+ // To be overridden
+ }
+
+ public void onDockSideChanged(final int newDockSide) {
+ // To be overridden
+ }
+}
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java
index ed2f831..d83b36d 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java
@@ -166,4 +166,16 @@
}
return NAV_BAR_POS_INVALID;
}
+
+ /**
+ * Registers a docked stack listener with the system.
+ */
+ public void registerDockedStackListener(DockedStackListenerCompat listener) {
+ try {
+ WindowManagerGlobal.getWindowManagerService().registerDockedStackListener(
+ listener.mListener);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to register docked stack listener");
+ }
+ }
}
diff --git a/packages/SystemUI/src/com/android/keyguard/CarrierText.java b/packages/SystemUI/src/com/android/keyguard/CarrierText.java
index 66475e2..a0a3687 100644
--- a/packages/SystemUI/src/com/android/keyguard/CarrierText.java
+++ b/packages/SystemUI/src/com/android/keyguard/CarrierText.java
@@ -43,11 +43,6 @@
import android.telephony.TelephonyManager;
public class CarrierText extends TextView {
- /** Do not show missing sim message. */
- public static final int FLAG_HIDE_MISSING_SIM = 1 << 0;
- /** Do not show airplane mode message. */
- public static final int FLAG_HIDE_AIRPLANE_MODE = 1 << 1;
-
private static final boolean DEBUG = KeyguardConstants.DEBUG;
private static final String TAG = "CarrierText";
@@ -55,17 +50,23 @@
private final boolean mIsEmergencyCallCapable;
+ private boolean mTelephonyCapable;
+
+ private boolean mShowMissingSim;
+
+ private boolean mShowAirplaneMode;
+
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private WifiManager mWifiManager;
private boolean[] mSimErrorState = new boolean[TelephonyManager.getDefault().getPhoneCount()];
- private int mFlags;
-
- private KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() {
+ private final KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() {
@Override
public void onRefreshCarrierInfo() {
+ if (DEBUG) Log.d(TAG, "onRefreshCarrierInfo(), mTelephonyCapable: "
+ + Boolean.toString(mTelephonyCapable));
updateCarrierText();
}
@@ -77,9 +78,18 @@
setSelected(true);
};
+ @Override
+ public void onTelephonyCapable(boolean capable) {
+ if (DEBUG) Log.d(TAG, "onTelephonyCapable() mTelephonyCapable: "
+ + Boolean.toString(capable));
+ mTelephonyCapable = capable;
+ updateCarrierText();
+ }
+
public void onSimStateChanged(int subId, int slotId, IccCardConstants.State simState) {
if (slotId < 0) {
- Log.d(TAG, "onSimStateChanged() - slotId invalid: " + slotId);
+ Log.d(TAG, "onSimStateChanged() - slotId invalid: " + slotId
+ + " mTelephonyCapable: " + Boolean.toString(mTelephonyCapable));
return;
}
@@ -91,13 +101,9 @@
mSimErrorState[slotId] = false;
updateCarrierText();
}
- };
+ }
};
- public void setDisplayFlags(int flags) {
- mFlags = flags;
- }
-
/**
* The status of this lock screen. Primarily used for widgets on LockScreen.
*/
@@ -110,7 +116,8 @@
SimLocked, // SIM card is currently locked
SimPermDisabled, // SIM card is permanently disabled due to PUK unlock failure
SimNotReady, // SIM is not ready yet. May never be on devices w/o a SIM.
- SimIoError; // SIM card is faulty
+ SimIoError, // SIM card is faulty
+ SimUnknown // SIM card is unknown
}
public CarrierText(Context context) {
@@ -126,6 +133,8 @@
attrs, R.styleable.CarrierText, 0, 0);
try {
useAllCaps = a.getBoolean(R.styleable.CarrierText_allCaps, false);
+ mShowAirplaneMode = a.getBoolean(R.styleable.CarrierText_showAirplaneMode, false);
+ mShowMissingSim = a.getBoolean(R.styleable.CarrierText_showMissingSim, false);
} finally {
a.recycle();
}
@@ -249,12 +258,12 @@
}
private String getMissingSimMessage() {
- return (mFlags & FLAG_HIDE_MISSING_SIM) == 0
+ return mShowMissingSim && mTelephonyCapable
? getContext().getString(R.string.keyguard_missing_sim_message_short) : "";
}
private String getAirplaneModeMessage() {
- return (mFlags & FLAG_HIDE_AIRPLANE_MODE) == 0
+ return mShowAirplaneMode
? getContext().getString(R.string.airplane_mode) : "";
}
@@ -360,6 +369,9 @@
getContext().getText(R.string.keyguard_sim_error_message_short),
text);
break;
+ case SimUnknown:
+ carrierText = null;
+ break;
}
return carrierText;
@@ -408,11 +420,11 @@
case PERM_DISABLED:
return StatusMode.SimPermDisabled;
case UNKNOWN:
- return StatusMode.SimMissing;
+ return StatusMode.SimUnknown;
case CARD_IO_ERROR:
return StatusMode.SimIoError;
}
- return StatusMode.SimMissing;
+ return StatusMode.SimUnknown;
}
private static CharSequence concatenate(CharSequence plmn, CharSequence spn) {
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
index fa7e814..dfd6a18 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -84,6 +84,7 @@
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.util.Preconditions;
import com.android.internal.widget.LockPatternUtils;
+import com.android.settingslib.WirelessUtils;
import com.android.systemui.recents.misc.SysUiTaskStackChangeListener;
import com.android.systemui.shared.system.ActivityManagerWrapper;
@@ -148,6 +149,7 @@
private static final int MSG_ASSISTANT_STACK_CHANGED = 335;
private static final int MSG_BIOMETRIC_AUTHENTICATION_CONTINUE = 336;
private static final int MSG_DEVICE_POLICY_MANAGER_STATE_CHANGED = 337;
+ private static final int MSG_TELEPHONY_CAPABLE = 338;
/** Biometric authentication state: Not listening. */
private static final int BIOMETRIC_STATE_STOPPED = 0;
@@ -204,6 +206,8 @@
private boolean mHasLockscreenWallpaper;
private boolean mAssistantVisible;
private boolean mKeyguardOccluded;
+ @VisibleForTesting
+ protected boolean mTelephonyCapable;
// Device provisioning state
private boolean mDeviceProvisioned;
@@ -344,6 +348,9 @@
case MSG_DEVICE_POLICY_MANAGER_STATE_CHANGED:
updateLogoutEnabled();
break;
+ case MSG_TELEPHONY_CAPABLE:
+ updateTelephonyCapable((boolean)msg.obj);
+ break;
default:
super.handleMessage(msg);
break;
@@ -962,14 +969,18 @@
maxChargingMicroWatt));
mHandler.sendMessage(msg);
} else if (TelephonyIntents.ACTION_SIM_STATE_CHANGED.equals(action)) {
+ SimData args = SimData.fromIntent(intent);
// ACTION_SIM_STATE_CHANGED is rebroadcast after unlocking the device to
// keep compatibility with apps that aren't direct boot aware.
// SysUI should just ignore this broadcast because it was already received
// and processed previously.
if (intent.getBooleanExtra(TelephonyIntents.EXTRA_REBROADCAST_ON_UNLOCK, false)) {
+ // Guarantee mTelephonyCapable state after SysUI crash and restart
+ if (args.simState == State.ABSENT) {
+ mHandler.obtainMessage(MSG_TELEPHONY_CAPABLE, true).sendToTarget();
+ }
return;
}
- SimData args = SimData.fromIntent(intent);
if (DEBUG_SIM_STATES) {
Log.v(TAG, "action " + action
+ " state: " + intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE)
@@ -1467,6 +1478,16 @@
mUserManager = context.getSystemService(UserManager.class);
mDevicePolicyManager = context.getSystemService(DevicePolicyManager.class);
mLogoutEnabled = mDevicePolicyManager.isLogoutEnabled();
+ updateAirplaneModeState();
+ }
+
+ private void updateAirplaneModeState() {
+ // ACTION_AIRPLANE_MODE_CHANGED do not broadcast if device set AirplaneMode ON and boot
+ if (!WirelessUtils.isAirplaneModeOn(mContext)
+ || mHandler.hasMessages(MSG_AIRPLANE_MODE_CHANGED)) {
+ return;
+ }
+ mHandler.sendEmptyMessage(MSG_AIRPLANE_MODE_CHANGED);
}
private void updateBiometricListeningState() {
@@ -1823,6 +1844,23 @@
}
/**
+ * Handle Telephony status during Boot for CarrierText display policy
+ */
+ @VisibleForTesting
+ void updateTelephonyCapable(boolean capable){
+ if (capable == mTelephonyCapable) {
+ return;
+ }
+ mTelephonyCapable = capable;
+ for (WeakReference<KeyguardUpdateMonitorCallback> ref : mCallbacks) {
+ KeyguardUpdateMonitorCallback cb = ref.get();
+ if (cb != null) {
+ cb.onTelephonyCapable(mTelephonyCapable);
+ }
+ }
+ }
+
+ /**
* Handle {@link #MSG_SIM_STATE_CHANGE}
*/
@VisibleForTesting
@@ -1835,6 +1873,10 @@
if (!SubscriptionManager.isValidSubscriptionId(subId)) {
Log.w(TAG, "invalid subId in handleSimStateChange()");
+ /* Only handle No SIM(ABSENT) due to handleServiceStateChange() handle other case */
+ if (state == State.ABSENT) {
+ updateTelephonyCapable(true);
+ }
return;
}
@@ -1863,7 +1905,8 @@
/**
* Handle {@link #MSG_SERVICE_STATE_CHANGE}
*/
- private void handleServiceStateChange(int subId, ServiceState serviceState) {
+ @VisibleForTesting
+ void handleServiceStateChange(int subId, ServiceState serviceState) {
if (DEBUG) {
Log.d(TAG,
"handleServiceStateChange(subId=" + subId + ", serviceState=" + serviceState);
@@ -1872,6 +1915,8 @@
if (!SubscriptionManager.isValidSubscriptionId(subId)) {
Log.w(TAG, "invalid subId in handleServiceStateChange()");
return;
+ } else {
+ updateTelephonyCapable(true);
}
mServiceStates.put(subId, serviceState);
@@ -2035,6 +2080,7 @@
callback.onRefreshCarrierInfo();
callback.onClockVisibilityChanged();
callback.onKeyguardVisibilityChangedRaw(mKeyguardIsVisible);
+ callback.onTelephonyCapable(mTelephonyCapable);
for (Entry<Integer, SimData> data : mSimDatas.entrySet()) {
final SimData state = data.getValue();
callback.onSimStateChanged(state.subId, state.slotId, state.simState);
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
index 8135ac5..f818d05 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
@@ -117,6 +117,12 @@
public void onUserSwitchComplete(int userId) { }
/**
+ * Called when the Telephony capable
+ * @param capable
+ */
+ public void onTelephonyCapable(boolean capable) { }
+
+ /**
* Called when the SIM state changes.
* @param slotId
* @param simState
diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
index 520e40a..68d77eb 100644
--- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
+++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
@@ -43,9 +43,12 @@
import android.graphics.Rect;
import android.graphics.Region;
import android.hardware.display.DisplayManager;
+import android.os.Handler;
+import android.os.HandlerThread;
import android.os.SystemProperties;
import android.provider.Settings.Secure;
import android.util.DisplayMetrics;
+import android.util.Log;
import android.view.DisplayCutout;
import android.view.DisplayInfo;
import android.view.Gravity;
@@ -60,6 +63,7 @@
import android.widget.FrameLayout;
import android.widget.ImageView;
+import com.android.internal.util.Preconditions;
import com.android.systemui.RegionInterceptingFrameLayout.RegionInterceptableView;
import com.android.systemui.fragments.FragmentHostManager;
import com.android.systemui.fragments.FragmentHostManager.FragmentListener;
@@ -79,6 +83,9 @@
* for antialiasing and emulation purposes.
*/
public class ScreenDecorations extends SystemUI implements Tunable {
+ private static final boolean DEBUG = false;
+ private static final String TAG = "ScreenDecorations";
+
public static final String SIZE = "sysui_rounded_size";
public static final String PADDING = "sysui_rounded_content_padding";
private static final boolean DEBUG_SCREENSHOT_ROUNDED_CORNERS =
@@ -99,9 +106,23 @@
private DisplayCutoutView mCutoutBottom;
private SecureSetting mColorInversionSetting;
private boolean mPendingRotationChange;
+ private Handler mHandler;
@Override
public void start() {
+ mHandler = startHandlerThread();
+ mHandler.post(this::startOnScreenDecorationsThread);
+ setupStatusBarPaddingIfNeeded();
+ }
+
+ @VisibleForTesting
+ Handler startHandlerThread() {
+ HandlerThread thread = new HandlerThread("ScreenDecorations");
+ thread.start();
+ return thread.getThreadHandler();
+ }
+
+ private void startOnScreenDecorationsThread() {
mWindowManager = mContext.getSystemService(WindowManager.class);
mRoundedDefault = mContext.getResources().getDimensionPixelSize(
R.dimen.rounded_corner_radius);
@@ -113,12 +134,6 @@
setupDecorations();
}
- int padding = mContext.getResources().getDimensionPixelSize(
- R.dimen.rounded_corner_content_padding);
- if (padding != 0) {
- setupPadding(padding);
- }
-
mDisplayListener = new DisplayManager.DisplayListener() {
@Override
public void onDisplayAdded(int displayId) {
@@ -132,8 +147,8 @@
@Override
public void onDisplayChanged(int displayId) {
- if ((hasRoundedCorners() || shouldDrawCutout()) &&
- mRotation != RotationUtils.getExactRotation(mContext)) {
+ final int newRotation = RotationUtils.getExactRotation(mContext);
+ if (mOverlay != null && mBottomOverlay != null && mRotation != newRotation) {
// We cannot immediately update the orientation. Otherwise
// WindowManager is still deferring layout until it has finished dispatching
// the config changes, which may cause divergence between what we draw
@@ -142,10 +157,15 @@
// - we are trying to redraw. This because WM resized our window and told us to.
// - the config change has been dispatched, so WM is no longer deferring layout.
mPendingRotationChange = true;
+ if (DEBUG) {
+ Log.i(TAG, "Rotation changed, deferring " + newRotation + ", staying at "
+ + mRotation);
+ }
+
mOverlay.getViewTreeObserver().addOnPreDrawListener(
- new RestartingPreDrawListener(mOverlay));
+ new RestartingPreDrawListener(mOverlay, newRotation));
mBottomOverlay.getViewTreeObserver().addOnPreDrawListener(
- new RestartingPreDrawListener(mBottomOverlay));
+ new RestartingPreDrawListener(mBottomOverlay, newRotation));
}
updateOrientation();
}
@@ -154,7 +174,7 @@
mRotation = -1;
mDisplayManager = (DisplayManager) mContext.getSystemService(
Context.DISPLAY_SERVICE);
- mDisplayManager.registerDisplayListener(mDisplayListener, null);
+ mDisplayManager.registerDisplayListener(mDisplayListener, mHandler);
}
private void setupDecorations() {
@@ -184,10 +204,11 @@
mWindowManager.getDefaultDisplay().getMetrics(metrics);
mDensity = metrics.density;
- Dependency.get(TunerService.class).addTunable(this, SIZE);
+ Dependency.get(Dependency.MAIN_HANDLER).post(
+ () -> Dependency.get(TunerService.class).addTunable(this, SIZE));
// Watch color inversion and invert the overlay as needed.
- mColorInversionSetting = new SecureSetting(mContext, Dependency.get(Dependency.MAIN_HANDLER),
+ mColorInversionSetting = new SecureSetting(mContext, mHandler,
Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED) {
@Override
protected void handleValueChanged(int value, boolean observedChange) {
@@ -199,7 +220,7 @@
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_USER_SWITCHED);
- mContext.registerReceiver(mIntentReceiver, filter);
+ mContext.registerReceiver(mIntentReceiver, filter, null /* permission */, mHandler);
mOverlay.addOnLayoutChangeListener(new OnLayoutChangeListener() {
@Override
@@ -217,6 +238,11 @@
.start();
}
});
+
+ mOverlay.getViewTreeObserver().addOnPreDrawListener(
+ new ValidatingPreDrawListener(mOverlay));
+ mBottomOverlay.getViewTreeObserver().addOnPreDrawListener(
+ new ValidatingPreDrawListener(mBottomOverlay));
}
private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@@ -246,14 +272,28 @@
@Override
protected void onConfigurationChanged(Configuration newConfig) {
- mPendingRotationChange = false;
- updateOrientation();
- if (shouldDrawCutout() && mOverlay == null) {
- setupDecorations();
- }
+ mHandler.post(() -> {
+ int oldRotation = mRotation;
+ mPendingRotationChange = false;
+ updateOrientation();
+ if (DEBUG) Log.i(TAG, "onConfigChanged from rot " + oldRotation + " to " + mRotation);
+ if (shouldDrawCutout() && mOverlay == null) {
+ setupDecorations();
+ }
+ if (mOverlay != null) {
+ // Updating the layout params ensures that ViewRootImpl will call relayoutWindow(),
+ // which ensures that the forced seamless rotation will end, even if we updated
+ // the rotation before window manager was ready (and was still waiting for sending
+ // the updated rotation).
+ updateLayoutParams();
+ }
+ });
}
- protected void updateOrientation() {
+ private void updateOrientation() {
+ Preconditions.checkState(mHandler.getLooper().getThread() == Thread.currentThread(),
+ "must call on " + mHandler.getLooper().getThread()
+ + ", but was " + Thread.currentThread());
if (mPendingRotationChange) {
return;
}
@@ -333,7 +373,19 @@
com.android.internal.R.bool.config_fillMainBuiltInDisplayCutout);
}
- private void setupPadding(int padding) {
+
+ private void setupStatusBarPaddingIfNeeded() {
+ // TODO: This should be moved to a more appropriate place, as it is not related to the
+ // screen decorations overlay.
+ int padding = mContext.getResources().getDimensionPixelSize(
+ R.dimen.rounded_corner_content_padding);
+ if (padding != 0) {
+ setupStatusBarPadding(padding);
+ }
+
+ }
+
+ private void setupStatusBarPadding(int padding) {
// Add some padding to all the content near the edge of the screen.
StatusBar sb = getComponent(StatusBar.class);
View statusBar = (sb != null ? sb.getStatusBarWindow() : null);
@@ -402,30 +454,32 @@
@Override
public void onTuningChanged(String key, String newValue) {
- if (mOverlay == null) return;
- if (SIZE.equals(key)) {
- int size = mRoundedDefault;
- int sizeTop = mRoundedDefaultTop;
- int sizeBottom = mRoundedDefaultBottom;
- if (newValue != null) {
- try {
- size = (int) (Integer.parseInt(newValue) * mDensity);
- } catch (Exception e) {
+ mHandler.post(() -> {
+ if (mOverlay == null) return;
+ if (SIZE.equals(key)) {
+ int size = mRoundedDefault;
+ int sizeTop = mRoundedDefaultTop;
+ int sizeBottom = mRoundedDefaultBottom;
+ if (newValue != null) {
+ try {
+ size = (int) (Integer.parseInt(newValue) * mDensity);
+ } catch (Exception e) {
+ }
}
- }
- if (sizeTop == 0) {
- sizeTop = size;
- }
- if (sizeBottom == 0) {
- sizeBottom = size;
- }
+ if (sizeTop == 0) {
+ sizeTop = size;
+ }
+ if (sizeBottom == 0) {
+ sizeBottom = size;
+ }
- setSize(mOverlay.findViewById(R.id.left), sizeTop);
- setSize(mOverlay.findViewById(R.id.right), sizeTop);
- setSize(mBottomOverlay.findViewById(R.id.left), sizeBottom);
- setSize(mBottomOverlay.findViewById(R.id.right), sizeBottom);
- }
+ setSize(mOverlay.findViewById(R.id.left), sizeTop);
+ setSize(mOverlay.findViewById(R.id.right), sizeTop);
+ setSize(mBottomOverlay.findViewById(R.id.left), sizeBottom);
+ setSize(mBottomOverlay.findViewById(R.id.right), sizeBottom);
+ }
+ });
}
private void setSize(View view, int pixelSize) {
@@ -484,6 +538,11 @@
mVisibilityChangedListener = visibilityChangedListener;
mDecorations = decorations;
setId(R.id.display_cutout);
+ if (DEBUG) {
+ getViewTreeObserver().addOnDrawListener(() -> Log.i(TAG,
+ (mInitialStart ? "OverlayTop" : "OverlayBottom")
+ + " drawn in rot " + mRotation));
+ }
}
public void setColor(int color) {
@@ -719,20 +778,66 @@
private class RestartingPreDrawListener implements ViewTreeObserver.OnPreDrawListener {
private final View mView;
+ private final int mTargetRotation;
- private RestartingPreDrawListener(View view) {
+ private RestartingPreDrawListener(View view, int targetRotation) {
+ mView = view;
+ mTargetRotation = targetRotation;
+ }
+
+ @Override
+ public boolean onPreDraw() {
+ mView.getViewTreeObserver().removeOnPreDrawListener(this);
+
+ if (mTargetRotation == mRotation) {
+ if (DEBUG) {
+ Log.i(TAG, (mView == mOverlay ? "OverlayTop" : "OverlayBottom")
+ + " already in target rot "
+ + mTargetRotation + ", allow draw without restarting it");
+ }
+ return true;
+ }
+
+ mPendingRotationChange = false;
+ // This changes the window attributes - we need to restart the traversal for them to
+ // take effect.
+ updateOrientation();
+ if (DEBUG) {
+ Log.i(TAG, (mView == mOverlay ? "OverlayTop" : "OverlayBottom")
+ + " restarting listener fired, restarting draw for rot " + mRotation);
+ }
+ mView.invalidate();
+ return false;
+ }
+ }
+
+ /**
+ * A pre-draw listener, that validates that the rotation we draw in matches the displays
+ * rotation before continuing the draw.
+ *
+ * This is to prevent a race condition, where we have not received the display changed event
+ * yet, and would thus draw in an old orientation.
+ */
+ private class ValidatingPreDrawListener implements ViewTreeObserver.OnPreDrawListener {
+
+ private final View mView;
+
+ public ValidatingPreDrawListener(View view) {
mView = view;
}
@Override
public boolean onPreDraw() {
- mPendingRotationChange = false;
- mView.getViewTreeObserver().removeOnPreDrawListener(this);
- // This changes the window attributes - we need to restart the traversal for them to
- // take effect.
- updateOrientation();
- mView.invalidate();
- return false;
+ final int displayRotation = RotationUtils.getExactRotation(mContext);
+ if (displayRotation != mRotation && !mPendingRotationChange) {
+ if (DEBUG) {
+ Log.i(TAG, "Drawing rot " + mRotation + ", but display is at rot "
+ + displayRotation + ". Restarting draw");
+ }
+ mView.invalidate();
+ return false;
+ }
+ return true;
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardUI.java b/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardUI.java
index 682efb6..a42191c 100644
--- a/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardUI.java
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardUI.java
@@ -318,8 +318,7 @@
private CachedBluetoothDevice getCachedBluetoothDevice(BluetoothDevice d) {
CachedBluetoothDevice cachedDevice = mCachedDeviceManager.findDevice(d);
if (cachedDevice == null) {
- cachedDevice = mCachedDeviceManager.addDevice(
- mLocalBluetoothAdapter, mProfileManager, d);
+ cachedDevice = mCachedDeviceManager.addDevice(mLocalBluetoothAdapter, d);
}
return cachedDevice;
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
index f13f489..f1b7eec 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
@@ -55,7 +55,6 @@
private Scroller mScroller;
private AnimatorSet mBounceAnimatorSet;
- private int mAnimatingToPage = -1;
private float mLastExpansion;
public PagedTileLayout(Context context, AttributeSet attrs) {
@@ -95,40 +94,16 @@
}
@Override
- public boolean onInterceptTouchEvent(MotionEvent ev) {
- // Suppress all touch event during reveal animation.
- if (mAnimatingToPage != -1) {
- return true;
- }
- return super.onInterceptTouchEvent(ev);
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
- // Suppress all touch event during reveal animation.
- if (mAnimatingToPage != -1) {
- return true;
- }
- return super.onTouchEvent(ev);
- }
-
- @Override
public void computeScroll() {
if (!mScroller.isFinished() && mScroller.computeScrollOffset()) {
- scrollTo(mScroller.getCurrX(), mScroller.getCurrY());
- float pageFraction = (float) getScrollX() / getWidth();
- int position = (int) pageFraction;
- float positionOffset = pageFraction - position;
- mOnPageChangeListener.onPageScrolled(position, positionOffset, getScrollX());
+ fakeDragBy(getScrollX() - mScroller.getCurrX());
// Keep on drawing until the animation has finished.
postInvalidateOnAnimation();
return;
- }
- if (mAnimatingToPage != -1) {
- setCurrentItem(mAnimatingToPage, true);
+ } else if (isFakeDragging()) {
+ endFakeDrag();
mBounceAnimatorSet.start();
setOffscreenPageLimit(1);
- mAnimatingToPage = -1;
}
super.computeScroll();
}
@@ -287,7 +262,7 @@
}
public void startTileReveal(Set<String> tileSpecs, final Runnable postAnimation) {
- if (tileSpecs.isEmpty() || mPages.size() < 2 || getScrollX() != 0) {
+ if (tileSpecs.isEmpty() || mPages.size() < 2 || getScrollX() != 0 || !beginFakeDrag()) {
// Do not start the reveal animation unless there are tiles to animate, multiple
// TilePages available and the user has not already started dragging.
return;
@@ -305,6 +280,7 @@
if (bounceAnims.isEmpty()) {
// All tileSpecs are on the first page. Nothing to do.
// TODO: potentially show a bounce animation for first page QS tiles
+ endFakeDrag();
return;
}
@@ -317,10 +293,10 @@
postAnimation.run();
}
});
- mAnimatingToPage = lastPageNumber;
- setOffscreenPageLimit(mAnimatingToPage); // Ensure the page to reveal has been inflated.
- mScroller.startScroll(getScrollX(), getScrollY(), getWidth() * mAnimatingToPage, 0,
- REVEAL_SCROLL_DURATION_MILLIS);
+ setOffscreenPageLimit(lastPageNumber); // Ensure the page to reveal has been inflated.
+ int dx = getWidth() * lastPageNumber;
+ mScroller.startScroll(getScrollX(), getScrollY(), isLayoutRtl() ? -dx : dx, 0,
+ REVEAL_SCROLL_DURATION_MILLIS);
postInvalidateOnAnimation();
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java b/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java
index a6b065f..f147fb3 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java
@@ -123,8 +123,6 @@
mMobileSignal = findViewById(R.id.mobile_signal);
mMobileRoaming = findViewById(R.id.mobile_roaming);
mCarrierText = findViewById(R.id.qs_carrier_text);
- mCarrierText.setDisplayFlags(
- CarrierText.FLAG_HIDE_AIRPLANE_MODE | CarrierText.FLAG_HIDE_MISSING_SIM);
mMultiUserSwitch = findViewById(R.id.multi_user_switch);
mMultiUserAvatar = mMultiUserSwitch.findViewById(R.id.multi_user_avatar);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
index 25a55bd..af0ed284 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
@@ -101,7 +101,8 @@
hideUserGrid();
}
- if (record.mIsForeground) {
+ if (record.mIsForeground || (record.mIsStartGuestSession
+ && mUserManagerHelper.foregroundUserIsGuestUser())) {
dismissKeyguard();
return;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java
index 257fa75..23724c2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java
@@ -109,14 +109,12 @@
userRecords.add(record);
}
- // Add guest user record if the foreground user is not a guest
- if (!mUserManagerHelper.foregroundUserIsGuestUser()) {
- userRecords.add(addGuestUserRecord());
- }
+ // Add button for starting guest session.
+ userRecords.add(createStartGuestUserRecord());
// Add add user record if the foreground user can add users
if (mUserManagerHelper.foregroundUserCanAddUsers()) {
- userRecords.add(addUserRecord());
+ userRecords.add(createAddUserRecord());
}
return userRecords;
@@ -125,17 +123,17 @@
/**
* Create guest user record
*/
- private UserRecord addGuestUserRecord() {
+ private UserRecord createStartGuestUserRecord() {
UserInfo userInfo = new UserInfo();
- userInfo.name = mContext.getString(R.string.car_guest);
- return new UserRecord(userInfo, true /* isStartGuestSession */,
- false /* isAddUser */, false /* isForeground */);
+ userInfo.name = mContext.getString(R.string.start_guest_session);
+ return new UserRecord(userInfo, true /* isStartGuestSession */, false /* isAddUser */,
+ false /* isForeground */);
}
/**
* Create add user record
*/
- private UserRecord addUserRecord() {
+ private UserRecord createAddUserRecord() {
UserInfo userInfo = new UserInfo();
userInfo.name = mContext.getString(R.string.car_add_user);
return new UserRecord(userInfo, false /* isStartGuestSession */,
@@ -210,8 +208,6 @@
return;
}
-
- // If the user selects Guest, start the guest session.
if (userRecord.mIsStartGuestSession) {
notifyUserSelected(userRecord);
mUserManagerHelper.startNewGuestSession(mGuestName);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java
index 894ea62..f48c3f5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java
@@ -134,6 +134,9 @@
((ButtonInterface) mViews.get(i)).setImageDrawable(mImageDrawable);
}
}
+ if (mImageDrawable != null) {
+ mImageDrawable.setCallback(mCurrentView);
+ }
}
public void setVisibility(int visibility) {
@@ -266,6 +269,9 @@
public void setCurrentView(View currentView) {
mCurrentView = currentView.findViewById(mId);
+ if (mImageDrawable != null) {
+ mImageDrawable.setCallback(mCurrentView);
+ }
}
public void setVertical(boolean vertical) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java
index 042e4ff..b80cd30 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java
@@ -103,9 +103,9 @@
private float mDarkAmount;
/**
- * If keyguard will require a password or just fade away.
+ * If keyguard will just fade away or will require a password.
*/
- private boolean mCurrentlySecure;
+ private boolean mFadeAway;
/**
* Dozing and receiving a notification (AOD notification.)
@@ -135,7 +135,7 @@
public void setup(int minTopMargin, int maxShadeBottom, int notificationStackHeight,
float panelExpansion, int parentHeight,
- int keyguardStatusHeight, float dark, boolean secure, boolean pulsing,
+ int keyguardStatusHeight, float dark, boolean fadeAway, boolean pulsing,
int bouncerTop) {
mMinTopMargin = minTopMargin + mContainerTopPadding;
mMaxShadeBottom = maxShadeBottom;
@@ -144,7 +144,7 @@
mHeight = parentHeight;
mKeyguardStatusHeight = keyguardStatusHeight;
mDarkAmount = dark;
- mCurrentlySecure = secure;
+ mFadeAway = fadeAway;
mPulsing = pulsing;
mBouncerTop = bouncerTop;
}
@@ -198,7 +198,7 @@
float clockYRegular = getExpandedClockPosition();
boolean hasEnoughSpace = mMinTopMargin + mKeyguardStatusHeight < mBouncerTop;
- float clockYTarget = mCurrentlySecure && hasEnoughSpace ?
+ float clockYTarget = !mFadeAway && hasEnoughSpace ?
mMinTopMargin : -mKeyguardStatusHeight;
// Move clock up while collapsing the shade
@@ -218,11 +218,11 @@
*/
private float getClockAlpha(int y) {
float alphaKeyguard;
- if (mCurrentlySecure) {
- alphaKeyguard = 1;
- } else {
+ if (mFadeAway) {
alphaKeyguard = Math.max(0, y / Math.max(1f, getExpandedClockPosition()));
alphaKeyguard = Interpolators.ACCELERATE.getInterpolation(alphaKeyguard);
+ } else {
+ alphaKeyguard = 1;
}
return MathUtils.lerp(alphaKeyguard, 1f, mDarkAmount);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index b7bc577..ad2e9dc 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -25,6 +25,7 @@
import android.animation.LayoutTransition;
import android.animation.LayoutTransition.TransitionListener;
import android.animation.ObjectAnimator;
+import android.animation.PropertyValuesHolder;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.annotation.DrawableRes;
@@ -61,6 +62,7 @@
import com.android.settingslib.Utils;
import com.android.systemui.Dependency;
import com.android.systemui.DockedStackExistsListener;
+import com.android.systemui.Interpolators;
import com.android.systemui.OverviewProxyService;
import com.android.systemui.R;
import com.android.systemui.RecentsComponent;
@@ -483,14 +485,15 @@
Context lightContext = new ContextThemeWrapper(ctx, dualToneLightTheme);
Context darkContext = new ContextThemeWrapper(ctx, dualToneDarkTheme);
- if (oldConfig.orientation != newConfig.orientation
- || oldConfig.densityDpi != newConfig.densityDpi) {
+ final boolean orientationChange = oldConfig.orientation != newConfig.orientation;
+ final boolean densityChange = oldConfig.densityDpi != newConfig.densityDpi;
+ final boolean dirChange = oldConfig.getLayoutDirection() != newConfig.getLayoutDirection();
+
+ if (orientationChange || densityChange) {
mDockedIcon = getDrawable(lightContext, darkContext, R.drawable.ic_sysbar_docked);
mHomeDefaultIcon = getHomeDrawable(lightContext, darkContext);
}
- if (oldConfig.densityDpi != newConfig.densityDpi
- || oldConfig.getLayoutDirection() != newConfig.getLayoutDirection()) {
- mBackIcon = getBackDrawable(lightContext, darkContext);
+ if (densityChange || dirChange) {
mRecentIcon = getDrawable(lightContext, darkContext, R.drawable.ic_sysbar_recent);
mMenuIcon = getDrawable(lightContext, darkContext, R.drawable.ic_sysbar_menu);
@@ -506,6 +509,9 @@
updateCarModeIcons(ctx);
}
}
+ if (orientationChange || densityChange || dirChange) {
+ mBackIcon = getBackDrawable(lightContext, darkContext);
+ }
}
public KeyButtonDrawable getBackDrawable(Context lightContext, Context darkContext) {
@@ -527,9 +533,26 @@
private void orientBackButton(KeyButtonDrawable drawable) {
final boolean useAltBack =
- (mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0;
- drawable.setRotation(useAltBack
- ? -90 : (getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) ? 180 : 0);
+ (mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0;
+ final boolean isRtl = getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
+ float degrees = useAltBack
+ ? (isRtl ? 270 : -90)
+ : (isRtl ? 180 : 0);
+ if (drawable.getRotation() == degrees) {
+ return;
+ }
+
+ // Animate the back button's rotation to the new degrees and only in portrait move up the
+ // back button to line up with the other buttons
+ float targetY = !mOverviewProxyService.shouldShowSwipeUpUI() && !mVertical && useAltBack
+ ? - getResources().getDimension(R.dimen.navbar_back_button_ime_offset)
+ : 0;
+ ObjectAnimator navBarAnimator = ObjectAnimator.ofPropertyValuesHolder(drawable,
+ PropertyValuesHolder.ofFloat(KeyButtonDrawable.KEY_DRAWABLE_ROTATE, degrees),
+ PropertyValuesHolder.ofFloat(KeyButtonDrawable.KEY_DRAWABLE_TRANSLATE_Y, targetY));
+ navBarAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
+ navBarAnimator.setDuration(200);
+ navBarAnimator.start();
}
private void orientHomeButton(KeyButtonDrawable drawable) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index be8bf02..7db5802 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -524,7 +524,8 @@
totalHeight,
mKeyguardStatusView.getHeight(),
mInterpolatedDarkAmount,
- mStatusBar.isKeyguardCurrentlySecure(),
+ !mStatusBar.isKeyguardCurrentlySecure()
+ || mStatusBar.isKeyguardOccludeAnimationRunning(),
mPulsing,
mBouncerTop);
mClockPositionAlgorithm.run(mClockPositionResult);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadowKeyDrawable.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadowKeyDrawable.java
index 2471e34..8bd8048 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadowKeyDrawable.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadowKeyDrawable.java
@@ -28,8 +28,6 @@
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
-import com.android.systemui.R;
-
/**
* A drawable which adds shadow around a child drawable.
*/
@@ -60,6 +58,23 @@
}
}
+ public void setTranslationX(float x) {
+ setTranslation(x, mState.mTranslationY);
+ }
+
+ public void setTranslationY(float y) {
+ setTranslation(mState.mTranslationX, y);
+ }
+
+ public void setTranslation(float x, float y) {
+ if (mState.mTranslationX != x || mState.mTranslationY != y) {
+ mState.mTranslationX = x;
+ mState.mTranslationY = y;
+ mState.mLastDrawnBitmap = null;
+ invalidateSelf();
+ }
+ }
+
public void setShadowProperties(int x, int y, int size, int color) {
if (mState.mShadowOffsetX != x || mState.mShadowOffsetY != y
|| mState.mShadowSize != size || mState.mShadowColor != color) {
@@ -76,6 +91,14 @@
return mState.mRotateDegrees;
}
+ public float getTranslationX() {
+ return mState.mTranslationX;
+ }
+
+ public float getTranslationY() {
+ return mState.mTranslationY;
+ }
+
@Override
public void draw(Canvas canvas) {
Rect bounds = getBounds();
@@ -151,6 +174,7 @@
// Call mutate, so that the pixel allocation by the underlying vector drawable is cleared.
final Drawable d = mState.mChildState.newDrawable().mutate();
d.setBounds(0, 0, mState.mBaseWidth, mState.mBaseHeight);
+ canvas.translate(mState.mTranslationX, mState.mTranslationY);
d.draw(canvas);
if (mState.mShadowSize > 0) {
@@ -168,9 +192,9 @@
canvas.rotate(mState.mRotateDegrees, width / 2, height / 2);
final float shadowOffsetX = (float) (Math.sin(radians) * mState.mShadowOffsetY
- + Math.cos(radians) * mState.mShadowOffsetX);
+ + Math.cos(radians) * mState.mShadowOffsetX) - mState.mTranslationX;
final float shadowOffsetY = (float) (Math.cos(radians) * mState.mShadowOffsetY
- - Math.sin(radians) * mState.mShadowOffsetX);
+ - Math.sin(radians) * mState.mShadowOffsetX) - mState.mTranslationY;
canvas.drawBitmap(shadow, offset[0] + shadowOffsetX, offset[1] + shadowOffsetY, paint);
d.draw(canvas);
@@ -189,6 +213,8 @@
int mBaseWidth;
int mBaseHeight;
float mRotateDegrees;
+ float mTranslationX;
+ float mTranslationY;
int mShadowOffsetX;
int mShadowOffsetY;
int mShadowSize;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 4c91a9d..dd4ea3d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -322,6 +322,8 @@
public static final int FADE_KEYGUARD_START_DELAY = 100;
public static final int FADE_KEYGUARD_DURATION = 300;
public static final int FADE_KEYGUARD_DURATION_PULSING = 96;
+ public static final int FADE_BACKDROP_DURATION = 300;
+ public static final int FADE_BACKDROP_DURATION_FAST = 240;
/** If true, the system is in the half-boot-to-decryption-screen state.
* Prudently disable QS and notifications. */
@@ -543,6 +545,7 @@
private boolean mIsOccluded;
private boolean mWereIconsJustHidden;
private boolean mBouncerWasShowingWhenHidden;
+ private boolean mKeyguardOccludeAnimationRunning;
// Notifies StatusBarKeyguardViewManager every time the keyguard transition is over,
// this animation is tied to the scrim for historic reasons.
@@ -1641,7 +1644,7 @@
boolean wakeAndUnlock = mBiometricUnlockController != null
&& mBiometricUnlockController.isWakeAndUnlock();
- if (mLaunchTransitionFadingAway || wakeAndUnlock) {
+ if (mLaunchTransitionFadingAway && !mIsOccluded || wakeAndUnlock) {
mBackdrop.setVisibility(View.INVISIBLE);
Trace.endSection();
return;
@@ -1760,7 +1763,8 @@
boolean cannotAnimateDoze = mDozing && !ScrimState.AOD.getAnimateChange();
if (mBiometricUnlockController.getMode()
== BiometricUnlockController.MODE_WAKE_AND_UNLOCK_PULSING
- || hideBecauseOccluded || cannotAnimateDoze) {
+ || hideBecauseOccluded && !mKeyguardOccludeAnimationRunning
+ || cannotAnimateDoze) {
// We are unlocking directly - no animation!
mBackdrop.setVisibility(View.GONE);
@@ -1771,7 +1775,9 @@
mBackdrop.animate()
.alpha(SRC_MIN_ALPHA)
.setInterpolator(Interpolators.ACCELERATE_DECELERATE)
- .setDuration(300)
+ .setDuration(
+ mKeyguardOccludeAnimationRunning
+ ? FADE_BACKDROP_DURATION_FAST : FADE_BACKDROP_DURATION)
.setStartDelay(0)
.withEndAction(() -> {
mBackdrop.setVisibility(View.GONE);
@@ -3668,6 +3674,27 @@
}
/**
+ * Is keyguard being occluded by a newly launched activity.
+ */
+ public boolean isKeyguardOccludeAnimationRunning() {
+ return mKeyguardOccludeAnimationRunning;
+ }
+
+ /**
+ * Plays the animation when new activity is launched over keyguard.
+ */
+ public void animateKeyguardOccluding() {
+ mKeyguardOccludeAnimationRunning = true;
+ addPostCollapseAction(() -> {
+ mStatusBarKeyguardViewManager.reset(true /* hideBouncerWhenShowing */);
+ mKeyguardOccludeAnimationRunning = false;
+ });
+ mStatusBarKeyguardViewManager.animateCollapsePanels(1.0f /* speedfactor */);
+ updateScrimController();
+ updateMediaMetaData(false /* metaDataChanged */, true /* allowEnterAnimation */);
+ }
+
+ /**
* Plays the animation when an activity that was occluding Keyguard goes away.
*/
public void animateKeyguardUnoccluding() {
@@ -4012,7 +4039,7 @@
private void showBouncerIfKeyguard() {
if ((mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)
- && !mKeyguardViewMediator.isHiding()) {
+ && !mKeyguardViewMediator.isHiding() && !mKeyguardOccludeAnimationRunning) {
showBouncer(true /* scrimmed */);
}
}
@@ -4512,6 +4539,11 @@
@Override
public void onStartedGoingToSleep() {
+ // in case we start going to sleep while new animation is launching over keyguard, make
+ // sure to finish it
+ if (mKeyguardOccludeAnimationRunning) {
+ runPostCollapseRunnables();
+ }
notifyHeadsUpGoingToSleep();
dismissVolumeDialog();
}
@@ -4753,7 +4785,7 @@
? ScrimState.BOUNCER_SCRIMMED : ScrimState.BOUNCER;
mScrimController.transitionTo(state);
} else if (isInLaunchTransition() || mLaunchCameraOnScreenTurningOn
- || launchingAffordanceWithPreview) {
+ || launchingAffordanceWithPreview || mKeyguardOccludeAnimationRunning) {
mScrimController.transitionTo(ScrimState.UNLOCKED, mUnlockScrimCallback);
} else if (mBrightnessMirrorVisible) {
mScrimController.transitionTo(ScrimState.BRIGHTNESS_MIRROR);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
index c4424d8..97088bd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -365,6 +365,11 @@
}
});
return;
+ } else if (animate) {
+ mOccluded = true;
+ mStatusBar.animateKeyguardOccluding();
+ mStatusBarWindowManager.setKeyguardOccluded(mOccluded);
+ return;
}
} else if (!occluded && mOccluded && mShowing) {
StatsLog.write(StatsLog.KEYGUARD_STATE_CHANGED,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
index a38328a..f83fb43 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
@@ -144,7 +144,8 @@
state.scrimsVisibility == ScrimController.VISIBILITY_FULLY_OPAQUE;
final boolean keyguardOrAod = state.keyguardShowing
|| (state.dozing && mDozeParameters.getAlwaysOn());
- if (keyguardOrAod && !state.backdropShowing && !scrimsOccludingWallpaper) {
+ if (keyguardOrAod && !state.backdropShowing && !scrimsOccludingWallpaper
+ && !state.keyguardOccluded) {
mLpChanged.flags |= WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
} else {
mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonDrawable.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonDrawable.java
index 1a85c47..8e31f31 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonDrawable.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonDrawable.java
@@ -22,6 +22,7 @@
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
+import android.util.FloatProperty;
import android.view.Gravity;
import com.android.systemui.R;
@@ -33,6 +34,32 @@
*/
public class KeyButtonDrawable extends LayerDrawable {
+ public static final FloatProperty<KeyButtonDrawable> KEY_DRAWABLE_ROTATE =
+ new FloatProperty<KeyButtonDrawable>("KeyButtonRotation") {
+ @Override
+ public void setValue(KeyButtonDrawable drawable, float degree) {
+ drawable.setRotation(degree);
+ }
+
+ @Override
+ public Float get(KeyButtonDrawable drawable) {
+ return drawable.getRotation();
+ }
+ };
+
+ public static final FloatProperty<KeyButtonDrawable> KEY_DRAWABLE_TRANSLATE_Y =
+ new FloatProperty<KeyButtonDrawable>("KeyButtonTranslateY") {
+ @Override
+ public void setValue(KeyButtonDrawable drawable, float y) {
+ drawable.setTranslationY(y);
+ }
+
+ @Override
+ public Float get(KeyButtonDrawable drawable) {
+ return drawable.getTranslationY();
+ }
+ };
+
private final boolean mHasDarkDrawable;
public static KeyButtonDrawable create(Context lightContext, Drawable lightDrawable,
@@ -83,4 +110,33 @@
((ShadowKeyDrawable) getDrawable(1)).setRotation(degrees);
}
}
+
+ public void setTranslationY(float y) {
+ if (getDrawable(0) instanceof ShadowKeyDrawable) {
+ ((ShadowKeyDrawable) getDrawable(0)).setTranslationY(y);
+ }
+ if (mHasDarkDrawable && getDrawable(1) instanceof ShadowKeyDrawable) {
+ ((ShadowKeyDrawable) getDrawable(1)).setTranslationY(y);
+ }
+ }
+
+ public float getRotation() {
+ if (getDrawable(0) instanceof ShadowKeyDrawable) {
+ return ((ShadowKeyDrawable) getDrawable(0)).getRotation();
+ }
+ if (mHasDarkDrawable && getDrawable(1) instanceof ShadowKeyDrawable) {
+ return ((ShadowKeyDrawable) getDrawable(1)).getRotation();
+ }
+ return 0;
+ }
+
+ public float getTranslationY() {
+ if (getDrawable(0) instanceof ShadowKeyDrawable) {
+ return ((ShadowKeyDrawable) getDrawable(0)).getTranslationY();
+ }
+ if (mHasDarkDrawable && getDrawable(1) instanceof ShadowKeyDrawable) {
+ return ((ShadowKeyDrawable) getDrawable(1)).getTranslationY();
+ }
+ return 0;
+ }
}
diff --git a/packages/SystemUI/tests/AndroidManifest.xml b/packages/SystemUI/tests/AndroidManifest.xml
index 1be8322..e604877 100644
--- a/packages/SystemUI/tests/AndroidManifest.xml
+++ b/packages/SystemUI/tests/AndroidManifest.xml
@@ -49,6 +49,7 @@
<uses-permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW" />
<uses-permission android:name="android.permission.NETWORK_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.REGISTER_WINDOW_MANAGER_LISTENERS" />
<application android:debuggable="true">
<uses-library android:name="android.test.runner" />
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java
index d46a974..2055519 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java
@@ -16,14 +16,22 @@
package com.android.keyguard;
+import static com.google.common.truth.Truth.assertThat;
+
+import com.google.common.truth.Truth.*;
+
import android.content.Context;
import android.content.Intent;
+import android.os.Bundle;
+import android.telephony.ServiceState;
+import android.telephony.SubscriptionManager;
import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import com.android.internal.telephony.IccCardConstants;
+import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.systemui.SysuiTestCase;
@@ -70,6 +78,184 @@
keyguardUpdateMonitor.hasSimStateJustChanged());
}
+ @Test
+ public void testTelephonyCapable_BootInitState() {
+ TestableKeyguardUpdateMonitor keyguardUpdateMonitor =
+ new TestableKeyguardUpdateMonitor(getContext());
+ assertThat(keyguardUpdateMonitor.mTelephonyCapable).isFalse();
+ }
+
+ @Test
+ public void testTelephonyCapable_SimState_Absent() {
+ Intent intent = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
+ intent.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE
+ , IccCardConstants.INTENT_VALUE_ICC_ABSENT);
+ TestableKeyguardUpdateMonitor keyguardUpdateMonitor =
+ new TestableKeyguardUpdateMonitor(getContext());
+ keyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext()
+ , putPhoneInfo(intent,null, false));
+ mTestableLooper.processAllMessages();
+ assertThat(keyguardUpdateMonitor.mTelephonyCapable).isTrue();
+ }
+
+ @Test
+ public void testTelephonyCapable_SimInvalid_ServiceState_InService() {
+ // SERVICE_STATE - IN_SERVICE, but SIM_STATE is invalid TelephonyCapable should be False
+ TestableKeyguardUpdateMonitor keyguardUpdateMonitor =
+ new TestableKeyguardUpdateMonitor(getContext());
+ Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
+ Bundle data = new Bundle();
+ ServiceState state = new ServiceState();
+ state.setState(ServiceState.STATE_IN_SERVICE);
+ state.fillInNotifierBundle(data);
+ keyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext()
+ , putPhoneInfo(intent, data, false));
+ mTestableLooper.processAllMessages();
+ assertThat(keyguardUpdateMonitor.mTelephonyCapable).isFalse();
+ }
+
+ @Test
+ public void testTelephonyCapable_SimValid_ServiceState_PowerOff() {
+ // Simulate AirplaneMode case, SERVICE_STATE - POWER_OFF, check TelephonyCapable False
+ // Only receive ServiceState callback IN_SERVICE -> OUT_OF_SERVICE -> POWER_OFF
+ TestableKeyguardUpdateMonitor keyguardUpdateMonitor =
+ new TestableKeyguardUpdateMonitor(getContext());
+ Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
+ intent.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE
+ , IccCardConstants.INTENT_VALUE_ICC_LOADED);
+ Bundle data = new Bundle();
+ ServiceState state = new ServiceState();
+ state.setState(ServiceState.STATE_POWER_OFF);
+ state.fillInNotifierBundle(data);
+ keyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext()
+ , putPhoneInfo(intent, data, true));
+ mTestableLooper.processAllMessages();
+ assertThat(keyguardUpdateMonitor.mTelephonyCapable).isTrue();
+ }
+
+ /* Normal SIM inserted flow
+ * ServiceState: ---OutOfServie----->PowerOff->OutOfServie--->InService
+ * SimState: ----NOT_READY---->READY----------------------LOADED>>>
+ * Subscription: --------null---->null--->"Chunghwa Telecom"-------->>>
+ * System: -------------------------------BOOT_COMPLETED------>>>
+ * TelephonyCapable:(F)-(F)-(F)-(F)-(F)-(F)-(F)-(F)-(F)-(F)------(T)-(T)>>
+ */
+ @Test
+ public void testTelephonyCapable_BootInitState_ServiceState_OutOfService() {
+ TestableKeyguardUpdateMonitor keyguardUpdateMonitor =
+ new TestableKeyguardUpdateMonitor(getContext());
+ Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
+ Bundle data = new Bundle();
+ ServiceState state = new ServiceState();
+ state.setState(ServiceState.STATE_OUT_OF_SERVICE);
+ state.fillInNotifierBundle(data);
+ intent.putExtras(data);
+ keyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext()
+ , putPhoneInfo(intent, data, false));
+ mTestableLooper.processAllMessages();
+ assertThat(keyguardUpdateMonitor.mTelephonyCapable).isFalse();
+ }
+
+ @Test
+ public void testTelephonyCapable_BootInitState_SimState_NotReady() {
+ TestableKeyguardUpdateMonitor keyguardUpdateMonitor =
+ new TestableKeyguardUpdateMonitor(getContext());
+ Bundle data = new Bundle();
+ ServiceState state = new ServiceState();
+ state.setState(ServiceState.STATE_OUT_OF_SERVICE);
+ state.fillInNotifierBundle(data);
+ Intent intent = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
+ intent.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE
+ , IccCardConstants.INTENT_VALUE_ICC_NOT_READY);
+ keyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext()
+ , putPhoneInfo(intent, data, false));
+ mTestableLooper.processAllMessages();
+ assertThat(keyguardUpdateMonitor.mTelephonyCapable).isFalse();
+ }
+
+ @Test
+ public void testTelephonyCapable_BootInitState_SimState_Ready() {
+ TestableKeyguardUpdateMonitor keyguardUpdateMonitor =
+ new TestableKeyguardUpdateMonitor(getContext());
+ Bundle data = new Bundle();
+ ServiceState state = new ServiceState();
+ state.setState(ServiceState.STATE_OUT_OF_SERVICE);
+ state.fillInNotifierBundle(data);
+ Intent intent = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
+ intent.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE
+ , IccCardConstants.INTENT_VALUE_ICC_READY);
+ keyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext()
+ , putPhoneInfo(intent, data, false));
+ mTestableLooper.processAllMessages();
+ assertThat(keyguardUpdateMonitor.mTelephonyCapable).isFalse();
+ }
+
+ @Test
+ public void testTelephonyCapable_BootInitState_ServiceState_PowerOff() {
+ TestableKeyguardUpdateMonitor keyguardUpdateMonitor =
+ new TestableKeyguardUpdateMonitor(getContext());
+ Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
+ Bundle data = new Bundle();
+ ServiceState state = new ServiceState();
+ state.setState(ServiceState.STATE_POWER_OFF);
+ state.fillInNotifierBundle(data);
+ keyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext()
+ , putPhoneInfo(intent, data, false));
+ mTestableLooper.processAllMessages();
+ assertThat(keyguardUpdateMonitor.mTelephonyCapable).isFalse();
+ }
+
+ @Test
+ public void testTelephonyCapable_SimValid_ServiceState_InService() {
+ TestableKeyguardUpdateMonitor keyguardUpdateMonitor =
+ new TestableKeyguardUpdateMonitor(getContext());
+ Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
+ Bundle data = new Bundle();
+ ServiceState state = new ServiceState();
+ state.setState(ServiceState.STATE_IN_SERVICE);
+ state.fillInNotifierBundle(data);
+ keyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext()
+ , putPhoneInfo(intent, data, true));
+ mTestableLooper.processAllMessages();
+ assertThat(keyguardUpdateMonitor.mTelephonyCapable).isTrue();
+ }
+
+ @Test
+ public void testTelephonyCapable_SimValid_SimState_Loaded() {
+ TestableKeyguardUpdateMonitor keyguardUpdateMonitor =
+ new TestableKeyguardUpdateMonitor(getContext());
+ Bundle data = new Bundle();
+ ServiceState state = new ServiceState();
+ state.setState(ServiceState.STATE_IN_SERVICE);
+ state.fillInNotifierBundle(data);
+ Intent intentSimState = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
+ intentSimState.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE
+ , IccCardConstants.INTENT_VALUE_ICC_LOADED);
+ keyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext()
+ , putPhoneInfo(intentSimState, data, true));
+ mTestableLooper.processAllMessages();
+ // Even SimState Loaded, still need ACTION_SERVICE_STATE_CHANGED turn on mTelephonyCapable
+ assertThat(keyguardUpdateMonitor.mTelephonyCapable).isFalse();
+
+ Intent intentServiceState = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
+ intentSimState.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE
+ , IccCardConstants.INTENT_VALUE_ICC_LOADED);
+ keyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext()
+ , putPhoneInfo(intentServiceState, data, true));
+ mTestableLooper.processAllMessages();
+ assertThat(keyguardUpdateMonitor.mTelephonyCapable).isTrue();
+ }
+
+ private Intent putPhoneInfo(Intent intent, Bundle data, Boolean simInited) {
+ int subscription = simInited
+ ? 1/* mock subid=1 */ : SubscriptionManager.DUMMY_SUBSCRIPTION_ID_BASE;
+ if (data != null) intent.putExtras(data);
+ intent.putExtra(PhoneConstants.PHONE_NAME_KEY, "Phone");
+ intent.putExtra("subscription", subscription);
+ intent.putExtra("slot", 0/* SLOT 1 */);
+ return intent;
+ }
+
private class TestableKeyguardUpdateMonitor extends KeyguardUpdateMonitor {
AtomicBoolean mSimStateChanged = new AtomicBoolean(false);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java b/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java
index f1bf31d..644c0b3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java
@@ -34,8 +34,10 @@
import android.app.Fragment;
import android.content.res.Configuration;
+import android.os.Handler;
import android.support.test.filters.SmallTest;
import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import android.view.Display;
import android.view.View;
@@ -60,6 +62,7 @@
@SmallTest
public class ScreenDecorationsTest extends SysuiTestCase {
+ private TestableLooper mTestableLooper;
private ScreenDecorations mScreenDecorations;
private StatusBar mStatusBar;
private WindowManager mWindowManager;
@@ -71,6 +74,10 @@
@Before
public void setup() {
+ mTestableLooper = TestableLooper.get(this);
+ mDependency.injectTestDependency(Dependency.MAIN_HANDLER,
+ new Handler(mTestableLooper.getLooper()));
+
mStatusBar = mock(StatusBar.class);
mWindowManager = mock(WindowManager.class);
mView = spy(new StatusBarWindowView(mContext, null));
@@ -88,7 +95,31 @@
mTunerService = mDependency.injectMockDependency(TunerService.class);
- mScreenDecorations = new ScreenDecorations();
+
+ mScreenDecorations = new ScreenDecorations() {
+ @Override
+ public void start() {
+ super.start();
+ mTestableLooper.processAllMessages();
+ }
+
+ @Override
+ Handler startHandlerThread() {
+ return new Handler(mTestableLooper.getLooper());
+ }
+
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ mTestableLooper.processAllMessages();
+ }
+
+ @Override
+ public void onTuningChanged(String key, String newValue) {
+ super.onTuningChanged(key, newValue);
+ mTestableLooper.processAllMessages();
+ }
+ };
mScreenDecorations.mContext = mContext;
mScreenDecorations.mComponents = mContext.getComponents();
diff --git a/rs/java/android/renderscript/BaseObj.java b/rs/java/android/renderscript/BaseObj.java
index f95af16..b7e05d9 100644
--- a/rs/java/android/renderscript/BaseObj.java
+++ b/rs/java/android/renderscript/BaseObj.java
@@ -16,6 +16,7 @@
package android.renderscript;
+import android.annotation.UnsupportedAppUsage;
import dalvik.system.CloseGuard;
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -73,6 +74,7 @@
final CloseGuard guard = CloseGuard.get();
private boolean mDestroyed;
private String mName;
+ @UnsupportedAppUsage
RenderScript mRS;
/**
diff --git a/rs/java/android/renderscript/Element.java b/rs/java/android/renderscript/Element.java
index 667bf71..b8eb3a1 100644
--- a/rs/java/android/renderscript/Element.java
+++ b/rs/java/android/renderscript/Element.java
@@ -16,6 +16,8 @@
package android.renderscript;
+import android.annotation.UnsupportedAppUsage;
+
/**
* <p>An Element represents one item within an {@link
* android.renderscript.Allocation}. An Element is roughly equivalent to a C
@@ -1146,6 +1148,7 @@
* @param dt The DataType for the new element.
* @return Element
*/
+ @UnsupportedAppUsage
static Element createUser(RenderScript rs, DataType dt) {
DataKind dk = DataKind.USER;
boolean norm = false;
diff --git a/rs/java/android/renderscript/FileA3D.java b/rs/java/android/renderscript/FileA3D.java
index 278d309..9a6b0bc 100644
--- a/rs/java/android/renderscript/FileA3D.java
+++ b/rs/java/android/renderscript/FileA3D.java
@@ -19,6 +19,7 @@
import java.io.File;
import java.io.InputStream;
+import android.annotation.UnsupportedAppUsage;
import android.content.res.AssetManager;
import android.content.res.Resources;
@@ -53,6 +54,7 @@
* @deprecated in API 16
* RenderScript Mesh object
**/
+ @UnsupportedAppUsage
MESH (1);
int mID;
@@ -100,6 +102,7 @@
* @return type of a renderscript object the index entry
* describes
*/
+ @UnsupportedAppUsage
public EntryType getEntryType() {
return mEntryType;
}
@@ -109,6 +112,7 @@
* Used to load the object described by the index entry
* @return base renderscript object described by the entry
*/
+ @UnsupportedAppUsage
public BaseObj getObject() {
mRS.validate();
BaseObj obj = internalCreate(mRS, this);
@@ -212,6 +216,7 @@
*
* @return entry in the a3d file described by the index
*/
+ @UnsupportedAppUsage
public IndexEntry getIndexEntry(int index) {
if(getIndexEntryCount() == 0 || index < 0 || index >= mFileEntries.length) {
return null;
@@ -284,6 +289,7 @@
*
* @return a3d file containing renderscript objects
*/
+ @UnsupportedAppUsage
static public FileA3D createFromResource(RenderScript rs, Resources res, int id) {
rs.validate();
diff --git a/rs/java/android/renderscript/Font.java b/rs/java/android/renderscript/Font.java
index d5ca31e..583350e 100644
--- a/rs/java/android/renderscript/Font.java
+++ b/rs/java/android/renderscript/Font.java
@@ -23,6 +23,7 @@
import android.os.Environment;
+import android.annotation.UnsupportedAppUsage;
import android.content.res.AssetManager;
import android.content.res.Resources;
@@ -85,6 +86,7 @@
/**
* @deprecated in API 16
*/
+ @UnsupportedAppUsage
ITALIC,
/**
* @deprecated in API 16
@@ -236,6 +238,7 @@
*
* Returns default font if no match could be found.
*/
+ @UnsupportedAppUsage
static public Font create(RenderScript rs, Resources res, String familyName, Style fontStyle, float pointSize) {
String fileName = getFontFileName(familyName, fontStyle);
String fontPath = Environment.getRootDirectory().getAbsolutePath();
diff --git a/rs/java/android/renderscript/Matrix4f.java b/rs/java/android/renderscript/Matrix4f.java
index 5d5bf5f..026c9fb 100644
--- a/rs/java/android/renderscript/Matrix4f.java
+++ b/rs/java/android/renderscript/Matrix4f.java
@@ -16,6 +16,7 @@
package android.renderscript;
+import android.annotation.UnsupportedAppUsage;
import java.lang.Math;
@@ -489,5 +490,6 @@
}
}
+ @UnsupportedAppUsage
final float[] mMat;
}
diff --git a/rs/java/android/renderscript/Mesh.java b/rs/java/android/renderscript/Mesh.java
index 9e4f905..5321dcb 100644
--- a/rs/java/android/renderscript/Mesh.java
+++ b/rs/java/android/renderscript/Mesh.java
@@ -16,6 +16,7 @@
package android.renderscript;
+import android.annotation.UnsupportedAppUsage;
import java.util.Vector;
/**
@@ -49,6 +50,7 @@
* @deprecated in API 16
* Vertex data will be rendered as a series of points
*/
+ @UnsupportedAppUsage
POINT (0),
/**
* @deprecated in API 16
@@ -64,6 +66,7 @@
* @deprecated in API 16
* Vertices will be rendered as individual triangles
*/
+ @UnsupportedAppUsage
TRIANGLE (3),
/**
* @deprecated in API 16
@@ -111,6 +114,7 @@
* @return vertex data allocation at the given index
*
**/
+ @UnsupportedAppUsage
public Allocation getVertexAllocation(int slot) {
return mVertexBuffers[slot];
}
@@ -424,6 +428,7 @@
/**
* @deprecated in API 16
**/
+ @UnsupportedAppUsage
public AllocationBuilder(RenderScript rs) {
mRS = rs;
mVertexTypeCount = 0;
@@ -458,6 +463,7 @@
*
* @return this
**/
+ @UnsupportedAppUsage
public AllocationBuilder addVertexAllocation(Allocation a) throws IllegalStateException {
if (mVertexTypeCount >= mVertexTypes.length) {
throw new IllegalStateException("Max vertex types exceeded.");
@@ -479,6 +485,7 @@
*
* @return this
**/
+ @UnsupportedAppUsage
public AllocationBuilder addIndexSetAllocation(Allocation a, Primitive p) {
Entry indexType = new Entry();
indexType.a = a;
@@ -495,6 +502,7 @@
*
* @return this
**/
+ @UnsupportedAppUsage
public AllocationBuilder addIndexSetType(Primitive p) {
Entry indexType = new Entry();
indexType.a = null;
@@ -508,6 +516,7 @@
* Create a Mesh object from the current state of the builder
*
**/
+ @UnsupportedAppUsage
public Mesh create() {
mRS.validate();
@@ -596,6 +605,7 @@
* channels are present in the mesh
*
**/
+ @UnsupportedAppUsage
public TriangleMeshBuilder(RenderScript rs, int vtxSize, int flags) {
mRS = rs;
mVtxCount = 0;
@@ -652,6 +662,7 @@
* @return this
*
**/
+ @UnsupportedAppUsage
public TriangleMeshBuilder addVertex(float x, float y) {
if (mVtxSize != 2) {
throw new IllegalStateException("add mistmatch with declared components.");
@@ -757,6 +768,7 @@
*
* @return this
**/
+ @UnsupportedAppUsage
public TriangleMeshBuilder addTriangle(int idx1, int idx2, int idx3) {
if((idx1 >= mMaxIndex) || (idx1 < 0) ||
(idx2 >= mMaxIndex) || (idx2 < 0) ||
@@ -789,6 +801,7 @@
* accessible memory
*
**/
+ @UnsupportedAppUsage
public Mesh create(boolean uploadToBufferObject) {
Element.Builder b = new Element.Builder(mRS);
b.add(Element.createVector(mRS,
diff --git a/rs/java/android/renderscript/Program.java b/rs/java/android/renderscript/Program.java
index 772021c..e28d646 100644
--- a/rs/java/android/renderscript/Program.java
+++ b/rs/java/android/renderscript/Program.java
@@ -21,6 +21,7 @@
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
+import android.annotation.UnsupportedAppUsage;
import android.content.res.Resources;
import android.util.Log;
@@ -45,6 +46,7 @@
*
**/
public enum TextureType {
+ @UnsupportedAppUsage
TEXTURE_2D (0),
TEXTURE_CUBE (1);
@@ -199,20 +201,30 @@
public static class BaseProgramBuilder {
+ @UnsupportedAppUsage
RenderScript mRS;
+ @UnsupportedAppUsage
Element mInputs[];
+ @UnsupportedAppUsage
Element mOutputs[];
+ @UnsupportedAppUsage
Type mConstants[];
Type mTextures[];
TextureType mTextureTypes[];
String mTextureNames[];
+ @UnsupportedAppUsage
int mInputCount;
+ @UnsupportedAppUsage
int mOutputCount;
+ @UnsupportedAppUsage
int mConstantCount;
+ @UnsupportedAppUsage
int mTextureCount;
+ @UnsupportedAppUsage
String mShader;
+ @UnsupportedAppUsage
protected BaseProgramBuilder(RenderScript rs) {
mRS = rs;
mInputs = new Element[MAX_INPUT];
diff --git a/rs/java/android/renderscript/ProgramFragment.java b/rs/java/android/renderscript/ProgramFragment.java
index 5f71bd1..3dde9b6 100644
--- a/rs/java/android/renderscript/ProgramFragment.java
+++ b/rs/java/android/renderscript/ProgramFragment.java
@@ -16,6 +16,8 @@
package android.renderscript;
+import android.annotation.UnsupportedAppUsage;
+
/**
* @hide
@@ -50,6 +52,7 @@
*
* @param rs Context to which the program will belong.
*/
+ @UnsupportedAppUsage
public Builder(RenderScript rs) {
super(rs);
}
@@ -60,6 +63,7 @@
*
* @return ProgramFragment
*/
+ @UnsupportedAppUsage
public ProgramFragment create() {
mRS.validate();
long[] tmp = new long[(mInputCount + mOutputCount + mConstantCount + mTextureCount) * 2];
diff --git a/rs/java/android/renderscript/ProgramFragmentFixedFunction.java b/rs/java/android/renderscript/ProgramFragmentFixedFunction.java
index 2b647c76..d05d41d 100644
--- a/rs/java/android/renderscript/ProgramFragmentFixedFunction.java
+++ b/rs/java/android/renderscript/ProgramFragmentFixedFunction.java
@@ -16,6 +16,8 @@
package android.renderscript;
+import android.annotation.UnsupportedAppUsage;
+
/**
* @hide
@@ -102,10 +104,12 @@
/**
* @deprecated in API 16
**/
+ @UnsupportedAppUsage
REPLACE (1),
/**
* @deprecated in API 16
**/
+ @UnsupportedAppUsage
MODULATE (2),
/**
* @deprecated in API 16
@@ -128,6 +132,7 @@
/**
* @deprecated in API 16
**/
+ @UnsupportedAppUsage
ALPHA (1),
/**
* @deprecated in API 16
@@ -136,10 +141,12 @@
/**
* @deprecated in API 16
**/
+ @UnsupportedAppUsage
RGB (3),
/**
* @deprecated in API 16
**/
+ @UnsupportedAppUsage
RGBA (4);
int mID;
@@ -228,6 +235,7 @@
*
* @param rs Context to which the program will belong.
*/
+ @UnsupportedAppUsage
public Builder(RenderScript rs) {
mRS = rs;
mSlots = new Slot[MAX_TEXTURE];
@@ -248,6 +256,7 @@
*
* @return this
*/
+ @UnsupportedAppUsage
public Builder setTexture(EnvMode env, Format fmt, int slot)
throws IllegalArgumentException {
if((slot < 0) || (slot >= MAX_TEXTURE)) {
@@ -277,6 +286,7 @@
* fragment shader
*
**/
+ @UnsupportedAppUsage
public Builder setVaryingColor(boolean enable) {
mVaryingColorEnable = enable;
return this;
@@ -288,6 +298,7 @@
* state of the builder.
*
*/
+ @UnsupportedAppUsage
public ProgramFragmentFixedFunction create() {
InternalBuilder sb = new InternalBuilder(mRS);
mNumTextures = 0;
diff --git a/rs/java/android/renderscript/ProgramRaster.java b/rs/java/android/renderscript/ProgramRaster.java
index 8c7c9aa..33000ac 100644
--- a/rs/java/android/renderscript/ProgramRaster.java
+++ b/rs/java/android/renderscript/ProgramRaster.java
@@ -16,6 +16,8 @@
package android.renderscript;
+import android.annotation.UnsupportedAppUsage;
+
/**
* @hide
@@ -124,6 +126,7 @@
/**
* @deprecated in API 16
*/
+ @UnsupportedAppUsage
public Builder(RenderScript rs) {
mRS = rs;
mPointSprite = false;
@@ -133,6 +136,7 @@
/**
* @deprecated in API 16
*/
+ @UnsupportedAppUsage
public Builder setPointSpriteEnabled(boolean enable) {
mPointSprite = enable;
return this;
@@ -149,6 +153,7 @@
/**
* @deprecated in API 16
*/
+ @UnsupportedAppUsage
public ProgramRaster create() {
mRS.validate();
long id = mRS.nProgramRasterCreate(mPointSprite, mCullMode.mID);
diff --git a/rs/java/android/renderscript/ProgramStore.java b/rs/java/android/renderscript/ProgramStore.java
index c0fa9c4..622fe21 100644
--- a/rs/java/android/renderscript/ProgramStore.java
+++ b/rs/java/android/renderscript/ProgramStore.java
@@ -16,6 +16,8 @@
package android.renderscript;
+import android.annotation.UnsupportedAppUsage;
+
/**
* @hide
@@ -45,11 +47,13 @@
/**
* Always drawn
*/
+ @UnsupportedAppUsage
ALWAYS (0),
/**
* Drawn if the incoming depth value is less than that in the
* depth buffer
*/
+ @UnsupportedAppUsage
LESS (1),
/**
* Drawn if the incoming depth value is less or equal to that in
@@ -93,9 +97,11 @@
*/
public enum BlendSrcFunc {
ZERO (0),
+ @UnsupportedAppUsage
ONE (1),
DST_COLOR (2),
ONE_MINUS_DST_COLOR (3),
+ @UnsupportedAppUsage
SRC_ALPHA (4),
ONE_MINUS_SRC_ALPHA (5),
DST_ALPHA (6),
@@ -118,11 +124,14 @@
*
*/
public enum BlendDstFunc {
+ @UnsupportedAppUsage
ZERO (0),
+ @UnsupportedAppUsage
ONE (1),
SRC_COLOR (2),
ONE_MINUS_SRC_COLOR (3),
SRC_ALPHA (4),
+ @UnsupportedAppUsage
ONE_MINUS_SRC_ALPHA (5),
DST_ALPHA (6),
ONE_MINUS_DST_ALPHA (7);
@@ -299,6 +308,7 @@
*
* @param rs Context to which the program will belong.
**/
+ @UnsupportedAppUsage
public static ProgramStore BLEND_ALPHA_DEPTH_NONE(RenderScript rs) {
if(rs.mProgramStore_BLEND_ALPHA_DEPTH_NO_DEPTH == null) {
ProgramStore.Builder builder = new ProgramStore.Builder(rs);
@@ -328,6 +338,7 @@
BlendDstFunc mBlendDst;
boolean mDither;
+ @UnsupportedAppUsage
public Builder(RenderScript rs) {
mRS = rs;
mDepthFunc = DepthFunc.ALWAYS;
@@ -347,6 +358,7 @@
*
* @return this
*/
+ @UnsupportedAppUsage
public Builder setDepthFunc(DepthFunc func) {
mDepthFunc = func;
return this;
@@ -360,6 +372,7 @@
*
* @return this
*/
+ @UnsupportedAppUsage
public Builder setDepthMaskEnabled(boolean enable) {
mDepthMask = enable;
return this;
@@ -394,6 +407,7 @@
*
* @return this
*/
+ @UnsupportedAppUsage
public Builder setBlendFunc(BlendSrcFunc src, BlendDstFunc dst) {
mBlendSrc = src;
mBlendDst = dst;
@@ -408,6 +422,7 @@
*
* @return this
*/
+ @UnsupportedAppUsage
public Builder setDitherEnabled(boolean enable) {
mDither = enable;
return this;
@@ -416,6 +431,7 @@
/**
* Creates a program store from the current state of the builder
*/
+ @UnsupportedAppUsage
public ProgramStore create() {
mRS.validate();
long id = mRS.nProgramStoreCreate(mColorMaskR, mColorMaskG, mColorMaskB, mColorMaskA,
diff --git a/rs/java/android/renderscript/ProgramVertex.java b/rs/java/android/renderscript/ProgramVertex.java
index 0d7e2d9..83d9ea7 100644
--- a/rs/java/android/renderscript/ProgramVertex.java
+++ b/rs/java/android/renderscript/ProgramVertex.java
@@ -38,6 +38,8 @@
**/
package android.renderscript;
+import android.annotation.UnsupportedAppUsage;
+
/**
* @hide
@@ -90,6 +92,7 @@
*
* @param rs Context to which the program will belong.
*/
+ @UnsupportedAppUsage
public Builder(RenderScript rs) {
super(rs);
}
@@ -102,6 +105,7 @@
* structure
* @return self
*/
+ @UnsupportedAppUsage
public Builder addInput(Element e) throws IllegalStateException {
// Should check for consistant and non-conflicting names...
if(mInputCount >= MAX_INPUT) {
@@ -120,6 +124,7 @@
*
* @return ProgramVertex
*/
+ @UnsupportedAppUsage
public ProgramVertex create() {
mRS.validate();
long[] tmp = new long[(mInputCount + mOutputCount + mConstantCount + mTextureCount) * 2];
diff --git a/rs/java/android/renderscript/ProgramVertexFixedFunction.java b/rs/java/android/renderscript/ProgramVertexFixedFunction.java
index 45840ae..579d3bb 100644
--- a/rs/java/android/renderscript/ProgramVertexFixedFunction.java
+++ b/rs/java/android/renderscript/ProgramVertexFixedFunction.java
@@ -16,6 +16,8 @@
package android.renderscript;
+import android.annotation.UnsupportedAppUsage;
+
/**
* @hide
@@ -38,6 +40,7 @@
*
* @param va allocation containing fixed function matrices
*/
+ @UnsupportedAppUsage
public void bindConstants(Constants va) {
mRS.validate();
bindConstants(va.getAllocation(), 0);
@@ -118,6 +121,7 @@
*
* @param rs Context to which the program will belong.
*/
+ @UnsupportedAppUsage
public Builder(RenderScript rs) {
mRS = rs;
}
@@ -170,6 +174,7 @@
*
* @return Fixed function emulation ProgramVertex
*/
+ @UnsupportedAppUsage
public ProgramVertexFixedFunction create() {
buildShaderString();
@@ -215,6 +220,7 @@
*
* @param rs Context to which the allocation will belong.
**/
+ @UnsupportedAppUsage
public Constants(RenderScript rs) {
Type constInputType = ProgramVertexFixedFunction.Builder.getConstantInputType(rs);
mAlloc = Allocation.createTyped(rs, constInputType);
@@ -268,6 +274,7 @@
*
* @param m projection matrix
*/
+ @UnsupportedAppUsage
public void setProjection(Matrix4f m) {
mProjection.load(m);
addToBuffer(PROJECTION_OFFSET*4, m);
diff --git a/rs/java/android/renderscript/RSSurfaceView.java b/rs/java/android/renderscript/RSSurfaceView.java
index 5db72d9..561373c 100644
--- a/rs/java/android/renderscript/RSSurfaceView.java
+++ b/rs/java/android/renderscript/RSSurfaceView.java
@@ -16,6 +16,7 @@
package android.renderscript;
+import android.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.util.AttributeSet;
import android.view.SurfaceHolder;
@@ -42,6 +43,7 @@
* must call {@link android.opengl.GLSurfaceView#setRenderer} to
* register a renderer.
*/
+ @UnsupportedAppUsage
public RSSurfaceView(Context context) {
super(context);
init();
@@ -54,6 +56,7 @@
* must call {@link android.opengl.GLSurfaceView#setRenderer} to
* register a renderer.
*/
+ @UnsupportedAppUsage
public RSSurfaceView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java
index 0f22568..4293157 100644
--- a/rs/java/android/renderscript/RenderScript.java
+++ b/rs/java/android/renderscript/RenderScript.java
@@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import android.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
@@ -103,6 +104,7 @@
* Detect the bitness of the VM to allow FieldPacker to do the right thing.
*/
static native int rsnSystemGetPointerSize();
+ @UnsupportedAppUsage
static int sPointerSize;
static {
@@ -153,6 +155,7 @@
* @return Always return 1
*
*/
+ @UnsupportedAppUsage
public static long getMinorID() {
return 1;
}
@@ -833,6 +836,7 @@
native long rsnScriptCCreate(long con, String resName, String cacheDir,
byte[] script, int length);
+ @UnsupportedAppUsage
synchronized long nScriptCCreate(String resName, String cacheDir, byte[] script, int length) {
validate();
return rsnScriptCCreate(mContext, resName, cacheDir, script, length);
@@ -1158,6 +1162,7 @@
* sendToClient} by scripts from this context.
*
*/
+ @UnsupportedAppUsage
RSMessageHandler mMessageCallback = null;
public void setMessageHandler(RSMessageHandler msg) {
@@ -1232,6 +1237,7 @@
}
}
+ @UnsupportedAppUsage
void validate() {
if (mContext == 0) {
throw new RSInvalidStateException("Calling RS with no Context active.");
@@ -1495,6 +1501,7 @@
* @param sdkVersion The target SDK Version.
* @return RenderScript
*/
+ @UnsupportedAppUsage
public static RenderScript create(Context ctx, int sdkVersion) {
return create(ctx, sdkVersion, ContextType.NORMAL, CREATE_FLAG_NONE);
}
@@ -1508,6 +1515,7 @@
* @param flags The OR of the CREATE_FLAG_* options desired
* @return RenderScript
*/
+ @UnsupportedAppUsage
private static RenderScript create(Context ctx, int sdkVersion, ContextType ct, int flags) {
if (sdkVersion < 23) {
return internalCreate(ctx, sdkVersion, ct, flags);
diff --git a/rs/java/android/renderscript/RenderScriptCacheDir.java b/rs/java/android/renderscript/RenderScriptCacheDir.java
index 95a9d75..1797bef 100644
--- a/rs/java/android/renderscript/RenderScriptCacheDir.java
+++ b/rs/java/android/renderscript/RenderScriptCacheDir.java
@@ -16,6 +16,7 @@
package android.renderscript;
+import android.annotation.UnsupportedAppUsage;
import java.io.File;
/**
@@ -30,11 +31,13 @@
* @hide
* @param cacheDir A directory the current process can write to
*/
+ @UnsupportedAppUsage
public static void setupDiskCache(File cacheDir) {
// Defer creation of cache path to nScriptCCreate().
mCacheDir = cacheDir;
}
+ @UnsupportedAppUsage
static File mCacheDir;
}
diff --git a/rs/java/android/renderscript/RenderScriptGL.java b/rs/java/android/renderscript/RenderScriptGL.java
index be1f899..6fac83e 100644
--- a/rs/java/android/renderscript/RenderScriptGL.java
+++ b/rs/java/android/renderscript/RenderScriptGL.java
@@ -16,6 +16,7 @@
package android.renderscript;
+import android.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.view.Surface;
@@ -65,6 +66,7 @@
/**
* @deprecated in API 16
*/
+ @UnsupportedAppUsage
public SurfaceConfig() {
}
@@ -132,6 +134,7 @@
* @param minimum
* @param preferred
*/
+ @UnsupportedAppUsage
public void setDepth(int minimum, int preferred) {
validateRange(minimum, preferred, 0, 24);
mDepthMin = minimum;
@@ -169,6 +172,7 @@
* @param ctx The context.
* @param sc The desired format of the primary rendering surface.
*/
+ @UnsupportedAppUsage
public RenderScriptGL(Context ctx, SurfaceConfig sc) {
super(ctx);
mSurfaceConfig = new SurfaceConfig(sc);
@@ -202,6 +206,7 @@
* @param h
* @param sur
*/
+ @UnsupportedAppUsage
public void setSurface(SurfaceHolder sur, int w, int h) {
validate();
Surface s = null;
@@ -281,6 +286,7 @@
*
* @param s Graphics script to process rendering requests.
*/
+ @UnsupportedAppUsage
public void bindRootScript(Script s) {
validate();
nContextBindRootScript((int)safeID(s));
@@ -293,6 +299,7 @@
*
* @param p
*/
+ @UnsupportedAppUsage
public void bindProgramStore(ProgramStore p) {
validate();
nContextBindProgramStore((int)safeID(p));
@@ -317,6 +324,7 @@
*
* @param p
*/
+ @UnsupportedAppUsage
public void bindProgramRaster(ProgramRaster p) {
validate();
nContextBindProgramRaster((int)safeID(p));
@@ -329,6 +337,7 @@
*
* @param p
*/
+ @UnsupportedAppUsage
public void bindProgramVertex(ProgramVertex p) {
validate();
nContextBindProgramVertex((int)safeID(p));
diff --git a/rs/java/android/renderscript/Script.java b/rs/java/android/renderscript/Script.java
index d0d9a11..9ad9aea 100644
--- a/rs/java/android/renderscript/Script.java
+++ b/rs/java/android/renderscript/Script.java
@@ -16,6 +16,7 @@
package android.renderscript;
+import android.annotation.UnsupportedAppUsage;
import android.util.SparseArray;
/**
@@ -475,8 +476,10 @@
*
*/
public static class Builder {
+ @UnsupportedAppUsage
RenderScript mRS;
+ @UnsupportedAppUsage
Builder(RenderScript rs) {
mRS = rs;
}
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
index 9c0e110..acbb67c 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -701,6 +701,7 @@
public int addAccessibilityInteractionConnection(IWindow windowToken,
IAccessibilityInteractionConnection connection, String packageName,
int userId) throws RemoteException {
+ final int windowId;
synchronized (mLock) {
// We treat calls from a profile as if made by its parent as profiles
// share the accessibility state of the parent. The call below
@@ -713,7 +714,7 @@
packageName = mSecurityPolicy.resolveValidReportedPackageLocked(
packageName, UserHandle.getCallingAppId(), resolvedUserId);
- final int windowId = sNextWindowId++;
+ windowId = sNextWindowId++;
// If the window is from a process that runs across users such as
// the system UI or the system we add it to the global state that
// is shared across users.
@@ -741,8 +742,10 @@
+ " and token: " + windowToken.asBinder());
}
}
- return windowId;
}
+ WindowManagerInternal wm = LocalServices.getService(WindowManagerInternal.class);
+ wm.computeWindowsForAccessibility();
+ return windowId;
}
@Override
diff --git a/services/accessibility/java/com/android/server/accessibility/TouchExplorer.java b/services/accessibility/java/com/android/server/accessibility/TouchExplorer.java
index 2cae060..1229c58 100644
--- a/services/accessibility/java/com/android/server/accessibility/TouchExplorer.java
+++ b/services/accessibility/java/com/android/server/accessibility/TouchExplorer.java
@@ -572,6 +572,8 @@
}
}
+ // Remove move history before send injected non-move events
+ event = MotionEvent.obtainNoHistory(event);
if (isDraggingGesture(event)) {
// Two pointers moving in the same direction within
// a given distance perform a drag.
@@ -602,6 +604,7 @@
// More than two pointers are delegated to the view hierarchy.
mCurrentState = STATE_DELEGATING;
+ event = MotionEvent.obtainNoHistory(event);
sendDownForAllNotInjectedPointers(event, policyFlags);
}
}
@@ -690,6 +693,8 @@
// The two pointers are moving either in different directions or
// no close enough => delegate the gesture to the view hierarchy.
mCurrentState = STATE_DELEGATING;
+ // Remove move history before send injected non-move events
+ event = MotionEvent.obtainNoHistory(event);
// Send an event to the end of the drag gesture.
sendMotionEvent(event, MotionEvent.ACTION_UP, pointerIdBits,
policyFlags);
@@ -699,6 +704,7 @@
} break;
default: {
mCurrentState = STATE_DELEGATING;
+ event = MotionEvent.obtainNoHistory(event);
// Send an event to the end of the drag gesture.
sendMotionEvent(event, MotionEvent.ACTION_UP, pointerIdBits,
policyFlags);
diff --git a/services/art-profile b/services/art-profile
index 24964f3..cbc00ea 100644
--- a/services/art-profile
+++ b/services/art-profile
@@ -9258,24 +9258,24 @@
PLcom/android/server/backup/internal/BackupState;-><init>(Ljava/lang/String;I)V
PLcom/android/server/backup/internal/BackupState;->values()[Lcom/android/server/backup/internal/BackupState;
PLcom/android/server/backup/internal/Operation;-><init>(ILcom/android/server/backup/BackupRestoreTask;I)V
-PLcom/android/server/backup/internal/KeyValueBackupTask;-><init>(Lcom/android/server/backup/BackupManagerService;Lcom/android/server/backup/transport/TransportClient;Ljava/lang/String;Ljava/util/List;Lcom/android/server/backup/DataChangedJournal;Landroid/app/backup/IBackupObserver;Landroid/app/backup/IBackupManagerMonitor;Lcom/android/server/backup/internal/OnTaskFinishedListener;Ljava/util/List;ZZ)V
-PLcom/android/server/backup/internal/KeyValueBackupTask;->backupPm()V
-PLcom/android/server/backup/internal/KeyValueBackupTask;->beginBackup()V
-PLcom/android/server/backup/internal/KeyValueBackupTask;->clearAgentState()V
-PLcom/android/server/backup/internal/KeyValueBackupTask;->execute()V
-PLcom/android/server/backup/internal/KeyValueBackupTask;->executeNextState(Lcom/android/server/backup/internal/BackupState;)V
-PLcom/android/server/backup/internal/KeyValueBackupTask;->finalizeBackup()V
-PLcom/android/server/backup/internal/KeyValueBackupTask;->invokeAgentForBackup(Ljava/lang/String;Landroid/app/IBackupAgent;)I
-PLcom/android/server/backup/internal/KeyValueBackupTask;->invokeNextAgent()V
-PLcom/android/server/backup/internal/KeyValueBackupTask;->operationComplete(J)V
-PLcom/android/server/backup/internal/KeyValueBackupTask;->registerTask()V
-PLcom/android/server/backup/internal/KeyValueBackupTask;->revertAndEndBackup()V
-PLcom/android/server/backup/internal/KeyValueBackupTask;->unregisterTask()V
-PLcom/android/server/backup/internal/KeyValueBackupTask;->writeWidgetPayloadIfAppropriate(Ljava/io/FileDescriptor;Ljava/lang/String;)V
PLcom/android/server/backup/internal/ProvisionedObserver;-><init>(Lcom/android/server/backup/BackupManagerService;Landroid/os/Handler;)V
PLcom/android/server/backup/internal/RunBackupReceiver;-><init>(Lcom/android/server/backup/BackupManagerService;)V
PLcom/android/server/backup/internal/RunBackupReceiver;->onReceive(Landroid/content/Context;Landroid/content/Intent;)V
PLcom/android/server/backup/internal/RunInitializeReceiver;-><init>(Lcom/android/server/backup/BackupManagerService;)V
+PLcom/android/server/backup/keyvalue/KeyValueBackupTask;-><init>(Lcom/android/server/backup/BackupManagerService;Lcom/android/server/backup/transport/TransportClient;Ljava/lang/String;Ljava/util/List;Lcom/android/server/backup/DataChangedJournal;Landroid/app/backup/IBackupObserver;Landroid/app/backup/IBackupManagerMonitor;Lcom/android/server/backup/internal/OnTaskFinishedListener;Ljava/util/List;ZZ)V
+PLcom/android/server/backup/keyvalue/KeyValueBackupTask;->backupPm()V
+PLcom/android/server/backup/keyvalue/KeyValueBackupTask;->beginBackup()V
+PLcom/android/server/backup/keyvalue/KeyValueBackupTask;->clearAgentState()V
+PLcom/android/server/backup/keyvalue/KeyValueBackupTask;->execute()V
+PLcom/android/server/backup/keyvalue/KeyValueBackupTask;->executeNextState(Lcom/android/server/backup/internal/BackupState;)V
+PLcom/android/server/backup/keyvalue/KeyValueBackupTask;->finalizeBackup()V
+PLcom/android/server/backup/keyvalue/KeyValueBackupTask;->invokeAgentForBackup(Ljava/lang/String;Landroid/app/IBackupAgent;)I
+PLcom/android/server/backup/keyvalue/KeyValueBackupTask;->invokeNextAgent()V
+PLcom/android/server/backup/keyvalue/KeyValueBackupTask;->operationComplete(J)V
+PLcom/android/server/backup/keyvalue/KeyValueBackupTask;->registerTask()V
+PLcom/android/server/backup/keyvalue/KeyValueBackupTask;->revertAndEndBackup()V
+PLcom/android/server/backup/keyvalue/KeyValueBackupTask;->unregisterTask()V
+PLcom/android/server/backup/keyvalue/KeyValueBackupTask;->writeWidgetPayloadIfAppropriate(Ljava/io/FileDescriptor;Ljava/lang/String;)V
PLcom/android/server/backup/transport/-$$Lambda$TransportClient$ciIUj0x0CRg93UETUpy2FB5aqCQ;-><init>(Lcom/android/server/backup/transport/TransportClient;Lcom/android/server/backup/transport/TransportConnectionListener;Lcom/android/internal/backup/IBackupTransport;)V
PLcom/android/server/backup/transport/-$$Lambda$TransportClient$ciIUj0x0CRg93UETUpy2FB5aqCQ;->run()V
PLcom/android/server/backup/transport/-$$Lambda$TransportClient$uc3fygwQjQIS_JT7mlt-yMBfJcE;-><init>(Ljava/util/concurrent/CompletableFuture;)V
diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java
index ec27da9..c26ac17 100644
--- a/services/backup/java/com/android/server/backup/BackupManagerService.java
+++ b/services/backup/java/com/android/server/backup/BackupManagerService.java
@@ -104,7 +104,7 @@
import com.android.server.backup.fullbackup.FullBackupEntry;
import com.android.server.backup.fullbackup.PerformFullTransportBackupTask;
import com.android.server.backup.internal.BackupHandler;
-import com.android.server.backup.internal.BackupRequest;
+import com.android.server.backup.keyvalue.BackupRequest;
import com.android.server.backup.internal.ClearDataObserver;
import com.android.server.backup.internal.OnTaskFinishedListener;
import com.android.server.backup.internal.Operation;
diff --git a/services/backup/java/com/android/server/backup/internal/BackupHandler.java b/services/backup/java/com/android/server/backup/internal/BackupHandler.java
index 6e96fe0..2722729 100644
--- a/services/backup/java/com/android/server/backup/internal/BackupHandler.java
+++ b/services/backup/java/com/android/server/backup/internal/BackupHandler.java
@@ -41,6 +41,8 @@
import com.android.server.backup.TransportManager;
import com.android.server.backup.fullbackup.PerformAdbBackupTask;
import com.android.server.backup.fullbackup.PerformFullTransportBackupTask;
+import com.android.server.backup.keyvalue.BackupRequest;
+import com.android.server.backup.keyvalue.KeyValueBackupTask;
import com.android.server.backup.params.AdbBackupParams;
import com.android.server.backup.params.AdbParams;
import com.android.server.backup.params.AdbRestoreParams;
diff --git a/services/backup/java/com/android/server/backup/internal/BackupState.java b/services/backup/java/com/android/server/backup/internal/BackupState.java
deleted file mode 100644
index 320b555..0000000
--- a/services/backup/java/com/android/server/backup/internal/BackupState.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.android.server.backup.internal;
-
-/**
- * Current state of the backup.
- */
-enum BackupState {
- INITIAL,
- BACKUP_PM,
- RUNNING_QUEUE,
- CANCELLED,
- FINAL
-}
diff --git a/services/backup/java/com/android/server/backup/internal/BackupRequest.java b/services/backup/java/com/android/server/backup/keyvalue/BackupRequest.java
similarity index 96%
rename from services/backup/java/com/android/server/backup/internal/BackupRequest.java
rename to services/backup/java/com/android/server/backup/keyvalue/BackupRequest.java
index 01e4385..67b2f72 100644
--- a/services/backup/java/com/android/server/backup/internal/BackupRequest.java
+++ b/services/backup/java/com/android/server/backup/keyvalue/BackupRequest.java
@@ -14,7 +14,7 @@
* limitations under the License
*/
-package com.android.server.backup.internal;
+package com.android.server.backup.keyvalue;
import java.util.Objects;
diff --git a/services/backup/java/com/android/server/backup/internal/KeyValueBackupTask.java b/services/backup/java/com/android/server/backup/keyvalue/KeyValueBackupTask.java
similarity index 95%
rename from services/backup/java/com/android/server/backup/internal/KeyValueBackupTask.java
rename to services/backup/java/com/android/server/backup/keyvalue/KeyValueBackupTask.java
index a4d7bd1..113e2b6 100644
--- a/services/backup/java/com/android/server/backup/internal/KeyValueBackupTask.java
+++ b/services/backup/java/com/android/server/backup/keyvalue/KeyValueBackupTask.java
@@ -14,7 +14,7 @@
* limitations under the License
*/
-package com.android.server.backup.internal;
+package com.android.server.backup.keyvalue;
import static com.android.server.backup.BackupManagerService.DEBUG_BACKUP_TRACE;
import static com.android.server.backup.BackupManagerService.KEY_WIDGET_STATE;
@@ -62,6 +62,8 @@
import com.android.server.backup.DataChangedJournal;
import com.android.server.backup.KeyValueBackupJob;
import com.android.server.backup.fullbackup.PerformFullTransportBackupTask;
+import com.android.server.backup.internal.OnTaskFinishedListener;
+import com.android.server.backup.internal.Operation;
import com.android.server.backup.remote.RemoteCall;
import com.android.server.backup.remote.RemoteCallable;
import com.android.server.backup.remote.RemoteResult;
@@ -395,7 +397,7 @@
synchronized (mBackupManagerService.getCurrentOpLock()) {
if (mBackupManagerService.isBackupOperationInProgress()) {
if (DEBUG) {
- Slog.d(TAG, "Skipping backup since one is already in progress.");
+ Slog.d(TAG, "Skipping backup since one is already in progress");
}
mBackupManagerService.addBackupTrace("Skipped. Backup already in progress.");
return BackupState.FINAL;
@@ -424,7 +426,7 @@
// Sanity check: if the queue is empty we have no work to do.
if (mOriginalQueue.isEmpty() && mPendingFullBackups.isEmpty()) {
- Slog.w(TAG, "Backup begun with an empty queue - nothing to do.");
+ Slog.w(TAG, "Backup begun with an empty queue, nothing to do.");
mBackupManagerService.addBackupTrace("queue empty at begin");
return BackupState.FINAL;
}
@@ -440,7 +442,7 @@
for (int i = 0; i < mQueue.size(); i++) {
if (PACKAGE_MANAGER_SENTINEL.equals(mQueue.get(i).packageName)) {
if (MORE_DEBUG) {
- Slog.i(TAG, "Metadata in queue; eliding");
+ Slog.i(TAG, "PM metadata in queue, removing");
}
mQueue.remove(i);
skipPm = false;
@@ -459,7 +461,7 @@
// If we haven't stored package manager metadata yet, we must init the transport.
if (pmState.length() <= 0) {
- Slog.i(TAG, "Initializing (wiping) backup state and transport storage");
+ Slog.i(TAG, "Initializing transport and resetting backup state");
mBackupManagerService.addBackupTrace("initializing transport " + transportName);
mBackupManagerService.resetBackupState(mStateDir); // Just to make sure.
mStatus = transport.initializeDevice();
@@ -473,7 +475,7 @@
}
}
} catch (Exception e) {
- Slog.e(TAG, "Error in backup thread during init", e);
+ Slog.e(TAG, "Error during initialization", e);
mBackupManagerService.addBackupTrace("Exception in backup thread during init: " + e);
mStatus = BackupTransport.TRANSPORT_ERROR;
}
@@ -487,7 +489,7 @@
}
if (skipPm) {
- Slog.d(TAG, "Skipping backup of package metadata.");
+ Slog.d(TAG, "Skipping backup of PM metadata");
return BackupState.RUNNING_QUEUE;
}
@@ -509,9 +511,9 @@
mStatus = statusAndResult.first;
agentResult = statusAndResult.second;
- mBackupManagerService.addBackupTrace("PMBA invoke: " + mStatus);
+ mBackupManagerService.addBackupTrace("PM agent invoke: " + mStatus);
} catch (Exception e) {
- Slog.e(TAG, "Error in backup thread during pm", e);
+ Slog.e(TAG, "Error during PM metadata backup", e);
mBackupManagerService.addBackupTrace("Exception in backup thread during pm: " + e);
mStatus = BackupTransport.TRANSPORT_ERROR;
}
@@ -545,15 +547,16 @@
// Sanity check that we have work to do. If not, skip to the end where
// we reestablish the wakelock invariants etc.
if (mQueue.isEmpty()) {
- if (MORE_DEBUG) Slog.i(TAG, "queue now empty");
+ if (MORE_DEBUG) {
+ Slog.i(TAG, "Queue now empty");
+ }
return Pair.create(BackupState.FINAL, null);
}
// pop the entry we're going to process on this step
- BackupRequest request = mQueue.get(0);
- mQueue.remove(0);
+ BackupRequest request = mQueue.remove(0);
- Slog.d(TAG, "starting key/value backup of " + request);
+ Slog.d(TAG, "Starting key-value backup of " + request);
mBackupManagerService.addBackupTrace("launch agent for " + request.packageName);
// Verify that the requested app exists; it might be something that
@@ -567,11 +570,10 @@
mCurrentPackage = pm.getPackageInfo(request.packageName,
PackageManager.GET_SIGNING_CERTIFICATES);
if (!AppBackupUtils.appIsEligibleForBackup(mCurrentPackage.applicationInfo, pm)) {
- // The manifest has changed but we had a stale backup request pending.
- // This won't happen again because the app won't be requesting further
- // backups.
+ // The manifest has changed but we had a stale backup request pending. This won't
+ // happen again because the app won't be requesting further backups.
Slog.i(TAG, "Package " + request.packageName
- + " no longer supports backup; skipping");
+ + " no longer supports backup, skipping");
mBackupManagerService.addBackupTrace("skipping - not eligible, completion is noop");
// Shouldn't happen in case of requested backup, as pre-check was done in
// #requestBackup(), except to app update done concurrently
@@ -582,11 +584,11 @@
}
if (AppBackupUtils.appGetsFullBackup(mCurrentPackage)) {
- // It's possible that this app *formerly* was enqueued for key/value backup,
- // but has since been updated and now only supports the full-data path.
- // Don't proceed with a key/value backup for it in this case.
+ // It's possible that this app *formerly* was enqueued for key-value backup, but has
+ // since been updated and now only supports the full-backup path. Don't proceed with
+ // a key-value backup for it in this case.
Slog.i(TAG, "Package " + request.packageName
- + " requests full-data rather than key/value; skipping");
+ + " performs full-backup rather than key-value, skipping");
mBackupManagerService.addBackupTrace(
"skipping - fullBackupOnly, completion is noop");
// Shouldn't happen in case of requested backup, as pre-check was done in
@@ -626,14 +628,14 @@
// Timeout waiting for the agent
mStatus = BackupTransport.AGENT_ERROR;
}
- } catch (SecurityException ex) {
+ } catch (SecurityException se) {
// Try for the next one.
- Slog.d(TAG, "error in bind/backup", ex);
+ Slog.d(TAG, "Error in bind/backup", se);
mStatus = BackupTransport.AGENT_ERROR;
mBackupManagerService.addBackupTrace("agent SE");
}
} catch (PackageManager.NameNotFoundException e) {
- Slog.d(TAG, "Package does not exist; skipping");
+ Slog.d(TAG, "Package does not exist, skipping");
mBackupManagerService.addBackupTrace("no such package");
mStatus = BackupTransport.AGENT_UNKNOWN;
} finally {
@@ -648,7 +650,7 @@
// a later retry, but otherwise proceed normally.
if (mStatus == BackupTransport.AGENT_ERROR) {
if (MORE_DEBUG) {
- Slog.i(TAG, "Agent failure for " + request.packageName + " - restaging");
+ Slog.i(TAG, "Agent failure for " + request.packageName + ", re-staging");
}
mBackupManagerService.dataChangedImpl(request.packageName);
mStatus = BackupTransport.TRANSPORT_OK;
@@ -707,7 +709,7 @@
} catch (Exception e) {
// nothing for it at this point, unfortunately, but this will be
// recorded the next time we fully succeed.
- Slog.e(TAG, "Transport threw reporting restore set: " + e.getMessage());
+ Slog.e(TAG, "Transport threw reporting restore set: " + e);
mBackupManagerService.addBackupTrace("transport threw returning token");
}
}
@@ -717,9 +719,8 @@
synchronized (mBackupManagerService.getQueueLock()) {
mBackupManagerService.setBackupRunning(false);
if (mStatus == BackupTransport.TRANSPORT_NOT_INITIALIZED) {
- // Make sure we back up everything and perform the one-time init
if (MORE_DEBUG) {
- Slog.d(TAG, "Server requires init; rerunning");
+ Slog.d(TAG, "Transport requires initialization, rerunning");
}
mBackupManagerService.addBackupTrace("init required; rerunning");
try {
@@ -727,7 +728,7 @@
.getTransportName(mTransportClient.getTransportComponent());
mBackupManagerService.getPendingInits().add(name);
} catch (Exception e) {
- Slog.w(TAG, "Failed to query transport name for init: " + e.getMessage());
+ Slog.w(TAG, "Failed to query transport name for init: " + e);
// swallow it and proceed; we don't rely on this
}
clearMetadata();
@@ -773,8 +774,7 @@
break;
}
}
- Slog.i(TAG, "K/V backup pass finished.");
- // Only once we're entirely finished do we release the wakelock for k/v backup.
+ Slog.i(TAG, "K/V backup pass finished");
mBackupManagerService.getWakelock().release();
}
@@ -792,7 +792,7 @@
private Pair<Integer, RemoteResult> invokeAgentForBackup(
String packageName, IBackupAgent agent) {
if (DEBUG) {
- Slog.d(TAG, "invokeAgentForBackup on " + packageName);
+ Slog.d(TAG, "Invoking agent on " + packageName);
}
mBackupManagerService.addBackupTrace("invoking " + packageName);
@@ -802,7 +802,7 @@
new File(mBackupManagerService.getDataDir(), packageName + STAGING_FILE_SUFFIX);
mNewStateFile = new File(mStateDir, packageName + NEW_STATE_FILE_SUFFIX);
if (MORE_DEBUG) {
- Slog.d(TAG, "data file: " + mBackupDataFile);
+ Slog.d(TAG, "Data file: " + mBackupDataFile);
}
@@ -865,7 +865,7 @@
transport.getTransportFlags()),
kvBackupAgentTimeoutMillis);
} catch (Exception e) {
- Slog.e(TAG, "Error invoking for backup on " + packageName + ". " + e);
+ Slog.e(TAG, "Error invoking agent on " + packageName + ": " + e);
mBackupManagerService.addBackupTrace("exception: " + e);
EventLog.writeEvent(EventLogTags.BACKUP_AGENT_FAILURE, packageName, e.toString());
errorCleanup();
@@ -901,8 +901,8 @@
}
StringBuffer sb = new StringBuffer(checksum.length * 2);
- for (int i = 0; i < checksum.length; i++) {
- sb.append(Integer.toHexString(checksum[i]));
+ for (byte item : checksum) {
+ sb.append(Integer.toHexString(item));
}
return sb.toString();
}
@@ -910,8 +910,7 @@
private void writeWidgetPayloadIfAppropriate(FileDescriptor fd, String pkgName)
throws IOException {
// TODO: http://b/22388012
- byte[] widgetState = AppWidgetBackupBridge.getWidgetState(pkgName,
- UserHandle.USER_SYSTEM);
+ byte[] widgetState = AppWidgetBackupBridge.getWidgetState(pkgName, UserHandle.USER_SYSTEM);
// has the widget state changed since last time?
final File widgetFile = new File(mStateDir, pkgName + "_widget");
final boolean priorStateExists = widgetFile.exists();
@@ -1007,7 +1006,7 @@
errorCleanup();
if (MORE_DEBUG) {
Slog.i(TAG, "Agent failure for " + pkgName
- + " with illegal key: " + key + "; dropped");
+ + " with illegal key " + key + ", dropped");
}
return BackupState.RUNNING_QUEUE;
@@ -1032,7 +1031,7 @@
try {
Os.ftruncate(fd, filepos);
} catch (ErrnoException ee) {
- Slog.w(TAG, "Unable to roll back!");
+ Slog.w(TAG, "Unable to roll back");
}
}
@@ -1072,7 +1071,7 @@
// incremental, as if the backup is non-incremental there is no state to
// clear. This avoids us ending up in a retry loop if the transport always
// returns this code.
- Slog.w(TAG, "Transport requested non-incremental but already the case, error");
+ Slog.e(TAG, "Transport requested non-incremental but already the case");
mBackupManagerService.addBackupTrace(
"Transport requested non-incremental but already the case, error");
mStatus = BackupTransport.TRANSPORT_ERROR;
@@ -1088,7 +1087,7 @@
}
} else {
if (MORE_DEBUG) {
- Slog.i(TAG, "No backup data written; not calling transport");
+ Slog.i(TAG, "No backup data written, not calling transport");
}
mBackupManagerService.addBackupTrace("no data to send");
mMonitor = BackupManagerMonitorUtils.monitorEvent(mMonitor,
@@ -1162,7 +1161,7 @@
backupData.close();
}
} catch (IOException e) {
- Slog.w(TAG, "Error closing backup data fd");
+ Slog.w(TAG, "Error closing backup data file-descriptor");
}
}
@@ -1186,7 +1185,7 @@
} else if (mStatus == BackupTransport.TRANSPORT_QUOTA_EXCEEDED) {
if (MORE_DEBUG) {
Slog.d(TAG, "Package " + mCurrentPackage.packageName +
- " hit quota limit on k/v backup");
+ " hit quota limit on key-value backup");
}
if (mAgentBinder != null) {
try {
@@ -1278,7 +1277,7 @@
private void revertAndEndBackup() {
if (MORE_DEBUG) {
- Slog.i(TAG, "Reverting backup queue - restaging everything");
+ Slog.i(TAG, "Reverting backup queue, re-staging everything");
}
mBackupManagerService.addBackupTrace("transport error; reverting");
@@ -1290,7 +1289,7 @@
mTransportClient.connectOrThrow("KVBT.revertAndEndBackup()");
delay = transport.requestBackupTime();
} catch (Exception e) {
- Slog.w(TAG, "Unable to contact transport for recommended backoff: " + e.getMessage());
+ Slog.w(TAG, "Unable to contact transport for recommended backoff: " + e);
delay = 0; // use the scheduler's default
}
KeyValueBackupJob.schedule(mBackupManagerService.getContext(), delay,
@@ -1314,21 +1313,21 @@
mSavedState.close();
}
} catch (IOException e) {
- Slog.w(TAG, "Error closing old state fd");
+ Slog.w(TAG, "Error closing old state file-descriptor");
}
try {
if (mBackupData != null) {
mBackupData.close();
}
} catch (IOException e) {
- Slog.w(TAG, "Error closing backup data fd");
+ Slog.w(TAG, "Error closing backup data file-descriptor");
}
try {
if (mNewState != null) {
mNewState.close();
}
} catch (IOException e) {
- Slog.w(TAG, "Error closing new state fd");
+ Slog.w(TAG, "Error closing new state file-descriptor");
}
synchronized (mBackupManagerService.getCurrentOpLock()) {
// Current-operation callback handling requires the validity of these various
@@ -1354,4 +1353,12 @@
mPendingCall = null;
return result;
}
+
+ private enum BackupState {
+ INITIAL,
+ BACKUP_PM,
+ RUNNING_QUEUE,
+ CANCELLED,
+ FINAL
+ }
}
diff --git a/services/core/java/com/android/server/VibratorService.java b/services/core/java/com/android/server/VibratorService.java
index 95e5518..ae3946a 100644
--- a/services/core/java/com/android/server/VibratorService.java
+++ b/services/core/java/com/android/server/VibratorService.java
@@ -66,6 +66,7 @@
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
+import java.util.List;
import java.util.Date;
public class VibratorService extends IVibratorService.Stub
@@ -158,6 +159,7 @@
public final int usageHint;
public final int uid;
public final String opPkg;
+ public final String reason;
// The actual effect to be played.
public VibrationEffect effect;
@@ -167,7 +169,7 @@
public VibrationEffect originalEffect;
private Vibration(IBinder token, VibrationEffect effect,
- int usageHint, int uid, String opPkg) {
+ int usageHint, int uid, String opPkg, String reason) {
this.token = token;
this.effect = effect;
this.startTime = SystemClock.elapsedRealtime();
@@ -175,6 +177,7 @@
this.usageHint = usageHint;
this.uid = uid;
this.opPkg = opPkg;
+ this.reason = reason;
}
public void binderDied() {
@@ -233,7 +236,7 @@
public VibrationInfo toInfo() {
return new VibrationInfo(
- startTimeDebug, effect, originalEffect, usageHint, uid, opPkg);
+ startTimeDebug, effect, originalEffect, usageHint, uid, opPkg, reason);
}
}
@@ -244,15 +247,18 @@
private final int mUsageHint;
private final int mUid;
private final String mOpPkg;
+ private final String mReason;
public VibrationInfo(long startTimeDebug, VibrationEffect effect,
- VibrationEffect originalEffect, int usageHint, int uid, String opPkg) {
+ VibrationEffect originalEffect, int usageHint, int uid,
+ String opPkg, String reason) {
mStartTimeDebug = startTimeDebug;
mEffect = effect;
mOriginalEffect = originalEffect;
mUsageHint = usageHint;
mUid = uid;
mOpPkg = opPkg;
+ mReason = reason;
}
@Override
@@ -270,6 +276,8 @@
.append(mUid)
.append(", opPkg: ")
.append(mOpPkg)
+ .append(", reason: ")
+ .append(mReason)
.toString();
}
}
@@ -482,9 +490,9 @@
}
@Override // Binder call
- public void vibrate(int uid, String opPkg, VibrationEffect effect, int usageHint,
+ public void vibrate(int uid, String opPkg, VibrationEffect effect, int usageHint, String reason,
IBinder token) {
- Trace.traceBegin(Trace.TRACE_TAG_VIBRATOR, "vibrate");
+ Trace.traceBegin(Trace.TRACE_TAG_VIBRATOR, "vibrate, reason = " + reason);
try {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.VIBRATE)
!= PackageManager.PERMISSION_GRANTED) {
@@ -531,10 +539,11 @@
return;
}
- Vibration vib = new Vibration(token, effect, usageHint, uid, opPkg);
+ Vibration vib = new Vibration(token, effect, usageHint, uid, opPkg, reason);
linkVibration(vib);
long ident = Binder.clearCallingIdentity();
try {
+
doCancelVibrateLocked();
startVibrationLocked(vib);
addToPreviousVibrationsLocked(vib);
@@ -1001,8 +1010,8 @@
Slog.w(TAG, "Failed to play prebaked effect, no fallback");
return 0;
}
- Vibration fallbackVib =
- new Vibration(vib.token, effect, vib.usageHint, vib.uid, vib.opPkg);
+ Vibration fallbackVib = new Vibration(vib.token, effect, vib.usageHint, vib.uid,
+ vib.opPkg, vib.reason + " (fallback)");
final int intensity = getCurrentIntensityLocked(fallbackVib);
linkVibration(fallbackVib);
applyVibrationIntensityScalingLocked(fallbackVib, intensity);
@@ -1292,7 +1301,7 @@
VibrationEffect effect =
VibrationEffect.createOneShot(duration, VibrationEffect.DEFAULT_AMPLITUDE);
vibrate(Binder.getCallingUid(), description, effect, AudioAttributes.USAGE_UNKNOWN,
- mToken);
+ "Shell Command", mToken);
return 0;
} finally {
Trace.traceEnd(Trace.TRACE_TAG_VIBRATOR);
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 48d554c..a660040 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -3620,8 +3620,7 @@
mPendingStarts.remove(startSeq);
app.pendingStart = false;
forceStopPackageLocked(app.info.packageName, UserHandle.getAppId(app.uid),
- false, false, true, false, false,
- UserHandle.getUserId(app.userId), "start failure");
+ false, false, true, false, false, app.userId, "start failure");
}
}
});
@@ -3637,8 +3636,7 @@
Slog.e(TAG, "Failure starting process " + app.processName, e);
app.pendingStart = false;
forceStopPackageLocked(app.info.packageName, UserHandle.getAppId(app.uid),
- false, false, true, false, false,
- UserHandle.getUserId(app.userId), "start failure");
+ false, false, true, false, false, app.userId, "start failure");
}
return app.pid > 0;
}
@@ -6019,10 +6017,9 @@
}
// We deprecated Build.SERIAL and it is not accessible to
- // apps that target the v2 security sandbox and to apps that
- // target APIs higher than O MR1. Since access to the serial
+ // Instant Apps and target APIs higher than O MR1. Since access to the serial
// is now behind a permission we push down the value.
- final String buildSerial = (appInfo.targetSandboxVersion < 2
+ final String buildSerial = (!appInfo.isInstantApp()
&& appInfo.targetSdkVersion < Build.VERSION_CODES.P)
? sTheRealBuildSerial : Build.UNKNOWN;
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 54f87ce..fbf2855 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -498,7 +498,7 @@
+ reason);
setResumedActivity(record, reason + " - onActivityStateChanged");
if (record == mStackSupervisor.getTopResumedActivity()) {
- // TODO(b/111541062): Support tracking multiple resumed activities
+ // TODO(b/111361570): Support multiple focused apps in WM
mService.setResumedActivityUncheckLocked(record, reason);
}
mStackSupervisor.mRecentTasks.add(record.getTask());
@@ -3423,7 +3423,15 @@
}
// Move focus to next focusable stack if possible.
- if (adjustFocusToNextFocusableStack(myReason) != null) {
+ final ActivityStack nextFocusableStack = adjustFocusToNextFocusableStack(myReason);
+ if (nextFocusableStack != null) {
+ final ActivityRecord top = nextFocusableStack.topRunningActivityLocked();
+ if (top != null && top == mStackSupervisor.getTopResumedActivity()) {
+ // TODO(b/111361570): Remove this and update focused app per-display in
+ // WindowManager every time an activity becomes resumed in
+ // ActivityTaskManagerService#setResumedActivityUncheckLocked().
+ mService.setResumedActivityUncheckLocked(top, reason);
+ }
return;
}
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 609ad75..27a4460 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -3451,7 +3451,7 @@
stack.moveToFront(reason, task);
// Report top activity change to tracking services and WM
if (r == getTopResumedActivity()) {
- // TODO(b/111541062): Support tracking multiple resumed activities
+ // TODO(b/111361570): Support multiple focused apps in WM
mService.setResumedActivityUncheckLocked(r, reason);
}
return true;
diff --git a/services/core/java/com/android/server/am/ActivityTaskManagerService.java b/services/core/java/com/android/server/am/ActivityTaskManagerService.java
index 54c2ee5..68b1d76 100644
--- a/services/core/java/com/android/server/am/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityTaskManagerService.java
@@ -4749,7 +4749,7 @@
updateResumedAppTrace(r);
mLastResumedActivity = r;
- // TODO(b/111541062): Support multiple focused apps in WM
+ // TODO(b/111361570): Support multiple focused apps in WM
mWindowManager.setFocusedApp(r.appToken, true);
applyUpdateLockStateLocked(r);
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index c7e103c..8caa702 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -2580,12 +2580,12 @@
toastText = com.android.internal.R.string.volume_dialog_ringer_guidance_vibrate;
break;
}
- maybeVibrate(effect);
+ maybeVibrate(effect, reason);
setRingerModeInternal(ringerMode, reason);
Toast.makeText(mContext, toastText, Toast.LENGTH_SHORT).show();
}
- private boolean maybeVibrate(VibrationEffect effect) {
+ private boolean maybeVibrate(VibrationEffect effect, String reason) {
if (!mHasVibrator) {
return false;
}
@@ -2598,8 +2598,8 @@
if (effect == null) {
return false;
}
- mVibrator.vibrate(
- Binder.getCallingUid(), mContext.getOpPackageName(), effect, VIBRATION_ATTRIBUTES);
+ mVibrator.vibrate(Binder.getCallingUid(), mContext.getOpPackageName(), effect,
+ reason, VIBRATION_ATTRIBUTES);
return true;
}
diff --git a/services/core/java/com/android/server/connectivity/NetworkMonitor.java b/services/core/java/com/android/server/connectivity/NetworkMonitor.java
index 9b9a380..59beef2 100644
--- a/services/core/java/com/android/server/connectivity/NetworkMonitor.java
+++ b/services/core/java/com/android/server/connectivity/NetworkMonitor.java
@@ -21,7 +21,10 @@
import static android.net.CaptivePortal.APP_RETURN_WANTED_AS_IS;
import static android.net.ConnectivityManager.EXTRA_CAPTIVE_PORTAL_PROBE_SPEC;
import static android.net.ConnectivityManager.EXTRA_CAPTIVE_PORTAL_URL;
+import static android.net.metrics.ValidationProbeEvent.DNS_FAILURE;
+import static android.net.metrics.ValidationProbeEvent.DNS_SUCCESS;
import static android.net.metrics.ValidationProbeEvent.PROBE_FALLBACK;
+import static android.net.metrics.ValidationProbeEvent.PROBE_PRIVDNS;
import android.annotation.Nullable;
import android.app.PendingIntent;
@@ -799,8 +802,10 @@
final InetAddress[] ips = ResolvUtil.blockingResolveAllLocally(
mNetwork, mPrivateDnsProviderHostname, 0 /* aiFlags */);
mPrivateDnsConfig = new PrivateDnsConfig(mPrivateDnsProviderHostname, ips);
+ validationLog("Strict mode hostname resolved: " + mPrivateDnsConfig);
} catch (UnknownHostException uhe) {
mPrivateDnsConfig = null;
+ validationLog("Strict mode hostname resolution failed: " + uhe.getMessage());
}
}
@@ -829,10 +834,21 @@
final String ONE_TIME_HOSTNAME_SUFFIX = "-dnsotls-ds.metric.gstatic.com";
final String host = UUID.randomUUID().toString().substring(0, 8) +
ONE_TIME_HOSTNAME_SUFFIX;
+ final Stopwatch watch = new Stopwatch().start();
try {
final InetAddress[] ips = mNetworkAgentInfo.network().getAllByName(host);
- return (ips != null && ips.length > 0);
- } catch (UnknownHostException uhe) {}
+ final long time = watch.stop();
+ final String strIps = Arrays.toString(ips);
+ final boolean success = (ips != null && ips.length > 0);
+ validationLog(PROBE_PRIVDNS, host, String.format("%dms: %s", time, strIps));
+ logValidationProbe(time, PROBE_PRIVDNS, success ? DNS_SUCCESS : DNS_FAILURE);
+ return success;
+ } catch (UnknownHostException uhe) {
+ final long time = watch.stop();
+ validationLog(PROBE_PRIVDNS, host,
+ String.format("%dms - Error: %s", time, uhe.getMessage()));
+ logValidationProbe(time, PROBE_PRIVDNS, DNS_FAILURE);
+ }
return false;
}
}
diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java
index 9df9ba6..a5d7b27 100644
--- a/services/core/java/com/android/server/input/InputManagerService.java
+++ b/services/core/java/com/android/server/input/InputManagerService.java
@@ -212,7 +212,8 @@
int injectorPid, int injectorUid, int syncMode, int timeoutMillis,
int policyFlags);
private static native void nativeToggleCapsLock(long ptr, int deviceId);
- private static native void nativeSetInputWindows(long ptr, InputWindowHandle[] windowHandles);
+ private static native void nativeSetInputWindows(long ptr, InputWindowHandle[] windowHandles,
+ int displayId);
private static native void nativeSetInputDispatchMode(long ptr, boolean enabled, boolean frozen);
private static native void nativeSetSystemUiVisibility(long ptr, int visibility);
private static native void nativeSetFocusedApplication(long ptr,
@@ -1467,7 +1468,7 @@
}
public void setInputWindows(InputWindowHandle[] windowHandles,
- InputWindowHandle focusedWindowHandle) {
+ InputWindowHandle focusedWindowHandle, int displayId) {
final IWindow newFocusedWindow =
focusedWindowHandle != null ? focusedWindowHandle.clientWindow : null;
if (mFocusedWindow != newFocusedWindow) {
@@ -1476,7 +1477,7 @@
setPointerCapture(false);
}
}
- nativeSetInputWindows(mPtr, windowHandles);
+ nativeSetInputWindows(mPtr, windowHandles, displayId);
}
public void setFocusedApplication(InputApplicationHandle application) {
diff --git a/services/core/java/com/android/server/job/JobSchedulerService.java b/services/core/java/com/android/server/job/JobSchedulerService.java
index 0b7c5b9..260633a 100644
--- a/services/core/java/com/android/server/job/JobSchedulerService.java
+++ b/services/core/java/com/android/server/job/JobSchedulerService.java
@@ -32,6 +32,7 @@
import android.app.job.JobProtoEnums;
import android.app.job.JobScheduler;
import android.app.job.JobService;
+import android.app.job.JobSnapshot;
import android.app.job.JobWorkItem;
import android.app.usage.UsageStatsManager;
import android.app.usage.UsageStatsManagerInternal;
@@ -2724,6 +2725,55 @@
(new JobSchedulerShellCommand(JobSchedulerService.this)).exec(
this, in, out, err, args, callback, resultReceiver);
}
+
+ /**
+ * <b>For internal system user only!</b>
+ * Returns a list of all currently-executing jobs.
+ */
+ @Override
+ public List<JobInfo> getStartedJobs() {
+ final int uid = Binder.getCallingUid();
+ if (uid != Process.SYSTEM_UID) {
+ throw new SecurityException(
+ "getStartedJobs() is system internal use only.");
+ }
+
+ final ArrayList<JobInfo> runningJobs;
+
+ synchronized (mLock) {
+ runningJobs = new ArrayList<>(mActiveServices.size());
+ for (JobServiceContext jsc : mActiveServices) {
+ final JobStatus job = jsc.getRunningJobLocked();
+ if (job != null) {
+ runningJobs.add(job.getJob());
+ }
+ }
+ }
+
+ return runningJobs;
+ }
+
+ /**
+ * <b>For internal system user only!</b>
+ * Returns a snapshot of the state of all jobs known to the system.
+ *
+ * <p class="note">This is a slow operation, so it should be called sparingly.
+ */
+ @Override
+ public List<JobSnapshot> getAllJobSnapshots() {
+ final int uid = Binder.getCallingUid();
+ if (uid != Process.SYSTEM_UID) {
+ throw new SecurityException(
+ "getAllJobSnapshots() is system internal use only.");
+ }
+ synchronized (mLock) {
+ final ArrayList<JobSnapshot> snapshots = new ArrayList<>(mJobs.size());
+ mJobs.forEachJob((job) -> snapshots.add(
+ new JobSnapshot(job.getJob(), job.getSatisfiedConstraintFlags(),
+ isReadyToBeExecutedLocked(job))));
+ return snapshots;
+ }
+ }
};
// Shell command infrastructure: run the given job immediately
diff --git a/services/core/java/com/android/server/job/controllers/JobStatus.java b/services/core/java/com/android/server/job/controllers/JobStatus.java
index a1e066e..3f8941d 100644
--- a/services/core/java/com/android/server/job/controllers/JobStatus.java
+++ b/services/core/java/com/android/server/job/controllers/JobStatus.java
@@ -694,6 +694,10 @@
mInternalFlags |= flags;
}
+ public int getSatisfiedConstraintFlags() {
+ return satisfiedConstraints;
+ }
+
public void maybeAddForegroundExemption(Predicate<Integer> uidForegroundChecker) {
// Jobs with time constraints shouldn't be exempted.
if (job.hasEarlyConstraint() || job.hasLateConstraint()) {
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index de53427..3f57faf 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -5033,11 +5033,11 @@
Thread.sleep(waitMs);
} catch (InterruptedException e) { }
mVibrator.vibrate(record.sbn.getUid(), record.sbn.getOpPkg(),
- effect, record.getAudioAttributes());
+ effect, "Notification (delayed)", record.getAudioAttributes());
}).start();
} else {
mVibrator.vibrate(record.sbn.getUid(), record.sbn.getOpPkg(),
- effect, record.getAudioAttributes());
+ effect, "Notification", record.getAudioAttributes());
}
return true;
} finally{
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 3d6b3fb..0d46437 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -17293,13 +17293,6 @@
"Instant app package must target at least O");
return;
}
- if (pkg.applicationInfo.targetSandboxVersion != 2) {
- Slog.w(TAG, "Instant app package " + pkg.packageName
- + " does not target targetSandboxVersion 2");
- res.setError(INSTALL_FAILED_INSTANT_APP_INVALID,
- "Instant app package must use targetSandboxVersion 2");
- return;
- }
if (pkg.mSharedUserId != null) {
Slog.w(TAG, "Instant app package " + pkg.packageName
+ " may not declare sharedUserId.");
@@ -21227,7 +21220,8 @@
}
@Override
- public int getComponentEnabledSetting(ComponentName component, int userId) {
+ public int getComponentEnabledSetting(@NonNull ComponentName component, int userId) {
+ if (component == null) return COMPONENT_ENABLED_STATE_DEFAULT;
if (!sUserManager.exists(userId)) return COMPONENT_ENABLED_STATE_DISABLED;
int callingUid = Binder.getCallingUid();
mPermissionManager.enforceCrossUserPermission(callingUid, userId,
@@ -22070,9 +22064,6 @@
//TODO: b/111402650
private void disableSkuSpecificApps() {
- if (!mIsUpgrade && !mFirstBoot) {
- return;
- }
String apkList[] = mContext.getResources().getStringArray(
R.array.config_disableApksUnlessMatchedSku_apk_list);
String skuArray[] = mContext.getResources().getStringArray(
@@ -22086,7 +22077,9 @@
}
for (String packageName : apkList) {
setSystemAppHiddenUntilInstalled(packageName, true);
- setSystemAppInstallState(packageName, false, ActivityManager.getCurrentUser());
+ for (UserInfo user : sUserManager.getUsers(false)) {
+ setSystemAppInstallState(packageName, false, user.id);
+ }
}
}
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index a8b92a6..ed1dc58 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -990,7 +990,8 @@
public void onWakeUp() {
synchronized (mLock) {
if (shouldEnableWakeGestureLp()) {
- performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false);
+ performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false,
+ "Wake Up");
wakeUp(SystemClock.uptimeMillis(), mAllowTheaterModeWakeFromWakeGesture,
"android.policy:GESTURE");
}
@@ -1427,19 +1428,22 @@
break;
case LONG_PRESS_POWER_GLOBAL_ACTIONS:
mPowerKeyHandled = true;
- performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
+ performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false,
+ "Power - Long Press - Global Actions");
showGlobalActionsInternal();
break;
case LONG_PRESS_POWER_SHUT_OFF:
case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM:
mPowerKeyHandled = true;
- performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
+ performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false,
+ "Power - Long Press - Shut Off");
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
mWindowManagerFuncs.shutdown(behavior == LONG_PRESS_POWER_SHUT_OFF);
break;
case LONG_PRESS_POWER_GO_TO_VOICE_ASSIST:
mPowerKeyHandled = true;
- performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
+ performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false,
+ "Power - Long Press - Go To Voice Assist");
final boolean keyguardActive = mKeyguardDelegate == null
? false
: mKeyguardDelegate.isShowing();
@@ -1461,7 +1465,8 @@
break;
case VERY_LONG_PRESS_POWER_GLOBAL_ACTIONS:
mPowerKeyHandled = true;
- performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
+ performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false,
+ "Power - Very Long Press - Show Global Actions");
showGlobalActionsInternal();
break;
}
@@ -1616,7 +1621,8 @@
@Override
public void run() {
mEndCallKeyHandled = true;
- performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
+ performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false,
+ "End Call - Long Press - Show Global Actions");
showGlobalActionsInternal();
}
};
@@ -1743,7 +1749,8 @@
return;
}
mHomeConsumed = true;
- performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
+ performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false,
+ "Home - Long Press");
switch (mLongPressOnHomeBehavior) {
case LONG_PRESS_HOME_ALL_APPS:
launchAllAppsAction();
@@ -2445,13 +2452,11 @@
attrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
break;
case TYPE_STATUS_BAR:
-
// If the Keyguard is in a hidden state (occluded by another window), we force to
- // remove the wallpaper and keyguard flag so that any change in-flight after setting
- // the keyguard as occluded wouldn't set these flags again.
+ // remove the keyguard flag so that any change in-flight after setting
+ // the keyguard as occluded wouldn't set the flag again.
// See {@link #processKeyguardSetHiddenResultLw}.
if (mKeyguardOccluded) {
- attrs.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
}
break;
@@ -3925,7 +3930,8 @@
}
private void launchAssistLongPressAction() {
- performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
+ performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false,
+ "Assist - Long Press");
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST);
// launch the search activity
@@ -5511,17 +5517,13 @@
mKeyguardDelegate.setOccluded(false, true /* animate */);
if (mStatusBar != null) {
mStatusBar.getAttrs().privateFlags |= PRIVATE_FLAG_KEYGUARD;
- if (!mKeyguardDelegate.hasLockscreenWallpaper()) {
- mStatusBar.getAttrs().flags |= FLAG_SHOW_WALLPAPER;
- }
}
return true;
} else if (isOccluded && changed && showing) {
mKeyguardOccluded = true;
- mKeyguardDelegate.setOccluded(true, false /* animate */);
+ mKeyguardDelegate.setOccluded(true, !mShowingDream /* animate */);
if (mStatusBar != null) {
mStatusBar.getAttrs().privateFlags &= ~PRIVATE_FLAG_KEYGUARD;
- mStatusBar.getAttrs().flags &= ~FLAG_SHOW_WALLPAPER;
}
return true;
} else if (changed) {
@@ -6029,7 +6031,8 @@
}
if (useHapticFeedback) {
- performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false);
+ performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false,
+ "Virtual Key - Press");
}
if (isWakeKey) {
@@ -6862,7 +6865,8 @@
public void setSafeMode(boolean safeMode) {
mSafeMode = safeMode;
if (safeMode) {
- performHapticFeedbackLw(null, HapticFeedbackConstants.SAFE_MODE_ENABLED, true);
+ performHapticFeedbackLw(null, HapticFeedbackConstants.SAFE_MODE_ENABLED, true,
+ "Safe Mode Enabled");
}
}
@@ -7324,7 +7328,8 @@
}
@Override
- public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always) {
+ public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always,
+ String reason) {
if (!mVibrator.hasVibrator()) {
return false;
}
@@ -7348,7 +7353,7 @@
owningUid = android.os.Process.myUid();
owningPackage = mContext.getOpPackageName();
}
- mVibrator.vibrate(owningUid, owningPackage, effect, VIBRATION_ATTRIBUTES);
+ mVibrator.vibrate(owningUid, owningPackage, effect, reason, VIBRATION_ATTRIBUTES);
return true;
}
diff --git a/services/core/java/com/android/server/policy/WindowManagerPolicy.java b/services/core/java/com/android/server/policy/WindowManagerPolicy.java
index cc39217..3ae5ced 100644
--- a/services/core/java/com/android/server/policy/WindowManagerPolicy.java
+++ b/services/core/java/com/android/server/policy/WindowManagerPolicy.java
@@ -1468,7 +1468,8 @@
/**
* Call from application to perform haptic feedback on its window.
*/
- public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always);
+ public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always,
+ String reason);
/**
* Called when we have started keeping the screen on because a window
diff --git a/services/core/java/com/android/server/webkit/WebViewUpdateServiceShellCommand.java b/services/core/java/com/android/server/webkit/WebViewUpdateServiceShellCommand.java
index 39e28c7..3199ed4 100644
--- a/services/core/java/com/android/server/webkit/WebViewUpdateServiceShellCommand.java
+++ b/services/core/java/com/android/server/webkit/WebViewUpdateServiceShellCommand.java
@@ -66,6 +66,12 @@
private int setWebViewImplementation() throws RemoteException {
final PrintWriter pw = getOutPrintWriter();
String shellChosenPackage = getNextArg();
+ if (shellChosenPackage == null) {
+ pw.println("Failed to switch, no PACKAGE provided.");
+ pw.println("");
+ helpSetWebViewImplementation();
+ return 1;
+ }
String newPackage = mInterface.changeProviderAndSetting(shellChosenPackage);
if (shellChosenPackage.equals(newPackage)) {
pw.println("Success");
@@ -85,6 +91,12 @@
return 0;
}
+ public void helpSetWebViewImplementation() {
+ PrintWriter pw = getOutPrintWriter();
+ pw.println(" set-webview-implementation PACKAGE");
+ pw.println(" Set the WebView implementation to the specified package.");
+ }
+
@Override
public void onHelp() {
PrintWriter pw = getOutPrintWriter();
@@ -99,8 +111,7 @@
pw.println(" disable-redundant-packages");
pw.println(" Disallow installing and enabling fallback packages when a more-preferred");
pw.println(" package is available.");
- pw.println(" set-webview-implementation PACKAGE");
- pw.println(" Set the WebView implementation to the specified package.");
+ helpSetWebViewImplementation();
pw.println(" enable-multiprocess");
pw.println(" Enable multi-process mode for WebView");
pw.println(" disable-multiprocess");
diff --git a/services/core/java/com/android/server/webkit/WebViewUpdater.java b/services/core/java/com/android/server/webkit/WebViewUpdater.java
index 3e72d981..f270715 100644
--- a/services/core/java/com/android/server/webkit/WebViewUpdater.java
+++ b/services/core/java/com/android/server/webkit/WebViewUpdater.java
@@ -504,20 +504,20 @@
private static boolean providerHasValidSignature(WebViewProviderInfo provider,
PackageInfo packageInfo, SystemInterface systemInterface) {
- if (systemInterface.systemIsDebuggable()) {
- return true;
- }
- // If no signature is declared, instead check whether the package is included in the
- // system.
- if (provider.signatures == null || provider.signatures.length == 0) {
- return packageInfo.applicationInfo.isSystemApp();
- }
+ // Skip checking signatures on debuggable builds, for development purposes.
+ if (systemInterface.systemIsDebuggable()) return true;
+
+ // Allow system apps to be valid providers regardless of signature.
+ if (packageInfo.applicationInfo.isSystemApp()) return true;
+
+ // We don't support packages with multiple signatures.
if (packageInfo.signatures.length != 1) return false;
- // Return whether the package signature matches any of the valid signatures
+ // If any of the declared signatures match the package signature, it's valid.
for (Signature signature : provider.signatures) {
if (signature.equals(packageInfo.signatures[0])) return true;
}
+
return false;
}
diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java
index f0898c0..e449111 100644
--- a/services/core/java/com/android/server/wm/AccessibilityController.java
+++ b/services/core/java/com/android/server/wm/AccessibilityController.java
@@ -119,13 +119,13 @@
}
}
- public void performComputeChangedWindowsNotLocked() {
+ public void performComputeChangedWindowsNotLocked(boolean forceSend) {
WindowsForAccessibilityObserver observer = null;
synchronized (mService) {
observer = mWindowsForAccessibilityObserver;
}
if (observer != null) {
- observer.performComputeChangedWindowsNotLocked();
+ observer.performComputeChangedWindowsNotLocked(forceSend);
}
}
@@ -193,7 +193,7 @@
observer = mWindowsForAccessibilityObserver;
}
if (observer != null) {
- observer.performComputeChangedWindowsNotLocked();
+ observer.performComputeChangedWindowsNotLocked(false);
}
}
@@ -1011,12 +1011,12 @@
mHandler = new MyHandler(mService.mH.getLooper());
mRecurringAccessibilityEventsIntervalMillis = ViewConfiguration
.getSendRecurringAccessibilityEventsInterval();
- computeChangedWindows();
+ computeChangedWindows(true);
}
- public void performComputeChangedWindowsNotLocked() {
+ public void performComputeChangedWindowsNotLocked(boolean forceSend) {
mHandler.removeMessages(MyHandler.MESSAGE_COMPUTE_CHANGED_WINDOWS);
- computeChangedWindows();
+ computeChangedWindows(forceSend);
}
public void scheduleComputeChangedWindowsLocked() {
@@ -1026,7 +1026,12 @@
}
}
- public void computeChangedWindows() {
+ /**
+ * Check if windows have changed, and send them to the accessibilty subsystem if they have.
+ *
+ * @param forceSend Send the windows the accessibility even if they haven't changed.
+ */
+ public void computeChangedWindows(boolean forceSend) {
if (DEBUG) {
Slog.i(LOG_TAG, "computeChangedWindows()");
}
@@ -1171,36 +1176,38 @@
visibleWindows.clear();
addedWindows.clear();
- // We computed the windows and if they changed notify the client.
- if (mOldWindows.size() != windows.size()) {
- // Different size means something changed.
- windowsChanged = true;
- } else if (!mOldWindows.isEmpty() || !windows.isEmpty()) {
- // Since we always traverse windows from high to low layer
- // the old and new windows at the same index should be the
- // same, otherwise something changed.
- for (int i = 0; i < windowCount; i++) {
- WindowInfo oldWindow = mOldWindows.get(i);
- WindowInfo newWindow = windows.get(i);
- // We do not care for layer changes given the window
- // order does not change. This brings no new information
- // to the clients.
- if (windowChangedNoLayer(oldWindow, newWindow)) {
- windowsChanged = true;
- break;
+ if (!forceSend) {
+ // We computed the windows and if they changed notify the client.
+ if (mOldWindows.size() != windows.size()) {
+ // Different size means something changed.
+ windowsChanged = true;
+ } else if (!mOldWindows.isEmpty() || !windows.isEmpty()) {
+ // Since we always traverse windows from high to low layer
+ // the old and new windows at the same index should be the
+ // same, otherwise something changed.
+ for (int i = 0; i < windowCount; i++) {
+ WindowInfo oldWindow = mOldWindows.get(i);
+ WindowInfo newWindow = windows.get(i);
+ // We do not care for layer changes given the window
+ // order does not change. This brings no new information
+ // to the clients.
+ if (windowChangedNoLayer(oldWindow, newWindow)) {
+ windowsChanged = true;
+ break;
+ }
}
}
}
- if (windowsChanged) {
+ if (forceSend || windowsChanged) {
cacheWindows(windows);
}
}
// Now we do not hold the lock, so send the windows over.
- if (windowsChanged) {
+ if (forceSend || windowsChanged) {
if (DEBUG) {
- Log.i(LOG_TAG, "Windows changed:" + windows);
+ Log.i(LOG_TAG, "Windows changed or force sending:" + windows);
}
mCallback.onWindowsForAccessibilityChanged(windows);
} else {
@@ -1345,7 +1352,7 @@
public void handleMessage(Message message) {
switch (message.what) {
case MESSAGE_COMPUTE_CHANGED_WINDOWS: {
- computeChangedWindows();
+ computeChangedWindows(false);
} break;
}
}
diff --git a/services/core/java/com/android/server/wm/AppTransition.java b/services/core/java/com/android/server/wm/AppTransition.java
index d73606f..7ee35e7 100644
--- a/services/core/java/com/android/server/wm/AppTransition.java
+++ b/services/core/java/com/android/server/wm/AppTransition.java
@@ -1557,7 +1557,7 @@
if (isKeyguardGoingAwayTransit(transit) && enter) {
a = loadKeyguardExitAnimation(transit);
} else if (transit == TRANSIT_KEYGUARD_OCCLUDE) {
- a = null;
+ a = loadAnimationRes(lp, com.android.internal.R.anim.keyguard_occlude_open_enter);
} else if (transit == TRANSIT_KEYGUARD_UNOCCLUDE && !enter) {
a = loadAnimationRes(lp, com.android.internal.R.anim.wallpaper_open_exit);
} else if (transit == TRANSIT_CRASHING_ACTIVITY_CLOSE) {
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 4ab06a2..44d0187 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -814,9 +814,7 @@
// {@link DisplayContent} ready for use.
mDisplayReady = true;
- // TODO(b/112081256): Use independent InputMonitor.
- mInputMonitor = isDefaultDisplay ? new InputMonitor(service, mDisplayId)
- : mService.getDefaultDisplayContentLocked().mInputMonitor;
+ mInputMonitor = new InputMonitor(service, mDisplayId);
}
boolean isReady() {
@@ -2134,6 +2132,7 @@
mRemovingDisplay = false;
}
+ mInputMonitor.onRemoved();
mService.onDisplayRemoved(mDisplayId);
}
diff --git a/services/core/java/com/android/server/wm/ForcedSeamlessRotator.java b/services/core/java/com/android/server/wm/ForcedSeamlessRotator.java
index ad745a2..f5e6e72 100644
--- a/services/core/java/com/android/server/wm/ForcedSeamlessRotator.java
+++ b/services/core/java/com/android/server/wm/ForcedSeamlessRotator.java
@@ -21,9 +21,13 @@
import android.graphics.Matrix;
import android.view.DisplayInfo;
+import android.view.Surface.Rotation;
import com.android.server.wm.utils.CoordinateTransforms;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
/**
* Helper class for forced seamless rotation.
*
@@ -37,8 +41,13 @@
private final Matrix mTransform = new Matrix();
private final float[] mFloat9 = new float[9];
+ private final int mOldRotation;
+ private final int mNewRotation;
public ForcedSeamlessRotator(int oldRotation, int newRotation, DisplayInfo info) {
+ mOldRotation = oldRotation;
+ mNewRotation = newRotation;
+
final boolean flipped = info.rotation == ROTATION_90 || info.rotation == ROTATION_270;
final int h = flipped ? info.logicalWidth : info.logicalHeight;
final int w = flipped ? info.logicalHeight : info.logicalWidth;
@@ -58,6 +67,16 @@
}
/**
+ * Returns the rotation of the display before it started rotating.
+ *
+ * @return the old rotation of the display
+ */
+ @Rotation
+ public int getOldRotation() {
+ return mOldRotation;
+ }
+
+ /**
* Removes the transform to the window token's surface that undoes the effect of the global
* display rotation.
*
@@ -77,4 +96,16 @@
win.getFrameNumber());
}
}
+
+ public void dump(PrintWriter pw) {
+ pw.print("{old="); pw.print(mOldRotation); pw.print(", new="); pw.print(mNewRotation);
+ pw.print("}");
+ }
+
+ @Override
+ public String toString() {
+ StringWriter sw = new StringWriter();
+ dump(new PrintWriter(sw));
+ return "ForcedSeamlessRotator" + sw.toString();
+ }
}
diff --git a/services/core/java/com/android/server/wm/InputConsumerImpl.java b/services/core/java/com/android/server/wm/InputConsumerImpl.java
index 6a08f4d..af0eac6 100644
--- a/services/core/java/com/android/server/wm/InputConsumerImpl.java
+++ b/services/core/java/com/android/server/wm/InputConsumerImpl.java
@@ -20,7 +20,6 @@
import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
-import android.view.Display;
import android.view.InputChannel;
import android.view.WindowManager;
import com.android.server.input.InputApplicationHandle;
diff --git a/services/core/java/com/android/server/wm/InputMonitor.java b/services/core/java/com/android/server/wm/InputMonitor.java
index c4beb55..823a0de 100644
--- a/services/core/java/com/android/server/wm/InputMonitor.java
+++ b/services/core/java/com/android/server/wm/InputMonitor.java
@@ -367,6 +367,13 @@
}
}
+ void onRemoved() {
+ // If DisplayContent removed, we need find a way to remove window handles of this display
+ // from InputDispatcher, so pass an empty InputWindowHandles to remove them.
+ mService.mInputManager.setInputWindows(mInputWindowHandles, mFocusedInputWindowHandle,
+ mDisplayId);
+ }
+
private final class UpdateInputForAllWindowsConsumer implements Consumer<WindowState> {
InputConsumerImpl navInputConsumer;
InputConsumerImpl pipInputConsumer;
@@ -399,8 +406,7 @@
this.inDrag = inDrag;
wallpaperController = mService.mRoot.mWallpaperController;
- // TODO(b/112081256): Use independent InputMonitor for each display.
- mService.mRoot/*.getDisplayContent(mDisplayId)*/.forAllWindows(this,
+ mService.mRoot.getDisplayContent(mDisplayId).forAllWindows(this,
true /* traverseTopToBottom */);
if (mAddWallpaperInputConsumerHandle) {
// No visible wallpaper found, add the wallpaper input consumer at the end.
@@ -408,8 +414,8 @@
}
// Send windows to native code.
- // TODO: Update Input windows and focus by display?
- mService.mInputManager.setInputWindows(mInputWindowHandles, mFocusedInputWindowHandle);
+ mService.mInputManager.setInputWindows(mInputWindowHandles, mFocusedInputWindowHandle,
+ mDisplayId);
clearInputWindowHandlesLw();
@@ -429,7 +435,8 @@
final int flags = w.mAttrs.flags;
final int privateFlags = w.mAttrs.privateFlags;
final int type = w.mAttrs.type;
- final boolean hasFocus = w == mInputFocus;
+ // TODO(b/111361570): multi-display focus, one focus for all display in current.
+ final boolean hasFocus = w == mService.mCurrentFocus;//mInputFocus;
final boolean isVisible = w.isVisibleLw();
if (mAddRecentsAnimationInputConsumerHandle) {
diff --git a/services/core/java/com/android/server/wm/RecentsAnimationController.java b/services/core/java/com/android/server/wm/RecentsAnimationController.java
index 3a0cc28..b5566a7 100644
--- a/services/core/java/com/android/server/wm/RecentsAnimationController.java
+++ b/services/core/java/com/android/server/wm/RecentsAnimationController.java
@@ -315,12 +315,9 @@
@VisibleForTesting
AnimationAdapter addAnimation(Task task, boolean isRecentTaskInvisible) {
if (DEBUG_RECENTS_ANIMATIONS) Slog.d(TAG, "addAnimation(" + task.getName() + ")");
- // TODO: Refactor this to use the task's animator
- final SurfaceAnimator anim = new SurfaceAnimator(task, null /* animationFinishedCallback */,
- mService);
final TaskAnimationAdapter taskAdapter = new TaskAnimationAdapter(task,
isRecentTaskInvisible);
- anim.startAnimation(task.getPendingTransaction(), taskAdapter, false /* hidden */);
+ task.startAnimation(task.getPendingTransaction(), taskAdapter, false /* hidden */);
task.commitPendingTransaction();
mPendingAnimations.add(taskAdapter);
return taskAdapter;
diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java
index 26ddf2c..5cf5e0d 100644
--- a/services/core/java/com/android/server/wm/Session.java
+++ b/services/core/java/com/android/server/wm/Session.java
@@ -287,7 +287,7 @@
try {
return mService.mPolicy.performHapticFeedbackLw(
mService.windowForClientLocked(this, window, true),
- effectId, always);
+ effectId, always, null);
} finally {
Binder.restoreCallingIdentity(ident);
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerInternal.java b/services/core/java/com/android/server/wm/WindowManagerInternal.java
index 0c65518..90a763d 100644
--- a/services/core/java/com/android/server/wm/WindowManagerInternal.java
+++ b/services/core/java/com/android/server/wm/WindowManagerInternal.java
@@ -410,7 +410,7 @@
public abstract boolean isDockedDividerResizing();
/**
- * Requests the window manager to recompute the windows for accessibility.
+ * Requests the window manager to resend the windows for accessibility.
*/
public abstract void computeWindowsForAccessibility();
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index ab735af..0015693 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -1901,6 +1901,7 @@
// TODO(b/111504081): Consolidate seamless rotation logic.
if (win.mPendingForcedSeamlessRotate != null && !mWaitingForConfig) {
win.mPendingForcedSeamlessRotate.finish(win.mToken, win);
+ win.mFinishForcedSeamlessRotateFrameNumber = win.getFrameNumber();
win.mPendingForcedSeamlessRotate = null;
}
@@ -6070,26 +6071,21 @@
@Override
public void createInputConsumer(IBinder token, String name, InputChannel inputChannel) {
synchronized (mWindowMap) {
- // TODO(b/112049699): Fix this for multiple displays. There is only one inputChannel
- // here to accept the return value.
- DisplayContent display = mRoot.getDisplayContent(Display.DEFAULT_DISPLAY);
- if (display != null) {
- display.getInputMonitor().createInputConsumer(token, name, inputChannel,
- Binder.getCallingPid(), Binder.getCallingUserHandle());
- }
+ // TODO(b/112049699): multi-display inputConsumer, just support default in current.
+ // Need consider about the behavior from controller.
+ DisplayContent displayContent = getDefaultDisplayContentLocked();
+ displayContent.getInputMonitor().createInputConsumer(token, name, inputChannel,
+ Binder.getCallingPid(), Binder.getCallingUserHandle());
}
}
@Override
public boolean destroyInputConsumer(String name) {
synchronized (mWindowMap) {
- // TODO(b/112049699): Fix this for multiple displays. For consistency with
- // createInputConsumer above.
- DisplayContent display = mRoot.getDisplayContent(Display.DEFAULT_DISPLAY);
- if (display != null) {
- return display.getInputMonitor().destroyInputConsumer(name);
- }
- return false;
+ // TODO(b/112049699): multi-display inputConsumer, just support default in current.
+ // Need consider about the behavior from controller.
+ DisplayContent displayContent = getDefaultDisplayContentLocked();
+ return displayContent.getInputMonitor().destroyInputConsumer(name);
}
}
@@ -6930,10 +6926,8 @@
@Override
public void registerDockedStackListener(IDockedStackListener listener) {
- if (!checkCallingPermission(REGISTER_WINDOW_MANAGER_LISTENERS,
- "registerDockedStackListener()")) {
- return;
- }
+ mAtmInternal.enforceCallerIsRecentsOrHasPermission(REGISTER_WINDOW_MANAGER_LISTENERS,
+ "registerDockedStackListener()");
synchronized (mWindowMap) {
// TODO(multi-display): The listener is registered on the default display only.
getDefaultDisplayContentLocked().mDividerControllerLocked.registerDockedStackListener(
@@ -7422,7 +7416,7 @@
accessibilityController = mAccessibilityController;
}
if (accessibilityController != null) {
- accessibilityController.performComputeChangedWindowsNotLocked();
+ accessibilityController.performComputeChangedWindowsNotLocked(true);
}
}
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 9f394ac..58fb7a0 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -122,6 +122,7 @@
import static com.android.server.wm.WindowStateProto.CONTENT_INSETS;
import static com.android.server.wm.WindowStateProto.DESTROYING;
import static com.android.server.wm.WindowStateProto.DISPLAY_ID;
+import static com.android.server.wm.WindowStateProto.FINISHED_FORCED_SEAMLESS_ROTATION_FRAME;
import static com.android.server.wm.WindowStateProto.GIVEN_CONTENT_INSETS;
import static com.android.server.wm.WindowStateProto.HAS_SURFACE;
import static com.android.server.wm.WindowStateProto.IDENTIFIER;
@@ -130,6 +131,7 @@
import static com.android.server.wm.WindowStateProto.IS_VISIBLE;
import static com.android.server.wm.WindowStateProto.OUTSETS;
import static com.android.server.wm.WindowStateProto.OVERSCAN_INSETS;
+import static com.android.server.wm.WindowStateProto.PENDING_FORCED_SEAMLESS_ROTATION;
import static com.android.server.wm.WindowStateProto.REMOVED;
import static com.android.server.wm.WindowStateProto.REMOVE_ON_EXIT;
import static com.android.server.wm.WindowStateProto.REQUESTED_HEIGHT;
@@ -281,6 +283,7 @@
*/
final boolean mForceSeamlesslyRotate;
ForcedSeamlessRotator mPendingForcedSeamlessRotate;
+ long mFinishForcedSeamlessRotateFrameNumber;
private RemoteCallbackList<IWindowFocusObserver> mFocusCallbacks;
@@ -631,6 +634,10 @@
void forceSeamlesslyRotateIfAllowed(int oldRotation, int rotation) {
if (mForceSeamlesslyRotate) {
+ if (mPendingForcedSeamlessRotate != null) {
+ oldRotation = mPendingForcedSeamlessRotate.getOldRotation();
+ }
+
mPendingForcedSeamlessRotate = new ForcedSeamlessRotator(
oldRotation, rotation, getDisplayInfo());
mPendingForcedSeamlessRotate.unrotate(this.mToken);
@@ -3294,6 +3301,11 @@
proto.write(REMOVED, mRemoved);
proto.write(IS_ON_SCREEN, isOnScreen());
proto.write(IS_VISIBLE, isVisible());
+ if (mForceSeamlesslyRotate) {
+ proto.write(PENDING_FORCED_SEAMLESS_ROTATION, mPendingForcedSeamlessRotate != null);
+ proto.write(FINISHED_FORCED_SEAMLESS_ROTATION_FRAME,
+ mFinishForcedSeamlessRotateFrameNumber);
+ }
proto.end(token);
}
@@ -3449,6 +3461,16 @@
pw.print(prefix); pw.print("mLastFreezeDuration=");
TimeUtils.formatDuration(mLastFreezeDuration, pw); pw.println();
}
+ if (mForceSeamlesslyRotate) {
+ pw.print(prefix); pw.print("forceSeamlesslyRotate: pending=");
+ if (mPendingForcedSeamlessRotate != null) {
+ mPendingForcedSeamlessRotate.dump(pw);
+ } else {
+ pw.print("null");
+ }
+ pw.print(" finishedFrameNumber="); pw.print(mFinishForcedSeamlessRotateFrameNumber);
+ pw.println();
+ }
if (mHScale != 1 || mVScale != 1) {
pw.print(prefix); pw.print("mHScale="); pw.print(mHScale);
pw.print(" mVScale="); pw.println(mVScale);
diff --git a/services/core/jni/Android.bp b/services/core/jni/Android.bp
index 9e1191d..becde73 100644
--- a/services/core/jni/Android.bp
+++ b/services/core/jni/Android.bp
@@ -59,17 +59,6 @@
"frameworks/native/services",
"system/gatekeeper/include",
],
-
- product_variables: {
- arc: {
- cflags: [
- "-DUSE_ARC",
- ],
- srcs: [
- "com_android_server_ArcVideoService.cpp",
- ],
- }
- }
}
cc_defaults {
@@ -144,7 +133,9 @@
shared_libs: [
"libarcbridge",
"libarcbridgeservice",
- "libarcvideobridge",
+ "libarctimer",
+ "libbase",
+ "libcap",
"libchrome",
"libmojo",
],
diff --git a/services/core/jni/BroadcastRadio/NativeCallbackThread.cpp b/services/core/jni/BroadcastRadio/NativeCallbackThread.cpp
index 81d46f3..777d344 100644
--- a/services/core/jni/BroadcastRadio/NativeCallbackThread.cpp
+++ b/services/core/jni/BroadcastRadio/NativeCallbackThread.cpp
@@ -106,7 +106,7 @@
mQueueCond.notify_one();
}
- if (mThread.get_id() == std::thread::id()) {
+ if (mThread.get_id() == std::this_thread::get_id()) {
// you can't self-join a thread, but it's ok when calling from our sub-task
ALOGD("About to stop native callback thread %p", this);
mThread.detach();
diff --git a/services/core/jni/com_android_server_ArcVideoService.cpp b/services/core/jni/com_android_server_ArcVideoService.cpp
deleted file mode 100644
index f93cd90..0000000
--- a/services/core/jni/com_android_server_ArcVideoService.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright 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_NDEBUG 0
-#define LOG_TAG "ArcVideoService"
-
-#include <binder/IPCThreadState.h>
-#include <binder/IServiceManager.h>
-#include <media/arcvideobridge/IArcVideoBridge.h>
-#include <utils/Log.h>
-
-#include <base/bind.h>
-#include <base/bind_helpers.h>
-#include <mojo/edk/embedder/embedder.h>
-#include <mojo/public/cpp/bindings/binding.h>
-
-#include <arc/ArcBridgeSupport.h>
-#include <arc/ArcService.h>
-#include <arc/Future.h>
-#include <arc/IArcBridgeService.h>
-#include <arc/MojoProcessSupport.h>
-#include <components/arc/common/video.mojom.h>
-
-namespace {
-
-// [MinVersion] of OnVideoInstanceReady method in arc_bridge.mojom.
-constexpr int kMinimumArcBridgeHostVersion = 6;
-
-void onCaptureResult(arc::Future<arc::MojoBootstrapResult>* future, uint32_t version,
- mojo::ScopedHandle handle, const std::string& token) {
- mojo::edk::ScopedPlatformHandle scoped_platform_handle;
- MojoResult result =
- mojo::edk::PassWrappedPlatformHandle(handle.release().value(), &scoped_platform_handle);
- if (result != MOJO_RESULT_OK) {
- ALOGE("Received invalid file descriptor.");
- future->set(arc::MojoBootstrapResult());
- return;
- }
-
- base::ScopedFD fd(scoped_platform_handle.release().handle);
- future->set(arc::MojoBootstrapResult(std::move(fd), token, version));
-}
-
-} // namespace
-
-namespace arc {
-
-class VideoService : public mojom::VideoInstance,
- public ArcService,
- public android::BnArcVideoBridge {
-public:
- explicit VideoService(MojoProcessSupport* mojoProcessSupport)
- : mMojoProcessSupport(mojoProcessSupport), mBinding(this) {
- mMojoProcessSupport->arc_bridge_support().requestArcBridgeProxyAsync(
- this, kMinimumArcBridgeHostVersion);
- }
-
- ~VideoService() override { mMojoProcessSupport->disconnect(&mBinding, &mHostPtr); }
-
- // VideoInstance overrides:
- void InitDeprecated(mojom::VideoHostPtr hostPtr) override {
- Init(std::move(hostPtr), base::Bind(&base::DoNothing));
- }
-
- void Init(mojom::VideoHostPtr hostPtr, const InitCallback& callback) override {
- ALOGV("Init");
- mHostPtr = std::move(hostPtr);
- // A method must be called while we are still in a Mojo thread so the
- // proxy can perform lazy initialization and be able to be called from
- // non-Mojo threads later.
- // This also caches the version number so it can be obtained by calling
- // .version().
- mHostPtr.QueryVersion(base::Bind(
- [](const InitCallback& callback, uint32_t version) {
- ALOGI("VideoService ready (version=%d)", version);
- callback.Run();
- },
- callback));
- ALOGV("Init done");
- }
-
- // ArcService overrides:
- void ready(mojom::ArcBridgeHostPtr* bridgeHost) override {
- (*bridgeHost)->OnVideoInstanceReady(mBinding.CreateInterfacePtrAndBind());
- }
-
- void versionMismatch(uint32_t version) override {
- ALOGE("ArcBridgeHost version %d, does not support video (version %d)\n", version,
- kMinimumArcBridgeHostVersion);
- }
-
- // BnArcVideoBridge overrides:
- MojoBootstrapResult bootstrapVideoAcceleratorFactory() override {
- ALOGV("VideoService::bootstrapVideoAcceleratorFactory");
-
- Future<MojoBootstrapResult> future;
- mMojoProcessSupport->mojo_thread().getTaskRunner()->PostTask(
- FROM_HERE, base::Bind(&VideoService::bootstrapVideoAcceleratorFactoryOnMojoThread,
- base::Unretained(this), &future));
- return future.get();
- }
-
- int32_t hostVersion() override {
- ALOGV("VideoService::hostVersion");
- return mHostPtr.version();
- }
-
-private:
- void bootstrapVideoAcceleratorFactoryOnMojoThread(Future<MojoBootstrapResult>* future) {
- if (!mHostPtr) {
- ALOGE("mHostPtr is not ready yet");
- future->set(MojoBootstrapResult());
- return;
- }
- mHostPtr->OnBootstrapVideoAcceleratorFactory(
- base::Bind(&onCaptureResult, base::Unretained(future), mHostPtr.version()));
- }
-
- // Outlives VideoService.
- MojoProcessSupport* const mMojoProcessSupport;
- mojo::Binding<mojom::VideoInstance> mBinding;
- mojom::VideoHostPtr mHostPtr;
-};
-
-} // namespace arc
-
-namespace android {
-
-int register_android_server_ArcVideoService() {
- defaultServiceManager()->addService(
- String16("android.os.IArcVideoBridge"),
- new arc::VideoService(arc::MojoProcessSupport::getLeakyInstance()));
- return 0;
-}
-
-} // namespace android
diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp
index 52f2d67..f5f19f6 100644
--- a/services/core/jni/com_android_server_input_InputManagerService.cpp
+++ b/services/core/jni/com_android_server_input_InputManagerService.cpp
@@ -210,7 +210,7 @@
const sp<InputWindowHandle>& inputWindowHandle, bool monitor);
status_t unregisterInputChannel(JNIEnv* env, const sp<InputChannel>& inputChannel);
- void setInputWindows(JNIEnv* env, jobjectArray windowHandleObjArray);
+ void setInputWindows(JNIEnv* env, jobjectArray windowHandleObjArray, int displayId);
void setFocusedApplication(JNIEnv* env, jobject applicationHandleObj);
void setInputDispatchMode(bool enabled, bool frozen);
void setSystemUiVisibility(int32_t visibility);
@@ -736,7 +736,8 @@
}
}
-void NativeInputManager::setInputWindows(JNIEnv* env, jobjectArray windowHandleObjArray) {
+void NativeInputManager::setInputWindows(JNIEnv* env, jobjectArray windowHandleObjArray,
+ int displayId) {
Vector<sp<InputWindowHandle> > windowHandles;
if (windowHandleObjArray) {
@@ -756,7 +757,7 @@
}
}
- mInputManager->getDispatcher()->setInputWindows(windowHandles);
+ mInputManager->getDispatcher()->setInputWindows(windowHandles, displayId);
// Do this after the dispatcher has updated the window handle state.
bool newPointerGesturesEnabled = true;
@@ -1446,10 +1447,10 @@
}
static void nativeSetInputWindows(JNIEnv* env, jclass /* clazz */,
- jlong ptr, jobjectArray windowHandleObjArray) {
+ jlong ptr, jobjectArray windowHandleObjArray, jint displayId) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
- im->setInputWindows(env, windowHandleObjArray);
+ im->setInputWindows(env, windowHandleObjArray, displayId);
}
static void nativeSetFocusedApplication(JNIEnv* env, jclass /* clazz */,
@@ -1678,7 +1679,7 @@
(void*) nativeInjectInputEvent },
{ "nativeToggleCapsLock", "(JI)V",
(void*) nativeToggleCapsLock },
- { "nativeSetInputWindows", "(J[Lcom/android/server/input/InputWindowHandle;)V",
+ { "nativeSetInputWindows", "(J[Lcom/android/server/input/InputWindowHandle;I)V",
(void*) nativeSetInputWindows },
{ "nativeSetFocusedApplication", "(JLcom/android/server/input/InputApplicationHandle;)V",
(void*) nativeSetFocusedApplication },
diff --git a/services/core/jni/onload.cpp b/services/core/jni/onload.cpp
index 0ebef37..bb6e684 100644
--- a/services/core/jni/onload.cpp
+++ b/services/core/jni/onload.cpp
@@ -54,9 +54,6 @@
int register_android_server_GraphicsStatsService(JNIEnv* env);
int register_android_hardware_display_DisplayViewport(JNIEnv* env);
int register_android_server_net_NetworkStatsService(JNIEnv* env);
-#ifdef USE_ARC
-int register_android_server_ArcVideoService();
-#endif
};
using namespace android;
@@ -104,8 +101,5 @@
register_android_server_GraphicsStatsService(env);
register_android_hardware_display_DisplayViewport(env);
register_android_server_net_NetworkStatsService(env);
-#ifdef USE_ARC
- register_android_server_ArcVideoService();
-#endif
return JNI_VERSION_1_4;
}
diff --git a/services/robotests/src/com/android/server/backup/BackupManagerServiceTest.java b/services/robotests/src/com/android/server/backup/BackupManagerServiceTest.java
index ea9967b..2e0ae02 100644
--- a/services/robotests/src/com/android/server/backup/BackupManagerServiceTest.java
+++ b/services/robotests/src/com/android/server/backup/BackupManagerServiceTest.java
@@ -45,7 +45,7 @@
import android.os.PowerSaveState;
import android.platform.test.annotations.Presubmit;
import android.provider.Settings;
-import com.android.server.backup.internal.BackupRequest;
+import com.android.server.backup.keyvalue.BackupRequest;
import com.android.server.backup.testing.BackupManagerServiceTestUtils;
import com.android.server.backup.testing.TransportData;
import com.android.server.backup.testing.TransportTestUtils.TransportMock;
diff --git a/services/robotests/src/com/android/server/backup/KeyValueBackupTaskTest.java b/services/robotests/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java
similarity index 98%
rename from services/robotests/src/com/android/server/backup/KeyValueBackupTaskTest.java
rename to services/robotests/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java
index 56f5f15..fde9bc8 100644
--- a/services/robotests/src/com/android/server/backup/KeyValueBackupTaskTest.java
+++ b/services/robotests/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java
@@ -14,7 +14,7 @@
* limitations under the License
*/
-package com.android.server.backup;
+package com.android.server.backup.keyvalue;
import static android.app.backup.BackupManager.ERROR_AGENT_FAILURE;
import static android.app.backup.BackupManager.ERROR_BACKUP_NOT_ALLOWED;
@@ -25,9 +25,12 @@
import static android.app.backup.ForwardingBackupAgent.forward;
import static com.android.server.backup.testing.BackupManagerServiceTestUtils.createBackupWakeLock;
-import static com.android.server.backup.testing.BackupManagerServiceTestUtils.createInitializedBackupManagerService;
-import static com.android.server.backup.testing.BackupManagerServiceTestUtils.setUpBackupManagerServiceBasics;
-import static com.android.server.backup.testing.BackupManagerServiceTestUtils.setUpBinderCallerAndApplicationAsSystem;
+import static com.android.server.backup.testing.BackupManagerServiceTestUtils
+ .createInitializedBackupManagerService;
+import static com.android.server.backup.testing.BackupManagerServiceTestUtils
+ .setUpBackupManagerServiceBasics;
+import static com.android.server.backup.testing.BackupManagerServiceTestUtils
+ .setUpBinderCallerAndApplicationAsSystem;
import static com.android.server.backup.testing.PackageData.PM_PACKAGE;
import static com.android.server.backup.testing.PackageData.fullBackupPackage;
import static com.android.server.backup.testing.PackageData.keyValuePackage;
@@ -90,10 +93,14 @@
import com.android.internal.backup.IBackupTransport;
import com.android.server.EventLogTags;
+import com.android.server.backup.BackupManagerService;
+import com.android.server.backup.BackupRestoreTask;
+import com.android.server.backup.DataChangedJournal;
+import com.android.server.backup.KeyValueBackupJob;
+import com.android.server.backup.PackageManagerBackupAgent;
+import com.android.server.backup.TransportManager;
import com.android.server.backup.internal.BackupHandler;
-import com.android.server.backup.internal.BackupRequest;
import com.android.server.backup.internal.OnTaskFinishedListener;
-import com.android.server.backup.internal.KeyValueBackupTask;
import com.android.server.backup.testing.PackageData;
import com.android.server.backup.testing.TransportData;
import com.android.server.backup.testing.TransportTestUtils;
@@ -1795,10 +1802,10 @@
* <li>The transport being initialized with {@link IBackupTransport#initializeDevice()}
* <li>{@link BackupManagerService#resetBackupState(File)} being called, which will:
* <ul>
- * <li>Call {@link ProcessedPackagesJournal#reset()}
- * <li>Reset current token to 0
- * <li>Delete state files
- * <li>Mark data changed for every key-value participant
+ * <li>Reset processed packages journal.
+ * <li>Reset current token to 0.
+ * <li>Delete state files.
+ * <li>Mark data changed for every key-value participant.
* </ul>
* </ul>
*/
diff --git a/services/robotests/src/com/android/server/testing/shadows/ShadowKeyValueBackupTask.java b/services/robotests/src/com/android/server/testing/shadows/ShadowKeyValueBackupTask.java
index f22cdb8..838902d 100644
--- a/services/robotests/src/com/android/server/testing/shadows/ShadowKeyValueBackupTask.java
+++ b/services/robotests/src/com/android/server/testing/shadows/ShadowKeyValueBackupTask.java
@@ -22,15 +22,14 @@
import com.android.server.backup.BackupManagerService;
import com.android.server.backup.DataChangedJournal;
-import com.android.server.backup.internal.BackupRequest;
import com.android.server.backup.internal.OnTaskFinishedListener;
-import com.android.server.backup.internal.KeyValueBackupTask;
+import com.android.server.backup.keyvalue.BackupRequest;
+import com.android.server.backup.keyvalue.KeyValueBackupTask;
import com.android.server.backup.transport.TransportClient;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
-import java.util.ArrayList;
import java.util.List;
@Implements(KeyValueBackupTask.class)
diff --git a/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java b/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java
index 735e284..5fb8997 100644
--- a/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java
+++ b/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java
@@ -417,7 +417,7 @@
@Override
public boolean performHapticFeedbackLw(WindowState win, int effectId,
- boolean always) {
+ boolean always, String reason) {
return false;
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java b/services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java
index dbba2b2..7abf49e 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java
@@ -364,22 +364,23 @@
private void verifyNeverVibrate() {
verify(mVibrator, never()).vibrate(anyInt(), anyString(), (VibrationEffect) anyObject(),
- (AudioAttributes) anyObject());
+ anyString(), (AudioAttributes) anyObject());
}
private void verifyVibrate() {
verify(mVibrator, times(1)).vibrate(anyInt(), anyString(), argThat(mVibrateOnceMatcher),
- (AudioAttributes) anyObject());
+ anyString(), (AudioAttributes) anyObject());
}
private void verifyVibrateLooped() {
verify(mVibrator, times(1)).vibrate(anyInt(), anyString(), argThat(mVibrateLoopMatcher),
- (AudioAttributes) anyObject());
+ anyString(), (AudioAttributes) anyObject());
}
private void verifyDelayedVibrateLooped() {
verify(mVibrator, timeout(MAX_VIBRATION_DELAY).times(1)).vibrate(anyInt(), anyString(),
- argThat(mVibrateLoopMatcher), (AudioAttributes) anyObject());
+ argThat(mVibrateLoopMatcher), anyString(),
+ (AudioAttributes) anyObject());
}
private void verifyStopVibrate() {
@@ -646,7 +647,8 @@
VibrationEffect effect = VibrationEffect.createWaveform(r.getVibration(), -1);
verify(mVibrator, timeout(MAX_VIBRATION_DELAY).times(1)).vibrate(anyInt(), anyString(),
- eq(effect), (AudioAttributes) anyObject());
+ eq(effect), anyString(),
+ (AudioAttributes) anyObject());
assertTrue(r.isInterruptive());
}
@@ -680,7 +682,7 @@
mService.buzzBeepBlinkLocked(r);
verify(mVibrator, timeout(MAX_VIBRATION_DELAY).times(1)).vibrate(anyInt(), anyString(),
- eq(FALLBACK_VIBRATION), (AudioAttributes) anyObject());
+ eq(FALLBACK_VIBRATION), anyString(), (AudioAttributes) anyObject());
verify(mRingtonePlayer, never()).playAsync
(anyObject(), anyObject(), anyBoolean(), anyObject());
assertTrue(r.isInterruptive());
diff --git a/telecomm/java/android/telecom/AudioState.java b/telecomm/java/android/telecom/AudioState.java
index 33013ac..eb202a7 100644
--- a/telecomm/java/android/telecom/AudioState.java
+++ b/telecomm/java/android/telecom/AudioState.java
@@ -17,6 +17,7 @@
package android.telecom;
import android.annotation.SystemApi;
+import android.annotation.UnsupportedAppUsage;
import android.os.Parcel;
import android.os.Parcelable;
@@ -53,8 +54,11 @@
private static final int ROUTE_ALL = ROUTE_EARPIECE | ROUTE_BLUETOOTH | ROUTE_WIRED_HEADSET |
ROUTE_SPEAKER;
+ @UnsupportedAppUsage
private final boolean isMuted;
+ @UnsupportedAppUsage
private final int route;
+ @UnsupportedAppUsage
private final int supportedRouteMask;
public AudioState(boolean muted, int route, int supportedRouteMask) {
diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java
index 1c0e260..096cf37 100644
--- a/telecomm/java/android/telecom/Call.java
+++ b/telecomm/java/android/telecom/Call.java
@@ -19,6 +19,7 @@
import android.annotation.IntDef;
import android.annotation.Nullable;
import android.annotation.SystemApi;
+import android.annotation.UnsupportedAppUsage;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -308,6 +309,7 @@
* Call can be upgraded to a video call.
* @hide
*/
+ @UnsupportedAppUsage
public static final int CAPABILITY_CAN_UPGRADE_TO_VIDEO = 0x00080000;
/**
diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java
index 62fc9c4..3d2b397 100644
--- a/telecomm/java/android/telecom/Connection.java
+++ b/telecomm/java/android/telecom/Connection.java
@@ -23,6 +23,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
+import android.annotation.UnsupportedAppUsage;
import android.app.Notification;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;
@@ -1280,6 +1281,7 @@
* @param looper The looper.
* @hide
*/
+ @UnsupportedAppUsage
public VideoProvider(Looper looper) {
mBinder = new VideoProvider.VideoProviderBinder();
mMessageHandler = new VideoProvider.VideoProviderHandler(looper);
diff --git a/telecomm/java/android/telecom/ParcelableCall.java b/telecomm/java/android/telecom/ParcelableCall.java
index 6212a77..8b0211e 100644
--- a/telecomm/java/android/telecom/ParcelableCall.java
+++ b/telecomm/java/android/telecom/ParcelableCall.java
@@ -16,6 +16,7 @@
package android.telecom;
+import android.annotation.UnsupportedAppUsage;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcel;
@@ -117,6 +118,7 @@
}
/** The unique ID of the call. */
+ @UnsupportedAppUsage
public String getId() {
return mId;
}
@@ -130,6 +132,7 @@
* Reason for disconnection, as described by {@link android.telecomm.DisconnectCause}. Valid
* when call state is {@link CallState#DISCONNECTED}.
*/
+ @UnsupportedAppUsage
public DisconnectCause getDisconnectCause() {
return mDisconnectCause;
}
@@ -155,11 +158,13 @@
}
/** The time that the call switched to the active state. */
+ @UnsupportedAppUsage
public long getConnectTimeMillis() {
return mConnectTimeMillis;
}
/** The endpoint to which the call is connected. */
+ @UnsupportedAppUsage
public Uri getHandle() {
return mHandle;
}
@@ -300,6 +305,7 @@
}
/** Responsible for creating ParcelableCall objects for deserialized Parcels. */
+ @UnsupportedAppUsage
public static final Parcelable.Creator<ParcelableCall> CREATOR =
new Parcelable.Creator<ParcelableCall> () {
@Override
diff --git a/telecomm/java/android/telecom/Phone.java b/telecomm/java/android/telecom/Phone.java
index 99f94f2..d3ccd2c 100644
--- a/telecomm/java/android/telecom/Phone.java
+++ b/telecomm/java/android/telecom/Phone.java
@@ -17,6 +17,7 @@
package android.telecom;
import android.annotation.SystemApi;
+import android.annotation.UnsupportedAppUsage;
import android.bluetooth.BluetoothDevice;
import android.os.Bundle;
import android.os.RemoteException;
@@ -330,6 +331,7 @@
*
* @hide
*/
+ @UnsupportedAppUsage
public final void setProximitySensorOn() {
mInCallAdapter.turnProximitySensorOn();
}
@@ -345,6 +347,7 @@
*
* @hide
*/
+ @UnsupportedAppUsage
public final void setProximitySensorOff(boolean screenOnImmediately) {
mInCallAdapter.turnProximitySensorOff(screenOnImmediately);
}
diff --git a/telecomm/java/android/telecom/PhoneAccountHandle.java b/telecomm/java/android/telecom/PhoneAccountHandle.java
index 77b510d..279804e 100644
--- a/telecomm/java/android/telecom/PhoneAccountHandle.java
+++ b/telecomm/java/android/telecom/PhoneAccountHandle.java
@@ -17,6 +17,7 @@
package android.telecom;
import android.annotation.NonNull;
+import android.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.os.Parcel;
import android.os.Parcelable;
@@ -40,7 +41,9 @@
* See {@link PhoneAccount}, {@link TelecomManager}.
*/
public final class PhoneAccountHandle implements Parcelable {
+ @UnsupportedAppUsage
private final ComponentName mComponentName;
+ @UnsupportedAppUsage
private final String mId;
private final UserHandle mUserHandle;
@@ -164,6 +167,7 @@
}
};
+ @UnsupportedAppUsage
private PhoneAccountHandle(Parcel in) {
this(ComponentName.CREATOR.createFromParcel(in),
in.readString(),
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index 75572b3..48c1e24 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -20,6 +20,7 @@
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.SystemService;
+import android.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -376,6 +377,7 @@
* The phone number of the call used by Telecom to determine which call should be handed over.
* @hide
*/
+ @UnsupportedAppUsage
public static final String EXTRA_IS_HANDOVER = "android.telecom.extra.IS_HANDOVER";
/**
@@ -493,6 +495,7 @@
*
* @hide
*/
+ @UnsupportedAppUsage
public static final int TTY_MODE_OFF = 0;
/**
@@ -652,6 +655,7 @@
/**
* @hide
*/
+ @UnsupportedAppUsage
public static TelecomManager from(Context context) {
return (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
}
@@ -721,6 +725,7 @@
* @return The user outgoing phone account selected by the user.
* @hide
*/
+ @UnsupportedAppUsage
public PhoneAccountHandle getUserSelectedOutgoingPhoneAccount() {
try {
if (isServiceConnected()) {
@@ -736,6 +741,7 @@
* Sets the user-chosen default for making outgoing phone calls.
* @hide
*/
+ @UnsupportedAppUsage
public void setUserSelectedOutgoingPhoneAccount(PhoneAccountHandle accountHandle) {
try {
if (isServiceConnected()) {
@@ -773,6 +779,7 @@
*
* @hide
*/
+ @UnsupportedAppUsage
public PhoneAccountHandle getSimCallManager(int userId) {
try {
if (isServiceConnected()) {
@@ -876,6 +883,7 @@
* @return A list of {@code PhoneAccountHandle} objects.
* @hide
*/
+ @UnsupportedAppUsage
public List<PhoneAccountHandle> getCallCapablePhoneAccounts(boolean includeDisabledAccounts) {
try {
if (isServiceConnected()) {
@@ -1109,6 +1117,7 @@
*
* @hide
*/
+ @UnsupportedAppUsage
public boolean setDefaultDialer(String packageName) {
try {
if (isServiceConnected()) {
@@ -1126,6 +1135,7 @@
* @return package name for the system dialer package or null if no system dialer is preloaded.
* @hide
*/
+ @UnsupportedAppUsage
public String getSystemDialerPackage() {
try {
if (isServiceConnected()) {
@@ -1413,6 +1423,7 @@
* - {@link TelecomManager#TTY_MODE_VCO}
* @hide
*/
+ @UnsupportedAppUsage
public int getCurrentTtyMode() {
try {
if (isServiceConnected()) {
diff --git a/telecomm/java/android/telecom/VideoCallImpl.java b/telecomm/java/android/telecom/VideoCallImpl.java
index bae58ff..2c7fecb 100644
--- a/telecomm/java/android/telecom/VideoCallImpl.java
+++ b/telecomm/java/android/telecom/VideoCallImpl.java
@@ -16,6 +16,7 @@
package android.telecom;
+import android.annotation.UnsupportedAppUsage;
import android.net.Uri;
import android.os.Handler;
import android.os.IBinder;
@@ -217,6 +218,7 @@
mTargetSdkVersion = sdkVersion;
}
+ @UnsupportedAppUsage
public void destroy() {
unregisterCallback(mCallback);
}
diff --git a/telecomm/java/android/telecom/VideoProfile.java b/telecomm/java/android/telecom/VideoProfile.java
index 90ed36f..bbac8eb 100644
--- a/telecomm/java/android/telecom/VideoProfile.java
+++ b/telecomm/java/android/telecom/VideoProfile.java
@@ -17,6 +17,7 @@
package android.telecom;
import android.annotation.IntDef;
+import android.annotation.UnsupportedAppUsage;
import android.os.Parcel;
import android.os.Parcelable;
@@ -377,6 +378,7 @@
* @param maxZoom Maximum zoom supported by camera.
* @hide
*/
+ @UnsupportedAppUsage
public CameraCapabilities(int width, int height, boolean zoomSupported, float maxZoom) {
mWidth = width;
mHeight = height;
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index 1dfe5df..ab94093 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -224,6 +224,13 @@
public static final String
KEY_ALLOW_EMERGENCY_NUMBERS_IN_CALL_LOG_BOOL = "allow_emergency_numbers_in_call_log_bool";
+ /**
+ * A string array containing numbers that shouldn't be included in the call log.
+ * @hide
+ */
+ public static final String KEY_UNLOGGABLE_NUMBERS_STRING_ARRAY =
+ "unloggable_numbers_string_array";
+
/** If true, removes the Voice Privacy option from Call Settings */
public static final String KEY_VOICE_PRIVACY_DISABLE_UI_BOOL = "voice_privacy_disable_ui_bool";
@@ -2041,6 +2048,7 @@
sDefaults.putBoolean(KEY_AUTO_RETRY_FAILED_WIFI_EMERGENCY_CALL, false);
sDefaults.putBoolean(KEY_ADDITIONAL_CALL_SETTING_BOOL, true);
sDefaults.putBoolean(KEY_ALLOW_EMERGENCY_NUMBERS_IN_CALL_LOG_BOOL, false);
+ sDefaults.putStringArray(KEY_UNLOGGABLE_NUMBERS_STRING_ARRAY, null);
sDefaults.putBoolean(KEY_ALLOW_LOCAL_DTMF_TONES_BOOL, true);
sDefaults.putBoolean(KEY_PLAY_CALL_RECORDING_TONE_BOOL, false);
sDefaults.putBoolean(KEY_APN_EXPAND_BOOL, true);
diff --git a/tests/net/java/android/net/NetworkUtilsTest.java b/tests/net/java/android/net/NetworkUtilsTest.java
index a5ee8e3..2b172da 100644
--- a/tests/net/java/android/net/NetworkUtilsTest.java
+++ b/tests/net/java/android/net/NetworkUtilsTest.java
@@ -16,17 +16,32 @@
package android.net;
-import android.net.NetworkUtils;
-import android.test.suitebuilder.annotation.SmallTest;
+import static android.net.NetworkUtils.getImplicitNetmask;
+import static android.net.NetworkUtils.inet4AddressToIntHTH;
+import static android.net.NetworkUtils.inet4AddressToIntHTL;
+import static android.net.NetworkUtils.intToInet4AddressHTH;
+import static android.net.NetworkUtils.intToInet4AddressHTL;
+import static android.net.NetworkUtils.netmaskToPrefixLength;
+import static android.net.NetworkUtils.prefixLengthToV4NetmaskIntHTH;
+import static android.net.NetworkUtils.prefixLengthToV4NetmaskIntHTL;
+
+import static junit.framework.Assert.assertEquals;
+
+import static org.junit.Assert.fail;
+
+import android.support.test.runner.AndroidJUnit4;
import java.math.BigInteger;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.util.TreeSet;
-import junit.framework.TestCase;
+import org.junit.Test;
+import org.junit.runner.RunWith;
-public class NetworkUtilsTest extends TestCase {
+@RunWith(AndroidJUnit4.class)
+@android.support.test.filters.SmallTest
+public class NetworkUtilsTest {
private InetAddress Address(String addr) {
return InetAddress.parseNumericAddress(addr);
@@ -36,41 +51,126 @@
return (Inet4Address) Address(addr);
}
- @SmallTest
+ @Test
public void testGetImplicitNetmask() {
- assertEquals(8, NetworkUtils.getImplicitNetmask(IPv4Address("4.2.2.2")));
- assertEquals(8, NetworkUtils.getImplicitNetmask(IPv4Address("10.5.6.7")));
- assertEquals(16, NetworkUtils.getImplicitNetmask(IPv4Address("173.194.72.105")));
- assertEquals(16, NetworkUtils.getImplicitNetmask(IPv4Address("172.23.68.145")));
- assertEquals(24, NetworkUtils.getImplicitNetmask(IPv4Address("192.0.2.1")));
- assertEquals(24, NetworkUtils.getImplicitNetmask(IPv4Address("192.168.5.1")));
- assertEquals(32, NetworkUtils.getImplicitNetmask(IPv4Address("224.0.0.1")));
- assertEquals(32, NetworkUtils.getImplicitNetmask(IPv4Address("255.6.7.8")));
+ assertEquals(8, getImplicitNetmask(IPv4Address("4.2.2.2")));
+ assertEquals(8, getImplicitNetmask(IPv4Address("10.5.6.7")));
+ assertEquals(16, getImplicitNetmask(IPv4Address("173.194.72.105")));
+ assertEquals(16, getImplicitNetmask(IPv4Address("172.23.68.145")));
+ assertEquals(24, getImplicitNetmask(IPv4Address("192.0.2.1")));
+ assertEquals(24, getImplicitNetmask(IPv4Address("192.168.5.1")));
+ assertEquals(32, getImplicitNetmask(IPv4Address("224.0.0.1")));
+ assertEquals(32, getImplicitNetmask(IPv4Address("255.6.7.8")));
}
private void assertInvalidNetworkMask(Inet4Address addr) {
try {
- NetworkUtils.netmaskToPrefixLength(addr);
+ netmaskToPrefixLength(addr);
fail("Invalid netmask " + addr.getHostAddress() + " did not cause exception");
} catch (IllegalArgumentException expected) {
}
}
- @SmallTest
+ @Test
+ public void testInet4AddressToIntHTL() {
+ assertEquals(0, inet4AddressToIntHTL(IPv4Address("0.0.0.0")));
+ assertEquals(0x000080ff, inet4AddressToIntHTL(IPv4Address("255.128.0.0")));
+ assertEquals(0x0080ff0a, inet4AddressToIntHTL(IPv4Address("10.255.128.0")));
+ assertEquals(0x00feff0a, inet4AddressToIntHTL(IPv4Address("10.255.254.0")));
+ assertEquals(0xfeffa8c0, inet4AddressToIntHTL(IPv4Address("192.168.255.254")));
+ assertEquals(0xffffa8c0, inet4AddressToIntHTL(IPv4Address("192.168.255.255")));
+ }
+
+ @Test
+ public void testIntToInet4AddressHTL() {
+ assertEquals(IPv4Address("0.0.0.0"), intToInet4AddressHTL(0));
+ assertEquals(IPv4Address("255.128.0.0"), intToInet4AddressHTL(0x000080ff));
+ assertEquals(IPv4Address("10.255.128.0"), intToInet4AddressHTL(0x0080ff0a));
+ assertEquals(IPv4Address("10.255.254.0"), intToInet4AddressHTL(0x00feff0a));
+ assertEquals(IPv4Address("192.168.255.254"), intToInet4AddressHTL(0xfeffa8c0));
+ assertEquals(IPv4Address("192.168.255.255"), intToInet4AddressHTL(0xffffa8c0));
+ }
+
+ @Test
+ public void testInet4AddressToIntHTH() {
+ assertEquals(0, inet4AddressToIntHTH(IPv4Address("0.0.0.0")));
+ assertEquals(0xff800000, inet4AddressToIntHTH(IPv4Address("255.128.0.0")));
+ assertEquals(0x0aff8000, inet4AddressToIntHTH(IPv4Address("10.255.128.0")));
+ assertEquals(0x0afffe00, inet4AddressToIntHTH(IPv4Address("10.255.254.0")));
+ assertEquals(0xc0a8fffe, inet4AddressToIntHTH(IPv4Address("192.168.255.254")));
+ assertEquals(0xc0a8ffff, inet4AddressToIntHTH(IPv4Address("192.168.255.255")));
+ }
+
+ @Test
+ public void testIntToInet4AddressHTH() {
+ assertEquals(IPv4Address("0.0.0.0"), intToInet4AddressHTH(0));
+ assertEquals(IPv4Address("255.128.0.0"), intToInet4AddressHTH(0xff800000));
+ assertEquals(IPv4Address("10.255.128.0"), intToInet4AddressHTH(0x0aff8000));
+ assertEquals(IPv4Address("10.255.254.0"), intToInet4AddressHTH(0x0afffe00));
+ assertEquals(IPv4Address("192.168.255.254"), intToInet4AddressHTH(0xc0a8fffe));
+ assertEquals(IPv4Address("192.168.255.255"), intToInet4AddressHTH(0xc0a8ffff));
+ }
+
+ @Test
public void testNetmaskToPrefixLength() {
- assertEquals(0, NetworkUtils.netmaskToPrefixLength(IPv4Address("0.0.0.0")));
- assertEquals(9, NetworkUtils.netmaskToPrefixLength(IPv4Address("255.128.0.0")));
- assertEquals(17, NetworkUtils.netmaskToPrefixLength(IPv4Address("255.255.128.0")));
- assertEquals(23, NetworkUtils.netmaskToPrefixLength(IPv4Address("255.255.254.0")));
- assertEquals(31, NetworkUtils.netmaskToPrefixLength(IPv4Address("255.255.255.254")));
- assertEquals(32, NetworkUtils.netmaskToPrefixLength(IPv4Address("255.255.255.255")));
+ assertEquals(0, netmaskToPrefixLength(IPv4Address("0.0.0.0")));
+ assertEquals(9, netmaskToPrefixLength(IPv4Address("255.128.0.0")));
+ assertEquals(17, netmaskToPrefixLength(IPv4Address("255.255.128.0")));
+ assertEquals(23, netmaskToPrefixLength(IPv4Address("255.255.254.0")));
+ assertEquals(31, netmaskToPrefixLength(IPv4Address("255.255.255.254")));
+ assertEquals(32, netmaskToPrefixLength(IPv4Address("255.255.255.255")));
assertInvalidNetworkMask(IPv4Address("0.0.0.1"));
assertInvalidNetworkMask(IPv4Address("255.255.255.253"));
assertInvalidNetworkMask(IPv4Address("255.255.0.255"));
}
- @SmallTest
+
+ @Test
+ public void testPrefixLengthToV4NetmaskIntHTL() {
+ assertEquals(0, prefixLengthToV4NetmaskIntHTL(0));
+ assertEquals(0x000080ff /* 255.128.0.0 */, prefixLengthToV4NetmaskIntHTL(9));
+ assertEquals(0x0080ffff /* 255.255.128.0 */, prefixLengthToV4NetmaskIntHTL(17));
+ assertEquals(0x00feffff /* 255.255.254.0 */, prefixLengthToV4NetmaskIntHTL(23));
+ assertEquals(0xfeffffff /* 255.255.255.254 */, prefixLengthToV4NetmaskIntHTL(31));
+ assertEquals(0xffffffff /* 255.255.255.255 */, prefixLengthToV4NetmaskIntHTL(32));
+ }
+
+ @Test
+ public void testPrefixLengthToV4NetmaskIntHTH() {
+ assertEquals(0, prefixLengthToV4NetmaskIntHTH(0));
+ assertEquals(0xff800000 /* 255.128.0.0 */, prefixLengthToV4NetmaskIntHTH(9));
+ assertEquals(0xffff8000 /* 255.255.128.0 */, prefixLengthToV4NetmaskIntHTH(17));
+ assertEquals(0xfffffe00 /* 255.255.254.0 */, prefixLengthToV4NetmaskIntHTH(23));
+ assertEquals(0xfffffffe /* 255.255.255.254 */, prefixLengthToV4NetmaskIntHTH(31));
+ assertEquals(0xffffffff /* 255.255.255.255 */, prefixLengthToV4NetmaskIntHTH(32));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testPrefixLengthToV4NetmaskIntHTH_NegativeLength() {
+ prefixLengthToV4NetmaskIntHTH(-1);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testPrefixLengthToV4NetmaskIntHTH_LengthTooLarge() {
+ prefixLengthToV4NetmaskIntHTH(33);
+ }
+
+ private void checkAddressMasking(String expectedAddr, String addr, int prefixLength) {
+ final int prefix = prefixLengthToV4NetmaskIntHTH(prefixLength);
+ final int addrInt = inet4AddressToIntHTH(IPv4Address(addr));
+ assertEquals(IPv4Address(expectedAddr), intToInet4AddressHTH(prefix & addrInt));
+ }
+
+ @Test
+ public void testPrefixLengthToV4NetmaskIntHTH_MaskAddr() {
+ checkAddressMasking("192.168.0.0", "192.168.128.1", 16);
+ checkAddressMasking("255.240.0.0", "255.255.255.255", 12);
+ checkAddressMasking("255.255.255.255", "255.255.255.255", 32);
+ checkAddressMasking("0.0.0.0", "255.255.255.255", 0);
+ }
+
+ @Test
public void testRoutedIPv4AddressCount() {
final TreeSet<IpPrefix> set = new TreeSet<>(IpPrefix.lengthComparator());
// No routes routes to no addresses.
@@ -118,7 +218,7 @@
assertEquals(7l - 4 + 4 + 16 + 65536, NetworkUtils.routedIPv4AddressCount(set));
}
- @SmallTest
+ @Test
public void testRoutedIPv6AddressCount() {
final TreeSet<IpPrefix> set = new TreeSet<>(IpPrefix.lengthComparator());
// No routes routes to no addresses.
diff --git a/tests/permission/src/com/android/framework/permission/tests/VibratorServicePermissionTest.java b/tests/permission/src/com/android/framework/permission/tests/VibratorServicePermissionTest.java
index 2757296..388c7d0 100644
--- a/tests/permission/src/com/android/framework/permission/tests/VibratorServicePermissionTest.java
+++ b/tests/permission/src/com/android/framework/permission/tests/VibratorServicePermissionTest.java
@@ -52,7 +52,7 @@
final VibrationEffect effect =
VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE);
mVibratorService.vibrate(Process.myUid(), null, effect, AudioManager.STREAM_ALARM,
- new Binder());
+ "testVibrate", new Binder());
fail("vibrate did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected