Home | History | Annotate | Download | only in compat
      1 /*
      2  * Copyright (C) 2016 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.contacts.common.compat;
     18 
     19 import android.telecom.Call;
     20 
     21 import java.lang.reflect.InvocationTargetException;
     22 import java.lang.reflect.Method;
     23 
     24 public class CallSdkCompat {
     25     public static class Details {
     26         public static final int PROPERTY_IS_EXTERNAL_CALL = Call.Details.PROPERTY_IS_EXTERNAL_CALL;
     27         public static final int PROPERTY_ENTERPRISE_CALL = Call.Details.PROPERTY_ENTERPRISE_CALL;
     28         public static final int CAPABILITY_CAN_PULL_CALL = Call.Details.CAPABILITY_CAN_PULL_CALL;
     29         public static final int CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO =
     30                 Call.Details.CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO;
     31     }
     32 
     33     /**
     34      * TODO: This API is hidden in the N release; replace the implementation with a call to the
     35      * actual once it is made public.
     36      */
     37     public static void pullExternalCall(Call call) {
     38         if (!CompatUtils.isNCompatible()) {
     39             return;
     40         }
     41         Class<?> callClass = Call.class;
     42         try {
     43             Method pullExternalCallMethod = callClass.getDeclaredMethod("pullExternalCall");
     44             pullExternalCallMethod.invoke(call);
     45         } catch (NoSuchMethodException e) {
     46             // Ignore requests to pull call if there is a problem.
     47         } catch (InvocationTargetException e) {
     48             // Ignore requests to pull call if there is a problem.
     49         } catch (IllegalAccessException e) {
     50             // Ignore requests to pull call if there is a problem.
     51         }
     52     }
     53 }
     54