Skip to content

Commit

Permalink
Merge branch 'master' of github.com:costinm/datamessaging
Browse files Browse the repository at this point in the history
Conflicts:
	android/AndroidManifest.xml
	android/build.gradle
  • Loading branch information
costinm committed Oct 1, 2015
2 parents bb6a993 + 2aeeede commit a4fcacb
Show file tree
Hide file tree
Showing 33 changed files with 689 additions and 1,183 deletions.
79 changes: 32 additions & 47 deletions android/AndroidManifest.xml
@@ -1,75 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.apps.chrometophone"
android:installLocation="auto"
android:versionCode="15"
android:versionName="2.3.2" >

<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="10" />

package="com.google.android.apps.chrometophone"
android:installLocation="auto"
android:versionCode="17"
android:versionName="2.3.4">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="10" />

<!-- Only this application can receive the messages and registration result
Used on Gingerbread/Froyo
-->
<permission
android:name="com.google.android.apps.chrometophone.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<permission android:name="com.google.android.apps.chrometophone.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.google.android.apps.chrometophone.permission.C2D_MESSAGE" />

<!-- This app has permission to register and receive data message -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

<!-- Permissions for internet access and account access -->
<uses-permission android:name="android.permission.INTERNET" />

<!-- App must have this permission to use the library -->
<uses-permission android:name="android.permission.WAKE_LOCK" />

<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />

<!--
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
-->
<application
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:theme="@style/Theme.LightNoActionBar" >
<activity
android:name=".HistoryActivity"
android:label="@string/app_name" >

<application android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:theme="@style/Theme.LightNoActionBar">
<activity android:name=".HistoryActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SetupActivity"
android:label="@string/app_name"
android:launchMode="singleTop" >

<activity android:name=".SetupActivity"
android:label="@string/app_name"
android:launchMode="singleTop">
</activity>
<activity
android:name=".HelpActivity"
android:label="@string/app_name" >

<activity android:name=".HelpActivity"
android:label="@string/app_name">
</activity>
<activity
android:name=".ShareLinkActivity"
android:theme="@style/Theme.Translucent" >
<!--
<activity android:name=".ShareLinkActivity"
android:theme="@style/Theme.Translucent">
<intent-filter>
<action android:name="android.intent.action.SEND" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="text/plain" />
</intent-filter>
</activity>
-->

<!-- Handles incoming messages, using GCM 3.0 API -->
<service android:name=".GCMIntentService" android:exported="false">
Expand Down Expand Up @@ -103,19 +85,22 @@
</intent-filter>
</receiver>

<!--
Receiver called when the application is updated (Android 3.1+), it will check
if the previous version used C2DM and update to GCM if necessary.
-->
<receiver
android:name=".DeviceRegistrar$Updater">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter>
</receiver>
<receiver
android:name=".UserPresentReceiver"
android:enabled="false" >

<receiver android:name=".UserPresentReceiver" android:enabled="false">
<intent-filter>
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
</application>

</manifest>
</manifest>
Expand Up @@ -102,10 +102,16 @@ void registerWithServer(final Context context,
// If we had a previous c2dm or GCM registration ID
String c2dmRegId = settings.getString(Prefs.OLD_REGID, "");

String oldRegId = c2dmRegId;
if ("".equals(oldRegId)) {
// removed from prefs after we upgraded to IID. Send the previous IID
oldRegId = Prefs.getPrefs(context).getIid();
}

int sc = HttpClient.get(context).makeSimpleRequest(
DeviceRegistrar.REGISTER_PATH, token,
"deviceName", isTablet(context) ? "Tablet" : "Phone",
"updatedIID", c2dmRegId);
"updatedIID", oldRegId);


if (sc == 200) {
Expand Down
Expand Up @@ -32,7 +32,7 @@ public void setTitle(String title) {

public void setUrl(String url) {
int id = R.drawable.history_browser_item_indicator;
if (LauncherUtils.isMapsURL(url)) {
if (LauncherUtils.isSupportedMapsURL(url, mContext)) {
id = R.drawable.history_maps_item_indicator;
} else if (LauncherUtils.isYouTubeURL(url)) {
id = R.drawable.history_yt_item_indicator;
Expand Down
Expand Up @@ -9,6 +9,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.media.AudioManager;
import android.media.Ringtone;
Expand Down Expand Up @@ -38,7 +39,7 @@ public static Intent getLaunchIntent(Context context, String title, String url,
} else {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (isMapsURL(url)) {
if (isSupportedMapsURL(url, context)) {
intent.setClassName(GMM_PACKAGE_NAME, GMM_CLASS_NAME);
} else if (isYouTubeURL(url)) {
intent.setPackage(YT_PACKAGE_NAME);
Expand Down Expand Up @@ -119,9 +120,19 @@ public static String parseTelephoneNumber(String sel) {
return number;
}

public static boolean isMapsURL(String url) {
return url.matches("http[s]://maps\\.google\\.[a-z]{2,3}(\\.[a-z]{2})?[/?].*") ||
url.matches("http[s]://www\\.google\\.[a-z]{2,3}(\\.[a-z]{2})?/maps.*");
public static boolean isSupportedMapsURL(String url, Context context) {
if (url.matches("http[s]://maps\\.google\\.[a-z]{2,3}(\\.[a-z]{2})?[/?].*") ||
url.matches("http[s]://www\\.google\\.[a-z]{2,3}(\\.[a-z]{2})?/maps.*")) {
try {
// Desktop maps URLs changed to /preview; only GMM 7.6+ understands these
PackageManager pm = context.getPackageManager();
PackageInfo info = pm.getPackageInfo(GMM_PACKAGE_NAME, 0);
if (info != null && info.versionCode >= 706000000) {
return true;
}
} catch (PackageManager.NameNotFoundException e) { }
}
return false;
}

public static boolean isYouTubeURL(String url) {
Expand Down
15 changes: 5 additions & 10 deletions android/src/com/google/android/apps/chrometophone/Prefs.java
Expand Up @@ -171,21 +171,16 @@ private static String getCert(Context context) {

// Do the dance to get the DER-encoded certificate,
try {
/*
InputStream input = new ByteArrayInputStream(certB);
CertificateFactory cf = CertificateFactory.getInstance("X509");
X509Certificate c = (X509Certificate) cf.generateCertificate(input);

System.out.println("Orig: " +
byte2HexFormatted(certB));
System.out.println("Encoded: " +
byte2HexFormatted(c.getEncoded()));

certB == c.getEncoded()
*/
MessageDigest md = MessageDigest.getInstance("SHA1");
byte[] publicKey = md.digest(c.getEncoded());
byte[] publicKey = md.digest(certB);
cert = byte2HexFormatted(publicKey);

System.out.println("SHA1: " + cert);
} catch (CertificateException|NoSuchAlgorithmException e) {
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return "";
}
Expand Down
Expand Up @@ -24,6 +24,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
Expand Down Expand Up @@ -336,9 +337,14 @@ private void register() {

final String account = Prefs.getPrefs(SetupActivity.this).getAccount();

// Will force update if < 7.5. Client library needs to be queso to get IID API,
// but we can fall back up to ICS.
boolean hasPlayServices = true;
try {
getPackageManager().getPackageInfo("com.google.android.gms", 0);
PackageInfo pi = getPackageManager().getPackageInfo("com.google.android.gms", 0);
if (pi.versionCode < 7500000) {
hasPlayServices = false; // use AccountManager, even if gms is present
}
} catch (PackageManager.NameNotFoundException e) {
hasPlayServices = false;
}
Expand Down Expand Up @@ -374,7 +380,6 @@ public void run() {
} else {
// Play services not available - ICS to JB MR2. Use AccountManager


AccountManager.get(this).getAuthToken(new Account(account, "com.google"),
scope, null, this,
new AccountManagerCallback<Bundle>() {
Expand Down
2 changes: 1 addition & 1 deletion appengine/build.xml
@@ -1,5 +1,5 @@
<project name="Guestbook" default="datanucleusenhance">
<property name="sdk.dir" location="/home/ywen/local/appengine-java-sdk" />
<property name="sdk.dir" location="appengine-java-sdk" />

<import file="${sdk.dir}/config/user/ant-macros.xml" />

Expand Down
101 changes: 0 additions & 101 deletions appengine/c2dm/com/google/android/c2dm/server/C2DMConfig.java

This file was deleted.

0 comments on commit a4fcacb

Please sign in to comment.