FreeShare Geek v3.1.8290版本的 MD5 值为:492ca3ae4cdfab7e2d18d5e1b4428e75
以下内容为反编译后的 ContactTransferService.java 源代码,内容仅作参考
package com.stkj.processor.services;
import android.app.Service;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.provider.ContactsContract;
import android.text.TextUtils;
import android.util.Log;
import com.stkj.processor.def.a.b;
import com.stkj.processor.def.a.f;
import com.stkj.processor.def.a.g;
import com.stkj.processor.impl.resource.syncdata.i;
import java.io.File;
import java.io.IOException;
import org.json.JSONException;
import org.json.JSONObject;
public class ContactTransferService extends Service {
public static f f2208a;
public static f b;
private final Handler f2209c = new Handler(Looper.getMainLooper());
public static void a(Context context, String str, String str2, File file) {
Intent intent = new Intent(context, (Class<?>) ContactTransferService.class);
intent.putExtra("KEY_TYPE", 0);
intent.putExtra("KEY_AID", str);
intent.putExtra("KEY_MD5", str2);
intent.putExtra("KEY_FILE", file);
context.startService(intent);
}
public static void a(Context context, String str, File file) {
Intent intent = new Intent(context, (Class<?>) ContactTransferService.class);
intent.putExtra("KEY_TYPE", 1);
intent.putExtra("KEY_URL", str);
intent.putExtra("KEY_FILE", file);
context.startService(intent);
}
@Override
public void onCreate() {
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int i, int i2) {
if (intent == null) {
return 1;
}
switch (intent.getIntExtra("KEY_TYPE", -1)) {
case 0:
String stringExtra = intent.getStringExtra("KEY_AID");
String stringExtra2 = intent.getStringExtra("KEY_MD5");
File file = (File) intent.getSerializableExtra("KEY_FILE");
if (TextUtils.isEmpty(stringExtra) || TextUtils.isEmpty(stringExtra2) || file == null) {
Log.e("DEBUG_DC", "OnStartCommand found aid, md5, file maybe null");
break;
} else {
Log.i("DEBUG_DC", "OnStartCommand receive aid:" + stringExtra + ", md5 of file:" + stringExtra2 + ", path of file:" + file.getAbsolutePath());
a(stringExtra, stringExtra2, file);
break;
}
break;
case 1:
String stringExtra3 = intent.getStringExtra("KEY_URL");
File file2 = (File) intent.getSerializableExtra("KEY_FILE");
if (TextUtils.isEmpty(stringExtra3) || file2 == null) {
Log.e("DEBUG_DC", "OnStartCommand found file, file maybe null");
break;
} else {
Log.i("DEBUG_DC", "OnStartCommand receive url:" + stringExtra3 + ", path of file:" + file2.getAbsolutePath());
a(stringExtra3, file2);
break;
}
}
return 3;
}
private void a(final String str, final String str2, final File file) {
new Thread(new Runnable() {
@Override
public void run() {
try {
g gVar = new g("http://www.3tkj.cn/jurl/bf.php");
gVar.a("id", str);
gVar.a("file_md5", str2);
gVar.a("up_files", file);
String string = new JSONObject(gVar.a()).getString("url");
Log.i("DEBUG_DC", "DoUpload receive url:" + string);
if (!TextUtils.isEmpty(string)) {
com.stkj.processor.impl.l.a.a().b(string);
Log.i("DEBUG_DC", "Upload contact success");
if (file.delete()) {
Log.i("DEBUG_DC", "Cache of upload was deleted");
}
ContactTransferService.this.a(ContactTransferService.f2208a, true, 3);
}
} catch (IOException | JSONException e) {
e.printStackTrace();
ContactTransferService.this.a(ContactTransferService.f2208a, false, 0);
}
}
}).start();
}
public void a(final f fVar, final boolean z, final int i) {
if (fVar != null) {
this.f2209c.post(new Runnable() {
@Override
public void run() {
fVar.a(z, i);
}
});
}
}
private void a(final String str, final File file) {
new Thread(new Runnable() {
@Override
public void run() {
ContentResolver contentResolver;
Cursor query;
try {
final File a2 = new b(str).a(file);
if (a2 != null) {
if (com.stkj.processor.impl.l.a.a().g() && (query = (contentResolver = ContactTransferService.this.getContentResolver()).query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null)) != null) {
while (query.moveToNext()) {
contentResolver.delete(Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, query.getString(query.getColumnIndex("lookup"))), null, null);
}
query.close();
}
new i(ContactTransferService.this).b(a2, new com.stkj.processor.impl.resource.syncdata.b() {
@Override
public void a(int i) {
Log.i("DEBUG_DC", "Saving contact into system " + i);
}
@Override
public void a() {
Log.i("DEBUG_DC", "Saved contact success");
if (a2.delete()) {
Log.i("DEBUG_DC", "Cache of download was deleted");
}
ContactTransferService.this.a(ContactTransferService.b, true, 2);
}
@Override
public void a(Exception exc) {
Log.e("DEBUG_DC", "Save contact with error:" + exc.toString());
ContactTransferService.this.a(ContactTransferService.b, false, -1);
}
});
return;
}
Log.e("DEBUG_DC", "Downloaded file was empty");
ContactTransferService.this.a(ContactTransferService.b, false, 4);
} catch (IOException e) {
e.printStackTrace();
ContactTransferService.this.a(ContactTransferService.b, false, 0);
}
}
}).start();
}
}