Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae274c92 authored by Amit Mahajan's avatar Amit Mahajan Committed by Automerger Merge Worker
Browse files

Merge "Revert "Fix permission check for get/setSmscAddress."" am: c070b1de

Change-Id: I0dd710ec44b71ee2744da01b97356de1d67ba7ab
parents b39ca49a c070b1de
Loading
Loading
Loading
Loading
+1 −16
Original line number Original line Diff line number Diff line
@@ -1051,8 +1051,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
@@ -1061,22 +1060,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)) {
+3 −4
Original line number Original line Diff line number Diff line
@@ -2751,7 +2751,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;
    }
    }
@@ -2773,8 +2773,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)
@@ -2786,7 +2785,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;
    }
    }