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

Commit 0c00e523 authored by Keun young Park's avatar Keun young Park Committed by Keun-young Park
Browse files

Remove only selected messages for vold reset

- Resetting all pending messages can lead into secondary user
  losing unlocking event in automotive devices.
- Only remove selected messages like RESET, VOLUME_MOUNT/UNMOUNT/BROADCAST.

Bug: 151457974
Test: try reboot in auto devices where this race can happen.
      run cts: atest android.appsecurity.cts.AdoptableHostTest

Change-Id: Iee52b4ee76f07e0c7aaaa6f0dfa480aeef1df2e9
parent d8208009
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1083,7 +1083,12 @@ class StorageManagerService extends IStorageManager.Stub
            final List<UserInfo> users = mContext.getSystemService(UserManager.class).getUsers();

            if (mIsFuseEnabled) {
                mStorageSessionController.onReset(mVold, mHandler);
                mStorageSessionController.onReset(mVold, () -> {
                    mHandler.removeMessages(H_RESET);
                    mHandler.removeMessages(H_VOLUME_BROADCAST);
                    mHandler.removeMessages(H_VOLUME_MOUNT);
                    mHandler.removeMessages(H_VOLUME_UNMOUNT);
                });
            } else {
                killMediaProvider(users);
            }
+2 −3
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.os.Handler;
import android.os.IVold;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
@@ -238,7 +237,7 @@ public final class StorageSessionController {
     *
     * Does nothing if {@link #shouldHandle} is {@code false}
     **/
    public void onReset(IVold vold, Handler handler) {
    public void onReset(IVold vold, Runnable resetHandlerRunnable) {
        if (!shouldHandle(null)) {
            return;
        }
@@ -280,7 +279,7 @@ public final class StorageSessionController {
            connection.close();
        }

        handler.removeCallbacksAndMessages(null);
        resetHandlerRunnable.run();
        synchronized (mLock) {
            mConnections.clear();
            mIsResetting = false;