Merge "Check for installed bluetooth package name" into tm-dev am: 945df7d77d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17774836

Change-Id: I9432dd71bb26f44b90ab3b985d483d857c55c611
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Zach Johnson
2022-05-11 21:13:40 +00:00
committed by Automerger Merge Worker
2 changed files with 9 additions and 4 deletions

View File

@@ -68,7 +68,6 @@ import java.util.stream.Collectors;
public final class SmsApplication { public final class SmsApplication {
static final String LOG_TAG = "SmsApplication"; static final String LOG_TAG = "SmsApplication";
public static final String PHONE_PACKAGE_NAME = "com.android.phone"; public static final String PHONE_PACKAGE_NAME = "com.android.phone";
public static final String BLUETOOTH_PACKAGE_NAME = "com.android.bluetooth.services";
public static final String MMS_SERVICE_PACKAGE_NAME = "com.android.mms.service"; public static final String MMS_SERVICE_PACKAGE_NAME = "com.android.mms.service";
public static final String TELEPHONY_PROVIDER_PACKAGE_NAME = "com.android.providers.telephony"; public static final String TELEPHONY_PROVIDER_PACKAGE_NAME = "com.android.providers.telephony";
@@ -541,11 +540,13 @@ public final class SmsApplication {
PackageManager packageManager = context.getPackageManager(); PackageManager packageManager = context.getPackageManager();
AppOpsManager appOps = context.getSystemService(AppOpsManager.class); AppOpsManager appOps = context.getSystemService(AppOpsManager.class);
final String bluetoothPackageName = context.getResources()
.getString(com.android.internal.R.string.config_systemBluetoothStack);
// Assign permission to special system apps // Assign permission to special system apps
assignExclusiveSmsPermissionsToSystemApp(context, packageManager, appOps, assignExclusiveSmsPermissionsToSystemApp(context, packageManager, appOps,
PHONE_PACKAGE_NAME, true); PHONE_PACKAGE_NAME, true);
assignExclusiveSmsPermissionsToSystemApp(context, packageManager, appOps, assignExclusiveSmsPermissionsToSystemApp(context, packageManager, appOps,
BLUETOOTH_PACKAGE_NAME, true); bluetoothPackageName, false);
assignExclusiveSmsPermissionsToSystemApp(context, packageManager, appOps, assignExclusiveSmsPermissionsToSystemApp(context, packageManager, appOps,
MMS_SERVICE_PACKAGE_NAME, true); MMS_SERVICE_PACKAGE_NAME, true);
assignExclusiveSmsPermissionsToSystemApp(context, packageManager, appOps, assignExclusiveSmsPermissionsToSystemApp(context, packageManager, appOps,
@@ -1128,8 +1129,11 @@ public final class SmsApplication {
return false; return false;
} }
final String defaultSmsPackage = getDefaultSmsApplicationPackageName(context); final String defaultSmsPackage = getDefaultSmsApplicationPackageName(context);
final String bluetoothPackageName = context.getResources()
.getString(com.android.internal.R.string.config_systemBluetoothStack);
if ((defaultSmsPackage != null && defaultSmsPackage.equals(packageName)) if ((defaultSmsPackage != null && defaultSmsPackage.equals(packageName))
|| BLUETOOTH_PACKAGE_NAME.equals(packageName)) { || bluetoothPackageName.equals(packageName)) {
return true; return true;
} }
return false; return false;

View File

@@ -22,6 +22,7 @@ import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNotNull; import static org.mockito.ArgumentMatchers.isNotNull;
import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.matches;
import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doAnswer;
@@ -214,7 +215,7 @@ public class SmsApplicationTest {
ApplicationInfo bluetoothApplicationInfo = new ApplicationInfo(); ApplicationInfo bluetoothApplicationInfo = new ApplicationInfo();
bluetoothApplicationInfo.uid = FAKE_BT_UID; bluetoothApplicationInfo.uid = FAKE_BT_UID;
bluetoothPackageInfo.applicationInfo = bluetoothApplicationInfo; bluetoothPackageInfo.applicationInfo = bluetoothApplicationInfo;
when(mPackageManager.getPackageInfo(eq(SmsApplication.BLUETOOTH_PACKAGE_NAME), anyInt())) when(mPackageManager.getPackageInfo(matches(".*android.bluetooth.services"), anyInt()))
.thenReturn(bluetoothPackageInfo); .thenReturn(bluetoothPackageInfo);
PackageInfo telephonyProviderPackageInfo = new PackageInfo(); PackageInfo telephonyProviderPackageInfo = new PackageInfo();