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

Commit 0b59883b authored by Philip P. Moltmann's avatar Philip P. Moltmann Committed by android-build-merger
Browse files

Merge "Init MidiService once system user gets unlocked." into nyc-dev am: da08abed

am: 80db52bf

* commit '80db52bf':
  Init MidiService once system user gets unlocked.

Change-Id: If28f78f905f07a08f6feeb12405a2bd6c8567eed
parents 524bf55d 80db52bf
Loading
Loading
Loading
Loading
+16 −3
Original line number Original line Diff line number Diff line
@@ -41,6 +41,7 @@ import android.os.Bundle;
import android.os.IBinder;
import android.os.IBinder;
import android.os.Process;
import android.os.Process;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.Log;
import android.util.Log;


import com.android.internal.content.PackageMonitor;
import com.android.internal.content.PackageMonitor;
@@ -71,6 +72,13 @@ public class MidiService extends IMidiManager.Stub {
            mMidiService = new MidiService(getContext());
            mMidiService = new MidiService(getContext());
            publishBinderService(Context.MIDI_SERVICE, mMidiService);
            publishBinderService(Context.MIDI_SERVICE, mMidiService);
        }
        }

        @Override
        public void onUnlockUser(int userHandle) {
            if (userHandle == UserHandle.USER_SYSTEM) {
                mMidiService.onUnlockUser();
            }
        }
    }
    }


    private static final String TAG = "MidiService";
    private static final String TAG = "MidiService";
@@ -97,7 +105,7 @@ public class MidiService extends IMidiManager.Stub {
    private final PackageManager mPackageManager;
    private final PackageManager mPackageManager;


    // UID of BluetoothMidiService
    // UID of BluetoothMidiService
    private final int mBluetoothServiceUid;
    private int mBluetoothServiceUid;


    // PackageMonitor for listening to package changes
    // PackageMonitor for listening to package changes
    private final PackageMonitor mPackageMonitor = new PackageMonitor() {
    private final PackageMonitor mPackageMonitor = new PackageMonitor() {
@@ -557,7 +565,12 @@ public class MidiService extends IMidiManager.Stub {
    public MidiService(Context context) {
    public MidiService(Context context) {
        mContext = context;
        mContext = context;
        mPackageManager = context.getPackageManager();
        mPackageManager = context.getPackageManager();
        mPackageMonitor.register(context, null, true);

        mBluetoothServiceUid = -1;
    }

    private void onUnlockUser() {
        mPackageMonitor.register(mContext, null, true);


        Intent intent = new Intent(MidiDeviceService.SERVICE_INTERFACE);
        Intent intent = new Intent(MidiDeviceService.SERVICE_INTERFACE);
        List<ResolveInfo> resolveInfos = mPackageManager.queryIntentServices(intent,
        List<ResolveInfo> resolveInfos = mPackageManager.queryIntentServices(intent,