Skip to content

Most visited

Recently visited

navigation
MediaBrowserService / src / com.example.android.mediabrowserservice / utils /

CarHelper.java

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
package com.example.android.mediabrowserservice.utils;
17
 
18
import android.os.Bundle;
19
 
20
public class CarHelper {
21
    private static final String AUTO_APP_PACKAGE_NAME = "com.google.android.projection.gearhead";
22
 
23
    // Use these extras to reserve space for the corresponding actions, even when they are disabled
24
    // in the playbackstate, so the custom actions don't reflow.
25
    private static final String SLOT_RESERVATION_SKIP_TO_NEXT =
26
            "com.google.android.gms.car.media.ALWAYS_RESERVE_SPACE_FOR.ACTION_SKIP_TO_NEXT";
27
    private static final String SLOT_RESERVATION_SKIP_TO_PREV =
28
            "com.google.android.gms.car.media.ALWAYS_RESERVE_SPACE_FOR.ACTION_SKIP_TO_PREVIOUS";
29
    private static final String SLOT_RESERVATION_QUEUE =
30
            "com.google.android.gms.car.media.ALWAYS_RESERVE_SPACE_FOR.ACTION_QUEUE";
31
 
32
 
33
    public static boolean isValidCarPackage(String packageName) {
34
        return AUTO_APP_PACKAGE_NAME.equals(packageName);
35
    }
36
 
37
    public static void setSlotReservationFlags(Bundle extras, boolean reservePlayingQueueSlot,
38
          boolean reserveSkipToNextSlot, boolean reserveSkipToPrevSlot) {
39
        if (reservePlayingQueueSlot) {
40
            extras.putBoolean(SLOT_RESERVATION_QUEUE, true);
41
        } else {
42
            extras.remove(SLOT_RESERVATION_QUEUE);
43
        }
44
        if (reserveSkipToPrevSlot) {
45
            extras.putBoolean(SLOT_RESERVATION_SKIP_TO_PREV, true);
46
        } else {
47
            extras.remove(SLOT_RESERVATION_SKIP_TO_PREV);
48
        }
49
        if (reserveSkipToNextSlot) {
50
            extras.putBoolean(SLOT_RESERVATION_SKIP_TO_NEXT, true);
51
        } else {
52
            extras.remove(SLOT_RESERVATION_SKIP_TO_NEXT);
53
        }
54
    }
55
}
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)