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