360手机助手 v5.2.50版本的 MD5 值为:087c008db9e518cd556c792742e6830c

以下内容为反编译后的 c.java 源代码,内容仅作参考


package com.qihoo.appstore.utils;

import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import com.qihoo.appstore.R;
import com.qihoo.appstore.stat.StatHelper;
import com.tencent.open.SocialConstants;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;
import org.json.JSONException;
import org.json.JSONObject;

public class c {
    private static String a = "content://com.android.calendar/calendars";
    private static String b = "content://com.android.calendar/events";
    private static String c = "content://com.android.calendar/reminders";
    private static String d = "360appstore";
    private static String e = "mygmailaddress@gmail.com";
    private static String f = "com.android.exchange";
    private static String g = "360手机助手";
    private static long h = 3600000;

    private static long a(Context context) {
        TimeZone timeZone = TimeZone.getDefault();
        ContentValues contentValues = new ContentValues();
        contentValues.put("name", d);
        contentValues.put("account_name", e);
        contentValues.put("account_type", f);
        contentValues.put("calendar_displayName", g);
        contentValues.put("visible", (Integer) 1);
        contentValues.put("calendar_color", (Integer) (-16776961));
        contentValues.put("calendar_access_level", (Integer) 700);
        contentValues.put("sync_events", (Integer) 1);
        contentValues.put("calendar_timezone", timeZone.getID());
        contentValues.put("ownerAccount", e);
        contentValues.put("canOrganizerRespond", (Integer) 0);
        Uri insert = context.getContentResolver().insert(Uri.parse(a).buildUpon().appendQueryParameter("caller_is_syncadapter", "true").appendQueryParameter("account_name", e).appendQueryParameter("account_type", f).build(), contentValues);
        long parseId = insert == null ? -1L : ContentUris.parseId(insert);
        if (com.qihoo.appstore.h.a.a) {
            Log.d("CalendarEventHelper", "add account , id:" + parseId);
        }
        return parseId;
    }

    private static int b(Context context) {
        int c2 = c(context);
        if (c2 >= 0) {
            return c2;
        }
        if (a(context) >= 0) {
            return c(context);
        }
        return -1;
    }

    private static int c(Context context) {
        Cursor query = context.getContentResolver().query(Uri.parse(a), null, null, null, null);
        if (query == null) {
            return -1;
        }
        try {
            if (query.getCount() <= 0) {
                if (query != null) {
                    query.close();
                }
                return -1;
            }
            query.moveToFirst();
            if (com.qihoo.appstore.h.a.a) {
                Log.d("CalendarEventHelper", "already has account :" + query.getString(query.getColumnIndex("_id")));
            }
            int i = query.getInt(query.getColumnIndex("_id"));
            if (query == null) {
                return i;
            }
            query.close();
            return i;
        } finally {
            if (query != null) {
                query.close();
            }
        }
    }

    public static void a(Context context, String str) {
        a(context, a(str));
    }

    public static void a(Context context, com.qihoo.productdatainfo.base.j jVar) {
        int b2 = b(context);
        if (b2 >= 0 && jVar != null) {
            ContentValues contentValues = new ContentValues();
            contentValues.put("title", jVar.b);
            contentValues.put(SocialConstants.PARAM_COMMENT, jVar.d);
            contentValues.put("calendar_id", Integer.valueOf(b2));
            Calendar calendar = Calendar.getInstance();
            try {
                calendar.setTimeInMillis(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(jVar.e).getTime());
            } catch (ParseException e2) {
                e2.printStackTrace();
                try {
                    calendar.setTimeInMillis(Long.parseLong(jVar.e));
                } catch (NumberFormatException e3) {
                    e3.printStackTrace();
                    return;
                }
            }
            long time = calendar.getTime().getTime();
            calendar.setTimeInMillis(h + time);
            long time2 = calendar.getTime().getTime();
            contentValues.put("dtstart", Long.valueOf(time));
            contentValues.put("dtend", Long.valueOf(time2));
            contentValues.put("hasAlarm", (Integer) 1);
            contentValues.put("eventTimezone", "Asia/Shanghai");
            Uri insert = context.getContentResolver().insert(Uri.parse(b), contentValues);
            if (insert != null) {
                ContentValues contentValues2 = new ContentValues();
                contentValues2.put("event_id", Long.valueOf(ContentUris.parseId(insert)));
                contentValues2.put("minutes", (Integer) 10);
                contentValues2.put("method", (Integer) 1);
                if (context.getContentResolver().insert(Uri.parse(c), contentValues2) != null) {
                    StatHelper.e("newgamereserve", com.qihoo.productdatainfo.a.d.o);
                    Toast.makeText(context, context.getString(R.string.reservation_success_tips1), 1).show();
                }
            }
        }
    }

    public static void b(Context context, String str) {
        b(context, a(str));
    }

    public static void b(Context context, com.qihoo.productdatainfo.base.j jVar) {
        if (jVar == null) {
            return;
        }
        Cursor query = context.getContentResolver().query(Uri.parse(b), null, null, null, null);
        if (query == null) {
            if (query != null) {
                return;
            } else {
                return;
            }
        }
        try {
            if (query.getCount() > 0) {
                query.moveToFirst();
                while (!query.isAfterLast()) {
                    String string = query.getString(query.getColumnIndex("title"));
                    if (!TextUtils.isEmpty(jVar.b) && jVar.b.equals(string)) {
                        if (context.getContentResolver().delete(ContentUris.withAppendedId(Uri.parse(b), query.getInt(query.getColumnIndex("_id"))), null, null) == -1) {
                            if (query != null) {
                                query.close();
                                return;
                            }
                            return;
                        }
                        StatHelper.e("newgamereserve", com.qihoo.productdatainfo.a.d.p);
                    }
                    query.moveToNext();
                }
            }
            if (query != null) {
                query.close();
            }
        } finally {
            if (query != null) {
                query.close();
            }
        }
    }

    public static com.qihoo.productdatainfo.base.j a(String str) {
        try {
            JSONObject jSONObject = new JSONObject(str);
            com.qihoo.productdatainfo.base.j jVar = new com.qihoo.productdatainfo.base.j();
            jVar.a = jSONObject.optString("token");
            jVar.b = jSONObject.optString("name");
            jVar.c = jSONObject.optString("logo_url");
            jVar.d = jSONObject.optString(SocialConstants.PARAM_COMMENT);
            jVar.e = jSONObject.optString("online_time");
            jVar.f = jSONObject.optString("online_time_text");
            jVar.g = jSONObject.optString("level");
            jVar.h = jSONObject.optString(SocialConstants.PARAM_URL);
            jVar.i = jSONObject.optInt("is_reserve");
            return jVar;
        } catch (JSONException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public static com.qihoo.productdatainfo.base.j a(com.qihoo.appstore.search.module.app.y yVar) {
        com.qihoo.productdatainfo.base.j jVar = new com.qihoo.productdatainfo.base.j();
        jVar.a = yVar.b;
        jVar.b = yVar.c;
        jVar.c = yVar.d;
        jVar.d = yVar.e;
        jVar.e = yVar.f;
        jVar.g = yVar.g;
        jVar.h = yVar.h;
        jVar.i = yVar.i;
        return jVar;
    }
}