diff options
author | qqzhou <qqzhou@codeaurora.org> | 2014-10-28 14:17:13 +0800 |
---|---|---|
committer | Matt Garnes <matt@cyngn.com> | 2014-11-13 17:48:12 -0800 |
commit | 1d8c0c9ac7d347f4c0ab29a85fc7f957ed4ca73d (patch) | |
tree | 920a929f7f605fc73bf9ace50bcc827eb9ca907a /src | |
parent | f8595cb0c561457770d8a2f12728fb7fae31baa2 (diff) | |
download | android_packages_apps_Dialer-1d8c0c9ac7d347f4c0ab29a85fc7f957ed4ca73d.tar.gz android_packages_apps_Dialer-1d8c0c9ac7d347f4c0ab29a85fc7f957ed4ca73d.tar.bz2 android_packages_apps_Dialer-1d8c0c9ac7d347f4c0ab29a85fc7f957ed4ca73d.zip |
Dialer: support "add to black/white list" in call detail
- add the "add to black list" and "add to white list" into options
menu of call detail activity.
- remove the "IP call" options in call detail activity.
Change-Id: I2139d670213e94629c1fcabb1e53110609693859
CRs-Fixed: 746722
Diffstat (limited to 'src')
-rwxr-xr-x | src/com/android/dialer/CallDetailActivity.java | 115 |
1 files changed, 46 insertions, 69 deletions
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java index 4240d1215..eb4af634a 100755 --- a/src/com/android/dialer/CallDetailActivity.java +++ b/src/com/android/dialer/CallDetailActivity.java @@ -23,6 +23,9 @@ import android.content.ContentUris; import android.content.ContentValues; import android.content.Context; import android.content.Intent; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; import android.database.Cursor; import android.net.Uri; @@ -152,10 +155,13 @@ public class CallDetailActivity extends AnalyticsActivity implements ProximitySe private boolean mHasTrashOption; /** Whether we should show "remove from call log" in the options menu. */ private boolean mHasRemoveFromCallLogOption; - /** Whether we should show "Ip Call by SIM1" in the options menu. */ - private boolean mHasSub1IpCallOption; - /** Whether we should show "Ip Call by SIM2" in the options menu. */ - private boolean mHasSub2IpCallOption; + + /** Add for black/white list. */ + private boolean mHasInstallFireWallOption = false; + private static final String NUMBER_KEY = "number"; + private static final String MODE_KEY = "mode"; + private static final String FIREWALL_APK_NAME = "com.android.firewall"; + private static final String FIREWALL_BLACK_WHITE_LIST = "com.android.firewall.FirewallListPage"; private ProximitySensorManager mProximitySensorManager; private final ProximitySensorListener mProximitySensorListener = new ProximitySensorListener(); @@ -279,6 +285,20 @@ public class CallDetailActivity extends AnalyticsActivity implements ProximitySe public void onResume() { super.onResume(); updateData(getCallLogEntryUris()); + + mHasInstallFireWallOption = isFireWallInstalled(); + } + + private boolean isFireWallInstalled() { + boolean installed = false; + try { + ApplicationInfo info = getPackageManager().getApplicationInfo( + FIREWALL_APK_NAME, PackageManager.GET_PROVIDERS); + installed = (info != null); + } catch (NameNotFoundException e) { + } + Log.d(TAG, "Is Firewall installed ? " + installed); + return installed; } /** @@ -474,16 +494,6 @@ public class CallDetailActivity extends AnalyticsActivity implements ProximitySe canPlaceCallsTo && !isSipNumber && !isVoicemailNumber; mHasTrashOption = hasVoicemail(); mHasRemoveFromCallLogOption = !hasVoicemail(); - mHasSub1IpCallOption = canPlaceCallsTo - && !isSipNumber - && !isVoicemailNumber - && MoreContactUtils - .isMultiSimEnable(CallDetailActivity.this, PhoneConstants.SUB1); - mHasSub2IpCallOption = canPlaceCallsTo - && !isSipNumber - && !isVoicemailNumber - && MoreContactUtils - .isMultiSimEnable(CallDetailActivity.this, PhoneConstants.SUB2); invalidateOptionsMenu(); ListView historyList = (ListView) findViewById(R.id.history); @@ -741,19 +751,8 @@ public class CallDetailActivity extends AnalyticsActivity implements ProximitySe menu.findItem(R.id.menu_video_call).setVisible(CallUtil.isCSVTEnabled()); - menu.findItem(R.id.menu_ip_call_by_slot1).setVisible(mHasSub1IpCallOption); - menu.findItem(R.id.menu_ip_call_by_slot2).setVisible(mHasSub2IpCallOption); - - if (mHasSub1IpCallOption) { - String sub1Name = MoreContactUtils.getMultiSimAliasesName(this, PhoneConstants.SUB1); - menu.findItem(R.id.menu_ip_call_by_slot1).setTitle(getString( - com.android.contacts.common.R.string.ip_call_by_slot, sub1Name)); - } - if (mHasSub2IpCallOption) { - String sub2Name = MoreContactUtils.getMultiSimAliasesName(this, PhoneConstants.SUB2); - menu.findItem(R.id.menu_ip_call_by_slot2).setTitle(getString( - com.android.contacts.common.R.string.ip_call_by_slot, sub2Name)); - } + menu.findItem(R.id.menu_add_to_black_list).setVisible(mHasInstallFireWallOption); + menu.findItem(R.id.menu_add_to_white_list).setVisible(mHasInstallFireWallOption); return super.onPrepareOptionsMenu(menu); } @@ -766,50 +765,28 @@ public class CallDetailActivity extends AnalyticsActivity implements ProximitySe } } - public void onMenuIpCallBySlot1(MenuItem menuItem) { - String prefix = MoreContactUtils.getIPCallPrefix(this, PhoneConstants.SUB1); - if (!TextUtils.isEmpty(prefix)) { - long[] subId = SubscriptionManager.getSubId(PhoneConstants.SUB1); - if (subId != null && subId.length >= 1) { - ComponentName serviceName = - new ComponentName("com.android.phone", - "com.android.services.telephony.TelephonyConnectionService"); - PhoneAccountHandle account = new PhoneAccountHandle(serviceName, - String.valueOf(subId[0])); - Intent callIntent = new Intent(CallUtil.getCallIntent( - prefix + mNumber, account)); - startActivity(callIntent); - } else { - Intent callIntent = new Intent(CallUtil.getCallIntent( - prefix + mNumber)); - startActivity(callIntent); - } - } else { - MoreContactUtils.showNoIPNumberDialog(this, PhoneConstants.SUB1); - } + public void onMenuAddToBlackList(MenuItem menuItem) { + Bundle blackBundle = new Bundle(); + blackBundle.putString(NUMBER_KEY, mNumber); + blackBundle.putString(MODE_KEY, "blacklist"); + + Intent blackIntent = new Intent(); + blackIntent.setClassName(FIREWALL_APK_NAME, FIREWALL_BLACK_WHITE_LIST); + blackIntent.setAction(Intent.ACTION_INSERT); + blackIntent.putExtras(blackBundle); + startActivity(blackIntent); } - public void onMenuIpCallBySlot2(MenuItem menuItem) { - String prefix = MoreContactUtils.getIPCallPrefix(this, PhoneConstants.SUB2); - if (!TextUtils.isEmpty(prefix)) { - long[] subId = SubscriptionManager.getSubId(PhoneConstants.SUB2); - if (subId != null && subId.length >= 1) { - ComponentName serviceName = - new ComponentName("com.android.phone", - "com.android.services.telephony.TelephonyConnectionService"); - PhoneAccountHandle account = new PhoneAccountHandle(serviceName, - String.valueOf(subId[0])); - Intent callIntent = new Intent(CallUtil.getCallIntent( - prefix + mNumber, account)); - startActivity(callIntent); - } else { - Intent callIntent = new Intent(CallUtil.getCallIntent( - prefix + mNumber)); - startActivity(callIntent); - } - } else { - MoreContactUtils.showNoIPNumberDialog(this, PhoneConstants.SUB2); - } + public void onMenuAddToWhiteList(MenuItem menuItem) { + Bundle whiteBundle = new Bundle(); + whiteBundle.putString(NUMBER_KEY, mNumber); + whiteBundle.putString(MODE_KEY, "whitelist"); + + Intent whiteIntent = new Intent(); + whiteIntent.setClassName(FIREWALL_APK_NAME, FIREWALL_BLACK_WHITE_LIST); + whiteIntent.setAction(Intent.ACTION_INSERT); + whiteIntent.putExtras(whiteBundle); + startActivity(whiteIntent); } public void onMenuRemoveFromCallLog(MenuItem menuItem) { |