Merge "Add log info for BroadcastRadioService" into tm-qpr-dev
This commit is contained in:
@@ -39,7 +39,6 @@ import java.util.OptionalInt;
|
|||||||
|
|
||||||
public class BroadcastRadioService extends SystemService {
|
public class BroadcastRadioService extends SystemService {
|
||||||
private static final String TAG = "BcRadioSrv";
|
private static final String TAG = "BcRadioSrv";
|
||||||
private static final boolean DEBUG = false;
|
|
||||||
|
|
||||||
private final ServiceImpl mServiceImpl = new ServiceImpl();
|
private final ServiceImpl mServiceImpl = new ServiceImpl();
|
||||||
|
|
||||||
@@ -74,6 +73,7 @@ public class BroadcastRadioService extends SystemService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RadioManager.ModuleProperties> listModules() {
|
public List<RadioManager.ModuleProperties> listModules() {
|
||||||
|
Slog.v(TAG, "Listing HIDL modules");
|
||||||
enforcePolicyAccess();
|
enforcePolicyAccess();
|
||||||
List<RadioManager.ModuleProperties> modules = new ArrayList<>();
|
List<RadioManager.ModuleProperties> modules = new ArrayList<>();
|
||||||
modules.addAll(mV1Modules);
|
modules.addAll(mV1Modules);
|
||||||
@@ -84,7 +84,7 @@ public class BroadcastRadioService extends SystemService {
|
|||||||
@Override
|
@Override
|
||||||
public ITuner openTuner(int moduleId, RadioManager.BandConfig bandConfig,
|
public ITuner openTuner(int moduleId, RadioManager.BandConfig bandConfig,
|
||||||
boolean withAudio, ITunerCallback callback) throws RemoteException {
|
boolean withAudio, ITunerCallback callback) throws RemoteException {
|
||||||
if (DEBUG) Slog.i(TAG, "Opening module " + moduleId);
|
Slog.v(TAG, "Opening module " + moduleId);
|
||||||
enforcePolicyAccess();
|
enforcePolicyAccess();
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
throw new IllegalArgumentException("Callback must not be empty");
|
throw new IllegalArgumentException("Callback must not be empty");
|
||||||
@@ -101,16 +101,14 @@ public class BroadcastRadioService extends SystemService {
|
|||||||
@Override
|
@Override
|
||||||
public ICloseHandle addAnnouncementListener(int[] enabledTypes,
|
public ICloseHandle addAnnouncementListener(int[] enabledTypes,
|
||||||
IAnnouncementListener listener) {
|
IAnnouncementListener listener) {
|
||||||
if (DEBUG) {
|
Slog.v(TAG, "Adding announcement listener for " + Arrays.toString(enabledTypes));
|
||||||
Slog.i(TAG, "Adding announcement listener for " + Arrays.toString(enabledTypes));
|
|
||||||
}
|
|
||||||
Objects.requireNonNull(enabledTypes);
|
Objects.requireNonNull(enabledTypes);
|
||||||
Objects.requireNonNull(listener);
|
Objects.requireNonNull(listener);
|
||||||
enforcePolicyAccess();
|
enforcePolicyAccess();
|
||||||
|
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (!mHal2.hasAnyModules()) {
|
if (!mHal2.hasAnyModules()) {
|
||||||
Slog.i(TAG, "There are no HAL 2.x modules registered");
|
Slog.i(TAG, "There are no HAL 2.0 modules registered");
|
||||||
return new AnnouncementAggregator(listener, mLock);
|
return new AnnouncementAggregator(listener, mLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ public class BroadcastRadioService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public @NonNull Collection<RadioManager.ModuleProperties> listModules() {
|
public @NonNull Collection<RadioManager.ModuleProperties> listModules() {
|
||||||
|
Slog.v(TAG, "List HIDL 2.0 modules");
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
return mModules.values().stream().map(module -> module.mProperties)
|
return mModules.values().stream().map(module -> module.mProperties)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@@ -152,10 +153,11 @@ public class BroadcastRadioService {
|
|||||||
|
|
||||||
public ITuner openSession(int moduleId, @Nullable RadioManager.BandConfig legacyConfig,
|
public ITuner openSession(int moduleId, @Nullable RadioManager.BandConfig legacyConfig,
|
||||||
boolean withAudio, @NonNull ITunerCallback callback) throws RemoteException {
|
boolean withAudio, @NonNull ITunerCallback callback) throws RemoteException {
|
||||||
|
Slog.v(TAG, "Open HIDL 2.0 session");
|
||||||
Objects.requireNonNull(callback);
|
Objects.requireNonNull(callback);
|
||||||
|
|
||||||
if (!withAudio) {
|
if (!withAudio) {
|
||||||
throw new IllegalArgumentException("Non-audio sessions not supported with HAL 2.x");
|
throw new IllegalArgumentException("Non-audio sessions not supported with HAL 2.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
RadioModule module = null;
|
RadioModule module = null;
|
||||||
@@ -175,6 +177,7 @@ public class BroadcastRadioService {
|
|||||||
|
|
||||||
public ICloseHandle addAnnouncementListener(@NonNull int[] enabledTypes,
|
public ICloseHandle addAnnouncementListener(@NonNull int[] enabledTypes,
|
||||||
@NonNull IAnnouncementListener listener) {
|
@NonNull IAnnouncementListener listener) {
|
||||||
|
Slog.v(TAG, "Add announcementListener");
|
||||||
AnnouncementAggregator aggregator = new AnnouncementAggregator(listener, mLock);
|
AnnouncementAggregator aggregator = new AnnouncementAggregator(listener, mLock);
|
||||||
boolean anySupported = false;
|
boolean anySupported = false;
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
|
|||||||
@@ -142,8 +142,12 @@ class RadioModule {
|
|||||||
public static @Nullable RadioModule tryLoadingModule(int idx, @NonNull String fqName,
|
public static @Nullable RadioModule tryLoadingModule(int idx, @NonNull String fqName,
|
||||||
Object lock) {
|
Object lock) {
|
||||||
try {
|
try {
|
||||||
|
Slog.i(TAG, "Try loading module for idx " + idx + ", fqName " + fqName);
|
||||||
IBroadcastRadio service = IBroadcastRadio.getService(fqName);
|
IBroadcastRadio service = IBroadcastRadio.getService(fqName);
|
||||||
if (service == null) return null;
|
if (service == null) {
|
||||||
|
Slog.w(TAG, "No service found for fqName " + fqName);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Mutable<AmFmRegionConfig> amfmConfig = new Mutable<>();
|
Mutable<AmFmRegionConfig> amfmConfig = new Mutable<>();
|
||||||
service.getAmFmRegionConfig(false, (result, config) -> {
|
service.getAmFmRegionConfig(false, (result, config) -> {
|
||||||
@@ -160,7 +164,7 @@ class RadioModule {
|
|||||||
|
|
||||||
return new RadioModule(service, prop, lock);
|
return new RadioModule(service, prop, lock);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Slog.e(TAG, "failed to load module " + fqName, ex);
|
Slog.e(TAG, "Failed to load module " + fqName, ex);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,6 +175,7 @@ class RadioModule {
|
|||||||
|
|
||||||
public @NonNull TunerSession openSession(@NonNull android.hardware.radio.ITunerCallback userCb)
|
public @NonNull TunerSession openSession(@NonNull android.hardware.radio.ITunerCallback userCb)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
|
Slog.i(TAG, "Open TunerSession");
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mHalTunerSession == null) {
|
if (mHalTunerSession == null) {
|
||||||
Mutable<ITunerSession> hwSession = new Mutable<>();
|
Mutable<ITunerSession> hwSession = new Mutable<>();
|
||||||
@@ -201,6 +206,7 @@ class RadioModule {
|
|||||||
// Copy the contents of mAidlTunerSessions into a local array because TunerSession.close()
|
// Copy the contents of mAidlTunerSessions into a local array because TunerSession.close()
|
||||||
// must be called without mAidlTunerSessions locked because it can call
|
// must be called without mAidlTunerSessions locked because it can call
|
||||||
// onTunerSessionClosed().
|
// onTunerSessionClosed().
|
||||||
|
Slog.i(TAG, "Close TunerSessions");
|
||||||
TunerSession[] tunerSessions;
|
TunerSession[] tunerSessions;
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
tunerSessions = new TunerSession[mAidlTunerSessions.size()];
|
tunerSessions = new TunerSession[mAidlTunerSessions.size()];
|
||||||
@@ -313,7 +319,7 @@ class RadioModule {
|
|||||||
}
|
}
|
||||||
onTunerSessionProgramListFilterChanged(null);
|
onTunerSessionProgramListFilterChanged(null);
|
||||||
if (mAidlTunerSessions.isEmpty() && mHalTunerSession != null) {
|
if (mAidlTunerSessions.isEmpty() && mHalTunerSession != null) {
|
||||||
Slog.v(TAG, "closing HAL tuner session");
|
Slog.i(TAG, "Closing HAL tuner session");
|
||||||
try {
|
try {
|
||||||
mHalTunerSession.close();
|
mHalTunerSession.close();
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
@@ -365,6 +371,7 @@ class RadioModule {
|
|||||||
|
|
||||||
public android.hardware.radio.ICloseHandle addAnnouncementListener(@NonNull int[] enabledTypes,
|
public android.hardware.radio.ICloseHandle addAnnouncementListener(@NonNull int[] enabledTypes,
|
||||||
@NonNull android.hardware.radio.IAnnouncementListener listener) throws RemoteException {
|
@NonNull android.hardware.radio.IAnnouncementListener listener) throws RemoteException {
|
||||||
|
Slog.i(TAG, "Add AnnouncementListener");
|
||||||
ArrayList<Byte> enabledList = new ArrayList<>();
|
ArrayList<Byte> enabledList = new ArrayList<>();
|
||||||
for (int type : enabledTypes) {
|
for (int type : enabledTypes) {
|
||||||
enabledList.add((byte)type);
|
enabledList.add((byte)type);
|
||||||
@@ -401,6 +408,7 @@ class RadioModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bitmap getImage(int id) {
|
Bitmap getImage(int id) {
|
||||||
|
Slog.i(TAG, "Get image for id " + id);
|
||||||
if (id == 0) throw new IllegalArgumentException("Image ID is missing");
|
if (id == 0) throw new IllegalArgumentException("Image ID is missing");
|
||||||
|
|
||||||
byte[] rawImage;
|
byte[] rawImage;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import android.hardware.radio.ProgramList;
|
|||||||
import android.hardware.radio.ProgramSelector;
|
import android.hardware.radio.ProgramSelector;
|
||||||
import android.hardware.radio.RadioManager;
|
import android.hardware.radio.RadioManager;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.util.Log;
|
||||||
import android.util.MutableBoolean;
|
import android.util.MutableBoolean;
|
||||||
import android.util.MutableInt;
|
import android.util.MutableInt;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
@@ -61,8 +62,13 @@ class TunerSession extends ITuner.Stub {
|
|||||||
mLock = Objects.requireNonNull(lock);
|
mLock = Objects.requireNonNull(lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isDebugEnabled() {
|
||||||
|
return Log.isLoggable(TAG, Log.DEBUG);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
|
if (isDebugEnabled()) Slog.d(TAG, "Close");
|
||||||
close(null);
|
close(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +80,7 @@ class TunerSession extends ITuner.Stub {
|
|||||||
* @param error Optional error to send to client before session is closed.
|
* @param error Optional error to send to client before session is closed.
|
||||||
*/
|
*/
|
||||||
public void close(@Nullable Integer error) {
|
public void close(@Nullable Integer error) {
|
||||||
|
if (isDebugEnabled()) Slog.d(TAG, "Close on error " + error);
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mIsClosed) return;
|
if (mIsClosed) return;
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
@@ -104,7 +111,7 @@ class TunerSession extends ITuner.Stub {
|
|||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
checkNotClosedLocked();
|
checkNotClosedLocked();
|
||||||
mDummyConfig = Objects.requireNonNull(config);
|
mDummyConfig = Objects.requireNonNull(config);
|
||||||
Slog.i(TAG, "Ignoring setConfiguration - not applicable for broadcastradio HAL 2.x");
|
Slog.i(TAG, "Ignoring setConfiguration - not applicable for broadcastradio HAL 2.0");
|
||||||
mModule.fanoutAidlCallback(cb -> cb.onConfigurationChanged(config));
|
mModule.fanoutAidlCallback(cb -> cb.onConfigurationChanged(config));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,6 +144,10 @@ class TunerSession extends ITuner.Stub {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void step(boolean directionDown, boolean skipSubChannel) throws RemoteException {
|
public void step(boolean directionDown, boolean skipSubChannel) throws RemoteException {
|
||||||
|
if (isDebugEnabled()) {
|
||||||
|
Slog.d(TAG, "Step with directionDown " + directionDown
|
||||||
|
+ " skipSubChannel " + skipSubChannel);
|
||||||
|
}
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
checkNotClosedLocked();
|
checkNotClosedLocked();
|
||||||
int halResult = mHwSession.step(!directionDown);
|
int halResult = mHwSession.step(!directionDown);
|
||||||
@@ -146,6 +157,10 @@ class TunerSession extends ITuner.Stub {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scan(boolean directionDown, boolean skipSubChannel) throws RemoteException {
|
public void scan(boolean directionDown, boolean skipSubChannel) throws RemoteException {
|
||||||
|
if (isDebugEnabled()) {
|
||||||
|
Slog.d(TAG, "Scan with directionDown " + directionDown
|
||||||
|
+ " skipSubChannel " + skipSubChannel);
|
||||||
|
}
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
checkNotClosedLocked();
|
checkNotClosedLocked();
|
||||||
int halResult = mHwSession.scan(!directionDown, skipSubChannel);
|
int halResult = mHwSession.scan(!directionDown, skipSubChannel);
|
||||||
@@ -155,6 +170,7 @@ class TunerSession extends ITuner.Stub {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tune(ProgramSelector selector) throws RemoteException {
|
public void tune(ProgramSelector selector) throws RemoteException {
|
||||||
|
if (isDebugEnabled()) Slog.d(TAG, "Tune with selector " + selector);
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
checkNotClosedLocked();
|
checkNotClosedLocked();
|
||||||
int halResult = mHwSession.tune(Convert.programSelectorToHal(selector));
|
int halResult = mHwSession.tune(Convert.programSelectorToHal(selector));
|
||||||
@@ -164,6 +180,7 @@ class TunerSession extends ITuner.Stub {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
|
Slog.i(TAG, "Cancel");
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
checkNotClosedLocked();
|
checkNotClosedLocked();
|
||||||
Utils.maybeRethrow(mHwSession::cancel);
|
Utils.maybeRethrow(mHwSession::cancel);
|
||||||
@@ -172,23 +189,25 @@ class TunerSession extends ITuner.Stub {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelAnnouncement() {
|
public void cancelAnnouncement() {
|
||||||
Slog.i(TAG, "Announcements control doesn't involve cancelling at the HAL level in 2.x");
|
Slog.i(TAG, "Announcements control doesn't involve cancelling at the HAL level in HAL 2.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Bitmap getImage(int id) {
|
public Bitmap getImage(int id) {
|
||||||
|
if (isDebugEnabled()) Slog.d(TAG, "Get image for " + id);
|
||||||
return mModule.getImage(id);
|
return mModule.getImage(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean startBackgroundScan() {
|
public boolean startBackgroundScan() {
|
||||||
Slog.i(TAG, "Explicit background scan trigger is not supported with HAL 2.x");
|
Slog.i(TAG, "Explicit background scan trigger is not supported with HAL 2.0");
|
||||||
mModule.fanoutAidlCallback(cb -> cb.onBackgroundScanComplete());
|
mModule.fanoutAidlCallback(cb -> cb.onBackgroundScanComplete());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startProgramListUpdates(ProgramList.Filter filter) throws RemoteException {
|
public void startProgramListUpdates(ProgramList.Filter filter) throws RemoteException {
|
||||||
|
if (isDebugEnabled()) Slog.d(TAG, "start programList updates " + filter);
|
||||||
// If the AIDL client provides a null filter, it wants all updates, so use the most broad
|
// If the AIDL client provides a null filter, it wants all updates, so use the most broad
|
||||||
// filter.
|
// filter.
|
||||||
if (filter == null) {
|
if (filter == null) {
|
||||||
@@ -247,6 +266,7 @@ class TunerSession extends ITuner.Stub {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopProgramListUpdates() throws RemoteException {
|
public void stopProgramListUpdates() throws RemoteException {
|
||||||
|
if (isDebugEnabled()) Slog.d(TAG, "Stop programList updates");
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
checkNotClosedLocked();
|
checkNotClosedLocked();
|
||||||
mProgramInfoCache = null;
|
mProgramInfoCache = null;
|
||||||
@@ -270,7 +290,7 @@ class TunerSession extends ITuner.Stub {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isConfigFlagSet(int flag) {
|
public boolean isConfigFlagSet(int flag) {
|
||||||
Slog.v(TAG, "isConfigFlagSet " + ConfigFlag.toString(flag));
|
if (isDebugEnabled()) Slog.d(TAG, "Is ConfigFlagSet for " + ConfigFlag.toString(flag));
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
checkNotClosedLocked();
|
checkNotClosedLocked();
|
||||||
|
|
||||||
@@ -292,7 +312,9 @@ class TunerSession extends ITuner.Stub {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setConfigFlag(int flag, boolean value) throws RemoteException {
|
public void setConfigFlag(int flag, boolean value) throws RemoteException {
|
||||||
Slog.v(TAG, "setConfigFlag " + ConfigFlag.toString(flag) + " = " + value);
|
if (isDebugEnabled()) {
|
||||||
|
Slog.d(TAG, "Set ConfigFlag " + ConfigFlag.toString(flag) + " = " + value);
|
||||||
|
}
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
checkNotClosedLocked();
|
checkNotClosedLocked();
|
||||||
int halResult = mHwSession.setConfigFlag(flag, value);
|
int halResult = mHwSession.setConfigFlag(flag, value);
|
||||||
|
|||||||
Reference in New Issue
Block a user