Home | History | Annotate | Download | only in utils
      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.android.incallui.videotech.utils;
     18 
     19 import android.content.Context;
     20 import android.content.pm.PackageManager;
     21 import android.support.annotation.NonNull;
     22 import android.support.v4.content.ContextCompat;
     23 import com.android.dialer.util.PermissionsUtil;
     24 
     25 public class VideoUtils {
     26 
     27   public static boolean hasSentVideoUpgradeRequest(@SessionModificationState int state) {
     28     return state == SessionModificationState.WAITING_FOR_UPGRADE_TO_VIDEO_RESPONSE
     29         || state == SessionModificationState.UPGRADE_TO_VIDEO_REQUEST_FAILED
     30         || state == SessionModificationState.REQUEST_REJECTED
     31         || state == SessionModificationState.UPGRADE_TO_VIDEO_REQUEST_TIMED_OUT;
     32   }
     33 
     34   public static boolean hasReceivedVideoUpgradeRequest(@SessionModificationState int state) {
     35     return state == SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST;
     36   }
     37 
     38   public static boolean hasCameraPermissionAndShownPrivacyToast(@NonNull Context context) {
     39     return PermissionsUtil.hasCameraPrivacyToastShown(context) && hasCameraPermission(context);
     40   }
     41 
     42   public static boolean hasCameraPermission(@NonNull Context context) {
     43     return ContextCompat.checkSelfPermission(context, android.Manifest.permission.CAMERA)
     44         == PackageManager.PERMISSION_GRANTED;
     45   }
     46 }
     47