Switch to the new Java-based RadioService.

As of now, the new service is meant to match all features from the old,
native service.

Bug: b/36863239
Test: instrumentalization
Change-Id: Ib579e433c62498afac91a67253b8b24cf0702b0a
This commit is contained in:
Tomasz Wasilczyk
2017-06-21 11:14:19 -07:00
parent 9110df7bf5
commit 9b595f3f85
4 changed files with 17 additions and 41 deletions

View File

@@ -17,7 +17,6 @@
package android.hardware.radio;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.content.Context;
@@ -27,7 +26,6 @@ import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceManager.ServiceNotFoundException;
import android.os.SystemProperties;
import android.text.TextUtils;
import android.util.Log;
@@ -1482,10 +1480,6 @@ public class RadioManager {
return STATUS_BAD_VALUE;
}
if (mService == null) {
return nativeListModules(modules);
}
Log.d(TAG, "Listing available tuners...");
List<ModuleProperties> returnedList;
try {
@@ -1526,45 +1520,32 @@ public class RadioManager {
throw new IllegalArgumentException("callback must not be empty");
}
if (mService != null) {
Log.d(TAG, "Opening tuner " + moduleId + "...");
Log.d(TAG, "Opening tuner " + moduleId + "...");
ITuner tuner;
ITunerCallback halCallback = new TunerCallbackAdapter(callback, handler);
try {
tuner = mService.openTuner(moduleId, config, withAudio, halCallback);
} catch (RemoteException e) {
Log.e(TAG, "Failed to open tuner", e);
return null;
}
if (tuner == null) {
Log.e(TAG, "Failed to open tuner");
return null;
}
return new TunerAdapter(tuner);
ITuner tuner;
ITunerCallback halCallback = new TunerCallbackAdapter(callback, handler);
try {
tuner = mService.openTuner(moduleId, config, withAudio, halCallback);
} catch (RemoteException e) {
Log.e(TAG, "Failed to open tuner", e);
return null;
}
RadioModule module = new RadioModule(moduleId, config, withAudio, callback, handler);
if (!module.initCheck()) {
if (tuner == null) {
Log.e(TAG, "Failed to open tuner");
module = null;
return null;
}
return (RadioTuner)module;
return new TunerAdapter(tuner);
}
@NonNull private final Context mContext;
// TODO(b/36863239): NonNull when transitioned from native service
@Nullable private final IRadioService mService;
@NonNull private final IRadioService mService;
/**
* @hide
*/
public RadioManager(@NonNull Context context) throws ServiceNotFoundException {
mContext = context;
boolean isServiceJava = SystemProperties.getBoolean("config.enable_java_radio", false);
mService = isServiceJava ? IRadioService.Stub.asInterface(
ServiceManager.getServiceOrThrow(Context.RADIO_SERVICE)) : null;
mService = IRadioService.Stub.asInterface(
ServiceManager.getServiceOrThrow(Context.RADIO_SERVICE));
}
}

View File

@@ -27,8 +27,7 @@ import android.util.Slog;
import java.util.List;
class Tuner extends ITuner.Stub {
// TODO(b/36863239): rename to RadioService.Tuner when native service goes away
private static final String TAG = "RadioServiceJava.Tuner";
private static final String TAG = "RadioService.Tuner";
/**
* This field is used by native code, do not access or modify.

View File

@@ -27,8 +27,7 @@ import android.os.RemoteException;
import android.util.Slog;
class TunerCallback implements ITunerCallback {
// TODO(b/36863239): rename to RadioService.TunerCallback when native service goes away
private static final String TAG = "RadioServiceJava.TunerCallback";
private static final String TAG = "RadioService.TunerCallback";
/**
* This field is used by native code, do not access or modify.

View File

@@ -703,8 +703,6 @@ public final class SystemServer {
boolean disableVrManager = SystemProperties.getBoolean("config.disable_vrmanager", false);
boolean disableCameraService = SystemProperties.getBoolean("config.disable_cameraservice",
false);
// TODO(b/36863239): Remove when transitioned from native service.
boolean enableRadioService = SystemProperties.getBoolean("config.enable_java_radio", false);
boolean enableLeftyService = SystemProperties.getBoolean("config.enable_lefty", false);
boolean isEmulator = SystemProperties.get("ro.kernel.qemu").equals("1");
@@ -1206,8 +1204,7 @@ public final class SystemServer {
mSystemServiceManager.startService(AudioService.Lifecycle.class);
traceEnd();
if (enableRadioService &&
mPackageManager.hasSystemFeature(PackageManager.FEATURE_RADIO)) {
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_RADIO)) {
traceBeginAndSlog("StartRadioService");
mSystemServiceManager.startService(RadioService.class);
traceEnd();