diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-03-29 23:31:29 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-03-29 23:31:29 +0000 |
commit | de41f76130a1f376134f84765dd64edbdcd904fa (patch) | |
tree | e620ec32680195e0e84c4ce0fa7e3f90571b7fb4 | |
parent | 5b14bbe94fb131b41739ce7e3966e580406f7c2f (diff) | |
parent | e9951861da7138058b76e822e54b2496c35efc1d (diff) | |
download | Telephony-android10-qpr2-s4-release.tar.gz |
Merge cherrypicks of [10880181, 10883346, 10883347, 10883348, 10883349, 10883812, 10883813, 10883716, 10883814, 10883815, 10883672, 10876113, 10883717, 10883359, 10883882] into sparse-6310743-L56900000511645444android-10.0.0_r36android-10.0.0_r35android10-qpr2-s4-releaseandroid10-qpr2-s3-release
Change-Id: I6e26c02d1982c1c8dfc52ec3602b444c22c06f1a
-rwxr-xr-x | src/com/android/phone/PhoneInterfaceManager.java | 13 | ||||
-rw-r--r-- | tests/src/com/android/phone/PhoneInterfaceManagerTest.java | 83 |
2 files changed, 1 insertions, 95 deletions
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java index f8541bc99..435cd9601 100755 --- a/src/com/android/phone/PhoneInterfaceManager.java +++ b/src/com/android/phone/PhoneInterfaceManager.java @@ -115,7 +115,6 @@ import android.util.Slog; import com.android.ims.ImsException; import com.android.ims.ImsManager; import com.android.ims.internal.IImsServiceFeatureCallback; -import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.CallManager; import com.android.internal.telephony.CallStateException; import com.android.internal.telephony.CarrierInfoManager; @@ -1338,8 +1337,7 @@ public class PhoneInterfaceManager extends ITelephony.Stub { } /** Private constructor; @see init() */ - @VisibleForTesting - /* package */ PhoneInterfaceManager(PhoneGlobals app) { + private PhoneInterfaceManager(PhoneGlobals app) { mApp = app; mCM = PhoneGlobals.getInstance().mCM; mUserManager = (UserManager) app.getSystemService(Context.USER_SERVICE); @@ -6488,15 +6486,6 @@ public class PhoneInterfaceManager extends ITelephony.Stub { @Override public List<UiccCardInfo> getUiccCardsInfo(String callingPackage) { - try { - PackageManager pm = mApp.getPackageManager(); - if (Binder.getCallingUid() != pm.getPackageUid(callingPackage, 0)) { - throw new SecurityException("Calling package " + callingPackage + " does not match " - + "calling UID"); - } - } catch (PackageManager.NameNotFoundException e) { - throw new SecurityException("Invalid calling package. e=" + e); - } boolean hasReadPermission = false; try { enforceReadPrivilegedPermission("getUiccCardsInfo"); diff --git a/tests/src/com/android/phone/PhoneInterfaceManagerTest.java b/tests/src/com/android/phone/PhoneInterfaceManagerTest.java deleted file mode 100644 index 9f8de9e6d..000000000 --- a/tests/src/com/android/phone/PhoneInterfaceManagerTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2020 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.phone; - -import static junit.framework.TestCase.fail; - -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; - -import android.content.pm.PackageManager; -import android.os.Binder; -import android.util.Log; - -import androidx.test.runner.AndroidJUnit4; - -import com.android.TelephonyTestBase; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - - -@RunWith(AndroidJUnit4.class) -public class PhoneInterfaceManagerTest extends TelephonyTestBase { - - private static final String PRIVILEGED_PACKAGE_NAME = "test.package.name"; - - private static final String TAG = "PhoneInterfaceManagerTest"; - - private PhoneInterfaceManager mPhoneInterfaceManager; - private PhoneGlobals mMockPhoneGlobals; - - @Before - public void setUp() throws Exception { - super.setUp(); - mMockPhoneGlobals = mock(PhoneGlobals.class); - //PhoneGlobals phoneGlobals = new PhoneGlobals(mContext); - mPhoneInterfaceManager = new PhoneInterfaceManager(mMockPhoneGlobals); - } - - @After - public void tearDown() throws Exception { - super.tearDown(); - } - - @Test - public void testGetUiccCardsInfoSecurity() { - // Set up mocks so that the supplied package UID does not equal the calling UID - PackageManager mockPackageManager = mock(PackageManager.class); - try { - doReturn(Binder.getCallingUid() + 1).when(mockPackageManager) - .getPackageUid(eq(PRIVILEGED_PACKAGE_NAME), anyInt()); - } catch (Exception e) { - Log.d(TAG, "testGetUiccCardsInfoSecurity unable to setup mocks"); - fail(); - } - doReturn(mockPackageManager).when(mContext).getPackageManager(); - doReturn(mockPackageManager).when(mMockPhoneGlobals).getPackageManager(); - try { - mPhoneInterfaceManager.getUiccCardsInfo(PRIVILEGED_PACKAGE_NAME); - fail(); - } catch (SecurityException e) { - Log.d(TAG, "testGetUiccCardsInfoSecurity e = " + e); - } - } -} |