summaryrefslogtreecommitdiffstats
path: root/sip
diff options
context:
space:
mode:
authorSantos Cordon <santoscordon@google.com>2015-04-27 15:17:49 -0700
committerSantos Cordon <santoscordon@google.com>2015-04-30 14:54:00 -0700
commit6781b0c2375a905614781f8503bfd601f4020340 (patch)
treedb18d39b48059df67fedf5f1e3233c973162a191 /sip
parent699e37e52da113bd53cca5627c811a2a27f96759 (diff)
downloadandroid_packages_services_Telephony-6781b0c2375a905614781f8503bfd601f4020340.tar.gz
android_packages_services_Telephony-6781b0c2375a905614781f8503bfd601f4020340.tar.bz2
android_packages_services_Telephony-6781b0c2375a905614781f8503bfd601f4020340.zip
Adding settings for connection services.
1) List all connection services in phone account settings. 2) Add icon to the settings listings 3) Adds code for SIP phone accounts to handle the standard telecom CONFIGURE_CONNECTION_SERVICE intent. This means that when a user clicks on the listed SIP account, they will be taken to thats SIP profile's settings. 4) Added code to SipProfileDb to retrieve a single profile by Uri. 5) Updated SipSettings to refresh list onResume(). This allows deletes and updates made from the phone account list to reflect the legacy Sip Profile Setting activity. Bug: 20303449 Change-Id: If8dd98d17422c2f34a1ff1d3abd4c8e9fd81b496
Diffstat (limited to 'sip')
-rw-r--r--sip/src/com/android/services/telephony/sip/SipPhoneAccountSettingsActivity.java62
-rw-r--r--sip/src/com/android/services/telephony/sip/SipProfileDb.java42
-rw-r--r--sip/src/com/android/services/telephony/sip/SipSettings.java16
3 files changed, 100 insertions, 20 deletions
diff --git a/sip/src/com/android/services/telephony/sip/SipPhoneAccountSettingsActivity.java b/sip/src/com/android/services/telephony/sip/SipPhoneAccountSettingsActivity.java
new file mode 100644
index 000000000..04553469e
--- /dev/null
+++ b/sip/src/com/android/services/telephony/sip/SipPhoneAccountSettingsActivity.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.services.telephony.sip;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.net.sip.SipProfile;
+import android.os.Bundle;
+import android.os.Parcelable;
+import android.telecom.PhoneAccountHandle;
+import android.telecom.TelecomManager;
+import android.util.Log;
+
+/**
+ * This activity receives the standard telecom intent to open settings for a PhoneAccount. It
+ * translates the incoming phone account to a SIP profile and opens the corresponding
+ * PreferenceActivity for said profile.
+ */
+public final class SipPhoneAccountSettingsActivity extends Activity {
+ private static final String TAG = "SipSettingsActivity";
+
+ /** ${inheritDoc} */
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ Intent intent = getIntent();
+ Log.i(TAG, "" + intent);
+ if (intent != null) {
+ PhoneAccountHandle accountHandle = (PhoneAccountHandle)
+ intent.getParcelableExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE);
+ Log.i(TAG, "" + accountHandle);
+
+ if (accountHandle != null) {
+ SipProfileDb profileDb = new SipProfileDb(this);
+ String sipUri = SipUtil.getSipUriFromPhoneAccount(accountHandle);
+ SipProfile profile = profileDb.retrieveSipProfile(sipUri);
+ if (profile != null) {
+ Intent settingsIntent = new Intent(this, SipEditor.class);
+ settingsIntent.putExtra(SipSettings.KEY_SIP_PROFILE, (Parcelable) profile);
+ startActivity(settingsIntent);
+ }
+ }
+ }
+
+ finish();
+ }
+}
diff --git a/sip/src/com/android/services/telephony/sip/SipProfileDb.java b/sip/src/com/android/services/telephony/sip/SipProfileDb.java
index 00e214fa4..5641af9d1 100644
--- a/sip/src/com/android/services/telephony/sip/SipProfileDb.java
+++ b/sip/src/com/android/services/telephony/sip/SipProfileDb.java
@@ -20,6 +20,7 @@ import com.android.internal.os.AtomicFile;
import android.content.Context;
import android.net.sip.SipProfile;
+import android.text.TextUtils;
import android.util.Log;
import java.io.File;
@@ -42,6 +43,8 @@ class SipProfileDb {
private static final String PROFILES_DIR = "/profiles/";
private static final String PROFILE_OBJ_FILE = ".pobj";
+ private static final String SCHEME_PREFIX = "sip:";
+
private String mProfilesDirectory;
private SipSharedPreferences mSipSharedPreferences;
private int mProfilesCount = -1;
@@ -100,6 +103,15 @@ class SipProfileDb {
}
}
+ public SipProfile retrieveSipProfile(String sipUri) {
+ sipUri = sipUri.trim();
+ if (sipUri.startsWith(SCHEME_PREFIX)) {
+ return retrieveSipProfileFromName(sipUri.substring(SCHEME_PREFIX.length()));
+ }
+
+ return null;
+ }
+
private List<SipProfile> retrieveSipProfileListInternal() {
List<SipProfile> sipProfileList = Collections.synchronizedList(
new ArrayList<SipProfile>());
@@ -108,21 +120,33 @@ class SipProfileDb {
String[] dirs = root.list();
if (dirs == null) return sipProfileList;
for (String dir : dirs) {
- File f = new File(new File(root, dir), PROFILE_OBJ_FILE);
- if (!f.exists()) continue;
+ SipProfile p = retrieveSipProfileFromName(dir);
+ if (p == null) continue;
+ sipProfileList.add(p);
+ }
+ mProfilesCount = sipProfileList.size();
+ mSipSharedPreferences.setProfilesCount(mProfilesCount);
+ return sipProfileList;
+ }
+
+ private SipProfile retrieveSipProfileFromName(String name) {
+ if (TextUtils.isEmpty(name)) {
+ return null;
+ }
+
+ File root = new File(mProfilesDirectory);
+ File f = new File(new File(root, name), PROFILE_OBJ_FILE);
+ if (f.exists()) {
try {
SipProfile p = deserialize(f);
- if (p == null) continue;
- if (!dir.equals(p.getProfileName())) continue;
-
- sipProfileList.add(p);
+ if (p != null && name.equals(p.getProfileName())) {
+ return p;
+ }
} catch (IOException e) {
log("retrieveSipProfileListInternal, exception: " + e);
}
}
- mProfilesCount = sipProfileList.size();
- mSipSharedPreferences.setProfilesCount(mProfilesCount);
- return sipProfileList;
+ return null;
}
private SipProfile deserialize(File profileObjectFile) throws IOException {
diff --git a/sip/src/com/android/services/telephony/sip/SipSettings.java b/sip/src/com/android/services/telephony/sip/SipSettings.java
index 7da013188..b89a5b142 100644
--- a/sip/src/com/android/services/telephony/sip/SipSettings.java
+++ b/sip/src/com/android/services/telephony/sip/SipSettings.java
@@ -57,25 +57,20 @@ import java.util.Map;
* The PreferenceActivity class for managing sip profile preferences.
*/
public class SipSettings extends PreferenceActivity {
- private static final String PREFIX = "[SipSettings] ";
- private static final boolean VERBOSE = false; /* STOP SHIP if true */
-
public static final String SIP_SHARED_PREFERENCES = "SIP_PREFERENCES";
- private static final int MENU_ADD_ACCOUNT = Menu.FIRST;
-
static final String KEY_SIP_PROFILE = "sip_profile";
+ static final int REQUEST_ADD_OR_EDIT_SIP_PROFILE = 1;
+ private static final String PREFIX = "[SipSettings] ";
+ private static final boolean VERBOSE = false; /* STOP SHIP if true */
+ private static final int MENU_ADD_ACCOUNT = Menu.FIRST;
private static final String PREF_SIP_LIST = "sip_account_list";
- private static final int REQUEST_ADD_OR_EDIT_SIP_PROFILE = 1;
-
private PackageManager mPackageManager;
private SipManager mSipManager;
private SipProfileDb mProfileDb;
-
private SipProfile mProfile; // profile that's being edited
-
private PreferenceCategory mSipListContainer;
private Map<String, SipPreference> mSipPreferenceMap;
private List<SipProfile> mSipProfileList;
@@ -144,8 +139,6 @@ public class SipSettings extends PreferenceActivity {
addPreferencesFromResource(R.xml.sip_setting);
mSipListContainer = (PreferenceCategory) findPreference(PREF_SIP_LIST);
- updateProfilesStatus();
-
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
@@ -155,6 +148,7 @@ public class SipSettings extends PreferenceActivity {
@Override
public void onResume() {
super.onResume();
+ updateProfilesStatus();
}
@Override