summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorWei Huang <weih@google.com>2009-08-14 17:00:02 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2009-08-14 17:00:02 -0700
commit64e0dbcb993559e06171471fd984b578a967407e (patch)
tree87fddfdad57aab4321de8fd7b06052269fa665ef /core
parent613ad4b8bb455689fe3d12f5612c2ba2e9677b95 (diff)
parentc650bf583dbed8701da9a49b9dbd9023768f0df8 (diff)
downloadframeworks_base-64e0dbcb993559e06171471fd984b578a967407e.zip
frameworks_base-64e0dbcb993559e06171471fd984b578a967407e.tar.gz
frameworks_base-64e0dbcb993559e06171471fd984b578a967407e.tar.bz2
am c650bf58: Get rid of Settings.getJIDResource(), which really should live in GTalkService. Add API to store the JID resource in IM provider settings.
Merge commit 'c650bf583dbed8701da9a49b9dbd9023768f0df8' * commit 'c650bf583dbed8701da9a49b9dbd9023768f0df8': Get rid of Settings.getJIDResource(), which really should live in GTalkService. Add API to store the JID resource in IM provider settings.
Diffstat (limited to 'core')
-rw-r--r--core/java/android/provider/Im.java28
-rw-r--r--core/java/android/provider/Settings.java38
2 files changed, 28 insertions, 38 deletions
diff --git a/core/java/android/provider/Im.java b/core/java/android/provider/Im.java
index b11abe8..b1cf648 100644
--- a/core/java/android/provider/Im.java
+++ b/core/java/android/provider/Im.java
@@ -1620,6 +1620,9 @@ public class Im {
/** specifies the last heartbeat interval received from the server */
public static final String SETTING_HEARTBEAT_INTERVAL = "heartbeat_interval";
+ /** specifiy the JID resource used for Google Talk connection */
+ public static final String SETTING_JID_RESOURCE = "jid_resource";
+
/**
* Used for reliable message queue (RMQ). This is for storing the last rmq id received
* from the GTalk server
@@ -1861,6 +1864,14 @@ public class Im {
putLongValue(contentResolver, providerId, SETTING_HEARTBEAT_INTERVAL, interval);
}
+ /**
+ * A convenience method to set the jid resource.
+ */
+ public static void setJidResource(ContentResolver contentResolver,
+ long providerId, String jidResource) {
+ putStringValue(contentResolver, providerId, SETTING_JID_RESOURCE, jidResource);
+ }
+
public static class QueryMap extends ContentQueryMap {
private ContentResolver mContentResolver;
private long mProviderId;
@@ -2047,6 +2058,23 @@ public class Im {
}
/**
+ * Set the JID resource.
+ *
+ * @param jidResource the jid resource to be stored.
+ */
+ public void setJidResource(String jidResource) {
+ ProviderSettings.setJidResource(mContentResolver, mProviderId, jidResource);
+ }
+ /**
+ * Get the JID resource used for the Google Talk connection
+ *
+ * @return the JID resource stored.
+ */
+ public String getJidResource() {
+ return getString(SETTING_JID_RESOURCE, null);
+ }
+
+ /**
* Convenience function for retrieving a single settings value
* as a boolean.
*
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 85a2041..d3e4c4c 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -413,8 +413,6 @@ public final class Settings {
private static final String TAG = "Settings";
- private static String sJidResource = null;
-
public static class SettingNotFoundException extends AndroidException {
public SettingNotFoundException(String msg) {
super(msg);
@@ -3622,42 +3620,6 @@ public final class Settings {
}
/**
- * Returns the GTalk JID resource associated with this device.
- *
- * @return String the JID resource of the device. It uses the device IMEI in the computation
- * of the JID resource. If IMEI is not ready (i.e. telephony module not ready), we'll return
- * an empty string.
- * @hide
- */
- // TODO: we shouldn't not have a permenant Jid resource, as that's an easy target for
- // spams. We should change it once a while, like when we resubscribe to the subscription feeds
- // server.
- // (also, should this live in GTalkService?)
- public static synchronized String getJidResource() {
- if (sJidResource != null) {
- return sJidResource;
- }
-
- MessageDigest digest;
- try {
- digest = MessageDigest.getInstance("SHA-1");
- } catch (NoSuchAlgorithmException e) {
- throw new RuntimeException("this should never happen");
- }
-
- String deviceId = TelephonyManager.getDefault().getDeviceId();
- if (TextUtils.isEmpty(deviceId)) {
- return "";
- }
-
- byte[] hashedDeviceId = digest.digest(deviceId.getBytes());
- String id = new String(Base64.encodeBase64(hashedDeviceId), 0, 12);
- id = id.replaceAll("/", "_");
- sJidResource = JID_RESOURCE_PREFIX + id;
- return sJidResource;
- }
-
- /**
* Returns the device ID that we should use when connecting to the mobile gtalk server.
* This is a string like "android-0x1242", where the hex string is the Android ID obtained
* from the GoogleLoginService.