Java Examples for android.telecom.TelecomManager
The following java examples will help you to understand the usage of android.telecom.TelecomManager. These source code samples are taken from different open source projects.
Example 1
Project: platform_packages_providers_contactsprovider-master File: CallLogProvider.java View source code |
/** * Un-hides any hidden call log entries that are associated with the specified handle. * * @param handle The handle to the newly registered {@link android.telecom.PhoneAccount}. */ private void adjustForNewPhoneAccountInternal(PhoneAccountHandle handle) { String[] handleArgs = new String[] { handle.getComponentName().flattenToString(), handle.getId() }; // Check to see if any entries exist for this handle. If so (not empty), run the un-hiding // update. If not, then try to identify the call from the phone number. Cursor cursor = query(Calls.CONTENT_URI, MINIMAL_PROJECTION, Calls.PHONE_ACCOUNT_COMPONENT_NAME + " =? AND " + Calls.PHONE_ACCOUNT_ID + " =?", handleArgs, null); if (cursor != null) { try { if (cursor.getCount() >= 1) { // run un-hiding process based on phone account mDbHelper.getWritableDatabase().execSQL(UNHIDE_BY_PHONE_ACCOUNT_QUERY, handleArgs); } else { TelecomManager tm = TelecomManager.from(getContext()); if (tm != null) { PhoneAccount account = tm.getPhoneAccount(handle); if (account != null && account.getAddress() != null) { // We did not find any items for the specific phone account, so run the // query based on the phone number instead. mDbHelper.getWritableDatabase().execSQL(UNHIDE_BY_ADDRESS_QUERY, new String[] { account.getAddress().toString() }); } } } } finally { cursor.close(); } } }
Example 2
Project: robolectric-master File: ShadowContextImpl.java View source code |
@Implementation
public Object getSystemService(String name) {
if (name.equals(Context.LAYOUT_INFLATER_SERVICE)) {
return new RoboLayoutInflater(RuntimeEnvironment.application);
}
Object service = systemServices.get(name);
if (service == null) {
String serviceClassName = SYSTEM_SERVICE_MAP.get(name);
if (serviceClassName == null) {
System.err.println("WARNING: unknown service " + name);
return null;
}
try {
Class<?> clazz = Class.forName(serviceClassName);
if (serviceClassName.equals("android.app.admin.DevicePolicyManager")) {
if (getApiLevel() >= N) {
service = ReflectionHelpers.callConstructor(clazz, ClassParameter.from(Context.class, RuntimeEnvironment.application), ClassParameter.from(IDevicePolicyManager.class, null), ClassParameter.from(boolean.class, false));
} else {
service = ReflectionHelpers.callConstructor(clazz, ClassParameter.from(Context.class, RuntimeEnvironment.application), ClassParameter.from(Handler.class, null));
}
} else if (serviceClassName.equals("android.app.SearchManager") || serviceClassName.equals("android.app.ActivityManager") || serviceClassName.equals("android.app.WallpaperManager")) {
service = ReflectionHelpers.callConstructor(clazz, ClassParameter.from(Context.class, RuntimeEnvironment.application), ClassParameter.from(Handler.class, null));
} else if (serviceClassName.equals("android.os.storage.StorageManager")) {
service = ReflectionHelpers.callConstructor(clazz);
} else if (serviceClassName.equals("android.nfc.NfcManager") || serviceClassName.equals("android.telecom.TelecomManager")) {
service = ReflectionHelpers.callConstructor(clazz, ClassParameter.from(Context.class, RuntimeEnvironment.application));
} else if (serviceClassName.equals("android.hardware.display.DisplayManager") || serviceClassName.equals("android.telephony.SubscriptionManager")) {
service = ReflectionHelpers.callConstructor(clazz, ClassParameter.from(Context.class, RuntimeEnvironment.application));
} else if (serviceClassName.equals("android.view.accessibility.AccessibilityManager")) {
service = AccessibilityManager.getInstance(realObject);
} else if (getApiLevel() >= JELLY_BEAN_MR1 && serviceClassName.equals("android.view.WindowManagerImpl")) {
Class<?> windowMgrImplClass = Class.forName("android.view.WindowManagerImpl");
if (getApiLevel() >= N) {
service = ReflectionHelpers.callConstructor(windowMgrImplClass, ClassParameter.from(Context.class, realObject));
} else {
Display display = newInstanceOf(Display.class);
service = ReflectionHelpers.callConstructor(windowMgrImplClass, ClassParameter.from(Display.class, display));
}
} else if (serviceClassName.equals("android.accounts.AccountManager")) {
service = ReflectionHelpers.callConstructor(Class.forName("android.accounts.AccountManager"), ClassParameter.from(Context.class, RuntimeEnvironment.application), ClassParameter.from(IAccountManager.class, null));
} else if (serviceClassName.equals("android.net.wifi.p2p.WifiP2pManager")) {
service = new WifiP2pManager(ReflectionHelpers.createNullProxy(IWifiP2pManager.class));
} else if (getApiLevel() >= KITKAT && serviceClassName.equals("android.print.PrintManager")) {
service = ReflectionHelpers.callConstructor(Class.forName("android.print.PrintManager"), ClassParameter.from(Context.class, RuntimeEnvironment.application), ClassParameter.from(android.print.IPrintManager.class, null), ClassParameter.from(int.class, -1), ClassParameter.from(int.class, -1));
} else if (serviceClassName.equals("android.hardware.SystemSensorManager")) {
if (RuntimeEnvironment.getApiLevel() >= JELLY_BEAN_MR2) {
service = new SystemSensorManager(RuntimeEnvironment.application, Looper.getMainLooper());
} else {
service = ReflectionHelpers.callConstructor(Class.forName(serviceClassName), ClassParameter.from(Looper.class, Looper.getMainLooper()));
}
} else {
service = newInstanceOf(clazz);
}
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
systemServices.put(name, service);
}
return service;
}
Example 3
Project: android-platform-tools-base-master File: ServiceCastDetector.java View source code |
@NonNull
private static Map<String, String> getServiceMap() {
if (sServiceMap == null) {
final int EXPECTED_SIZE = 49;
sServiceMap = Maps.newHashMapWithExpectedSize(EXPECTED_SIZE);
sServiceMap.put("ACCESSIBILITY_SERVICE", "android.view.accessibility.AccessibilityManager");
sServiceMap.put("ACCOUNT_SERVICE", "android.accounts.AccountManager");
sServiceMap.put("ACTIVITY_SERVICE", "android.app.ActivityManager");
sServiceMap.put("ALARM_SERVICE", "android.app.AlarmManager");
sServiceMap.put("APPWIDGET_SERVICE", "android.appwidget.AppWidgetManager");
sServiceMap.put("APP_OPS_SERVICE", "android.app.AppOpsManager");
sServiceMap.put("AUDIO_SERVICE", "android.media.AudioManager");
sServiceMap.put("BATTERY_SERVICE", "android.os.BatteryManager");
sServiceMap.put("BLUETOOTH_SERVICE", "android.bluetooth.BluetoothManager");
sServiceMap.put("CAMERA_SERVICE", "android.hardware.camera2.CameraManager");
sServiceMap.put("CAPTIONING_SERVICE", "android.view.accessibility.CaptioningManager");
sServiceMap.put("CLIPBOARD_SERVICE", "android.text.ClipboardManager");
sServiceMap.put("CONNECTIVITY_SERVICE", "android.net.ConnectivityManager");
sServiceMap.put("CONSUMER_IR_SERVICE", "android.hardware.ConsumerIrManager");
sServiceMap.put("DEVICE_POLICY_SERVICE", "android.app.admin.DevicePolicyManager");
sServiceMap.put("DISPLAY_SERVICE", "android.hardware.display.DisplayManager");
sServiceMap.put("DOWNLOAD_SERVICE", "android.app.DownloadManager");
sServiceMap.put("DROPBOX_SERVICE", "android.os.DropBoxManager");
sServiceMap.put("INPUT_METHOD_SERVICE", "android.view.inputmethod.InputMethodManager");
sServiceMap.put("INPUT_SERVICE", "android.hardware.input.InputManager");
sServiceMap.put("JOB_SCHEDULER_SERVICE", "android.app.job.JobScheduler");
sServiceMap.put("KEYGUARD_SERVICE", "android.app.KeyguardManager");
sServiceMap.put("LAUNCHER_APPS_SERVICE", "android.content.pm.LauncherApps");
sServiceMap.put("LAYOUT_INFLATER_SERVICE", "android.view.LayoutInflater");
sServiceMap.put("LOCATION_SERVICE", "android.location.LocationManager");
sServiceMap.put("MEDIA_PROJECTION_SERVICE", "android.media.projection.MediaProjectionManager");
sServiceMap.put("MEDIA_ROUTER_SERVICE", "android.media.MediaRouter");
sServiceMap.put("MEDIA_SESSION_SERVICE", "android.media.session.MediaSessionManager");
sServiceMap.put("NFC_SERVICE", "android.nfc.NfcManager");
sServiceMap.put("NOTIFICATION_SERVICE", "android.app.NotificationManager");
sServiceMap.put("NSD_SERVICE", "android.net.nsd.NsdManager");
sServiceMap.put("POWER_SERVICE", "android.os.PowerManager");
sServiceMap.put("PRINT_SERVICE", "android.print.PrintManager");
sServiceMap.put("RESTRICTIONS_SERVICE", "android.content.RestrictionsManager");
sServiceMap.put("SEARCH_SERVICE", "android.app.SearchManager");
sServiceMap.put("SENSOR_SERVICE", "android.hardware.SensorManager");
sServiceMap.put("STORAGE_SERVICE", "android.os.storage.StorageManager");
sServiceMap.put("TELECOM_SERVICE", "android.telecom.TelecomManager");
sServiceMap.put("TELEPHONY_SERVICE", "android.telephony.TelephonyManager");
sServiceMap.put("TEXT_SERVICES_MANAGER_SERVICE", "android.view.textservice.TextServicesManager");
sServiceMap.put("TV_INPUT_SERVICE", "android.media.tv.TvInputManager");
sServiceMap.put("UI_MODE_SERVICE", "android.app.UiModeManager");
sServiceMap.put("USB_SERVICE", "android.hardware.usb.UsbManager");
sServiceMap.put("USER_SERVICE", "android.os.UserManager");
sServiceMap.put("VIBRATOR_SERVICE", "android.os.Vibrator");
sServiceMap.put("WALLPAPER_SERVICE", "com.android.server.WallpaperService");
sServiceMap.put("WIFI_P2P_SERVICE", "android.net.wifi.p2p.WifiP2pManager");
sServiceMap.put("WIFI_SERVICE", "android.net.wifi.WifiManager");
sServiceMap.put("WINDOW_SERVICE", "android.view.WindowManager");
assert sServiceMap.size() == EXPECTED_SIZE : sServiceMap.size();
}
return sServiceMap;
}
Example 4
Project: platform_frameworks_base-master File: PhoneWindowManager.java View source code |
// returns true if the key was handled and should not be passed to the user
private boolean interceptBackKeyUp(KeyEvent event) {
// Cache handled state
boolean handled = mBackKeyHandled;
if (hasPanicPressOnBackBehavior()) {
// Check for back key panic press
++mBackKeyPressCounter;
final long eventTime = event.getDownTime();
if (mBackKeyPressCounter <= PANIC_PRESS_BACK_COUNT) {
// This could be a multi-press. Wait a little bit longer to confirm.
Message msg = mHandler.obtainMessage(MSG_BACK_DELAYED_PRESS, mBackKeyPressCounter, 0, eventTime);
msg.setAsynchronous(true);
mHandler.sendMessageDelayed(msg, ViewConfiguration.getMultiPressTimeout());
}
}
// Reset back long press state
cancelPendingBackKeyAction();
if (mHasFeatureWatch) {
TelecomManager telecomManager = getTelecommService();
if (telecomManager != null) {
if (telecomManager.isRinging()) {
// Pressing back while there's a ringing incoming
// call should silence the ringer.
telecomManager.silenceRinger();
// It should not prevent navigating away
return false;
} else if ((mIncallBackBehavior & Settings.Secure.INCALL_BACK_BUTTON_BEHAVIOR_HANGUP) != 0 && telecomManager.isInCall()) {
// the Back button will hang up any current active call.
return telecomManager.endCall();
}
}
}
return handled;
}
Example 5
Project: android-sdk-sources-for-api-level-23-master File: PhoneWindowManager.java View source code |
private void interceptPowerKeyDown(KeyEvent event, boolean interactive) {
// Hold a wake lock until the power key is released.
if (!mPowerKeyWakeLock.isHeld()) {
mPowerKeyWakeLock.acquire();
}
// Cancel multi-press detection timeout.
if (mPowerKeyPressCounter != 0) {
mHandler.removeMessages(MSG_POWER_DELAYED_PRESS);
}
// Detect user pressing the power button in panic when an application has
// taken over the whole screen.
boolean panic = mImmersiveModeConfirmation.onPowerKeyDown(interactive, SystemClock.elapsedRealtime(), isImmersiveMode(mLastSystemUiFlags));
if (panic) {
mHandler.post(mHiddenNavPanic);
}
// Latch power key state to detect screenshot chord.
if (interactive && !mScreenshotChordPowerKeyTriggered && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) {
mScreenshotChordPowerKeyTriggered = true;
mScreenshotChordPowerKeyTime = event.getDownTime();
interceptScreenshotChord();
}
// Stop ringing or end call if configured to do so when power is pressed.
TelecomManager telecomManager = getTelecommService();
boolean hungUp = false;
if (telecomManager != null) {
if (telecomManager.isRinging()) {
// Pressing Power while there's a ringing incoming
// call should silence the ringer.
telecomManager.silenceRinger();
} else if ((mIncallPowerBehavior & Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP) != 0 && telecomManager.isInCall() && interactive) {
// Otherwise, if "Power button ends call" is enabled,
// the Power button will hang up any current active call.
hungUp = telecomManager.endCall();
}
}
// If the power key has still not yet been handled, then detect short
// press, long press, or multi press and decide what to do.
mPowerKeyHandled = hungUp || mScreenshotChordVolumeDownKeyTriggered || mScreenshotChordVolumeUpKeyTriggered;
if (!mPowerKeyHandled) {
if (interactive) {
// Wait for a long press or for the button to be released to decide what to do.
if (hasLongPressOnPowerBehavior()) {
Message msg = mHandler.obtainMessage(MSG_POWER_LONG_PRESS);
msg.setAsynchronous(true);
mHandler.sendMessageDelayed(msg, ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout());
}
} else {
wakeUpFromPowerKey(event.getDownTime());
if (mSupportLongPressPowerWhenNonInteractive && hasLongPressOnPowerBehavior()) {
Message msg = mHandler.obtainMessage(MSG_POWER_LONG_PRESS);
msg.setAsynchronous(true);
mHandler.sendMessageDelayed(msg, ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout());
mBeganFromNonInteractive = true;
} else {
final int maxCount = getMaxMultiPressPowerCount();
if (maxCount <= 1) {
mPowerKeyHandled = true;
} else {
mBeganFromNonInteractive = true;
}
}
}
}
}
Example 6
Project: packages_apps_settings-master File: SimSettings.java View source code |
private void updateCallValues() { final Preference simPref = findPreference(KEY_CALLS); final TelecomManager telecomManager = TelecomManager.from(mContext); final PhoneAccountHandle phoneAccountHandle = telecomManager.getUserSelectedOutgoingPhoneAccount(); final List<PhoneAccountHandle> allPhoneAccounts = telecomManager.getCallCapablePhoneAccounts(); simPref.setTitle(R.string.calls_title); PhoneAccount phoneAccount = null; if (phoneAccountHandle != null) { phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle); } simPref.setSummary(phoneAccount == null ? mContext.getResources().getString(R.string.sim_calls_ask_first_prefs_title) : (String) phoneAccount.getLabel()); simPref.setEnabled(allPhoneAccounts.size() > 1); }
Example 7
Project: platform_packages_apps_settings-master File: SimDialogActivity.java View source code |
private PhoneAccountHandle subscriptionIdToPhoneAccountHandle(final int subId) { final TelecomManager telecomManager = TelecomManager.from(this); final TelephonyManager telephonyManager = TelephonyManager.from(this); final Iterator<PhoneAccountHandle> phoneAccounts = telecomManager.getCallCapablePhoneAccounts().listIterator(); while (phoneAccounts.hasNext()) { final PhoneAccountHandle phoneAccountHandle = phoneAccounts.next(); final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle); if (subId == telephonyManager.getSubIdForPhoneAccount(phoneAccount)) { return phoneAccountHandle; } } return null; }
Example 8
Project: android_packages_apps_Bluetooth-master File: HeadsetStateMachine.java View source code |
private void processIntentUpdateCallType(Intent intent) {
if (DBG)
Log.d(TAG, "Enter processIntentUpdateCallType()");
mIsCsCall = intent.getBooleanExtra(TelecomManager.EXTRA_CALL_TYPE_CS, true);
if (DBG)
Log.d(TAG, "processIntentUpdateCallType " + mIsCsCall);
mPhoneState.setIsCsCall(mIsCsCall);
if (mActiveScoDevice != null) {
if (!mPhoneState.getIsCsCall()) {
log("processIntentUpdateCallType, Non CS call, check for network type");
sendVoipConnectivityNetworktype(true);
} else {
log("processIntentUpdateCallType, CS call, do not check for network type");
}
} else {
log("processIntentUpdateCallType: Sco not yet connected");
}
if (DBG)
Log.d(TAG, "Exit processIntentUpdateCallType()");
}
Example 9
Project: XieDaDeng-master File: PhoneStatusBarPolicy.java View source code |
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED)) {
updateAlarm();
} else if (action.equals(Intent.ACTION_SYNC_STATE_CHANGED)) {
updateSyncState(intent);
} else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED) || action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
updateBluetooth();
} else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION) || action.equals(AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION)) {
updateVolumeZen();
} else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
updateSimState(intent);
} else if (action.equals(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED)) {
updateTTY(intent);
} else if (action.equals(Intent.ACTION_USER_SWITCHED)) {
updateAlarm();
} else /* SPRD: fixbug421569 ADD headset icon in statusbar {@*/
if (action.equals(Intent.ACTION_HEADSET_PLUG)) {
updateHeadSet(intent);
} else /* SPRD: Add for VOLTE {@*/
if (action.equals(TelephonyIntents.ACTION_IMS_REGISTRATION)) {
updateImsRegistration(intent);
}
Log.i(TAG, "mIntentReceiver->onReceive action = " + action);
/* @} */
}
Example 10
Project: Brevent-master File: BreventActivity.java View source code |
private void resolveImportantPackages(SimpleArrayMap<String, SparseIntArray> processes, SimpleArrayMap<String, Integer> packageNames) {
// input method
String input = getPackageName(getSecureSetting(Settings.Secure.DEFAULT_INPUT_METHOD));
if (input != null) {
packageNames.put(input, IMPORTANT_INPUT);
}
// next alarm
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
AlarmManager.AlarmClockInfo alarmClock = alarmManager.getNextAlarmClock();
if (alarmClock != null && alarmClock.getShowIntent() != null) {
String alarmClockPackage = alarmClock.getShowIntent().getCreatorPackage();
packageNames.put(alarmClockPackage, IMPORTANT_ALARM);
}
// sms
packageNames.put(getSecureSetting(HideApiOverride.SMS_DEFAULT_APPLICATION), IMPORTANT_SMS);
// dialer
String dialer = getDefaultApp(Intent.ACTION_DIAL);
if (dialer != null) {
packageNames.put(dialer, IMPORTANT_DIALER);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// dialer
dialer = ((TelecomManager) getSystemService(TELECOM_SERVICE)).getDefaultDialerPackage();
if (dialer != null) {
packageNames.put(dialer, IMPORTANT_DIALER);
}
}
// assistant
String assistant;
assistant = getPackageName(getSecureSetting(HideApiOverride.getVoiceInteractionService()));
if (assistant != null) {
packageNames.put(assistant, IMPORTANT_ASSISTANT);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
assistant = getPackageName(getSecureSetting(HideApiOverride.getAssistant()));
if (assistant != null) {
packageNames.put(assistant, IMPORTANT_ASSISTANT);
}
}
// webview
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
String webView = Settings.Global.getString(getContentResolver(), HideApiOverrideN.WEBVIEW_PROVIDER);
packageNames.put(webView, IMPORTANT_WEBVIEW);
}
// launcher
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
ResolveInfo resolveInfo = getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (resolveInfo != null) {
mLauncher = resolveInfo.activityInfo.packageName;
packageNames.put(mLauncher, IMPORTANT_HOME);
}
AccessibilityManager accessibilityManager = (AccessibilityManager) getSystemService(Context.ACCESSIBILITY_SERVICE);
List<AccessibilityServiceInfo> enabledAccessibilityServiceList = accessibilityManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
for (AccessibilityServiceInfo accessibilityServiceInfo : enabledAccessibilityServiceList) {
packageNames.put(accessibilityServiceInfo.getResolveInfo().serviceInfo.packageName, IMPORTANT_ACCESSIBILITY);
}
DevicePolicyManager devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
List<ComponentName> componentNames = devicePolicyManager.getActiveAdmins();
if (componentNames != null) {
for (ComponentName componentName : componentNames) {
packageNames.put(componentName.getPackageName(), IMPORTANT_DEVICE_ADMIN);
}
}
// persistent
int size = processes.size();
for (int i = 0; i < size; ++i) {
if (BreventStatus.isPersistent(processes.valueAt(i))) {
packageNames.put(processes.keyAt(i), IMPORTANT_PERSISTENT);
}
}
if (Log.isLoggable(UILog.TAG, Log.DEBUG)) {
UILog.d("important: " + packageNames);
}
}
Example 11
Project: frameworks_opt-master File: ImsPhoneCallTracker.java View source code |
private void dialInternal(ImsPhoneConnection conn, int clirMode, int videoState, Bundle intentExtras) { if (conn == null) { return; } boolean isConferenceUri = false; boolean isSkipSchemaParsing = false; boolean isCallPull = false; if (intentExtras != null) { isConferenceUri = intentExtras.getBoolean(TelephonyProperties.EXTRA_DIAL_CONFERENCE_URI, false); isSkipSchemaParsing = intentExtras.getBoolean(TelephonyProperties.EXTRA_SKIP_SCHEMA_PARSING, false); } if (!isConferenceUri && !isSkipSchemaParsing && (conn.getAddress() == null || conn.getAddress().length() == 0 || conn.getAddress().indexOf(PhoneNumberUtils.WILD) >= 0)) { // Phone number is invalid conn.setDisconnectCause(DisconnectCause.INVALID_NUMBER); sendEmptyMessageDelayed(EVENT_HANGUP_PENDINGMO, TIMEOUT_HANGUP_PENDINGMO); return; } // Always unmute when initiating a new call setMute(false); int serviceType = PhoneNumberUtils.isEmergencyNumber(conn.getAddress()) ? ImsCallProfile.SERVICE_TYPE_EMERGENCY : ImsCallProfile.SERVICE_TYPE_NORMAL; int callType = ImsCallProfile.getCallTypeFromVideoState(videoState); //TODO(vt): Is this sufficient? At what point do we know the video state of the call? conn.setVideoState(videoState); try { String[] callees = new String[] { conn.getAddress() }; ImsCallProfile profile = mImsManager.createCallProfile(mServiceId, serviceType, callType); profile.setCallExtraInt(ImsCallProfile.EXTRA_OIR, clirMode); profile.setCallExtraBoolean(TelephonyProperties.EXTRAS_IS_CONFERENCE_URI, isConferenceUri); // ImsCallProfile key. if (intentExtras != null) { if (intentExtras.containsKey(android.telecom.TelecomManager.EXTRA_CALL_SUBJECT)) { intentExtras.putString(ImsCallProfile.EXTRA_DISPLAY_TEXT, cleanseInstantLetteringMessage(intentExtras.getString(android.telecom.TelecomManager.EXTRA_CALL_SUBJECT))); } isCallPull = intentExtras.getBoolean(TelephonyProperties.EXTRA_IS_CALL_PULL, false); if (intentExtras.containsKey(ImsCallProfile.EXTRA_IS_CALL_PULL)) { profile.mCallExtras.putBoolean(ImsCallProfile.EXTRA_IS_CALL_PULL, intentExtras.getBoolean(ImsCallProfile.EXTRA_IS_CALL_PULL)); int dialogId = intentExtras.getInt(ImsExternalCallTracker.EXTRA_IMS_EXTERNAL_CALL_ID); conn.setIsPulledCall(true); conn.setPulledDialogId(dialogId); } // Pack the OEM-specific call extras. profile.mCallExtras.putBundle(ImsCallProfile.EXTRA_OEM_EXTRAS, intentExtras); profile.setCallExtraBoolean(ImsCallProfile.EXTRA_IS_CALL_PULL, isCallPull); // NOTE: Extras to be sent over the network are packed into the // intentExtras individually, with uniquely defined keys. // These key-value pairs are processed by IMS Service before // being sent to the lower layers/to the network. } ImsCall imsCall = mImsManager.makeCall(mServiceId, profile, callees, mImsCallListener); conn.setImsCall(imsCall); mMetrics.writeOnImsCallStart(mPhone.getPhoneId(), imsCall.getSession()); setVideoCallProvider(conn, imsCall); conn.setAllowAddCallDuringVideoCall(mAllowAddCallDuringVideoCall); } catch (ImsException e) { loge("dialInternal : " + e); conn.setDisconnectCause(DisconnectCause.ERROR_UNSPECIFIED); sendEmptyMessageDelayed(EVENT_HANGUP_PENDINGMO, TIMEOUT_HANGUP_PENDINGMO); } catch (RemoteException e) { } }
Example 12
Project: packages-apps-Contacts-master File: QuickContactActivity.java View source code |
@Override
public void onClick(View v) {
final Object entryTagObject = v.getTag();
if (entryTagObject == null || !(entryTagObject instanceof EntryTag)) {
Log.w(TAG, "EntryTag was not used correctly");
return;
}
final EntryTag entryTag = (EntryTag) entryTagObject;
final Intent intent = entryTag.getIntent();
final int dataId = entryTag.getId();
if (dataId == CARD_ENTRY_ID_EDIT_CONTACT) {
editContact();
return;
}
// Pass the touch point through the intent for use in the InCallUI
if (Intent.ACTION_CALL.equals(intent.getAction())) {
if (TouchPointManager.getInstance().hasValidPoint()) {
Bundle extras = new Bundle();
extras.putParcelable(TouchPointManager.TOUCH_POINT, TouchPointManager.getInstance().getPoint());
intent.putExtra(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, extras);
}
}
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mHasIntentLaunched = true;
try {
ImplicitIntentsUtil.startActivityInAppIfPossible(QuickContactActivity.this, intent);
} catch (SecurityException ex) {
Toast.makeText(QuickContactActivity.this, R.string.missing_app, Toast.LENGTH_SHORT).show();
Log.e(TAG, "QuickContacts does not have permission to launch " + intent);
} catch (ActivityNotFoundException ex) {
Toast.makeText(QuickContactActivity.this, R.string.missing_app, Toast.LENGTH_SHORT).show();
}
// Default to USAGE_TYPE_CALL. Usage is summed among all types for sorting each data id
// so the exact usage type is not necessary in all cases
String usageType = DataUsageFeedback.USAGE_TYPE_CALL;
final Uri intentUri = intent.getData();
if ((intentUri != null && intentUri.getScheme() != null && intentUri.getScheme().equals(ContactsUtils.SCHEME_SMSTO)) || (intent.getType() != null && intent.getType().equals(MIMETYPE_SMS))) {
usageType = DataUsageFeedback.USAGE_TYPE_SHORT_TEXT;
}
// Data IDs start at 1 so anything less is invalid
if (dataId > 0) {
final Uri dataUsageUri = DataUsageFeedback.FEEDBACK_URI.buildUpon().appendPath(String.valueOf(dataId)).appendQueryParameter(DataUsageFeedback.USAGE_TYPE, usageType).build();
try {
final boolean successful = getContentResolver().update(dataUsageUri, new ContentValues(), null, null) > 0;
if (!successful) {
Log.w(TAG, "DataUsageFeedback increment failed");
}
} catch (SecurityException ex) {
Log.w(TAG, "DataUsageFeedback increment failed", ex);
}
} else {
Log.w(TAG, "Invalid Data ID");
}
}
Example 13
Project: android_frameworks_base-master File: PhoneWindowManager.java View source code |
private void interceptPowerKeyDown(KeyEvent event, boolean interactive) {
// Hold a wake lock until the power key is released.
if (!mPowerKeyWakeLock.isHeld()) {
mPowerKeyWakeLock.acquire();
}
// Cancel multi-press detection timeout.
if (mPowerKeyPressCounter != 0) {
mHandler.removeMessages(MSG_POWER_DELAYED_PRESS);
}
// Detect user pressing the power button in panic when an application has
// taken over the whole screen.
boolean panic = mImmersiveModeConfirmation.onPowerKeyDown(interactive, SystemClock.elapsedRealtime(), isImmersiveMode(mLastSystemUiFlags), isNavBarEmpty(mLastSystemUiFlags));
if (panic) {
mHandler.post(mHiddenNavPanic);
}
// Latch power key state to detect screenshot chord.
if (interactive && !mScreenshotChordPowerKeyTriggered && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) {
mScreenshotChordPowerKeyTriggered = true;
mScreenshotChordPowerKeyTime = event.getDownTime();
interceptScreenshotChord();
}
// Stop ringing or end call if configured to do so when power is pressed.
TelecomManager telecomManager = getTelecommService();
boolean hungUp = false;
if (telecomManager != null) {
if (telecomManager.isRinging()) {
// Pressing Power while there's a ringing incoming
// call should silence the ringer.
telecomManager.silenceRinger();
} else if ((mIncallPowerBehavior & Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP) != 0 && telecomManager.isInCall() && interactive) {
// Otherwise, if "Power button ends call" is enabled,
// the Power button will hang up any current active call.
hungUp = telecomManager.endCall();
}
}
GestureLauncherService gestureService = LocalServices.getService(GestureLauncherService.class);
boolean gesturedServiceIntercepted = false;
if (gestureService != null) {
gesturedServiceIntercepted = gestureService.interceptPowerKeyDown(event, interactive, mTmpBoolean);
if (mTmpBoolean.value && mGoingToSleep) {
mCameraGestureTriggeredDuringGoingToSleep = true;
}
}
// If the power key has still not yet been handled, then detect short
// press, long press, or multi press and decide what to do.
mPowerKeyHandled = hungUp || mScreenshotChordVolumeDownKeyTriggered || mScreenshotChordVolumeUpKeyTriggered || gesturedServiceIntercepted;
if (!mPowerKeyHandled) {
if (interactive) {
// Wait for a long press or for the button to be released to decide what to do.
if (hasLongPressOnPowerBehavior()) {
Message msg = mHandler.obtainMessage(MSG_POWER_LONG_PRESS);
msg.setAsynchronous(true);
mHandler.sendMessageDelayed(msg, ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout());
}
} else {
wakeUpFromPowerKey(event.getDownTime());
if (mSupportLongPressPowerWhenNonInteractive && hasLongPressOnPowerBehavior()) {
Message msg = mHandler.obtainMessage(MSG_POWER_LONG_PRESS);
msg.setAsynchronous(true);
mHandler.sendMessageDelayed(msg, ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout());
mBeganFromNonInteractive = true;
} else {
final int maxCount = getMaxMultiPressPowerCount();
if (maxCount <= 1) {
mPowerKeyHandled = true;
} else {
mBeganFromNonInteractive = true;
}
}
}
}
}
Example 14
Project: kotlin-master File: ServiceCastDetector.java View source code |
@NonNull
private static Map<String, String> getServiceMap() {
if (sServiceMap == null) {
final int EXPECTED_SIZE = 55;
sServiceMap = Maps.newHashMapWithExpectedSize(EXPECTED_SIZE);
sServiceMap.put("ACCESSIBILITY_SERVICE", "android.view.accessibility.AccessibilityManager");
sServiceMap.put("ACCOUNT_SERVICE", "android.accounts.AccountManager");
sServiceMap.put("ACTIVITY_SERVICE", "android.app.ActivityManager");
sServiceMap.put("ALARM_SERVICE", "android.app.AlarmManager");
sServiceMap.put("APPWIDGET_SERVICE", "android.appwidget.AppWidgetManager");
sServiceMap.put("APP_OPS_SERVICE", "android.app.AppOpsManager");
sServiceMap.put("AUDIO_SERVICE", "android.media.AudioManager");
sServiceMap.put("BATTERY_SERVICE", "android.os.BatteryManager");
sServiceMap.put("BLUETOOTH_SERVICE", "android.bluetooth.BluetoothManager");
sServiceMap.put("CAMERA_SERVICE", "android.hardware.camera2.CameraManager");
sServiceMap.put("CAPTIONING_SERVICE", "android.view.accessibility.CaptioningManager");
sServiceMap.put("CARRIER_CONFIG_SERVICE", "android.telephony.CarrierConfigManager");
// also allow @Deprecated android.content.ClipboardManager
sServiceMap.put("CLIPBOARD_SERVICE", "android.text.ClipboardManager");
sServiceMap.put("CONNECTIVITY_SERVICE", "android.net.ConnectivityManager");
sServiceMap.put("CONSUMER_IR_SERVICE", "android.hardware.ConsumerIrManager");
sServiceMap.put("DEVICE_POLICY_SERVICE", "android.app.admin.DevicePolicyManager");
sServiceMap.put("DISPLAY_SERVICE", "android.hardware.display.DisplayManager");
sServiceMap.put("DOWNLOAD_SERVICE", "android.app.DownloadManager");
sServiceMap.put("DROPBOX_SERVICE", "android.os.DropBoxManager");
sServiceMap.put("FINGERPRINT_SERVICE", "android.hardware.fingerprint.FingerprintManager");
sServiceMap.put("INPUT_METHOD_SERVICE", "android.view.inputmethod.InputMethodManager");
sServiceMap.put("INPUT_SERVICE", "android.hardware.input.InputManager");
sServiceMap.put("JOB_SCHEDULER_SERVICE", "android.app.job.JobScheduler");
sServiceMap.put("KEYGUARD_SERVICE", "android.app.KeyguardManager");
sServiceMap.put("LAUNCHER_APPS_SERVICE", "android.content.pm.LauncherApps");
sServiceMap.put("LAYOUT_INFLATER_SERVICE", "android.view.LayoutInflater");
sServiceMap.put("LOCATION_SERVICE", "android.location.LocationManager");
sServiceMap.put("MEDIA_PROJECTION_SERVICE", "android.media.projection.MediaProjectionManager");
sServiceMap.put("MEDIA_ROUTER_SERVICE", "android.media.MediaRouter");
sServiceMap.put("MEDIA_SESSION_SERVICE", "android.media.session.MediaSessionManager");
sServiceMap.put("MIDI_SERVICE", "android.media.midi.MidiManager");
sServiceMap.put("NETWORK_STATS_SERVICE", "android.app.usage.NetworkStatsManager");
sServiceMap.put("NFC_SERVICE", "android.nfc.NfcManager");
sServiceMap.put("NOTIFICATION_SERVICE", "android.app.NotificationManager");
sServiceMap.put("NSD_SERVICE", "android.net.nsd.NsdManager");
sServiceMap.put("POWER_SERVICE", "android.os.PowerManager");
sServiceMap.put("PRINT_SERVICE", "android.print.PrintManager");
sServiceMap.put("RESTRICTIONS_SERVICE", "android.content.RestrictionsManager");
sServiceMap.put("SEARCH_SERVICE", "android.app.SearchManager");
sServiceMap.put("SENSOR_SERVICE", "android.hardware.SensorManager");
sServiceMap.put("STORAGE_SERVICE", "android.os.storage.StorageManager");
sServiceMap.put("TELECOM_SERVICE", "android.telecom.TelecomManager");
sServiceMap.put("TELEPHONY_SERVICE", "android.telephony.TelephonyManager");
sServiceMap.put("TELEPHONY_SUBSCRIPTION_SERVICE", "android.telephony.SubscriptionManager");
sServiceMap.put("TEXT_SERVICES_MANAGER_SERVICE", "android.view.textservice.TextServicesManager");
sServiceMap.put("TV_INPUT_SERVICE", "android.media.tv.TvInputManager");
sServiceMap.put("UI_MODE_SERVICE", "android.app.UiModeManager");
sServiceMap.put("USAGE_STATS_SERVICE", "android.app.usage.UsageStatsManager");
sServiceMap.put("USB_SERVICE", "android.hardware.usb.UsbManager");
sServiceMap.put("USER_SERVICE", "android.os.UserManager");
sServiceMap.put("VIBRATOR_SERVICE", "android.os.Vibrator");
sServiceMap.put("WALLPAPER_SERVICE", "android.service.wallpaper.WallpaperService");
sServiceMap.put("WIFI_P2P_SERVICE", "android.net.wifi.p2p.WifiP2pManager");
sServiceMap.put("WIFI_SERVICE", "android.net.wifi.WifiManager");
sServiceMap.put("WINDOW_SERVICE", "android.view.WindowManager");
assert sServiceMap.size() == EXPECTED_SIZE : sServiceMap.size();
}
return sServiceMap;
}
Example 15
Project: platform_packages_apps_contacts-master File: QuickContactActivity.java View source code |
@Override
public void onClick(View v) {
final Object entryTagObject = v.getTag();
if (entryTagObject == null || !(entryTagObject instanceof EntryTag)) {
Log.w(TAG, "EntryTag was not used correctly");
return;
}
final EntryTag entryTag = (EntryTag) entryTagObject;
final Intent intent = entryTag.getIntent();
final int dataId = entryTag.getId();
if (dataId == CARD_ENTRY_ID_EDIT_CONTACT) {
editContact();
return;
}
// Pass the touch point through the intent for use in the InCallUI
if (Intent.ACTION_CALL.equals(intent.getAction())) {
if (TouchPointManager.getInstance().hasValidPoint()) {
Bundle extras = new Bundle();
extras.putParcelable(TouchPointManager.TOUCH_POINT, TouchPointManager.getInstance().getPoint());
intent.putExtra(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, extras);
}
}
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mHasIntentLaunched = true;
try {
ImplicitIntentsUtil.startActivityInAppIfPossible(QuickContactActivity.this, intent);
} catch (SecurityException ex) {
Toast.makeText(QuickContactActivity.this, R.string.missing_app, Toast.LENGTH_SHORT).show();
Log.e(TAG, "QuickContacts does not have permission to launch " + intent);
} catch (ActivityNotFoundException ex) {
Toast.makeText(QuickContactActivity.this, R.string.missing_app, Toast.LENGTH_SHORT).show();
}
// Default to USAGE_TYPE_CALL. Usage is summed among all types for sorting each data id
// so the exact usage type is not necessary in all cases
String usageType = DataUsageFeedback.USAGE_TYPE_CALL;
final Uri intentUri = intent.getData();
if ((intentUri != null && intentUri.getScheme() != null && intentUri.getScheme().equals(ContactsUtils.SCHEME_SMSTO)) || (intent.getType() != null && intent.getType().equals(MIMETYPE_SMS))) {
usageType = DataUsageFeedback.USAGE_TYPE_SHORT_TEXT;
}
// Data IDs start at 1 so anything less is invalid
if (dataId > 0) {
final Uri dataUsageUri = DataUsageFeedback.FEEDBACK_URI.buildUpon().appendPath(String.valueOf(dataId)).appendQueryParameter(DataUsageFeedback.USAGE_TYPE, usageType).build();
try {
final boolean successful = getContentResolver().update(dataUsageUri, new ContentValues(), null, null) > 0;
if (!successful) {
Log.w(TAG, "DataUsageFeedback increment failed");
}
} catch (SecurityException ex) {
Log.w(TAG, "DataUsageFeedback increment failed", ex);
}
} else {
Log.w(TAG, "Invalid Data ID");
}
}
Example 16
Project: AndroidBaseUtils-master File: ServiceUtil.java View source code |
@TargetApi(21) public static TelecomManager getTelecomManager() { return (TelecomManager) getSystemService(Context.TELECOM_SERVICE); }