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 } 56