Skip to content

add gzip support for upload both Android SDK & PHP web #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/android_sdk/SDK/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
# project structure.

# Project target.
target=android-7
target=android-17
android.library=true
3 changes: 1 addition & 2 deletions sdk/android_sdk/SDK/src/com/wbtech/ums/UmsAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.Iterator;
import java.util.Locale;

import org.apache.http.util.LangUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
Expand Down Expand Up @@ -654,7 +653,7 @@ private static void uploadAllLog(Context context) {
sb.append(new String(s, 0, i));
}
if (CommonUtil.isNetworkAvailable(context)) {
MyMessage message = NetworkUitlity.post(UmsConstants.preUrl
MyMessage message = NetworkUitlity.postCompressed(UmsConstants.preUrl
+ UmsConstants.uploadUrl, sb + "");
if (message.isFlag()) {
File file = new File(Environment.getExternalStorageDirectory()
Expand Down
113 changes: 73 additions & 40 deletions sdk/android_sdk/SDK/src/com/wbtech/ums/common/CommonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
import java.util.Date;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
Expand All @@ -38,10 +42,6 @@
import com.wbtech.ums.objects.LatitudeAndLongitude;
import com.wbtech.ums.objects.SCell;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class CommonUtil {

public static void saveInfoToFile(Handler handler,String type, JSONObject info, Context context) {
Expand Down Expand Up @@ -471,42 +471,75 @@ public static boolean isHaveGravity(Context context){
* @return WIFI or MOBILE
*/
public static String getNetworkType(Context context){
TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
int type= manager.getNetworkType();
String typeString="UNKNOWN";
if(type==TelephonyManager.NETWORK_TYPE_CDMA){
typeString ="CDMA";
}
if(type==TelephonyManager.NETWORK_TYPE_EDGE){
typeString ="EDGE";
}
if(type==TelephonyManager.NETWORK_TYPE_EVDO_0){
typeString ="EVDO_0";
}
if(type==TelephonyManager.NETWORK_TYPE_EVDO_A){
typeString ="EVDO_A";
}
if(type==TelephonyManager.NETWORK_TYPE_GPRS){
typeString ="GPRS";
}
if(type==TelephonyManager.NETWORK_TYPE_HSDPA){
typeString ="HSDPA";
}
if(type==TelephonyManager.NETWORK_TYPE_HSPA){
typeString ="HSPA";
}
if(type==TelephonyManager.NETWORK_TYPE_HSUPA){
typeString ="HSUPA";
}
if(type==TelephonyManager.NETWORK_TYPE_UMTS){
typeString ="UMTS";
}
if(type==TelephonyManager.NETWORK_TYPE_UNKNOWN){
typeString ="UNKNOWN";
}

return typeString;
}
String typeString = "UNKNOWN";
// check if wifi or mobile first
final ConnectivityManager connectivityManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkInfo mobNetInfoActivity = connectivityManager.getActiveNetworkInfo();
if (mobNetInfoActivity == null || !mobNetInfoActivity.isAvailable()) {
return typeString;
}

int netType = mobNetInfoActivity.getType();
if (netType == ConnectivityManager.TYPE_WIFI) {
return "wifi";
} else if (netType == ConnectivityManager.TYPE_MOBILE) {
// for mobile net
TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
int type = manager.getNetworkType();

switch (type) {
case TelephonyManager.NETWORK_TYPE_GPRS:
typeString = "GPRS";
break;
case TelephonyManager.NETWORK_TYPE_EDGE:
typeString = "EDGE";
break;
case TelephonyManager.NETWORK_TYPE_UMTS:
typeString = "UMTS";
break;

case TelephonyManager.NETWORK_TYPE_CDMA:
typeString = "CDMA";
break;
case TelephonyManager.NETWORK_TYPE_EVDO_0:
typeString = "EVDO rev. 0";
break;
case TelephonyManager.NETWORK_TYPE_EVDO_A:
typeString = "EVDO rev. A";
break;
case TelephonyManager.NETWORK_TYPE_1xRTT:
typeString = "1xRTT";
break;
case TelephonyManager.NETWORK_TYPE_HSDPA:
typeString = "HSDPA";
break;
case TelephonyManager.NETWORK_TYPE_HSUPA:
typeString = "HSUPA";
break;
case TelephonyManager.NETWORK_TYPE_HSPA:
typeString = "HSPA";
break;
case TelephonyManager.NETWORK_TYPE_IDEN:
typeString = "iDen";
break;
case TelephonyManager.NETWORK_TYPE_EVDO_B:
typeString = "EVDO rev. B";
break;
case TelephonyManager.NETWORK_TYPE_LTE:
typeString = "LTE";
break;
case TelephonyManager.NETWORK_TYPE_EHRPD:
typeString = "eHRPD";
break;
case TelephonyManager.NETWORK_TYPE_HSPAP:
typeString = "HSPA+";
break;
}

}
return typeString;
}
/**
* Determine the current network type
* @param context
Expand Down
Loading