summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chen Xu <fionaxu@google.com> 2019-07-30 11:23:04 -0700
committer Chen Xu <fionaxu@google.com> 2019-09-04 11:42:14 -0700
commit27c4e658b3fedee791835a40f5f28a6c60e89dd3 (patch)
treec7a24526092b9bd684845c375bfcc5882de7a596
parent2c833c2b0f7131d8490e29c42d7da88c62673341 (diff)
remove symbols from greylist
telephony-common is not intended to used by any apps and being in boot class is not updatability friendly. We are removing telephony-common from bootclass and apply <uses-library> in manifest instead. for apps targeting < R will auto load telephony-common lib for app compatibility. For apos >=R, only allow usage for phone UID. Bug: 135955937 Test: Build Change-Id: Ia318661546df6d8516328886e5cc0c54d5cfafe6
-rw-r--r--config/hiddenapi-greylist.txt4
-rw-r--r--core/java/android/content/pm/AndroidTelephonyCommonUpdater.java82
-rw-r--r--core/java/android/content/pm/PackageBackwardCompatibility.java2
-rw-r--r--core/java/android/content/pm/SharedLibraryNames.java2
-rw-r--r--core/tests/coretests/src/android/content/pm/AndroidTelephonyCommonUpdaterTest.java140
-rw-r--r--core/tests/coretests/src/android/content/pm/PackageBuilder.java8
-rw-r--r--data/etc/platform.xml2
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/SmsMessage.java2
8 files changed, 237 insertions, 5 deletions
diff --git a/config/hiddenapi-greylist.txt b/config/hiddenapi-greylist.txt
index 9f48f8a12b13..2edd7c45373e 100644
--- a/config/hiddenapi-greylist.txt
+++ b/config/hiddenapi-greylist.txt
@@ -1174,8 +1174,6 @@ Lcom/android/internal/statusbar/IStatusBar$Stub;->asInterface(Landroid/os/IBinde
Lcom/android/internal/statusbar/IStatusBarService$Stub;-><init>()V
Lcom/android/internal/statusbar/IStatusBarService$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/statusbar/IStatusBarService;
Lcom/android/internal/telecom/ITelecomService$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/telecom/ITelecomService;
-Lcom/android/internal/telephony/IIccPhoneBook$Stub$Proxy;->mRemote:Landroid/os/IBinder;
-Lcom/android/internal/telephony/IIccPhoneBook$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/telephony/IIccPhoneBook;
Lcom/android/internal/telephony/IMms$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/telephony/IMms;
Lcom/android/internal/telephony/IPhoneStateListener$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/telephony/IPhoneStateListener;
Lcom/android/internal/telephony/IPhoneSubInfo$Stub$Proxy;-><init>(Landroid/os/IBinder;)V
@@ -1183,7 +1181,6 @@ Lcom/android/internal/telephony/IPhoneSubInfo$Stub;->asInterface(Landroid/os/IBi
Lcom/android/internal/telephony/IPhoneSubInfo$Stub;->TRANSACTION_getDeviceId:I
Lcom/android/internal/telephony/ISms$Stub;-><init>()V
Lcom/android/internal/telephony/ISms$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/telephony/ISms;
-Lcom/android/internal/telephony/ISub$Stub$Proxy;-><init>(Landroid/os/IBinder;)V
Lcom/android/internal/telephony/ISub$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/telephony/ISub;
Lcom/android/internal/telephony/ITelephony$Stub$Proxy;-><init>(Landroid/os/IBinder;)V
Lcom/android/internal/telephony/ITelephony$Stub$Proxy;->mRemote:Landroid/os/IBinder;
@@ -1207,5 +1204,4 @@ Lcom/android/server/net/BaseNetworkObserver;-><init>()V
Lcom/android/server/ResettableTimeout$T;-><init>(Lcom/android/server/ResettableTimeout;)V
Lcom/google/android/gles_jni/EGLImpl;-><init>()V
Lcom/google/android/gles_jni/GLImpl;-><init>()V
-Lcom/google/android/mms/pdu/PduParser;->$assertionsDisabled:Z
Lcom/google/android/util/AbstractMessageParser$Token$Type;->values()[Lcom/google/android/util/AbstractMessageParser$Token$Type;
diff --git a/core/java/android/content/pm/AndroidTelephonyCommonUpdater.java b/core/java/android/content/pm/AndroidTelephonyCommonUpdater.java
new file mode 100644
index 000000000000..1a720d50f2ce
--- /dev/null
+++ b/core/java/android/content/pm/AndroidTelephonyCommonUpdater.java
@@ -0,0 +1,82 @@
+/*
+ * 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.content.pm;
+
+import static android.content.pm.SharedLibraryNames.ANDROID_TELEPHONY_COMMON;
+
+
+import com.android.internal.compat.IPlatformCompat;
+import android.compat.annotation.ChangeId;
+import android.compat.annotation.EnabledAfter;
+import android.content.pm.PackageParser.Package;
+
+import android.os.Build.VERSION_CODES;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.util.Log;
+import com.android.internal.annotations.VisibleForTesting;
+
+/**
+ * Updates a package to ensure that
+ * <ul>
+ * <li> if apps have target SDK < R, then telephony-common library is included by default to
+ * their class path. Even without <uses-library>.</li>
+ * <li> if apps with target SDK level >= R && have special permission (or Phone UID):
+ * apply <uses-library> on telephony-common should work.</li>
+ * <li> Otherwise not allow to use the lib.
+ * See {@link PackageSharedLibraryUpdater#removeLibrary(Package, String)}.</li>
+ * </ul>
+ *
+ * @hide
+ */
+@VisibleForTesting
+public class AndroidTelephonyCommonUpdater extends PackageSharedLibraryUpdater {
+
+ private static final String TAG = AndroidTelephonyCommonUpdater.class.getSimpleName();
+ /**
+ * Restrict telephony-common lib for apps having target SDK >= R
+ */
+ @ChangeId
+ @EnabledAfter(targetSdkVersion = VERSION_CODES.Q)
+ static final long RESTRICT_TELEPHONY_COMMON_CHANGE_ID = 139318877L;
+
+ private static boolean apkTargetsApiLevelLessThanROrCurrent(Package pkg) {
+ boolean shouldRestrict = false;
+ try {
+ IBinder b = ServiceManager.getService("platform_compat");
+ IPlatformCompat platformCompat = IPlatformCompat.Stub.asInterface(b);
+ shouldRestrict = platformCompat.isChangeEnabled(RESTRICT_TELEPHONY_COMMON_CHANGE_ID,
+ pkg.applicationInfo);
+ } catch (RemoteException ex) {
+ Log.e(TAG, ex.getMessage());
+ }
+ // TODO(b/139318877): remove version check for CUR_DEVELOPEMENT after clean up work.
+ return !shouldRestrict
+ || pkg.applicationInfo.targetSdkVersion == VERSION_CODES.CUR_DEVELOPMENT;
+ }
+
+ @Override
+ public void updatePackage(Package pkg) {
+ // for apps with targetSDKVersion < R include the library for backward compatibility.
+ if (apkTargetsApiLevelLessThanROrCurrent(pkg)) {
+ prefixRequiredLibrary(pkg, ANDROID_TELEPHONY_COMMON);
+ } else if (pkg.mSharedUserId == null || !pkg.mSharedUserId.equals("android.uid.phone")) {
+ // if apps target >= R
+ removeLibrary(pkg, ANDROID_TELEPHONY_COMMON);
+ }
+ }
+}
diff --git a/core/java/android/content/pm/PackageBackwardCompatibility.java b/core/java/android/content/pm/PackageBackwardCompatibility.java
index 4331bd4ac4d4..797ba64b5d1f 100644
--- a/core/java/android/content/pm/PackageBackwardCompatibility.java
+++ b/core/java/android/content/pm/PackageBackwardCompatibility.java
@@ -51,6 +51,8 @@ public class PackageBackwardCompatibility extends PackageSharedLibraryUpdater {
packageUpdaters.add(new AndroidHidlUpdater());
+ packageUpdaters.add(new AndroidTelephonyCommonUpdater());
+
// Add this before adding AndroidTestBaseUpdater so that android.test.base comes before
// android.test.mock.
packageUpdaters.add(new AndroidTestRunnerSplitUpdater());
diff --git a/core/java/android/content/pm/SharedLibraryNames.java b/core/java/android/content/pm/SharedLibraryNames.java
index a607a9ff682b..4c66fc007856 100644
--- a/core/java/android/content/pm/SharedLibraryNames.java
+++ b/core/java/android/content/pm/SharedLibraryNames.java
@@ -33,4 +33,6 @@ public class SharedLibraryNames {
static final String ANDROID_TEST_RUNNER = "android.test.runner";
public static final String ORG_APACHE_HTTP_LEGACY = "org.apache.http.legacy";
+
+ public static final String ANDROID_TELEPHONY_COMMON = "telephony-common";
}
diff --git a/core/tests/coretests/src/android/content/pm/AndroidTelephonyCommonUpdaterTest.java b/core/tests/coretests/src/android/content/pm/AndroidTelephonyCommonUpdaterTest.java
new file mode 100644
index 000000000000..8ab9ddbee6d8
--- /dev/null
+++ b/core/tests/coretests/src/android/content/pm/AndroidTelephonyCommonUpdaterTest.java
@@ -0,0 +1,140 @@
+/*
+ * 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.content.pm;
+
+import static android.content.pm.PackageBuilder.builder;
+import static android.content.pm.SharedLibraryNames.ANDROID_HIDL_BASE;
+import static android.content.pm.SharedLibraryNames.ANDROID_HIDL_MANAGER;
+import static android.content.pm.SharedLibraryNames.ANDROID_TELEPHONY_COMMON;
+
+import android.os.Build;
+import androidx.test.filters.SmallTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Test for {@link AndroidHidlUpdater}
+ */
+@SmallTest
+@RunWith(JUnit4.class)
+public class AndroidTelephonyCommonUpdaterTest extends PackageSharedLibraryUpdaterTest {
+
+ private static final String OTHER_LIBRARY = "other.library";
+ private static final String PHONE_UID = "android.uid.phone";
+
+ @Test
+ public void targeted_at_Q() {
+ PackageBuilder before = builder()
+ .targetSdkVersion(Build.VERSION_CODES.Q);
+
+ PackageBuilder after = builder().targetSdkVersion(Build.VERSION_CODES.Q)
+ .requiredLibraries(ANDROID_TELEPHONY_COMMON);
+
+ // Should add telephony-common libraries
+ checkBackwardsCompatibility(before, after);
+ }
+
+ @Test
+ public void targeted_at_Q_phoneUID() {
+ PackageBuilder before = builder().setSharedUid(PHONE_UID)
+ .targetSdkVersion(Build.VERSION_CODES.Q);
+
+ // Should add telephony-common libraries
+ PackageBuilder after = builder().setSharedUid(PHONE_UID)
+ .targetSdkVersion(Build.VERSION_CODES.Q)
+ .requiredLibraries(ANDROID_TELEPHONY_COMMON);
+
+ checkBackwardsCompatibility(before, after);
+ }
+
+ @Test
+ public void targeted_at_Q_not_empty_usesLibraries() {
+ PackageBuilder before = builder()
+ .targetSdkVersion(Build.VERSION_CODES.Q)
+ .requiredLibraries(OTHER_LIBRARY);
+
+ // no change
+ checkBackwardsCompatibility(before, before);
+ }
+
+ @Test
+ public void targeted_at_Q_not_empty_usesLibraries_phoneUID() {
+ PackageBuilder before = builder().setSharedUid(PHONE_UID)
+ .targetSdkVersion(Build.VERSION_CODES.Q)
+ .requiredLibraries(OTHER_LIBRARY);
+
+ // The telephony-common jars should be added at the start of the list because it
+ // is not on the bootclasspath and the package targets pre-R.
+ PackageBuilder after = builder().setSharedUid(PHONE_UID)
+ .targetSdkVersion(Build.VERSION_CODES.Q)
+ .requiredLibraries(ANDROID_TELEPHONY_COMMON, OTHER_LIBRARY);
+
+ checkBackwardsCompatibility(before, after);
+ }
+
+ @Test
+ public void targeted_at_R_in_usesLibraries() {
+ PackageBuilder before = builder()
+ .targetSdkVersion(Build.VERSION_CODES.Q + 1)
+ .requiredLibraries(ANDROID_TELEPHONY_COMMON);
+
+ PackageBuilder after = builder()
+ .targetSdkVersion(Build.VERSION_CODES.Q + 1);
+
+ // Libraries are removed because they are not available for apps target >= R and not run
+ // on phone-uid
+ checkBackwardsCompatibility(before, after);
+ }
+
+ @Test
+ public void targeted_at_Q_in_usesLibraries() {
+ PackageBuilder before = builder().asSystemApp()
+ .targetSdkVersion(Build.VERSION_CODES.Q)
+ .requiredLibraries(ANDROID_TELEPHONY_COMMON);
+
+ // No change is required because the package explicitly requests the telephony libraries
+ // and is targeted at the current version so does not need backwards compatibility.
+ checkBackwardsCompatibility(before, before);
+ }
+
+
+ @Test
+ public void targeted_at_R_in_usesOptionalLibraries() {
+ PackageBuilder before = builder().targetSdkVersion(Build.VERSION_CODES.Q + 1)
+ .optionalLibraries(ANDROID_TELEPHONY_COMMON);
+
+ // Dependency is removed, it is not available.
+ PackageBuilder after = builder().targetSdkVersion(Build.VERSION_CODES.Q + 1);
+
+ // Libraries are removed because they are not available for apps targeting Q+
+ checkBackwardsCompatibility(before, after);
+ }
+
+ @Test
+ public void targeted_at_R() {
+ PackageBuilder before = builder()
+ .targetSdkVersion(Build.VERSION_CODES.Q + 1);
+
+ // no change
+ checkBackwardsCompatibility(before, before);
+ }
+
+ private void checkBackwardsCompatibility(PackageBuilder before, PackageBuilder after) {
+ checkBackwardsCompatibility(before, after, AndroidTelephonyCommonUpdater::new);
+ }
+}
diff --git a/core/tests/coretests/src/android/content/pm/PackageBuilder.java b/core/tests/coretests/src/android/content/pm/PackageBuilder.java
index f7544af43461..f3a56e2814e4 100644
--- a/core/tests/coretests/src/android/content/pm/PackageBuilder.java
+++ b/core/tests/coretests/src/android/content/pm/PackageBuilder.java
@@ -37,6 +37,8 @@ class PackageBuilder {
private ArrayList<String> mOptionalLibraries;
+ private String mSharedUid;
+
public static PackageBuilder builder() {
return new PackageBuilder();
}
@@ -47,6 +49,7 @@ class PackageBuilder {
pkg.applicationInfo.flags = mFlags;
pkg.usesLibraries = mRequiredLibraries;
pkg.usesOptionalLibraries = mOptionalLibraries;
+ pkg.mSharedUserId = mSharedUid;
return pkg;
}
@@ -55,6 +58,11 @@ class PackageBuilder {
return this;
}
+ PackageBuilder setSharedUid(String uid) {
+ this.mSharedUid = uid;
+ return this;
+ }
+
PackageBuilder asSystemApp() {
this.mFlags |= ApplicationInfo.FLAG_SYSTEM;
return this;
diff --git a/data/etc/platform.xml b/data/etc/platform.xml
index 233f82640a20..5a4af96278c3 100644
--- a/data/etc/platform.xml
+++ b/data/etc/platform.xml
@@ -224,6 +224,8 @@
<library name="android.hidl.manager-V1.0-java"
file="/system/framework/android.hidl.manager-V1.0-java.jar"
dependency="android.hidl.base-V1.0-java" />
+ <library name="telephony-common"
+ file="/system/framework/telephony-common.jar" />
<!-- These are the standard packages that are white-listed to always have internet
access while in power save mode, even if they aren't in the foreground. -->
diff --git a/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java b/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java
index da32c8c45a73..28b331b17b91 100644
--- a/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java
+++ b/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java
@@ -1496,7 +1496,7 @@ public class SmsMessage extends SmsMessageBase {
*
* @return true if this is a USIM data download message; false otherwise
*/
- boolean isUsimDataDownload() {
+ public boolean isUsimDataDownload() {
return messageClass == MessageClass.CLASS_2 &&
(mProtocolIdentifier == 0x7f || mProtocolIdentifier == 0x7c);
}