PlaybackStateCompatApi21.java revision d2eec9eeb9bacd4b62d4fc1c66760ec1f7f8a73b
1/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.support.v4.media.session;
18
19import android.media.session.PlaybackState;
20import android.os.SystemClock;
21
22class PlaybackStateCompatApi21 {
23    public static int getState(Object stateObj) {
24        return ((PlaybackState)stateObj).getState();
25    }
26
27    public static long getPosition(Object stateObj) {
28        return ((PlaybackState)stateObj).getPosition();
29    }
30
31    public static long getBufferPosition(Object stateObj) {
32        return ((PlaybackState)stateObj).getBufferPosition();
33    }
34
35    public static float getPlaybackRate(Object stateObj) {
36        return ((PlaybackState)stateObj).getPlaybackRate();
37    }
38
39    public static long getActions(Object stateObj) {
40        return ((PlaybackState)stateObj).getActions();
41    }
42
43    public static CharSequence getErrorMessage(Object stateObj) {
44        return ((PlaybackState)stateObj).getErrorMessage();
45    }
46
47    public static long getLastPositionUpdateTime(Object stateObj) {
48        // TODO: this method is inaccessible
49        // return ((PlaybackState)stateObj).getLastPositionUpdateTime();
50        return SystemClock.uptimeMillis();
51    }
52
53    public static Object newInstance(int state, long position, long bufferPosition,
54            float rate, long actions, CharSequence errorMessage, long updateTime) {
55        PlaybackState stateObj = new PlaybackState();
56        stateObj.setState(state, position, rate);
57        stateObj.setBufferPosition(bufferPosition);
58        stateObj.setActions(actions);
59        stateObj.setErrorMessage(errorMessage);
60        // TODO: updateTime is inaccessible
61        return stateObj;
62    }
63}
64