Commit 9c450bb01aac6f8d208b4397546568819e1f8ba2
1 parent
15bd869561
Exists in
master
调试接口和逻辑以及奔溃处理
Showing
9 changed files
with
414 additions
and
33 deletions
Show diff stats
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/AccountManagementActivity.java
... | ... | @@ -174,20 +174,19 @@ public class AccountManagementActivity extends AppCompatActivity implements View |
174 | 174 | public void onClick(View v) { |
175 | 175 | switch (v.getId()) { |
176 | 176 | case R.id.changBangding: |
177 | + Content.authcodeflag = 1; | |
177 | 178 | Intent changebangding = new Intent(); |
178 | - changebangding.setClass(AccountManagementActivity.this, ChangeBangDingActivity.class); | |
179 | + changebangding.setClass(AccountManagementActivity.this, ElectronicCardValidationActivity.class); | |
179 | 180 | startActivity(changebangding); |
180 | 181 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
181 | 182 | break; |
182 | 183 | case R.id.changpassword: |
183 | - Content.authcodeflag = 1; | |
184 | 184 | Intent changpwd = new Intent(); |
185 | 185 | changpwd.setClass(AccountManagementActivity.this, ChangePasswordActivity.class); |
186 | 186 | startActivity(changpwd); |
187 | 187 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
188 | 188 | break; |
189 | 189 | case R.id.add_account: |
190 | - Content.accountflag = 2; | |
191 | 190 | Intent account = new Intent(); |
192 | 191 | account.setClass(AccountManagementActivity.this, RegisterInfoActivity.class); |
193 | 192 | startActivity(account); |
... | ... | @@ -223,6 +222,8 @@ public class AccountManagementActivity extends AppCompatActivity implements View |
223 | 222 | super.onResume(); |
224 | 223 | String userID = SaveParam.getInstance().getLoginParam(this, "userId"); |
225 | 224 | String devicenumber = GetDevicesUtil.getDevicesInfo(this).getDeviceNumber(); |
225 | + String cunt_username = SaveParam.getInstance().getLoginParam(this, "username"); | |
226 | + usernames.setText(cunt_username); | |
226 | 227 | try { |
227 | 228 | long auserID = Long.parseLong(userID); |
228 | 229 | HttpManager.getInstance().getchildAccountinfo(this, auserID, devicenumber, handler); | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ElectronicCardLookInfoActivity.java
... | ... | @@ -15,6 +15,7 @@ import com.hjx.personalcenter.db.SaveParam; |
15 | 15 | import com.hjx.personalcenter.http.HttpCode; |
16 | 16 | import com.hjx.personalcenter.http.HttpManager; |
17 | 17 | import com.hjx.personalcenter.model.CardInfo; |
18 | +import com.hjx.personalcenter.util.AlertUtils; | |
18 | 19 | |
19 | 20 | import java.util.ArrayList; |
20 | 21 | |
... | ... | @@ -22,32 +23,35 @@ import java.util.ArrayList; |
22 | 23 | * Created by h on 2017/8/11. |
23 | 24 | */ |
24 | 25 | |
25 | -public class ElectronicCardLookInfoActivity extends AppCompatActivity implements View.OnClickListener{ | |
26 | +public class ElectronicCardLookInfoActivity extends AppCompatActivity implements View.OnClickListener { | |
26 | 27 | private ImageView iv_last_step; |
27 | - private TextView usename,deviceModel,customer_address,mac_adress,shoptime,deviceNumber, | |
28 | - shopadress,phone,tlePhone,tv_card_adress_change,tv_card_phone_change; | |
28 | + private TextView usename, deviceModel, customer_address, mac_adress, shoptime, deviceNumber, | |
29 | + shopadress, phone, tlePhone, tv_card_adress_change, tv_card_phone_change; | |
29 | 30 | private ArrayList<CardInfo.DataBean> data = new ArrayList<>(); |
30 | 31 | |
31 | - Handler handler = new Handler(){ | |
32 | + Handler handler = new Handler() { | |
32 | 33 | @Override |
33 | 34 | public void handleMessage(Message msg) { |
34 | 35 | super.handleMessage(msg); |
35 | - switch (msg.what){ | |
36 | + switch (msg.what) { | |
36 | 37 | |
37 | 38 | case HttpCode.SUCHCARDINFO: |
38 | - CardInfo.DataBean cardinfoBean =(CardInfo.DataBean)msg.obj; | |
39 | - //获取设备信息 | |
40 | - deviceModel.setText(cardinfoBean.getProductModel()); | |
41 | - deviceNumber.setText(cardinfoBean.getDeviceNumber()); | |
42 | - mac_adress.setText(cardinfoBean.getMacAddress()); | |
43 | - //获取保卡信息 | |
44 | - usename.setText(cardinfoBean.getCustomerName()); | |
45 | - customer_address.setText(cardinfoBean.getCustomerAddress()); | |
46 | - shoptime.setText(cardinfoBean.getBuyTime()); | |
47 | - shopadress.setText(cardinfoBean.getBuyAddress()); | |
48 | - tlePhone.setText(cardinfoBean.getAlterSaleCall()); | |
49 | - phone.setText(cardinfoBean.getMobilePhone()); | |
50 | - | |
39 | + CardInfo.DataBean cardinfoBean = (CardInfo.DataBean) msg.obj; | |
40 | + if (cardinfoBean != null) { | |
41 | + //获取设备信息 | |
42 | + deviceModel.setText(cardinfoBean.getProductModel()); | |
43 | + deviceNumber.setText(cardinfoBean.getDeviceNumber()); | |
44 | + mac_adress.setText(cardinfoBean.getMacAddress()); | |
45 | + //获取保卡信息 | |
46 | + usename.setText(cardinfoBean.getCustomerName()); | |
47 | + customer_address.setText(cardinfoBean.getCustomerAddress()); | |
48 | + shoptime.setText(cardinfoBean.getBuyTime()); | |
49 | + shopadress.setText(cardinfoBean.getBuyAddress()); | |
50 | + tlePhone.setText(cardinfoBean.getAlterSaleCall()); | |
51 | + phone.setText(cardinfoBean.getMobilePhone()); | |
52 | + }else { | |
53 | + AlertUtils.showToast(ElectronicCardLookInfoActivity.this,"您的机器还没有保卡信息,请重新登录"); | |
54 | + } | |
51 | 55 | |
52 | 56 | break; |
53 | 57 | |
... | ... | @@ -68,10 +72,10 @@ public class ElectronicCardLookInfoActivity extends AppCompatActivity implements |
68 | 72 | @Override |
69 | 73 | protected void onResume() { |
70 | 74 | super.onResume(); |
71 | - String userID = SaveParam.getInstance().getLoginParam(this,"userId"); | |
75 | + String userID = SaveParam.getInstance().getLoginParam(this, "userId"); | |
72 | 76 | try { |
73 | 77 | Long a = Long.parseLong(userID); |
74 | - HttpManager.getInstance().getcardinfo(this,a,handler); | |
78 | + HttpManager.getInstance().getcardinfo(this, a, handler); | |
75 | 79 | } catch (NumberFormatException e) { |
76 | 80 | e.printStackTrace(); |
77 | 81 | } |
... | ... | @@ -79,7 +83,7 @@ public class ElectronicCardLookInfoActivity extends AppCompatActivity implements |
79 | 83 | |
80 | 84 | private void initView() { |
81 | 85 | usename = (TextView) findViewById(R.id.iv_card_username); |
82 | - iv_last_step = (ImageView) findViewById(R.id.cancel); | |
86 | + iv_last_step = (ImageView) findViewById(R.id.cancel); | |
83 | 87 | deviceModel = (TextView) findViewById(R.id.tv_card_deviceModel); |
84 | 88 | customer_address = (TextView) findViewById(R.id.tv_card_adress); |
85 | 89 | mac_adress = (TextView) findViewById(R.id.tv_card_mac); |
... | ... | @@ -91,6 +95,7 @@ public class ElectronicCardLookInfoActivity extends AppCompatActivity implements |
91 | 95 | tv_card_adress_change = (TextView) findViewById(R.id.tv_card_adress_change); |
92 | 96 | tv_card_phone_change = (TextView) findViewById(R.id.tv_card_phone_change); |
93 | 97 | } |
98 | + | |
94 | 99 | private void initData() { |
95 | 100 | |
96 | 101 | // //获取设备信息 |
... | ... | @@ -107,25 +112,27 @@ public class ElectronicCardLookInfoActivity extends AppCompatActivity implements |
107 | 112 | |
108 | 113 | |
109 | 114 | } |
115 | + | |
110 | 116 | private void initLister() { |
111 | 117 | tv_card_adress_change.setOnClickListener(this); |
112 | 118 | tv_card_phone_change.setOnClickListener(this); |
113 | 119 | iv_last_step.setOnClickListener(this); |
114 | 120 | } |
121 | + | |
115 | 122 | @Override |
116 | 123 | public void onClick(View v) { |
117 | - switch (v.getId()){ | |
124 | + switch (v.getId()) { | |
118 | 125 | case R.id.tv_card_adress_change: |
119 | 126 | Intent intent = new Intent(); |
120 | - intent.setClass(this,ChangeElectronicCardAdressInfoActivity.class); | |
127 | + intent.setClass(this, ChangeElectronicCardAdressInfoActivity.class); | |
121 | 128 | startActivity(intent); |
122 | 129 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
123 | 130 | |
124 | 131 | break; |
125 | 132 | case R.id.tv_card_phone_change: |
126 | - Content.authcodeflag =2; | |
133 | + Content.authcodeflag = 2; | |
127 | 134 | Intent intent1 = new Intent(); |
128 | - intent1.setClass(this,ElectronicCardValidationActivity.class); | |
135 | + intent1.setClass(this, ElectronicCardValidationActivity.class); | |
129 | 136 | startActivity(intent1); |
130 | 137 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
131 | 138 | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/ElectronicCardValidationActivity.java
... | ... | @@ -146,7 +146,6 @@ public class ElectronicCardValidationActivity extends AppCompatActivity implemen |
146 | 146 | HttpManager.getInstance().changecardinfophone(this, |
147 | 147 | auserID,usernameStr,authcodeStr); |
148 | 148 | |
149 | - | |
150 | 149 | }else if (Content.authcodeflag==2){ |
151 | 150 | //修改保卡手机号 |
152 | 151 | HttpManager.getInstance().changecardinfophone(this, | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/MyApplication.java
... | ... | @@ -2,8 +2,15 @@ package com.hjx.personalcenter.activity; |
2 | 2 | |
3 | 3 | import android.app.Application; |
4 | 4 | import android.content.Context; |
5 | +import android.graphics.drawable.Drawable; | |
6 | +import android.os.Looper; | |
7 | +import android.view.Gravity; | |
8 | +import android.widget.TextView; | |
9 | +import android.widget.Toast; | |
5 | 10 | |
6 | 11 | import com.facebook.drawee.backends.pipeline.Fresco; |
12 | +import com.hjx.personalcenter.R; | |
13 | +import com.hjx.personalcenter.crash.CrashHandler; | |
7 | 14 | import com.hjx.personalcenter.util.ImageCache; |
8 | 15 | import com.squareup.leakcanary.LeakCanary; |
9 | 16 | import com.tencent.bugly.crashreport.CrashReport; |
... | ... | @@ -19,7 +26,6 @@ public class MyApplication extends Application { |
19 | 26 | private static MyApplication instance; |
20 | 27 | @Override |
21 | 28 | public void onCreate() { |
22 | - super.onCreate(); | |
23 | 29 | context = getApplicationContext(); |
24 | 30 | //c初始化内存检测 |
25 | 31 | LeakCanary.install(this); |
... | ... | @@ -28,6 +34,45 @@ public class MyApplication extends Application { |
28 | 34 | mImageCache = new ImageCache(); |
29 | 35 | instance = this; |
30 | 36 | CrashReport.initCrashReport(getApplicationContext(), "c2170557a0", false); |
37 | + CrashHandler crashHandler = CrashHandler.getInstance(); | |
38 | + crashHandler.init(getApplicationContext()); | |
39 | + crashHandler.registerHandler(new CrashHandler.ExceptionHandler() { | |
40 | + | |
41 | + @Override | |
42 | + public boolean handleCrash(final Context context, final Throwable ex) { | |
43 | + new Thread(new Runnable() { | |
44 | + | |
45 | + @Override | |
46 | + public void run() { | |
47 | + Looper.prepare(); | |
48 | + System.out.println("bcz = " + ex.toString()); | |
49 | + Toast toast = new Toast(context); | |
50 | + TextView tv = new TextView(context); | |
51 | + tv.setText(" 很抱歉,"+context.getString(R.string.app_name)+"崩溃了,我们会尽快修复."); | |
52 | + tv.setPadding(10, 10, 10, 10); | |
53 | + tv.setTextSize(20); | |
54 | + tv.setBackgroundResource(R.drawable.black_btn_default); | |
55 | + tv.setTextColor(context.getResources().getColor(android.R.color.white)); | |
56 | + Drawable drawable= context.getResources().getDrawable(R.drawable.sorry); | |
57 | + drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); | |
58 | + tv.setCompoundDrawables(drawable,null,null,null); | |
59 | + toast.setView(tv); | |
60 | + toast.setGravity(Gravity.CENTER, 0, 0); | |
61 | + toast.setDuration(Toast.LENGTH_LONG); | |
62 | + toast.show(); | |
63 | + Looper.loop(); | |
64 | + } | |
65 | + }).start(); | |
66 | + try { | |
67 | + Thread.sleep(1000); | |
68 | + } catch (InterruptedException e) { | |
69 | + // TODO Auto-generated catch block | |
70 | + e.printStackTrace(); | |
71 | + } | |
72 | + return false; | |
73 | + } | |
74 | + }); | |
75 | + super.onCreate(); | |
31 | 76 | } |
32 | 77 | public ImageCache getImageCache() { |
33 | 78 | return mImageCache; |
... | ... | @@ -39,4 +84,5 @@ public class MyApplication extends Application { |
39 | 84 | public static MyApplication getInstance() { |
40 | 85 | return instance; |
41 | 86 | } |
87 | + | |
42 | 88 | } | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/crash/CrashHandler.java
... | ... | @@ -0,0 +1,320 @@ |
1 | +package com.hjx.personalcenter.crash; | |
2 | + | |
3 | +import android.content.Context; | |
4 | +import android.content.pm.PackageInfo; | |
5 | +import android.content.pm.PackageManager; | |
6 | +import android.net.wifi.WifiInfo; | |
7 | +import android.net.wifi.WifiManager; | |
8 | +import android.os.Build; | |
9 | +import android.os.Environment; | |
10 | +import android.util.Log; | |
11 | + | |
12 | +import com.hjx.personalcenter.util.MachineUtil; | |
13 | + | |
14 | +import org.json.JSONObject; | |
15 | + | |
16 | +import java.io.BufferedReader; | |
17 | +import java.io.File; | |
18 | +import java.io.FileOutputStream; | |
19 | +import java.io.FileReader; | |
20 | +import java.io.IOException; | |
21 | +import java.io.PrintWriter; | |
22 | +import java.io.StringWriter; | |
23 | +import java.io.Writer; | |
24 | +import java.lang.Thread.UncaughtExceptionHandler; | |
25 | +import java.util.HashMap; | |
26 | +import java.util.Map; | |
27 | + | |
28 | + | |
29 | +/** | |
30 | + * UncaughtException处理类,当程序发生Uncaught异常的时候,有该类来接管程序,并记录发送错误报告. | |
31 | + * | |
32 | + * @author user | |
33 | + * | |
34 | + */ | |
35 | +public class CrashHandler implements UncaughtExceptionHandler { | |
36 | + | |
37 | + public static final String TAG = "CrashHandler"; | |
38 | + // CrashHandler实例 | |
39 | + private static CrashHandler INSTANCE = null; | |
40 | + // 程序的Context对象 | |
41 | + private Context mContext = null; | |
42 | + private ExceptionHandler exceptionH = null; | |
43 | + private StringBuffer log; | |
44 | + | |
45 | + // 文件保存路径 | |
46 | + public static final String LOG_DIR = Environment.getExternalStorageDirectory().toString()+"/hjx/log";; | |
47 | + | |
48 | + private static final String APP_NAME = "APP_NAME"; | |
49 | + private static final String VERSION_NAME = "VERSION_NAME"; | |
50 | + private static final String VERSION_CODE = "VERSION_CODE"; | |
51 | + private static final String APP_MODLE = "APP_MODLE";// 手机型号 | |
52 | + private static final String CRASH_TIME = "CRASH_TIME"; | |
53 | + private static final String DEVICE_NUMBER = "DEVICE_NUMBER"; | |
54 | + // private static final String IMSI_CODE = "IMSI_CODE"; | |
55 | + // private static final String PHONE_NUMBER = "PHONE_NUMBER"; | |
56 | + private static final String OS_VERSION = "OS_VERSION"; | |
57 | + private static final String MAC_ADDRESS = "MAC_ADDRESS"; | |
58 | + | |
59 | + /** 保证只有一个CrashHandler实例 */ | |
60 | + private CrashHandler() { | |
61 | + } | |
62 | + | |
63 | + /** 获取CrashHandler实例 ,单例模式 */ | |
64 | + public static synchronized CrashHandler getInstance() { | |
65 | + if(INSTANCE == null){ | |
66 | + INSTANCE = new CrashHandler(); | |
67 | + } | |
68 | + return INSTANCE; | |
69 | + } | |
70 | + | |
71 | + public interface ExceptionHandler{ | |
72 | + /** | |
73 | + * | |
74 | + * @param context | |
75 | + * @param ex | |
76 | + * @return 如果返回true消费这个throwable false不消费 | |
77 | + */ | |
78 | + public boolean handleCrash(Context context, Throwable ex); | |
79 | + } | |
80 | + | |
81 | + public void registerHandler(ExceptionHandler handler){ | |
82 | + this.exceptionH = handler; | |
83 | + } | |
84 | + | |
85 | + /** | |
86 | + * 初始化 | |
87 | + * | |
88 | + * @param context | |
89 | + */ | |
90 | + public void init(Context context) { | |
91 | + mContext = context; | |
92 | + log = new StringBuffer(); | |
93 | + // 设置该CrashHandler为程序的默认处理器 | |
94 | + Thread.setDefaultUncaughtExceptionHandler(this); | |
95 | + } | |
96 | + | |
97 | + /** | |
98 | + * 当UncaughtException发生时会转入该函数来处理 | |
99 | + */ | |
100 | + @Override | |
101 | + public void uncaughtException(Thread thread, Throwable ex) { | |
102 | + if (!handleException(ex)) { | |
103 | + // 收集设备参数信息 | |
104 | + collectDeviceInfo(mContext); | |
105 | + | |
106 | + // 保存日志文件 | |
107 | + saveCrashInfo2File(ex); | |
108 | + // 解析文件信息 | |
109 | + //parseFile(path); | |
110 | + // 上传日志文件 | |
111 | + // try { | |
112 | + // urlPostFile(path); | |
113 | + // } catch (Exception e) { | |
114 | + // e.printStackTrace(); | |
115 | + // } | |
116 | + // 退出程序 | |
117 | + } | |
118 | + log.setLength(0); | |
119 | + android.os.Process.killProcess(android.os.Process.myPid()); | |
120 | + System.exit(1); | |
121 | + } | |
122 | + | |
123 | + /** | |
124 | + * 应用程序自己处理未捕获的异常 | |
125 | + * | |
126 | + * @param ex | |
127 | + * @return true: 如果返回true消耗这个throwable false不消耗 | |
128 | + */ | |
129 | + private boolean handleException(Throwable ex) { | |
130 | + if (exceptionH == null) { | |
131 | + return false; | |
132 | + }else{ | |
133 | + return exceptionH.handleCrash(mContext, ex); | |
134 | + } | |
135 | + } | |
136 | + | |
137 | + /** | |
138 | + * 收集参数信息 | |
139 | + * | |
140 | + * @param ctx | |
141 | + */ | |
142 | + private void collectDeviceInfo(Context ctx) { | |
143 | + | |
144 | + try { | |
145 | + PackageManager pm = ctx.getPackageManager(); | |
146 | + PackageInfo pi = pm.getPackageInfo(ctx.getPackageName(), | |
147 | + PackageManager.GET_META_DATA); | |
148 | + if (pi != null) { | |
149 | + String appName = pi.applicationInfo.loadLabel(pm).toString(); | |
150 | + String versionName = pi.versionName == null ? "null" | |
151 | + : pi.versionName; | |
152 | + String versionCode = pi.versionCode + ""; | |
153 | + log.append("{\"").append(APP_NAME).append("\":\"") | |
154 | + .append(appName).append("\",\"") | |
155 | + .append(VERSION_NAME).append("\":\"") | |
156 | + .append(versionName).append("\",\"") | |
157 | + .append(OS_VERSION).append("\":\"") | |
158 | + .append(Build.VERSION.RELEASE).append("\",\"") | |
159 | + .append(VERSION_CODE).append("\":\"") | |
160 | + .append(versionCode).append("\",\"") | |
161 | + .append(APP_MODLE).append("\":\"") | |
162 | + .append(Build.MODEL).append("\",\"") | |
163 | + .append(CRASH_TIME).append("\":\"") | |
164 | + .append(System.currentTimeMillis()).append("\""); | |
165 | + } | |
166 | + } catch (Exception e) { | |
167 | + Log.e(TAG, "an error occured when collect package info", e); | |
168 | + log.setLength(0); | |
169 | + log.append("{\"").append(APP_NAME).append("\":\"") | |
170 | + .append("unkown").append("\",\"") | |
171 | + .append(VERSION_NAME).append("\":\"") | |
172 | + .append("unkown").append("\",\"") | |
173 | + .append(OS_VERSION).append("\":\"") | |
174 | + .append(Build.VERSION.RELEASE).append("\",\"") | |
175 | + .append(VERSION_CODE).append("\":\"") | |
176 | + .append("unkown").append("\",\"") | |
177 | + .append(APP_MODLE).append("\":\"") | |
178 | + .append(Build.MODEL).append("\",\"") | |
179 | + .append(CRASH_TIME).append("\":\"") | |
180 | + .append(System.currentTimeMillis()).append("\""); | |
181 | + } | |
182 | + try { | |
183 | + //common android os | |
184 | + /* | |
185 | + TelephonyManager mTm = (TelephonyManager)ctx.getSystemService(Context.TELEPHONY_SERVICE); | |
186 | + String imei = mTm.getDeviceId(); | |
187 | + String imsi = mTm.getSubscriberId(); | |
188 | + String numer = mTm.getLine1Number(); // 手机号码,有的可得,有的不可得 | |
189 | + if(mTm != null){ | |
190 | + log.append(",\"").append(DEVICE_NUMBER).append("\":\"") | |
191 | + .append(TextUtils.isEmpty(imei)?"unkown":imei).append("\",\"") | |
192 | + .append(IMSI_CODE).append("\":\"") | |
193 | + .append(TextUtils.isEmpty(imsi)?"unkown":imsi).append("\",\"") | |
194 | + .append(PHONE_NUMBER).append("\":\"") | |
195 | + .append(TextUtils.isEmpty(numer)?"unkown":numer).append("\"}"); | |
196 | + } | |
197 | + */ | |
198 | + //hjx machine | |
199 | + | |
200 | + log.append(",\"").append(DEVICE_NUMBER).append("\":\"") | |
201 | + .append(getCPUSerial(ctx)).append("\",\"") | |
202 | + .append(MAC_ADDRESS).append("\":\"") | |
203 | + .append(getMacAddress(ctx)).append("\"}"); | |
204 | + | |
205 | + } catch (Exception e) { | |
206 | + /* | |
207 | + * common android os | |
208 | + log.append(",\"").append(DEVICE_NUMBER).append("\":\"") | |
209 | + .append("unkown").append("\",\"") | |
210 | + .append(IMSI_CODE).append("\":\"") | |
211 | + .append("unkown").append("\",\"") | |
212 | + .append(PHONE_NUMBER).append("\":\"") | |
213 | + .append("unkown").append("\"}"); | |
214 | + */ | |
215 | + log.append(",\"").append(DEVICE_NUMBER).append("\":\"") | |
216 | + .append("unkown").append("\",\"") | |
217 | + .append(MAC_ADDRESS).append("\":\"") | |
218 | + .append("unkown").append("\"}"); | |
219 | + Log.e(TAG, "an error occured when collect package info", e); | |
220 | + } | |
221 | + } | |
222 | + | |
223 | + private String getCPUSerial(Context context) { | |
224 | + return MachineUtil.getMachineCode(context); | |
225 | + } | |
226 | + | |
227 | + private String getMacAddress(Context mContext){ | |
228 | + String ret = null; | |
229 | + try { | |
230 | + WifiManager manager = (WifiManager)mContext.getSystemService(Context.WIFI_SERVICE); | |
231 | + WifiInfo info = manager.getConnectionInfo(); | |
232 | + ret = info.getMacAddress(); | |
233 | + } catch (Exception e) { | |
234 | + Log.e(TAG, "get wifi address wrong", e); | |
235 | + } | |
236 | + return ret; | |
237 | + } | |
238 | + | |
239 | + /** | |
240 | + * 保存错误信息到文件中 | |
241 | + * | |
242 | + * @param ex | |
243 | + * @return 返回文件名称,便于将文件传送到服务器 | |
244 | + */ | |
245 | + private String saveCrashInfo2File(Throwable ex) { | |
246 | + | |
247 | + // SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); | |
248 | + Writer writer = new StringWriter(); | |
249 | + PrintWriter printWriter = new PrintWriter(writer); | |
250 | + ex.printStackTrace(printWriter); | |
251 | + Throwable cause = ex.getCause(); | |
252 | + while (cause != null) { | |
253 | + cause.printStackTrace(printWriter); | |
254 | + cause = cause.getCause(); | |
255 | + } | |
256 | + printWriter.close(); | |
257 | + String result = writer.toString(); | |
258 | + log.append("\n").append(result); | |
259 | + try { | |
260 | + // String name = mContext.getPackageName(); | |
261 | + // String time = formatter.format(new Date()); | |
262 | + String fileName = System.currentTimeMillis()+".log"; | |
263 | + if (Environment.getExternalStorageState().equals( | |
264 | + Environment.MEDIA_MOUNTED)) { | |
265 | + File dir = new File(LOG_DIR); | |
266 | + if (!dir.exists()) { | |
267 | + dir.mkdirs(); | |
268 | + } | |
269 | + FileOutputStream fos = new FileOutputStream(LOG_DIR+"/" | |
270 | + + fileName); | |
271 | + fos.write(log.toString().getBytes()); | |
272 | + fos.close(); | |
273 | + } | |
274 | + return fileName; | |
275 | + } catch (Exception e) { | |
276 | + Log.e(TAG, "an error occured while writing file...", e); | |
277 | + } | |
278 | + return null; | |
279 | + } | |
280 | + | |
281 | + /** | |
282 | + * 解析文件信息 | |
283 | + * | |
284 | + * @param filePath | |
285 | + * @return 装有相关信息的map | |
286 | + */ | |
287 | + @Deprecated | |
288 | + public Map<String, String> parseFile(String filePath) { | |
289 | + BufferedReader read = null; | |
290 | + try { | |
291 | + read = new BufferedReader(new FileReader(filePath)); | |
292 | + String line = read.readLine(); | |
293 | + JSONObject jsonObj = new JSONObject(line); | |
294 | + Map<String, String> map = new HashMap<String, String>(); | |
295 | + map.put(APP_NAME, jsonObj.optString(APP_NAME)); | |
296 | + map.put(APP_MODLE, jsonObj.optString(APP_MODLE)); | |
297 | + map.put(VERSION_NAME, jsonObj.optString(VERSION_NAME)); | |
298 | + map.put(VERSION_CODE, jsonObj.optString(VERSION_CODE)); | |
299 | + map.put(CRASH_TIME, jsonObj.optString(CRASH_TIME)); | |
300 | + StringBuffer sb = new StringBuffer(); | |
301 | + int readed = 0; | |
302 | + char[] buf = new char[1024]; | |
303 | + while((readed = read.read(buf))!=-1){ | |
304 | + sb.append(buf,0,readed); | |
305 | + } | |
306 | + map.put("CONTENT", sb.toString()); | |
307 | + return map; | |
308 | + } catch (Exception e) { | |
309 | + e.printStackTrace(); | |
310 | + } finally{ | |
311 | + try { | |
312 | + if(read != null) | |
313 | + read.close(); | |
314 | + } catch (IOException e) { | |
315 | + e.printStackTrace(); | |
316 | + } | |
317 | + } | |
318 | + return null; | |
319 | + } | |
320 | +} | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/db/Content.java
... | ... | @@ -5,8 +5,9 @@ package com.hjx.personalcenter.db; |
5 | 5 | */ |
6 | 6 | |
7 | 7 | public class Content { |
8 | - public static int authcodeflag;//1是进入填写保卡信息验证,2是修改保卡手机号验证,3是更改绑定验证 | |
8 | + public static int authcodeflag;//其他是进入填写保卡信息验证,2是修改保卡手机号验证,1是更改绑定验证 | |
9 | 9 | public static int adressflag;//1购买地址,2客户地址 |
10 | 10 | public static int accountflag;//1主账户注册信息,2子账户注册信息 |
11 | 11 | public static int changgeaccountflag;//账户切换成功标志 |
12 | + public static int changeinfoflag;//1提交个人信息2是提交版本信息 | |
12 | 13 | } | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpManager.java
... | ... | @@ -17,6 +17,7 @@ import com.google.gson.Gson; |
17 | 17 | import com.hjx.personalcenter.R; |
18 | 18 | import com.hjx.personalcenter.activity.LoginAndRegisterActivity; |
19 | 19 | import com.hjx.personalcenter.activity.TheStartPageActivity; |
20 | +import com.hjx.personalcenter.db.Content; | |
20 | 21 | import com.hjx.personalcenter.db.SaveParam; |
21 | 22 | import com.hjx.personalcenter.gson.GsonTool; |
22 | 23 | import com.hjx.personalcenter.model.AppVersion; |
... | ... | @@ -542,7 +543,13 @@ public class HttpManager { |
542 | 543 | String status = jsonObject.optString("status"); |
543 | 544 | if (status.equals("1")) { |
544 | 545 | Toast.makeText(mContext, "手机号修改成功", Toast.LENGTH_LONG).show(); |
545 | - SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.CARDPHONE, customerPhone); | |
546 | + if (Content.authcodeflag==2){ | |
547 | + SaveParam.getInstance().saveCustomizeParam(mContext, SaveParam.CARDPHONE, customerPhone); | |
548 | + }else if (Content.authcodeflag==1){ | |
549 | + SaveParam.getInstance().saveLoginParam(mContext, "username", customerPhone); | |
550 | + }else { | |
551 | + AlertUtils.showToast(mContext, "修改未知的手机号"); | |
552 | + } | |
546 | 553 | ((Activity) mContext).finish(); |
547 | 554 | } else if (status.equals("1001")) { |
548 | 555 | Toast.makeText(mContext, "验证码输入错误", Toast.LENGTH_LONG).show(); |
... | ... | @@ -1165,7 +1172,7 @@ public class HttpManager { |
1165 | 1172 | @Override |
1166 | 1173 | public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { |
1167 | 1174 | closeProgress(); |
1168 | - Log.e("test", "错误信息" + new String(arg2)); | |
1175 | +// Log.e("test", "错误信息" + new String(arg2)); | |
1169 | 1176 | new CircleDialog.Builder((FragmentActivity) mContext) |
1170 | 1177 | .setCanceledOnTouchOutside(false) |
1171 | 1178 | .setCancelable(false) | ... | ... |
PersonalCenter/app/src/main/res/drawable/black_btn_default.9.png
946 Bytes
PersonalCenter/app/src/main/res/drawable/sorry.png
2.06 KB