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

Commit b7f954e3 authored by Eugene Susla's avatar Eugene Susla Committed by Android (Google) Code Review
Browse files

Merge "Mirgate default SMS app handling to RoleManager"

parents 5a678395 062c7e1a
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -56,6 +56,8 @@ public class Role {

    private static final String LOG_TAG = Role.class.getSimpleName();

    private static final boolean DEBUG = false;

    private static final String PACKAGE_NAME_ANDROID_SYSTEM = "android";

    /**
@@ -362,7 +364,12 @@ public class Role {
        }
    }

    private static void killApp(@NonNull String packageName, @NonNull Context context) {
    private void killApp(@NonNull String packageName, @NonNull Context context) {
        if (DEBUG) {
            Log.i(LOG_TAG, "Killing " + packageName + " due to "
                    + Thread.currentThread().getStackTrace()[3].getMethodName()
                    + "(" + mName + ")");
        }
        ApplicationInfo applicationInfo = PackageUtils.getApplicationInfo(packageName, context);
        if (applicationInfo == null) {
            Log.w(LOG_TAG, "Cannot get ApplicationInfo for package: " + packageName);
+10 −1
Original line number Diff line number Diff line
@@ -182,12 +182,19 @@ public class RoleControllerServiceImpl extends RoleControllerService {
            return;
        }

        boolean added = false;
        if (role.isExclusive()) {
            List<String> currentPackageNames = mRoleManager.getRoleHolders(roleName);
            int currentPackageNamesSize = currentPackageNames.size();
            for (int i = 0; i < currentPackageNamesSize; i++) {
                String currentPackageName = currentPackageNames.get(i);

                if (currentPackageName.equals(packageName)) {
                    Log.i(LOG_TAG, packageName + " already holds " + roleName);
                    added = true;
                    continue;
                }

                boolean removed = removeRoleHolderInternal(role, currentPackageName);
                if (!removed) {
                    Log.e(LOG_TAG, "Failed to remove current holder from role holders in"
@@ -202,7 +209,9 @@ public class RoleControllerServiceImpl extends RoleControllerService {
        // TODO: STOPSHIP: Pass in appropriate arguments.
        role.grant(packageName, true, true, false, this);

        boolean added = mRoleManager.addRoleHolderFromController(roleName, packageName);
        if (!added) {
            added = mRoleManager.addRoleHolderFromController(roleName, packageName);
        }
        if (!added) {
            Log.e(LOG_TAG, "Failed to add package to role holders in RoleManager, package: "
                    + packageName + ", role: " + roleName);