Check for installed bluetooth package name
Since Bluetooth is optional module, it can have 2 name depending on the target. Test: Build + pre-submit + try to send message from carkit Bug: 226403247 Fix: 228936027 Change-Id: I96a9bf4de972f16d5a391cc277aae237ff89e31c
This commit is contained in:
parent
c0573c9851
commit
8c9a96ad00
@ -68,7 +68,6 @@ import java.util.stream.Collectors;
|
||||
public final class SmsApplication {
|
||||
static final String LOG_TAG = "SmsApplication";
|
||||
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 TELEPHONY_PROVIDER_PACKAGE_NAME = "com.android.providers.telephony";
|
||||
|
||||
@ -541,11 +540,13 @@ public final class SmsApplication {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
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
|
||||
assignExclusiveSmsPermissionsToSystemApp(context, packageManager, appOps,
|
||||
PHONE_PACKAGE_NAME, true);
|
||||
assignExclusiveSmsPermissionsToSystemApp(context, packageManager, appOps,
|
||||
BLUETOOTH_PACKAGE_NAME, true);
|
||||
bluetoothPackageName, false);
|
||||
assignExclusiveSmsPermissionsToSystemApp(context, packageManager, appOps,
|
||||
MMS_SERVICE_PACKAGE_NAME, true);
|
||||
assignExclusiveSmsPermissionsToSystemApp(context, packageManager, appOps,
|
||||
@ -1128,8 +1129,11 @@ public final class SmsApplication {
|
||||
return false;
|
||||
}
|
||||
final String defaultSmsPackage = getDefaultSmsApplicationPackageName(context);
|
||||
final String bluetoothPackageName = context.getResources()
|
||||
.getString(com.android.internal.R.string.config_systemBluetoothStack);
|
||||
|
||||
if ((defaultSmsPackage != null && defaultSmsPackage.equals(packageName))
|
||||
|| BLUETOOTH_PACKAGE_NAME.equals(packageName)) {
|
||||
|| bluetoothPackageName.equals(packageName)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -22,6 +22,7 @@ import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNotNull;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.ArgumentMatchers.matches;
|
||||
import static org.mockito.ArgumentMatchers.nullable;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
@ -214,7 +215,7 @@ public class SmsApplicationTest {
|
||||
ApplicationInfo bluetoothApplicationInfo = new ApplicationInfo();
|
||||
bluetoothApplicationInfo.uid = FAKE_BT_UID;
|
||||
bluetoothPackageInfo.applicationInfo = bluetoothApplicationInfo;
|
||||
when(mPackageManager.getPackageInfo(eq(SmsApplication.BLUETOOTH_PACKAGE_NAME), anyInt()))
|
||||
when(mPackageManager.getPackageInfo(matches(".*android.bluetooth.services"), anyInt()))
|
||||
.thenReturn(bluetoothPackageInfo);
|
||||
|
||||
PackageInfo telephonyProviderPackageInfo = new PackageInfo();
|
||||
|
Loading…
x
Reference in New Issue
Block a user