Use the SystemService lifecycle mechanism for AudioService
This will be needed to refactor user restriction handling. Change-Id: I4b77a020d631714e7f94bce5559190e3b78ec72c
This commit is contained in:
@@ -109,6 +109,7 @@ import android.view.accessibility.AccessibilityManager;
|
||||
import com.android.internal.util.XmlUtils;
|
||||
import com.android.server.EventLogTags;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.SystemService;
|
||||
import com.android.server.pm.UserManagerService;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
@@ -564,6 +565,27 @@ public class AudioService extends IAudioService.Stub {
|
||||
return "card=" + card + ";device=" + device + ";";
|
||||
}
|
||||
|
||||
public static final class Lifecycle extends SystemService {
|
||||
private AudioService mService;
|
||||
|
||||
public Lifecycle(Context context) {
|
||||
super(context);
|
||||
mService = new AudioService(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
publishBinderService(Context.AUDIO_SERVICE, mService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBootPhase(int phase) {
|
||||
if (phase == SystemService.PHASE_ACTIVITY_MANAGER_READY) {
|
||||
mService.systemReady();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Construction
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -438,7 +438,6 @@ public final class SystemServer {
|
||||
InputManagerService inputManager = null;
|
||||
TelephonyRegistry telephonyRegistry = null;
|
||||
ConsumerIrService consumerIr = null;
|
||||
AudioService audioService = null;
|
||||
MmsServiceBroker mmsService = null;
|
||||
EntropyMixer entropyMixer = null;
|
||||
|
||||
@@ -857,12 +856,7 @@ public final class SystemServer {
|
||||
}
|
||||
|
||||
traceBeginAndSlog("StartAudioService");
|
||||
try {
|
||||
audioService = new AudioService(context);
|
||||
ServiceManager.addService(Context.AUDIO_SERVICE, audioService);
|
||||
} catch (Throwable e) {
|
||||
reportWtf("starting Audio Service", e);
|
||||
}
|
||||
mSystemServiceManager.startService(AudioService.Lifecycle.class);
|
||||
Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
|
||||
|
||||
if (!disableNonCoreServices) {
|
||||
@@ -1163,7 +1157,6 @@ public final class SystemServer {
|
||||
final InputManagerService inputManagerF = inputManager;
|
||||
final TelephonyRegistry telephonyRegistryF = telephonyRegistry;
|
||||
final MediaRouterService mediaRouterF = mediaRouter;
|
||||
final AudioService audioServiceF = audioService;
|
||||
final MmsServiceBroker mmsServiceF = mmsService;
|
||||
|
||||
// We now tell the activity manager it is okay to run third party
|
||||
@@ -1234,13 +1227,7 @@ public final class SystemServer {
|
||||
reportWtf("making Connectivity Service ready", e);
|
||||
}
|
||||
Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
|
||||
Trace.traceBegin(Trace.TRACE_TAG_SYSTEM_SERVER, "MakeAudioServiceReady");
|
||||
try {
|
||||
if (audioServiceF != null) audioServiceF.systemReady();
|
||||
} catch (Throwable e) {
|
||||
reportWtf("Notifying AudioService running", e);
|
||||
}
|
||||
Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
|
||||
|
||||
Watchdog.getInstance().start();
|
||||
|
||||
// It is now okay to let the various system services start their
|
||||
|
||||
Reference in New Issue
Block a user