ProfileManagerService: Fix initialization order

According to the lifecycle of a SystemService, onStart() is called to get
the service running and the service should publish its binder interface
at that point. First of all, ensure to do that and then initialize the
rest of the stuff only during PHASE_ACTIVITY_MANAGER_READY boot phase,
because services can only broadcast intents after that phase.

This fixes a particular issue, that was causing LineageParts to crash
while starting System Profiles activity.

Change-Id: I8a397523aec8b5008da3e596eee23463618c8489
diff --git a/lineage/lib/main/java/org/lineageos/platform/internal/ProfileManagerService.java b/lineage/lib/main/java/org/lineageos/platform/internal/ProfileManagerService.java
index 7411412..4e448d4 100644
--- a/lineage/lib/main/java/org/lineageos/platform/internal/ProfileManagerService.java
+++ b/lineage/lib/main/java/org/lineageos/platform/internal/ProfileManagerService.java
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2011-2015 CyanogenMod Project
+ * Copyright (C) 2011-2015 CyanogenMod Project
+ *               2017-2020 LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -231,13 +232,6 @@
         super(context);
         mContext = context;
         mHandler = new Handler(mHandlerCallback);
-        if (context.getPackageManager().hasSystemFeature(
-                LineageContextConstants.Features.PROFILES)) {
-            publishBinderService(LineageContextConstants.LINEAGE_PROFILE_SERVICE, mService);
-        } else {
-            Log.wtf(TAG, "Lineage profile service started by system server but feature xml not" +
-                    " declared. Not publishing binder service!");
-        }
     }
 
     @Override
@@ -259,12 +253,18 @@
                 org.lineageos.platform.internal.R.string.wildcardProfile,
                 mWildcardUUID);
 
-        initialize();
-
         IntentFilter filter = new IntentFilter();
         filter.addAction(Intent.ACTION_LOCALE_CHANGED);
         filter.addAction(Intent.ACTION_SHUTDOWN);
         mContext.registerReceiver(mIntentReceiver, filter);
+
+        if (mContext.getPackageManager().hasSystemFeature(
+                LineageContextConstants.Features.PROFILES)) {
+            publishBinderService(LineageContextConstants.LINEAGE_PROFILE_SERVICE, mService);
+        } else {
+            Log.wtf(TAG, "Lineage profile service started by system server but feature xml not" +
+                    " declared. Not publishing binder service!");
+        }
     }
 
     private void bindKeyguard() {
@@ -281,6 +281,7 @@
     @Override
     public void onBootPhase(int phase) {
         if (phase == PHASE_ACTIVITY_MANAGER_READY) {
+            initialize();
             bindKeyguard();
         } else if (phase == PHASE_BOOT_COMPLETED) {
             mContext.getContentResolver().registerContentObserver(