Close panel when media stop
-Add forceClose callback to finish panel -Add test cases Bug: 151396986 Test: make -j50 RunSettingsRoboTests Change-Id: Ic0ac2880a4ff412382816ccb41b4fbb60dbdf519
This commit is contained in:
@@ -33,6 +33,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.media.MediaMetadata;
|
||||
import android.media.session.MediaController;
|
||||
import android.media.session.MediaSessionManager;
|
||||
import android.media.session.PlaybackState;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -66,12 +67,11 @@ public class MediaOutputPanel implements PanelContent, LocalMediaManager.DeviceC
|
||||
private final Context mContext;
|
||||
private final String mPackageName;
|
||||
|
||||
private PanelContentCallback mCallback;
|
||||
private boolean mIsCustomizedButtonUsed = true;
|
||||
|
||||
@VisibleForTesting
|
||||
LocalMediaManager mLocalMediaManager;
|
||||
|
||||
private PanelContentCallback mCallback;
|
||||
private boolean mIsCustomizedButtonUsed = true;
|
||||
private MediaSessionManager mMediaSessionManager;
|
||||
private MediaController mMediaController;
|
||||
|
||||
@@ -255,5 +255,12 @@ public class MediaOutputPanel implements PanelContent, LocalMediaManager.DeviceC
|
||||
mCallback.onHeaderChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaybackStateChanged(PlaybackState state) {
|
||||
if (mCallback != null && state.getState() != PlaybackState.STATE_PLAYING) {
|
||||
mCallback.forceClose();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,4 +32,9 @@ public interface PanelContentCallback {
|
||||
* a group
|
||||
*/
|
||||
void onHeaderChanged();
|
||||
|
||||
/**
|
||||
* It will be called when panel requests to close itself.
|
||||
*/
|
||||
void forceClose();
|
||||
}
|
||||
|
||||
@@ -433,5 +433,16 @@ public class PanelFragment extends Fragment {
|
||||
mHeaderSubtitle.setText(mPanel.getSubTitle());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forceClose() {
|
||||
mPanelClosedKey = PanelClosedKeys.KEY_OTHERS;
|
||||
getFragmentActivity().finish();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
FragmentActivity getFragmentActivity() {
|
||||
return getActivity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user