List of usage examples for android.content Context TELECOM_SERVICE
String TELECOM_SERVICE
To view the source code for android.content Context TELECOM_SERVICE.
Click Source Link
From source file:Main.java
private static TelecomManager getTelecomManager(Context context) { return (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); }
From source file:Main.java
/** Removes the missed call notifications. */ public static void removeMissedCallNotifications(Context context) { TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); telecomManager.cancelMissedCallsNotification(); }
From source file:Main.java
/** * Extract account color from PhoneAccount object. *//*from ww w . jav a2s . co m*/ public static int getAccountColor(Context context, PhoneAccountHandle accountHandle) { TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); final PhoneAccount account = telecomManager.getPhoneAccount(accountHandle); // For single-sim devices the PhoneAccount will be NO_HIGHLIGHT_COLOR by default, so it is // safe to always use the account highlight color. return account == null ? PhoneAccount.NO_HIGHLIGHT_COLOR : account.getHighlightColor(); }
From source file:Main.java
public static boolean isVideoEnabled(Context context) { if (true) {/* w w w .j a v a2 s . co m*/ return true; } TelecomManager telecommMgr = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); if (telecommMgr == null) { return false; } List<PhoneAccountHandle> phoneAccountHandles = telecommMgr.getCallCapablePhoneAccounts(); for (PhoneAccountHandle handle : phoneAccountHandles) { final PhoneAccount phoneAccount = telecommMgr.getPhoneAccount(handle); if (hasCapability(phoneAccount, PhoneAccount.CAPABILITY_VIDEO_CALLING)) { return true; } } return false; }
From source file:Main.java
/** * Return a list of phone accounts that are subscription/SIM accounts. *//*from ww w .j a v a2 s .com*/ public static List<PhoneAccountHandle> getSubscriptionPhoneAccounts(Context context) { final TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); List<PhoneAccountHandle> subscriptionAccountHandles = new ArrayList<PhoneAccountHandle>(); List<PhoneAccountHandle> accountHandles = telecomManager.getCallCapablePhoneAccounts(); for (PhoneAccountHandle accountHandle : accountHandles) { PhoneAccount account = telecomManager.getPhoneAccount(accountHandle); if (account.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)) { subscriptionAccountHandles.add(accountHandle); } } return subscriptionAccountHandles; }
From source file:Main.java
/** * Retrieve the account metadata, but if the account does not exist or the device has only a * single registered and enabled account, return null. *///from ww w .ja va 2 s . c o m static PhoneAccount getAccountOrNull(Context context, PhoneAccountHandle accountHandle) { TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); final PhoneAccount account = telecomManager.getPhoneAccount(accountHandle); if (telecomManager.getCallCapablePhoneAccounts().size() <= 1) { return null; } return account; }
From source file:com.mobileglobe.android.simpledialer.common.CallUtil.java
/** * Determines if video calling is available, and if so whether presence checking is available * as well./* w ww . ja v a 2s . c o m*/ * * Returns a bitmask with {@link #VIDEO_CALLING_ENABLED} to indicate that video calling is * available, and {@link #VIDEO_CALLING_PRESENCE} if presence indication is also available. * * @param context The context * @return A bit-mask describing the current video capabilities. */ @RequiresApi(api = Build.VERSION_CODES.M) public static int getVideoCallingAvailability(Context context) { if (!PermissionsUtil.hasPermission(context, Manifest.permission.READ_PHONE_STATE) || !CompatUtils.isVideoCompatible()) { return VIDEO_CALLING_DISABLED; } TelecomManager telecommMgr = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); if (telecommMgr == null) { return VIDEO_CALLING_DISABLED; } if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return 0; } List<PhoneAccountHandle> accountHandles = telecommMgr.getCallCapablePhoneAccounts(); for (PhoneAccountHandle accountHandle : accountHandles) { PhoneAccount account = telecommMgr.getPhoneAccount(accountHandle); if (account != null) { if (account.hasCapabilities(PhoneAccount.CAPABILITY_VIDEO_CALLING)) { // Builds prior to N do not have presence support. if (!CompatUtils.isVideoPresenceCompatible()) { return VIDEO_CALLING_ENABLED; } int videoCapabilities = VIDEO_CALLING_ENABLED; if (account .hasCapabilities(PhoneAccountSdkCompat.CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE)) { videoCapabilities |= VIDEO_CALLING_PRESENCE; } return videoCapabilities; } } } return VIDEO_CALLING_DISABLED; }
From source file:com.mobileglobe.android.customdialer.common.CallUtil.java
/** * Determines if video calling is available, and if so whether presence checking is available * as well./* w ww . java2 s . co m*/ * * Returns a bitmask with {@link #VIDEO_CALLING_ENABLED} to indicate that video calling is * available, and {@link #VIDEO_CALLING_PRESENCE} if presence indication is also available. * * @param context The context * @return A bit-mask describing the current video capabilities. */ @RequiresApi(api = Build.VERSION_CODES.M) public static int getVideoCallingAvailability(Context context) { if (!PermissionsUtil.hasPermission(context, android.Manifest.permission.READ_PHONE_STATE) || !CompatUtils.isVideoCompatible()) { return VIDEO_CALLING_DISABLED; } TelecomManager telecommMgr = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); if (telecommMgr == null) { return VIDEO_CALLING_DISABLED; } if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return 0; } List<PhoneAccountHandle> accountHandles = telecommMgr.getCallCapablePhoneAccounts(); for (PhoneAccountHandle accountHandle : accountHandles) { PhoneAccount account = telecommMgr.getPhoneAccount(accountHandle); if (account != null) { if (account.hasCapabilities(PhoneAccount.CAPABILITY_VIDEO_CALLING)) { // Builds prior to N do not have presence support. if (!CompatUtils.isVideoPresenceCompatible()) { return VIDEO_CALLING_ENABLED; } int videoCapabilities = VIDEO_CALLING_ENABLED; if (account .hasCapabilities(PhoneAccountSdkCompat.CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE)) { videoCapabilities |= VIDEO_CALLING_PRESENCE; } return videoCapabilities; } } } return VIDEO_CALLING_DISABLED; }
From source file:com.nick.scalpel.core.AutoFoundWirer.java
private void wireFromContext(Context context, AutoFound.Type type, int idRes, Resources.Theme theme, Field field, Object forWho) { Resources resources = context.getResources(); switch (type) { case STRING:/*from ww w.j a v a 2s. c o m*/ setField(field, forWho, resources.getString(idRes)); break; case COLOR: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, resources.getColor(idRes, theme)); } else { //noinspection deprecation setField(field, forWho, resources.getColor(idRes)); } break; case INTEGER: setField(field, forWho, resources.getInteger(idRes)); break; case BOOL: setField(field, forWho, resources.getBoolean(idRes)); break; case STRING_ARRAY: setField(field, forWho, resources.getStringArray(idRes)); break; case INT_ARRAY: setField(field, forWho, resources.getIntArray(idRes)); break; case PM: setField(field, forWho, context.getSystemService(Context.POWER_SERVICE)); break; case ACCOUNT: setField(field, forWho, context.getSystemService(Context.ACCOUNT_SERVICE)); break; case ALARM: setField(field, forWho, context.getSystemService(Context.ALARM_SERVICE)); break; case AM: setField(field, forWho, context.getSystemService(Context.ACTIVITY_SERVICE)); break; case WM: setField(field, forWho, context.getSystemService(Context.WINDOW_SERVICE)); break; case NM: setField(field, forWho, context.getSystemService(Context.NOTIFICATION_SERVICE)); break; case TM: setField(field, forWho, context.getSystemService(Context.TELEPHONY_SERVICE)); break; case TCM: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.TELECOM_SERVICE)); } break; case SP: setField(field, forWho, PreferenceManager.getDefaultSharedPreferences(context)); break; case PKM: setField(field, forWho, context.getPackageManager()); break; case HANDLE: setField(field, forWho, new Handler(Looper.getMainLooper())); break; case ASM: setField(field, forWho, context.getSystemService(Context.ACCESSIBILITY_SERVICE)); break; case CAP: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setField(field, forWho, context.getSystemService(Context.CAPTIONING_SERVICE)); } break; case KGD: setField(field, forWho, context.getSystemService(Context.KEYGUARD_SERVICE)); break; case LOCATION: setField(field, forWho, context.getSystemService(Context.LOCATION_SERVICE)); break; case SEARCH: setField(field, forWho, context.getSystemService(Context.SEARCH_SERVICE)); break; case SENSOR: setField(field, forWho, context.getSystemService(Context.SENSOR_SERVICE)); break; case STORAGE: setField(field, forWho, context.getSystemService(Context.STORAGE_SERVICE)); break; case WALLPAPER: setField(field, forWho, context.getSystemService(Context.WALLPAPER_SERVICE)); break; case VIBRATOR: setField(field, forWho, context.getSystemService(Context.VIBRATOR_SERVICE)); break; case CONNECT: setField(field, forWho, context.getSystemService(Context.CONNECTIVITY_SERVICE)); break; case NETWORK_STATUS: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, context.getSystemService(Context.NETWORK_STATS_SERVICE)); } break; case WIFI: setField(field, forWho, context.getSystemService(Context.WIFI_SERVICE)); break; case AUDIO: setField(field, forWho, context.getSystemService(Context.AUDIO_SERVICE)); break; case FP: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, context.getSystemService(Context.FINGERPRINT_SERVICE)); } break; case MEDIA_ROUTER: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { setField(field, forWho, context.getSystemService(Context.MEDIA_ROUTER_SERVICE)); } break; case SUB: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { setField(field, forWho, context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE)); } break; case IME: setField(field, forWho, context.getSystemService(Context.INPUT_METHOD_SERVICE)); break; case CLIP_BOARD: setField(field, forWho, context.getSystemService(Context.CLIPBOARD_SERVICE)); break; case APP_WIDGET: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.APPWIDGET_SERVICE)); } break; case DEVICE_POLICY: setField(field, forWho, context.getSystemService(Context.DEVICE_POLICY_SERVICE)); break; case DOWNLOAD: setField(field, forWho, context.getSystemService(Context.DOWNLOAD_SERVICE)); break; case BATTERY: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.BATTERY_SERVICE)); } break; case NFC: setField(field, forWho, context.getSystemService(Context.NFC_SERVICE)); break; case DISPLAY: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { setField(field, forWho, context.getSystemService(Context.DISPLAY_SERVICE)); } break; case USER: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { setField(field, forWho, context.getSystemService(Context.USER_SERVICE)); } break; case APP_OPS: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setField(field, forWho, context.getSystemService(Context.APP_OPS_SERVICE)); } break; case BITMAP: setField(field, forWho, BitmapFactory.decodeResource(resources, idRes, null)); break; } }
From source file:com.mobileglobe.android.simpledialer.common.CallUtil.java
/** * Determines if one of the call capable phone accounts defined supports calling with a subject * specified.//from ww w . ja v a 2s .com * * @param context The context. * @return {@code true} if one of the call capable phone accounts supports calling with a * subject specified, {@code false} otherwise. */ @RequiresApi(api = Build.VERSION_CODES.M) public static boolean isCallWithSubjectSupported(Context context) { if (!PermissionsUtil.hasPermission(context, Manifest.permission.READ_PHONE_STATE) || !CompatUtils.isCallSubjectCompatible()) { return false; } TelecomManager telecommMgr = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); if (telecommMgr == null) { return false; } if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return false; } List<PhoneAccountHandle> accountHandles = telecommMgr.getCallCapablePhoneAccounts(); for (PhoneAccountHandle accountHandle : accountHandles) { PhoneAccount account = telecommMgr.getPhoneAccount(accountHandle); if (account != null && account.hasCapabilities(PhoneAccount.CAPABILITY_CALL_SUBJECT)) { return true; } } return false; }