Home | History | Annotate | Download | only in media
      1 /*
      2  * Copyright 2018 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.android.settingslib.media;
     17 
     18 import android.content.Context;
     19 import android.graphics.drawable.Drawable;
     20 import android.widget.Toast;
     21 
     22 import androidx.mediarouter.media.MediaRouter;
     23 
     24 import com.android.settingslib.R;
     25 import com.android.settingslib.bluetooth.BluetoothUtils;
     26 
     27 /**
     28  * InfoMediaDevice extends MediaDevice to represents wifi device.
     29  */
     30 public class InfoMediaDevice extends MediaDevice {
     31 
     32     private static final String TAG = "InfoMediaDevice";
     33 
     34     private MediaRouter.RouteInfo mRouteInfo;
     35 
     36     InfoMediaDevice(Context context, MediaRouter.RouteInfo info) {
     37         super(context, MediaDeviceType.TYPE_CAST_DEVICE);
     38         mRouteInfo = info;
     39         initDeviceRecord();
     40     }
     41 
     42     @Override
     43     public String getName() {
     44         return mRouteInfo.getName();
     45     }
     46 
     47     @Override
     48     public String getSummary() {
     49         return null;
     50     }
     51 
     52     @Override
     53     public Drawable getIcon() {
     54         //TODO(b/120669861): Return remote device icon uri once api is ready.
     55         return BluetoothUtils.buildBtRainbowDrawable(mContext,
     56                 mContext.getDrawable(R.drawable.ic_media_device), getId().hashCode());
     57     }
     58 
     59     @Override
     60     public String getId() {
     61         return MediaDeviceUtils.getId(mRouteInfo);
     62     }
     63 
     64     @Override
     65     public boolean connect() {
     66         //TODO(b/121083246): use SystemApi to transfer media
     67         setConnectedRecord();
     68         Toast.makeText(mContext, "This is cast device !", Toast.LENGTH_SHORT).show();
     69         return false;
     70     }
     71 
     72     @Override
     73     public void disconnect() {
     74         //TODO(b/121083246): disconnected last select device
     75     }
     76 
     77     @Override
     78     public boolean isConnected() {
     79         return true;
     80     }
     81 }
     82