Merge "TIF: Rename setTvInputInfo to updateTvInputInfo" into nyc-dev

This commit is contained in:
Jae Seo
2016-02-17 02:52:42 +00:00
committed by Android (Google) Code Review
8 changed files with 51 additions and 42 deletions

View File

@@ -22977,7 +22977,7 @@ package android.media.tv {
method public void onInputRemoved(java.lang.String);
method public void onInputStateChanged(java.lang.String, int);
method public void onInputUpdated(java.lang.String);
method public void onTvInputInfoChanged(android.media.tv.TvInputInfo);
method public void onTvInputInfoUpdated(android.media.tv.TvInputInfo);
}
public abstract class TvInputService extends android.app.Service {
@@ -22985,7 +22985,7 @@ package android.media.tv {
method public final android.os.IBinder onBind(android.content.Intent);
method public android.media.tv.TvInputService.RecordingSession onCreateRecordingSession(java.lang.String);
method public abstract android.media.tv.TvInputService.Session onCreateSession(java.lang.String);
method public static final void setTvInputInfo(android.content.Context, android.media.tv.TvInputInfo);
method public static final void updateTvInputInfo(android.content.Context, android.media.tv.TvInputInfo);
field public static final java.lang.String SERVICE_INTERFACE = "android.media.tv.TvInputService";
field public static final java.lang.String SERVICE_META_DATA = "android.media.tv.input";
}

View File

@@ -24720,7 +24720,7 @@ package android.media.tv {
method public void onInputRemoved(java.lang.String);
method public void onInputStateChanged(java.lang.String, int);
method public void onInputUpdated(java.lang.String);
method public void onTvInputInfoChanged(android.media.tv.TvInputInfo);
method public void onTvInputInfoUpdated(android.media.tv.TvInputInfo);
}
public abstract class TvInputService extends android.app.Service {
@@ -24732,7 +24732,7 @@ package android.media.tv {
method public java.lang.String onHardwareRemoved(android.media.tv.TvInputHardwareInfo);
method public android.media.tv.TvInputInfo onHdmiDeviceAdded(android.hardware.hdmi.HdmiDeviceInfo);
method public java.lang.String onHdmiDeviceRemoved(android.hardware.hdmi.HdmiDeviceInfo);
method public static final void setTvInputInfo(android.content.Context, android.media.tv.TvInputInfo);
method public static final void updateTvInputInfo(android.content.Context, android.media.tv.TvInputInfo);
field public static final java.lang.String SERVICE_INTERFACE = "android.media.tv.TvInputService";
field public static final java.lang.String SERVICE_META_DATA = "android.media.tv.input";
}

View File

@@ -22986,7 +22986,7 @@ package android.media.tv {
method public void onInputRemoved(java.lang.String);
method public void onInputStateChanged(java.lang.String, int);
method public void onInputUpdated(java.lang.String);
method public void onTvInputInfoChanged(android.media.tv.TvInputInfo);
method public void onTvInputInfoUpdated(android.media.tv.TvInputInfo);
}
public abstract class TvInputService extends android.app.Service {
@@ -22994,7 +22994,7 @@ package android.media.tv {
method public final android.os.IBinder onBind(android.content.Intent);
method public android.media.tv.TvInputService.RecordingSession onCreateRecordingSession(java.lang.String);
method public abstract android.media.tv.TvInputService.Session onCreateSession(java.lang.String);
method public static final void setTvInputInfo(android.content.Context, android.media.tv.TvInputInfo);
method public static final void updateTvInputInfo(android.content.Context, android.media.tv.TvInputInfo);
field public static final java.lang.String SERVICE_INTERFACE = "android.media.tv.TvInputService";
field public static final java.lang.String SERVICE_META_DATA = "android.media.tv.input";
}

View File

@@ -41,7 +41,7 @@ import android.view.Surface;
interface ITvInputManager {
List<TvInputInfo> getTvInputList(int userId);
TvInputInfo getTvInputInfo(in String inputId, int userId);
void setTvInputInfo(in TvInputInfo inputInfo, int userId);
void updateTvInputInfo(in TvInputInfo inputInfo, int userId);
int getTvInputState(in String inputId, int userId);
List<TvContentRatingSystemInfo> getTvContentRatingSystemList(int userId);

View File

@@ -26,8 +26,6 @@ oneway interface ITvInputManagerCallback {
void onInputAdded(in String inputId);
void onInputRemoved(in String inputId);
void onInputUpdated(in String inputId);
void onInputStateChanged(in String inputId, int state);
void onTvInputInfoChanged(in TvInputInfo TvInputInfo);
void onTvInputInfoUpdated(in TvInputInfo TvInputInfo);
}

View File

@@ -727,11 +727,17 @@ public final class TvInputManager {
}
/**
* This is called when the information about a given TV input has been changed.
* This is called when the information about an existing TV input has been updated.
*
* @param inputInfo TvInputInfo object that contains the information about the TV input.
* <p>Because the system automatically creates a <code>TvInputInfo</code> object for each TV
* input based on the information collected from the <code>AndroidManifest.xml</code>, this
* method is only called back when such information has changed dynamically or when the TV
* input service implementation wants to pass additional information that is not specified
* by the manifest file, such as ability to record and tuner count.
*
* @param inputInfo The <code>TvInputInfo</code> object that contains new information.
*/
public void onTvInputInfoChanged(TvInputInfo inputInfo) {
public void onTvInputInfoUpdated(TvInputInfo inputInfo) {
}
}
@@ -784,11 +790,11 @@ public final class TvInputManager {
});
}
public void postTvInputInfoChanged(final TvInputInfo inputInfo) {
public void postTvInputInfoUpdated(final TvInputInfo inputInfo) {
mHandler.post(new Runnable() {
@Override
public void run() {
mCallback.onTvInputInfoChanged(inputInfo);
mCallback.onTvInputInfoUpdated(inputInfo);
}
});
}
@@ -1077,10 +1083,10 @@ public final class TvInputManager {
}
@Override
public void onTvInputInfoChanged(TvInputInfo inputInfo) {
public void onTvInputInfoUpdated(TvInputInfo inputInfo) {
synchronized (mLock) {
for (TvInputCallbackRecord record : mCallbackRecords) {
record.postTvInputInfoChanged(inputInfo);
record.postTvInputInfoUpdated(inputInfo);
}
}
}
@@ -1131,19 +1137,19 @@ public final class TvInputManager {
}
/**
* Sets a new TvInputInfo object for a given input.
* Updates information about an existing TV input.
*
* <p>This is called internally only by {@link TvInputService}.
*
* @param inputInfo The TvInputInfo object to set.
* @param inputInfo The <code>TvInputInfo</code> object that contains new information.
* @throws IllegalArgumentException if the argument is {@code null}.
*/
void setTvInputInfo(@NonNull TvInputInfo inputInfo) {
void updateTvInputInfo(@NonNull TvInputInfo inputInfo) {
Preconditions.checkNotNull(inputInfo);
try {
mService.setTvInputInfo(inputInfo, mUserId);
mService.updateTvInputInfo(inputInfo, mUserId);
} catch (RemoteException e) {
throw new RuntimeException("Error trying to set " + inputInfo, e);
throw new RuntimeException("Error trying to update " + inputInfo, e);
}
}

View File

@@ -255,23 +255,31 @@ public abstract class TvInputService extends Service {
return null;
}
/**
* Sets the TvInputInfo for this TV input.
* Updates the <code>TvInputInfo</code> for an existing TV input. A TV input service
* implementation may call this method to pass the application and system an up-to-date
* <code>TvInputInfo</code> object that describes itself.
*
* <p>The system service automatically creates the TvInputInfo for each TV input based on
* information collected from the AndroidManifest.xml, thus it is not necessary to call this
* method unless the TV input has additional information to pass such as ability to record and
* tuner count. Attempting to change information about a TV input that the calling package does
* not own does nothing.
* <p>The system automatically creates a <code>TvInputInfo</code> object for each TV input,
* based on the information collected from the <code>AndroidManifest.xml</code>, thus it is not
* necessary to call this method unless such information has changed dynamically. This may be
* also used to pass additional information that is not specified by the manifest file, such as
* ability to record and tuner count. Use {@link TvInputInfo.Builder} to build a new
* <code>TvInputInfo</code> object.
*
* <p>Attempting to change information about a TV input that the calling package does not own
* does nothing.
*
* @param context The application context.
* @param inputInfo The TvInputInfo object that contains that new information.
* @param inputInfo The <code>TvInputInfo</code> object that contains new information.
* @see TvInputManager.TvInputCallback#onTvInputInfoUpdated(TvInputInfo)
*/
public static final void setTvInputInfo(Context context, TvInputInfo inputInfo) {
public static final void updateTvInputInfo(Context context, TvInputInfo inputInfo) {
TvInputManager manager = (TvInputManager) context.getSystemService(
Context.TV_INPUT_SERVICE);
manager.setTvInputInfo(inputInfo);
if (manager != null) {
manager.updateTvInputInfo(inputInfo);
}
}
private boolean isPassthroughInput(String inputId) {

View File

@@ -769,9 +769,9 @@ public final class TvInputManagerService extends SystemService {
}
}
private void setTvInputInfoLocked(UserState userState, TvInputInfo inputInfo) {
private void updateTvInputInfoLocked(UserState userState, TvInputInfo inputInfo) {
if (DEBUG) {
Slog.d(TAG, "setTvInputInfoLocked(inputInfo=" + inputInfo + ")");
Slog.d(TAG, "updateTvInputInfoLocked(inputInfo=" + inputInfo + ")");
}
String inputId = inputInfo.getId();
TvInputState inputState = userState.inputMap.get(inputId);
@@ -779,16 +779,13 @@ public final class TvInputManagerService extends SystemService {
Slog.e(TAG, "failed to set input info - unknown input id " + inputId);
return;
}
if (inputState.info.equals(inputInfo)) {
return;
}
inputState.info = inputInfo;
for (ITvInputManagerCallback callback : userState.callbackSet) {
try {
callback.onTvInputInfoChanged(inputInfo);
callback.onTvInputInfoUpdated(inputInfo);
} catch (RemoteException e) {
Slog.e(TAG, "failed to report changed input info to callback", e);
Slog.e(TAG, "failed to report updated input info to callback", e);
}
}
}
@@ -845,7 +842,7 @@ public final class TvInputManagerService extends SystemService {
}
}
public void setTvInputInfo(TvInputInfo inputInfo, int userId) {
public void updateTvInputInfo(TvInputInfo inputInfo, int userId) {
String inputInfoPackageName = inputInfo.getServiceInfo().packageName;
String callingPackageName = getCallingPackageName();
if (!TextUtils.equals(inputInfoPackageName, callingPackageName)) {
@@ -854,12 +851,12 @@ public final class TvInputManagerService extends SystemService {
}
final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(),
Binder.getCallingUid(), userId, "setTvInputInfo");
Binder.getCallingUid(), userId, "updateTvInputInfo");
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
UserState userState = getOrCreateUserStateLocked(resolvedUserId);
setTvInputInfoLocked(userState, inputInfo);
updateTvInputInfoLocked(userState, inputInfo);
}
} finally {
Binder.restoreCallingIdentity(identity);