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

Commit 8407342f authored by Hideki Ishii's avatar Hideki Ishii Committed by takeshi tanigawa
Browse files

Bind WapPushManagerService regardless of DirectBoot status

Bind WapPushManagerService regardless of DirectBoot status to receive
WAP PUSH messages during DirectBoot.

There are cases in which a device receives a WAP PUSH message requesting
location information from network when user makes an emergency call.
To avoid missing the message during DirectBoot, must bind
WapPushManagerService.

Test: manual - Confirm that WapPushOverSms#onServiceConnected() is
called during DirectBoot.
Confirm that WapPushManager#WapPushManager() is called when unlocking
the screen.
Bug: 141654363

Change-Id: I2c2ab3c28a395ea5b16c37542b37de3d9be450ea
parent 64e72304
Loading
Loading
Loading
Loading
+1 −34
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import android.content.ComponentName;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
@@ -87,32 +86,6 @@ public class WapPushOverSms implements ServiceConnection {
    @UnsupportedAppUsage
    private volatile IWapPushManager mWapPushManager;

    /** Broadcast receiver that binds to WapPushManager when the user unlocks the phone for the
     *  first time after reboot and the credential-encrypted storage is available.
     */
    private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(final Context context, Intent intent) {
            Rlog.d(TAG, "Received broadcast " + intent.getAction());
            if (Intent.ACTION_USER_UNLOCKED.equals(intent.getAction())) {
                new BindServiceThread(mContext).start();
            }
        }
    };

    private class BindServiceThread extends Thread {
        private final Context context;

        private BindServiceThread(Context context) {
            this.context = context;
        }

        @Override
        public void run() {
            bindWapPushManagerService(context);
        }
    }

    private void bindWapPushManagerService(Context context) {
        Intent intent = new Intent(IWapPushManager.class.getName());
        ComponentName comp = resolveSystemService(context.getPackageManager(), intent);
@@ -173,13 +146,7 @@ public class WapPushOverSms implements ServiceConnection {

        UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);

        if (userManager.isUserUnlocked()) {
        bindWapPushManagerService(mContext);
        } else {
            IntentFilter userFilter = new IntentFilter();
            userFilter.addAction(Intent.ACTION_USER_UNLOCKED);
            context.registerReceiver(mBroadcastReceiver, userFilter);
        }
    }

    public void dispose() {