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

Commit 8024a3af authored by Harshit Mahajan's avatar Harshit Mahajan
Browse files

Refactoring recovery related code

In modules, we could only use Public and SystemAPI for interaction.
Refactoring to meet that criteria. This does not change any functionality.
1. Moving unsupported async Handler creation to public api
2. Getting System user handle using SystemApi

Bug: b/289203818
Test: m

Change-Id: Ib2bdfaade3a930dd549bee25b044e4f64d13f400
parent 2768c06f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@ public abstract class ExplicitHealthCheckService extends Service {
     */
    @NonNull public abstract List<String> onGetRequestedPackages();

    private final Handler mHandler = new Handler(Looper.getMainLooper(), null, true);
    private final Handler mHandler = Handler.createAsync(Looper.getMainLooper());
    @Nullable private RemoteCallback mCallback;

    @Override
+1 −1
Original line number Diff line number Diff line
@@ -343,7 +343,7 @@ class ExplicitHealthCheckController {
            };

            mContext.bindServiceAsUser(intent, mConnection,
                    Context.BIND_AUTO_CREATE, UserHandle.of(UserHandle.USER_SYSTEM));
                    Context.BIND_AUTO_CREATE, UserHandle.SYSTEM);
            Slog.i(TAG, "Explicit health check service is bound");
        }
    }
+5 −3
Original line number Diff line number Diff line
@@ -500,7 +500,8 @@ public class RescueParty {
        Exception res = null;
        final ContentResolver resolver = context.getContentResolver();
        try {
            Settings.Global.resetToDefaultsAsUser(resolver, null, mode, UserHandle.USER_SYSTEM);
            Settings.Global.resetToDefaultsAsUser(resolver, null, mode,
                UserHandle.SYSTEM.getIdentifier());
        } catch (Exception e) {
            res = new RuntimeException("Failed to reset global settings", e);
        }
@@ -741,12 +742,13 @@ public class RescueParty {
    }

    private static int[] getAllUserIds() {
        int[] userIds = { UserHandle.USER_SYSTEM };
        int systemUserId = UserHandle.SYSTEM.getIdentifier();
        int[] userIds = { systemUserId };
        try {
            for (File file : FileUtils.listFilesOrEmpty(Environment.getDataSystemDeDirectory())) {
                try {
                    final int userId = Integer.parseInt(file.getName());
                    if (userId != UserHandle.USER_SYSTEM) {
                    if (userId != systemUserId) {
                        userIds = ArrayUtils.appendInt(userIds, userId);
                    }
                } catch (NumberFormatException ignored) {