summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-10-27 14:49:38 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-10-27 14:49:38 +0000
commit37e2e248430976004df02588e9ff489bb2cd5ae8 (patch)
treeb68defcb321c455098c9f5027f46a6ec3ce9570b
parent4745025d36ce428dce07ef13ee6039f7234ea087 (diff)
parentee62f699468260b4e993de899e9cef9d853018dd (diff)
downloadbase-37e2e248430976004df02588e9ff489bb2cd5ae8.tar.gz
Merge cherrypicks of [3134552, 3130583, 3131953, 3131954, 3131955, 3131956, 3131957, 3131958, 3131959, 3132062, 3132336, 3131074, 3133939, 3131024, 3131025, 3131026, 3130584, 3130879, 3130880] into oc-mr1-release
Change-Id: I345643be0750801a95bd6a61a235f1576501807f
-rw-r--r--packages/SystemUI/src/com/android/systemui/ForegroundServiceControllerImpl.java16
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/ForegroundServiceControllerTest.java1
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java11
-rw-r--r--tools/aapt/Command.cpp11
-rw-r--r--tools/aapt/ResourceTable.cpp4
-rw-r--r--tools/aapt2/Android.bp2
-rw-r--r--tools/aapt2/cmd/Link.cpp2
-rw-r--r--tools/aapt2/cmd/Util.cpp17
-rw-r--r--tools/aapt2/cmd/Util_test.cpp38
9 files changed, 81 insertions, 21 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/ForegroundServiceControllerImpl.java b/packages/SystemUI/src/com/android/systemui/ForegroundServiceControllerImpl.java
index c930d567254a..3714c4ea7e2c 100644
--- a/packages/SystemUI/src/com/android/systemui/ForegroundServiceControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/ForegroundServiceControllerImpl.java
@@ -34,6 +34,10 @@ import java.util.Arrays;
*/
public class ForegroundServiceControllerImpl
implements ForegroundServiceController {
+
+ // shelf life of foreground services before they go bad
+ public static final long FG_SERVICE_GRACE_MILLIS = 5000;
+
private static final String TAG = "FgServiceController";
private static final boolean DBG = false;
@@ -72,7 +76,7 @@ public class ForegroundServiceControllerImpl
if (isDungeonNotification(sbn)) {
// if you remove the dungeon entirely, we take that to mean there are
// no running services
- userServices.setRunningServices(null);
+ userServices.setRunningServices(null, 0);
return true;
} else {
// this is safe to call on any notification, not just FLAG_FOREGROUND_SERVICE
@@ -94,7 +98,7 @@ public class ForegroundServiceControllerImpl
final Bundle extras = sbn.getNotification().extras;
if (extras != null) {
final String[] svcs = extras.getStringArray(Notification.EXTRA_FOREGROUND_APPS);
- userServices.setRunningServices(svcs); // null ok
+ userServices.setRunningServices(svcs, sbn.getNotification().when);
}
} else {
userServices.removeNotification(sbn.getPackageName(), sbn.getKey());
@@ -118,9 +122,11 @@ public class ForegroundServiceControllerImpl
*/
private static class UserServices {
private String[] mRunning = null;
+ private long mServiceStartTime = 0;
private ArrayMap<String, ArraySet<String>> mNotifications = new ArrayMap<>(1);
- public void setRunningServices(String[] pkgs) {
+ public void setRunningServices(String[] pkgs, long serviceStartTime) {
mRunning = pkgs != null ? Arrays.copyOf(pkgs, pkgs.length) : null;
+ mServiceStartTime = serviceStartTime;
}
public void addNotification(String pkg, String key) {
if (mNotifications.get(pkg) == null) {
@@ -142,7 +148,9 @@ public class ForegroundServiceControllerImpl
return found;
}
public boolean isDungeonNeeded() {
- if (mRunning != null) {
+ if (mRunning != null
+ && System.currentTimeMillis() - mServiceStartTime >= FG_SERVICE_GRACE_MILLIS) {
+
for (String pkg : mRunning) {
final ArraySet<String> set = mNotifications.get(pkg);
if (set == null || set.size() == 0) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/ForegroundServiceControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/ForegroundServiceControllerTest.java
index 1f5255a0e869..943020c7b28e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/ForegroundServiceControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/ForegroundServiceControllerTest.java
@@ -287,6 +287,7 @@ public class ForegroundServiceControllerTest extends SysuiTestCase {
final Bundle extras = new Bundle();
if (pkgs != null) extras.putStringArray(Notification.EXTRA_FOREGROUND_APPS, pkgs);
n.extras = extras;
+ n.when = System.currentTimeMillis() - 10000; // ten seconds ago
final StatusBarNotification sbn = makeMockSBN(userid, "android",
SystemMessageProto.SystemMessage.NOTE_FOREGROUND_SERVICES,
null, n);
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 0d3925c19b45..06600bf75ffa 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -3794,19 +3794,16 @@ public class PackageManagerService extends IPackageManager.Stub
* <p>
* Currently, there are three cases in which this can occur:
* <ol>
- * <li>The calling application is a "special" process. The special
- * processes are {@link Process#SYSTEM_UID}, {@link Process#SHELL_UID}
- * and {@code 0}</li>
+ * <li>The calling application is a "special" process. Special processes
+ * are those with a UID < {@link Process#FIRST_APPLICATION_UID}.</li>
* <li>The calling application has the permission
- * {@link android.Manifest.permission#ACCESS_INSTANT_APPS}</li>
+ * {@link android.Manifest.permission#ACCESS_INSTANT_APPS}.</li>
* <li>The calling application is the default launcher on the
* system partition.</li>
* </ol>
*/
private boolean canViewInstantApps(int callingUid, int userId) {
- if (callingUid == Process.SYSTEM_UID
- || callingUid == Process.SHELL_UID
- || callingUid == Process.ROOT_UID) {
+ if (callingUid < Process.FIRST_APPLICATION_UID) {
return true;
}
if (mContext.checkCallingOrSelfPermission(
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index ba731801e507..63f1802fdf2e 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -757,12 +757,8 @@ int doDump(Bundle* bundle)
AssetManager assets;
int32_t assetsCookie;
- if (!assets.addAssetPath(String8(filename), &assetsCookie)) {
- fprintf(stderr, "ERROR: dump failed because assets could not be loaded\n");
- return 1;
- }
- // Now add any dependencies passed in.
+ // Add any dependencies passed in.
for (size_t i = 0; i < bundle->getPackageIncludes().size(); i++) {
const String8& assetPath = bundle->getPackageIncludes()[i];
if (!assets.addAssetPath(assetPath, NULL)) {
@@ -771,6 +767,11 @@ int doDump(Bundle* bundle)
}
}
+ if (!assets.addAssetPath(String8(filename), &assetsCookie)) {
+ fprintf(stderr, "ERROR: dump failed because assets could not be loaded\n");
+ return 1;
+ }
+
// Make a dummy config for retrieving resources... we need to supply
// non-default values for some configs so that we can retrieve resources
// in the app that don't have a default. The most important of these is
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index 52b93a945433..669afe18af88 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -4847,6 +4847,7 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle,
const String16 animatedVector16("animated-vector");
const String16 pathInterpolator16("pathInterpolator");
const String16 objectAnimator16("objectAnimator");
+ const String16 gradient16("gradient");
const int minSdk = getMinSdkVersion(bundle);
if (minSdk >= SDK_LOLLIPOP_MR1) {
@@ -4874,7 +4875,8 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle,
if (bundle->getNoVersionVectors() && (node->getElementName() == vector16 ||
node->getElementName() == animatedVector16 ||
node->getElementName() == objectAnimator16 ||
- node->getElementName() == pathInterpolator16)) {
+ node->getElementName() == pathInterpolator16 ||
+ node->getElementName() == gradient16)) {
// We were told not to version vector tags, so skip the children here.
continue;
}
diff --git a/tools/aapt2/Android.bp b/tools/aapt2/Android.bp
index 2ae2e496f25d..76225748009f 100644
--- a/tools/aapt2/Android.bp
+++ b/tools/aapt2/Android.bp
@@ -170,7 +170,7 @@ cc_test_host {
"test/Builders.cpp",
"test/Common.cpp",
"**/*_test.cpp",
- ],
+ ] + toolSources,
static_libs: [
"libaapt2",
"libgmock",
diff --git a/tools/aapt2/cmd/Link.cpp b/tools/aapt2/cmd/Link.cpp
index 7742f36f1610..fea11ed70bbe 100644
--- a/tools/aapt2/cmd/Link.cpp
+++ b/tools/aapt2/cmd/Link.cpp
@@ -442,7 +442,7 @@ static bool IsTransitionElement(const std::string& name) {
static bool IsVectorElement(const std::string& name) {
return name == "vector" || name == "animated-vector" || name == "pathInterpolator" ||
- name == "objectAnimator";
+ name == "objectAnimator" || name == "gradient";
}
template <typename T>
diff --git a/tools/aapt2/cmd/Util.cpp b/tools/aapt2/cmd/Util.cpp
index d17858d45d08..708bed80555b 100644
--- a/tools/aapt2/cmd/Util.cpp
+++ b/tools/aapt2/cmd/Util.cpp
@@ -72,7 +72,6 @@ bool ParseSplitParameter(const StringPiece& arg, IDiagnostics* diag, std::string
}
*out_path = parts[0];
- std::vector<ConfigDescription> configs;
for (const StringPiece& config_str : util::Tokenize(parts[1], ',')) {
ConfigDescription config;
if (!ConfigDescription::Parse(config_str, &config)) {
@@ -141,6 +140,16 @@ static xml::NamespaceDecl CreateAndroidNamespaceDecl() {
return decl;
}
+static std::string MakePackageSafeName(const std::string &name) {
+ std::string result(name);
+ for (char &c : result) {
+ if (c == '-') {
+ c = '_';
+ }
+ }
+ return result;
+}
+
std::unique_ptr<xml::XmlResource> GenerateSplitManifest(const AppInfo& app_info,
const SplitConstraints& constraints) {
const ResourceId kVersionCode(0x0101021b);
@@ -172,7 +181,11 @@ std::unique_ptr<xml::XmlResource> GenerateSplitManifest(const AppInfo& app_info,
if (app_info.split_name) {
split_name << app_info.split_name.value() << ".";
}
- split_name << "config." << util::Joiner(constraints.configs, "_");
+ std::vector<std::string> sanitized_config_names;
+ for (const auto &config : constraints.configs) {
+ sanitized_config_names.push_back(MakePackageSafeName(config.toString().string()));
+ }
+ split_name << "config." << util::Joiner(sanitized_config_names, "_");
manifest_el->attributes.push_back(xml::Attribute{"", "split", split_name.str()});
diff --git a/tools/aapt2/cmd/Util_test.cpp b/tools/aapt2/cmd/Util_test.cpp
new file mode 100644
index 000000000000..9c33135f228d
--- /dev/null
+++ b/tools/aapt2/cmd/Util_test.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Util.h"
+
+#include "AppInfo.h"
+#include "split/TableSplitter.h"
+#include "test/Test.h"
+
+namespace aapt {
+
+TEST(UtilTest, SplitNamesAreSanitized) {
+ AppInfo app_info{"com.pkg"};
+ SplitConstraints split_constraints{{test::ParseConfigOrDie("en-rUS-land")}};
+
+ const auto doc = GenerateSplitManifest(app_info, split_constraints);
+ const auto &root = doc->root;
+ EXPECT_EQ(root->name, "manifest");
+ // split names cannot contain hyphens
+ EXPECT_EQ(root->FindAttribute("", "split")->value, "config.en_rUS_land");
+ // but we should use resource qualifiers verbatim in 'targetConfig'.
+ EXPECT_EQ(root->FindAttribute("", "targetConfig")->value, "en-rUS-land");
+}
+
+} // namespace aapt