Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MediaController] Fix CustomCommand crash issue #5652

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Tizen.Applications;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using NativeClient = Interop.MediaControllerClient;
using NativeServer = Interop.MediaControllerServer;
using NativeClientHandle = Interop.MediaControllerClientHandle;
Expand Down Expand Up @@ -59,10 +60,22 @@ internal void SetRequestInformation(string receiverId)
/// <param name="requestId">The request Id for each command.</param>
internal void SetResponseInformation(string receiverId, string requestId)
{
ReceiverId = receiverId ?? throw new ArgumentNullException(nameof(receiverId)); ;
_requestId = requestId ?? throw new ArgumentNullException(nameof(requestId)); ;
ReceiverId = receiverId ?? throw new ArgumentNullException(nameof(receiverId));
_requestId = requestId;

if (_requestId == null)
{
Log.Info(GetType().FullName, "request_id is null. Response() should not be called.");
}
}

/// <summary>
/// Gets the status of response.
/// </summary>
/// <remarks>If false, the receiver should not response for the received command.</remarks>
[EditorBrowsable(EditorBrowsableState.Never)]
public bool NeedToResponse => _requestId != null;

/// <summary>
/// Requests command to server.
/// </summary>
Expand Down Expand Up @@ -90,6 +103,11 @@ protected virtual void OnResponseCompleted() { }
/// <param name="bundle">The extra data.</param>
internal void Response(IntPtr serverHandle, int result, Bundle bundle)
{
if (NeedToResponse == false)
{
throw new InvalidOperationException("The receiver should not call this, if NeedToResponse is false.");
}

try
{
if (bundle != null)
Expand Down Expand Up @@ -121,6 +139,11 @@ internal void Response(IntPtr serverHandle, int result, Bundle bundle)
/// <param name="bundle">The extra data.</param>
internal void Response(NativeClientHandle clientHandle, int result, Bundle bundle)
{
if (NeedToResponse == false)
{
throw new InvalidOperationException("The receiver should not call this, if NeedToResponse is false.");
}

try
{
if (bundle != null)
Expand Down Expand Up @@ -645,7 +668,7 @@ public SearchCommand(MediaControlSearchCondition condition)
NativeClient.CreateSearchHandle(out _searchHandle).ThrowIfError("Failed to create search handle.");

try
{
{
if (condition.Bundle != null)
{
NativeClient.SetSearchConditionBundle(_searchHandle, condition.ContentType, condition.Category,
Expand Down
Loading