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

Commit 6a965af2 authored by San Mehat's avatar San Mehat
Browse files

MountService: Send UMS_CONNECTED broadcast on boot if UMS connected.



UMS detection is now done wayyyy before the system is booted, so set a flag
to send our intent broadcast once we've booted.

Signed-off-by: default avatarSan Mehat <san@google.com>
parent 9b1e9edf
Loading
Loading
Loading
Loading
+19 −9
Original line number Diff line number Diff line
@@ -115,8 +115,9 @@ class MountService extends IMountService.Stub
    private PackageManagerService                 mPms;
    private boolean                               mUmsEnabling;
    private ArrayList<MountServiceBinderListener> mListeners;
    private boolean                               mBooted;
    private boolean                               mReady;
    private boolean                               mBooted = false;
    private boolean                               mReady = false;
    private boolean                               mSendUmsConnectedOnBoot = false;

    /**
     * Private hash of currently mounted secure containers.
@@ -162,6 +163,14 @@ class MountService extends IMountService.Stub
                                    Log.e(TAG, String.format("Boot-time mount failed (%d)", rc));
                                }
                            }
                            /*
                             * If UMS is connected in boot, send the connected event
                             * now that we're up.
                             */
                            if (mSendUmsConnectedOnBoot) {
                                sendUmsIntent(true);
                                mSendUmsConnectedOnBoot = false;
                            }
                        } catch (Exception ex) {
                            Log.e(TAG, "Boot-time mount exception", ex);
                        }
@@ -636,14 +645,15 @@ class MountService extends IMountService.Stub
        }

        if (mBooted == true) {
            Intent intent;
            if (avail) {
                intent = new Intent(Intent.ACTION_UMS_CONNECTED);
            sendUmsIntent(avail);
        } else {
                intent = new Intent(Intent.ACTION_UMS_DISCONNECTED);
            mSendUmsConnectedOnBoot = avail;
        }
            mContext.sendBroadcast(intent);
    }

    private void sendUmsIntent(boolean c) {
        mContext.sendBroadcast(
                new Intent((c ? Intent.ACTION_UMS_CONNECTED : Intent.ACTION_UMS_DISCONNECTED)));
    }

    private void validatePermission(String perm) {