360手机助手 v3.3.0版本的 MD5 值为:127c345ad16bbebee6e347381328afd0

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


package com.qihoo360.mobilesafe.pcdaemon;

import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import com.qihoo.speedometer.Config;
import com.qihoo360.mobilesafe.pcdaemon.data.ACSIITextPdu;
import com.qihoo360.mobilesafe.pcdaemon.data.InputStreamPdu;
import com.qihoo360.mobilesafe.pcdaemon.data.PduBase;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;

public class ai extends r {
    public ai(Context context) {
        super(context);
    }

    private PduBase a() {
        FileOutputStream fileOutputStream;
        Throwable th;
        if (!com.qihoo360.mobilesafe.util.aj.c(this.f)) {
            return ACSIITextPdu.a("RET_GET_ALL_IMAGE:ERR_FAILED:ERR_NOT_FOUND:");
        }
        ArrayList a2 = com.qihoo360.mobilesafe.businesscard.d.d.a(this.f.getContentResolver(), false);
        if (a2.size() <= 0) {
            return new ACSIITextPdu("RET_GET_ALL_IMAGE:ERR_NOT_FOUND:");
        }
        File file = new File(com.qihoo360.mobilesafe.util.aj.d(this.f), "AllImagesInfos.tmp");
        if (file.exists()) {
            file.delete();
        }
        try {
            fileOutputStream = new FileOutputStream(file);
            try {
                try {
                    Iterator it = a2.iterator();
                    while (it.hasNext()) {
                        fileOutputStream.write(((com.qihoo360.mobilesafe.businesscard.d.a.c) it.next()).a().getBytes());
                    }
                    fileOutputStream.flush();
                    ACSIITextPdu aCSIITextPdu = new ACSIITextPdu("RET_GET_ALL_IMAGE:OK:" + file.getPath());
                    if (fileOutputStream == null) {
                        return aCSIITextPdu;
                    }
                    try {
                        fileOutputStream.close();
                        return aCSIITextPdu;
                    } catch (IOException e) {
                        return aCSIITextPdu;
                    }
                } catch (IOException e2) {
                    ACSIITextPdu aCSIITextPdu2 = new ACSIITextPdu("RET_GET_ALL_IMAGE:ERR_FAILED:");
                    if (fileOutputStream == null) {
                        return aCSIITextPdu2;
                    }
                    try {
                        fileOutputStream.close();
                        return aCSIITextPdu2;
                    } catch (IOException e3) {
                        return aCSIITextPdu2;
                    }
                }
            } catch (Throwable th2) {
                th = th2;
                if (fileOutputStream != null) {
                    try {
                        fileOutputStream.close();
                    } catch (IOException e4) {
                    }
                }
                throw th;
            }
        } catch (IOException e5) {
            fileOutputStream = null;
        } catch (Throwable th3) {
            fileOutputStream = null;
            th = th3;
            if (fileOutputStream != null) {
            }
            throw th;
        }
    }

    private PduBase a(Bitmap bitmap, String str, String str2) {
        InputStreamPdu inputStreamPdu;
        if (bitmap == null) {
            return new ACSIITextPdu(str + "ERR_NOT_FOUND:");
        }
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        if (bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream)) {
            inputStreamPdu = new InputStreamPdu(str + "OK:" + str2 + ":PNG:", new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
        } else {
            if (byteArrayOutputStream != null) {
                try {
                    byteArrayOutputStream.close();
                } catch (Exception e) {
                }
            }
            byteArrayOutputStream = new ByteArrayOutputStream();
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
            inputStreamPdu = new InputStreamPdu(str + "OK:" + str2 + ":JPEG:", new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
        }
        try {
            byteArrayOutputStream.close();
            bitmap.recycle();
            return inputStreamPdu;
        } catch (Exception e2) {
            return inputStreamPdu;
        }
    }

    private PduBase a(PduBase pduBase) {
        ACSIITextPdu aCSIITextPdu;
        try {
            String[] split = new String(pduBase.d, com.qihoo360.mobilesafe.a.a.f5314b).split(":");
            if (split.length != 5) {
                aCSIITextPdu = new ACSIITextPdu("RET_SET_AUDIO_TYPE:ERR_FAILED:Invalided parameter,the number of parameter must be 4");
            } else {
                long b2 = com.qihoo360.mobilesafe.util.aj.b(split[1]);
                int b3 = (int) com.qihoo360.mobilesafe.util.aj.b(split[2]);
                int b4 = (int) com.qihoo360.mobilesafe.util.aj.b(split[3]);
                int b5 = (int) com.qihoo360.mobilesafe.util.aj.b(split[4]);
                aCSIITextPdu = b2 <= 0 ? new ACSIITextPdu("RET_SET_AUDIO_TYPE:ERR_FAILED:Invalided music id") : (b3 == 0 || b3 == 1) ? (b4 == 0 || b4 == 1) ? (b5 == 0 || b5 == 1) ? com.qihoo360.mobilesafe.businesscard.d.a.a(this.f.getContentResolver(), b2, b3, b4, b5) ? new ACSIITextPdu("RET_SET_AUDIO_TYPE:OK:") : new ACSIITextPdu("RET_SET_AUDIO_TYPE:ERR_NOT_FOUND:") : new ACSIITextPdu("RET_SET_AUDIO_TYPE:ERR_FAILED:Invalided alarmType,must be 1 or 0") : new ACSIITextPdu("RET_SET_AUDIO_TYPE:ERR_FAILED:Invalided notificationType,must be 1 or 0") : new ACSIITextPdu("RET_SET_AUDIO_TYPE:ERR_FAILED:Invalided ringtoneType,must be 1 or 0");
            }
            return aCSIITextPdu;
        } catch (Exception e) {
            return new ACSIITextPdu("RET_SET_AUDIO_TYPE:ERR_FAILED:" + e.getMessage());
        }
    }

    private PduBase a(PduBase pduBase, String str) {
        PduBase inputStreamPdu;
        try {
            if (TextUtils.isEmpty(str)) {
                inputStreamPdu = new ACSIITextPdu("RET_GET_EBOOK_COVER:ERR_FAILED:Invalided parameter:file path=" + str);
            } else {
                File file = new File(str);
                if (!file.exists()) {
                    inputStreamPdu = new ACSIITextPdu("RET_GET_EBOOK_COVER:ERR_NOT_FOUND:");
                } else if (file.isFile()) {
                    byte[] a2 = com.qihoo360.mobilesafe.businesscard.d.c.a(this.f, file);
                    inputStreamPdu = a2 != null ? new InputStreamPdu("RET_GET_EBOOK_COVER:OK:" + com.qihoo360.mobilesafe.businesscard.d.c.a(file) + ":", new ByteArrayInputStream(a2)) : new ACSIITextPdu("RET_GET_EBOOK_COVER:ERR_NOT_FOUND:");
                } else {
                    inputStreamPdu = new ACSIITextPdu("RET_GET_EBOOK_COVER:RET_ERROR_FILE_IS_DIR:");
                }
            }
            return inputStreamPdu;
        } catch (Exception e) {
            return new ACSIITextPdu("RET_GET_EBOOK_COVER:ERR_FAILED:" + e.getMessage());
        }
    }

    private PduBase b() {
        FileOutputStream fileOutputStream;
        Throwable th;
        ArrayList a2 = com.qihoo360.mobilesafe.businesscard.d.c.a(this.f, this.f.getContentResolver());
        if (a2.size() <= 0) {
            return new ACSIITextPdu("RET_GET_ALL_EBOOK:ERR_NOT_FOUND:");
        }
        File file = new File(com.qihoo360.mobilesafe.util.aj.d(this.f), "AllEbookInfos.tmp");
        if (file.exists()) {
            file.delete();
        }
        try {
            fileOutputStream = new FileOutputStream(file);
            try {
                try {
                    Iterator it = a2.iterator();
                    while (it.hasNext()) {
                        fileOutputStream.write(((com.qihoo360.mobilesafe.businesscard.d.a.b) it.next()).a().getBytes());
                    }
                    fileOutputStream.flush();
                    ACSIITextPdu aCSIITextPdu = new ACSIITextPdu("RET_GET_ALL_EBOOK:OK:" + file.getPath());
                    if (fileOutputStream == null) {
                        return aCSIITextPdu;
                    }
                    try {
                        fileOutputStream.close();
                        return aCSIITextPdu;
                    } catch (IOException e) {
                        return aCSIITextPdu;
                    }
                } catch (IOException e2) {
                    ACSIITextPdu aCSIITextPdu2 = new ACSIITextPdu("RET_GET_ALL_EBOOK:ERR_FAILED:");
                    if (fileOutputStream == null) {
                        return aCSIITextPdu2;
                    }
                    try {
                        fileOutputStream.close();
                        return aCSIITextPdu2;
                    } catch (IOException e3) {
                        return aCSIITextPdu2;
                    }
                }
            } catch (Throwable th2) {
                th = th2;
                if (fileOutputStream != null) {
                    try {
                        fileOutputStream.close();
                    } catch (IOException e4) {
                    }
                }
                throw th;
            }
        } catch (IOException e5) {
            fileOutputStream = null;
        } catch (Throwable th3) {
            fileOutputStream = null;
            th = th3;
            if (fileOutputStream != null) {
            }
            throw th;
        }
    }

    private PduBase b(PduBase pduBase) {
        try {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            byteArrayOutputStream.write("BEGIN: RINGTONE\r\n".getBytes(e));
            byteArrayOutputStream.write("ALARM_ALERT:".getBytes(e));
            Uri a2 = com.qihoo360.mobilesafe.businesscard.d.a.a(this.f, 4);
            if (a2 != null) {
                byteArrayOutputStream.write(a2.toString().getBytes(e));
            }
            byteArrayOutputStream.write("\r\n".getBytes(e));
            byteArrayOutputStream.write("NOTIFICATION:".getBytes(e));
            Uri a3 = com.qihoo360.mobilesafe.businesscard.d.a.a(this.f, 2);
            if (a3 != null) {
                byteArrayOutputStream.write(a3.toString().getBytes(e));
            }
            byteArrayOutputStream.write("\r\n".getBytes(e));
            byteArrayOutputStream.write("RINGTONE:".getBytes(e));
            Uri a4 = com.qihoo360.mobilesafe.businesscard.d.a.a(this.f, 1);
            if (a4 != null) {
                byteArrayOutputStream.write(a4.toString().getBytes(e));
            }
            byteArrayOutputStream.write("\r\n".getBytes(e));
            byteArrayOutputStream.write("END: RINGTONE\r\n".getBytes(e));
            return new InputStreamPdu("RET_GET_RINGTONE:OK:", new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
        } catch (Throwable th) {
            if (d) {
                Log.d("Daemon.MediaBussinessLogic", "doGetRingtone:" + th.getMessage(), th);
            }
            return new ACSIITextPdu("RET_GET_RINGTONE:ERR_FAILED:" + th.getMessage());
        }
    }

    private PduBase b(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.service.a aVar) {
        return new ACSIITextPdu("RET_CAN_UPLOAD_SDCARDEX:OK:");
    }

    private PduBase b(PduBase pduBase, String str) {
        if (TextUtils.isEmpty(str)) {
            return new ACSIITextPdu("RET_GET_AUDIO_ARTWORK:ERR_FAILED:Invalided parameter:audio id=" + str);
        }
        try {
            try {
                InputStream a2 = com.qihoo360.mobilesafe.businesscard.d.a.a(this.f, Long.parseLong(str));
                if (a2 == null) {
                    return new ACSIITextPdu("RET_GET_AUDIO_ARTWORK:ERR_NOT_FOUND:");
                }
                if (a2.available() > 0) {
                    return new InputStreamPdu("RET_GET_AUDIO_ARTWORK:OK:N/A:", a2);
                }
                try {
                    a2.close();
                } catch (Exception e) {
                }
                return new ACSIITextPdu("RET_GET_AUDIO_ARTWORK:ERR_NOT_FOUND:");
            } catch (Throwable th) {
                if (d) {
                    Log.d("Daemon.MediaBussinessLogic", "doGetAudioArtwork:" + th.getMessage(), th);
                }
                return new ACSIITextPdu("RET_GET_AUDIO_ARTWORK:ERR_FAILED:" + th.getMessage());
            }
        } catch (NumberFormatException e2) {
            return new ACSIITextPdu("RET_GET_AUDIO_ARTWORK:ERR_FAILED:Invalided parameter:audio id=" + str);
        }
    }

    private PduBase c(PduBase pduBase) {
        int i;
        try {
            String str = new String(pduBase.d);
            int indexOf = str.indexOf(":");
            int indexOf2 = str.indexOf(":", indexOf + 1);
            String substring = indexOf2 >= 0 ? str.substring(indexOf + 1, indexOf2) : str.substring(indexOf + 1);
            if ("ALARM_ALERT".equals(substring)) {
                i = 4;
            } else if ("NOTIFICATION".equals(substring)) {
                i = 2;
            } else {
                if (!"RINGTONE".equals(substring)) {
                    return new ACSIITextPdu("RET_SET_RINGTONE:ERR_FAILED:Invalid ringtone type");
                }
                i = 1;
            }
            if (indexOf2 < 0) {
                return new ACSIITextPdu("RET_SET_RINGTONE:ERR_FAILED:Invalid ringtone uri");
            }
            return !com.qihoo360.mobilesafe.businesscard.d.a.a(this.f, i, str.substring(indexOf2 + 1)) ? new ACSIITextPdu("RET_SET_RINGTONE:ERR_FAILED:Invalid uri") : new ACSIITextPdu("RET_SET_RINGTONE:OK:");
        } catch (Throwable th) {
            if (d) {
                Log.d("Daemon.MediaBussinessLogic", "doSetRingtone:" + th.getMessage(), th);
            }
            return new ACSIITextPdu("RET_SET_RINGTONE:ERR_FAILED:" + th.getMessage());
        }
    }

    private PduBase c(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.service.a aVar) {
        try {
            return new ACSIITextPdu("RET_IS_NEW_IMAGE_DCIM_COUNT:OK:NEW");
        } catch (Throwable th) {
            return new ACSIITextPdu("RET_IS_NEW_IMAGE_DCIM_COUNT:ERR_FAILED:" + th.getMessage());
        }
    }

    private PduBase c(PduBase pduBase, String str) {
        int i = -1;
        int i2 = 120;
        int i3 = 90;
        try {
            String[] split = str.split(":");
            if (split.length == 1) {
                i = Integer.parseInt(split[0]);
            } else if (split.length == 3) {
                i = Integer.parseInt(split[0]);
                i2 = Integer.parseInt(split[1]);
                i3 = Integer.parseInt(split[2]);
            }
            return a(com.qihoo360.mobilesafe.businesscard.d.e.a(this.f.getContentResolver(), i, i2, i3), "RET_GET_VIDEO_THUMBNAILS:", str);
        } catch (Exception e) {
            return new ACSIITextPdu("RET_GET_VIDEO_THUMBNAILS:ERR_FAILED:" + e.getMessage());
        }
    }

    private PduBase d(PduBase pduBase) {
        try {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            for (com.qihoo360.mobilesafe.businesscard.d.a.d dVar : com.qihoo360.mobilesafe.businesscard.d.a.b(this.f)) {
                byteArrayOutputStream.write("BEGIN:SYSTEM_RINGTONE\r\n".getBytes(e));
                byteArrayOutputStream.write("NAME:".getBytes(e));
                byteArrayOutputStream.write(dVar.i().getBytes(e));
                byteArrayOutputStream.write("\r\n".getBytes(e));
                byteArrayOutputStream.write("SIZE:".getBytes(e));
                byteArrayOutputStream.write(String.valueOf(dVar.j()).getBytes(e));
                byteArrayOutputStream.write("\r\n".getBytes(e));
                byteArrayOutputStream.write("PATH:".getBytes(e));
                byteArrayOutputStream.write(dVar.k().getBytes(e));
                byteArrayOutputStream.write("\r\n".getBytes(e));
                byteArrayOutputStream.write("TYPE:".getBytes(e));
                byteArrayOutputStream.write(dVar.l().getBytes(e));
                byteArrayOutputStream.write("\r\n".getBytes(e));
                byteArrayOutputStream.write("LOCATION:".getBytes(e));
                byteArrayOutputStream.write(dVar.c().getBytes(e));
                byteArrayOutputStream.write("\r\n".getBytes(e));
                byteArrayOutputStream.write("DATA:".getBytes(e));
                byteArrayOutputStream.write(dVar.d().getBytes(e));
                byteArrayOutputStream.write("\r\n".getBytes(e));
                byteArrayOutputStream.write("DURATION:".getBytes(e));
                String e = dVar.e();
                byteArrayOutputStream.write(e != null ? e.getBytes(e) : Config.INVALID_IP.getBytes(e));
                byteArrayOutputStream.write("\r\n".getBytes(e));
                byteArrayOutputStream.write("DISPALY_NAME:".getBytes(e));
                byteArrayOutputStream.write(dVar.f().getBytes(e));
                byteArrayOutputStream.write("\r\n".getBytes(e));
                byteArrayOutputStream.write("ADDED_DATE:".getBytes(e));
                byteArrayOutputStream.write(dVar.g().getBytes(e));
                byteArrayOutputStream.write("\r\n".getBytes(e));
                byteArrayOutputStream.write("END:SYSTEM_RINGTONE\r\n".getBytes(e));
            }
            return new InputStreamPdu("RET_GET_SYSTEM_RINGTONE:OK:", new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
        } catch (Throwable th) {
            if (d) {
                Log.d("Daemon.MediaBussinessLogic", "doGetSystemRingtone:" + th.getMessage(), th);
            }
            return new ACSIITextPdu("RET_GET_SYSTEM_RINGTONE:ERR_FAILED:" + th.getMessage());
        }
    }

    private PduBase d(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.service.a aVar) {
        boolean z = false;
        String str = null;
        try {
            String[] d = pduBase.d();
            if (d != null && d.length > 0) {
                str = d[0];
            }
            if (!TextUtils.isEmpty(str) && "new".equalsIgnoreCase(str)) {
                z = true;
            }
            return new ACSIITextPdu("RET_GET_IMAGE_DCIM_COUNT:OK:" + com.qihoo360.mobilesafe.businesscard.d.d.a(this.f, z));
        } catch (Throwable th) {
            return new ACSIITextPdu("RET_GET_IMAGE_DCIM_COUNT:ERR_FAILED:" + th.getMessage());
        }
    }

    private PduBase d(PduBase pduBase, String str) {
        String str2 = null;
        int i = 120;
        int i2 = 90;
        try {
            String[] split = str.split(":");
            if (split.length == 1) {
                str2 = split[0];
            } else if (split.length == 3) {
                str2 = split[0];
                i = Integer.parseInt(split[1]);
                i2 = Integer.parseInt(split[2]);
            }
            return a(com.qihoo360.mobilesafe.businesscard.d.e.a(str2, i, i2), "RET_GET_VIDEO_THUMBNAILS_PATH:", str);
        } catch (Exception e) {
            return new ACSIITextPdu("RET_GET_VIDEO_THUMBNAILS_PATH:ERR_FAILED:" + e.getMessage());
        }
    }

    private PduBase e(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.service.a aVar) {
        InputStreamPdu inputStreamPdu;
        try {
            String[] d = pduBase.d();
            String str = null;
            if (d != null && d.length > 0) {
                str = d[0];
            }
            if (TextUtils.isEmpty(str)) {
                throw new w("Image ids must not be null");
            }
            String[] split = str.split(",");
            if (split == null) {
                throw new w("Illegal image id list");
            }
            ArrayList arrayList = new ArrayList(split.length);
            for (String str2 : split) {
                long b2 = com.qihoo360.mobilesafe.util.aj.b(str2);
                if (b2 >= 0) {
                    arrayList.add(Long.valueOf(b2));
                }
            }
            if (arrayList.size() <= 0) {
                throw new w("No image id be found");
            }
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                Long l = (Long) it.next();
                Bitmap a2 = com.qihoo360.mobilesafe.businesscard.d.d.a(this.f.getContentResolver(), l.longValue(), 96, 96);
                if (a2 != null) {
                    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                    if (a2.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream)) {
                        inputStreamPdu = new InputStreamPdu("RET_GET_IMAGE_THUMBNAILS2:PROGRESS:OK:" + l + ":PNG:", new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
                    } else {
                        if (byteArrayOutputStream != null) {
                            try {
                                byteArrayOutputStream.close();
                            } catch (Exception e) {
                            }
                        }
                        byteArrayOutputStream = new ByteArrayOutputStream();
                        a2.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
                        inputStreamPdu = new InputStreamPdu("RET_GET_IMAGE_THUMBNAILS2:PROGRESS:OK:" + l + ":JPEG:", new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
                    }
                    try {
                        byteArrayOutputStream.close();
                        a2.recycle();
                    } catch (Exception e2) {
                    }
                    aVar.a(inputStreamPdu);
                } else {
                    aVar.a(new ACSIITextPdu("RET_GET_IMAGE_THUMBNAILS2:PROGRESS:ERR_FAILED:" + l + ":ERR_NOT_FOUND:"));
                }
            }
            return new ACSIITextPdu("RET_GET_IMAGE_THUMBNAILS2:FINISHED:");
        } catch (Throwable th) {
            return new ACSIITextPdu("RET_GET_IMAGE_THUMBNAILS2:ERR_FAILED:" + th.getMessage());
        }
    }

    private PduBase e(PduBase pduBase, String str) {
        int i = -1;
        try {
            int parseInt = Integer.parseInt(str);
            if (parseInt >= 0) {
                i = com.qihoo360.mobilesafe.businesscard.d.d.a(this.f.getContentResolver(), parseInt);
            }
        } catch (Exception e) {
        }
        return i > 0 ? new ACSIITextPdu("RET_DELETE_IMAGE:OK:") : new ACSIITextPdu("RET_DELETE_IMAGE:ERR_FAILED:");
    }

    private PduBase f(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.service.a aVar) {
        InputStreamPdu inputStreamPdu;
        try {
            String[] d = pduBase.d();
            if (d == null || d.length <= 0) {
                throw new w("The number of par must not be 0");
            }
            int parseInt = Integer.parseInt(d[0]);
            Bitmap a2 = com.qihoo360.mobilesafe.businesscard.d.d.a(this.f.getContentResolver(), parseInt, d.length > 1 ? Integer.parseInt(d[1]) : 96, d.length > 2 ? Integer.parseInt(d[2]) : 96);
            if (a2 == null) {
                return new ACSIITextPdu("RET_GET_IMAGE_THUMBNAILS:ERR_NOT_FOUND:");
            }
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            if (a2.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream)) {
                inputStreamPdu = new InputStreamPdu("RET_GET_IMAGE_THUMBNAILS:OK:" + parseInt + ":PNG:", new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
            } else {
                if (byteArrayOutputStream != null) {
                    try {
                        byteArrayOutputStream.close();
                    } catch (Exception e) {
                    }
                }
                byteArrayOutputStream = new ByteArrayOutputStream();
                a2.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
                inputStreamPdu = new InputStreamPdu("RET_GET_IMAGE_THUMBNAILS:OK:" + parseInt + ":JPEG:", new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
            }
            try {
                byteArrayOutputStream.close();
                a2.recycle();
                return inputStreamPdu;
            } catch (Exception e2) {
                return inputStreamPdu;
            }
        } catch (Exception e3) {
            return new ACSIITextPdu("RET_GET_IMAGE_THUMBNAILS:ERR_FAILED:" + e3.getMessage());
        }
    }

    private PduBase f(PduBase pduBase, String str) {
        int i = -1;
        try {
            int parseInt = Integer.parseInt(str);
            if (parseInt >= 0) {
                i = com.qihoo360.mobilesafe.businesscard.d.e.a(this.f.getContentResolver(), parseInt);
            }
        } catch (Exception e) {
        }
        return i > 0 ? new ACSIITextPdu("RET_DELETE_VIDEO:OK:") : new ACSIITextPdu("RET_DELETE_VIDEO:ERR_FAILED:");
    }

    private PduBase g(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.service.a aVar) {
        String f = pduBase.f();
        if (TextUtils.isEmpty(f) || !new File(f).exists() || !new File(f).isFile()) {
            return new ACSIITextPdu("RET_SCAN_MEDIA_FILE:ERR_FAILED:");
        }
        new aj(this, this.f, f, null, aVar);
        return new ACSIITextPdu("RET_SCAN_MEDIA_FILE:STARTING:");
    }

    private PduBase g(PduBase pduBase, String str) {
        int i = -1;
        try {
            int parseInt = Integer.parseInt(str);
            if (parseInt >= 0) {
                i = com.qihoo360.mobilesafe.businesscard.d.a.a(this.f.getContentResolver(), parseInt);
            }
        } catch (Exception e) {
        }
        return i > 0 ? new ACSIITextPdu("RET_DELETE_AUDIO:OK:") : new ACSIITextPdu("RET_DELETE_AUDIO:ERR_FAILED:");
    }

    private PduBase h(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.service.a aVar) {
        int i = Config.HTTP_STATUS_OK;
        try {
            if (!com.qihoo360.mobilesafe.util.aj.b()) {
                return ACSIITextPdu.a("RET_GET_ALL_AUDIO2:ERR_FAILED:ERR_NOT_FOUND:");
            }
            String[] d = pduBase.d();
            int c = d.length >= 1 ? com.qihoo360.mobilesafe.util.aj.c(d[0]) : 200;
            int c2 = d.length >= 2 ? com.qihoo360.mobilesafe.util.aj.c(d[1]) : 1;
            int i2 = c2 >= 0 ? c2 : 0;
            if (c > 0) {
                i = c;
            }
            ArrayList a2 = com.qihoo360.mobilesafe.businesscard.d.a.a(this.f.getContentResolver(), i, i2);
            if (a2.size() <= 0) {
                return ACSIITextPdu.a("RET_GET_ALL_AUDIO2:ERR_FAILED:ERR_NOT_FOUND:");
            }
            StringBuilder sb = new StringBuilder();
            Iterator it = a2.iterator();
            while (it.hasNext()) {
                sb.append(((com.qihoo360.mobilesafe.businesscard.d.a.a) it.next()).a());
            }
            return InputStreamPdu.a("RET_GET_ALL_AUDIO2:OK:", new ByteArrayInputStream(sb.toString().getBytes(com.qihoo360.mobilesafe.a.a.f5314b)));
        } catch (Exception e) {
            return ACSIITextPdu.a("RET_GET_ALL_AUDIO2:ERR_FAILED:" + e.getClass().getSimpleName() + "(" + e.getMessage() + ")");
        }
    }

    private PduBase i(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.service.a aVar) {
        FileOutputStream fileOutputStream;
        try {
            if (!com.qihoo360.mobilesafe.util.aj.c(this.f)) {
                return ACSIITextPdu.a("RET_GET_ALL_VIDEO:ERR_FAILED:ERR_NOT_FOUND:");
            }
            String[] d = pduBase.d();
            boolean equals = (d == null || d.length <= 0) ? false : TextUtils.equals("GET_EXT_FILE", d[0]);
            String[] split = (d == null || d.length <= 1 || TextUtils.isEmpty(d[1])) ? null : d[1].split(";");
            String[] split2 = (d == null || d.length <= 2 || TextUtils.isEmpty(d[2])) ? null : d[2].split(";");
            ArrayList a2 = com.qihoo360.mobilesafe.businesscard.d.e.a(this.f, this.f.getContentResolver(), equals);
            com.qihoo360.mobilesafe.businesscard.d.e.a(a2, split2, split);
            if (a2.size() <= 0) {
                throw new w("ERR_NOT_FOUND:");
            }
            StringBuilder sb = new StringBuilder();
            Iterator it = a2.iterator();
            while (it.hasNext()) {
                sb.append(((com.qihoo360.mobilesafe.businesscard.d.a.e) it.next()).a());
            }
            File file = new File(com.qihoo360.mobilesafe.util.aj.d(this.f), "AllVideoInfos.tmp");
            if (file.exists()) {
                file.delete();
            }
            try {
                fileOutputStream = new FileOutputStream(file);
                try {
                    try {
                        fileOutputStream.write(sb.toString().getBytes());
                        fileOutputStream.flush();
                        ACSIITextPdu aCSIITextPdu = new ACSIITextPdu("RET_GET_ALL_VIDEO:OK:" + file.getPath());
                        if (fileOutputStream == null) {
                            return aCSIITextPdu;
                        }
                        try {
                            fileOutputStream.close();
                            return aCSIITextPdu;
                        } catch (IOException e) {
                            return aCSIITextPdu;
                        }
                    } catch (IOException e2) {
                        e = e2;
                        throw new w(e);
                    }
                } catch (Throwable th) {
                    th = th;
                    if (fileOutputStream != null) {
                        try {
                            fileOutputStream.close();
                        } catch (IOException e3) {
                        }
                    }
                    throw th;
                }
            } catch (IOException e4) {
                e = e4;
                fileOutputStream = null;
            } catch (Throwable th2) {
                th = th2;
                fileOutputStream = null;
                if (fileOutputStream != null) {
                }
                throw th;
            }
        } catch (Exception e5) {
            return new ACSIITextPdu("RET_GET_ALL_VIDEO:" + e5.getMessage());
        }
    }

    private PduBase j(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.service.a aVar) {
        int i = Config.HTTP_STATUS_OK;
        try {
            if (!com.qihoo360.mobilesafe.util.aj.b()) {
                return ACSIITextPdu.a("RET_GET_ALL_IMAGE2:ERR_FAILED:ERR_NOT_FOUND:");
            }
            String[] d = pduBase.d();
            int c = d.length >= 1 ? com.qihoo360.mobilesafe.util.aj.c(d[0]) : 200;
            int c2 = d.length >= 2 ? com.qihoo360.mobilesafe.util.aj.c(d[1]) : 1;
            int i2 = c2 >= 0 ? c2 : 0;
            if (c > 0) {
                i = c;
            }
            ArrayList a2 = com.qihoo360.mobilesafe.businesscard.d.d.a(this.f.getContentResolver(), i, i2);
            if (a2.size() <= 0) {
                return ACSIITextPdu.a("RET_GET_ALL_IMAGE2:ERR_FAILED:ERR_NOT_FOUND:");
            }
            StringBuilder sb = new StringBuilder();
            Iterator it = a2.iterator();
            while (it.hasNext()) {
                sb.append(((com.qihoo360.mobilesafe.businesscard.d.a.c) it.next()).a());
            }
            return InputStreamPdu.a("RET_GET_ALL_IMAGE2:OK:", new ByteArrayInputStream(sb.toString().getBytes(com.qihoo360.mobilesafe.a.a.f5314b)));
        } catch (Exception e) {
            return ACSIITextPdu.a("RET_GET_ALL_IMAGE2:ERR_FAILED:" + e.getClass().getSimpleName() + "(" + e.getMessage() + ")");
        }
    }

    private PduBase k(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.service.a aVar) {
        FileOutputStream fileOutputStream;
        try {
            if (!com.qihoo360.mobilesafe.util.aj.c(this.f)) {
                return ACSIITextPdu.a("RET_GET_ALL_AUDIO:ERR_FAILED:ERR_NOT_FOUND:");
            }
            String[] d = pduBase.d();
            String[] split = (d == null || d.length <= 0 || TextUtils.isEmpty(d[0])) ? null : d[0].split(";");
            String[] split2 = (d == null || d.length <= 1 || TextUtils.isEmpty(d[1])) ? null : d[1].split(";");
            ArrayList a2 = com.qihoo360.mobilesafe.businesscard.d.a.a(this.f.getContentResolver());
            com.qihoo360.mobilesafe.businesscard.d.a.a(a2, split2, split);
            if (a2.size() <= 0) {
                throw new w("ERR_NOT_FOUND:");
            }
            File file = new File(com.qihoo360.mobilesafe.util.aj.d(this.f), "AllAudioInfos.tmp");
            if (file.exists()) {
                file.delete();
            }
            try {
                fileOutputStream = new FileOutputStream(file);
                try {
                    try {
                        Iterator it = a2.iterator();
                        while (it.hasNext()) {
                            fileOutputStream.write(((com.qihoo360.mobilesafe.businesscard.d.a.a) it.next()).a().getBytes());
                        }
                        fileOutputStream.flush();
                        ACSIITextPdu aCSIITextPdu = new ACSIITextPdu("RET_GET_ALL_AUDIO:OK:" + file.getPath());
                        if (fileOutputStream == null) {
                            return aCSIITextPdu;
                        }
                        try {
                            fileOutputStream.close();
                            return aCSIITextPdu;
                        } catch (IOException e) {
                            return aCSIITextPdu;
                        }
                    } catch (Throwable th) {
                        th = th;
                        if (fileOutputStream != null) {
                            try {
                                fileOutputStream.close();
                            } catch (IOException e2) {
                            }
                        }
                        throw th;
                    }
                } catch (IOException e3) {
                    e = e3;
                    throw new w(e);
                }
            } catch (IOException e4) {
                e = e4;
            } catch (Throwable th2) {
                th = th2;
                fileOutputStream = null;
            }
        } catch (Exception e5) {
            return new ACSIITextPdu("RET_GET_ALL_AUDIO:ERR_FAILED:" + e5.getMessage());
        }
    }

    public PduBase a(PduBase pduBase, com.qihoo360.mobilesafe.pcdaemon.service.a aVar) {
        PduBase b2;
        PduBase d;
        PduBase c;
        PduBase a2;
        PduBase a3;
        PduBase d2;
        PduBase c2;
        PduBase b3;
        PduBase b4;
        PduBase d3;
        PduBase c3;
        PduBase g;
        PduBase e;
        PduBase f;
        PduBase g2;
        PduBase i;
        PduBase j;
        PduBase a4;
        PduBase b5;
        PduBase h;
        PduBase k;
        switch (pduBase.c) {
            case 1:
                String e2 = pduBase.e();
                String f2 = pduBase.f();
                if ("CMD_GET_ALL_AUDIO".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_GET_ALL_AUDIO") {
                        k = k(pduBase, aVar);
                    }
                    return k;
                }
                if ("CMD_GET_ALL_AUDIO2".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_GET_ALL_AUDIO2") {
                        h = h(pduBase, aVar);
                    }
                    return h;
                }
                if ("CMD_GET_ALL_EBOOK".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_GET_ALL_EBOOK") {
                        b5 = b();
                    }
                    return b5;
                }
                if ("CMD_GET_ALL_IMAGE".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_GET_ALL_IMAGE") {
                        a4 = a();
                    }
                    return a4;
                }
                if ("CMD_GET_ALL_IMAGE2".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_GET_ALL_IMAGE2") {
                        j = j(pduBase, aVar);
                    }
                    return j;
                }
                if ("CMD_GET_ALL_VIDEO".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_GET_ALL_IMAGE") {
                        i = i(pduBase, aVar);
                    }
                    return i;
                }
                if ("CMD_DELETE_AUDIO".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_DELETE_AUDIO") {
                        g2 = g(pduBase, f2);
                    }
                    return g2;
                }
                if ("CMD_DELETE_VIDEO".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_DELETE_VIDEO") {
                        f = f(pduBase, f2);
                    }
                    return f;
                }
                if ("CMD_DELETE_IMAGE".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_DELETE_IMAGE") {
                        e = e(pduBase, f2);
                    }
                    return e;
                }
                if ("CMD_SCAN_MEDIA_FILE".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_SCAN_MEDIA_FILE") {
                        g = g(pduBase, aVar);
                    }
                    return g;
                }
                if ("CMD_GET_IMAGE_THUMBNAILS".equalsIgnoreCase(e2)) {
                    return f(pduBase, aVar);
                }
                if ("CMD_GET_VIDEO_THUMBNAILS".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_GET_VIDEO_THUMBNAILS") {
                        c3 = c(pduBase, f2);
                    }
                    return c3;
                }
                if ("CMD_GET_VIDEO_THUMBNAILS_PATH".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_GET_VIDEO_THUMBNAILS_PATH") {
                        d3 = d(pduBase, f2);
                    }
                    return d3;
                }
                if ("CMD_GET_AUDIO_ARTWORK".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_GET_AUDIO_ARTWORK") {
                        b4 = b(pduBase, f2);
                    }
                    return b4;
                }
                if ("CMD_GET_RINGTONE".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_GET_RINGTONE") {
                        b3 = b(pduBase);
                    }
                    return b3;
                }
                if ("CMD_SET_RINGTONE".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_SET_RINGTONE") {
                        c2 = c(pduBase);
                    }
                    return c2;
                }
                if ("CMD_GET_SYSTEM_RINGTONE".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_GET_SYSTEM_RINGTONE") {
                        d2 = d(pduBase);
                    }
                    return d2;
                }
                if ("CMD_GET_EBOOK_COVER".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_GET_EBOOK_COVER") {
                        a3 = a(pduBase, f2);
                    }
                    return a3;
                }
                if ("CMD_SET_AUDIO_TYPE".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_SET_AUDIO_TYPE") {
                        a2 = a(pduBase);
                    }
                    return a2;
                }
                if ("CMD_GET_IMAGE_THUMBNAILS2".equalsIgnoreCase(e2)) {
                    return e(pduBase, aVar);
                }
                if ("CMD_IS_NEW_IMAGE_DCIM_COUNT".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_IS_NEW_IMAGE_DCIM_COUNT") {
                        c = c(pduBase, aVar);
                    }
                    return c;
                }
                if ("CMD_GET_IMAGE_DCIM_COUNT".equalsIgnoreCase(e2)) {
                    synchronized ("CMD_GET_IMAGE_DCIM_COUNT") {
                        d = d(pduBase, aVar);
                    }
                    return d;
                }
                if (!"CMD_CAN_UPLOAD_SDCARDEX".equalsIgnoreCase(e2)) {
                    return new ACSIITextPdu("ERR_FAILED:");
                }
                synchronized ("CMD_CAN_UPLOAD_SDCARDEX") {
                    b2 = b(pduBase, aVar);
                }
                return b2;
            default:
                return null;
        }
    }

    public boolean a(String str) {
        return "CMD_GET_ALL_AUDIO".equalsIgnoreCase(str) || "CMD_GET_ALL_EBOOK".equalsIgnoreCase(str) || "CMD_GET_ALL_IMAGE".equalsIgnoreCase(str) || "CMD_GET_ALL_VIDEO".equalsIgnoreCase(str) || "CMD_GET_AUDIO_ARTWORK".equalsIgnoreCase(str) || "CMD_GET_IMAGE_THUMBNAILS".equalsIgnoreCase(str) || "CMD_GET_VIDEO_THUMBNAILS".equalsIgnoreCase(str) || "CMD_DELETE_AUDIO".equalsIgnoreCase(str) || "CMD_DELETE_IMAGE".equalsIgnoreCase(str) || "CMD_DELETE_VIDEO".equalsIgnoreCase(str) || "CMD_SCAN_MEDIA_FILE".equalsIgnoreCase(str) || "CMD_GET_RINGTONE".equalsIgnoreCase(str) || "CMD_SET_RINGTONE".equalsIgnoreCase(str) || "CMD_GET_SYSTEM_RINGTONE".equalsIgnoreCase(str) || "CMD_SET_AUDIO_TYPE".equalsIgnoreCase(str) || "CMD_GET_IMAGE_DCIM_COUNT".equalsIgnoreCase(str) || "CMD_CAN_UPLOAD_SDCARDEX".equalsIgnoreCase(str) || "CMD_GET_VIDEO_THUMBNAILS_PATH".equalsIgnoreCase(str) || "CMD_IS_NEW_IMAGE_DCIM_COUNT".equalsIgnoreCase(str);
    }
}