Permalink
Browse files

Updating the AppBlade Android SDK to 0.9.7. Adding the SDK version, G…

…SF ID, and GIT SHA to the attributes passed over headers.
  • Loading branch information...
jamesdaniels committed May 28, 2014
1 parent 90c1d4b commit 7b00dcd8acfb879201de007606b84897a5d957e4
@@ -0,0 +1 @@
Android/AppBlade[[:space:]]Framework/src/com/appblade/framework/AppBlade.java export-subst
BIN +0 Bytes (100%) Android/.DS_Store
Binary file not shown.
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.appblade.framework"
android:versionCode="2"
android:versionName="0.9.6" >
android:versionCode="3"
android:versionName="0.9.7" >

<uses-sdk android:minSdkVersion="9" />
<uses-sdk android:targetSdkVersion="17" />
@@ -14,7 +14,9 @@
import android.content.DialogInterface.OnClickListener;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.provider.Settings;
import android.util.Log;
import android.view.View;
@@ -45,10 +47,15 @@
* <li>Crash Reporting
* <li>Custom Parameters (for Feedback and Crash Reporting)
*
* @author rich.stern@raizlabs
* @author andrew.tremblay@raizlabs
* @author rich.stern@raizlabs.com
* @author andrew@appblade.com
* @author james@appblade.com
*/
public class AppBlade {

public static final String VERSION = "0.9.7"; // make sure to validate this against the XML in a hook
public static final String GIT_SHA = "$Format:%H$"; // make sure to write this in a hook

public static String LogTag = "AppBlade";
public static boolean makeToast = false; //for toast display in the device, not desired by default

@@ -129,6 +136,7 @@ public static void register(Context context, String token, String secret, String
appInfo.Secret = secret;
appInfo.Issuance = issuance;
appInfo.storedANDROID_ID = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
appInfo.storedGSF_ID = getGsfAndroidId(context);


if(customHost != null)
@@ -758,4 +766,19 @@ private static String makeDirFromRoot(String subfolder, Context context)
return toRet;
}

private static final Uri GSF_URI = Uri.parse("content://com.google.android.gsf.gservices");
private static final String GSF_ID_KEY = "android_id";

public static String getGsfAndroidId(Context context) {
String params[] = {GSF_ID_KEY};
Cursor c = context.getContentResolver().query(GSF_URI, null, null, params, null);
if (!c.moveToFirst() || c.getColumnCount() < 2)
return null;
try {
return Long.toHexString(Long.parseLong(c.getString(1)));
} catch (NumberFormatException e) {
return null;
}
}

}
@@ -37,6 +37,7 @@
PackageInfo PackageInfo;
private String systemInfo;
public String storedANDROID_ID;
public String storedGSF_ID;

/**
* Initializes systemInfo string if it does not yet exist.
@@ -20,8 +20,9 @@
* <br>
* Current API level is 2.0
*
* @author andrew.tremblay@raizlabs
* @author rich.stern@raizlabs
* @author andrew@appblade.com
* @author rich.stern@raizlabs.com
* @author james@appblade.com
*/
public class WebServiceHelper {
public enum HttpMethod {
@@ -106,25 +107,30 @@ public static String getHMACAuthHeader(AppInfo appInfo, String urlPath, String c
* <li> device_mfg The {@link android.os.Build.MANUFACTURER} of the OS
* <li> device_model The {@link android.os.Build.MODEL} of the OS
* <li> device_id The {@link android.os.Build.ID} of the OS
* <li> device_brand The {@link android.os.Build.ID} of the OS
* <li> device_brand The {@link android.os.Build.BRAND} of the OS
* <li> device_fingerprint The {@link android.os.Build.FINGERPRINT} of the OS
* <li> android_id The {@link android.provider.Settings.Secure.ANDROID_ID} of the device
* <li> gsf_id The GSF ID of the device
* <li> sdk_version The AppBlade Framework Version for auditing
* <li> sdk_git_sha The AppBlade Framework GIT SHA for auditing
* </ul>
* @param request The HttpRequest to which we've added the above headers.
*/
@SuppressWarnings("deprecation")
public static void addCommonHeaders(HttpRequest request) {
if(AppBlade.hasPackageInfo()) {
PackageInfo pi = AppBlade.getPackageInfo();
request.addHeader("bundle_version", pi.versionName);
request.addHeader("executable_uuid", SystemUtils.hashedExecutableUuid(pi));
request.addHeader("static_resource_uuid", SystemUtils.hashedStaticResourcesUuid(pi) );
request.addHeader("certificate_uuid", SystemUtils.hashedCertificateUuid(pi) );
request.addHeader("manifest_uuid", SystemUtils.hashedManifestFileUuid(pi) );
request.addHeader("bundle_version", pi.versionName);
request.addHeader("bundle_code", Integer.toString(pi.versionCode));
request.addHeader("executable_uuid", SystemUtils.hashedExecutableUuid(pi));
request.addHeader("static_resource_uuid", SystemUtils.hashedStaticResourcesUuid(pi) );
request.addHeader("certificate_uuid", SystemUtils.hashedCertificateUuid(pi) );
request.addHeader("manifest_uuid", SystemUtils.hashedManifestFileUuid(pi) );

Log.v(AppBlade.LogTag, " " + request.getFirstHeader("executable_uuid"));
Log.v(AppBlade.LogTag, " " + request.getFirstHeader("static_resource_uuid"));
Log.v(AppBlade.LogTag, " " + request.getFirstHeader("certificate_uuid"));
Log.v(AppBlade.LogTag, " " + request.getFirstHeader("manifest_uuid"));
Log.v(AppBlade.LogTag, " " + request.getFirstHeader("executable_uuid"));
Log.v(AppBlade.LogTag, " " + request.getFirstHeader("static_resource_uuid"));
Log.v(AppBlade.LogTag, " " + request.getFirstHeader("certificate_uuid"));
Log.v(AppBlade.LogTag, " " + request.getFirstHeader("manifest_uuid"));
}

request.addHeader("android_release", Build.VERSION.RELEASE);
@@ -135,8 +141,10 @@ public static void addCommonHeaders(HttpRequest request) {
request.addHeader("device_brand", Build.BRAND);
request.addHeader("device_fingerprint", SystemUtils.getReadableFINGERPRINT());
request.addHeader("android_id", AppBlade.appInfo.storedANDROID_ID);
request.addHeader("gsf_id", AppBlade.appInfo.storedGSF_ID);


request.addHeader("sdk_version", AppBlade.VERSION);
request.addHeader("sdk_git_sha", AppBlade.GIT_SHA);
}

/**

0 comments on commit 7b00dcd

Please sign in to comment.