Skip to content

Commit 7a7ed2b

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "Do not check features in PackageManagerService DO NOT MERGE" into gingerbread
2 parents a019d15 + fa2ae1a commit 7a7ed2b

6 files changed

Lines changed: 57 additions & 21 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
LOCAL_PATH:= $(call my-dir)
2+
include $(CLEAR_VARS)
3+
4+
LOCAL_MODULE_TAGS := tests
5+
6+
LOCAL_SRC_FILES := $(call all-subdir-java-files)
7+
8+
LOCAL_PACKAGE_NAME := FrameworkCoreTests_install_uses_feature
9+
10+
include $(BUILD_PACKAGE)
11+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2010 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
17+
package="com.android.frameworks.coretests.install_uses_feature">
18+
19+
<uses-feature android:name="com.android.frameworks.coretests.nonexistent" />
20+
21+
<application android:hasCode="false">
22+
</application>
23+
</manifest>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<!-- Just need this dummy file to have something to build. -->
4+
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
5+
<string name="dummy">dummy</string>
6+
</resources>
3.08 KB
Binary file not shown.

core/tests/coretests/src/android/content/pm/PackageManagerTests.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2838,6 +2838,23 @@ public void testReplaceSecondSharedMatchMoreCerts() {
28382838
installFromRawResource("install.apk", rapk2, PackageManager.INSTALL_REPLACE_EXISTING, true,
28392839
fail, retCode, PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
28402840
}
2841+
2842+
/**
2843+
* Unknown features should be allowed to install. This prevents older phones
2844+
* from rejecting new packages that specify features that didn't exist when
2845+
* an older phone existed. All older phones are assumed to have those
2846+
* features.
2847+
* <p>
2848+
* Right now we allow all packages to be installed regardless of their
2849+
* features.
2850+
*/
2851+
@LargeTest
2852+
public void testUsesFeatureUnknownFeature() {
2853+
int retCode = PackageManager.INSTALL_SUCCEEDED;
2854+
installFromRawResource("install.apk", R.raw.install_uses_feature, 0, true, false, retCode,
2855+
PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
2856+
}
2857+
28412858
/*---------- Recommended install location tests ----*/
28422859
/*
28432860
* TODO's

services/java/com/android/server/PackageManagerService.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2926,27 +2926,6 @@ private PackageParser.Package scanPackageLI(PackageParser.Package pkg,
29262926
System.arraycopy(mTmpSharedLibraries, 0,
29272927
pkg.usesLibraryFiles, 0, num);
29282928
}
2929-
2930-
if (pkg.reqFeatures != null) {
2931-
N = pkg.reqFeatures.size();
2932-
for (int i=0; i<N; i++) {
2933-
FeatureInfo fi = pkg.reqFeatures.get(i);
2934-
if ((fi.flags&FeatureInfo.FLAG_REQUIRED) == 0) {
2935-
// Don't care.
2936-
continue;
2937-
}
2938-
2939-
if (fi.name != null) {
2940-
if (mAvailableFeatures.get(fi.name) == null) {
2941-
Slog.e(TAG, "Package " + pkg.packageName
2942-
+ " requires unavailable feature "
2943-
+ fi.name + "; failing!");
2944-
mLastScanError = PackageManager.INSTALL_FAILED_MISSING_FEATURE;
2945-
return null;
2946-
}
2947-
}
2948-
}
2949-
}
29502929
}
29512930

29522931
if (pkg.mSharedUserId != null) {

0 commit comments

Comments
 (0)