Merge "Revert "Fix permission check for get/setSmscAddress."" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-03-03 20:44:27 +00:00
committed by Android (Google) Code Review
2 changed files with 4 additions and 20 deletions

View File

@@ -1057,8 +1057,7 @@ public final class SmsApplication {
} }
/** /**
* Check if a package is default sms app (or equivalent, like bluetooth), and verify that * Check if a package is default sms app (or equivalent, like bluetooth)
* packageName belongs to the caller.
* *
* @param context context from the calling app * @param context context from the calling app
* @param packageName the name of the package to be checked * @param packageName the name of the package to be checked
@@ -1067,22 +1066,8 @@ public final class SmsApplication {
@UnsupportedAppUsage @UnsupportedAppUsage
public static boolean isDefaultSmsApplication(Context context, String packageName) { public static boolean isDefaultSmsApplication(Context context, String packageName) {
if (packageName == null) { if (packageName == null) {
Log.e(LOG_TAG, "isDefaultSmsApplication: packageName is null");
return false; return false;
} }
try {
if (Binder.getCallingUid()
== context.getPackageManager().getPackageUid(packageName, 0)) {
Log.e(LOG_TAG, "isDefaultSmsApplication: " + packageName + " calling uid "
+ context.getPackageManager().getPackageUid(packageName, 0)
+ " does not match calling uid " + Binder.getCallingUid());
return false;
}
} catch (NameNotFoundException ex) {
Log.e(LOG_TAG, "isDefaultSmsApplication: packageName " + packageName + " not found");
return false;
}
final String defaultSmsPackage = getDefaultSmsApplicationPackageName(context); final String defaultSmsPackage = getDefaultSmsApplicationPackageName(context);
if ((defaultSmsPackage != null && defaultSmsPackage.equals(packageName)) if ((defaultSmsPackage != null && defaultSmsPackage.equals(packageName))
|| BLUETOOTH_PACKAGE_NAME.equals(packageName)) { || BLUETOOTH_PACKAGE_NAME.equals(packageName)) {

View File

@@ -2898,7 +2898,7 @@ public final class SmsManager {
getSubscriptionId(), null); getSubscriptionId(), null);
} }
} catch (RemoteException ex) { } catch (RemoteException ex) {
throw new RuntimeException(ex); // ignore it
} }
return smsc; return smsc;
} }
@@ -2920,8 +2920,7 @@ public final class SmsManager {
* </p> * </p>
* *
* @param smsc the SMSC address string. * @param smsc the SMSC address string.
* @return true for success, false otherwise. Failure can be due to caller not having the * @return true for success, false otherwise.
* appropriate permission, or modem returning an error.
*/ */
@SuppressAutoDoc // for carrier privileges and default SMS application. @SuppressAutoDoc // for carrier privileges and default SMS application.
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
@@ -2933,7 +2932,7 @@ public final class SmsManager {
smsc, getSubscriptionId(), null); smsc, getSubscriptionId(), null);
} }
} catch (RemoteException ex) { } catch (RemoteException ex) {
throw new RuntimeException(ex); // ignore it
} }
return false; return false;
} }