Browse Source

增加源码

liuyuqi-dellpc 3 years ago
parent
commit
eed5f4f9a6
82 changed files with 21818 additions and 6 deletions
  1. 1 1
      app/src/main/java/com/epson/memcardacc/LocalProgressDialogFragment.java
  2. 1 1
      app/src/main/java/com/epson/mobilephone/common/wifidirect/DialogProgressWiFiDirect.java
  3. 15 0
      app/src/main/java/com/epson/p007sd/common/apf/EpsonColorLogoList.java
  4. 78 0
      app/src/main/java/com/epson/p007sd/common/apf/apflib.java
  5. 1 1
      app/src/main/java/epson/common/DialogProgress.java
  6. 1 1
      app/src/main/java/epson/common/wifidirect/DialogProgressWiFiDirect.java
  7. 2 1
      app/src/main/java/epson/epsonconnectregistration/ECConfigurationTask.java
  8. 160 0
      app/src/main/java/epson/maintain/BatteryInfoAdapter.java
  9. 563 0
      app/src/main/java/epson/maintain/EfuReader.java
  10. 191 0
      app/src/main/java/epson/maintain/FirmInfFile.java
  11. 1158 0
      app/src/main/java/epson/maintain/FirmwareManager.java
  12. 51 0
      app/src/main/java/epson/maintain/activity/CheckEulaActivity.java
  13. 305 0
      app/src/main/java/epson/maintain/activity/EccPrintLog.java
  14. 16 0
      app/src/main/java/epson/maintain/activity/EccPrintLogException.java
  15. 17 0
      app/src/main/java/epson/maintain/activity/EccPrintLogViewModel.java
  16. 426 0
      app/src/main/java/epson/maintain/activity/FirmwareUpdateActivity.java
  17. 609 0
      app/src/main/java/epson/maintain/activity/GetPrinterReplyData.java
  18. 43 0
      app/src/main/java/epson/maintain/activity/LogUrl.java
  19. 1953 0
      app/src/main/java/epson/maintain/activity/MaintainActivity.java
  20. 94 0
      app/src/main/java/epson/maintain/activity/MaintainBuyInkOnlineRegTask.java
  21. 1312 0
      app/src/main/java/epson/maintain/activity/MaintainPrinterSearchActivity.java
  22. 47 0
      app/src/main/java/epson/maintain/activity/NozzleGuidanceDialog.java
  23. 31 0
      app/src/main/java/epson/maintain/activity/PrinterNotFoundDialogCreator.java
  24. 1 1
      app/src/main/java/epson/print/storage/ConfirmCancelDialog.java
  25. 72 0
      app/src/main/java/epson/provider/IAFileProvider.java
  26. 4 0
      app/src/main/java/epson/provider/ScannedFileProvider.java
  27. 414 0
      app/src/main/java/epson/provider/SharedPreferencesProvider.java
  28. 16 0
      app/src/main/java/epson/scan/activity/$$Lambda$ScanContinueParam$O5_W7A8WVuIPQG0HgQ75RE2hUc.java
  29. 61 0
      app/src/main/java/epson/scan/activity/CustomButtonWrapper.java
  30. 175 0
      app/src/main/java/epson/scan/activity/DisplayIdConverter.java
  31. 138 0
      app/src/main/java/epson/scan/activity/I2DoubleSideScanSettingActivity.java
  32. 878 0
      app/src/main/java/epson/scan/activity/I2ScanActivity.java
  33. 526 0
      app/src/main/java/epson/scan/activity/I2ScanAreaView.java
  34. 480 0
      app/src/main/java/epson/scan/activity/I2ScanSettingActivity.java
  35. 68 0
      app/src/main/java/epson/scan/activity/I2SettingDetailActivity.java
  36. 138 0
      app/src/main/java/epson/scan/activity/InputUnitSettingActivity.java
  37. 9 0
      app/src/main/java/epson/scan/activity/LocalListAdapterBuilder.java
  38. 207 0
      app/src/main/java/epson/scan/activity/MailActivity.java
  39. 101 0
      app/src/main/java/epson/scan/activity/ModeListAdapter.java
  40. 2010 0
      app/src/main/java/epson/scan/activity/ScanActivity.java
  41. 53 0
      app/src/main/java/epson/scan/activity/ScanActivityCommonParams.java
  42. 897 0
      app/src/main/java/epson/scan/activity/ScanBaseView.java
  43. 126 0
      app/src/main/java/epson/scan/activity/ScanContinueParam.java
  44. 30 0
      app/src/main/java/epson/scan/activity/ScanCount.java
  45. 1105 0
      app/src/main/java/epson/scan/activity/ScanSearchActivity.java
  46. 644 0
      app/src/main/java/epson/scan/activity/ScanSettingsActivity.java
  47. 110 0
      app/src/main/java/epson/scan/activity/ScanSettingsAdvanceDensityActivity.java
  48. 165 0
      app/src/main/java/epson/scan/activity/ScanSettingsAdvanceDetailActivity.java
  49. 223 0
      app/src/main/java/epson/scan/activity/ScanSettingsDetailActivity.java
  50. 84 0
      app/src/main/java/epson/scan/activity/ScanSettingsDetailAdapter.java
  51. 69 0
      app/src/main/java/epson/scan/activity/ScannerListAdapter.java
  52. 145 0
      app/src/main/java/epson/scan/activity/ScannerPropertyWrapper.java
  53. 65 0
      app/src/main/java/epson/scan/activity/SettingActivityParams.java
  54. 63 0
      app/src/main/java/epson/scan/activity/StringListAdapter.java
  55. 517 0
      app/src/main/java/epson/scan/i2lib/I2ScanParamArbiter.java
  56. 319 0
      app/src/main/java/epson/scan/i2lib/I2ScanParamManager.java
  57. 592 0
      app/src/main/java/epson/scan/i2lib/I2ScanTask.java
  58. 257 0
      app/src/main/java/epson/scan/i2lib/ImageProcessController.java
  59. 112 0
      app/src/main/java/epson/scan/i2lib/ImageProcessThread.java
  60. 54 0
      app/src/main/java/epson/scan/lib/CancelableFind.java
  61. 79 0
      app/src/main/java/epson/scan/lib/CancelablePropertyTaker.java
  62. 387 0
      app/src/main/java/epson/scan/lib/CancelableScannerProbe.java
  63. 24 0
      app/src/main/java/epson/scan/lib/EscanLibException.java
  64. 37 0
      app/src/main/java/epson/scan/lib/EscanLibInterface.java
  65. 10 0
      app/src/main/java/epson/scan/lib/I1ScanParams.java
  66. 94 0
      app/src/main/java/epson/scan/lib/ScanCommonParams.java
  67. 130 0
      app/src/main/java/epson/scan/lib/ScanInfoStorage.java
  68. 217 0
      app/src/main/java/epson/scan/lib/ScanSettingHelper.java
  69. 148 0
      app/src/main/java/epson/scan/lib/ScanSizeHelper.java
  70. 17 0
      app/src/main/java/epson/scan/lib/ScannerConnection.java
  71. 386 0
      app/src/main/java/epson/scan/lib/ScannerInfo.java
  72. 502 0
      app/src/main/java/epson/scan/lib/escanLib.java
  73. 29 0
      app/src/main/java/epson/scan/lib/libHaru.java
  74. 253 0
      app/src/main/java/epson/server/screens/StorageServer.java
  75. 521 0
      app/src/main/java/epson/server/screens/UploadScreen.java
  76. 25 0
      app/src/main/java/epson/server/service/EvernoteClient.java
  77. 53 0
      app/src/main/java/epson/server/utils/Define.java
  78. 141 0
      app/src/main/java/epson/server/utils/MyUtility.java
  79. 73 0
      app/src/main/java/epson/server/utils/NetworkConnectivityListener.java
  80. 501 0
      app/src/main/java/epson/support/DeviceInformationActivity.java
  81. 28 0
      app/src/main/java/epson/support/SupportAboutActivity.java
  82. 160 0
      app/src/main/java/epson/support/SupportActivity.java

+ 1 - 1
app/src/main/java/com/epson/memcardacc/LocalProgressDialogFragment.java

@@ -5,7 +5,7 @@ import android.os.Bundle;
 
 import android.support.annotation.Nullable;
 import android.support.p000v4.app.DialogFragment;
-import android.support.p003v7.app.AlertDialog;
+
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.TextView;

+ 1 - 1
app/src/main/java/com/epson/mobilephone/common/wifidirect/DialogProgressWiFiDirect.java

@@ -7,7 +7,7 @@ import android.os.Bundle;
 import android.support.annotation.Nullable;
 import android.support.p000v4.app.DialogFragment;
 import android.support.p000v4.app.FragmentManager;
-import android.support.p003v7.app.AlertDialog;
+
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ProgressBar;

+ 15 - 0
app/src/main/java/com/epson/p007sd/common/apf/EpsonColorLogoList.java

@@ -0,0 +1,15 @@
+package com.epson.p007sd.common.apf;
+
+/* renamed from: com.epson.sd.common.apf.EpsonColorLogoList */
+public class EpsonColorLogoList {
+    private static final String[] DeviceIDList = {"PM-A950", "PM-A890", "PM-D800", "PM-G730", "E-150", "PX-G930", "PM-T990", "PM-A970", "PM-A920", "PM-A820", "PM-D870", "E-700", "E-500", "E-300", "PM-G850", "PM-G4500", "PX-G5100", "PM-T960", "PM-A940", "PM-A840", "PM-G860", "E-720", "E-520", "PX-G5300", "EP-901F", "EP-901A", "EP-801A", "PM-A840S", "EP-301", "E-530", "E-330", "EP-902A", "EP-802A", "EP-702A", "EP-302", "E-800", "E-600", "E-330S", "EP-903F", "EP-903A", "EP-803A", "EP-803AW", "EP-703A", "E-810", "E-340", "EP-904F", "EP-904A", "EP-804A", "EP-774A", "EP-704A", "E-820", "E-350", "PX-7V", "EP-4004", "EP-905F Series", "EP-905A Series", "EP-805A Series", "EP-775A Series", "E-830 Series", "E-360 Series", "EP-976A3 Series", "EP-906F Series", "EP-806A Series", "EP-776A Series", "EP-706A Series", "EP-306 Series", "E-840 Series", "E-370 Series", "EP-977A3 Series", "EP-907F Series", "EP-807A Series", "EP-777A Series", "EP-707A Series", "E-850 Series", "EP-978A3 Series", "EP-808A Series", "EP-708A Series", "EP-10VA Series", "PF-71 Series", "PF-81 Series", "SC-PX7V2", "EP-979A3 Series", "EP-879A Series", "EP-709A Series", "EP-30VA Series", "EW-M770T Series", "EW-M970A3T Series", "EP-880A Series", "EP-50V Series", "EP-710A Series", "EP-810A Series", "EP-881A Series", "EP-711A Series", "EP-811A Series", "EP-882A Series", "EP-712A Series", "EP-812A Series", "EP-982A3 Series", "EW-M752T Series", "EP-M552T Series"};
+    private static final Integer[] MediaTypeIDList = {5, 6, 8, 11, 12, 13, 15, 16, 24, 25, 38, 39, 41, 43, 44, 52, 60};
+
+    public static Integer[] getMediatypeidlist() {
+        return MediaTypeIDList;
+    }
+
+    public static String[] getDeviceIDList() {
+        return DeviceIDList;
+    }
+}

+ 78 - 0
app/src/main/java/com/epson/p007sd/common/apf/apflib.java

@@ -0,0 +1,78 @@
+package com.epson.p007sd.common.apf;
+
+import android.media.ExifInterface;
+import java.io.IOException;
+import java.util.Arrays;
+
+/* renamed from: com.epson.sd.common.apf.apflib */
+public class apflib {
+    public static final int EPS_APF_INCREMENT_OF_CORRECTION_VALUE = 10;
+    public static final int EPS_APF_SHRPNESS_OPTIMUN_VALUE = 30;
+    private static final int EPS_CM_COLOR = 0;
+
+    private native int autoCorrectFile(String str, int i, String str2, String str3, boolean z, boolean z2, boolean z3);
+
+    private native int autoCorrectFileWithValue(String str, int i, String str2, String str3, boolean z, boolean z2, int i2, int i3, int i4);
+
+    private native void setInterruptionFlg();
+
+    static {
+        System.loadLibrary("apf");
+    }
+
+    public boolean apfFile(String str, int i, String str2, String str3) {
+        if (isEmpty(str2) || isEmpty(str3) || i > 8) {
+            return false;
+        }
+        if (autoCorrectFile(str, i < 0 ? exifOrientation(str) : i, str2, str3, true, false, false) == 0) {
+            return true;
+        }
+        return false;
+    }
+
+    public boolean apfFile(String str, int i, String str2, String str3, boolean z, boolean z2, boolean z3) {
+        int i2 = i;
+        if (isEmpty(str2) || isEmpty(str3) || i2 > 8 || (!z && !z2)) {
+            return false;
+        }
+        if (autoCorrectFile(str, i2 < 0 ? exifOrientation(str) : i2, str2, str3, z, z2, z3) == 0) {
+            return true;
+        }
+        return false;
+    }
+
+    public boolean apfFile(String str, int i, String str2, String str3, boolean z, boolean z2, int i2, int i3, int i4) {
+        int i5 = i;
+        int i6 = i2;
+        if (isEmpty(str2) || isEmpty(str3) || i5 > 8 || ((!z && !z2) || (z2 && (i6 > 127 || i6 < -128)))) {
+            return false;
+        }
+        if (autoCorrectFileWithValue(str, i5 < 0 ? exifOrientation(str) : i5, str2, str3, z, z2, i2, i3, i4) == 0) {
+            return true;
+        }
+        return false;
+    }
+
+    public int exifOrientation(String str) {
+        try {
+            return new ExifInterface(str).getAttributeInt(android.support.media.ExifInterface.TAG_ORIENTATION, 0);
+        } catch (IOException unused) {
+            return 0;
+        }
+    }
+
+    public void interrupt() {
+        setInterruptionFlg();
+    }
+
+    public boolean isDspEpsonColorLogo(String str, int i, int i2, boolean z) {
+        if (z && i2 == 0 && Arrays.asList(EpsonColorLogoList.getMediatypeidlist()).contains(Integer.valueOf(i)) && Arrays.asList(EpsonColorLogoList.getDeviceIDList()).contains(str)) {
+            return true;
+        }
+        return false;
+    }
+
+    private static boolean isEmpty(String str) {
+        return str == null || str.length() == 0;
+    }
+}

+ 1 - 1
app/src/main/java/epson/common/DialogProgress.java

@@ -7,7 +7,7 @@ import android.os.Bundle;
 import android.support.annotation.Nullable;
 import android.support.p000v4.app.DialogFragment;
 import android.support.p000v4.app.FragmentManager;
-import android.support.p003v7.app.AlertDialog;
+
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ProgressBar;

+ 1 - 1
app/src/main/java/epson/common/wifidirect/DialogProgressWiFiDirect.java

@@ -7,7 +7,7 @@ import android.os.Bundle;
 import android.support.annotation.Nullable;
 import android.support.p000v4.app.DialogFragment;
 import android.support.p000v4.app.FragmentManager;
-import android.support.p003v7.app.AlertDialog;
+
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ProgressBar;

+ 2 - 1
app/src/main/java/epson/epsonconnectregistration/ECConfigurationTask.java

@@ -4,11 +4,12 @@ import android.app.Activity;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.net.Uri;
-import android.support.p003v7.app.AlertDialog;
+
 import android.util.Xml;
 import android.view.View;
 import com.epson.mobilephone.common.EpLog;
 import epson.common.httpclient.IAHttpClient;
+import epson.print.R;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;

+ 160 - 0
app/src/main/java/epson/maintain/BatteryInfoAdapter.java

@@ -0,0 +1,160 @@
+package epson.maintain;
+
+import android.app.Activity;
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.ListAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+import epson.print.C2135R;
+import java.util.ArrayList;
+
+public class BatteryInfoAdapter extends ArrayAdapter<BatteryInfoList> {
+    private LayoutInflater mInflater;
+    private ArrayList<BatteryInfoList> mItems;
+    private int mResourceId;
+
+    public boolean isEnabled(int i) {
+        return false;
+    }
+
+    public BatteryInfoAdapter(Context context, int i, ArrayList<BatteryInfoList> arrayList) {
+        super(context, i, arrayList);
+        this.mResourceId = i;
+        this.mItems = arrayList;
+        this.mInflater = (LayoutInflater) context.getSystemService("layout_inflater");
+    }
+
+    public View getView(int i, View view, ViewGroup viewGroup) {
+        if (view == null) {
+            view = this.mInflater.inflate(this.mResourceId, (ViewGroup) null);
+        }
+        BatteryInfoList batteryInfoList = this.mItems.get(i);
+        ((TextView) view.findViewById(C2135R.C2137id.bt_name)).setText(batteryInfoList.getBatteryName());
+        ((TextView) view.findViewById(C2135R.C2137id.bt_percentage)).setText(batteryInfoList.getBatteryStatusPercentage());
+        ((ImageView) view.findViewById(C2135R.C2137id.bt_status_icon)).setImageResource(batteryInfoList.getBatteryStatusIcon());
+        return view;
+    }
+
+    static class BatteryInfoList {
+        private String mBatteryName = null;
+        private String mBatteryPercentage = null;
+        private int mBatteryStatusIcon = 0;
+
+        BatteryInfoList() {
+        }
+
+        /* access modifiers changed from: package-private */
+        public String getBatteryName() {
+            return this.mBatteryName;
+        }
+
+        /* access modifiers changed from: package-private */
+        public void setBatteryStatusName(String str) {
+            this.mBatteryName = str;
+        }
+
+        /* access modifiers changed from: package-private */
+        public String getBatteryStatusPercentage() {
+            return this.mBatteryPercentage;
+        }
+
+        /* access modifiers changed from: package-private */
+        public void setBatteryStatusPercentage(String str) {
+            this.mBatteryPercentage = str;
+        }
+
+        /* access modifiers changed from: package-private */
+        public int getBatteryStatusIcon() {
+            return this.mBatteryStatusIcon;
+        }
+
+        /* access modifiers changed from: package-private */
+        public void setBatteryStatusIcon(int i) {
+            this.mBatteryStatusIcon = i;
+        }
+    }
+
+    public static class BatteryInfoManager {
+        static boolean batteryIsUnknown(int i, int i2) {
+            return i == 0 || i2 == 2;
+        }
+
+        public static void showBatteryList(Activity activity, int i, int i2, int[] iArr, int[] iArr2) {
+            ArrayList arrayList = new ArrayList();
+            for (int i3 = 0; i3 < i; i3++) {
+                BatteryInfoList batteryInfoList = new BatteryInfoList();
+                setBatteryName(activity, batteryInfoList, i, i3);
+                setBatteryPercentage(activity, batteryInfoList, i2, iArr[i3], iArr2[i3]);
+                setBatteryIcon(activity, batteryInfoList, i2, iArr[i3], iArr2[i3]);
+                arrayList.add(batteryInfoList);
+            }
+            showListView(activity, new BatteryInfoAdapter(activity, C2135R.layout.maintain_battery_info, arrayList));
+        }
+
+        public static void clearBatteryList(Activity activity) {
+            activity.findViewById(C2135R.C2137id.bt_PowerText).setVisibility(8);
+            showListView(activity, (BatteryInfoAdapter) null);
+        }
+
+        static void setBatteryName(Context context, BatteryInfoList batteryInfoList, int i, int i2) {
+            int i3 = i2 + 1;
+            if (i == 1) {
+                batteryInfoList.setBatteryStatusName(context.getString(C2135R.string.bi_remain));
+                return;
+            }
+            batteryInfoList.setBatteryStatusName(context.getString(C2135R.string.bi_remain) + " " + i3);
+        }
+
+        static void setBatteryPercentage(Context context, BatteryInfoList batteryInfoList, int i, int i2, int i3) {
+            if (batteryIsUnknown(i, i2)) {
+                return;
+            }
+            if (i3 < 0 || i3 > 100) {
+                batteryInfoList.setBatteryStatusPercentage(context.getString(C2135R.string.bi_no_percentage));
+                return;
+            }
+            batteryInfoList.setBatteryStatusPercentage(i3 + " %");
+        }
+
+        static void setBatteryIcon(Activity activity, BatteryInfoList batteryInfoList, int i, int i2, int i3) {
+            if (batteryIsUnknown(i, i2)) {
+                batteryInfoList.setBatteryStatusIcon(C2135R.C2136drawable.bi_not_inserted);
+                return;
+            }
+            batteryInfoList.setBatteryStatusIcon(activity.getResources().getIdentifier(String.format("bi_%s_%d", new Object[]{i2 == 1 ? "charge" : "running", Integer.valueOf((76 > i3 || i3 > 100) ? (51 > i3 || i3 >= 76) ? (26 > i3 || i3 >= 51) ? (i3 <= 0 || i3 >= 26) ? 0 : 39 : 59 : 89 : 100)}), "drawable", activity.getPackageName()));
+        }
+
+        public static void showPowerText(Activity activity) {
+            activity.findViewById(C2135R.C2137id.bt_PowerText).setVisibility(0);
+        }
+
+        static void showListView(Activity activity, BatteryInfoAdapter batteryInfoAdapter) {
+            ListView listView = (ListView) activity.findViewById(C2135R.C2137id.battery_list);
+            listView.setAdapter(batteryInfoAdapter);
+            setListViewHeight(listView);
+        }
+
+        static void setListViewHeight(ListView listView) {
+            ListAdapter adapter = listView.getAdapter();
+            ViewGroup.LayoutParams layoutParams = listView.getLayoutParams();
+            if (adapter == null) {
+                layoutParams.height = 0;
+            } else {
+                int i = 0;
+                for (int i2 = 0; i2 < adapter.getCount(); i2++) {
+                    View view = adapter.getView(i2, (View) null, listView);
+                    view.measure(0, 0);
+                    i += view.getMeasuredHeight();
+                }
+                layoutParams.height = i + (listView.getDividerHeight() * (adapter.getCount() - 1));
+            }
+            listView.setLayoutParams(layoutParams);
+            listView.requestLayout();
+        }
+    }
+}

+ 563 - 0
app/src/main/java/epson/maintain/EfuReader.java

@@ -0,0 +1,563 @@
+package epson.maintain;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.annotation.VisibleForTesting;
+import android.support.media.ExifInterface;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.charset.Charset;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.commons.lang.CharEncoding;
+
+public class EfuReader {
+    /* JADX WARNING: Removed duplicated region for block: B:35:0x005d  */
+    /* JADX WARNING: Removed duplicated region for block: B:37:0x0062 A[SYNTHETIC, Splitter:B:37:0x0062] */
+    /* Code decompiled incorrectly, please refer to instructions dump. */
+    public static void unzipOnlyOneEntry(@android.support.annotation.NonNull java.lang.String r3, @android.support.annotation.NonNull java.lang.String r4) throws java.io.IOException {
+        /*
+            java.util.zip.ZipFile r0 = new java.util.zip.ZipFile
+            r0.<init>(r3)
+            int r3 = r0.size()
+            r1 = 1
+            if (r3 != r1) goto L_0x007d
+            java.util.Enumeration r3 = r0.entries()
+            boolean r1 = r3.hasMoreElements()
+            if (r1 == 0) goto L_0x0075
+            java.lang.Object r3 = r3.nextElement()     // Catch:{ NoSuchElementException -> 0x006e }
+            java.util.zip.ZipEntry r3 = (java.util.zip.ZipEntry) r3     // Catch:{ NoSuchElementException -> 0x006e }
+            boolean r1 = r3.isDirectory()
+            if (r1 != 0) goto L_0x0066
+            r1 = 0
+            java.io.BufferedInputStream r2 = new java.io.BufferedInputStream     // Catch:{ all -> 0x0059 }
+            java.io.InputStream r3 = r0.getInputStream(r3)     // Catch:{ all -> 0x0059 }
+            r2.<init>(r3)     // Catch:{ all -> 0x0059 }
+            java.io.BufferedOutputStream r3 = new java.io.BufferedOutputStream     // Catch:{ all -> 0x0057 }
+            java.io.FileOutputStream r0 = new java.io.FileOutputStream     // Catch:{ all -> 0x0057 }
+            r0.<init>(r4)     // Catch:{ all -> 0x0057 }
+            r3.<init>(r0)     // Catch:{ all -> 0x0057 }
+            r4 = 4096(0x1000, float:5.74E-42)
+            byte[] r4 = new byte[r4]     // Catch:{ all -> 0x0054 }
+        L_0x003a:
+            r0 = -1
+            int r1 = r2.read(r4)     // Catch:{ IOException -> 0x004d }
+            if (r0 == r1) goto L_0x0046
+            r0 = 0
+            r3.write(r4, r0, r1)     // Catch:{ IOException -> 0x004d }
+            goto L_0x003a
+        L_0x0046:
+            r3.close()
+            r2.close()     // Catch:{ IOException -> 0x004c }
+        L_0x004c:
+            return
+        L_0x004d:
+            r4 = move-exception
+            epson.maintain.EfuReader$WriteException r0 = new epson.maintain.EfuReader$WriteException     // Catch:{ all -> 0x0054 }
+            r0.<init>(r4)     // Catch:{ all -> 0x0054 }
+            throw r0     // Catch:{ all -> 0x0054 }
+        L_0x0054:
+            r4 = move-exception
+            r1 = r3
+            goto L_0x005b
+        L_0x0057:
+            r4 = move-exception
+            goto L_0x005b
+        L_0x0059:
+            r4 = move-exception
+            r2 = r1
+        L_0x005b:
+            if (r1 == 0) goto L_0x0060
+            r1.close()
+        L_0x0060:
+            if (r2 == 0) goto L_0x0065
+            r2.close()     // Catch:{ IOException -> 0x0065 }
+        L_0x0065:
+            throw r4
+        L_0x0066:
+            java.io.IOException r3 = new java.io.IOException
+            java.lang.String r4 = "zip no entry."
+            r3.<init>(r4)
+            throw r3
+        L_0x006e:
+            r3 = move-exception
+            java.io.IOException r4 = new java.io.IOException
+            r4.<init>(r3)
+            throw r4
+        L_0x0075:
+            java.io.IOException r3 = new java.io.IOException
+            java.lang.String r4 = "zip no entry."
+            r3.<init>(r4)
+            throw r3
+        L_0x007d:
+            java.io.IOException r3 = new java.io.IOException
+            java.lang.StringBuilder r4 = new java.lang.StringBuilder
+            r4.<init>()
+            java.lang.String r1 = "entry != 1 <"
+            r4.append(r1)
+            int r0 = r0.size()
+            r4.append(r0)
+            java.lang.String r0 = ">"
+            r4.append(r0)
+            java.lang.String r4 = r4.toString()
+            r3.<init>(r4)
+            throw r3
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.maintain.EfuReader.unzipOnlyOneEntry(java.lang.String, java.lang.String):void");
+    }
+
+    /* JADX WARNING: Removed duplicated region for block: B:22:0x0031  */
+    /* Code decompiled incorrectly, please refer to instructions dump. */
+    public void writeOnlyOneFirmwareData(java.io.File r3, java.io.File r4) throws java.io.IOException {
+        /*
+            r2 = this;
+            boolean r0 = epson.maintain.EfuReader.RcxFileReader.checkHeaderId(r3)
+            if (r0 != 0) goto L_0x0035
+            r0 = 0
+            epson.maintain.EfuReader$RcxFileReader r1 = new epson.maintain.EfuReader$RcxFileReader     // Catch:{ all -> 0x002d }
+            r1.<init>(r3)     // Catch:{ all -> 0x002d }
+            boolean r3 = r1.readHeader()     // Catch:{ all -> 0x002b }
+            if (r3 == 0) goto L_0x0025
+            boolean r3 = r2.checkHeaderData(r1)     // Catch:{ all -> 0x002b }
+            if (r3 == 0) goto L_0x001f
+            r1.writeOnlyOneFirmwareData(r4)     // Catch:{ all -> 0x002b }
+            r1.close()
+            return
+        L_0x001f:
+            java.io.IOException r3 = new java.io.IOException     // Catch:{ all -> 0x002b }
+            r3.<init>()     // Catch:{ all -> 0x002b }
+            throw r3     // Catch:{ all -> 0x002b }
+        L_0x0025:
+            java.io.IOException r3 = new java.io.IOException     // Catch:{ all -> 0x002b }
+            r3.<init>()     // Catch:{ all -> 0x002b }
+            throw r3     // Catch:{ all -> 0x002b }
+        L_0x002b:
+            r3 = move-exception
+            goto L_0x002f
+        L_0x002d:
+            r3 = move-exception
+            r1 = r0
+        L_0x002f:
+            if (r1 == 0) goto L_0x0034
+            r1.close()
+        L_0x0034:
+            throw r3
+        L_0x0035:
+            java.io.IOException r3 = new java.io.IOException
+            r3.<init>()
+            throw r3
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.maintain.EfuReader.writeOnlyOneFirmwareData(java.io.File, java.io.File):void");
+    }
+
+    private boolean checkHeaderData(@NonNull RcxFileReader rcxFileReader) {
+        String sectionAData = rcxFileReader.getSectionAData("1");
+        if ((!ExifInterface.GPS_MEASUREMENT_2D.equals(sectionAData) && !ExifInterface.GPS_MEASUREMENT_3D.equals(sectionAData)) || !"11".equals(rcxFileReader.getSectionAData(ExifInterface.GPS_MEASUREMENT_2D))) {
+            return false;
+        }
+        String sectionAData2 = rcxFileReader.getSectionAData("16");
+        if (sectionAData2 == null || !RcxFileReader.PATTERN_KOMMA.matcher(sectionAData2).lookingAt()) {
+            return true;
+        }
+        return false;
+    }
+
+    static class RcxFileReader implements Closeable {
+        private static final Pattern COMMENT_PATTERN = Pattern.compile("^#.*");
+        private static final Pattern PATTERN_KEY_AND_VALUE = Pattern.compile("(\\d+)=\"(.*)\"");
+        static final Pattern PATTERN_KOMMA = Pattern.compile(PreferencesConstants.COOKIE_DELIMITER);
+        private static final Pattern PATTERN_SECTION_SEPARATOR = Pattern.compile("\\[([A-Z]+)\\]", 2);
+        private static final byte[] RCX_HEADER_ID = "RCX\r\nSEIKO EPSON EpsonNet Form\r\n".getBytes(Charset.forName(CharEncoding.US_ASCII));
+
+        /* renamed from: is */
+        private RandomAccessFile f333is = null;
+        private long mHeaderEndPosition = -1;
+        private final HashMap<String, String> mSectionAKeyAndValue = new HashMap<>();
+
+        RcxFileReader(File file) throws FileNotFoundException {
+            this.f333is = new RandomAccessFile(file, "r");
+        }
+
+        public static boolean checkHeaderId(File file) {
+            return !Arrays.equals(RCX_HEADER_ID, getFileByte(file, RCX_HEADER_ID.length));
+        }
+
+        /* JADX WARNING: Removed duplicated region for block: B:20:0x0021 A[SYNTHETIC, Splitter:B:20:0x0021] */
+        /* JADX WARNING: Removed duplicated region for block: B:27:0x0028 A[SYNTHETIC, Splitter:B:27:0x0028] */
+        /* Code decompiled incorrectly, please refer to instructions dump. */
+        private static byte[] getFileByte(java.io.File r5, int r6) {
+            /*
+                byte[] r0 = new byte[r6]
+                r1 = 0
+                java.io.FileInputStream r2 = new java.io.FileInputStream     // Catch:{ IOException -> 0x0025, all -> 0x001e }
+                r2.<init>(r5)     // Catch:{ IOException -> 0x0025, all -> 0x001e }
+                r5 = 0
+            L_0x0009:
+                int r3 = r6 - r5
+                int r3 = r2.read(r0, r5, r3)     // Catch:{ IOException -> 0x001c, all -> 0x0019 }
+                r4 = -1
+                if (r3 == r4) goto L_0x0015
+                int r5 = r5 + r3
+                if (r5 < r6) goto L_0x0009
+            L_0x0015:
+                r2.close()     // Catch:{ IOException -> 0x0018 }
+            L_0x0018:
+                return r0
+            L_0x0019:
+                r5 = move-exception
+                r1 = r2
+                goto L_0x001f
+            L_0x001c:
+                goto L_0x0026
+            L_0x001e:
+                r5 = move-exception
+            L_0x001f:
+                if (r1 == 0) goto L_0x0024
+                r1.close()     // Catch:{ IOException -> 0x0024 }
+            L_0x0024:
+                throw r5
+            L_0x0025:
+                r2 = r1
+            L_0x0026:
+                if (r2 == 0) goto L_0x002b
+                r2.close()     // Catch:{ IOException -> 0x002b }
+            L_0x002b:
+                return r1
+            */
+            throw new UnsupportedOperationException("Method not decompiled: epson.maintain.EfuReader.RcxFileReader.getFileByte(java.io.File, int):byte[]");
+        }
+
+        @Nullable
+        public String getSectionAData(String str) {
+            return this.mSectionAKeyAndValue.get(str);
+        }
+
+        /* access modifiers changed from: private */
+        /* JADX WARNING: Code restructure failed: missing block: B:20:0x0048, code lost:
+            return false;
+         */
+        /* JADX WARNING: Exception block dominator not found, dom blocks: [] */
+        /* Code decompiled incorrectly, please refer to instructions dump. */
+        public boolean readHeader() {
+            /*
+                r6 = this;
+                java.util.HashMap<java.lang.String, java.lang.String> r0 = r6.mSectionAKeyAndValue
+                r0.clear()
+                r0 = -1
+                r6.mHeaderEndPosition = r0
+                r0 = 0
+                java.lang.String r1 = ""
+            L_0x000c:
+                java.io.RandomAccessFile r2 = r6.f333is     // Catch:{ IOException | OutOfMemoryError -> 0x0048, all -> 0x0046 }
+                java.lang.String r2 = r6.getNextLine(r2)     // Catch:{ IOException | OutOfMemoryError -> 0x0048, all -> 0x0046 }
+                r3 = 1
+                if (r2 == 0) goto L_0x003d
+                boolean r4 = isCommentLine(r2)     // Catch:{ IOException | OutOfMemoryError -> 0x0048, all -> 0x0046 }
+                if (r4 == 0) goto L_0x001c
+                goto L_0x000c
+            L_0x001c:
+                java.lang.String r4 = isSectionSeparator(r2)     // Catch:{ IOException | OutOfMemoryError -> 0x0048, all -> 0x0046 }
+                if (r4 == 0) goto L_0x0024
+                r1 = r4
+                goto L_0x000c
+            L_0x0024:
+                java.lang.String[] r2 = isKeyAndValueData(r2)     // Catch:{ IOException | OutOfMemoryError -> 0x0048, all -> 0x0046 }
+                if (r2 != 0) goto L_0x002b
+                goto L_0x000c
+            L_0x002b:
+                java.lang.String r4 = "A"
+                boolean r4 = r4.equals(r1)     // Catch:{ IOException | OutOfMemoryError -> 0x0048, all -> 0x0046 }
+                if (r4 == 0) goto L_0x000c
+                java.util.HashMap<java.lang.String, java.lang.String> r4 = r6.mSectionAKeyAndValue     // Catch:{ IOException | OutOfMemoryError -> 0x0048, all -> 0x0046 }
+                r5 = r2[r0]     // Catch:{ IOException | OutOfMemoryError -> 0x0048, all -> 0x0046 }
+                r2 = r2[r3]     // Catch:{ IOException | OutOfMemoryError -> 0x0048, all -> 0x0046 }
+                r4.put(r5, r2)     // Catch:{ IOException | OutOfMemoryError -> 0x0048, all -> 0x0046 }
+                goto L_0x000c
+            L_0x003d:
+                java.io.RandomAccessFile r1 = r6.f333is     // Catch:{ IOException | OutOfMemoryError -> 0x0048, all -> 0x0046 }
+                long r1 = r1.getFilePointer()     // Catch:{ IOException | OutOfMemoryError -> 0x0048, all -> 0x0046 }
+                r6.mHeaderEndPosition = r1     // Catch:{ IOException | OutOfMemoryError -> 0x0048, all -> 0x0046 }
+                return r3
+            L_0x0046:
+                r0 = move-exception
+                throw r0
+            L_0x0048:
+                return r0
+            */
+            throw new UnsupportedOperationException("Method not decompiled: epson.maintain.EfuReader.RcxFileReader.readHeader():boolean");
+        }
+
+        @VisibleForTesting
+        static boolean isCommentLine(@NonNull String str) {
+            return COMMENT_PATTERN.matcher(str).matches();
+        }
+
+        @Nullable
+        @VisibleForTesting
+        static String isSectionSeparator(@NonNull String str) {
+            Matcher matcher = PATTERN_SECTION_SEPARATOR.matcher(str);
+            if (!matcher.lookingAt()) {
+                return null;
+            }
+            return matcher.group(1).toUpperCase();
+        }
+
+        @Nullable
+        @VisibleForTesting
+        static String[] isKeyAndValueData(@NonNull String str) {
+            Matcher matcher = PATTERN_KEY_AND_VALUE.matcher(str);
+            if (!matcher.lookingAt()) {
+                return null;
+            }
+            return new String[]{matcher.group(1).toLowerCase(), matcher.group(2)};
+        }
+
+        @Nullable
+        private String getNextLine(@NonNull RandomAccessFile randomAccessFile) throws IOException {
+            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+            boolean z = false;
+            while (true) {
+                int read = randomAccessFile.read();
+                if (read != -1) {
+                    switch (z) {
+                        case false:
+                            if (read == 13) {
+                                z = true;
+                                break;
+                            } else if (read != 12 || byteArrayOutputStream.size() != 0) {
+                                byteArrayOutputStream.write(read);
+                                break;
+                            } else {
+                                return null;
+                            }
+                        case true:
+                            if (read == 10) {
+                                return byteArrayOutputStream.toString(CharEncoding.US_ASCII);
+                            }
+                            throw new IOException();
+                    }
+                } else {
+                    throw new IOException("file data ends");
+                }
+            }
+        }
+
+        public void close() {
+            RandomAccessFile randomAccessFile = this.f333is;
+            if (randomAccessFile != null) {
+                try {
+                    randomAccessFile.close();
+                    this.f333is = null;
+                } catch (IOException unused) {
+                }
+            }
+        }
+
+        public void writeOnlyOneFirmwareData(File file) throws IOException {
+            writeRemainingData(this.f333is, this.mHeaderEndPosition, file);
+        }
+
+        /* JADX WARNING: Removed duplicated region for block: B:23:0x0034 A[Catch:{ all -> 0x002b }] */
+        /* JADX WARNING: Removed duplicated region for block: B:26:0x003a A[SYNTHETIC, Splitter:B:26:0x003a] */
+        @android.support.annotation.VisibleForTesting
+        /* Code decompiled incorrectly, please refer to instructions dump. */
+        static void writeRemainingData(@android.support.annotation.NonNull java.io.RandomAccessFile r3, long r4, @android.support.annotation.NonNull java.io.File r6) throws java.io.IOException {
+            /*
+                r0 = 0
+                java.io.BufferedOutputStream r1 = new java.io.BufferedOutputStream     // Catch:{ IOException -> 0x002d }
+                java.io.FileOutputStream r2 = new java.io.FileOutputStream     // Catch:{ IOException -> 0x002d }
+                r2.<init>(r6)     // Catch:{ IOException -> 0x002d }
+                r1.<init>(r2)     // Catch:{ IOException -> 0x002d }
+                r3.seek(r4)     // Catch:{ IOException -> 0x0028, all -> 0x0025 }
+                writeRemainingData(r3, r1)     // Catch:{ IOException -> 0x0028, all -> 0x0025 }
+                r1.close()     // Catch:{ IOException -> 0x0015 }
+                return
+            L_0x0015:
+                r3 = move-exception
+                boolean r4 = r6.exists()
+                if (r4 == 0) goto L_0x001f
+                r6.delete()
+            L_0x001f:
+                epson.maintain.EfuReader$WriteException r4 = new epson.maintain.EfuReader$WriteException
+                r4.<init>(r3)
+                throw r4
+            L_0x0025:
+                r3 = move-exception
+                r0 = r1
+                goto L_0x0038
+            L_0x0028:
+                r3 = move-exception
+                r0 = r1
+                goto L_0x002e
+            L_0x002b:
+                r3 = move-exception
+                goto L_0x0038
+            L_0x002d:
+                r3 = move-exception
+            L_0x002e:
+                boolean r4 = r6.exists()     // Catch:{ all -> 0x002b }
+                if (r4 == 0) goto L_0x0037
+                r6.delete()     // Catch:{ all -> 0x002b }
+            L_0x0037:
+                throw r3     // Catch:{ all -> 0x002b }
+            L_0x0038:
+                if (r0 == 0) goto L_0x004e
+                r0.close()     // Catch:{ IOException -> 0x003e }
+                goto L_0x004e
+            L_0x003e:
+                r3 = move-exception
+                boolean r4 = r6.exists()
+                if (r4 == 0) goto L_0x0048
+                r6.delete()
+            L_0x0048:
+                epson.maintain.EfuReader$WriteException r4 = new epson.maintain.EfuReader$WriteException
+                r4.<init>(r3)
+                throw r4
+            L_0x004e:
+                throw r3
+            */
+            throw new UnsupportedOperationException("Method not decompiled: epson.maintain.EfuReader.RcxFileReader.writeRemainingData(java.io.RandomAccessFile, long, java.io.File):void");
+        }
+
+        /* JADX WARNING: Code restructure failed: missing block: B:21:0x002f, code lost:
+            r8.delete();
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:24:?, code lost:
+            r1.close();
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:27:0x003c, code lost:
+            if (r8.exists() == false) goto L_?;
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:38:?, code lost:
+            return false;
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:39:?, code lost:
+            return false;
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:40:?, code lost:
+            return false;
+         */
+        /* JADX WARNING: Failed to process nested try/catch */
+        /* JADX WARNING: Missing exception handler attribute for start block: B:18:0x0029 */
+        /* JADX WARNING: Removed duplicated region for block: B:21:0x002f A[Catch:{ all -> 0x0027 }] */
+        /* JADX WARNING: Removed duplicated region for block: B:23:0x0034 A[SYNTHETIC, Splitter:B:23:0x0034] */
+        /* JADX WARNING: Removed duplicated region for block: B:29:0x0042 A[SYNTHETIC, Splitter:B:29:0x0042] */
+        /* JADX WARNING: Removed duplicated region for block: B:38:? A[RETURN, SYNTHETIC] */
+        /* Code decompiled incorrectly, please refer to instructions dump. */
+        static boolean searchDataAndWriteRemaining(@android.support.annotation.NonNull java.io.RandomAccessFile r4, long r5, @android.support.annotation.NonNull byte[] r7, @android.support.annotation.NonNull java.io.File r8) {
+            /*
+                r0 = 0
+                r1 = 0
+                java.io.BufferedOutputStream r2 = new java.io.BufferedOutputStream     // Catch:{ IOException -> 0x0029 }
+                java.io.FileOutputStream r3 = new java.io.FileOutputStream     // Catch:{ IOException -> 0x0029 }
+                r3.<init>(r8)     // Catch:{ IOException -> 0x0029 }
+                r2.<init>(r3)     // Catch:{ IOException -> 0x0029 }
+                seekDataPosition(r4, r5, r7)     // Catch:{ IOException -> 0x0025, all -> 0x0022 }
+                writeRemainingData(r4, r2)     // Catch:{ IOException -> 0x0025, all -> 0x0022 }
+                r4 = 1
+                r2.close()     // Catch:{ IOException -> 0x0018 }
+                r0 = 1
+                goto L_0x003f
+            L_0x0018:
+                boolean r4 = r8.exists()
+                if (r4 == 0) goto L_0x003f
+            L_0x001e:
+                r8.delete()
+                goto L_0x003f
+            L_0x0022:
+                r4 = move-exception
+                r1 = r2
+                goto L_0x0040
+            L_0x0025:
+                r1 = r2
+                goto L_0x0029
+            L_0x0027:
+                r4 = move-exception
+                goto L_0x0040
+            L_0x0029:
+                boolean r4 = r8.exists()     // Catch:{ all -> 0x0027 }
+                if (r4 == 0) goto L_0x0032
+                r8.delete()     // Catch:{ all -> 0x0027 }
+            L_0x0032:
+                if (r1 == 0) goto L_0x003f
+                r1.close()     // Catch:{ IOException -> 0x0038 }
+                goto L_0x003f
+            L_0x0038:
+                boolean r4 = r8.exists()
+                if (r4 == 0) goto L_0x003f
+                goto L_0x001e
+            L_0x003f:
+                return r0
+            L_0x0040:
+                if (r1 == 0) goto L_0x004f
+                r1.close()     // Catch:{ IOException -> 0x0046 }
+                goto L_0x004f
+            L_0x0046:
+                boolean r5 = r8.exists()
+                if (r5 == 0) goto L_0x004f
+                r8.delete()
+            L_0x004f:
+                throw r4
+            */
+            throw new UnsupportedOperationException("Method not decompiled: epson.maintain.EfuReader.RcxFileReader.searchDataAndWriteRemaining(java.io.RandomAccessFile, long, byte[], java.io.File):boolean");
+        }
+
+        static void writeRemainingData(RandomAccessFile randomAccessFile, BufferedOutputStream bufferedOutputStream) throws IOException {
+            byte[] bArr = new byte[4096];
+            while (true) {
+                int read = randomAccessFile.read(bArr);
+                if (read != -1) {
+                    try {
+                        bufferedOutputStream.write(bArr, 0, read);
+                    } catch (IOException e) {
+                        throw new WriteException(e);
+                    }
+                } else {
+                    return;
+                }
+            }
+        }
+
+        static void seekDataPosition(RandomAccessFile randomAccessFile, long j, byte[] bArr) throws IOException {
+            randomAccessFile.seek(j);
+            long j2 = 0;
+            int i = 0;
+            while (true) {
+                int read = randomAccessFile.read();
+                if (read == -1) {
+                    throw new IOException("data not found");
+                } else if (i == 0) {
+                    if (read == bArr[0]) {
+                        j2 = randomAccessFile.getFilePointer();
+                        i++;
+                    }
+                } else if (read == bArr[i]) {
+                    i++;
+                    if (i >= bArr.length) {
+                        randomAccessFile.seek(j2 - 1);
+                        return;
+                    }
+                } else {
+                    randomAccessFile.seek(j2);
+                    i = 0;
+                }
+            }
+        }
+    }
+
+    public static class WriteException extends IOException {
+        public WriteException(Throwable th) {
+            super(th);
+        }
+
+        public WriteException() {
+        }
+    }
+}

+ 191 - 0
app/src/main/java/epson/maintain/FirmInfFile.java

@@ -0,0 +1,191 @@
+package epson.maintain;
+
+import android.support.annotation.Nullable;
+import android.support.annotation.VisibleForTesting;
+import java.util.HashMap;
+
+public class FirmInfFile {
+    private static final String INF_KEY_URL_ROM_EFU = "URLROMEFU";
+    private int mInfFileVersion = 0;
+    int mRomNum;
+    final HashMap<String, String> mUpdateInf = new HashMap<>();
+
+    public synchronized String getRomUrl(int i) {
+        String str;
+        if (i <= this.mRomNum) {
+            str = this.mUpdateInf.get(String.format("URLROM%d", new Object[]{Integer.valueOf(i)}));
+        } else {
+            str = null;
+        }
+        return str;
+    }
+
+    public synchronized String getMainVersion() {
+        return this.mUpdateInf.get("VERMAIN");
+    }
+
+    public synchronized String getNetVersion() {
+        return this.mUpdateInf.get("VERNET");
+    }
+
+    public synchronized int getRomNum() {
+        return this.mRomNum;
+    }
+
+    @Nullable
+    public synchronized String getfuUrl() {
+        return this.mUpdateInf.get(INF_KEY_URL_ROM_EFU);
+    }
+
+    public synchronized int getInfFileVersion() {
+        return this.mInfFileVersion;
+    }
+
+    /* JADX WARNING: Code restructure failed: missing block: B:27:0x0042, code lost:
+        return false;
+     */
+    /* Code decompiled incorrectly, please refer to instructions dump. */
+    public synchronized boolean checkInfFileVersion(byte[] r4) {
+        /*
+            r3 = this;
+            monitor-enter(r3)
+            r0 = 0
+            r3.mInfFileVersion = r0     // Catch:{ all -> 0x0043 }
+            boolean r4 = r3.parseInfFile(r4)     // Catch:{ all -> 0x0043 }
+            if (r4 != 0) goto L_0x000c
+            monitor-exit(r3)
+            return r0
+        L_0x000c:
+            java.util.HashMap<java.lang.String, java.lang.String> r4 = r3.mUpdateInf     // Catch:{ all -> 0x0043 }
+            java.lang.String r1 = "VERMAIN"
+            boolean r4 = r4.containsKey(r1)     // Catch:{ all -> 0x0043 }
+            if (r4 == 0) goto L_0x0041
+            java.util.HashMap<java.lang.String, java.lang.String> r4 = r3.mUpdateInf     // Catch:{ all -> 0x0043 }
+            java.lang.String r1 = "VERNET"
+            boolean r4 = r4.containsKey(r1)     // Catch:{ all -> 0x0043 }
+            if (r4 != 0) goto L_0x0021
+            goto L_0x0041
+        L_0x0021:
+            java.util.HashMap<java.lang.String, java.lang.String> r4 = r3.mUpdateInf     // Catch:{ all -> 0x0043 }
+            java.lang.String r1 = "URLROM1"
+            boolean r4 = r4.containsKey(r1)     // Catch:{ all -> 0x0043 }
+            r1 = 1
+            if (r4 == 0) goto L_0x0030
+            r3.mInfFileVersion = r1     // Catch:{ all -> 0x0043 }
+            monitor-exit(r3)
+            return r1
+        L_0x0030:
+            java.util.HashMap<java.lang.String, java.lang.String> r4 = r3.mUpdateInf     // Catch:{ all -> 0x0043 }
+            java.lang.String r2 = "URLROMEFU"
+            boolean r4 = r4.containsKey(r2)     // Catch:{ all -> 0x0043 }
+            if (r4 == 0) goto L_0x003f
+            r4 = 2
+            r3.mInfFileVersion = r4     // Catch:{ all -> 0x0043 }
+            monitor-exit(r3)
+            return r1
+        L_0x003f:
+            monitor-exit(r3)
+            return r0
+        L_0x0041:
+            monitor-exit(r3)
+            return r0
+        L_0x0043:
+            r4 = move-exception
+            monitor-exit(r3)
+            throw r4
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.maintain.FirmInfFile.checkInfFileVersion(byte[]):boolean");
+    }
+
+    /* access modifiers changed from: package-private */
+    /* JADX WARNING: Code restructure failed: missing block: B:29:0x0071, code lost:
+        return false;
+     */
+    @android.support.annotation.VisibleForTesting
+    /* Code decompiled incorrectly, please refer to instructions dump. */
+    public synchronized boolean parseInfFile(byte[] r10) {
+        /*
+            r9 = this;
+            monitor-enter(r9)
+            r0 = 0
+            if (r10 == 0) goto L_0x0070
+            int r1 = r10.length     // Catch:{ all -> 0x006d }
+            r2 = 4
+            if (r1 >= r2) goto L_0x0009
+            goto L_0x0070
+        L_0x0009:
+            int r1 = r10.length     // Catch:{ all -> 0x006d }
+            int r1 = r1 - r2
+            byte[] r1 = new byte[r1]     // Catch:{ all -> 0x006d }
+            int r3 = r1.length     // Catch:{ all -> 0x006d }
+            java.lang.System.arraycopy(r10, r2, r1, r0, r3)     // Catch:{ all -> 0x006d }
+            java.lang.String r10 = new java.lang.String     // Catch:{ all -> 0x006d }
+            r10.<init>(r1)     // Catch:{ all -> 0x006d }
+            java.lang.String r1 = ";\r\n"
+            java.lang.String[] r10 = r10.split(r1)     // Catch:{ all -> 0x006d }
+            java.util.HashMap<java.lang.String, java.lang.String> r1 = r9.mUpdateInf     // Catch:{ all -> 0x006d }
+            r1.clear()     // Catch:{ all -> 0x006d }
+            r9.mRomNum = r0     // Catch:{ all -> 0x006d }
+            int r1 = r10.length     // Catch:{ all -> 0x006d }
+            r2 = 0
+        L_0x0025:
+            r3 = 1
+            if (r2 >= r1) goto L_0x006b
+            r4 = r10[r2]     // Catch:{ all -> 0x006d }
+            java.lang.String r5 = ":"
+            int r5 = r4.indexOf(r5)     // Catch:{ all -> 0x006d }
+            r6 = -1
+            if (r5 != r6) goto L_0x0034
+            goto L_0x0068
+        L_0x0034:
+            java.lang.String r7 = r4.substring(r0, r5)     // Catch:{ all -> 0x006d }
+            int r5 = r5 + 1
+            int r8 = r4.length()     // Catch:{ all -> 0x006d }
+            java.lang.String r4 = r4.substring(r5, r8)     // Catch:{ all -> 0x006d }
+            boolean r5 = epson.maintain.FirmwareManager.DEV_FWUPDATE     // Catch:{ all -> 0x006d }
+            if (r5 == 0) goto L_0x0056
+            java.lang.String r5 = "URLROM"
+            int r5 = r7.indexOf(r5)     // Catch:{ all -> 0x006d }
+            if (r5 == r6) goto L_0x0056
+            java.lang.String r5 = "https://epsonpfu.ebz.epson.net"
+            java.lang.String r8 = "https://epsonpfu-stg.ebz.epson.net"
+            java.lang.String r4 = r4.replaceAll(r5, r8)     // Catch:{ all -> 0x006d }
+        L_0x0056:
+            java.lang.String r5 = "URLROM"
+            int r5 = r7.indexOf(r5)     // Catch:{ all -> 0x006d }
+            if (r5 == r6) goto L_0x0063
+            int r5 = r9.mRomNum     // Catch:{ all -> 0x006d }
+            int r5 = r5 + r3
+            r9.mRomNum = r5     // Catch:{ all -> 0x006d }
+        L_0x0063:
+            java.util.HashMap<java.lang.String, java.lang.String> r3 = r9.mUpdateInf     // Catch:{ all -> 0x006d }
+            r3.put(r7, r4)     // Catch:{ all -> 0x006d }
+        L_0x0068:
+            int r2 = r2 + 1
+            goto L_0x0025
+        L_0x006b:
+            monitor-exit(r9)
+            return r3
+        L_0x006d:
+            r10 = move-exception
+            monitor-exit(r9)
+            throw r10
+        L_0x0070:
+            monitor-exit(r9)
+            return r0
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.maintain.FirmInfFile.parseInfFile(byte[]):boolean");
+    }
+
+    @VisibleForTesting
+    static String getComparableVersion(@Nullable String str) {
+        if (str == null || str.length() < 6) {
+            throw new IllegalArgumentException();
+        }
+        return str.substring(4, 6) + str.substring(2, 4);
+    }
+
+    public int compareVersion(String str) {
+        return getComparableVersion(str).compareTo(getComparableVersion(getMainVersion()));
+    }
+}

+ 1158 - 0
app/src/main/java/epson/maintain/FirmwareManager.java

@@ -0,0 +1,1158 @@
+package epson.maintain;
+
+import android.content.Context;
+import android.os.AsyncTask;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.annotation.VisibleForTesting;
+import android.util.Log;
+import com.epson.iprint.prtlogger.Analytics;
+import com.epson.mobilephone.common.escpr.EscprLib;
+import com.epson.mobilephone.common.maintain2.BatteryInfoEx;
+import com.epson.mobilephone.common.maintain2.MaintainPrinter2;
+import epson.common.ExternalFileUtils;
+import epson.common.IPAddressUtils;
+import epson.print.CommonDefine;
+import epson.print.MyPrinter;
+import epson.print.Util.EPLog;
+import java.io.File;
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.EnumMap;
+import java.util.Locale;
+import java.util.UUID;
+
+public class FirmwareManager {
+    static final int BUFFER_SIZE = 4096;
+    static final boolean DEV_FWUPDATE = false;
+    static final String EVAL_UPDATEINF_URL_PREFIX = "https://epsonpfu-stg.ebz.epson.net";
+    static String FW_POST_FILE_NAME = "/FWUPDATE_POST_DATA.dat";
+    /* access modifiers changed from: private */
+    public static String FW_POST_FILE_PATH = null;
+    private static final String TAG = "FirmwareManager";
+    static final String UPDATEINF_URL_PREFIX = "https://epsonpfu.ebz.epson.net";
+    /* access modifiers changed from: private */
+    public final String boundary;
+    private final String lineEnd;
+    int mCurRomNum;
+    String mCurVer;
+    byte[] mDlData;
+    AsyncTask<FWUpdateStep, Integer, FWUpdateProcResult> mFWUpdateTask;
+    /* access modifiers changed from: private */
+    public FirmInfFile mFirmInfFile;
+    String mMarketID;
+    String mNewVer;
+    /* access modifiers changed from: private */
+    public final MyPrinter mPrinter;
+    private String mPrinterMainVersion;
+    FWUpdateProcResult mProcResult;
+    FWUpdateStep mProcStep;
+    String mSendProtocol;
+    long mTotalSize;
+    /* access modifiers changed from: private */
+    public volatile String mUpdateInfUrl;
+    /* access modifiers changed from: private */
+    public volatile FWUpdateListener mUpdateListener;
+    private final MaintainPrinterWrapper maintainPrinter;
+    private final String twoHyphens;
+
+    public interface FWUpdateListener {
+        void fwManagerDidEndProc(FWUpdateProcResult fWUpdateProcResult, FWUpdateStep fWUpdateStep);
+
+        void fwManagerProcDoing(int i);
+    }
+
+    public enum FWUpdateProcResult {
+        None,
+        Success,
+        Cancel,
+        Fail,
+        NotVerUp,
+        NotSupport,
+        Interrupted,
+        DiskFull,
+        NotAC,
+        PrinterBadStatus
+    }
+
+    public enum FWUpdateStep {
+        Init,
+        GetPrinterFWVersion,
+        GetUpdateInf,
+        Download,
+        ReadyUpdate,
+        Send
+    }
+
+    public interface ProgressListener {
+        void transferred(long j);
+    }
+
+    public FirmwareManager(Context context, MyPrinter myPrinter) {
+        this(myPrinter, new File(ExternalFileUtils.getInstance(context).getDownloadDir(), FW_POST_FILE_NAME).getPath(), new MaintainPrinterWrapper());
+    }
+
+    @VisibleForTesting
+    FirmwareManager(MyPrinter myPrinter, @NonNull String str, @Nullable MaintainPrinterWrapper maintainPrinterWrapper) {
+        this.twoHyphens = "--";
+        this.boundary = "*****" + UUID.randomUUID().toString() + "*****";
+        this.lineEnd = "\r\n";
+        this.mFirmInfFile = new FirmInfFile();
+        this.mProcResult = FWUpdateProcResult.None;
+        this.mProcStep = FWUpdateStep.Init;
+        this.mFWUpdateTask = buildFWUpdateTask();
+        this.mPrinter = myPrinter;
+        FW_POST_FILE_PATH = str;
+        this.maintainPrinter = maintainPrinterWrapper;
+    }
+
+    /* access modifiers changed from: package-private */
+    public void endConnect() {
+        this.mFWUpdateTask.cancel(true);
+    }
+
+    /* access modifiers changed from: package-private */
+    public void startProc(FWUpdateStep fWUpdateStep) {
+        this.mProcStep = fWUpdateStep;
+        this.mProcResult = FWUpdateProcResult.None;
+        this.mFWUpdateTask = buildFWUpdateTask();
+        this.mFWUpdateTask.execute(new FWUpdateStep[]{fWUpdateStep});
+    }
+
+    /* access modifiers changed from: package-private */
+    public void endWithProcResult(FWUpdateProcResult fWUpdateProcResult) {
+        endConnect();
+        if (fWUpdateProcResult != FWUpdateProcResult.Success) {
+            removeSavedFile();
+        }
+        this.mProcResult = fWUpdateProcResult;
+        if (this.mUpdateListener != null) {
+            this.mUpdateListener.fwManagerDidEndProc(this.mProcResult, this.mProcStep);
+        }
+    }
+
+    public void cancelProc() {
+        endWithProcResult(FWUpdateProcResult.Cancel);
+    }
+
+    public void interruptProc() {
+        endWithProcResult(FWUpdateProcResult.Interrupted);
+    }
+
+    /* access modifiers changed from: package-private */
+    public String getUpdateInfURL() {
+        return String.format("%s/%s_model_%s/UPDATE.INF", new Object[]{getUpdateInfSchemeAndHost(), this.mPrinter.getName().replaceAll(" ", CommonDefine.UNDER_BAR), this.mMarketID});
+    }
+
+    private static String getUpdateInfSchemeAndHost() {
+        return DEV_FWUPDATE ? EVAL_UPDATEINF_URL_PREFIX : UPDATEINF_URL_PREFIX;
+    }
+
+    /* access modifiers changed from: package-private */
+    public String getStartUpdateURL() {
+        return IPAddressUtils.buildURL(this.mSendProtocol, this.mPrinter.getIp(), "/FIRMWAREUPDATE");
+    }
+
+    /* access modifiers changed from: package-private */
+    public String getSendFWURL() {
+        return IPAddressUtils.buildURL(this.mSendProtocol, this.mPrinter.getIp(), "/DOWN/FIRMWAREUPDATE/ROM1");
+    }
+
+    /* access modifiers changed from: private */
+    public String getNextRomURL() {
+        this.mCurRomNum++;
+        return this.mFirmInfFile.getRomUrl(this.mCurRomNum);
+    }
+
+    public void startVersionCheck(FWUpdateListener fWUpdateListener) {
+        this.mUpdateListener = fWUpdateListener;
+        startProc(FWUpdateStep.GetPrinterFWVersion);
+    }
+
+    /* access modifiers changed from: package-private */
+    public FWUpdateProcResult getPrinterFWVer() {
+        int firmwareInfo;
+        String str;
+        EnumMap enumMap = new EnumMap(EscprLib.PrinterFirmInfo.class);
+        int i = 0;
+        while (true) {
+            firmwareInfo = this.maintainPrinter.getFirmwareInfo(enumMap);
+            EPLog.m305d(TAG, "getFirmwareInfo = " + firmwareInfo);
+            if (firmwareInfo != -1100) {
+                break;
+            }
+            int i2 = i + 1;
+            if (i >= 5) {
+                break;
+            }
+            i = i2;
+        }
+        FWUpdateProcResult fWUpdateProcResult = FWUpdateProcResult.Fail;
+        if (firmwareInfo == -1016) {
+            return FWUpdateProcResult.NotSupport;
+        }
+        if (firmwareInfo != 0 || enumMap.isEmpty()) {
+            return fWUpdateProcResult;
+        }
+        boolean equals = ((String) enumMap.get(EscprLib.PrinterFirmInfo.NicFlg)).equals("1");
+        this.mMarketID = (String) enumMap.get(EscprLib.PrinterFirmInfo.MarketID);
+        this.mPrinterMainVersion = (String) enumMap.get(EscprLib.PrinterFirmInfo.MainVer);
+        String str2 = this.mPrinterMainVersion;
+        if (str2 == null) {
+            return FWUpdateProcResult.NotSupport;
+        }
+        this.mCurVer = String.format("%s.%s", new Object[]{str2, enumMap.get(EscprLib.PrinterFirmInfo.NetVer)});
+        if (this.mCurVer == null || (str = this.mMarketID) == null || "NA".equals(str) || equals) {
+            return FWUpdateProcResult.NotSupport;
+        }
+        this.mUpdateInfUrl = getUpdateInfUrlForAllUrlVer(enumMap);
+        if (this.mUpdateInfUrl == null) {
+            return FWUpdateProcResult.NotSupport;
+        }
+        FWUpdateProcResult checkNotBatteryPowered = checkNotBatteryPowered();
+        return checkNotBatteryPowered != FWUpdateProcResult.Success ? checkNotBatteryPowered : checkNotBatteryPowered;
+    }
+
+    private FWUpdateProcResult checkNotBatteryPowered() {
+        int batteryInfoEx;
+        FWUpdateProcResult fWUpdateProcResult = FWUpdateProcResult.Success;
+        BatteryInfoEx batteryInfoEx2 = new BatteryInfoEx();
+        int i = 0;
+        while (true) {
+            batteryInfoEx = this.maintainPrinter.getBatteryInfoEx(batteryInfoEx2);
+            EPLog.m305d(TAG, "getBatteryInfoEx = " + batteryInfoEx);
+            if (batteryInfoEx != -1100) {
+                break;
+            }
+            int i2 = i + 1;
+            if (i >= 5) {
+                break;
+            }
+            i = i2;
+        }
+        return (batteryInfoEx != 0 || batteryInfoEx2.powerSourceType == -1 || batteryInfoEx2.powerSourceType == 1) ? fWUpdateProcResult : FWUpdateProcResult.NotAC;
+    }
+
+    /* access modifiers changed from: package-private */
+    @Nullable
+    public String getUpdateInfUrlForAllUrlVer(@NonNull EnumMap<EscprLib.PrinterFirmInfo, String> enumMap) {
+        String str = enumMap.get(EscprLib.PrinterFirmInfo.UrlVer);
+        if (str == null) {
+            return null;
+        }
+        char c = 65535;
+        switch (str.hashCode()) {
+            case 1536:
+                if (str.equals("00")) {
+                    c = 0;
+                    break;
+                }
+                break;
+            case 1537:
+                if (str.equals("01")) {
+                    c = 1;
+                    break;
+                }
+                break;
+        }
+        switch (c) {
+            case 0:
+                return getUpdateInfURL();
+            case 1:
+                return getUpdateInfUrlV01(enumMap);
+            default:
+                return null;
+        }
+    }
+
+    @Nullable
+    @VisibleForTesting
+    static String getUpdateInfUrlV01(@NonNull EnumMap<EscprLib.PrinterFirmInfo, String> enumMap) {
+        String str;
+        String str2 = enumMap.get(EscprLib.PrinterFirmInfo.FY);
+        if (str2 == null || (str = enumMap.get(EscprLib.PrinterFirmInfo.MainVer)) == null || str.length() < 2) {
+            return null;
+        }
+        return String.format(Locale.US, "%s/%s_%s_00/UPDATE.INF", new Object[]{getUpdateInfSchemeAndHost(), str2, str.substring(0, 2)});
+    }
+
+    public void startGetUpdateInf(FWUpdateListener fWUpdateListener) {
+        this.mUpdateListener = fWUpdateListener;
+        startProc(FWUpdateStep.GetUpdateInf);
+    }
+
+    /* access modifiers changed from: private */
+    /* JADX WARNING: Can't wrap try/catch for region: R(2:10|11) */
+    /* JADX WARNING: Code restructure failed: missing block: B:11:?, code lost:
+        endWithProcResult(epson.maintain.FirmwareManager.FWUpdateProcResult.Fail);
+     */
+    /* JADX WARNING: Missing exception handler attribute for start block: B:10:0x001a */
+    /* Code decompiled incorrectly, please refer to instructions dump. */
+    public synchronized void localCheckInfFileVersion(byte[] r3) {
+        /*
+            r2 = this;
+            monitor-enter(r2)
+            epson.maintain.FirmInfFile r0 = r2.mFirmInfFile     // Catch:{ all -> 0x002b }
+            boolean r3 = r0.checkInfFileVersion(r3)     // Catch:{ all -> 0x002b }
+            if (r3 != 0) goto L_0x0010
+            epson.maintain.FirmwareManager$FWUpdateProcResult r3 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail     // Catch:{ all -> 0x002b }
+            r2.endWithProcResult(r3)     // Catch:{ all -> 0x002b }
+            monitor-exit(r2)
+            return
+        L_0x0010:
+            r3 = 0
+            epson.maintain.FirmInfFile r0 = r2.mFirmInfFile     // Catch:{ IllegalArgumentException -> 0x001a }
+            java.lang.String r1 = r2.mPrinterMainVersion     // Catch:{ IllegalArgumentException -> 0x001a }
+            int r3 = r0.compareVersion(r1)     // Catch:{ IllegalArgumentException -> 0x001a }
+            goto L_0x001f
+        L_0x001a:
+            epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail     // Catch:{ all -> 0x002b }
+            r2.endWithProcResult(r0)     // Catch:{ all -> 0x002b }
+        L_0x001f:
+            if (r3 < 0) goto L_0x0024
+            epson.maintain.FirmwareManager$FWUpdateProcResult r3 = epson.maintain.FirmwareManager.FWUpdateProcResult.NotVerUp     // Catch:{ all -> 0x002b }
+            goto L_0x0026
+        L_0x0024:
+            epson.maintain.FirmwareManager$FWUpdateProcResult r3 = epson.maintain.FirmwareManager.FWUpdateProcResult.Success     // Catch:{ all -> 0x002b }
+        L_0x0026:
+            r2.endWithProcResult(r3)     // Catch:{ all -> 0x002b }
+            monitor-exit(r2)
+            return
+        L_0x002b:
+            r3 = move-exception
+            monitor-exit(r2)
+            throw r3
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.maintain.FirmwareManager.localCheckInfFileVersion(byte[]):void");
+    }
+
+    public void startFWDownload(FWUpdateListener fWUpdateListener) {
+        this.mUpdateListener = fWUpdateListener;
+        startProc(FWUpdateStep.Download);
+    }
+
+    public static void removeSavedFile() {
+        try {
+            File file = new File(FW_POST_FILE_PATH);
+            if (file.exists()) {
+                file.delete();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    static File createNewSaveFile() throws IOException, SecurityException {
+        File file = new File(FW_POST_FILE_PATH);
+        file.getParentFile().mkdirs();
+        file.createNewFile();
+        return file;
+    }
+
+    public static boolean isExistSaveFile() {
+        try {
+            return new File(FW_POST_FILE_PATH).exists();
+        } catch (Exception unused) {
+            return false;
+        }
+    }
+
+    public void startFWUpdate(FWUpdateListener fWUpdateListener) {
+        this.mUpdateListener = fWUpdateListener;
+        startProc(FWUpdateStep.ReadyUpdate);
+    }
+
+    public static class CountingOutputStream extends FilterOutputStream {
+        private final ProgressListener listener;
+        private long transferred = 0;
+
+        public CountingOutputStream(OutputStream outputStream, ProgressListener progressListener) {
+            super(outputStream);
+            this.listener = progressListener;
+        }
+
+        public void write(byte[] bArr, int i, int i2) throws IOException {
+            this.out.write(bArr, i, i2);
+            this.transferred += (long) i2;
+            this.listener.transferred(this.transferred);
+        }
+
+        public void write(int i) throws IOException {
+            this.out.write(i);
+            this.transferred++;
+            this.listener.transferred(this.transferred);
+        }
+    }
+
+    /* access modifiers changed from: package-private */
+    public AsyncTask<FWUpdateStep, Integer, FWUpdateProcResult> buildFWUpdateTask() {
+        return new LocalAsyncTask();
+    }
+
+    class LocalAsyncTask extends AsyncTask<FWUpdateStep, Integer, FWUpdateProcResult> {
+        LocalAsyncTask() {
+        }
+
+        /* access modifiers changed from: protected */
+        public void onPreExecute() {
+            FirmwareManager.this.mDlData = null;
+            publishProgress(new Integer[0]);
+        }
+
+        /* access modifiers changed from: protected */
+        public FWUpdateProcResult doInBackground(FWUpdateStep... fWUpdateStepArr) {
+            FirmwareManager.this.mProcResult = FWUpdateProcResult.None;
+            int[] iArr = C20021.$SwitchMap$epson$maintain$FirmwareManager$FWUpdateStep;
+            FirmwareManager firmwareManager = FirmwareManager.this;
+            FWUpdateStep fWUpdateStep = fWUpdateStepArr[0];
+            firmwareManager.mProcStep = fWUpdateStep;
+            switch (iArr[fWUpdateStep.ordinal()]) {
+                case 1:
+                    return FirmwareManager.this.getPrinterFWVer();
+                case 2:
+                    if (FirmwareManager.this.mUpdateInfUrl == null) {
+                        return FWUpdateProcResult.NotSupport;
+                    }
+                    return download(FirmwareManager.this.mUpdateInfUrl, (File) null, false);
+                case 3:
+                    switch (FirmwareManager.this.mFirmInfFile.getInfFileVersion()) {
+                        case 1:
+                            return downloadNewFW();
+                        case 2:
+                            return extractFirmDataFromRcx();
+                        default:
+                            return FWUpdateProcResult.Fail;
+                    }
+                case 4:
+                    if (FirmwareManager.this.mPrinter.getIp() != null && FirmwareManager.isExistSaveFile()) {
+                        FirmwareManager firmwareManager2 = FirmwareManager.this;
+                        firmwareManager2.mSendProtocol = "https";
+                        FWUpdateProcResult download = download(firmwareManager2.getStartUpdateURL(), (File) null, false);
+                        if (download == FWUpdateProcResult.Success) {
+                            return download;
+                        }
+                        FirmwareManager firmwareManager3 = FirmwareManager.this;
+                        firmwareManager3.mSendProtocol = Analytics.EXTENSION_STRING_WEB;
+                        return download(firmwareManager3.getStartUpdateURL(), (File) null, false);
+                    }
+                case 5:
+                    return sendFW();
+            }
+            return FWUpdateProcResult.Fail;
+        }
+
+        /* access modifiers changed from: protected */
+        public void onPostExecute(FWUpdateProcResult fWUpdateProcResult) {
+            if (fWUpdateProcResult == FWUpdateProcResult.Success) {
+                switch (FirmwareManager.this.mProcStep) {
+                    case GetPrinterFWVersion:
+                        FirmwareManager.this.endWithProcResult(fWUpdateProcResult);
+                        return;
+                    case GetUpdateInf:
+                        FirmwareManager firmwareManager = FirmwareManager.this;
+                        firmwareManager.localCheckInfFileVersion(firmwareManager.mDlData);
+                        return;
+                    case Download:
+                        FirmwareManager.this.endWithProcResult(fWUpdateProcResult);
+                        return;
+                    case ReadyUpdate:
+                        FirmwareManager.this.startProc(FWUpdateStep.Send);
+                        return;
+                    case Send:
+                        FirmwareManager.this.endWithProcResult(fWUpdateProcResult);
+                        return;
+                    default:
+                        FirmwareManager.this.endWithProcResult(FWUpdateProcResult.Fail);
+                        return;
+                }
+            } else {
+                FirmwareManager.this.endWithProcResult(fWUpdateProcResult);
+            }
+        }
+
+        /* access modifiers changed from: protected */
+        public void onProgressUpdate(Integer... numArr) {
+            int i = 0;
+            if (numArr.length == 1 && C20021.$SwitchMap$epson$maintain$FirmwareManager$FWUpdateStep[FirmwareManager.this.mProcStep.ordinal()] != 4) {
+                i = numArr[0].intValue();
+            }
+            FirmwareManager.this.mUpdateListener.fwManagerProcDoing(i);
+        }
+
+        /* access modifiers changed from: protected */
+        public void onCancelled() {
+            Log.d(toString(), "onCancelled");
+        }
+
+        private FWUpdateProcResult downloadEfuFile(File file) {
+            String str = FirmwareManager.this.mFirmInfFile.getfuUrl();
+            if (str == null) {
+                return FWUpdateProcResult.NotSupport;
+            }
+            return download(str, file, false);
+        }
+
+        /* JADX WARNING: Code restructure failed: missing block: B:19:0x0059, code lost:
+            if (r2.exists() != false) goto L_0x005b;
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:20:0x005b, code lost:
+            r2.delete();
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:21:0x005f, code lost:
+            r0 = move-exception;
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:23:?, code lost:
+            r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail;
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:25:0x0067, code lost:
+            if (r1.exists() != false) goto L_0x0069;
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:26:0x0069, code lost:
+            r1.delete();
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:28:0x0070, code lost:
+            if (r2.exists() == false) goto L_0x0085;
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:30:?, code lost:
+            r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.DiskFull;
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:32:0x0079, code lost:
+            if (r1.exists() != false) goto L_0x007b;
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:33:0x007b, code lost:
+            r1.delete();
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:35:0x0082, code lost:
+            if (r2.exists() == false) goto L_0x0085;
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:36:0x0085, code lost:
+            return r0;
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:38:0x008a, code lost:
+            if (r1.exists() != false) goto L_0x008c;
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:39:0x008c, code lost:
+            r1.delete();
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:41:0x0093, code lost:
+            if (r2.exists() != false) goto L_0x0095;
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:42:0x0095, code lost:
+            r2.delete();
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:43:0x0098, code lost:
+            throw r0;
+         */
+        /* JADX WARNING: Exception block dominator not found, dom blocks: [B:22:0x0061, B:29:0x0073] */
+        /* JADX WARNING: Missing exception handler attribute for start block: B:22:0x0061 */
+        /* JADX WARNING: Missing exception handler attribute for start block: B:29:0x0073 */
+        /* JADX WARNING: Unknown top exception splitter block from list: {B:22:0x0061=Splitter:B:22:0x0061, B:29:0x0073=Splitter:B:29:0x0073} */
+        /* Code decompiled incorrectly, please refer to instructions dump. */
+        private epson.maintain.FirmwareManager.FWUpdateProcResult extractFirmDataFromRcx() {
+            /*
+                r5 = this;
+                java.io.File r0 = epson.maintain.FirmwareManager.createNewSaveFile()     // Catch:{ IOException -> 0x0099 }
+                java.io.File r1 = new java.io.File
+                java.io.File r2 = r0.getParentFile()
+                java.lang.String r3 = "zip.efu"
+                r1.<init>(r2, r3)
+                java.io.File r2 = new java.io.File
+                java.io.File r3 = r0.getParentFile()
+                java.lang.String r4 = "unzip.efu"
+                r2.<init>(r3, r4)
+                epson.maintain.FirmwareManager$FWUpdateProcResult r3 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail
+                epson.maintain.FirmwareManager$FWUpdateProcResult r3 = r5.downloadEfuFile(r1)     // Catch:{ WriteException -> 0x0073, IOException -> 0x0061 }
+                epson.maintain.FirmwareManager$FWUpdateProcResult r4 = epson.maintain.FirmwareManager.FWUpdateProcResult.Success     // Catch:{ WriteException -> 0x0073, IOException -> 0x0061 }
+                if (r3 == r4) goto L_0x0037
+                boolean r0 = r1.exists()
+                if (r0 == 0) goto L_0x002d
+                r1.delete()
+            L_0x002d:
+                boolean r0 = r2.exists()
+                if (r0 == 0) goto L_0x0036
+                r2.delete()
+            L_0x0036:
+                return r3
+            L_0x0037:
+                java.lang.String r3 = r1.getPath()     // Catch:{ WriteException -> 0x0073, IOException -> 0x0061 }
+                java.lang.String r4 = r2.getPath()     // Catch:{ WriteException -> 0x0073, IOException -> 0x0061 }
+                epson.maintain.EfuReader.unzipOnlyOneEntry(r3, r4)     // Catch:{ WriteException -> 0x0073, IOException -> 0x0061 }
+                epson.maintain.EfuReader r3 = new epson.maintain.EfuReader     // Catch:{ WriteException -> 0x0073, IOException -> 0x0061 }
+                r3.<init>()     // Catch:{ WriteException -> 0x0073, IOException -> 0x0061 }
+                r3.writeOnlyOneFirmwareData(r2, r0)     // Catch:{ WriteException -> 0x0073, IOException -> 0x0061 }
+                epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Success     // Catch:{ WriteException -> 0x0073, IOException -> 0x0061 }
+                boolean r3 = r1.exists()
+                if (r3 == 0) goto L_0x0055
+                r1.delete()
+            L_0x0055:
+                boolean r1 = r2.exists()
+                if (r1 == 0) goto L_0x0085
+            L_0x005b:
+                r2.delete()
+                goto L_0x0085
+            L_0x005f:
+                r0 = move-exception
+                goto L_0x0086
+            L_0x0061:
+                epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail     // Catch:{ all -> 0x005f }
+                boolean r3 = r1.exists()
+                if (r3 == 0) goto L_0x006c
+                r1.delete()
+            L_0x006c:
+                boolean r1 = r2.exists()
+                if (r1 == 0) goto L_0x0085
+                goto L_0x005b
+            L_0x0073:
+                epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.DiskFull     // Catch:{ all -> 0x005f }
+                boolean r3 = r1.exists()
+                if (r3 == 0) goto L_0x007e
+                r1.delete()
+            L_0x007e:
+                boolean r1 = r2.exists()
+                if (r1 == 0) goto L_0x0085
+                goto L_0x005b
+            L_0x0085:
+                return r0
+            L_0x0086:
+                boolean r3 = r1.exists()
+                if (r3 == 0) goto L_0x008f
+                r1.delete()
+            L_0x008f:
+                boolean r1 = r2.exists()
+                if (r1 == 0) goto L_0x0098
+                r2.delete()
+            L_0x0098:
+                throw r0
+            L_0x0099:
+                epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.DiskFull
+                return r0
+            */
+            throw new UnsupportedOperationException("Method not decompiled: epson.maintain.FirmwareManager.LocalAsyncTask.extractFirmDataFromRcx():epson.maintain.FirmwareManager$FWUpdateProcResult");
+        }
+
+        /* access modifiers changed from: package-private */
+        public FWUpdateProcResult download(String str, File file, boolean z) {
+            return download(str, file, z, 1, 1);
+        }
+
+        /* JADX WARNING: type inference failed for: r0v7, types: [java.net.URLConnection] */
+        /* access modifiers changed from: package-private */
+        /* JADX WARNING: Code restructure failed: missing block: B:105:0x0139, code lost:
+            if (r13 != null) goto L_0x0105;
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:75:0x0103, code lost:
+            if (r13 != null) goto L_0x0105;
+         */
+        /* JADX WARNING: Code restructure failed: missing block: B:78:?, code lost:
+            r13.disconnect();
+         */
+        /* JADX WARNING: Failed to process nested try/catch */
+        /* JADX WARNING: Missing exception handler attribute for start block: B:73:0x0100 */
+        /* JADX WARNING: Multi-variable type inference failed */
+        /* JADX WARNING: Removed duplicated region for block: B:102:0x0134 A[SYNTHETIC, Splitter:B:102:0x0134] */
+        /* JADX WARNING: Removed duplicated region for block: B:111:0x0142 A[SYNTHETIC, Splitter:B:111:0x0142] */
+        /* JADX WARNING: Removed duplicated region for block: B:115:0x0149 A[SYNTHETIC, Splitter:B:115:0x0149] */
+        /* JADX WARNING: Removed duplicated region for block: B:119:0x0150 A[SYNTHETIC, Splitter:B:119:0x0150] */
+        /* JADX WARNING: Removed duplicated region for block: B:98:0x012d A[SYNTHETIC, Splitter:B:98:0x012d] */
+        /* JADX WARNING: Unknown top exception splitter block from list: {B:39:0x0076=Splitter:B:39:0x0076, B:32:0x006e=Splitter:B:32:0x006e} */
+        /* Code decompiled incorrectly, please refer to instructions dump. */
+        public epson.maintain.FirmwareManager.FWUpdateProcResult download(java.lang.String r20, java.io.File r21, boolean r22, int r23, int r24) {
+            /*
+                r19 = this;
+                r1 = r19
+                r0 = r20
+                r2 = r21
+                if (r0 != 0) goto L_0x000b
+                epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail
+                return r0
+            L_0x000b:
+                r3 = 1
+                java.lang.Integer[] r4 = new java.lang.Integer[r3]
+                int r5 = r23 + -1
+                double r5 = (double) r5
+                r7 = 4636737291354636288(0x4059000000000000, double:100.0)
+                double r9 = r5 * r7
+                r11 = r24
+                double r11 = (double) r11
+                double r9 = r9 / r11
+                int r9 = (int) r9
+                java.lang.Integer r9 = java.lang.Integer.valueOf(r9)
+                r10 = 0
+                r4[r10] = r9
+                r1.publishProgress(r4)
+                epson.maintain.FirmwareManager$FWUpdateProcResult r4 = epson.maintain.FirmwareManager.FWUpdateProcResult.Success
+                java.net.URL r13 = new java.net.URL     // Catch:{ Exception -> 0x0122, all -> 0x011d }
+                r13.<init>(r0)     // Catch:{ Exception -> 0x0122, all -> 0x011d }
+                java.net.URLConnection r0 = r13.openConnection()     // Catch:{ Exception -> 0x0122, all -> 0x011d }
+                r13 = r0
+                java.net.HttpURLConnection r13 = (java.net.HttpURLConnection) r13     // Catch:{ Exception -> 0x0122, all -> 0x011d }
+                java.lang.String r0 = "GET"
+                r13.setRequestMethod(r0)     // Catch:{ Exception -> 0x0119, all -> 0x0116 }
+                r13.connect()     // Catch:{ Exception -> 0x0119, all -> 0x0116 }
+                int r0 = r13.getResponseCode()     // Catch:{ Exception -> 0x0119, all -> 0x0116 }
+                r14 = 400(0x190, float:5.6E-43)
+                r15 = 500(0x1f4, float:7.0E-43)
+                if (r14 > r0) goto L_0x004e
+                if (r0 >= r15) goto L_0x004e
+                epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.NotSupport     // Catch:{ Exception -> 0x0119, all -> 0x0116 }
+                if (r13 == 0) goto L_0x004d
+                r13.disconnect()     // Catch:{ Exception -> 0x004d }
+            L_0x004d:
+                return r0
+            L_0x004e:
+                if (r15 > r0) goto L_0x0076
+                r14 = 600(0x258, float:8.41E-43)
+                if (r0 >= r14) goto L_0x0076
+                if (r15 != r0) goto L_0x006e
+                int[] r0 = epson.maintain.FirmwareManager.C20021.$SwitchMap$epson$maintain$FirmwareManager$FWUpdateStep     // Catch:{ Exception -> 0x0119, all -> 0x0116 }
+                epson.maintain.FirmwareManager r2 = epson.maintain.FirmwareManager.this     // Catch:{ Exception -> 0x0119, all -> 0x0116 }
+                epson.maintain.FirmwareManager$FWUpdateStep r2 = r2.mProcStep     // Catch:{ Exception -> 0x0119, all -> 0x0116 }
+                int r2 = r2.ordinal()     // Catch:{ Exception -> 0x0119, all -> 0x0116 }
+                r0 = r0[r2]     // Catch:{ Exception -> 0x0119, all -> 0x0116 }
+                switch(r0) {
+                    case 4: goto L_0x0066;
+                    case 5: goto L_0x0066;
+                    default: goto L_0x0065;
+                }     // Catch:{ Exception -> 0x0119, all -> 0x0116 }
+            L_0x0065:
+                goto L_0x006e
+            L_0x0066:
+                epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.PrinterBadStatus     // Catch:{ Exception -> 0x0119, all -> 0x0116 }
+                if (r13 == 0) goto L_0x006d
+                r13.disconnect()     // Catch:{ Exception -> 0x006d }
+            L_0x006d:
+                return r0
+            L_0x006e:
+                epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail     // Catch:{ Exception -> 0x0119, all -> 0x0116 }
+                if (r13 == 0) goto L_0x0075
+                r13.disconnect()     // Catch:{ Exception -> 0x0075 }
+            L_0x0075:
+                return r0
+            L_0x0076:
+                java.io.BufferedInputStream r14 = new java.io.BufferedInputStream     // Catch:{ Exception -> 0x0119, all -> 0x0116 }
+                java.io.InputStream r0 = r13.getInputStream()     // Catch:{ Exception -> 0x0119, all -> 0x0116 }
+                r15 = 4096(0x1000, float:5.74E-42)
+                r14.<init>(r0, r15)     // Catch:{ Exception -> 0x0119, all -> 0x0116 }
+                if (r2 == 0) goto L_0x008b
+                java.io.FileOutputStream r0 = new java.io.FileOutputStream     // Catch:{ Exception -> 0x0112, all -> 0x010f }
+                r9 = r22
+                r0.<init>(r2, r9)     // Catch:{ Exception -> 0x0112, all -> 0x010f }
+                goto L_0x0090
+            L_0x008b:
+                java.io.ByteArrayOutputStream r0 = new java.io.ByteArrayOutputStream     // Catch:{ Exception -> 0x0112, all -> 0x010f }
+                r0.<init>()     // Catch:{ Exception -> 0x0112, all -> 0x010f }
+            L_0x0090:
+                r9 = r0
+                byte[] r0 = new byte[r15]     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                int r2 = r13.getContentLength()     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                long r7 = (long) r2     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                r17 = 0
+            L_0x009a:
+                int r2 = r14.read(r0)     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                r15 = -1
+                if (r2 == r15) goto L_0x00e5
+                boolean r15 = r19.isCancelled()     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                if (r15 == 0) goto L_0x00ad
+                r13.disconnect()     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                epson.maintain.FirmwareManager$FWUpdateProcResult r4 = epson.maintain.FirmwareManager.FWUpdateProcResult.Cancel     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                goto L_0x00e7
+            L_0x00ad:
+                r24 = r4
+                long r3 = (long) r2
+                long r3 = r17 + r3
+                r9.write(r0, r10, r2)     // Catch:{ IOException -> 0x00da }
+                r2 = 1
+                java.lang.Integer[] r15 = new java.lang.Integer[r2]     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                r16 = r11
+                double r10 = (double) r3     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                r22 = r3
+                double r2 = (double) r7     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                double r10 = r10 / r2
+                double r10 = r10 + r5
+                r2 = 4636737291354636288(0x4059000000000000, double:100.0)
+                double r10 = r10 * r2
+                double r10 = r10 / r16
+                int r10 = (int) r10     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                java.lang.Integer r10 = java.lang.Integer.valueOf(r10)     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                r11 = 0
+                r15[r11] = r10     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                r1.publishProgress(r15)     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                r4 = r24
+                r11 = r16
+                r3 = 1
+                r10 = 0
+                r17 = r22
+                goto L_0x009a
+            L_0x00da:
+                boolean r0 = r9 instanceof java.io.ByteArrayOutputStream     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                if (r0 == 0) goto L_0x00e1
+                epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                goto L_0x00e3
+            L_0x00e1:
+                epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.DiskFull     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+            L_0x00e3:
+                r4 = r0
+                goto L_0x00e7
+            L_0x00e5:
+                r24 = r4
+            L_0x00e7:
+                epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Success     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                if (r4 != r0) goto L_0x00fd
+                r9.flush()     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                boolean r0 = r9 instanceof java.io.ByteArrayOutputStream     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                if (r0 == 0) goto L_0x00fd
+                epson.maintain.FirmwareManager r0 = epson.maintain.FirmwareManager.this     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                r2 = r9
+                java.io.ByteArrayOutputStream r2 = (java.io.ByteArrayOutputStream) r2     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                byte[] r2 = r2.toByteArray()     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+                r0.mDlData = r2     // Catch:{ Exception -> 0x010b, all -> 0x0109 }
+            L_0x00fd:
+                r14.close()     // Catch:{ Exception -> 0x0100 }
+            L_0x0100:
+                r9.close()     // Catch:{ Exception -> 0x0103 }
+            L_0x0103:
+                if (r13 == 0) goto L_0x013c
+            L_0x0105:
+                r13.disconnect()     // Catch:{ Exception -> 0x013c }
+                goto L_0x013c
+            L_0x0109:
+                r0 = move-exception
+                goto L_0x0140
+            L_0x010b:
+                r0 = move-exception
+                r2 = r9
+                r9 = r14
+                goto L_0x0126
+            L_0x010f:
+                r0 = move-exception
+                r9 = 0
+                goto L_0x0140
+            L_0x0112:
+                r0 = move-exception
+                r9 = r14
+                r2 = 0
+                goto L_0x0126
+            L_0x0116:
+                r0 = move-exception
+                r9 = 0
+                goto L_0x0120
+            L_0x0119:
+                r0 = move-exception
+                r2 = 0
+                r9 = 0
+                goto L_0x0126
+            L_0x011d:
+                r0 = move-exception
+                r9 = 0
+                r13 = 0
+            L_0x0120:
+                r14 = 0
+                goto L_0x0140
+            L_0x0122:
+                r0 = move-exception
+                r2 = 0
+                r9 = 0
+                r13 = 0
+            L_0x0126:
+                r0.printStackTrace()     // Catch:{ all -> 0x013d }
+                epson.maintain.FirmwareManager$FWUpdateProcResult r4 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail     // Catch:{ all -> 0x013d }
+                if (r9 == 0) goto L_0x0132
+                r9.close()     // Catch:{ Exception -> 0x0131 }
+                goto L_0x0132
+            L_0x0131:
+            L_0x0132:
+                if (r2 == 0) goto L_0x0139
+                r2.close()     // Catch:{ Exception -> 0x0138 }
+                goto L_0x0139
+            L_0x0138:
+            L_0x0139:
+                if (r13 == 0) goto L_0x013c
+                goto L_0x0105
+            L_0x013c:
+                return r4
+            L_0x013d:
+                r0 = move-exception
+                r14 = r9
+                r9 = r2
+            L_0x0140:
+                if (r14 == 0) goto L_0x0147
+                r14.close()     // Catch:{ Exception -> 0x0146 }
+                goto L_0x0147
+            L_0x0146:
+            L_0x0147:
+                if (r9 == 0) goto L_0x014e
+                r9.close()     // Catch:{ Exception -> 0x014d }
+                goto L_0x014e
+            L_0x014d:
+            L_0x014e:
+                if (r13 == 0) goto L_0x0153
+                r13.disconnect()     // Catch:{ Exception -> 0x0153 }
+            L_0x0153:
+                throw r0
+            */
+            throw new UnsupportedOperationException("Method not decompiled: epson.maintain.FirmwareManager.LocalAsyncTask.download(java.lang.String, java.io.File, boolean, int, int):epson.maintain.FirmwareManager$FWUpdateProcResult");
+        }
+
+        /* access modifiers changed from: package-private */
+        public FWUpdateProcResult downloadNewFW() {
+            String access$500;
+            FWUpdateProcResult fWUpdateProcResult = FWUpdateProcResult.Success;
+            try {
+                File createNewSaveFile = FirmwareManager.createNewSaveFile();
+                String access$5002 = FirmwareManager.this.getNextRomURL();
+                if (access$5002 == null || FirmwareManager.this.mCurVer == null || FirmwareManager.this.mFirmInfFile.getMainVersion() == null) {
+                    return FWUpdateProcResult.Fail;
+                }
+                int romNum = FirmwareManager.this.mFirmInfFile.getRomNum();
+                FWUpdateProcResult download = download(access$5002, createNewSaveFile, false, FirmwareManager.this.mCurRomNum, romNum);
+                while (download == FWUpdateProcResult.Success && (access$500 = FirmwareManager.this.getNextRomURL()) != null) {
+                    if (isCancelled()) {
+                        return FWUpdateProcResult.Cancel;
+                    }
+                    download = download(access$500, createNewSaveFile, true, FirmwareManager.this.mCurRomNum, romNum);
+                }
+                return download;
+            } catch (IOException e) {
+                e.printStackTrace();
+                return FWUpdateProcResult.DiskFull;
+            } catch (Exception e2) {
+                e2.printStackTrace();
+                return FWUpdateProcResult.Fail;
+            }
+        }
+
+        /* access modifiers changed from: package-private */
+        /* JADX WARNING: Can't wrap try/catch for region: R(19:0|1|2|3|4|5|6|(3:7|8|(3:10|11|12)(1:65))|18|19|20|21|22|23|24|(1:(1:31))(1:27)|(2:33|34)|56|(2:59|66)(1:67)) */
+        /* JADX WARNING: Can't wrap try/catch for region: R(7:35|39|40|41|42|43|44) */
+        /* JADX WARNING: Missing exception handler attribute for start block: B:21:0x0160 */
+        /* JADX WARNING: Missing exception handler attribute for start block: B:23:0x0163 */
+        /* JADX WARNING: Missing exception handler attribute for start block: B:41:0x0187 */
+        /* JADX WARNING: Missing exception handler attribute for start block: B:43:0x018a */
+        /* JADX WARNING: Removed duplicated region for block: B:26:0x016d A[ADDED_TO_REGION, Catch:{ all -> 0x0180, Exception -> 0x018d, all -> 0x018b }] */
+        /* JADX WARNING: Removed duplicated region for block: B:33:0x017c A[SYNTHETIC, Splitter:B:33:0x017c] */
+        /* JADX WARNING: Removed duplicated region for block: B:59:0x01a4  */
+        /* JADX WARNING: Removed duplicated region for block: B:61:0x01a9 A[SYNTHETIC, Splitter:B:61:0x01a9] */
+        /* JADX WARNING: Removed duplicated region for block: B:67:? A[RETURN, SYNTHETIC] */
+        /* JADX WARNING: Unknown top exception splitter block from list: {B:23:0x0163=Splitter:B:23:0x0163, B:43:0x018a=Splitter:B:43:0x018a} */
+        /* Code decompiled incorrectly, please refer to instructions dump. */
+        public epson.maintain.FirmwareManager.FWUpdateProcResult sendFW() {
+            /*
+                r10 = this;
+                epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Success
+                r1 = 0
+                java.net.URL r2 = new java.net.URL     // Catch:{ Exception -> 0x0193 }
+                epson.maintain.FirmwareManager r3 = epson.maintain.FirmwareManager.this     // Catch:{ Exception -> 0x0193 }
+                java.lang.String r3 = r3.getSendFWURL()     // Catch:{ Exception -> 0x0193 }
+                r2.<init>(r3)     // Catch:{ Exception -> 0x0193 }
+                java.net.URLConnection r2 = r2.openConnection()     // Catch:{ Exception -> 0x0193 }
+                java.net.HttpURLConnection r2 = (java.net.HttpURLConnection) r2     // Catch:{ Exception -> 0x0193 }
+                java.io.ByteArrayOutputStream r1 = new java.io.ByteArrayOutputStream     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r1.<init>()     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.StringBuilder r3 = new java.lang.StringBuilder     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r3.<init>()     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r4 = "--"
+                r3.append(r4)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                epson.maintain.FirmwareManager r4 = epson.maintain.FirmwareManager.this     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r4 = r4.boundary     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r3.append(r4)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r4 = "\r\n"
+                r3.append(r4)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r3 = r3.toString()     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r4 = "UTF-8"
+                byte[] r3 = r3.getBytes(r4)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r1.write(r3)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.StringBuilder r3 = new java.lang.StringBuilder     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r3.<init>()     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r4 = "Content-Disposition: form-data; name=\"\"fname\"\"; filename=\""
+                r3.append(r4)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.io.File r4 = new java.io.File     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r5 = epson.maintain.FirmwareManager.FW_POST_FILE_PATH     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r4.<init>(r5)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r4 = r4.getName()     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r3.append(r4)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r4 = "\""
+                r3.append(r4)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r4 = "\r\n"
+                r3.append(r4)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r3 = r3.toString()     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r4 = "UTF-8"
+                byte[] r3 = r3.getBytes(r4)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r1.write(r3)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r3 = "Content-Type: application/octet-stream\r\n"
+                java.lang.String r4 = "UTF-8"
+                byte[] r3 = r3.getBytes(r4)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r1.write(r3)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r3 = "Content-Transfer-Encoding: binary\r\n"
+                java.lang.String r4 = "UTF-8"
+                byte[] r3 = r3.getBytes(r4)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r1.write(r3)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r3 = "\r\n"
+                java.lang.String r4 = "UTF-8"
+                byte[] r3 = r3.getBytes(r4)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r1.write(r3)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.io.File r3 = new java.io.File     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r4 = epson.maintain.FirmwareManager.FW_POST_FILE_PATH     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r3.<init>(r4)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.io.ByteArrayOutputStream r4 = new java.io.ByteArrayOutputStream     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r4.<init>()     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.StringBuilder r5 = new java.lang.StringBuilder     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r5.<init>()     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r6 = "--"
+                r5.append(r6)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                epson.maintain.FirmwareManager r6 = epson.maintain.FirmwareManager.this     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r6 = r6.boundary     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r5.append(r6)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r6 = "--"
+                r5.append(r6)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r6 = "\r\n"
+                r5.append(r6)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r5 = r5.toString()     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r6 = "UTF-8"
+                byte[] r5 = r5.getBytes(r6)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r4.write(r5)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                epson.maintain.FirmwareManager r5 = epson.maintain.FirmwareManager.this     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                int r6 = r1.size()     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                long r6 = (long) r6     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                long r8 = r3.length()     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                long r6 = r6 + r8
+                int r8 = r4.size()     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                long r8 = (long) r8     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                long r6 = r6 + r8
+                r5.mTotalSize = r6     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r5 = "POST"
+                r2.setRequestMethod(r5)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r5 = 1
+                r2.setDoOutput(r5)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r5 = "Content-Type"
+                java.lang.StringBuilder r6 = new java.lang.StringBuilder     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r6.<init>()     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r7 = "multipart/form-data; boundary="
+                r6.append(r7)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                epson.maintain.FirmwareManager r7 = epson.maintain.FirmwareManager.this     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r7 = r7.boundary     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r6.append(r7)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r6 = r6.toString()     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r2.setRequestProperty(r5, r6)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                epson.maintain.FirmwareManager r5 = epson.maintain.FirmwareManager.this     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                long r5 = r5.mTotalSize     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                int r6 = (int) r5     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r2.setFixedLengthStreamingMode(r6)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r2.connect()     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.io.BufferedInputStream r5 = new java.io.BufferedInputStream     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.io.FileInputStream r6 = new java.io.FileInputStream     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.lang.String r3 = r3.getPath()     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r6.<init>(r3)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r3 = 4096(0x1000, float:5.74E-42)
+                r5.<init>(r6, r3)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                epson.maintain.FirmwareManager$CountingOutputStream r6 = new epson.maintain.FirmwareManager$CountingOutputStream     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                java.io.OutputStream r7 = r2.getOutputStream()     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                epson.maintain.FirmwareManager$LocalAsyncTask$1 r8 = new epson.maintain.FirmwareManager$LocalAsyncTask$1     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r8.<init>(r2)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r6.<init>(r7, r8)     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r1.writeTo(r6)     // Catch:{ IOException -> 0x0182 }
+                byte[] r1 = new byte[r3]     // Catch:{ IOException -> 0x0182 }
+            L_0x012f:
+                int r3 = r5.read(r1)     // Catch:{ IOException -> 0x0182 }
+                r7 = -1
+                if (r3 == r7) goto L_0x0157
+                r7 = 0
+                r6.write(r1, r7, r3)     // Catch:{ IOException -> 0x013b }
+                goto L_0x012f
+            L_0x013b:
+                r0 = move-exception
+                java.lang.String r1 = "FirmwareManager"
+                java.lang.StringBuilder r3 = new java.lang.StringBuilder     // Catch:{ IOException -> 0x0182 }
+                r3.<init>()     // Catch:{ IOException -> 0x0182 }
+                java.lang.String r4 = "error: in executeFile() : "
+                r3.append(r4)     // Catch:{ IOException -> 0x0182 }
+                java.lang.String r4 = r0.toString()     // Catch:{ IOException -> 0x0182 }
+                r3.append(r4)     // Catch:{ IOException -> 0x0182 }
+                java.lang.String r3 = r3.toString()     // Catch:{ IOException -> 0x0182 }
+                epson.print.Util.EPLog.m318w((java.lang.String) r1, (java.lang.String) r3)     // Catch:{ IOException -> 0x0182 }
+                throw r0     // Catch:{ IOException -> 0x0182 }
+            L_0x0157:
+                r4.writeTo(r6)     // Catch:{ IOException -> 0x0182 }
+                r6.flush()     // Catch:{ IOException -> 0x0182 }
+                r5.close()     // Catch:{ IOException -> 0x0160 }
+            L_0x0160:
+                r6.close()     // Catch:{ IOException -> 0x0163 }
+            L_0x0163:
+                int r1 = r2.getResponseCode()     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                r3 = 400(0x190, float:5.6E-43)
+                r4 = 500(0x1f4, float:7.0E-43)
+                if (r3 > r1) goto L_0x0172
+                if (r1 >= r4) goto L_0x0172
+                epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.NotSupport     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+                goto L_0x017a
+            L_0x0172:
+                if (r4 > r1) goto L_0x017a
+                r3 = 600(0x258, float:8.41E-43)
+                if (r1 >= r3) goto L_0x017a
+                epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+            L_0x017a:
+                if (r2 == 0) goto L_0x019e
+                r2.disconnect()     // Catch:{ Exception -> 0x019e }
+                goto L_0x019e
+            L_0x0180:
+                r0 = move-exception
+                goto L_0x0184
+            L_0x0182:
+                r0 = move-exception
+                throw r0     // Catch:{ all -> 0x0180 }
+            L_0x0184:
+                r5.close()     // Catch:{ IOException -> 0x0187 }
+            L_0x0187:
+                r6.close()     // Catch:{ IOException -> 0x018a }
+            L_0x018a:
+                throw r0     // Catch:{ Exception -> 0x018d, all -> 0x018b }
+            L_0x018b:
+                r0 = move-exception
+                goto L_0x01a7
+            L_0x018d:
+                r0 = move-exception
+                r1 = r2
+                goto L_0x0194
+            L_0x0190:
+                r0 = move-exception
+                r2 = r1
+                goto L_0x01a7
+            L_0x0193:
+                r0 = move-exception
+            L_0x0194:
+                r0.printStackTrace()     // Catch:{ all -> 0x0190 }
+                epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail     // Catch:{ all -> 0x0190 }
+                if (r1 == 0) goto L_0x019e
+                r1.disconnect()     // Catch:{ Exception -> 0x019e }
+            L_0x019e:
+                boolean r1 = r10.isCancelled()
+                if (r1 == 0) goto L_0x01a6
+                epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Cancel
+            L_0x01a6:
+                return r0
+            L_0x01a7:
+                if (r2 == 0) goto L_0x01ac
+                r2.disconnect()     // Catch:{ Exception -> 0x01ac }
+            L_0x01ac:
+                throw r0
+            */
+            throw new UnsupportedOperationException("Method not decompiled: epson.maintain.FirmwareManager.LocalAsyncTask.sendFW():epson.maintain.FirmwareManager$FWUpdateProcResult");
+        }
+    }
+
+    @VisibleForTesting
+    static class MaintainPrinterWrapper {
+        private final MaintainPrinter2 mMaintainPrinter2 = MaintainPrinter2.getInstance();
+
+        MaintainPrinterWrapper() {
+        }
+
+        public int getFirmwareInfo(EnumMap<EscprLib.PrinterFirmInfo, String> enumMap) {
+            return this.mMaintainPrinter2.getFirmwareInfo(enumMap);
+        }
+
+        public int getBatteryInfoEx(BatteryInfoEx batteryInfoEx) {
+            return this.mMaintainPrinter2.getBatteryInfo(batteryInfoEx);
+        }
+    }
+}

+ 51 - 0
app/src/main/java/epson/maintain/activity/CheckEulaActivity.java

@@ -0,0 +1,51 @@
+package epson.maintain.activity;
+
+import android.os.Bundle;
+import android.support.p003v7.app.AppCompatActivity;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+import com.epson.mobilephone.common.license.RestoreScrollView;
+import epson.common.IprintLicenseInfo;
+import epson.print.C2135R;
+
+public class CheckEulaActivity extends AppCompatActivity {
+    private static final String KEY_SCROLL_Y = "scroll_y";
+    private RestoreScrollView mScrollView;
+
+    public void onBackPressed() {
+    }
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        setContentView((int) C2135R.layout.activity_check_eula);
+        ((Button) findViewById(C2135R.C2137id.eulaAgreeButton)).setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                CheckEulaActivity.this.finishWithResult(-1);
+            }
+        });
+        ((Button) findViewById(C2135R.C2137id.eulaDisagreeButton)).setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                CheckEulaActivity.this.finishWithResult(0);
+            }
+        });
+        this.mScrollView = (RestoreScrollView) findViewById(C2135R.C2137id.eulaCheckMainScrollView);
+        ((TextView) findViewById(C2135R.C2137id.eulaTextView)).setText(new IprintLicenseInfo().getDocumentString(this, 1));
+        if (bundle != null) {
+            this.mScrollView.setScrollY(bundle.getInt(KEY_SCROLL_Y, 0));
+        }
+    }
+
+    /* access modifiers changed from: protected */
+    public void onSaveInstanceState(Bundle bundle) {
+        super.onSaveInstanceState(bundle);
+        bundle.putInt(KEY_SCROLL_Y, this.mScrollView.getLastY());
+    }
+
+    /* access modifiers changed from: private */
+    public void finishWithResult(int i) {
+        setResult(i);
+        finish();
+    }
+}

+ 305 - 0
app/src/main/java/epson/maintain/activity/EccPrintLog.java

@@ -0,0 +1,305 @@
+package epson.maintain.activity;
+
+import android.arch.lifecycle.Observer;
+import android.arch.lifecycle.ViewModelProviders;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.support.p000v4.app.DialogFragment;
+import android.support.p000v4.app.FragmentActivity;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+import epson.common.DialogProgress;
+import epson.common.DialogProgressViewModel;
+import epson.print.ActivityIACommon;
+import epson.print.C2135R;
+import epson.print.Util.EPLog;
+import epson.print.ecclient.EccErrorInfo;
+import java.lang.ref.WeakReference;
+import java.util.Deque;
+import java.util.Locale;
+import org.opencv.core.Core;
+
+public class EccPrintLog extends ActivityIACommon implements DialogProgress.DialogButtonClick {
+    private static final String DIALOG_ERROR = "dialog_error";
+    private static final String DIALOG_PROGRESS = "dialog_progress";
+    static final String LOG_TAG = "EccPrintLog";
+    static RemotePrintHistoryTask mRemotePrintHistoryTask;
+    private EccPrintLogViewModel mEccPrintLogViewModel;
+    private DialogProgressViewModel mModelDialog;
+    private WebView mWebView;
+
+    public void onCancelDialog(String str) {
+    }
+
+    public void onNegativeClick(String str) {
+    }
+
+    public void onNeutralClick(String str) {
+    }
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        EPLog.m313i(LOG_TAG, "onCreate() start");
+        super.onCreate(bundle);
+        setContentView((int) C2135R.layout.epsonconnect_print_log);
+        this.mModelDialog = (DialogProgressViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(DialogProgressViewModel.class);
+        this.mModelDialog.getDialogJob().observe(this, new Observer() {
+            public final void onChanged(Object obj) {
+                EccPrintLog.lambda$onCreate$0(EccPrintLog.this, (Deque) obj);
+            }
+        });
+        this.mEccPrintLogViewModel = (EccPrintLogViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(EccPrintLogViewModel.class);
+        setActionBar((int) C2135R.string.epsonconnect_str_print_history, true);
+        this.mWebView = (WebView) findViewById(C2135R.C2137id.prtlog_webview);
+        this.mWebView.setVerticalScrollbarOverlay(true);
+        this.mWebView.getSettings().setJavaScriptEnabled(true);
+        this.mWebView.setWebViewClient(new WebViewClient() {
+            public void onReceivedError(WebView webView, int i, String str, String str2) {
+                int i2;
+                if (i != -15) {
+                    switch (i) {
+                        case Core.StsAutoTrace /*-8*/:
+                        case -7:
+                        case -6:
+                            break;
+                        default:
+                            i2 = -1200;
+                            break;
+                    }
+                }
+                i2 = -1100;
+                EccPrintLog.this.show_message_and_finish(i2);
+            }
+        });
+        startRemotePrintHistoryTask();
+    }
+
+    public static /* synthetic */ void lambda$onCreate$0(EccPrintLog eccPrintLog, Deque deque) {
+        String[] checkQueue = eccPrintLog.mModelDialog.checkQueue();
+        if (checkQueue != null) {
+            String str = checkQueue[0];
+            String str2 = checkQueue[1];
+            if (str2.equals("do_show")) {
+                eccPrintLog.showDialog(str);
+            }
+            if (str2.equals("do_dismiss")) {
+                eccPrintLog.dismissDialog(str);
+            }
+        }
+    }
+
+    private synchronized void startRemotePrintHistoryTask() {
+        if (mRemotePrintHistoryTask == null) {
+            EPLog.m313i(LOG_TAG, "RemotePrintHistoryTask creating.");
+            LogUrl logUrl = new LogUrl();
+            logUrl.setContextDependValue(this);
+            mRemotePrintHistoryTask = new RemotePrintHistoryTask(this);
+            mRemotePrintHistoryTask.execute(new LogUrl[]{logUrl});
+        } else {
+            EPLog.m313i(LOG_TAG, "RemotePrintHistoryTask exists. not create");
+            mRemotePrintHistoryTask.setActivity(this);
+        }
+        showProgressDialog();
+    }
+
+    /* access modifiers changed from: package-private */
+    public String[] getErrorTitleAndMessage(int i) {
+        String str;
+        String str2;
+        String[] strArr = new String[2];
+        getString(C2135R.string.ECC_ERR_SVR_GENERAL_TITLE);
+        if (i != -1100) {
+            if (i != 10) {
+                switch (i) {
+                    case EccErrorInfo.ECC_ERR_SVR_HTTP_NOT_FOUND /*-1209*/:
+                    case EccErrorInfo.ECC_ERR_SVR_BUSY /*-1208*/:
+                        str = getString(C2135R.string.ECC_ERR_SVR_BUSY_TITLE);
+                        str2 = getString(C2135R.string.ECC_ERR_SVR_BUSY);
+                        break;
+                    default:
+                        switch (i) {
+                            case -1203:
+                                str = getString(C2135R.string.ECC_ERR_SVR_INVALID_ACCESSKEY_TITLE);
+                                str2 = getString(C2135R.string.ECC_ERR_SVR_INVALID_ACCESSKEY);
+                                break;
+                            case -1202:
+                                str = getString(C2135R.string.ECC_ERR_SVR_REMOTE_INVALID_TITLE);
+                                str2 = getString(C2135R.string.ECC_ERR_SVR_REMOTE_INVALID);
+                                break;
+                            case -1201:
+                                str = getString(C2135R.string.ECC_ERR_SVR_NOT_REGISTERED_TITLE);
+                                str2 = getString(C2135R.string.ECC_ERR_SVR_NOT_REGISTERED);
+                                break;
+                        }
+                }
+            } else {
+                getString(C2135R.string.ECC_ERR_SVR_GENERAL_TITLE);
+            }
+            String string = getString(C2135R.string.ECC_ERR_SVR_GENERAL_TITLE);
+            str2 = getString(C2135R.string.ECC_ERR_SVR_GENERAL2) + "0X" + Integer.toHexString(i).toUpperCase(Locale.US) + getString(C2135R.string.ECC_ERR_SVR_GENERAL3);
+            str = string;
+        } else {
+            str = getString(C2135R.string.EC_ERR_COMM_ERROR_TITLE);
+            str2 = getString(C2135R.string.EC_ERR_COMM_ERROR);
+        }
+        strArr[0] = str;
+        strArr[1] = str2;
+        return strArr;
+    }
+
+    /* access modifiers changed from: private */
+    public void show_message_and_finish(int i) {
+        this.mEccPrintLogViewModel.setTitleAndMessage(getErrorTitleAndMessage(i));
+        this.mModelDialog.doShow(DIALOG_ERROR);
+    }
+
+    /* access modifiers changed from: protected */
+    public void onDestroy() {
+        dissmissProgressDialog();
+        super.onDestroy();
+    }
+
+    /* access modifiers changed from: package-private */
+    public void dissmissProgressDialog() {
+        this.mModelDialog.doDismiss(DIALOG_PROGRESS);
+    }
+
+    /* access modifiers changed from: package-private */
+    public void showProgressDialog() {
+        this.mModelDialog.doShow(DIALOG_PROGRESS);
+    }
+
+    /* JADX WARNING: Can't fix incorrect switch cases order */
+    /* JADX WARNING: Removed duplicated region for block: B:12:0x002a  */
+    /* JADX WARNING: Removed duplicated region for block: B:15:0x0046  */
+    /* JADX WARNING: Removed duplicated region for block: B:16:0x0052 A[FALL_THROUGH] */
+    /* JADX WARNING: Removed duplicated region for block: B:18:0x0055  */
+    /* JADX WARNING: Removed duplicated region for block: B:20:? A[RETURN, SYNTHETIC] */
+    /* Code decompiled incorrectly, please refer to instructions dump. */
+    private void showDialog(java.lang.String r12) {
+        /*
+            r11 = this;
+            int r0 = r12.hashCode()
+            r1 = -21731516(0xfffffffffeb46744, float:-1.1989861E38)
+            r2 = 1
+            r3 = 0
+            if (r0 == r1) goto L_0x001b
+            r1 = 722082897(0x2b0a1c51, float:4.9066746E-13)
+            if (r0 == r1) goto L_0x0011
+            goto L_0x0025
+        L_0x0011:
+            java.lang.String r0 = "dialog_error"
+            boolean r0 = r12.equals(r0)
+            if (r0 == 0) goto L_0x0025
+            r0 = 1
+            goto L_0x0026
+        L_0x001b:
+            java.lang.String r0 = "dialog_progress"
+            boolean r0 = r12.equals(r0)
+            if (r0 == 0) goto L_0x0025
+            r0 = 0
+            goto L_0x0026
+        L_0x0025:
+            r0 = -1
+        L_0x0026:
+            switch(r0) {
+                case 0: goto L_0x0046;
+                case 1: goto L_0x002a;
+                default: goto L_0x0029;
+            }
+        L_0x0029:
+            goto L_0x0052
+        L_0x002a:
+            epson.maintain.activity.EccPrintLogViewModel r0 = r11.mEccPrintLogViewModel
+            java.lang.String[] r0 = r0.getTitleAndMessage()
+            if (r0 == 0) goto L_0x0052
+            r5 = 2
+            r6 = r0[r2]
+            r7 = r0[r3]
+            r0 = 2131624958(0x7f0e03fe, float:1.887711E38)
+            java.lang.String r8 = r11.getString(r0)
+            r9 = 0
+            r10 = 0
+            r4 = r12
+            epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r4, r5, r6, r7, r8, r9, r10)
+            goto L_0x0053
+        L_0x0046:
+            r0 = 2131625243(0x7f0e051b, float:1.8877688E38)
+            java.lang.String r0 = r11.getString(r0)
+            epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r12, r3, r0)
+            goto L_0x0053
+        L_0x0052:
+            r0 = 0
+        L_0x0053:
+            if (r0 == 0) goto L_0x005f
+            r0.setCancelable(r3)
+            android.support.v4.app.FragmentManager r1 = r11.getSupportFragmentManager()
+            r0.show(r1, r12)
+        L_0x005f:
+            return
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.maintain.activity.EccPrintLog.showDialog(java.lang.String):void");
+    }
+
+    private void dismissDialog(String str) {
+        DialogFragment dialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(str);
+        if (dialogFragment != null) {
+            dialogFragment.dismiss();
+        }
+    }
+
+    public synchronized void setUrl(String str, int i) {
+        mRemotePrintHistoryTask = null;
+        EPLog.m313i(LOG_TAG, "setUrl");
+        dissmissProgressDialog();
+        if (str == null || i != 0) {
+            show_message_and_finish(i);
+        }
+        if (this.mWebView != null) {
+            this.mWebView.loadUrl(str);
+        }
+    }
+
+    public void onPositiveClick(String str) {
+        if (((str.hashCode() == 722082897 && str.equals(DIALOG_ERROR)) ? (char) 0 : 65535) == 0) {
+            finish();
+        }
+    }
+
+    static class RemotePrintHistoryTask extends AsyncTask<LogUrl, Void, Void> {
+        WeakReference<EccPrintLog> mEccPrintLog;
+        int mErrorCode;
+        private String mLogUrl;
+
+        public RemotePrintHistoryTask(EccPrintLog eccPrintLog) {
+            this.mEccPrintLog = new WeakReference<>(eccPrintLog);
+        }
+
+        public void setActivity(EccPrintLog eccPrintLog) {
+            this.mEccPrintLog = new WeakReference<>(eccPrintLog);
+        }
+
+        /* access modifiers changed from: protected */
+        public Void doInBackground(LogUrl... logUrlArr) {
+            try {
+                this.mLogUrl = logUrlArr[0].getUrl();
+                this.mErrorCode = 0;
+                return null;
+            } catch (EccPrintLogException e) {
+                this.mErrorCode = e.getErrorCode();
+                return null;
+            }
+        }
+
+        /* access modifiers changed from: protected */
+        public void onPostExecute(Void voidR) {
+            EccPrintLog eccPrintLog;
+            EPLog.m313i(EccPrintLog.LOG_TAG, "onPostExecute() begin");
+            WeakReference<EccPrintLog> weakReference = this.mEccPrintLog;
+            if (weakReference != null && (eccPrintLog = (EccPrintLog) weakReference.get()) != null) {
+                eccPrintLog.setUrl(this.mLogUrl, this.mErrorCode);
+                EPLog.m313i(EccPrintLog.LOG_TAG, "onPostExecute() end");
+            }
+        }
+    }
+}

+ 16 - 0
app/src/main/java/epson/maintain/activity/EccPrintLogException.java

@@ -0,0 +1,16 @@
+package epson.maintain.activity;
+
+/* compiled from: EccPrintLog */
+class EccPrintLogException extends Exception {
+    public static final int ECC_LIB_INITIAL_ERROR = 10;
+    private static final long serialVersionUID = 1;
+    public int mErrorCode;
+
+    public EccPrintLogException(int i) {
+        this.mErrorCode = i;
+    }
+
+    public int getErrorCode() {
+        return this.mErrorCode;
+    }
+}

+ 17 - 0
app/src/main/java/epson/maintain/activity/EccPrintLogViewModel.java

@@ -0,0 +1,17 @@
+package epson.maintain.activity;
+
+import android.arch.lifecycle.ViewModel;
+
+public class EccPrintLogViewModel extends ViewModel {
+    private String[] mTitleAndMessage;
+
+    /* access modifiers changed from: protected */
+    public void setTitleAndMessage(String[] strArr) {
+        this.mTitleAndMessage = strArr;
+    }
+
+    /* access modifiers changed from: protected */
+    public String[] getTitleAndMessage() {
+        return this.mTitleAndMessage;
+    }
+}

+ 426 - 0
app/src/main/java/epson/maintain/activity/FirmwareUpdateActivity.java

@@ -0,0 +1,426 @@
+package epson.maintain.activity;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
+import epson.maintain.FirmwareManager;
+import epson.print.C2135R;
+import epson.print.MyPrinter;
+
+public class FirmwareUpdateActivity extends Activity implements FirmwareManager.FWUpdateListener {
+    static final String PRINTER_IP = "PRINTER_IP";
+    static final String PRINTER_MODEL_NAME = "PRINTER_MODEL_NAME";
+    static final int RECONNECT_SIMPLE_AP = 100;
+    private static final int REQUEST_CODE_EULA = 101;
+    Button mCancelButton;
+    AlertDialog mDialog = null;
+    FirmwareManager mFWManager;
+    final DialogInterface.OnClickListener mGoBackOnClickListenner = new DialogInterface.OnClickListener() {
+        public void onClick(DialogInterface dialogInterface, int i) {
+            FirmwareUpdateActivity.this.goBack();
+        }
+    };
+    boolean mInterrupted = false;
+    TextView mMessageText;
+    String mPrinterIP;
+    ProgressBar mProgress;
+    boolean mReconnectingSimpleAP = false;
+    boolean mShouldReconnectSimpleAP = false;
+    TextView mTitleText;
+    private boolean mWaitEulaCheckActivityEnd;
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        setContentView(C2135R.layout.fwupdate_progress);
+        this.mFWManager = new FirmwareManager(this, MyPrinter.getCurPrinter(this));
+        this.mMessageText = (TextView) findViewById(C2135R.C2137id.messageText);
+        this.mTitleText = (TextView) findViewById(C2135R.C2137id.messageTitle);
+        this.mProgress = (ProgressBar) findViewById(C2135R.C2137id.horizontalProgressBar);
+        this.mCancelButton = (Button) findViewById(C2135R.C2137id.cancelButton);
+        this.mWaitEulaCheckActivityEnd = false;
+        MyPrinter curPrinter = MyPrinter.getCurPrinter(this);
+        Intent intent = getIntent();
+        this.mPrinterIP = intent.getStringExtra("PRINTER_IP");
+        if (this.mPrinterIP == null) {
+            this.mPrinterIP = curPrinter.getIp();
+        }
+        this.mFWManager = new FirmwareManager(this, new MyPrinter(intent.getStringExtra(PRINTER_MODEL_NAME), this.mPrinterIP, curPrinter.getPrinterId(), curPrinter.getSerialNo()));
+        this.mCancelButton.setText(C2135R.string.str_cancel);
+        this.mCancelButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                FirmwareUpdateActivity.this.mFWManager.cancelProc();
+            }
+        });
+        setMessage(getResources().getString(C2135R.string.fw_checking_version), (String) null);
+        setProcCancelable(false);
+        if (bundle == null) {
+            this.mFWManager.startVersionCheck(this);
+        } else {
+            this.mInterrupted = true;
+        }
+    }
+
+    /* access modifiers changed from: protected */
+    public void onResume() {
+        super.onResume();
+        Log.d(toString(), String.format("onResume mReconnectingSimpleAP=%b mInterrupted=%b", new Object[]{Boolean.valueOf(this.mReconnectingSimpleAP), Boolean.valueOf(this.mInterrupted)}));
+        if (this.mInterrupted) {
+            showAlertDialog(getResources().getString(C2135R.string.fw_error_interrupted), getResources().getString(C2135R.string.fw_try_again), this.mGoBackOnClickListenner, (DialogInterface.OnClickListener) null);
+        }
+    }
+
+    /* access modifiers changed from: protected */
+    public void onPause() {
+        super.onPause();
+        AlertDialog alertDialog = this.mDialog;
+        if ((alertDialog == null || !alertDialog.isShowing()) && !this.mWaitEulaCheckActivityEnd && !this.mReconnectingSimpleAP) {
+            this.mInterrupted = true;
+            this.mFWManager.interruptProc();
+        }
+    }
+
+    public void onActivityResult(int i, int i2, Intent intent) {
+        Log.d(toString(), String.format("onAcitivityReuslt requestCode=%d resultCode=%d", new Object[]{Integer.valueOf(i), Integer.valueOf(i2)}));
+        if (i == 100) {
+            this.mShouldReconnectSimpleAP = false;
+            this.mReconnectingSimpleAP = false;
+            if (i2 != -1 || !WiFiDirectManager.isSimpleAP(this)) {
+                fwManagerDidEndProc(FirmwareManager.FWUpdateProcResult.Fail, FirmwareManager.FWUpdateStep.ReadyUpdate);
+            } else {
+                this.mFWManager.startFWUpdate(this);
+            }
+        } else if (i == 101) {
+            this.mWaitEulaCheckActivityEnd = false;
+            if (i2 != -1) {
+                goBack();
+            } else if (!this.mInterrupted) {
+                callStartDownload();
+            }
+        }
+    }
+
+    public boolean dispatchKeyEvent(KeyEvent keyEvent) {
+        if (keyEvent.getAction() == 0 && keyEvent.getKeyCode() == 4) {
+            return true;
+        }
+        return super.dispatchKeyEvent(keyEvent);
+    }
+
+    /* access modifiers changed from: package-private */
+    /* JADX WARNING: Can't fix incorrect switch cases order */
+    /* Code decompiled incorrectly, please refer to instructions dump. */
+    public java.lang.String[] getEndProcTitleAndMessage(epson.maintain.FirmwareManager.FWUpdateProcResult r6, epson.maintain.FirmwareManager.FWUpdateStep r7) {
+        /*
+            r5 = this;
+            int[] r0 = epson.maintain.activity.FirmwareUpdateActivity.C20104.$SwitchMap$epson$maintain$FirmwareManager$FWUpdateProcResult
+            int r6 = r6.ordinal()
+            r6 = r0[r6]
+            r0 = 2131624842(0x7f0e038a, float:1.8876875E38)
+            r1 = 0
+            r2 = 0
+            r3 = 2
+            r4 = 1
+            switch(r6) {
+                case 1: goto L_0x011e;
+                case 2: goto L_0x0101;
+                case 3: goto L_0x00be;
+                case 4: goto L_0x0073;
+                case 5: goto L_0x0055;
+                case 6: goto L_0x003a;
+                case 7: goto L_0x001f;
+                case 8: goto L_0x0014;
+                default: goto L_0x0012;
+            }
+        L_0x0012:
+            goto L_0x0130
+        L_0x0014:
+            java.lang.String r6 = r5.toString()
+            java.lang.String r7 = "MSG_CANCELED"
+            android.util.Log.d(r6, r7)
+            goto L_0x0130
+        L_0x001f:
+            java.lang.String[] r6 = new java.lang.String[r3]
+            android.content.res.Resources r7 = r5.getResources()
+            java.lang.String r7 = r7.getString(r0)
+            r6[r2] = r7
+            android.content.res.Resources r7 = r5.getResources()
+            r0 = 2131624826(0x7f0e037a, float:1.8876843E38)
+            java.lang.String r7 = r7.getString(r0)
+            r6[r4] = r7
+            goto L_0x0131
+        L_0x003a:
+            java.lang.String[] r6 = new java.lang.String[r3]
+            android.content.res.Resources r7 = r5.getResources()
+            java.lang.String r7 = r7.getString(r0)
+            r6[r2] = r7
+            android.content.res.Resources r7 = r5.getResources()
+            r0 = 2131624831(0x7f0e037f, float:1.8876853E38)
+            java.lang.String r7 = r7.getString(r0)
+            r6[r4] = r7
+            goto L_0x0131
+        L_0x0055:
+            java.lang.String[] r6 = new java.lang.String[r3]
+            android.content.res.Resources r7 = r5.getResources()
+            r0 = 2131624832(0x7f0e0380, float:1.8876855E38)
+            java.lang.String r7 = r7.getString(r0)
+            r6[r2] = r7
+            android.content.res.Resources r7 = r5.getResources()
+            r0 = 2131624833(0x7f0e0381, float:1.8876857E38)
+            java.lang.String r7 = r7.getString(r0)
+            r6[r4] = r7
+            goto L_0x0131
+        L_0x0073:
+            int[] r6 = epson.maintain.activity.FirmwareUpdateActivity.C20104.$SwitchMap$epson$maintain$FirmwareManager$FWUpdateStep
+            int r7 = r7.ordinal()
+            r6 = r6[r7]
+            if (r6 == r4) goto L_0x00a0
+            r7 = 5
+            if (r6 == r7) goto L_0x0082
+            goto L_0x0130
+        L_0x0082:
+            java.lang.String[] r6 = new java.lang.String[r3]
+            android.content.res.Resources r7 = r5.getResources()
+            r0 = 2131624839(0x7f0e0387, float:1.887687E38)
+            java.lang.String r7 = r7.getString(r0)
+            r6[r2] = r7
+            android.content.res.Resources r7 = r5.getResources()
+            r0 = 2131624840(0x7f0e0388, float:1.8876871E38)
+            java.lang.String r7 = r7.getString(r0)
+            r6[r4] = r7
+            goto L_0x0131
+        L_0x00a0:
+            java.lang.String[] r6 = new java.lang.String[r3]
+            android.content.res.Resources r7 = r5.getResources()
+            r0 = 2131624835(0x7f0e0383, float:1.887686E38)
+            java.lang.String r7 = r7.getString(r0)
+            r6[r2] = r7
+            android.content.res.Resources r7 = r5.getResources()
+            r0 = 2131624836(0x7f0e0384, float:1.8876863E38)
+            java.lang.String r7 = r7.getString(r0)
+            r6[r4] = r7
+            goto L_0x0131
+        L_0x00be:
+            int[] r6 = epson.maintain.activity.FirmwareUpdateActivity.C20104.$SwitchMap$epson$maintain$FirmwareManager$FWUpdateStep
+            int r7 = r7.ordinal()
+            r6 = r6[r7]
+            switch(r6) {
+                case 1: goto L_0x00e4;
+                case 2: goto L_0x00e4;
+                case 3: goto L_0x00ca;
+                case 4: goto L_0x00ca;
+                case 5: goto L_0x00ca;
+                default: goto L_0x00c9;
+            }
+        L_0x00c9:
+            goto L_0x0130
+        L_0x00ca:
+            java.lang.String[] r6 = new java.lang.String[r3]
+            android.content.res.Resources r7 = r5.getResources()
+            r3 = 2131624827(0x7f0e037b, float:1.8876845E38)
+            java.lang.String r7 = r7.getString(r3)
+            r6[r2] = r7
+            android.content.res.Resources r7 = r5.getResources()
+            java.lang.String r7 = r7.getString(r0)
+            r6[r4] = r7
+            goto L_0x0131
+        L_0x00e4:
+            java.lang.String[] r6 = new java.lang.String[r3]
+            android.content.res.Resources r7 = r5.getResources()
+            r0 = 2131624828(0x7f0e037c, float:1.8876847E38)
+            java.lang.String r7 = r7.getString(r0)
+            r6[r2] = r7
+            android.content.res.Resources r7 = r5.getResources()
+            r0 = 2131624829(0x7f0e037d, float:1.8876849E38)
+            java.lang.String r7 = r7.getString(r0)
+            r6[r4] = r7
+            goto L_0x0131
+        L_0x0101:
+            java.lang.String[] r6 = new java.lang.String[r3]
+            android.content.res.Resources r7 = r5.getResources()
+            r0 = 2131624837(0x7f0e0385, float:1.8876865E38)
+            java.lang.String r7 = r7.getString(r0)
+            r6[r2] = r7
+            android.content.res.Resources r7 = r5.getResources()
+            r0 = 2131624838(0x7f0e0386, float:1.8876867E38)
+            java.lang.String r7 = r7.getString(r0)
+            r6[r4] = r7
+            goto L_0x0131
+        L_0x011e:
+            java.lang.String[] r6 = new java.lang.String[r3]
+            r6[r2] = r1
+            android.content.res.Resources r7 = r5.getResources()
+            r0 = 2131624834(0x7f0e0382, float:1.8876859E38)
+            java.lang.String r7 = r7.getString(r0)
+            r6[r4] = r7
+            goto L_0x0131
+        L_0x0130:
+            r6 = r1
+        L_0x0131:
+            if (r6 != 0) goto L_0x0137
+            java.lang.String[] r6 = new java.lang.String[]{r1, r1}
+        L_0x0137:
+            return r6
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.maintain.activity.FirmwareUpdateActivity.getEndProcTitleAndMessage(epson.maintain.FirmwareManager$FWUpdateProcResult, epson.maintain.FirmwareManager$FWUpdateStep):java.lang.String[]");
+    }
+
+    public void fwManagerProcDoing(int i) {
+        this.mProgress.setProgress(i);
+    }
+
+    public void fwManagerDidEndProc(FirmwareManager.FWUpdateProcResult fWUpdateProcResult, FirmwareManager.FWUpdateStep fWUpdateStep) {
+        int i;
+        String[] endProcTitleAndMessage = getEndProcTitleAndMessage(fWUpdateProcResult, fWUpdateStep);
+        String str = endProcTitleAndMessage[0];
+        String str2 = endProcTitleAndMessage[1];
+        getWindow().clearFlags(128);
+        if (fWUpdateProcResult == FirmwareManager.FWUpdateProcResult.Success && (i = C20104.$SwitchMap$epson$maintain$FirmwareManager$FWUpdateStep[fWUpdateStep.ordinal()]) != 5) {
+            switch (i) {
+                case 1:
+                    showAlertDialog(str, str2, getString(C2135R.string.str_yes), new DialogInterface.OnClickListener() {
+                        public void onClick(DialogInterface dialogInterface, int i) {
+                            FirmwareUpdateActivity.this.startEulaActivity();
+                        }
+                    }, getString(C2135R.string.str_no), this.mGoBackOnClickListenner);
+                    return;
+                case 2:
+                    setMessage(getResources().getString(C2135R.string.fw_transferring), (String) null);
+                    getWindow().addFlags(128);
+                    if (this.mShouldReconnectSimpleAP) {
+                        this.mReconnectingSimpleAP = true;
+                        if (!WiFiDirectManager.reconnect(this, WiFiDirectManager.DEVICE_TYPE_PRINTER, 100)) {
+                            this.mReconnectingSimpleAP = false;
+                            fwManagerDidEndProc(FirmwareManager.FWUpdateProcResult.Fail, FirmwareManager.FWUpdateStep.ReadyUpdate);
+                            return;
+                        }
+                        return;
+                    }
+                    this.mFWManager.startFWUpdate(this);
+                    return;
+                case 3:
+                    if (WiFiDirectManager.isSimpleAP(this)) {
+                        new DisconnectAndStartGetUpdateInfTask().execute(new Void[0]);
+                        return;
+                    } else {
+                        this.mFWManager.startGetUpdateInf(this);
+                        return;
+                    }
+                default:
+                    String obj = toString();
+                    Log.d(obj, "Not Reachable:" + fWUpdateStep);
+                    break;
+            }
+        }
+        if (str != null || str2 != null) {
+            showAlertDialog(str, str2, this.mGoBackOnClickListenner, (DialogInterface.OnClickListener) null);
+        } else if (fWUpdateProcResult != FirmwareManager.FWUpdateProcResult.Interrupted) {
+            goBack();
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void startEulaActivity() {
+        this.mWaitEulaCheckActivityEnd = true;
+        startActivityForResult(new Intent(this, CheckEulaActivity.class), 101);
+    }
+
+    private void callStartDownload() {
+        getWindow().addFlags(128);
+        setProgressVisibility(true);
+        setProcCancelable(true);
+        setMessage(getResources().getString(C2135R.string.fw_downloading), (String) null);
+        this.mFWManager.startFWDownload(this);
+    }
+
+    /* access modifiers changed from: package-private */
+    public void setProcCancelable(boolean z) {
+        this.mCancelButton.setVisibility(z ? 0 : 8);
+    }
+
+    /* access modifiers changed from: package-private */
+    public void setProgressVisibility(boolean z) {
+        this.mProgress.setVisibility(z ? 0 : 8);
+    }
+
+    /* access modifiers changed from: package-private */
+    public void setMessage(String str, String str2) {
+        if (str != null) {
+            this.mTitleText.setText(str);
+            this.mTitleText.setVisibility(0);
+        } else {
+            this.mTitleText.setVisibility(8);
+        }
+        if (str2 != null) {
+            this.mMessageText.setText(str2);
+            this.mMessageText.setVisibility(0);
+            return;
+        }
+        this.mMessageText.setVisibility(8);
+    }
+
+    /* access modifiers changed from: package-private */
+    public void showAlertDialog(String str, String str2, DialogInterface.OnClickListener onClickListener, DialogInterface.OnClickListener onClickListener2) {
+        String str3 = null;
+        String string = onClickListener != null ? getString(C2135R.string.str_ok) : null;
+        if (onClickListener2 != null) {
+            str3 = getString(C2135R.string.str_cancel);
+        }
+        showAlertDialog(str, str2, string, onClickListener, str3, onClickListener2);
+    }
+
+    /* access modifiers changed from: package-private */
+    public void showAlertDialog(String str, String str2, String str3, DialogInterface.OnClickListener onClickListener, String str4, DialogInterface.OnClickListener onClickListener2) {
+        dismissAlertDialog();
+        this.mDialog = new AlertDialog.Builder(this).setTitle(str).setMessage(str2).setCancelable(false).setPositiveButton(str3, onClickListener).setNegativeButton(str4, onClickListener2).create();
+        this.mDialog.show();
+    }
+
+    /* access modifiers changed from: package-private */
+    public void dismissAlertDialog() {
+        AlertDialog alertDialog = this.mDialog;
+        if (alertDialog != null && alertDialog.isShowing()) {
+            this.mDialog.dismiss();
+        }
+    }
+
+    /* access modifiers changed from: package-private */
+    public void goBack() {
+        FirmwareManager.removeSavedFile();
+        dismissAlertDialog();
+        finish();
+    }
+
+    class DisconnectAndStartGetUpdateInfTask extends AsyncTask<Void, Void, Boolean> {
+        DisconnectAndStartGetUpdateInfTask() {
+        }
+
+        /* access modifiers changed from: protected */
+        public Boolean doInBackground(Void... voidArr) {
+            FirmwareUpdateActivity firmwareUpdateActivity = FirmwareUpdateActivity.this;
+            return Boolean.valueOf(MaintainActivity.disableSimpleApAndWait(firmwareUpdateActivity, firmwareUpdateActivity.mPrinterIP));
+        }
+
+        /* access modifiers changed from: protected */
+        public void onPostExecute(Boolean bool) {
+            super.onPostExecute(bool);
+            if (bool.booleanValue()) {
+                FirmwareUpdateActivity firmwareUpdateActivity = FirmwareUpdateActivity.this;
+                firmwareUpdateActivity.mShouldReconnectSimpleAP = true;
+                firmwareUpdateActivity.mFWManager.startGetUpdateInf(FirmwareUpdateActivity.this);
+                return;
+            }
+            FirmwareUpdateActivity.this.fwManagerDidEndProc(FirmwareManager.FWUpdateProcResult.Fail, FirmwareManager.FWUpdateStep.GetUpdateInf);
+        }
+    }
+}

+ 609 - 0
app/src/main/java/epson/maintain/activity/GetPrinterReplyData.java

@@ -0,0 +1,609 @@
+package epson.maintain.activity;
+
+import android.app.Dialog;
+import android.arch.lifecycle.Observer;
+import android.arch.lifecycle.ViewModelProviders;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.support.p000v4.app.DialogFragment;
+import android.support.p000v4.app.FragmentActivity;
+import android.support.p003v7.app.AppCompatActivity;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import com.epson.iprint.shared.SharedParamStatus;
+import com.epson.mobilephone.common.escpr.MediaInfo;
+import com.epson.mobilephone.common.maintain2.MaintainPrinter2;
+import com.epson.mobilephone.common.maintain2.MaintainPrinterInfo2;
+import epson.common.Constants;
+import epson.common.DialogProgress;
+import epson.common.DialogProgressViewModel;
+import epson.common.Utils;
+import epson.print.C2135R;
+import epson.print.CommonDefine;
+import epson.print.MyPrinter;
+import epson.print.Util.EPLog;
+import java.util.ArrayList;
+import java.util.Deque;
+
+public class GetPrinterReplyData extends AppCompatActivity implements MediaInfo, DialogProgress.DialogButtonClick {
+    private static final int CLEANING_ERROR = 10;
+    private static final int DELAY_TIME_MAINTAIN = 10;
+    private static final String DIALOG_PROGRESS = "dialog_progress";
+    private static final int END_REPLYDATA = 99;
+    private static final int EPS_COMM_BID = 2;
+    private static final int EPS_LANG_ESCPR = 1;
+    private static final int EPS_MNT_CLEANING = 2;
+    private static final int EPS_MNT_NOZZLE = 3;
+    private static final int EPS_PRNERR_CEMPTY = 103;
+    private static final int EPS_PRNERR_CFAIL = 104;
+    private static final int EPS_PRNERR_DISABEL_CLEANING = 108;
+    private static final int EPS_PRNERR_INKOUT = 6;
+    private static final int GET_PRINTER_NAME = 8;
+    private static final int HANDLE_ERROR = 4;
+    public static final int ITEM_HEIGHT = 40;
+    private static final int MAINTAIN_OK = 1;
+    private static final int MAINTAIN_START = 0;
+    private static final int NO_PRINTER_NAME = 9;
+    public static final String PREFS_NAME = "PrintSetting";
+    private static final int PROBE_ERROR = 7;
+    private static final String PROBE_RESULT = "PROBE_ERROR";
+    private static final int START_LOADCONFIG = 6;
+    private static final String TAG = "MAINTAIN";
+    private static final int UPDATE_INK = 3;
+    private static final int UPDATE_SELECTED_PRINTER = 5;
+    private static final int UPDATE_STT = 2;
+    public static MaintainPrinter2 mPrinter;
+    private Dialog customPro;
+    /* access modifiers changed from: private */
+    public SharedParamStatus extParam;
+    boolean isGotError = false;
+    boolean isResearchScanner = false;
+    private Thread mBackGround;
+    private Thread mDoMaintainThread;
+    boolean mHavePrinter = false;
+    volatile boolean mIsCancelProbe = false;
+    boolean mIsStillUpdate = true;
+    boolean mIsStop = false;
+    private Thread mLoadConfigThread;
+    private DialogProgressViewModel mModelDialog;
+    /* access modifiers changed from: private */
+    public String mPrinterId;
+    /* access modifiers changed from: private */
+    public String mPrinterIp;
+    /* access modifiers changed from: private */
+    public int mPrinterLocation;
+    /* access modifiers changed from: private */
+    public String mPrinterName;
+    private int[] mPrinterStatus;
+    boolean mStartSearch = false;
+    Handler mUiHandler = new Handler() {
+        public void handleMessage(Message message) {
+            int i = message.what;
+            if (i != 99) {
+                switch (i) {
+                    case 0:
+                        GetPrinterReplyData.this.showProDia();
+                        return;
+                    case 1:
+                        EPLog.m313i("Maintain", "********Maintain finish********");
+                        GetPrinterReplyData.this.interrupMaintainThread();
+                        return;
+                    case 2:
+                        GetPrinterReplyData.this.updateStatus(message.getData().getInt("GET_STT_RESULT"));
+                        return;
+                    case 3:
+                        GetPrinterReplyData.this.updateInkInfo(message.getData().getInt("GET_INK_RESULT"));
+                        return;
+                    case 4:
+                        GetPrinterReplyData.this.cancelLoadConPro();
+                        GetPrinterReplyData.this.interrupMaintainThread();
+                        return;
+                    case 5:
+                        GetPrinterReplyData.this.updateSelectedPrinter();
+                        return;
+                    case 6:
+                        GetPrinterReplyData.this.showLoadConPro();
+                        return;
+                    case 7:
+                        GetPrinterReplyData.this.setResult(1);
+                        GetPrinterReplyData.this.finish();
+                        return;
+                    case 9:
+                        GetPrinterReplyData.this.cancelLoadConPro();
+                        GetPrinterReplyData.this.endLoadConThread();
+                        GetPrinterReplyData.this.setResult(1);
+                        GetPrinterReplyData.this.finish();
+                        return;
+                    case 10:
+                        GetPrinterReplyData.this.setupErrorMessage(10);
+                        GetPrinterReplyData.this.interrupMaintainThread();
+                        return;
+                    default:
+                        return;
+                }
+            } else {
+                GetPrinterReplyData.this.endBackGroundThread();
+                GetPrinterReplyData.this.cancelLoadConPro();
+                GetPrinterReplyData.this.endLoadConThread();
+                Intent intent = new Intent();
+                intent.putExtra("extStatus", GetPrinterReplyData.this.extParam);
+                GetPrinterReplyData.this.setResult(message.getData().getInt("END_RELPY_RESULT"), intent);
+                GetPrinterReplyData.this.finish();
+            }
+        }
+    };
+
+    private String inkCodeToString(int i) {
+        switch (i) {
+            case 0:
+                return "Black";
+            case 1:
+                return "Cyan";
+            case 2:
+                return "Magenta";
+            case 3:
+                return "Yellow";
+            case 4:
+                return "Light Cyan";
+            case 5:
+                return "Light Magenta";
+            case 6:
+                return "Light Yellow";
+            case 7:
+                return "Dark Yellow";
+            case 8:
+                return "Light Black";
+            case 9:
+                return "Red";
+            case 10:
+                return "Blue";
+            case 12:
+                return "Light Gray";
+            case 14:
+                return "Gloss Optimizer";
+            case 17:
+                return "Black";
+            case 18:
+                return "Orange";
+            case 19:
+                return "Green";
+            case 20:
+                return "White";
+            case 21:
+                return "Clean";
+            default:
+                return "unKnown";
+        }
+    }
+
+    public void onNegativeClick(String str) {
+    }
+
+    public void onNeutralClick(String str) {
+    }
+
+    public void onPositiveClick(String str) {
+    }
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        this.mModelDialog = (DialogProgressViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(DialogProgressViewModel.class);
+        this.mModelDialog.getDialogJob().observe(this, new Observer() {
+            public final void onChanged(Object obj) {
+                GetPrinterReplyData.lambda$onCreate$0(GetPrinterReplyData.this, (Deque) obj);
+            }
+        });
+        this.extParam = (SharedParamStatus) getIntent().getSerializableExtra("extStatus");
+        if (this.extParam == null) {
+            this.extParam = new SharedParamStatus();
+        }
+        if (mPrinter == null) {
+            mPrinter = MaintainPrinter2.getInstance();
+        }
+        EPLog.m313i(TAG, "onCreate");
+        lockRotation();
+        mPrinter.doInitDriver(this, 2);
+        startLoadConThread();
+    }
+
+    public static /* synthetic */ void lambda$onCreate$0(GetPrinterReplyData getPrinterReplyData, Deque deque) {
+        String[] checkQueue = getPrinterReplyData.mModelDialog.checkQueue();
+        if (checkQueue != null) {
+            String str = checkQueue[0];
+            String str2 = checkQueue[1];
+            if (str2.equals("do_show")) {
+                getPrinterReplyData.showDialog(str);
+            }
+            if (str2.equals("do_dismiss")) {
+                getPrinterReplyData.dismissDialog(str);
+            }
+        }
+    }
+
+    private void lockRotation() {
+        switch (getResources().getConfiguration().orientation) {
+            case 1:
+                setRequestedOrientation(1);
+                return;
+            case 2:
+                setRequestedOrientation(0);
+                return;
+            default:
+                return;
+        }
+    }
+
+    public void startLoadConThread() {
+        this.mIsCancelProbe = false;
+        this.mLoadConfigThread = new Thread(new Runnable() {
+            public void run() {
+                EPLog.m313i(GetPrinterReplyData.TAG, "new load Config thread");
+                GetPrinterReplyData.this.mUiHandler.sendEmptyMessage(6);
+                try {
+                    Thread.sleep(500);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+                GetPrinterReplyData.this.loadConfig();
+                if (GetPrinterReplyData.this.mPrinterId == null || GetPrinterReplyData.this.mPrinterName == null) {
+                    GetPrinterReplyData getPrinterReplyData = GetPrinterReplyData.this;
+                    getPrinterReplyData.mHavePrinter = false;
+                    getPrinterReplyData.mUiHandler.sendEmptyMessage(9);
+                    EPLog.m313i(GetPrinterReplyData.TAG, "not select printer");
+                    return;
+                }
+                GetPrinterReplyData.this.mUiHandler.sendEmptyMessage(8);
+                EPLog.m313i("startLoadConThread", "mPrinter.doProbePrinter");
+                if (!GetPrinterReplyData.this.mIsCancelProbe) {
+                    int doProbePrinter = GetPrinterReplyData.mPrinter.doProbePrinter(60, GetPrinterReplyData.this.mPrinterId, GetPrinterReplyData.this.mPrinterIp, GetPrinterReplyData.this.mPrinterLocation);
+                    while (!GetPrinterReplyData.this.mIsCancelProbe && doProbePrinter != 0) {
+                        try {
+                            Message message = new Message();
+                            message.what = 7;
+                            Bundle bundle = new Bundle();
+                            bundle.putInt(GetPrinterReplyData.PROBE_RESULT, doProbePrinter);
+                            message.setData(bundle);
+                            GetPrinterReplyData.this.mUiHandler.sendMessage(message);
+                            Thread.sleep(4000);
+                            if (!GetPrinterReplyData.this.mIsCancelProbe) {
+                                doProbePrinter = GetPrinterReplyData.mPrinter.doProbePrinter(60, GetPrinterReplyData.this.mPrinterId, GetPrinterReplyData.this.mPrinterIp, GetPrinterReplyData.this.mPrinterLocation);
+                            }
+                        } catch (InterruptedException e2) {
+                            e2.printStackTrace();
+                        }
+                    }
+                    EPLog.m313i(GetPrinterReplyData.TAG, "Probe Printer result: " + doProbePrinter);
+                    if (doProbePrinter == 0) {
+                        GetPrinterReplyData.mPrinter.setMSearchPos(0);
+                        GetPrinterReplyData getPrinterReplyData2 = GetPrinterReplyData.this;
+                        getPrinterReplyData2.mHavePrinter = true;
+                        getPrinterReplyData2.mUiHandler.sendEmptyMessage(5);
+                    }
+                }
+            }
+        });
+        this.mLoadConfigThread.start();
+    }
+
+    /* access modifiers changed from: private */
+    public void setupErrorMessage(int i) {
+        Utils.makeMessageBox(this, getString(C2135R.string.EPS_PRNERR_DISABEL_CLEANING_TITLE), getString(C2135R.string.EPS_PRNERR_DISABEL_CLEANING_MSG), getString(C2135R.string.str_ok)).show();
+    }
+
+    public void showProDia() {
+        if (this.customPro == null) {
+            this.customPro = new CustomProDialog(this, C2135R.style.AppTheme_Translucent, C2135R.layout.maintain_executing_dialog);
+        }
+        this.customPro.show();
+    }
+
+    public void cancelProDia() {
+        Dialog dialog = this.customPro;
+        if (dialog != null && dialog.isShowing()) {
+            this.customPro.cancel();
+            this.customPro = null;
+        }
+    }
+
+    public void showLoadConPro() {
+        this.mModelDialog.doShow(DIALOG_PROGRESS);
+    }
+
+    private void showDialog(String str) {
+        DialogProgress dialogProgress;
+        if (((str.hashCode() == -21731516 && str.equals(DIALOG_PROGRESS)) ? (char) 0 : 65535) != 0) {
+            dialogProgress = null;
+        } else {
+            dialogProgress = DialogProgress.newInstance(str, 0, getString(C2135R.string.str_wait));
+        }
+        if (dialogProgress != null) {
+            dialogProgress.setCancelable(true);
+            dialogProgress.show(getSupportFragmentManager(), str);
+        }
+    }
+
+    private void dismissDialog(String str) {
+        DialogFragment dialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(str);
+        if (dialogFragment != null) {
+            dialogFragment.dismiss();
+        }
+    }
+
+    public void cancelLoadConPro() {
+        this.mModelDialog.doDismiss(DIALOG_PROGRESS);
+    }
+
+    public void endLoadConThread() {
+        this.mIsCancelProbe = true;
+        Thread thread = this.mLoadConfigThread;
+        if (thread != null && thread.isAlive()) {
+            this.mLoadConfigThread.interrupt();
+            try {
+                this.mLoadConfigThread.join();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+            this.mLoadConfigThread = null;
+        }
+    }
+
+    public void startBackgroundThread() {
+        this.mIsStillUpdate = true;
+        this.mBackGround = new Thread(new Runnable() {
+            public void run() {
+                int doGetStatus = GetPrinterReplyData.mPrinter.doGetStatus();
+                Message message = new Message();
+                message.what = 2;
+                Bundle bundle = new Bundle();
+                bundle.putInt("GET_STT_RESULT", doGetStatus);
+                message.setData(bundle);
+                GetPrinterReplyData.this.mUiHandler.sendMessage(message);
+                int doGetInkInfo = GetPrinterReplyData.mPrinter.doGetInkInfo();
+                Message message2 = new Message();
+                message2.what = 3;
+                Bundle bundle2 = new Bundle();
+                bundle2.putInt("GET_INK_RESULT", doGetInkInfo);
+                message2.setData(bundle2);
+                GetPrinterReplyData.this.mUiHandler.sendMessage(message2);
+            }
+        });
+        this.mBackGround.setPriority(5);
+        this.mBackGround.start();
+    }
+
+    public void endBackGroundThread() {
+        this.mIsStillUpdate = false;
+        Thread thread = this.mBackGround;
+        if (thread != null && thread.isAlive()) {
+            this.mBackGround.interrupt();
+            try {
+                this.mBackGround.join();
+            } catch (InterruptedException unused) {
+            }
+            this.mBackGround = null;
+        }
+    }
+
+    public void onConfigurationChanged(Configuration configuration) {
+        super.onConfigurationChanged(configuration);
+        int doGetStatus = mPrinter.doGetStatus();
+        Message message = new Message();
+        message.what = 2;
+        Bundle bundle = new Bundle();
+        bundle.putInt("GET_STT_RESULT", doGetStatus);
+        message.setData(bundle);
+        this.mUiHandler.sendMessage(message);
+    }
+
+    /* access modifiers changed from: protected */
+    public void onActivityResult(int i, int i2, Intent intent) {
+        super.onActivityResult(i, i2, intent);
+        if (i == 1) {
+            if (i2 == 1) {
+                mPrinter.setMSearchPos(intent.getIntExtra(Constants.PRINTER_POS, 0));
+                this.mPrinterName = intent.getStringExtra(Constants.PRINTER_NAME);
+                this.mPrinterId = intent.getStringExtra(Constants.PRINTER_ID);
+                this.mPrinterIp = intent.getStringExtra(Constants.PRINTER_IP);
+                Utils.savePref(getApplicationContext(), "PrintSetting", CommonDefine.RE_SEARCH, true);
+                this.mUiHandler.sendEmptyMessage(8);
+            }
+            saveSelectedPrinter();
+        }
+    }
+
+    public void updateSelectedPrinter() {
+        cancelLoadConPro();
+        endLoadConThread();
+        int doSetPrinter = mPrinter.doSetPrinter();
+        if (doSetPrinter == 0) {
+            startBackgroundThread();
+            this.mIsStillUpdate = true;
+            return;
+        }
+        this.mIsStillUpdate = false;
+        handlerError(doSetPrinter, false);
+    }
+
+    public void updateStatus(int i) {
+        if (i == 0) {
+            if (isPrinterReady() == 1) {
+                int doGetInkInfo = mPrinter.doGetInkInfo();
+                Message message = new Message();
+                message.what = 3;
+                Bundle bundle = new Bundle();
+                bundle.putInt("GET_INK_RESULT", doGetInkInfo);
+                message.setData(bundle);
+                this.mUiHandler.sendMessage(message);
+            }
+            int[] iArr = this.mPrinterStatus;
+            if (iArr[0] != 4) {
+                return;
+            }
+            if (iArr[1] == 6 || iArr[1] == 103 || iArr[1] == 104) {
+                int doGetInkInfo2 = mPrinter.doGetInkInfo();
+                Message message2 = new Message();
+                message2.what = 3;
+                Bundle bundle2 = new Bundle();
+                bundle2.putInt("GET_INK_RESULT", doGetInkInfo2);
+                message2.setData(bundle2);
+                this.mUiHandler.sendMessage(message2);
+                return;
+            }
+            return;
+        }
+        handlerError(i, false);
+    }
+
+    public void updateInkInfo(int i) {
+        int i2;
+        MaintainPrinterInfo2 mPrinterInfor = mPrinter.getMPrinterInfor();
+        if (i == 0) {
+            int inkNum = mPrinterInfor.getInkNum();
+            ArrayList arrayList = new ArrayList();
+            ArrayList arrayList2 = new ArrayList();
+            ArrayList arrayList3 = new ArrayList();
+            i2 = -1;
+            this.extParam.setPrinter_name(this.mPrinterName);
+            this.extParam.setPrinter_status(this.mPrinterStatus[0]);
+            for (int i3 = 0; i3 < inkNum; i3++) {
+                arrayList.add(inkCodeToString(mPrinterInfor.getInkCode(i3)));
+                arrayList2.add(Integer.valueOf(mPrinterInfor.getInkRemainingAmount(i3)));
+                arrayList3.add(Integer.valueOf(mPrinterInfor.getInkStatus(i3)));
+            }
+            this.extParam.setArrayOutInkName(arrayList);
+            this.extParam.setArrayOutInkRemain(arrayList2);
+            this.extParam.setEscprlibInkStatus(arrayList3);
+        } else {
+            i2 = 1;
+        }
+        Message message = new Message();
+        message.what = 99;
+        Bundle bundle = new Bundle();
+        bundle.putInt("END_RELPY_RESULT", i2);
+        message.setData(bundle);
+        this.mUiHandler.sendMessage(message);
+    }
+
+    public void handlerError(int i, boolean z) {
+        cancelLoadConPro();
+    }
+
+    public int isPrinterReady() {
+        this.mPrinterStatus = mPrinter.getMPrinterInfor().getMStatus();
+        int[] iArr = this.mPrinterStatus;
+        if (iArr[0] == 2 || iArr[0] == 1 || iArr[0] == 3) {
+            return 0;
+        }
+        if (iArr[0] == 4) {
+            return -1;
+        }
+        return 1;
+    }
+
+    public void interrupMaintainThread() {
+        Thread thread = this.mDoMaintainThread;
+        if (thread != null && thread.isAlive()) {
+            this.mDoMaintainThread.interrupt();
+            this.mDoMaintainThread = null;
+        }
+    }
+
+    /* access modifiers changed from: protected */
+    public void onDestroy() {
+        stopAllThread();
+        super.onDestroy();
+        EPLog.m313i(TAG, "onDestroy");
+    }
+
+    /* access modifiers changed from: protected */
+    public void onPause() {
+        super.onPause();
+    }
+
+    /* access modifiers changed from: protected */
+    public void OLDonPause() {
+        this.mIsStop = true;
+        this.mIsCancelProbe = true;
+        cancelLoadConPro();
+        mPrinter.doCancelFindPrinter();
+        endLoadConThread();
+        interrupMaintainThread();
+        endBackGroundThread();
+        super.onPause();
+    }
+
+    /* access modifiers changed from: protected */
+    public void onStop() {
+        super.onStop();
+    }
+
+    /* access modifiers changed from: private */
+    public void loadConfig() {
+        MyPrinter curPrinter = MyPrinter.getCurPrinter(this);
+        this.mPrinterId = curPrinter.getPrinterId();
+        this.mPrinterName = curPrinter.getName();
+        this.mPrinterIp = curPrinter.getIp();
+        this.mPrinterLocation = curPrinter.getLocation();
+    }
+
+    private void saveSelectedPrinter() {
+        Utils.savePref(getApplicationContext(), "PrintSetting", Constants.PRINTER_NAME, this.mPrinterName);
+        Utils.savePref(getApplicationContext(), "PrintSetting", Constants.PRINTER_IP, this.mPrinterIp);
+        Utils.savePref(getApplicationContext(), "PrintSetting", Constants.PRINTER_ID, this.mPrinterId);
+    }
+
+    public void onCancelDialog(String str) {
+        if (((str.hashCode() == -21731516 && str.equals(DIALOG_PROGRESS)) ? (char) 0 : 65535) == 0) {
+            stopAllThread();
+            finish();
+        }
+    }
+
+    private class CustomProDialog extends Dialog {
+        private int mLayoutId;
+
+        public CustomProDialog(Context context, int i, int i2) {
+            super(context, i);
+            this.mLayoutId = i2;
+            setCancelable(false);
+        }
+
+        /* access modifiers changed from: protected */
+        public void onCreate(Bundle bundle) {
+            super.onCreate(bundle);
+            requestWindowFeature(1);
+            View inflate = getLayoutInflater().inflate(this.mLayoutId, (ViewGroup) null);
+            if (this.mLayoutId == C2135R.layout.maintain_executing_dialog) {
+                ((Button) inflate.findViewById(C2135R.C2137id.close_btn)).setOnClickListener(new View.OnClickListener() {
+                    public void onClick(View view) {
+                        CustomProDialog.this.cancel();
+                        GetPrinterReplyData.this.interrupMaintainThread();
+                    }
+                });
+            }
+            setContentView(inflate);
+        }
+    }
+
+    /* access modifiers changed from: package-private */
+    public void stopAllThread() {
+        if (!this.mIsCancelProbe) {
+            this.mIsStop = true;
+            this.mIsCancelProbe = true;
+            MaintainPrinter2 maintainPrinter2 = mPrinter;
+            if (maintainPrinter2 != null) {
+                maintainPrinter2.doCancelFindPrinter();
+            }
+            cancelLoadConPro();
+            endLoadConThread();
+            interrupMaintainThread();
+            endBackGroundThread();
+        }
+    }
+}

+ 43 - 0
app/src/main/java/epson/maintain/activity/LogUrl.java

@@ -0,0 +1,43 @@
+package epson.maintain.activity;
+
+import android.content.Context;
+import com.epson.mobilephone.common.EpLog;
+import epson.common.Constants;
+import epson.print.MyPrinter;
+import epson.print.ecclient.EcClientLib;
+import epson.print.ecclient.EcClientLibUtil;
+import epson.provider.SharedPreferencesProvider;
+
+/* compiled from: EccPrintLog */
+class LogUrl {
+    String mAccessKey;
+    String mClientId;
+    String mMailAddress;
+    String mPrinterName;
+
+    LogUrl() {
+    }
+
+    public void setContextDependValue(Context context) {
+        this.mClientId = SharedPreferencesProvider.getInstace(context).getString(Constants.PRINTER_CLIENT_ID, "");
+        EpLog.m69d("▲clientId = " + this.mClientId);
+        MyPrinter curPrinter = MyPrinter.getCurPrinter(context);
+        this.mAccessKey = EcClientLibUtil.quoteForJsonString(curPrinter.getRemotePrinterAccessKey(context));
+        this.mPrinterName = EcClientLibUtil.quoteForJsonString(curPrinter.getUserDefName(context));
+        this.mMailAddress = EcClientLibUtil.quoteForJsonString(curPrinter.getEmailAddress());
+    }
+
+    public String getUrl() throws EccPrintLogException {
+        EcClientLib ecClientLib = new EcClientLib();
+        if (ecClientLib.Initialize()) {
+            int GetPrintLogUri = ecClientLib.GetPrintLogUri(this.mMailAddress, this.mAccessKey, this.mClientId, this.mPrinterName);
+            if (GetPrintLogUri == 0) {
+                String str = ecClientLib.mLogUri;
+                ecClientLib.Terminate();
+                return str;
+            }
+            throw new EccPrintLogException(GetPrintLogUri);
+        }
+        throw new EccPrintLogException(10);
+    }
+}

+ 1953 - 0
app/src/main/java/epson/maintain/activity/MaintainActivity.java

@@ -0,0 +1,1953 @@
+package epson.maintain.activity;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.arch.lifecycle.Observer;
+import android.arch.lifecycle.ViewModelProviders;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.content.SharedPreferences;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.graphics.Point;
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.Message;
+import android.os.RemoteException;
+import android.support.annotation.ColorRes;
+import android.support.annotation.NonNull;
+import android.support.p000v4.app.DialogFragment;
+import android.support.p000v4.app.FragmentActivity;
+import android.support.p000v4.content.ContextCompat;
+import android.support.p000v4.view.ViewCompat;
+import android.view.Display;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.Switch;
+import android.widget.TextView;
+import com.epson.iprint.prtlogger.Analytics;
+import com.epson.mobilephone.common.EpLog;
+import com.epson.mobilephone.common.escpr.MediaInfo;
+import com.epson.mobilephone.common.maintain2.BatteryInfoEx;
+import com.epson.mobilephone.common.maintain2.MaintainPrinter2;
+import com.epson.mobilephone.common.maintain2.MaintainPrinterInfo2;
+import com.epson.mobilephone.common.wifidirect.MacAddrUtils;
+import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
+import epson.common.Constants;
+import epson.common.DialogProgress;
+import epson.common.EventWrapper;
+import epson.common.IPAddressUtils;
+import epson.common.Utils;
+import epson.epsonconnectregistration.ActivityECConfiguration;
+import epson.maintain.BatteryInfoAdapter;
+import epson.print.ActivityIACommon;
+import epson.print.C2135R;
+import epson.print.CommonDefine;
+import epson.print.MyPrinter;
+import epson.print.Util.AsyncTaskExecutor;
+import epson.print.Util.EPLog;
+import epson.print.inkrpln.InkRplnInfoClient;
+import epson.print.inkrpln.InkRplnProgressDialog;
+import epson.print.inkrpln.InkRplnRepository;
+import epson.print.inkrpln.JumpUrlProgressActivity;
+import epson.print.screen.WorkingDialog;
+import epson.print.service.EpsonService;
+import epson.print.service.IEpsonService;
+import epson.print.service.IEpsonServiceCallback;
+import java.util.Arrays;
+
+public class MaintainActivity extends ActivityIACommon implements View.OnClickListener, MediaInfo {
+    private static final int CANCEL_LOADCONFIG = 14;
+    private static final int CLEANING_ERROR = 10;
+    private static final int DELAY_TIME_MAINTAIN = 10;
+    private static final String DIALOG_PROGRESS = "dialog_progress";
+    private static final String DIALOG_TAG_NOZZLE_GUIDANCE = "dialog_nozzle_guidance";
+    private static final int EC_BUTTON_HIDE = 2;
+    private static final int EC_BUTTON_INVALID = 1;
+    private static final int EC_BUTTON_VALID = 0;
+    private static final int EPS_COMM_BID = 2;
+    private static final int EPS_ERR_COMM_ERROR = -1100;
+    private static final int EPS_LANG_ESCPR = 1;
+    private static final int EPS_MNT_CLEANING = 2;
+    private static final int EPS_MNT_NOZZLE = 3;
+    private static final int EPS_PRNERR_CEMPTY = 103;
+    private static final int EPS_PRNERR_CFAIL = 104;
+    private static final int EPS_PRNERR_COMM = 102;
+    private static final int EPS_PRNERR_DISABEL_CLEANING = 108;
+    private static final int EPS_PRNERR_INKOUT = 6;
+    private static final String[] GAGA_DEVICE_ID_ARRAY = {"LX-10000F", "LX-7000F", "WF-C20590 Series", "WF-C17590 Series", "LX-10000FK", "LX-10010MF", "WF-M20590 Series", "LX-10050KF", "LX-10050MF", "LX-6050MF", "LX-7550MF", "WF-C20600 Series", "WF-C20750 Series", "WF-C21000 Series"};
+    private static final int GET_PRINTER_NAME = 8;
+    private static final int HANDLE_ERROR = 4;
+    public static final int ITEM_HEIGHT = 40;
+    private static final int LOGIN_STATUS_COMM_ERROR = -1;
+    private static final int LOGIN_STATUS_LOGIN_FAILED = -2;
+    private static final int LOGIN_STATUS_LOGIN_SUCCEEDED = 0;
+    private static final int MAINTAIN_OK = 1;
+    private static final int MAINTAIN_START = 0;
+    private static final int MAX_WAIT_CONNECTING_3G = 10;
+    private static final int MESSAGE_MAINTENANCE_BOX_INFO = 16;
+    private static final int NO_PRINTER_NAME = 9;
+    private static final String PREFS_NAME = "PrintSetting";
+    private static final int PROBE_ERROR = 7;
+    private static final String PROBE_RESULT = "PROBE_ERROR";
+    private static final int REQUEST_CODE_INK_DS_DIALOG = 100;
+    private static final int REQUEST_CODE_SELECT_PRINTER = 101;
+    private static final int START_LOADCONFIG = 6;
+    private static final String TAG = "MAINTAIN";
+    private static final int UPDATE_BATTERY = 15;
+    private static final int UPDATE_INK = 3;
+    private static final int UPDATE_MAINTENANCE_LABEL = 11;
+    private static final int UPDATE_SELECTED_PRINTER = 5;
+    private static final int UPDATE_STT = 2;
+    private static boolean isMessageScreenShowing = false;
+    private Switch btnToggleAlert;
+    /* access modifiers changed from: private */
+    public Switch btnTogglePreview;
+    private Dialog customPro;
+    /* access modifiers changed from: private */
+    public int escprSetPrinterSuccessed = -1;
+    /* access modifiers changed from: private */
+    public boolean isGotError = false;
+    /* access modifiers changed from: private */
+    public boolean isKeepSimpleAPConnection = false;
+    /* access modifiers changed from: private */
+    public boolean isRemotePrinter = false;
+    boolean isResearchScanner = false;
+    /* access modifiers changed from: private */
+    public boolean isTryConnectSimpleAp = false;
+    private View mAlertMesseageSeparater;
+    private LinearLayout mAlertMesseageView;
+    private Thread mBackGround;
+    private LinearLayout mBuyInkGroup;
+    private int mBuyInkGroupVisibility;
+    private View mBuyInkSeparator;
+    private LinearLayout mBuyInkView;
+    /* access modifiers changed from: private */
+    public IEpsonServiceCallback mCallback = new IEpsonServiceCallback.Stub() {
+        public void onFindPrinterResult(String str, String str2, String str3, String str4, String str5) throws RemoteException {
+        }
+
+        public void onGetInkState() throws RemoteException {
+        }
+
+        public void onGetStatusState() throws RemoteException {
+        }
+
+        public void onNotifyContinueable(int i) throws RemoteException {
+        }
+
+        public void onNotifyEndJob(int i) throws RemoteException {
+        }
+
+        public void onNotifyError(int i, int i2, boolean z) throws RemoteException {
+        }
+
+        public void onNotifyProgress(int i, int i2) throws RemoteException {
+        }
+    };
+    private LinearLayout mCleanCheckView;
+    private Context mContext = null;
+    private Display mDisplay;
+    private Thread mDoMaintainThread;
+    private LinearLayout mEpsonConnectView;
+    private ServiceConnection mEpsonConnection = new ServiceConnection() {
+        public void onServiceDisconnected(ComponentName componentName) {
+            try {
+                MaintainActivity.this.mEpsonService.unregisterCallback(MaintainActivity.this.mCallback);
+            } catch (RemoteException e) {
+                e.printStackTrace();
+            }
+            IEpsonService unused = MaintainActivity.this.mEpsonService = null;
+        }
+
+        public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
+            IEpsonService unused = MaintainActivity.this.mEpsonService = IEpsonService.Stub.asInterface(iBinder);
+            if (MaintainActivity.this.mEpsonService != null) {
+                try {
+                    MaintainActivity.this.mEpsonService.registerCallback(MaintainActivity.this.mCallback);
+                } catch (RemoteException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    };
+    /* access modifiers changed from: private */
+    public IEpsonService mEpsonService = null;
+    private TextView mFWUpdateText;
+    private LinearLayout mFWUpdateView;
+    boolean mHavePrinter = false;
+    private TextView mHeadCleanText;
+    private LinearLayout mHeadCleanView;
+    private LinearLayout mInkDsView;
+    private LinearLayout mInkView;
+    /* access modifiers changed from: private */
+    public volatile boolean mIsCancelProbe = false;
+    private Boolean mIsNozzleCheckEnable = true;
+    /* access modifiers changed from: private */
+    public volatile boolean mIsStillUpdate = true;
+    boolean mIsStop = false;
+    private LinearLayout mLLSerialNo;
+    private View mLoadConPro;
+    private Thread mLoadConfigThread;
+    private TextView mMaintenanceBoxText;
+    private LinearLayout mMaintenanceBoxView;
+    private TextView mNozzleCheckText;
+    private LinearLayout mNozzleCheckView;
+    private View mOnlineRegistrationSeparator;
+    private LinearLayout mOnlineRegistrationView;
+    private View mPrintHistorySeparator;
+    private LinearLayout mPrintHistoryView;
+    private LinearLayout mPrintPreviewView;
+    /* access modifiers changed from: private */
+    public MaintainPrinter2 mPrinter = MaintainPrinter2.getInstance();
+    private View mPrinterSettingSeparator;
+    private LinearLayout mPrinterSettingView;
+    /* access modifiers changed from: private */
+    public int[] mPrinterStatus;
+    boolean mStartSearch = false;
+    private TextView mTextMaintenance;
+    /* access modifiers changed from: private */
+    public TextView mTvPrinterName;
+    private TextView mTvPrinterStatus;
+    private TextView mTvPrinterStatusDetail;
+    private TextView mTvSerialNo;
+    /* access modifiers changed from: private */
+    public Handler mUiHandler = new Handler(new Handler.Callback() {
+        public boolean handleMessage(Message message) {
+            switch (message.what) {
+                case 0:
+                    MaintainActivity.this.showProDia();
+                    break;
+                case 1:
+                    EPLog.m313i("Maintain", "********Maintain finish********");
+                    MaintainActivity.this.interrupMaintainThread();
+                    MaintainActivity.this.cancelProDia();
+                    break;
+                case 2:
+                    MaintainActivity.this.updateStatus(message.getData().getInt("GET_STT_RESULT"));
+                    break;
+                case 3:
+                    MaintainActivity.this.updateInkInfo(message.getData().getInt("GET_INK_RESULT"));
+                    break;
+                case 4:
+                    MaintainActivity.this.interrupMaintainThread();
+                    break;
+                case 5:
+                    MaintainActivity.this.updateSelectedPrinter();
+                    break;
+                case 6:
+                    MaintainActivity.this.showLoadProgressBar();
+                    MaintainActivity.this.setButtonClickable(false);
+                    MaintainActivity.this.setEpsonConnectButton(1);
+                    break;
+                case 7:
+                    MaintainActivity.this.handlerError(message.getData().getInt(MaintainActivity.PROBE_RESULT), true);
+                    break;
+                case 8:
+                    MaintainActivity.this.mTvPrinterName.setText(MaintainActivity.this.printerName);
+                    switch (MaintainActivity.this.printerLocation) {
+                        case 2:
+                            ((ImageView) MaintainActivity.this.findViewById(C2135R.C2137id.imageViewPrinterLocation)).setVisibility(0);
+                            ((ImageView) MaintainActivity.this.findViewById(C2135R.C2137id.imageViewPrinterLocation)).setImageResource(C2135R.C2136drawable.print_remote);
+                            break;
+                        case 3:
+                            ((ImageView) MaintainActivity.this.findViewById(C2135R.C2137id.imageViewPrinterLocation)).setVisibility(0);
+                            ((ImageView) MaintainActivity.this.findViewById(C2135R.C2137id.imageViewPrinterLocation)).setImageResource(C2135R.C2136drawable.print_ip);
+                            break;
+                        default:
+                            if (!MaintainActivity.this.printerName.equals("")) {
+                                ((ImageView) MaintainActivity.this.findViewById(C2135R.C2137id.imageViewPrinterLocation)).setVisibility(0);
+                                ((ImageView) MaintainActivity.this.findViewById(C2135R.C2137id.imageViewPrinterLocation)).setImageResource(C2135R.C2136drawable.print_local);
+                                break;
+                            } else {
+                                ((ImageView) MaintainActivity.this.findViewById(C2135R.C2137id.imageViewPrinterLocation)).setVisibility(8);
+                                break;
+                            }
+                    }
+                case 9:
+                    MaintainActivity.this.mUiHandler.sendEmptyMessage(11);
+                    MaintainActivity.this.hideLoadProgressBar();
+                    MaintainActivity.this.stopLoadConfigThread();
+                    break;
+                case 10:
+                    MaintainActivity.this.setupErrorMessage(10);
+                    MaintainActivity.this.interrupMaintainThread();
+                    break;
+                case 11:
+                    MaintainActivity.this.updateButton();
+                    break;
+                case 14:
+                    MaintainActivity.this.hideLoadProgressBar();
+                    break;
+                case 15:
+                    MaintainActivity.this.updateBatteryInfoEx(message.getData().getInt("GET_BATTERY_RESULT"), (BatteryInfoEx) message.getData().getParcelable("GET_BATTERY_INFO"));
+                    break;
+                case 16:
+                    MaintainActivity.this.updateMaintenanceBoxInfo((int[]) message.obj);
+                    break;
+            }
+            return false;
+        }
+    });
+    private View mVSerialSeparator;
+    private boolean mWaiteInkDsDialog;
+    private MaintainBuyInkOnlineRegTask modelBuyInkOnlineRegTask;
+    /* access modifiers changed from: private */
+    public String printerId = "";
+    /* access modifiers changed from: private */
+    public String printerIp = "";
+    /* access modifiers changed from: private */
+    public int printerLocation = 1;
+    /* access modifiers changed from: private */
+    public String printerName = "";
+    /* access modifiers changed from: private */
+    public int serverLoginStatus = -2;
+
+    private static int calcInkWidth(int i, float f) {
+        if (i <= 0) {
+            i = 1;
+        } else if (i > 100) {
+            i = 100;
+        }
+        int i2 = (int) ((f / 100.0f) * ((float) i));
+        if (i2 > 0) {
+            return i2;
+        }
+        return 1;
+    }
+
+    private boolean isMaintenanceBoxStatusDisplayX(int i) {
+        switch (i) {
+            case -2:
+            case -1:
+                return true;
+            default:
+                return false;
+        }
+    }
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        EpLog.m78i(TAG, "onCreate IN");
+        super.onCreate(bundle);
+        setContentView((int) C2135R.layout.maintain);
+        this.mContext = this;
+        this.mBuyInkGroupVisibility = 0;
+        setActionBar((int) C2135R.string.str_maintenance, true);
+        if (this.mEpsonService == null) {
+            bindService(new Intent(this, EpsonService.class), this.mEpsonConnection, 1);
+        }
+        this.mDisplay = getWindowManager().getDefaultDisplay();
+        findViewById(C2135R.C2137id.printer).setOnClickListener(this);
+        this.mTvPrinterName = (TextView) findViewById(C2135R.C2137id.printer_name);
+        this.mVSerialSeparator = findViewById(C2135R.C2137id.serial_separator);
+        this.mLLSerialNo = (LinearLayout) findViewById(C2135R.C2137id.serial);
+        this.mTvSerialNo = (TextView) findViewById(C2135R.C2137id.serial_no);
+        this.mTvPrinterStatus = (TextView) findViewById(C2135R.C2137id.printer_status);
+        this.mTvPrinterStatusDetail = (TextView) findViewById(C2135R.C2137id.printer_status_detail);
+        this.mTextMaintenance = (TextView) findViewById(C2135R.C2137id.text_maintenance);
+        this.mInkView = (LinearLayout) findViewById(C2135R.C2137id.ink_view_ln);
+        this.mMaintenanceBoxText = (TextView) findViewById(C2135R.C2137id.maintenance_box_text);
+        this.mMaintenanceBoxView = (LinearLayout) findViewById(C2135R.C2137id.maintenance_box_info_layout);
+        this.mCleanCheckView = (LinearLayout) findViewById(C2135R.C2137id.clean_check);
+        this.mHeadCleanView = (LinearLayout) findViewById(C2135R.C2137id.head_clean_view);
+        this.mHeadCleanView.setOnClickListener(this);
+        this.mHeadCleanText = (TextView) findViewById(C2135R.C2137id.head_clean_text);
+        this.mNozzleCheckView = (LinearLayout) findViewById(C2135R.C2137id.nozzle_check_view);
+        this.mNozzleCheckView.setOnClickListener(this);
+        this.mNozzleCheckText = (TextView) findViewById(C2135R.C2137id.nozzle_check_text);
+        this.mFWUpdateView = (LinearLayout) findViewById(C2135R.C2137id.fwupdate_view);
+        this.mFWUpdateView.setOnClickListener(this);
+        this.mFWUpdateText = (TextView) findViewById(C2135R.C2137id.fwupdate_text);
+        this.btnTogglePreview = (Switch) findViewById(C2135R.C2137id.togglePreview);
+        this.btnTogglePreview.setOnClickListener(this);
+        this.btnToggleAlert = (Switch) findViewById(C2135R.C2137id.toggleAlert);
+        this.btnToggleAlert.setOnClickListener(this);
+        this.mPrinterSettingView = (LinearLayout) findViewById(C2135R.C2137id.printer_setting);
+        this.mPrinterSettingView.setOnClickListener(this);
+        this.mEpsonConnectView = (LinearLayout) findViewById(C2135R.C2137id.epsonconnect_option);
+        this.mEpsonConnectView.setOnClickListener(this);
+        this.mPrintHistoryView = (LinearLayout) findViewById(C2135R.C2137id.print_history);
+        this.mPrintHistoryView.setOnClickListener(this);
+        this.mOnlineRegistrationView = (LinearLayout) findViewById(C2135R.C2137id.online_registration);
+        this.mOnlineRegistrationView.setOnClickListener(this);
+        this.mBuyInkGroup = (LinearLayout) findViewById(C2135R.C2137id.mentenance_buy_ink_frame);
+        this.mBuyInkView = (LinearLayout) findViewById(C2135R.C2137id.mentenance_buy_ink);
+        this.mBuyInkView.setOnClickListener(this);
+        this.mBuyInkSeparator = findViewById(C2135R.C2137id.buy_ink_separator);
+        this.mInkDsView = (LinearLayout) findViewById(C2135R.C2137id.maintenance_inkds);
+        this.mInkDsView.setOnClickListener(this);
+        this.mPrintPreviewView = (LinearLayout) findViewById(C2135R.C2137id.print_preview);
+        this.mAlertMesseageView = (LinearLayout) findViewById(C2135R.C2137id.alert_messeage);
+        this.mPrinterSettingSeparator = findViewById(C2135R.C2137id.printer_setting_separator);
+        this.mPrintHistorySeparator = findViewById(C2135R.C2137id.print_history_separator);
+        this.mOnlineRegistrationSeparator = findViewById(C2135R.C2137id.online_registration_separator);
+        this.mAlertMesseageSeparater = findViewById(C2135R.C2137id.comm_messeage_separator);
+        this.mPrinterSettingView.setEnabled(false);
+        ((TextView) findViewById(C2135R.C2137id.text_printer_setting)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
+        ((ImageView) findViewById(C2135R.C2137id.printer_setting_arrow)).setVisibility(8);
+        this.mVSerialSeparator.setVisibility(8);
+        this.mLLSerialNo.setVisibility(8);
+        EpLog.m78i(TAG, "onCreate :: doInitDriver");
+        this.mPrinter.doInitDriver(this, 2);
+        this.isResearchScanner = Utils.getPrefBoolean(getApplicationContext(), Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_RESEACH);
+        if (MyPrinter.getCurPrinter(this).getName() == null) {
+            startSelectPrinterActivity();
+        }
+        this.mWaiteInkDsDialog = false;
+        this.modelBuyInkOnlineRegTask = (MaintainBuyInkOnlineRegTask) ViewModelProviders.m2of((FragmentActivity) this).get(MaintainBuyInkOnlineRegTask.class);
+        this.modelBuyInkOnlineRegTask.getUriEvent().observe(this, new Observer() {
+            public final void onChanged(Object obj) {
+                MaintainActivity.lambda$onCreate$0(MaintainActivity.this, (EventWrapper) obj);
+            }
+        });
+    }
+
+    public static /* synthetic */ void lambda$onCreate$0(MaintainActivity maintainActivity, EventWrapper eventWrapper) {
+        if (!eventWrapper.hasBeenHandled()) {
+            maintainActivity.dismissDialog(DIALOG_PROGRESS);
+            maintainActivity.startActivity(new Intent("android.intent.action.VIEW", (Uri) eventWrapper.getEventContent()));
+        }
+    }
+
+    private void startLoadConThread() {
+        this.mIsCancelProbe = false;
+        this.mLoadConfigThread = new Thread(new Runnable() {
+            /* JADX WARNING: Code restructure failed: missing block: B:83:0x01e6, code lost:
+                return;
+             */
+            /* Code decompiled incorrectly, please refer to instructions dump. */
+            public synchronized void run() {
+                /*
+                    r8 = this;
+                    monitor-enter(r8)
+                    java.lang.String r0 = "MAINTAIN"
+                    java.lang.String r1 = "new load Config thread"
+                    epson.print.Util.EPLog.m313i(r0, r1)     // Catch:{ all -> 0x01f0 }
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    android.os.Handler r0 = r0.mUiHandler     // Catch:{ all -> 0x01f0 }
+                    r1 = 6
+                    r0.sendEmptyMessage(r1)     // Catch:{ all -> 0x01f0 }
+                    r0 = 500(0x1f4, double:2.47E-321)
+                    java.lang.Thread.sleep(r0)     // Catch:{ InterruptedException -> 0x01e7 }
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    r0.loadConfig()     // Catch:{ all -> 0x01f0 }
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    android.os.Handler r0 = r0.mUiHandler     // Catch:{ all -> 0x01f0 }
+                    r1 = 8
+                    r0.sendEmptyMessage(r1)     // Catch:{ all -> 0x01f0 }
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    boolean r0 = r0.mIsCancelProbe     // Catch:{ all -> 0x01f0 }
+                    if (r0 == 0) goto L_0x0034
+                    r8.hideLoadProgress()     // Catch:{ all -> 0x01f0 }
+                    monitor-exit(r8)
+                    return
+                L_0x0034:
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    epson.maintain.activity.MaintainActivity r2 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    boolean r2 = epson.print.MyPrinter.isRemotePrinter(r2)     // Catch:{ all -> 0x01f0 }
+                    boolean unused = r0.isRemotePrinter = r2     // Catch:{ all -> 0x01f0 }
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    boolean r0 = r0.isRemotePrinter     // Catch:{ all -> 0x01f0 }
+                    r2 = -1
+                    r3 = 0
+                    r4 = 1
+                    if (r0 != r4) goto L_0x00ae
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
+                    r1 = -2
+                    int unused = r0.serverLoginStatus = r1     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
+                    r0 = 0
+                L_0x0051:
+                    epson.maintain.activity.MaintainActivity r5 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
+                    epson.print.service.IEpsonService r5 = r5.mEpsonService     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
+                    if (r5 != 0) goto L_0x006b
+                    epson.maintain.activity.MaintainActivity r5 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
+                    boolean r5 = r5.mIsCancelProbe     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
+                    if (r5 != 0) goto L_0x006b
+                    r5 = 100
+                    java.lang.Thread.sleep(r5)     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
+                    int r0 = r0 + r4
+                    r5 = 10
+                    if (r0 < r5) goto L_0x0051
+                L_0x006b:
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
+                    epson.print.service.IEpsonService r0 = r0.mEpsonService     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
+                    if (r0 == 0) goto L_0x009e
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
+                    epson.print.service.IEpsonService r0 = r0.mEpsonService     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
+                    int r0 = r0.ensureLogin(r4)     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
+                    if (r0 != 0) goto L_0x0085
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
+                    int unused = r0.serverLoginStatus = r3     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
+                    goto L_0x009e
+                L_0x0085:
+                    r3 = -1100(0xfffffffffffffbb4, float:NaN)
+                    if (r0 != r3) goto L_0x008f
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
+                    int unused = r0.serverLoginStatus = r2     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
+                    goto L_0x009e
+                L_0x008f:
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
+                    int unused = r0.serverLoginStatus = r1     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
+                    goto L_0x009e
+                L_0x0095:
+                    r0 = move-exception
+                    r0.printStackTrace()     // Catch:{ all -> 0x01f0 }
+                    goto L_0x009e
+                L_0x009a:
+                    r0 = move-exception
+                    r0.printStackTrace()     // Catch:{ all -> 0x01f0 }
+                L_0x009e:
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    android.os.Handler r0 = r0.mUiHandler     // Catch:{ all -> 0x01f0 }
+                    r1 = 11
+                    r0.sendEmptyMessage(r1)     // Catch:{ all -> 0x01f0 }
+                    r8.hideLoadProgress()     // Catch:{ all -> 0x01f0 }
+                    monitor-exit(r8)
+                    return
+                L_0x00ae:
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    boolean r0 = r0.mIsCancelProbe     // Catch:{ all -> 0x01f0 }
+                    if (r0 == 0) goto L_0x00bb
+                    r8.hideLoadProgress()     // Catch:{ all -> 0x01f0 }
+                    monitor-exit(r8)
+                    return
+                L_0x00bb:
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    java.lang.String r0 = r0.printerId     // Catch:{ all -> 0x01f0 }
+                    java.lang.String r5 = ""
+                    boolean r0 = r0.equals(r5)     // Catch:{ all -> 0x01f0 }
+                    if (r0 != 0) goto L_0x01cf
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    java.lang.String r0 = r0.printerName     // Catch:{ all -> 0x01f0 }
+                    java.lang.String r5 = ""
+                    boolean r0 = r0.equals(r5)     // Catch:{ all -> 0x01f0 }
+                    if (r0 != 0) goto L_0x01cf
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    int r0 = r0.printerLocation     // Catch:{ all -> 0x01f0 }
+                    if (r0 != r4) goto L_0x0108
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    java.lang.String r5 = "printer"
+                    boolean r0 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.isNeedConnect(r0, r5)     // Catch:{ all -> 0x01f0 }
+                    if (r0 != 0) goto L_0x00ef
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    boolean unused = r0.isTryConnectSimpleAp = r3     // Catch:{ all -> 0x01f0 }
+                    goto L_0x0108
+                L_0x00ef:
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    boolean r0 = r0.isTryConnectSimpleAp     // Catch:{ all -> 0x01f0 }
+                    if (r0 != 0) goto L_0x0108
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    boolean unused = r0.isTryConnectSimpleAp = r4     // Catch:{ all -> 0x01f0 }
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    java.lang.String r5 = "printer"
+                    boolean r0 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.reconnect(r0, r5, r2)     // Catch:{ all -> 0x01f0 }
+                    if (r0 == 0) goto L_0x0108
+                    monitor-exit(r8)
+                    return
+                L_0x0108:
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    android.os.Handler r0 = r0.mUiHandler     // Catch:{ all -> 0x01f0 }
+                    r0.sendEmptyMessage(r1)     // Catch:{ all -> 0x01f0 }
+                    java.lang.String r0 = "startLoadConThread"
+                    java.lang.String r1 = "mPrinter.doProbePrinter"
+                    epson.print.Util.EPLog.m313i(r0, r1)     // Catch:{ all -> 0x01f0 }
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    com.epson.mobilephone.common.maintain2.MaintainPrinter2 r0 = r0.mPrinter     // Catch:{ all -> 0x01f0 }
+                    epson.maintain.activity.MaintainActivity r1 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    java.lang.String r1 = r1.printerId     // Catch:{ all -> 0x01f0 }
+                    epson.maintain.activity.MaintainActivity r5 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    java.lang.String r5 = r5.printerIp     // Catch:{ all -> 0x01f0 }
+                    epson.maintain.activity.MaintainActivity r6 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    int r6 = r6.printerLocation     // Catch:{ all -> 0x01f0 }
+                    r7 = 60
+                    int r0 = r0.doProbePrinter(r7, r1, r5, r6)     // Catch:{ all -> 0x01f0 }
+                    epson.maintain.activity.MaintainActivity r1 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    int unused = r1.escprSetPrinterSuccessed = r2     // Catch:{ all -> 0x01f0 }
+                L_0x013b:
+                    epson.maintain.activity.MaintainActivity r1 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x018e }
+                    boolean r1 = r1.mIsCancelProbe     // Catch:{ InterruptedException -> 0x018e }
+                    if (r1 != 0) goto L_0x0192
+                    if (r0 != 0) goto L_0x0146
+                    goto L_0x0192
+                L_0x0146:
+                    android.os.Message r1 = new android.os.Message     // Catch:{ InterruptedException -> 0x018e }
+                    r1.<init>()     // Catch:{ InterruptedException -> 0x018e }
+                    r2 = 7
+                    r1.what = r2     // Catch:{ InterruptedException -> 0x018e }
+                    android.os.Bundle r2 = new android.os.Bundle     // Catch:{ InterruptedException -> 0x018e }
+                    r2.<init>()     // Catch:{ InterruptedException -> 0x018e }
+                    java.lang.String r5 = "PROBE_ERROR"
+                    r2.putInt(r5, r0)     // Catch:{ InterruptedException -> 0x018e }
+                    r1.setData(r2)     // Catch:{ InterruptedException -> 0x018e }
+                    epson.maintain.activity.MaintainActivity r2 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x018e }
+                    android.os.Handler r2 = r2.mUiHandler     // Catch:{ InterruptedException -> 0x018e }
+                    r2.sendMessage(r1)     // Catch:{ InterruptedException -> 0x018e }
+                    r1 = 4000(0xfa0, double:1.9763E-320)
+                    java.lang.Thread.sleep(r1)     // Catch:{ InterruptedException -> 0x018e }
+                    epson.maintain.activity.MaintainActivity r1 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x018e }
+                    boolean r1 = r1.mIsCancelProbe     // Catch:{ InterruptedException -> 0x018e }
+                    if (r1 != 0) goto L_0x013b
+                    epson.maintain.activity.MaintainActivity r1 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x018e }
+                    com.epson.mobilephone.common.maintain2.MaintainPrinter2 r1 = r1.mPrinter     // Catch:{ InterruptedException -> 0x018e }
+                    epson.maintain.activity.MaintainActivity r2 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x018e }
+                    java.lang.String r2 = r2.printerId     // Catch:{ InterruptedException -> 0x018e }
+                    epson.maintain.activity.MaintainActivity r5 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x018e }
+                    java.lang.String r5 = r5.printerIp     // Catch:{ InterruptedException -> 0x018e }
+                    epson.maintain.activity.MaintainActivity r6 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x018e }
+                    int r6 = r6.printerLocation     // Catch:{ InterruptedException -> 0x018e }
+                    int r0 = r1.doProbePrinter(r7, r2, r5, r6)     // Catch:{ InterruptedException -> 0x018e }
+                    goto L_0x013b
+                L_0x018e:
+                    r1 = move-exception
+                    r1.printStackTrace()     // Catch:{ all -> 0x01f0 }
+                L_0x0192:
+                    java.lang.String r1 = "MAINTAIN"
+                    java.lang.StringBuilder r2 = new java.lang.StringBuilder     // Catch:{ all -> 0x01f0 }
+                    r2.<init>()     // Catch:{ all -> 0x01f0 }
+                    java.lang.String r5 = "Probe Printer result: "
+                    r2.append(r5)     // Catch:{ all -> 0x01f0 }
+                    r2.append(r0)     // Catch:{ all -> 0x01f0 }
+                    java.lang.String r2 = r2.toString()     // Catch:{ all -> 0x01f0 }
+                    epson.print.Util.EPLog.m313i(r1, r2)     // Catch:{ all -> 0x01f0 }
+                    epson.maintain.activity.MaintainActivity r1 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    boolean r1 = r1.mIsCancelProbe     // Catch:{ all -> 0x01f0 }
+                    if (r1 != 0) goto L_0x01e5
+                    if (r0 != 0) goto L_0x01e5
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    com.epson.mobilephone.common.maintain2.MaintainPrinter2 r0 = r0.mPrinter     // Catch:{ all -> 0x01f0 }
+                    r0.setMSearchPos(r3)     // Catch:{ all -> 0x01f0 }
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    int unused = r0.escprSetPrinterSuccessed = r3     // Catch:{ all -> 0x01f0 }
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    r0.mHavePrinter = r4     // Catch:{ all -> 0x01f0 }
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    android.os.Handler r0 = r0.mUiHandler     // Catch:{ all -> 0x01f0 }
+                    r1 = 5
+                    r0.sendEmptyMessage(r1)     // Catch:{ all -> 0x01f0 }
+                    goto L_0x01e5
+                L_0x01cf:
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    r0.mHavePrinter = r3     // Catch:{ all -> 0x01f0 }
+                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
+                    android.os.Handler r0 = r0.mUiHandler     // Catch:{ all -> 0x01f0 }
+                    r1 = 9
+                    r0.sendEmptyMessage(r1)     // Catch:{ all -> 0x01f0 }
+                    java.lang.String r0 = "MAINTAIN"
+                    java.lang.String r1 = "not select printer"
+                    epson.print.Util.EPLog.m313i(r0, r1)     // Catch:{ all -> 0x01f0 }
+                L_0x01e5:
+                    monitor-exit(r8)
+                    return
+                L_0x01e7:
+                    r0 = move-exception
+                    r0.printStackTrace()     // Catch:{ all -> 0x01f0 }
+                    r8.hideLoadProgress()     // Catch:{ all -> 0x01f0 }
+                    monitor-exit(r8)
+                    return
+                L_0x01f0:
+                    r0 = move-exception
+                    monitor-exit(r8)
+                    throw r0
+                */
+                throw new UnsupportedOperationException("Method not decompiled: epson.maintain.activity.MaintainActivity.C20151.run():void");
+            }
+
+            private void hideLoadProgress() {
+                MaintainActivity.this.mUiHandler.sendEmptyMessage(14);
+            }
+        }, "load-config");
+        this.mLoadConfigThread.start();
+    }
+
+    /* access modifiers changed from: private */
+    public void updateButton() {
+        switch (this.printerLocation) {
+            case 0:
+                this.mTvPrinterName.setText(getString(C2135R.string.str_lbl_title_scan));
+                ((ImageView) findViewById(C2135R.C2137id.imageViewPrinterLocation)).setVisibility(8);
+                this.mTvPrinterStatus.setText(C2135R.string.EPS_PRNERR_NOT_SELECTED_TITTLE);
+                this.mTvPrinterStatusDetail.setText(C2135R.string.EPS_PRNERR_NOT_SELECTED);
+                LinearLayout linearLayout = this.mInkView;
+                if (linearLayout != null) {
+                    linearLayout.removeAllViews();
+                }
+                this.mTextMaintenance.setVisibility(0);
+                this.mCleanCheckView.setVisibility(0);
+                this.mPrinterSettingView.setVisibility(0);
+                this.mHeadCleanView.setEnabled(false);
+                this.mNozzleCheckView.setEnabled(false);
+                this.mFWUpdateView.setEnabled(false);
+                this.mPrinterSettingView.setEnabled(false);
+                ((TextView) findViewById(C2135R.C2137id.text_printer_setting)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
+                ((ImageView) findViewById(C2135R.C2137id.printer_setting_arrow)).setVisibility(8);
+                localSetBuyInkGroupVisibility(8);
+                this.mOnlineRegistrationSeparator.setVisibility(8);
+                this.mOnlineRegistrationView.setVisibility(8);
+                this.mPrinterSettingSeparator.setVisibility(8);
+                this.mPrintPreviewView.setVisibility(8);
+                this.mAlertMesseageSeparater.setVisibility(8);
+                this.mAlertMesseageView.setVisibility(8);
+                this.mPrintHistorySeparator.setVisibility(8);
+                this.mPrintHistoryView.setVisibility(8);
+                this.mMaintenanceBoxText.setVisibility(8);
+                this.mMaintenanceBoxView.setVisibility(8);
+                return;
+            case 1:
+                if (this.mPrinter.doGetLang() != 1) {
+                    this.mTextMaintenance.setVisibility(8);
+                    this.mCleanCheckView.setVisibility(8);
+                    this.mOnlineRegistrationSeparator.setVisibility(8);
+                    this.mOnlineRegistrationView.setVisibility(8);
+                } else {
+                    this.mTextMaintenance.setVisibility(0);
+                    this.mCleanCheckView.setVisibility(0);
+                    this.mOnlineRegistrationSeparator.setVisibility(0);
+                    this.mOnlineRegistrationView.setVisibility(0);
+                    this.mOnlineRegistrationView.setEnabled(true);
+                }
+                updateBuyInkGroupForLocalOrIPPrinter();
+                this.mPrinterSettingView.setVisibility(0);
+                this.mPrinterSettingSeparator.setVisibility(8);
+                this.mPrintPreviewView.setVisibility(8);
+                this.mAlertMesseageSeparater.setVisibility(8);
+                this.mAlertMesseageView.setVisibility(8);
+                this.mPrintHistorySeparator.setVisibility(8);
+                this.mPrintHistoryView.setVisibility(8);
+                if (this.escprSetPrinterSuccessed == 0) {
+                    this.mHeadCleanView.setEnabled(true);
+                    this.mNozzleCheckView.setEnabled(true);
+                    this.mFWUpdateView.setEnabled(true);
+                    this.mPrinterSettingView.setEnabled(true);
+                    ((TextView) findViewById(C2135R.C2137id.text_printer_setting)).setTextColor(this.mContext.getResources().getColor(C2135R.color.black));
+                    ((ImageView) findViewById(C2135R.C2137id.printer_setting_arrow)).setVisibility(0);
+                    setEpsonConnectButton(0);
+                } else {
+                    this.mHeadCleanView.setEnabled(false);
+                    this.mNozzleCheckView.setEnabled(false);
+                    this.mFWUpdateView.setEnabled(false);
+                    this.mPrinterSettingView.setEnabled(false);
+                    ((TextView) findViewById(C2135R.C2137id.text_printer_setting)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
+                    ((ImageView) findViewById(C2135R.C2137id.printer_setting_arrow)).setVisibility(8);
+                    setEpsonConnectButton(1);
+                }
+                if (MyPrinter.PRINTER_USB.equals(this.printerIp)) {
+                    this.mFWUpdateView.setVisibility(8);
+                    this.mPrinterSettingSeparator.setVisibility(8);
+                    this.mPrinterSettingView.setVisibility(8);
+                    return;
+                }
+                return;
+            case 2:
+                localSetBuyInkGroupVisibility(0);
+                this.mBuyInkView.setVisibility(0);
+                this.mPrinterSettingSeparator.setVisibility(0);
+                this.mPrinterSettingView.setVisibility(0);
+                this.mPrintPreviewView.setVisibility(0);
+                this.mAlertMesseageSeparater.setVisibility(0);
+                this.mAlertMesseageView.setVisibility(0);
+                this.mPrintHistorySeparator.setVisibility(0);
+                this.mPrintHistoryView.setVisibility(0);
+                setEpsonConnectButton(2);
+                LinearLayout linearLayout2 = this.mInkView;
+                if (linearLayout2 != null) {
+                    linearLayout2.removeAllViews();
+                }
+                TextView textView = new TextView(this.mContext);
+                textView.setTextColor(getResources().getColor(C2135R.color.black));
+                textView.setTextSize(16.0f);
+                textView.setText(getString(C2135R.string.epsonconnect_str_status_inkinfo_error));
+                this.mInkView.addView(textView);
+                SharedPreferences sharedPreferences = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0);
+                boolean z = sharedPreferences.getBoolean(Constants.ENABLE_SHOW_PREVIEW, true);
+                boolean z2 = sharedPreferences.getBoolean(Constants.ENABLE_SHOW_WARNING, true);
+                if (z) {
+                    this.btnTogglePreview.setChecked(true);
+                } else {
+                    this.btnTogglePreview.setChecked(false);
+                }
+                if (z2) {
+                    this.btnToggleAlert.setChecked(true);
+                } else {
+                    this.btnToggleAlert.setChecked(false);
+                }
+                BatteryInfoAdapter.BatteryInfoManager.clearBatteryList(this);
+                this.mTextMaintenance.setVisibility(8);
+                this.mCleanCheckView.setVisibility(8);
+                this.mOnlineRegistrationSeparator.setVisibility(8);
+                this.mOnlineRegistrationView.setVisibility(8);
+                this.mMaintenanceBoxText.setVisibility(8);
+                this.mMaintenanceBoxView.setVisibility(8);
+                int i = this.serverLoginStatus;
+                if (i == 0) {
+                    this.mTvPrinterStatus.setText(getString(C2135R.string.EPS_PRNST_IDLE_TITLE));
+                    this.mTvPrinterStatusDetail.setText(getString(C2135R.string.EPS_PRNST_IDLE_MSG));
+                    this.mPrintHistoryView.setEnabled(true);
+                    ((TextView) findViewById(C2135R.C2137id.text_print_history)).setTextColor(this.mContext.getResources().getColor(C2135R.color.black));
+                    ((ImageView) findViewById(C2135R.C2137id.print_history_arrow)).setVisibility(0);
+                    this.mPrinterSettingView.setEnabled(true);
+                    ((TextView) findViewById(C2135R.C2137id.text_printer_setting)).setTextColor(this.mContext.getResources().getColor(C2135R.color.black));
+                    ((ImageView) findViewById(C2135R.C2137id.printer_setting_arrow)).setVisibility(0);
+                    return;
+                } else if (i == -1) {
+                    this.mTvPrinterStatus.setText(getString(C2135R.string.EC_ERR_COMM_ERROR_TITLE));
+                    this.mTvPrinterStatusDetail.setText(getString(C2135R.string.EC_ERR_COMM_ERROR));
+                    this.mPrintHistoryView.setEnabled(false);
+                    ((TextView) findViewById(C2135R.C2137id.text_print_history)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
+                    ((ImageView) findViewById(C2135R.C2137id.print_history_arrow)).setVisibility(8);
+                    this.mPrinterSettingView.setEnabled(false);
+                    ((TextView) findViewById(C2135R.C2137id.text_printer_setting)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
+                    ((ImageView) findViewById(C2135R.C2137id.printer_setting_arrow)).setVisibility(8);
+                    return;
+                } else {
+                    this.mTvPrinterStatus.setText(C2135R.string.epsonconnect_str_status_login_error_title);
+                    this.mTvPrinterStatusDetail.setText(getString(C2135R.string.epsonconnect_str_status_login_error));
+                    this.mPrintHistoryView.setEnabled(false);
+                    ((TextView) findViewById(C2135R.C2137id.text_print_history)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
+                    ((ImageView) findViewById(C2135R.C2137id.print_history_arrow)).setVisibility(8);
+                    this.mPrinterSettingView.setEnabled(false);
+                    ((TextView) findViewById(C2135R.C2137id.text_printer_setting)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
+                    ((ImageView) findViewById(C2135R.C2137id.printer_setting_arrow)).setVisibility(8);
+                    return;
+                }
+            case 3:
+                if (this.mPrinter.doGetLang() != 1) {
+                    this.mTextMaintenance.setVisibility(8);
+                    this.mCleanCheckView.setVisibility(8);
+                } else {
+                    this.mTextMaintenance.setVisibility(0);
+                    this.mCleanCheckView.setVisibility(0);
+                }
+                updateBuyInkGroupForLocalOrIPPrinter();
+                this.mPrinterSettingView.setVisibility(0);
+                this.mPrinterSettingSeparator.setVisibility(8);
+                this.mPrintPreviewView.setVisibility(8);
+                this.mAlertMesseageSeparater.setVisibility(8);
+                this.mAlertMesseageView.setVisibility(8);
+                this.mPrintHistorySeparator.setVisibility(8);
+                this.mPrintHistoryView.setVisibility(8);
+                this.mOnlineRegistrationSeparator.setVisibility(8);
+                this.mOnlineRegistrationView.setVisibility(8);
+                if (this.escprSetPrinterSuccessed == 0) {
+                    this.mHeadCleanView.setEnabled(true);
+                    this.mNozzleCheckView.setEnabled(true);
+                    this.mPrinterSettingView.setEnabled(true);
+                    ((TextView) findViewById(C2135R.C2137id.text_printer_setting)).setTextColor(this.mContext.getResources().getColor(C2135R.color.black));
+                    ((ImageView) findViewById(C2135R.C2137id.printer_setting_arrow)).setVisibility(0);
+                    setEpsonConnectButton(0);
+                    return;
+                }
+                this.mHeadCleanView.setEnabled(false);
+                this.mNozzleCheckView.setEnabled(false);
+                this.mPrinterSettingView.setEnabled(false);
+                ((TextView) findViewById(C2135R.C2137id.text_printer_setting)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
+                ((ImageView) findViewById(C2135R.C2137id.printer_setting_arrow)).setVisibility(8);
+                setEpsonConnectButton(1);
+                return;
+            default:
+                return;
+        }
+    }
+
+    private void localSetBuyInkGroupVisibility(int i) {
+        this.mBuyInkGroup.setVisibility(i);
+        this.mBuyInkGroupVisibility = i;
+    }
+
+    private void updateBuyInkGroupForLocalOrIPPrinter() {
+        int i;
+        int i2;
+        int i3;
+        int i4 = 0;
+        InkRplnInfoClient.InkRsInfo info = new InkRplnRepository(false).getInfo(this);
+        if (info != null) {
+            i = info.getButtonType();
+        } else {
+            i = 0;
+        }
+        int i5 = 8;
+        switch (i) {
+            case 1:
+                i3 = 0;
+                i2 = 8;
+                break;
+            case 2:
+                i3 = 0;
+                i5 = 0;
+                i2 = 0;
+                break;
+            case 3:
+                i3 = 8;
+                i4 = 8;
+                i2 = 8;
+                break;
+            default:
+                i3 = 8;
+                i5 = 0;
+                i2 = 8;
+                break;
+        }
+        localSetBuyInkGroupVisibility(i4);
+        this.mBuyInkView.setVisibility(i5);
+        this.mInkDsView.setVisibility(i3);
+        this.mBuyInkSeparator.setVisibility(i2);
+    }
+
+    /* access modifiers changed from: private */
+    public void setupErrorMessage(int i) {
+        Utils.makeMessageBox(this, getString(C2135R.string.EPS_PRNERR_DISABEL_CLEANING_TITLE), getString(C2135R.string.EPS_PRNERR_DISABEL_CLEANING_MSG), getString(C2135R.string.str_cancel)).show();
+    }
+
+    public void onClick(View view) {
+        int id = view.getId();
+        int i = C2135R.string.str_nozzle_check;
+        switch (id) {
+            case C2135R.C2137id.epsonconnect_option /*2131231020*/:
+                Intent intent = new Intent(this, ActivityECConfiguration.class);
+                intent.putExtra(ActivityECConfiguration.INTENT_EC_BLE_CONTENT, false);
+                startActivity(intent);
+                return;
+            case C2135R.C2137id.fwupdate_view /*2131231071*/:
+                Analytics.sendAction(getApplicationContext(), Analytics.ACTION_ID_MAINTENANCE_FIRMWARE_UPDATE);
+                Intent intent2 = new Intent(this, FirmwareUpdateActivity.class);
+                intent2.putExtra(Constants.PRINTER_IP, this.printerIp);
+                intent2.putExtra("PRINTER_MODEL_NAME", this.printerName);
+                this.isKeepSimpleAPConnection = true;
+                startActivity(intent2);
+                return;
+            case C2135R.C2137id.head_clean_view /*2131231097*/:
+                Analytics.sendAction(getApplicationContext(), Analytics.ACTION_ID_MAINTENANCE_HEAD_CLEANING);
+                AlertDialog.Builder icon = new AlertDialog.Builder(this).setIcon(C2135R.C2136drawable.ic_action_warning);
+                if (view.getId() != C2135R.C2137id.nozzle_check_view) {
+                    i = C2135R.string.str_head_clean;
+                }
+                icon.setTitle(i).setPositiveButton(C2135R.string.str_yes, new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialogInterface, int i) {
+                        MaintainActivity.this.performMaintain(2);
+                    }
+                }).setNegativeButton(C2135R.string.str_no, new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialogInterface, int i) {
+                    }
+                }).show();
+                return;
+            case C2135R.C2137id.maintenance_inkds /*2131231241*/:
+                Analytics.sendAction(this, Analytics.ACTION_ID_MAINTENANCE_READY_INK);
+                startBrowsReadyInkUrl();
+                return;
+            case C2135R.C2137id.mentenance_buy_ink /*2131231247*/:
+                Analytics.sendAction(this, Analytics.ACTION_ID_MAINTENANCE_BUY_INK);
+                showDialog(DIALOG_PROGRESS);
+                BuyInkTask(1, this.printerIp);
+                return;
+            case C2135R.C2137id.nozzle_check_view /*2131231280*/:
+                Analytics.sendAction(getApplicationContext(), Analytics.ACTION_ID_MAINTENANCE_NOZZLE_CHECK);
+                AlertDialog.Builder icon2 = new AlertDialog.Builder(this).setIcon(C2135R.C2136drawable.ic_action_warning);
+                if (view.getId() != C2135R.C2137id.nozzle_check_view) {
+                    i = C2135R.string.str_head_clean;
+                }
+                icon2.setTitle(i).setPositiveButton(C2135R.string.str_yes, new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialogInterface, int i) {
+                        new NozzleCheckTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
+                    }
+                }).setNegativeButton(C2135R.string.str_no, new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialogInterface, int i) {
+                    }
+                }).show();
+                return;
+            case C2135R.C2137id.online_registration /*2131231289*/:
+                showDialog(DIALOG_PROGRESS);
+                OnlineRegTask(this.printerIp);
+                return;
+            case C2135R.C2137id.print_history /*2131231348*/:
+                startActivity(new Intent(this, EccPrintLog.class));
+                return;
+            case C2135R.C2137id.printer /*2131231358*/:
+                EPLog.m305d(TAG, "onClick() R.id.printer");
+                new AsyncTask<Void, Void, Void>() {
+                    WorkingDialog dialog = new WorkingDialog(MaintainActivity.this);
+
+                    /* access modifiers changed from: protected */
+                    public void onPreExecute() {
+                        super.onPreExecute();
+                        MaintainActivity.this.hideLoadProgressBar();
+                        this.dialog.show();
+                    }
+
+                    /* access modifiers changed from: protected */
+                    public Void doInBackground(Void... voidArr) {
+                        MaintainActivity.this.stopLoadConfigThread();
+                        MaintainActivity.this.endBackGroundThread();
+                        MaintainActivity maintainActivity = MaintainActivity.this;
+                        WiFiDirectManager.disconnect(maintainActivity, WiFiDirectManager.DEVICE_TYPE_PRINTER, maintainActivity.printerIp);
+                        return null;
+                    }
+
+                    /* access modifiers changed from: protected */
+                    public void onPostExecute(Void voidR) {
+                        MaintainActivity.this.startSelectPrinterActivity();
+                        this.dialog.dismiss();
+                    }
+                }.execute(new Void[0]);
+                return;
+            case C2135R.C2137id.printer_setting /*2131231369*/:
+                switch (this.printerLocation) {
+                    case 1:
+                    case 3:
+                        if (!WiFiDirectManager.isSimpleAP(this) || this.isKeepSimpleAPConnection) {
+                            this.printerIp = this.mPrinter.doGetIp();
+                            startActivity(new Intent("android.intent.action.VIEW", Uri.parse(IPAddressUtils.buildURL(Analytics.EXTENSION_STRING_WEB, this.printerIp, CommonDefine.SLASH))));
+                            return;
+                        }
+                        new AlertDialog.Builder(this.mContext).setCancelable(false).setMessage(C2135R.string.str_webconfig_warn_message).setPositiveButton(C2135R.string.str_ok, new DialogInterface.OnClickListener() {
+                            public void onClick(DialogInterface dialogInterface, int i) {
+                                boolean unused = MaintainActivity.this.isKeepSimpleAPConnection = true;
+                                MaintainActivity maintainActivity = MaintainActivity.this;
+                                String unused2 = maintainActivity.printerIp = maintainActivity.mPrinter.doGetIp();
+                                MaintainActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(CommonDefine.HTTP_PREFIX + MaintainActivity.this.printerIp + CommonDefine.SLASH)));
+                            }
+                        }).create().show();
+                        return;
+                    case 2:
+                        startActivity(new Intent("android.intent.action.VIEW", Uri.parse("https://www.epsonconnect.com/user/")));
+                        return;
+                    default:
+                        return;
+                }
+            case C2135R.C2137id.toggleAlert /*2131231560*/:
+                if (this.btnToggleAlert.isChecked()) {
+                    SharedPreferences.Editor edit = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).edit();
+                    edit.putBoolean(Constants.ENABLE_SHOW_WARNING, true);
+                    edit.commit();
+                    return;
+                }
+                SharedPreferences.Editor edit2 = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).edit();
+                edit2.putBoolean(Constants.ENABLE_SHOW_WARNING, false);
+                edit2.commit();
+                return;
+            case C2135R.C2137id.togglePreview /*2131231563*/:
+                if (!this.btnTogglePreview.isChecked()) {
+                    SharedPreferences.Editor edit3 = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).edit();
+                    edit3.putBoolean(Constants.ENABLE_SHOW_PREVIEW, false);
+                    edit3.commit();
+                    return;
+                } else if (!isMessageScreenShowing) {
+                    showMessageDialog();
+                    return;
+                } else {
+                    SharedPreferences.Editor edit4 = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).edit();
+                    edit4.putBoolean(Constants.ENABLE_SHOW_PREVIEW, true);
+                    edit4.commit();
+                    return;
+                }
+            default:
+                return;
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void startSelectPrinterActivity() {
+        this.mWaiteInkDsDialog = true;
+        Intent intent = new Intent(this, MaintainPrinterSearchActivity.class);
+        intent.putExtra(Constants.PRINTER_ID, this.printerId);
+        intent.setAction("android.intent.action.VIEW");
+        startActivityForResult(intent, 101);
+    }
+
+    private void startBrowsReadyInkUrl() {
+        startActivity(new Intent(this, JumpUrlProgressActivity.class));
+    }
+
+    /* access modifiers changed from: private */
+    public void showNozzleCheckGuidanceDialog() {
+        if (!checkGaga()) {
+            new NozzleGuidanceDialog().show(getSupportFragmentManager(), DIALOG_TAG_NOZZLE_GUIDANCE);
+        }
+    }
+
+    private boolean checkGaga() {
+        String printerDeviceId = MyPrinter.getPrinterDeviceId(this, false);
+        if (printerDeviceId == null) {
+            return false;
+        }
+        return Arrays.asList(GAGA_DEVICE_ID_ARRAY).contains(printerDeviceId);
+    }
+
+    private void showMessageDialog() {
+        isMessageScreenShowing = true;
+        AlertDialog.Builder builder = new AlertDialog.Builder(this);
+        builder.setMessage(getString(C2135R.string.epsonconnect_str_preview_warning) + "\n\n" + getString(C2135R.string.epsonconnect_str_preview_warning2));
+        C20299 r1 = new DialogInterface.OnClickListener() {
+            public void onClick(DialogInterface dialogInterface, int i) {
+                SharedPreferences.Editor edit = MaintainActivity.this.getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).edit();
+                edit.putBoolean(Constants.ENABLE_SHOW_PREVIEW, true);
+                edit.commit();
+            }
+        };
+        C201610 r2 = new DialogInterface.OnClickListener() {
+            public void onClick(DialogInterface dialogInterface, int i) {
+                MaintainActivity.this.btnTogglePreview.setChecked(false);
+            }
+        };
+        builder.setPositiveButton(C2135R.string.str_yes, r1);
+        builder.setNegativeButton(C2135R.string.str_no, r2);
+        builder.setCancelable(false);
+        builder.show();
+        isMessageScreenShowing = false;
+    }
+
+    /* access modifiers changed from: private */
+    public void showProDia() {
+        if (this.customPro == null) {
+            this.customPro = new CustomProDialog(this, C2135R.style.AppTheme_Translucent, C2135R.layout.maintain_executing_dialog);
+        }
+        this.customPro.show();
+    }
+
+    /* access modifiers changed from: private */
+    public void cancelProDia() {
+        Dialog dialog = this.customPro;
+        if (dialog != null && dialog.isShowing()) {
+            this.customPro.cancel();
+            this.customPro = null;
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void showLoadProgressBar() {
+        if (this.mLoadConPro == null) {
+            this.mLoadConPro = findViewById(C2135R.C2137id.progress_status);
+        }
+        this.mLoadConPro.setVisibility(0);
+    }
+
+    /* access modifiers changed from: private */
+    public void hideLoadProgressBar() {
+        View view = this.mLoadConPro;
+        if (view != null) {
+            view.setVisibility(8);
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void stopLoadConfigThread() {
+        this.mIsCancelProbe = true;
+        Thread thread = this.mLoadConfigThread;
+        if (thread != null && thread.isAlive()) {
+            this.mPrinter.doCancelFindPrinter();
+            if (this.mEpsonService != null) {
+                new AsyncTaskExecutor<Void, Void, Void>() {
+                    /* access modifiers changed from: protected */
+                    public Void doInBackground(Void... voidArr) {
+                        try {
+                            MaintainActivity.this.mEpsonService.EpsonConnectCancel();
+                            return null;
+                        } catch (RemoteException e) {
+                            e.printStackTrace();
+                            return null;
+                        }
+                    }
+                }.executeOnExecutor(new Void[0]);
+            }
+            this.mLoadConfigThread.interrupt();
+            this.mLoadConfigThread = null;
+        }
+    }
+
+    private void startBackgroundThread() {
+        this.mIsStillUpdate = true;
+        this.mBackGround = new Thread(new Runnable() {
+            public void run() {
+                int doGetStatus = MaintainActivity.this.mPrinter.doGetStatus();
+                Message message = new Message();
+                message.what = 2;
+                Bundle bundle = new Bundle();
+                bundle.putInt("GET_STT_RESULT", doGetStatus);
+                message.setData(bundle);
+                MaintainActivity.this.mUiHandler.sendMessage(message);
+                int doGetInkInfo = MaintainActivity.this.mPrinter.doGetInkInfo();
+                Message message2 = new Message();
+                message2.what = 3;
+                Bundle bundle2 = new Bundle();
+                bundle2.putInt("GET_INK_RESULT", doGetInkInfo);
+                message2.setData(bundle2);
+                MaintainActivity.this.mUiHandler.sendMessage(message2);
+                BatteryInfoEx batteryInfoEx = new BatteryInfoEx();
+                int batteryInfo = MaintainActivity.this.mPrinter.getBatteryInfo(batteryInfoEx);
+                boolean z = batteryInfo == 0 && batteryInfoEx.powerSourceType != -1;
+                Message message3 = new Message();
+                message3.what = 15;
+                Bundle bundle3 = new Bundle();
+                bundle3.putInt("GET_BATTERY_RESULT", batteryInfo);
+                bundle3.putParcelable("GET_BATTERY_INFO", batteryInfoEx);
+                message3.setData(bundle3);
+                MaintainActivity.this.mUiHandler.sendMessage(message3);
+                int[] maintenanceBoxInformation = MaintainActivity.this.mPrinter.getMaintenanceBoxInformation();
+                MaintainActivity maintainActivity = MaintainActivity.this;
+                maintainActivity.sendMaintenanceBoxInfoMessage(maintainActivity.mUiHandler, maintenanceBoxInformation);
+                while (MaintainActivity.this.mIsStillUpdate) {
+                    try {
+                        EPLog.m313i(MaintainActivity.TAG, "thread update stt running");
+                        int doGetStatus2 = MaintainActivity.this.mPrinter.doGetStatus();
+                        Message message4 = new Message();
+                        message4.what = 2;
+                        bundle3.putInt("GET_STT_RESULT", doGetStatus2);
+                        Bundle bundle4 = new Bundle();
+                        message4.setData(bundle4);
+                        MaintainActivity.this.mUiHandler.sendMessage(message4);
+                        if (z) {
+                            int batteryInfo2 = MaintainActivity.this.mPrinter.getBatteryInfo(batteryInfoEx);
+                            Message message5 = new Message();
+                            message5.what = 15;
+                            bundle3 = new Bundle();
+                            bundle3.putInt("GET_BATTERY_RESULT", batteryInfo2);
+                            bundle3.putParcelable("GET_BATTERY_INFO", batteryInfoEx);
+                            message5.setData(bundle3);
+                            MaintainActivity.this.mUiHandler.sendMessage(message5);
+                        } else {
+                            bundle3 = bundle4;
+                        }
+                        MaintainActivity.this.sendMaintenanceBoxInfoMessage(MaintainActivity.this.mUiHandler, MaintainActivity.this.mPrinter.getMaintenanceBoxInformation());
+                        Thread.sleep(4000);
+                    } catch (InterruptedException e) {
+                        EPLog.m318w("startBackgroundThread", "InterruptedException");
+                        e.printStackTrace();
+                        return;
+                    }
+                }
+            }
+        }, "status-update");
+        this.mBackGround.setPriority(5);
+        this.mBackGround.start();
+    }
+
+    /* access modifiers changed from: private */
+    public void sendMaintenanceBoxInfoMessage(Handler handler, int[] iArr) {
+        this.mUiHandler.removeMessages(16);
+        handler.sendMessage(handler.obtainMessage(16, 0, 0, iArr));
+    }
+
+    /* access modifiers changed from: private */
+    public void endBackGroundThread() {
+        this.mIsStillUpdate = false;
+        Thread thread = this.mBackGround;
+        if (thread != null && thread.isAlive()) {
+            this.mBackGround.interrupt();
+            try {
+                this.mBackGround.join();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+            this.mBackGround = null;
+        }
+    }
+
+    public void onConfigurationChanged(Configuration configuration) {
+        super.onConfigurationChanged(configuration);
+    }
+
+    /* access modifiers changed from: protected */
+    public void onActivityResult(int i, int i2, Intent intent) {
+        IEpsonService iEpsonService;
+        super.onActivityResult(i, i2, intent);
+        switch (i) {
+            case 100:
+                onInkReplenishDialogEnd();
+                return;
+            case 101:
+                MyPrinter curPrinter = MyPrinter.getCurPrinter(this);
+                if (curPrinter.getName() == null) {
+                    finish();
+                    return;
+                } else if (i2 == 1) {
+                    if (MyPrinter.isRemotePrinter(getApplicationContext()) && (iEpsonService = this.mEpsonService) != null) {
+                        try {
+                            iEpsonService.refreshRemotePrinterLogin();
+                        } catch (RemoteException unused) {
+                        }
+                    }
+                    if (!isSimpleApOrP2p(curPrinter)) {
+                        startInkDsDialog();
+                        return;
+                    } else {
+                        onInkReplenishDialogEnd();
+                        return;
+                    }
+                } else {
+                    onInkReplenishDialogEnd();
+                    return;
+                }
+            default:
+                return;
+        }
+    }
+
+    private boolean isSimpleApOrP2p(MyPrinter myPrinter) {
+        return WiFiDirectManager.getCurConnectInfo(this, MacAddrUtils.getMacAddressFromPrinterId(myPrinter.getPrinterId())) != null;
+    }
+
+    private void onInkReplenishDialogEnd() {
+        this.mWaiteInkDsDialog = false;
+    }
+
+    private void startInkDsDialog() {
+        startActivityForResult(InkRplnProgressDialog.getStartIntent(this), 100);
+    }
+
+    /* access modifiers changed from: private */
+    public void updateSelectedPrinter() {
+        hideLoadProgressBar();
+        stopLoadConfigThread();
+        this.mIsNozzleCheckEnable = true;
+        this.escprSetPrinterSuccessed = this.mPrinter.doSetPrinter();
+        int i = this.escprSetPrinterSuccessed;
+        int i2 = 0;
+        if (i == 0) {
+            startBackgroundThread();
+            this.mIsStillUpdate = true;
+            setButtonClickable(true);
+        } else {
+            this.mIsStillUpdate = false;
+            handlerError(i, false);
+        }
+        if (this.mPrinter.doGetLang() != 1) {
+            this.mHeadCleanView.setVisibility(8);
+            this.mNozzleCheckView.setVisibility(8);
+            this.mFWUpdateView.setVisibility(8);
+        } else {
+            this.mHeadCleanView.setVisibility(0);
+            this.mNozzleCheckView.setVisibility(0);
+            LinearLayout linearLayout = this.mFWUpdateView;
+            if (this.printerLocation != 1) {
+                i2 = 8;
+            }
+            linearLayout.setVisibility(i2);
+        }
+        this.printerIp = this.mPrinter.doGetIp();
+    }
+
+    /* access modifiers changed from: private */
+    public synchronized void updateStatus(int i) {
+        this.mUiHandler.sendEmptyMessage(11);
+        if (i == 0) {
+            if (isPrinterReady() != 1) {
+                setButtonClickable(false);
+            } else {
+                setButtonClickable(true);
+                int doGetInkInfo = this.mPrinter.doGetInkInfo();
+                Message message = new Message();
+                message.what = 3;
+                Bundle bundle = new Bundle();
+                bundle.putInt("GET_INK_RESULT", doGetInkInfo);
+                message.setData(bundle);
+                this.mUiHandler.sendMessage(message);
+            }
+            if (this.mPrinterStatus[0] == 4) {
+                if (this.mPrinterStatus[1] == 102) {
+                    this.escprSetPrinterSuccessed = -1;
+                } else {
+                    this.escprSetPrinterSuccessed = 0;
+                }
+                if (this.isRemotePrinter && this.mPrinterStatus[1] == 102) {
+                    this.mUiHandler.sendEmptyMessage(11);
+                } else {
+                    setErrorStatus(this.mPrinterStatus[0], this.mPrinterStatus[1]);
+                    if (this.mPrinterStatus[1] == 102) {
+                        this.mInkView.removeAllViews();
+                    }
+                    if (this.mPrinterStatus[1] == 6 || this.mPrinterStatus[1] == 103 || this.mPrinterStatus[1] == 104) {
+                        int doGetInkInfo2 = this.mPrinter.doGetInkInfo();
+                        Message message2 = new Message();
+                        message2.what = 3;
+                        Bundle bundle2 = new Bundle();
+                        bundle2.putInt("GET_INK_RESULT", doGetInkInfo2);
+                        message2.setData(bundle2);
+                        this.mUiHandler.sendMessage(message2);
+                    }
+                }
+            } else {
+                this.escprSetPrinterSuccessed = 0;
+                Integer[] stringId = MediaInfo.StatusTable.getStringId(this.mPrinterStatus[0]);
+                if (stringId != null) {
+                    this.mTvPrinterStatus.setText(getString(stringId[0].intValue()));
+                    this.mTvPrinterStatusDetail.setText(getString(stringId[1].intValue()));
+                } else {
+                    TextView textView = this.mTvPrinterStatus;
+                    textView.setText("Stt Code: " + this.mPrinterStatus[0]);
+                    TextView textView2 = this.mTvPrinterStatusDetail;
+                    textView2.setText("Err Code: " + this.mPrinterStatus[1]);
+                }
+            }
+        } else {
+            handlerError(i, false);
+        }
+    }
+
+    public void updateInkInfo(int i) {
+        createInkView(this.mPrinter.getMPrinterInfor(), i);
+    }
+
+    /* access modifiers changed from: private */
+    public void updateBatteryInfoEx(int i, BatteryInfoEx batteryInfoEx) {
+        int i2 = batteryInfoEx.number;
+        int i3 = batteryInfoEx.powerSourceType;
+        if (i != 0 || i2 <= 0 || i3 == -1) {
+            BatteryInfoAdapter.BatteryInfoManager.clearBatteryList(this);
+            return;
+        }
+        int[] iArr = batteryInfoEx.batteryState;
+        int[] iArr2 = batteryInfoEx.batteryRemain;
+        BatteryInfoAdapter.BatteryInfoManager.showPowerText(this);
+        BatteryInfoAdapter.BatteryInfoManager.showBatteryList(this, i2, i3, iArr, iArr2);
+    }
+
+    /* access modifiers changed from: private */
+    public void updateMaintenanceBoxInfo(int[] iArr) {
+        int i = this.mBuyInkGroupVisibility;
+        if (iArr == null || iArr.length <= 0) {
+            this.mMaintenanceBoxText.setVisibility(8);
+            this.mMaintenanceBoxView.setVisibility(8);
+            if (8 != this.mInkView.getVisibility()) {
+                int i2 = this.mBuyInkGroupVisibility;
+                return;
+            }
+            return;
+        }
+        this.mMaintenanceBoxText.setVisibility(0);
+        this.mMaintenanceBoxView.setVisibility(0);
+        this.mBuyInkGroup.setVisibility(i);
+        LayoutInflater from = LayoutInflater.from(this);
+        Point point = new Point();
+        this.mDisplay.getSize(point);
+        int i3 = (point.x - 30) / 2;
+        this.mMaintenanceBoxView.removeAllViews();
+        int length = iArr.length / 2;
+        for (int i4 = 0; i4 < length; i4++) {
+            int i5 = i4 * 2;
+            int i6 = iArr[i5];
+            int i7 = iArr[i5 + 1];
+            View inflate = from.inflate(C2135R.layout.ink_item, this.mMaintenanceBoxView, false);
+            ((TextView) inflate.findViewById(C2135R.C2137id.ink_name)).setVisibility(8);
+            ((RelativeLayout) inflate.findViewById(C2135R.C2137id.ink_holder)).getLayoutParams().width = i3;
+            ViewGroup viewGroup = (ViewGroup) inflate.findViewById(C2135R.C2137id.ink_level);
+            if (i7 <= 0 || isMaintenanceBoxStatusDisplayX(i6)) {
+                viewGroup.getLayoutParams().width = 0;
+                inflate.findViewById(C2135R.C2137id.ink_error).setVisibility(0);
+                viewGroup.setVisibility(4);
+            } else {
+                viewGroup.getLayoutParams().width = (int) ((((float) (i3 - 4)) / 100.0f) * ((float) i7));
+                viewGroup.setBackgroundResource(C2135R.color.maintenance_box_info);
+                viewGroup.setVisibility(0);
+            }
+            this.mMaintenanceBoxView.addView(inflate);
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void handlerError(int i, boolean z) {
+        hideLoadProgressBar();
+        if (i == -1351 || i == -1100) {
+            i = -1300;
+        }
+        if (this.isRemotePrinter && i == -1300) {
+            setButtonClickable(false);
+            this.mUiHandler.sendEmptyMessage(11);
+            return;
+        }
+        setErrorStatus(4, i);
+        setButtonClickable(false);
+        this.mUiHandler.sendEmptyMessage(11);
+        if (!z) {
+            return;
+        }
+        if (i == -1300 || i == -500001) {
+            this.mInkView.removeAllViews();
+        }
+    }
+
+    private void setErrorStatus(int i, int i2) {
+        Integer[] stringId = MediaInfo.ErrorTable.getStringId(i2);
+        if (stringId != null) {
+            String[] replaceMessage = Utils.replaceMessage(stringId, i2, getApplicationContext());
+            this.mTvPrinterStatus.setText(replaceMessage[1]);
+            EPLog.m313i(TAG, "Stt title: " + replaceMessage[1]);
+            String str = replaceMessage[0];
+            this.mTvPrinterStatusDetail.setText(str);
+            EPLog.m313i(TAG, "Stt detail: " + str);
+            return;
+        }
+        TextView textView = this.mTvPrinterStatus;
+        textView.setText("Stt Code: " + i);
+        TextView textView2 = this.mTvPrinterStatusDetail;
+        textView2.setText("Err Code: " + i2);
+    }
+
+    private int isPrinterReady() {
+        this.mPrinterStatus = this.mPrinter.getMPrinterInfor().getMStatus();
+        int[] iArr = this.mPrinterStatus;
+        if (iArr[0] == 2 || iArr[0] == 1 || iArr[0] == 3) {
+            return 0;
+        }
+        if (iArr[0] == 4) {
+            return -1;
+        }
+        return 1;
+    }
+
+    /* access modifiers changed from: private */
+    public void interrupMaintainThread() {
+        Thread thread = this.mDoMaintainThread;
+        if (thread != null && thread.isAlive()) {
+            this.mDoMaintainThread.interrupt();
+            this.mDoMaintainThread = null;
+        }
+    }
+
+    /* access modifiers changed from: protected */
+    public void onDestroy() {
+        super.onDestroy();
+        EPLog.m313i(TAG, "onDestroy");
+        IEpsonService iEpsonService = this.mEpsonService;
+        if (iEpsonService != null) {
+            try {
+                iEpsonService.unregisterCallback(this.mCallback);
+                unbindService(this.mEpsonConnection);
+            } catch (RemoteException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /* access modifiers changed from: protected */
+    public void onResume() {
+        EPLog.m307e("MaintainActivity", "onResume()");
+        super.onResume();
+        this.isKeepSimpleAPConnection = false;
+        if (!this.mWaiteInkDsDialog) {
+            startLoadConThread();
+        }
+    }
+
+    /* access modifiers changed from: protected */
+    public void onPause() {
+        EPLog.m305d("MaintainActivity", "onPause");
+        this.mIsCancelProbe = true;
+        hideLoadProgressBar();
+        this.mPrinter.doCancelFindPrinter();
+        stopLoadConfigThread();
+        interrupMaintainThread();
+        endBackGroundThread();
+        this.mUiHandler.removeMessages(16);
+        if (!this.isKeepSimpleAPConnection) {
+            WiFiDirectManager.disconnect(this, WiFiDirectManager.DEVICE_TYPE_PRINTER, this.printerIp);
+        }
+        super.onPause();
+    }
+
+    /* access modifiers changed from: protected */
+    public void onStop() {
+        super.onStop();
+    }
+
+    /* access modifiers changed from: private */
+    public void performMaintain(final int i) {
+        if (isPrinterReady() == 1) {
+            this.mUiHandler.sendEmptyMessage(0);
+            this.mDoMaintainThread = new Thread(new Runnable() {
+                /* JADX WARNING: Removed duplicated region for block: B:35:0x0092 A[EDGE_INSN: B:35:0x0092->B:29:0x0092 ?: BREAK  , SYNTHETIC] */
+                /* JADX WARNING: Removed duplicated region for block: B:37:0x002a A[SYNTHETIC] */
+                /* Code decompiled incorrectly, please refer to instructions dump. */
+                public void run() {
+                    /*
+                        r9 = this;
+                        epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this
+                        com.epson.mobilephone.common.maintain2.MaintainPrinter2 r0 = r0.mPrinter
+                        int r1 = r3
+                        int r0 = r0.doDoMainteCmd(r1)
+                        r1 = 108(0x6c, float:1.51E-43)
+                        r2 = 10
+                        r3 = 1
+                        r4 = 0
+                        if (r0 != r1) goto L_0x0028
+                        epson.maintain.activity.MaintainActivity r5 = epson.maintain.activity.MaintainActivity.this
+                        boolean unused = r5.isGotError = r3
+                        r5 = 11
+                        epson.maintain.activity.MaintainActivity r6 = epson.maintain.activity.MaintainActivity.this
+                        android.os.Handler r6 = r6.mUiHandler
+                        r6.sendEmptyMessage(r2)
+                        r5 = 0
+                        r6 = 11
+                        goto L_0x002a
+                    L_0x0028:
+                        r5 = 1
+                        r6 = 0
+                    L_0x002a:
+                        if (r5 != 0) goto L_0x002e
+                        if (r6 > r2) goto L_0x0092
+                    L_0x002e:
+                        r7 = 1000(0x3e8, double:4.94E-321)
+                        java.lang.Thread.sleep(r7)     // Catch:{ InterruptedException -> 0x009c }
+                        int r6 = r6 + 1
+                        if (r0 != r1) goto L_0x004a
+                        epson.maintain.activity.MaintainActivity r5 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x0046 }
+                        boolean unused = r5.isGotError = r3     // Catch:{ InterruptedException -> 0x0046 }
+                        epson.maintain.activity.MaintainActivity r5 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x0046 }
+                        android.os.Handler r5 = r5.mUiHandler     // Catch:{ InterruptedException -> 0x0046 }
+                        r5.sendEmptyMessage(r2)     // Catch:{ InterruptedException -> 0x0046 }
+                        goto L_0x0092
+                    L_0x0046:
+                        r5 = move-exception
+                        r7 = r5
+                        r5 = 0
+                        goto L_0x009d
+                    L_0x004a:
+                        epson.maintain.activity.MaintainActivity r7 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009c }
+                        com.epson.mobilephone.common.maintain2.MaintainPrinter2 r7 = r7.mPrinter     // Catch:{ InterruptedException -> 0x009c }
+                        r7.doGetStatus()     // Catch:{ InterruptedException -> 0x009c }
+                        epson.maintain.activity.MaintainActivity r7 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009c }
+                        int[] r7 = r7.mPrinterStatus     // Catch:{ InterruptedException -> 0x009c }
+                        r7 = r7[r4]     // Catch:{ InterruptedException -> 0x009c }
+                        r8 = 4
+                        if (r7 != r8) goto L_0x006d
+                        epson.maintain.activity.MaintainActivity r7 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009c }
+                        boolean unused = r7.isGotError = r3     // Catch:{ InterruptedException -> 0x009c }
+                        epson.maintain.activity.MaintainActivity r7 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009c }
+                        android.os.Handler r7 = r7.mUiHandler     // Catch:{ InterruptedException -> 0x009c }
+                        r7.sendEmptyMessage(r8)     // Catch:{ InterruptedException -> 0x009c }
+                        goto L_0x0072
+                    L_0x006d:
+                        epson.maintain.activity.MaintainActivity r7 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009c }
+                        boolean unused = r7.isGotError = r4     // Catch:{ InterruptedException -> 0x009c }
+                    L_0x0072:
+                        epson.maintain.activity.MaintainActivity r7 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009c }
+                        int[] r7 = r7.mPrinterStatus     // Catch:{ InterruptedException -> 0x009c }
+                        r7 = r7[r4]     // Catch:{ InterruptedException -> 0x009c }
+                        if (r7 == 0) goto L_0x0089
+                        epson.maintain.activity.MaintainActivity r7 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009c }
+                        int[] r7 = r7.mPrinterStatus     // Catch:{ InterruptedException -> 0x009c }
+                        r5 = r7[r4]     // Catch:{ InterruptedException -> 0x009c }
+                        if (r5 != r8) goto L_0x0087
+                        goto L_0x0089
+                    L_0x0087:
+                        r5 = 1
+                        goto L_0x008a
+                    L_0x0089:
+                        r5 = 0
+                    L_0x008a:
+                        epson.maintain.activity.MaintainActivity r7 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009c }
+                        boolean r7 = r7.isGotError     // Catch:{ InterruptedException -> 0x009c }
+                        if (r7 == 0) goto L_0x002a
+                    L_0x0092:
+                        epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this
+                        android.os.Handler r0 = r0.mUiHandler
+                        r0.sendEmptyMessage(r3)
+                        return
+                    L_0x009c:
+                        r7 = move-exception
+                    L_0x009d:
+                        r7.printStackTrace()
+                        goto L_0x002a
+                    */
+                    throw new UnsupportedOperationException("Method not decompiled: epson.maintain.activity.MaintainActivity.C201913.run():void");
+                }
+            });
+            this.mDoMaintainThread.start();
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void loadConfig() {
+        MyPrinter curPrinter = MyPrinter.getCurPrinter(this);
+        this.printerName = curPrinter.getUserDefName(this);
+        if (this.printerName == null) {
+            this.printerName = "";
+        }
+        this.printerId = curPrinter.getPrinterId();
+        if (this.printerId == null) {
+            this.printerId = "";
+        }
+        this.printerIp = curPrinter.getIp();
+        if (this.printerIp == null) {
+            this.printerIp = "";
+        }
+        this.printerLocation = curPrinter.getLocation();
+    }
+
+    public void createInkView(MaintainPrinterInfo2 maintainPrinterInfo2, int i) {
+        MaintainPrinterInfo2 maintainPrinterInfo22 = maintainPrinterInfo2;
+        LayoutInflater from = LayoutInflater.from(this);
+        Point point = new Point();
+        this.mDisplay.getSize(point);
+        int i2 = (point.x - 30) / 2;
+        LinearLayout linearLayout = this.mInkView;
+        if (linearLayout != null) {
+            linearLayout.removeAllViews();
+        }
+        int inkNum = maintainPrinterInfo2.getInkNum();
+        if (inkNum > 0) {
+            findViewById(C2135R.C2137id.ink_text).setVisibility(0);
+            this.mInkView.setVisibility(0);
+            this.mBuyInkGroup.setVisibility(this.mBuyInkGroupVisibility);
+            for (int i3 = 0; i3 < inkNum; i3++) {
+                int inkRemainingAmount = maintainPrinterInfo22.getInkRemainingAmount(i3);
+                int inkName = maintainPrinterInfo22.getInkName(i3);
+                Integer[] colorName = MediaInfo.ColorTable.getColorName(inkName);
+                if (colorName == null) {
+                    EpLog.m77i("colorNo = " + inkName);
+                    colorName = MediaInfo.ColorTable.getColorName(Constants.ColorName.EPS_COLOR_WHITE.ordinal());
+                    if (colorName != null) {
+                        colorName[1] = 0;
+                    } else {
+                        return;
+                    }
+                } else {
+                    logColorInfo(inkName, colorName);
+                }
+                View inflate = from.inflate(C2135R.layout.ink_item, (ViewGroup) null);
+                TextView textView = (TextView) inflate.findViewById(C2135R.C2137id.ink_name);
+                if (colorName[1].intValue() != 0) {
+                    textView.setText(colorName[1].intValue());
+                } else {
+                    textView.setText("");
+                }
+                ((RelativeLayout) inflate.findViewById(C2135R.C2137id.ink_holder)).getLayoutParams().width = i2;
+                ViewGroup viewGroup = (ViewGroup) inflate.findViewById(C2135R.C2137id.ink_level);
+                float f = (float) (i2 - 4);
+                if (maintainPrinterInfo22.getInkStatus(i3) == -4 || i != 0) {
+                    viewGroup.getLayoutParams().width = 0;
+                    viewGroup.setVisibility(4);
+                    if (maintainPrinterInfo22.getInkStatus(i3) != -4) {
+                        inflate.findViewById(C2135R.C2137id.ink_error).setVisibility(0);
+                    }
+                } else {
+                    viewGroup.getLayoutParams().width = calcInkWidth(inkRemainingAmount, f);
+                    if (!(maintainPrinterInfo22.getInkStatus(i3) == 0 || maintainPrinterInfo22.getInkStatus(i3) == 1 || maintainPrinterInfo22.getInkStatus(i3) == 2)) {
+                        viewGroup.getLayoutParams().width = 0;
+                    }
+                    if (checkIfWhite(colorName[0].intValue())) {
+                        View findViewById = inflate.findViewById(C2135R.C2137id.white_ink_level);
+                        findViewById.setBackgroundResource(colorName[0].intValue());
+                        findViewById.setVisibility(0);
+                    } else {
+                        viewGroup.setBackgroundResource(colorName[0].intValue());
+                    }
+                    viewGroup.setVisibility(0);
+                    if (inkRemainingAmount <= 0) {
+                        inflate.findViewById(C2135R.C2137id.ink_error).setVisibility(0);
+                    }
+                }
+                this.mInkView.addView(inflate);
+            }
+            return;
+        }
+        findViewById(C2135R.C2137id.ink_text).setVisibility(8);
+        this.mInkView.setVisibility(8);
+    }
+
+    private boolean checkIfWhite(@ColorRes int i) {
+        try {
+            return (getResources().getColor(i) & ViewCompat.MEASURED_SIZE_MASK) == 16777215;
+        } catch (Resources.NotFoundException unused) {
+            return false;
+        }
+    }
+
+    private void logColorInfo(int i, @NonNull Integer[] numArr) {
+        String str;
+        String str2;
+        String str3;
+        int intValue = numArr[1].intValue();
+        int intValue2 = numArr[0].intValue();
+        int intValue3 = numArr[2].intValue();
+        StringBuilder sb = new StringBuilder();
+        sb.append("colorNo = ");
+        sb.append(i);
+        sb.append(":");
+        if (intValue == 0) {
+            str = "--";
+        } else {
+            str = getString(numArr[1].intValue());
+        }
+        sb.append(str);
+        sb.append(":");
+        if (intValue2 == 0) {
+            str2 = "--";
+        } else {
+            str2 = String.format("#%06X", new Object[]{Integer.valueOf(16777215 & ContextCompat.getColor(this, numArr[0].intValue()))});
+        }
+        sb.append(str2);
+        sb.append(":");
+        if (intValue3 == 0) {
+            str3 = "--";
+        } else {
+            str3 = getString(numArr[2].intValue());
+        }
+        sb.append(str3);
+        EpLog.m77i(sb.toString());
+    }
+
+    private class CustomProDialog extends Dialog {
+        private int mLayoutId;
+
+        CustomProDialog(Context context, int i, int i2) {
+            super(context, i);
+            this.mLayoutId = i2;
+            setCancelable(false);
+        }
+
+        /* access modifiers changed from: protected */
+        public void onCreate(Bundle bundle) {
+            super.onCreate(bundle);
+            requestWindowFeature(1);
+            View inflate = getLayoutInflater().inflate(this.mLayoutId, (ViewGroup) null);
+            if (this.mLayoutId == C2135R.layout.maintain_executing_dialog) {
+                ((Button) inflate.findViewById(C2135R.C2137id.close_btn)).setOnClickListener(new View.OnClickListener() {
+                    public void onClick(View view) {
+                        CustomProDialog.this.cancel();
+                        MaintainActivity.this.interrupMaintainThread();
+                    }
+                });
+            }
+            setContentView(inflate);
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void setButtonClickable(boolean z) {
+        this.mNozzleCheckView.setClickable(z);
+        this.mHeadCleanView.setClickable(z);
+        this.mFWUpdateView.setClickable(z);
+        if (z) {
+            if (!this.mIsNozzleCheckEnable.booleanValue()) {
+                this.mNozzleCheckText.setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
+            } else {
+                this.mNozzleCheckText.setTextColor(this.mContext.getResources().getColor(C2135R.color.black));
+            }
+            this.mHeadCleanText.setTextColor(this.mContext.getResources().getColor(C2135R.color.black));
+            this.mFWUpdateText.setTextColor(this.mContext.getResources().getColor(C2135R.color.black));
+            return;
+        }
+        this.mNozzleCheckText.setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
+        this.mHeadCleanText.setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
+        this.mFWUpdateText.setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
+    }
+
+    /* access modifiers changed from: private */
+    public void setEpsonConnectButton(int i) {
+        switch (i) {
+            case 0:
+                this.mEpsonConnectView.setClickable(true);
+                this.mEpsonConnectView.setEnabled(true);
+                ((TextView) findViewById(C2135R.C2137id.text_epson_connect)).setTextColor(this.mContext.getResources().getColor(C2135R.color.black));
+                ((ImageView) findViewById(C2135R.C2137id.epsonconnect_arrow)).setVisibility(0);
+                findViewById(C2135R.C2137id.epsonconnect_separator).setVisibility(0);
+                this.mEpsonConnectView.setVisibility(0);
+                return;
+            case 1:
+                this.mEpsonConnectView.setClickable(false);
+                this.mEpsonConnectView.setEnabled(false);
+                ((TextView) findViewById(C2135R.C2137id.text_epson_connect)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
+                ((ImageView) findViewById(C2135R.C2137id.epsonconnect_arrow)).setVisibility(8);
+                findViewById(C2135R.C2137id.epsonconnect_separator).setVisibility(0);
+                this.mEpsonConnectView.setVisibility(0);
+                return;
+            case 2:
+                this.mEpsonConnectView.setClickable(false);
+                this.mEpsonConnectView.setEnabled(false);
+                ((TextView) findViewById(C2135R.C2137id.text_epson_connect)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
+                ((ImageView) findViewById(C2135R.C2137id.epsonconnect_arrow)).setVisibility(8);
+                findViewById(C2135R.C2137id.epsonconnect_separator).setVisibility(8);
+                this.mEpsonConnectView.setVisibility(8);
+                return;
+            default:
+                return;
+        }
+    }
+
+    /* access modifiers changed from: package-private */
+    public void startBrowseNozzleCheckGuidance() {
+        showDialog(DIALOG_PROGRESS);
+        BuyInkTask(2, this.printerIp);
+    }
+
+    private void BuyInkTask(int i, String str) {
+        if (this.modelBuyInkOnlineRegTask.getReady()) {
+            this.modelBuyInkOnlineRegTask.loadData(i, str);
+        }
+    }
+
+    private void OnlineRegTask(String str) {
+        if (this.modelBuyInkOnlineRegTask.getReady()) {
+            this.modelBuyInkOnlineRegTask.loadData(str);
+        }
+    }
+
+    public static boolean disableSimpleApAndWait(Context context, String str) {
+        if (!WiFiDirectManager.disconnect(context, WiFiDirectManager.DEVICE_TYPE_PRINTER, str)) {
+            return false;
+        }
+        int i = 0;
+        while (i < 10) {
+            try {
+                if (Utils.isOnline(context)) {
+                    return true;
+                }
+                EPLog.m305d(TAG, "Wait Connection 3G");
+                i++;
+                Thread.sleep(1000);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+                return false;
+            }
+        }
+        return false;
+    }
+
+    private void showDialog(String str) {
+        DialogProgress newInstance = DialogProgress.newInstance(str, 0, getString(C2135R.string.str_wait));
+        newInstance.setCancelable(false);
+        newInstance.show(getSupportFragmentManager(), str);
+    }
+
+    private void dismissDialog(String str) {
+        DialogFragment dialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(str);
+        if (dialogFragment != null) {
+            dialogFragment.dismiss();
+        }
+    }
+
+    private class NozzleCheckTask extends AsyncTask<Void, Void, Integer> {
+        private NozzleCheckTask() {
+        }
+
+        /* access modifiers changed from: protected */
+        public void onPreExecute() {
+            MaintainActivity.this.showProDia();
+        }
+
+        /* access modifiers changed from: protected */
+        public Integer doInBackground(Void... voidArr) {
+            return Integer.valueOf(MaintainActivity.this.mPrinter.doDoMainteCmd(3));
+        }
+
+        /* access modifiers changed from: protected */
+        public void onPostExecute(Integer num) {
+            MaintainActivity.this.cancelProDia();
+            if (num.intValue() == 108) {
+                MaintainActivity.this.setupErrorMessage(10);
+            } else {
+                MaintainActivity.this.showNozzleCheckGuidanceDialog();
+            }
+        }
+    }
+}

+ 94 - 0
app/src/main/java/epson/maintain/activity/MaintainBuyInkOnlineRegTask.java

@@ -0,0 +1,94 @@
+package epson.maintain.activity;
+
+import android.app.Application;
+import android.arch.lifecycle.AndroidViewModel;
+import android.arch.lifecycle.MutableLiveData;
+import android.net.Uri;
+import android.os.AsyncTask;
+import epson.common.EventWrapper;
+import epson.print.CommonDefine;
+import epson.print.Util.BuyInkUrl;
+
+public class MaintainBuyInkOnlineRegTask extends AndroidViewModel {
+    public static final int URL_BUY_INK = 1;
+    public static final int URL_NOZZLE_CHECK = 2;
+    private boolean mState = true;
+    private MutableLiveData<EventWrapper<Uri>> mUriEvent;
+
+    public MaintainBuyInkOnlineRegTask(Application application) {
+        super(application);
+    }
+
+    public void setReady(boolean z) {
+        this.mState = z;
+    }
+
+    public boolean getReady() {
+        return this.mState;
+    }
+
+    public void setUriEvent(Uri uri) {
+        if (this.mUriEvent == null) {
+            this.mUriEvent = new MutableLiveData<>();
+        }
+        this.mUriEvent.setValue(new EventWrapper(uri));
+    }
+
+    public MutableLiveData<EventWrapper<Uri>> getUriEvent() {
+        if (this.mUriEvent == null) {
+            this.mUriEvent = new MutableLiveData<>();
+        }
+        return this.mUriEvent;
+    }
+
+    public void loadData(final int i, final String str) {
+        final Application application = getApplication();
+        new AsyncTask<Void, Void, Uri>() {
+            /* access modifiers changed from: protected */
+            public void onPreExecute() {
+                super.onPreExecute();
+                MaintainBuyInkOnlineRegTask.this.setReady(false);
+            }
+
+            /* access modifiers changed from: protected */
+            public Uri doInBackground(Void... voidArr) {
+                MaintainActivity.disableSimpleApAndWait(application, str);
+                if (i != 2) {
+                    return BuyInkUrl.getBuyInkUri(application);
+                }
+                return BuyInkUrl.getNozzleCheckGuidanceUri(application);
+            }
+
+            /* access modifiers changed from: protected */
+            public void onPostExecute(Uri uri) {
+                super.onPostExecute(uri);
+                MaintainBuyInkOnlineRegTask.this.setUriEvent(uri);
+                MaintainBuyInkOnlineRegTask.this.setReady(true);
+            }
+        }.execute(new Void[0]);
+    }
+
+    public void loadData(final String str) {
+        final Application application = getApplication();
+        new AsyncTask<Void, Void, Uri>() {
+            /* access modifiers changed from: protected */
+            public void onPreExecute() {
+                super.onPreExecute();
+                MaintainBuyInkOnlineRegTask.this.setReady(false);
+            }
+
+            /* access modifiers changed from: protected */
+            public Uri doInBackground(Void... voidArr) {
+                MaintainActivity.disableSimpleApAndWait(application, str);
+                return Uri.parse(BuyInkUrl.urlSupport(application, CommonDefine.URL_ONLINE_REGISTRATION));
+            }
+
+            /* access modifiers changed from: protected */
+            public void onPostExecute(Uri uri) {
+                super.onPostExecute(uri);
+                MaintainBuyInkOnlineRegTask.this.setUriEvent(uri);
+                MaintainBuyInkOnlineRegTask.this.setReady(true);
+            }
+        }.execute(new Void[0]);
+    }
+}

+ 1312 - 0
app/src/main/java/epson/maintain/activity/MaintainPrinterSearchActivity.java

@@ -0,0 +1,1312 @@
+package epson.maintain.activity;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.support.p000v4.app.DialogFragment;
+import android.view.ContextMenu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.Button;
+import android.widget.ListView;
+import android.widget.ProgressBar;
+import android.widget.RadioButton;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+import com.epson.mobilephone.common.EpLog;
+import com.epson.mobilephone.common.ble.BleAsyncTask;
+import com.epson.mobilephone.common.ble.BleWork;
+import com.epson.mobilephone.common.ble.BleWorkActivity;
+import com.epson.mobilephone.common.ble.util.BLEUtility;
+import com.epson.mobilephone.common.ble.util.ScannedDevice;
+import com.epson.mobilephone.common.maintain2.MaintainPrinter2;
+import com.epson.mobilephone.common.wifidirect.ActivityRequestLocationPermission;
+import com.epson.mobilephone.common.wifidirect.ActivityWiFiDirectStart;
+import com.epson.mobilephone.common.wifidirect.ActivityiPrintConnect;
+import com.epson.mobilephone.common.wifidirect.SearchWiFiDirectPrinterTask;
+import com.epson.mobilephone.common.wifidirect.WiFiControl;
+import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
+import com.epson.mobilephone.common.wifidirect.WiFiDirectPrinterListUtils;
+import com.epson.mobilephone.common.wifidirect.WiFiNetworkManager;
+import com.epson.mobilephone.common.wifidirect.escprLib;
+import epson.common.Constants;
+import epson.common.ExternalFileUtils;
+import epson.common.Utils;
+import epson.print.ActivityIACommon;
+import epson.print.C2135R;
+import epson.print.CustomTitleDialogFragment;
+import epson.print.EPPrinterManager;
+import epson.print.MyPrinter;
+import epson.print.screen.ActivityPrinterSetting;
+import epson.print.screen.WorkingDialog;
+import epson.print.widgets.AbstractListBuilder;
+import epson.print.widgets.ListControlHelper;
+import epson.print.widgets.PrinterInfoBuilder;
+import epson.print.widgets.PrinterInfoECBuilder;
+import epson.print.widgets.PrinterInfoIpBuilder;
+import epson.scan.lib.escanLib;
+import java.util.ArrayList;
+import java.util.Locale;
+
+public class MaintainPrinterSearchActivity extends ActivityIACommon implements CustomTitleDialogFragment.Callback {
+    private static final int DELAY = 100;
+    private static final int DIALOG_ID_PRINTER_NOT_FOUND_WITH_WEB_GUIDANCE = 1;
+    private static final String DIALOG_TAG_PRINTER_NOT_FOUND = "printer_not_found_dialog";
+    private static final int EPS_PROTOCOL_ALL = 208;
+    private static final int EPS_PROTOCOL_LPR = 64;
+    private static final int EPS_PROTOCOL_NET = 192;
+    private static final int EPS_PROTOCOL_RAW = 128;
+    private static final int EPS_PROTOCOL_USB = 16;
+    private static final int Menu_Delete = 1;
+    private static final int Menu_Edit = 2;
+    private static final String TAG = "MaintainPrinterSearchActivity";
+    /* access modifiers changed from: private */
+    public static final Object mLock = new Object();
+    /* access modifiers changed from: private */
+    public static escanLib mScanner = new escanLib();
+    private final int BLE_SET_PRINTER = 15;
+    private final int CANCEL_FIND_PRINTER = 2;
+    private final int CONNECT_SIMPLEAP = 9;
+    private final int DELETE_PRINTER = 6;
+    private final int EDIT_IPPRINTER = 10;
+    private final int EDIT_PRINTER = 7;
+    private final int FINISH_FIND_PRINTER = 5;
+    private final int FOUND_SIMPLEAP = 8;
+    private final String PRINTER_COMMON_DEVICENAME = "common_devicename";
+    private final String PRINTER_ID = "id";
+    private final String PRINTER_INDEX = "index";
+    private final String PRINTER_IP = escprLib.PRINTER_IP;
+    private final String PRINTER_NAME = "name";
+    private final String PRINTER_SERIAL_NO = escprLib.PRINTER_SERIAL_NO;
+    private final int PROBE_PRINTER = 11;
+    private final int PROBE_SCANNER = 12;
+    private final int REQUEST_CODE_LOCATION_PERMISSION = 14;
+    private final int SEARCH_PRINTER = 1;
+    private final int SEARCH_PRINTER_P2P = 13;
+    private final int SELECT_PRINTER = 4;
+    private boolean bCheckWiFiStatus = false;
+    private boolean bRejectLocationPermission = false;
+    ListControlHelper helper = null;
+    /* access modifiers changed from: private */
+    public volatile boolean isFinishSearchPrinter = true;
+    /* access modifiers changed from: private */
+    public Boolean isFocused = true;
+    private boolean isJapaneseLocale = false;
+    /* access modifiers changed from: private */
+    public volatile boolean isSearchSimpleAp = false;
+    private AdapterView.AdapterContextMenuInfo listItemIndex;
+    View mAboutRemoteButton;
+    private boolean mActivityForegroundLifetime;
+    Button mAddButton;
+    /* access modifiers changed from: private */
+    public RelativeLayout mBleButton;
+    private BLEUtility.BleWorkCallback mBleFind = null;
+    AbstractListBuilder mBuilder;
+    /* access modifiers changed from: private */
+    public Context mContext = null;
+    /* access modifiers changed from: private */
+    public int mDeletePos = -1;
+    Handler mHandler = new Handler(new Handler.Callback() {
+        /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r8v46, resolved type: java.lang.Object} */
+        /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r2v19, resolved type: epson.print.MyPrinter} */
+        /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r8v55, resolved type: java.lang.Object} */
+        /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r2v26, resolved type: epson.print.MyPrinter} */
+        /* JADX WARNING: Multi-variable type inference failed */
+        /* Code decompiled incorrectly, please refer to instructions dump. */
+        public boolean handleMessage(android.os.Message r8) {
+            /*
+                r7 = this;
+                int r0 = r8.what
+                r1 = 8
+                r2 = 0
+                r3 = -1
+                r4 = 1
+                r5 = 0
+                switch(r0) {
+                    case 0: goto L_0x02c1;
+                    case 1: goto L_0x0292;
+                    case 2: goto L_0x028b;
+                    case 3: goto L_0x000b;
+                    case 4: goto L_0x0208;
+                    case 5: goto L_0x01fc;
+                    case 6: goto L_0x0149;
+                    case 7: goto L_0x0104;
+                    case 8: goto L_0x00bc;
+                    case 9: goto L_0x000b;
+                    case 10: goto L_0x0076;
+                    case 11: goto L_0x004d;
+                    case 12: goto L_0x0029;
+                    case 13: goto L_0x000d;
+                    default: goto L_0x000b;
+                }
+            L_0x000b:
+                goto L_0x0338
+            L_0x000d:
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                android.os.Handler r0 = r8.mHandler
+                r2 = 60
+                com.epson.mobilephone.common.wifidirect.SearchWiFiDirectPrinterTask r0 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.searchWiFiDirectPrinter(r8, r0, r1, r2)
+                com.epson.mobilephone.common.wifidirect.SearchWiFiDirectPrinterTask unused = r8.searchWiFiDirectPrinter = r0
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                com.epson.mobilephone.common.wifidirect.SearchWiFiDirectPrinterTask r8 = r8.searchWiFiDirectPrinter
+                if (r8 != 0) goto L_0x0338
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                boolean unused = r8.isSearchSimpleAp = r5
+                goto L_0x0338
+            L_0x0029:
+                java.lang.Object r8 = r8.obj
+                epson.print.MyPrinter r8 = (epson.print.MyPrinter) r8
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                boolean r0 = r0.isFinishSearchPrinter
+                if (r0 != 0) goto L_0x0041
+                java.lang.String r0 = "MaintainPrinterSearchActivity"
+                java.lang.String r1 = "cancelSearch for PROBE_SCANNER"
+                epson.print.Util.EPLog.m313i(r0, r1)
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                r0.interruptSearch()
+            L_0x0041:
+                epson.maintain.activity.MaintainPrinterSearchActivity$14$1 r0 = new epson.maintain.activity.MaintainPrinterSearchActivity$14$1
+                r0.<init>(r8)
+                java.lang.Void[] r8 = new java.lang.Void[r5]
+                r0.execute(r8)
+                goto L_0x0338
+            L_0x004d:
+                java.lang.Object r8 = r8.obj
+                epson.print.MyPrinter r8 = (epson.print.MyPrinter) r8
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                boolean r0 = r0.isFinishSearchPrinter
+                if (r0 != 0) goto L_0x0065
+                java.lang.String r0 = "MaintainPrinterSearchActivity"
+                java.lang.String r1 = "cancelSearch for PROBE_PRINTER"
+                epson.print.Util.EPLog.m313i(r0, r1)
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                r0.interruptSearch()
+            L_0x0065:
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                epson.maintain.activity.MaintainPrinterSearchActivity$14$2 r1 = new epson.maintain.activity.MaintainPrinterSearchActivity$14$2
+                r1.<init>(r8)
+                java.lang.Void[] r8 = new java.lang.Void[r5]
+                android.os.AsyncTask r8 = r1.execute(r8)
+                r0.probePrinterThread = r8
+                goto L_0x0338
+            L_0x0076:
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                r0.interruptSearch()
+                java.lang.Object r0 = r8.obj
+                if (r0 == 0) goto L_0x0084
+                java.lang.Object r8 = r8.obj
+                r2 = r8
+                epson.print.MyPrinter r2 = (epson.print.MyPrinter) r2
+            L_0x0084:
+                android.content.Intent r8 = new android.content.Intent
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                java.lang.Class<epson.print.screen.ActivityIpPrinterSetting> r1 = epson.print.screen.ActivityIpPrinterSetting.class
+                r8.<init>(r0, r1)
+                android.os.Bundle r0 = new android.os.Bundle
+                r0.<init>()
+                if (r2 == 0) goto L_0x00a4
+                java.lang.String r1 = r2.getPrinterId()
+                if (r1 == 0) goto L_0x00a4
+                java.lang.String r1 = "PRINTER_KEY"
+                java.lang.String r2 = r2.getPrinterId()
+                r0.putString(r1, r2)
+                goto L_0x00ab
+            L_0x00a4:
+                java.lang.String r1 = "PRINTER_KEY"
+                java.lang.String r2 = ""
+                r0.putString(r1, r2)
+            L_0x00ab:
+                epson.maintain.activity.MaintainPrinterSearchActivity r1 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                int unused = r1.mDeletePos = r3
+                r8.putExtras(r0)
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                r1 = 10
+                r0.startActivityForResult(r8, r1)
+                goto L_0x0338
+            L_0x00bc:
+                android.os.Bundle r8 = r8.getData()
+                if (r8 == 0) goto L_0x00ed
+                boolean r0 = r8.isEmpty()
+                if (r0 != 0) goto L_0x00ed
+                java.lang.String r0 = "ssid"
+                java.lang.String r0 = r8.getString(r0)
+                java.lang.String r1 = "name"
+                java.lang.String r1 = r8.getString(r1)
+                java.lang.String r2 = "addr_infra"
+                java.lang.String r8 = r8.getString(r2)
+                if (r1 != 0) goto L_0x00dd
+                r1 = r0
+            L_0x00dd:
+                epson.print.MyPrinter r2 = new epson.print.MyPrinter
+                java.lang.String r3 = ""
+                r2.<init>(r1, r0, r8, r3)
+                epson.maintain.activity.MaintainPrinterSearchActivity r1 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                com.epson.mobilephone.common.wifidirect.WiFiDirectPrinterListUtils r1 = r1.wiFiDirectPrinterListUtils
+                r1.addPrinter(r2, r5, r0, r8)
+                goto L_0x0338
+            L_0x00ed:
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                boolean unused = r8.isSearchSimpleAp = r5
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                boolean r8 = r8.isFinishSearchPrinter
+                if (r8 == 0) goto L_0x0338
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                android.os.Handler r8 = r8.mHandler
+                r0 = 5
+                r8.sendEmptyMessage(r0)
+                goto L_0x0338
+            L_0x0104:
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                r0.interruptSearch()
+                java.lang.Object r0 = r8.obj
+                if (r0 == 0) goto L_0x0112
+                java.lang.Object r8 = r8.obj
+                r2 = r8
+                epson.print.MyPrinter r2 = (epson.print.MyPrinter) r2
+            L_0x0112:
+                android.content.Intent r8 = new android.content.Intent
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                java.lang.Class<epson.print.screen.ActivityPrinterSetting> r1 = epson.print.screen.ActivityPrinterSetting.class
+                r8.<init>(r0, r1)
+                android.os.Bundle r0 = new android.os.Bundle
+                r0.<init>()
+                if (r2 == 0) goto L_0x0132
+                java.lang.String r1 = r2.getEmailAddress()
+                if (r1 == 0) goto L_0x0132
+                java.lang.String r1 = "PRINTER_EMAIL_ADDRESS"
+                java.lang.String r2 = r2.getEmailAddress()
+                r0.putString(r1, r2)
+                goto L_0x0139
+            L_0x0132:
+                java.lang.String r1 = "PRINTER_EMAIL_ADDRESS"
+                java.lang.String r2 = ""
+                r0.putString(r1, r2)
+            L_0x0139:
+                epson.maintain.activity.MaintainPrinterSearchActivity r1 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                int unused = r1.mDeletePos = r3
+                r8.putExtras(r0)
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                r1 = 7
+                r0.startActivityForResult(r8, r1)
+                goto L_0x0338
+            L_0x0149:
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                int r8 = r8.mDeletePos
+                if (r8 < 0) goto L_0x0338
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                int r8 = r8.printer_location
+                switch(r8) {
+                    case 2: goto L_0x019f;
+                    case 3: goto L_0x015c;
+                    default: goto L_0x015a;
+                }
+            L_0x015a:
+                goto L_0x01e1
+            L_0x015c:
+                epson.print.EPPrinterManager r8 = new epson.print.EPPrinterManager
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                android.content.Context r0 = r0.mContext
+                r8.<init>(r0)
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                epson.print.widgets.AbstractListBuilder r0 = r0.mBuilder
+                java.util.Vector r0 = r0.getData()
+                epson.maintain.activity.MaintainPrinterSearchActivity r2 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                int r2 = r2.mDeletePos
+                java.lang.Object r0 = r0.elementAt(r2)
+                epson.print.MyPrinter r0 = (epson.print.MyPrinter) r0
+                java.lang.String r0 = r0.getPrinterId()
+                r8.deleteIpPrinterInfo(r0)
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                epson.print.widgets.AbstractListBuilder r8 = r8.mBuilder
+                android.widget.BaseAdapter r8 = r8.getAdapter()
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                epson.print.widgets.AbstractListBuilder r0 = r0.mBuilder
+                java.util.Vector r0 = r0.getData()
+                epson.maintain.activity.MaintainPrinterSearchActivity r2 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                int r2 = r2.mDeletePos
+                r0.remove(r2)
+                r8.notifyDataSetChanged()
+                goto L_0x01e1
+            L_0x019f:
+                epson.print.EPPrinterManager r8 = new epson.print.EPPrinterManager
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                android.content.Context r0 = r0.mContext
+                r8.<init>(r0)
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                epson.print.widgets.AbstractListBuilder r0 = r0.mBuilder
+                java.util.Vector r0 = r0.getData()
+                epson.maintain.activity.MaintainPrinterSearchActivity r2 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                int r2 = r2.mDeletePos
+                java.lang.Object r0 = r0.elementAt(r2)
+                epson.print.MyPrinter r0 = (epson.print.MyPrinter) r0
+                java.lang.String r0 = r0.getEmailAddress()
+                r8.deleteRemotePrinterInfo(r0)
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                epson.print.widgets.AbstractListBuilder r8 = r8.mBuilder
+                android.widget.BaseAdapter r8 = r8.getAdapter()
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                epson.print.widgets.AbstractListBuilder r0 = r0.mBuilder
+                java.util.Vector r0 = r0.getData()
+                epson.maintain.activity.MaintainPrinterSearchActivity r2 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                int r2 = r2.mDeletePos
+                r0.remove(r2)
+                r8.notifyDataSetChanged()
+            L_0x01e1:
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                r8.displaySearchResult()
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                int r8 = r8.printer_location
+                if (r8 == r4) goto L_0x01f5
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                android.widget.Button r8 = r8.mSearchButton
+                r8.setVisibility(r1)
+            L_0x01f5:
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                int unused = r8.mDeletePos = r3
+                goto L_0x0338
+            L_0x01fc:
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                r8.interruptSearch()
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                r8.displaySearchResult()
+                goto L_0x0338
+            L_0x0208:
+                com.epson.mobilephone.common.ble.BleAsyncTask.blePrinterCheckStop()
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                boolean r0 = r0.isFinishSearchPrinter
+                if (r0 == 0) goto L_0x021b
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                boolean r0 = r0.isSearchSimpleAp
+                if (r0 == 0) goto L_0x0227
+            L_0x021b:
+                java.lang.String r0 = "MaintainPrinterSearchActivity"
+                java.lang.String r1 = "cancelSearch for SELECT_PRINTER"
+                epson.print.Util.EPLog.m313i(r0, r1)
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                r0.interruptSearch()
+            L_0x0227:
+                java.lang.Object r8 = r8.obj
+                epson.print.MyPrinter r8 = (epson.print.MyPrinter) r8
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                r8.setCurPrinter(r0)
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                android.content.Context r0 = r0.getApplicationContext()
+                java.lang.String r1 = "PrintSetting"
+                java.lang.String r2 = "RE_SEARCH"
+                epson.common.Utils.savePref((android.content.Context) r0, (java.lang.String) r1, (java.lang.String) r2, (boolean) r4)
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                int r0 = r0.printer_location
+                if (r0 != r4) goto L_0x0268
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                java.lang.String r1 = r8.getPrinterId()
+                java.lang.String r1 = com.epson.mobilephone.common.wifidirect.MacAddrUtils.getMacAddressFromPrinterId(r1)
+                java.lang.String r0 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.getCurConnectInfo(r0, r1)
+                if (r0 == 0) goto L_0x0261
+                epson.maintain.activity.MaintainPrinterSearchActivity r1 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                java.lang.String r2 = "printer"
+                java.lang.String r8 = r8.getName()
+                com.epson.mobilephone.common.wifidirect.WiFiDirectManager.setConnectInfo(r1, r0, r2, r8)
+                goto L_0x0268
+            L_0x0261:
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                java.lang.String r0 = "printer"
+                com.epson.mobilephone.common.wifidirect.WiFiDirectManager.resetConnectInfo(r8, r0)
+            L_0x0268:
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                int r8 = r8.printer_location
+                r0 = 2
+                if (r8 != r0) goto L_0x027a
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                epson.common.ExternalFileUtils r8 = epson.common.ExternalFileUtils.getInstance(r8)
+                r8.removeAreaInfo()
+            L_0x027a:
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                r8.commitEPPrinterInfo()
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                r8.setResult(r4)
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                r8.finish()
+                goto L_0x0338
+            L_0x028b:
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                r8.interruptSearch()
+                goto L_0x0338
+            L_0x0292:
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                int r8 = r8.printer_location
+                if (r8 == r4) goto L_0x029c
+                goto L_0x0338
+            L_0x029c:
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                android.os.AsyncTask<java.lang.Void, java.lang.Void, java.lang.Integer> r8 = r8.probePrinterThread
+                if (r8 == 0) goto L_0x02bb
+                android.os.AsyncTask$Status r8 = android.os.AsyncTask.Status.RUNNING
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                android.os.AsyncTask<java.lang.Void, java.lang.Void, java.lang.Integer> r0 = r0.probePrinterThread
+                android.os.AsyncTask$Status r0 = r0.getStatus()
+                boolean r8 = r8.equals(r0)
+                if (r8 == 0) goto L_0x02bb
+                java.lang.String r8 = "MaintainPrinterSearchActivity"
+                java.lang.String r0 = "Cancel serch. probePrinterThread is running."
+                epson.print.Util.EPLog.m305d(r8, r0)
+                goto L_0x0338
+            L_0x02bb:
+                epson.maintain.activity.MaintainPrinterSearchActivity r8 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                r8.search()
+                goto L_0x0338
+            L_0x02c1:
+                android.os.Bundle r8 = r8.getData()
+                java.lang.String r0 = "name"
+                java.lang.String r0 = r8.getString(r0)
+                if (r0 == 0) goto L_0x0338
+                java.lang.String r0 = "ip"
+                java.lang.String r0 = r8.getString(r0)
+                if (r0 == 0) goto L_0x0338
+                java.lang.String r0 = "id"
+                java.lang.String r0 = r8.getString(r0)
+                if (r0 == 0) goto L_0x0338
+                java.lang.String r0 = "common_devicename"
+                java.lang.String r0 = r8.getString(r0)
+                java.lang.StringBuilder r1 = new java.lang.StringBuilder
+                r1.<init>()
+                java.lang.String r2 = "commonDeviceName = "
+                r1.append(r2)
+                r1.append(r0)
+                java.lang.String r1 = r1.toString()
+                com.epson.mobilephone.common.EpLog.m69d(r1)
+                epson.print.MyPrinter r1 = new epson.print.MyPrinter
+                java.lang.String r2 = "name"
+                java.lang.String r2 = r8.getString(r2)
+                java.lang.String r3 = "ip"
+                java.lang.String r3 = r8.getString(r3)
+                java.lang.String r4 = "id"
+                java.lang.String r4 = r8.getString(r4)
+                java.lang.String r6 = "serial_no"
+                java.lang.String r6 = r8.getString(r6)
+                r1.<init>(r2, r3, r4, r6)
+                r1.setCommonDeviceName(r0)
+                epson.maintain.activity.MaintainPrinterSearchActivity r0 = epson.maintain.activity.MaintainPrinterSearchActivity.this
+                com.epson.mobilephone.common.wifidirect.WiFiDirectPrinterListUtils r0 = r0.wiFiDirectPrinterListUtils
+                java.lang.String r2 = "index"
+                java.lang.String r8 = r8.getString(r2)
+                java.lang.Integer r8 = java.lang.Integer.valueOf(r8)
+                int r8 = r8.intValue()
+                java.lang.String r2 = r1.getIp()
+                java.lang.String r3 = r1.getPrinterId()
+                java.lang.String r3 = com.epson.mobilephone.common.wifidirect.MacAddrUtils.getMacAddressFromPrinterId(r3)
+                r0.addPrinter(r1, r8, r2, r3)
+            L_0x0338:
+                return r5
+            */
+            throw new UnsupportedOperationException("Method not decompiled: epson.maintain.activity.MaintainPrinterSearchActivity.C203814.handleMessage(android.os.Message):boolean");
+        }
+    });
+    RadioButton mIpButton;
+    boolean mIsClickSelect = false;
+    ViewGroup mLayout;
+    private TextView mListEmptyMessageTextView;
+    /* access modifiers changed from: private */
+    public ListView mListView;
+    RadioButton mLocalButton;
+    /* access modifiers changed from: private */
+    public MaintainPrinter2 mPrinter = MaintainPrinter2.getInstance();
+    ProgressBar mProgressBar;
+    RadioButton mRemoteButton;
+    Button mSearchButton;
+    private Thread mSearchThread;
+    TextView mTextDetail;
+    View mWiFiSettingButton;
+    private String printerEmailAddress = "";
+    private String printerId = "";
+    private String printerKey = "";
+    /* access modifiers changed from: private */
+    public volatile int printer_location = 0;
+    AsyncTask<Void, Void, Integer> probePrinterThread = null;
+    WorkingDialog progress;
+    /* access modifiers changed from: private */
+    public SearchWiFiDirectPrinterTask searchWiFiDirectPrinter = null;
+    WiFiDirectPrinterListUtils wiFiDirectPrinterListUtils = null;
+
+    public void onLocalNegativeCallback(int i) {
+    }
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        if (Locale.getDefault().getLanguage().equalsIgnoreCase(Locale.JAPAN.getLanguage()) || Locale.getDefault().getLanguage().equalsIgnoreCase(Locale.JAPANESE.getLanguage())) {
+            this.isJapaneseLocale = true;
+        } else {
+            this.isJapaneseLocale = false;
+        }
+        this.mLayout = (ViewGroup) getLayoutInflater().inflate(C2135R.layout.search_printer_layout, (ViewGroup) null);
+        addWiFiSetupButton();
+        addAboutRemoteButton();
+        this.mListEmptyMessageTextView = (TextView) this.mLayout.findViewById(C2135R.C2137id.list_empty_message);
+        this.mListView = (ListView) this.mLayout.findViewById(16908298);
+        init();
+        setContentView((View) this.mLayout);
+        this.mContext = this;
+        this.mIsClickSelect = false;
+        if (this.printer_location != 1) {
+            displaySearchResult();
+            this.mSearchButton.setVisibility(8);
+            ((TextView) this.mLayout.findViewById(C2135R.C2137id.empty)).setVisibility(8);
+        }
+        setNotFoundPrinterButton();
+        setBleWifiSetupButton();
+        setActionBar((int) C2135R.string.title_addprint, true);
+        requestLocationPermission();
+    }
+
+    private void init() {
+        MyPrinter curPrinter = MyPrinter.getCurPrinter(this);
+        this.printer_location = curPrinter.getLocation();
+        if (this.printer_location == 0) {
+            this.printer_location = 1;
+        }
+        switch (this.printer_location) {
+            case 2:
+                this.printerEmailAddress = curPrinter.getEmailAddress();
+                break;
+            case 3:
+                this.printerKey = curPrinter.getPrinterId();
+                break;
+            default:
+                this.printerId = curPrinter.getPrinterId();
+                break;
+        }
+        buildElements();
+    }
+
+    private void requestLocationPermission() {
+        if (!this.bRejectLocationPermission && !ActivityRequestLocationPermission.canAccessWiFiInfo(this, 20)) {
+            if (BleWork.isStartBleProcess(this, false)) {
+                ActivityRequestLocationPermission.requestLocationPermission((Activity) this, 14);
+            } else if (Build.VERSION.SDK_INT > 28 && !WiFiNetworkManager.getInsetance(this).isWiFiValidated()) {
+                ActivityRequestLocationPermission.requestLocationPermissionForce(this, 14);
+            }
+        }
+    }
+
+    private void setBleWifiSetupButton() {
+        this.mBleButton = (RelativeLayout) this.mLayout.findViewById(C2135R.C2137id.ble_wifi_setting);
+        this.mBleButton.setVisibility(8);
+        this.mBleButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                MaintainPrinterSearchActivity.this.interruptSearch();
+                BleAsyncTask.blePrinterCheckStop();
+                Intent intent = new Intent(MaintainPrinterSearchActivity.this.getApplicationContext(), BleWorkActivity.class);
+                intent.putParcelableArrayListExtra(ScannedDevice.TYPE, (ArrayList) MaintainPrinterSearchActivity.this.mBleButton.getTag());
+                MaintainPrinterSearchActivity.this.startActivityForResult(intent, 15);
+            }
+        });
+    }
+
+    private void setNotFoundPrinterButton() {
+        this.mLayout.findViewById(C2135R.C2137id.not_found_printer_epsonsn).setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                MaintainPrinterSearchActivity maintainPrinterSearchActivity = MaintainPrinterSearchActivity.this;
+                maintainPrinterSearchActivity.startActivity(PrinterNotFoundDialogCreator.getStartIntent(maintainPrinterSearchActivity.getApplicationContext()));
+            }
+        });
+    }
+
+    /* access modifiers changed from: package-private */
+    public void addWiFiSetupButton() {
+        this.mWiFiSettingButton = this.mLayout.findViewById(C2135R.C2137id.rlWifiSettings);
+        if (this.isJapaneseLocale) {
+            ((TextView) this.mWiFiSettingButton).setText(C2135R.string.str_goto_wifidirect_settings);
+        } else {
+            ((TextView) this.mWiFiSettingButton).setText(C2135R.string.str_wifidirect_settings);
+        }
+        this.mWiFiSettingButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                MaintainPrinterSearchActivity.this.startWifiPrinterSelect();
+            }
+        });
+    }
+
+    /* access modifiers changed from: private */
+    public void startWifiPrinterSelect() {
+        startActivityForResult(new Intent(this, ActivityWiFiDirectStart.class), 9);
+    }
+
+    /* access modifiers changed from: package-private */
+    public void addAboutRemoteButton() {
+        this.mAboutRemoteButton = this.mLayout.findViewById(C2135R.C2137id.AboutRemoteFrame);
+        this.mAboutRemoteButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                MaintainPrinterSearchActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("https://www.epsonconnect.com/iguide/")));
+            }
+        });
+    }
+
+    /* access modifiers changed from: private */
+    public void buildElements() {
+        this.mSearchButton = (Button) this.mLayout.findViewById(C2135R.C2137id.function_button);
+        this.mProgressBar = (ProgressBar) this.mLayout.findViewById(C2135R.C2137id.progress_bar);
+        this.mAddButton = (Button) this.mLayout.findViewById(C2135R.C2137id.edit_button);
+        this.mTextDetail = (TextView) this.mLayout.findViewById(C2135R.C2137id.detail);
+        searchButtonSetEnabled(false);
+        this.mProgressBar.setVisibility(0);
+        this.mAddButton.setVisibility(8);
+        this.mTextDetail.setVisibility(0);
+        this.mWiFiSettingButton.setVisibility(0);
+        this.mLocalButton = (RadioButton) this.mLayout.findViewById(C2135R.C2137id.btn_local);
+        this.mIpButton = (RadioButton) this.mLayout.findViewById(C2135R.C2137id.btn_ip);
+        this.mRemoteButton = (RadioButton) this.mLayout.findViewById(C2135R.C2137id.btn_remote);
+        Utils.setDrawble2TextView(this, this.mLocalButton, C2135R.C2136drawable.printer_selector_icon_local);
+        Utils.setDrawble2TextView(this, this.mIpButton, C2135R.C2136drawable.printer_selector_icon_ip);
+        Utils.setDrawble2TextView(this, this.mRemoteButton, C2135R.C2136drawable.printer_selector_icon_remote);
+        TextView textView = null;
+        switch (this.printer_location) {
+            case 1:
+                this.mListView.setEmptyView((View) null);
+                this.mListEmptyMessageTextView.setText((CharSequence) null);
+                this.mListEmptyMessageTextView.setVisibility(8);
+                this.mBuilder = new PrinterInfoBuilder(getBaseContext(), this.mLayout, 0);
+                String connectInfo = WiFiDirectManager.getConnectInfo(this, WiFiDirectManager.DEVICE_TYPE_PRINTER);
+                this.mBuilder.setResource(WiFiDirectPrinterListUtils.getCurPrinterString(this, this.printerId, connectInfo));
+                this.helper = new ListControlHelper((PrinterInfoBuilder) this.mBuilder);
+                this.wiFiDirectPrinterListUtils = new WiFiDirectPrinterListUtils(this, this.mBuilder.getData(), this.helper, connectInfo);
+                this.mLocalButton.setChecked(true);
+                this.mTextDetail.setText(C2135R.string.str_detailtext_local);
+                this.mLayout.findViewById(C2135R.C2137id.not_found_printer_epsonsn).setVisibility(0);
+                RelativeLayout relativeLayout = this.mBleButton;
+                if (!(relativeLayout == null || relativeLayout.getTag() == null)) {
+                    this.mBleButton.setVisibility(0);
+                    break;
+                }
+            case 2:
+                this.mAddButton.setVisibility(0);
+                this.mListEmptyMessageTextView.setText(C2135R.string.printer_list_empty_message);
+                textView = this.mListEmptyMessageTextView;
+                this.mBuilder = new PrinterInfoECBuilder(getBaseContext(), this.mLayout);
+                this.mBuilder.setResource(this.printerEmailAddress);
+                this.mRemoteButton.setChecked(true);
+                this.mTextDetail.setText(C2135R.string.str_detailtext_remote);
+                this.mSearchButton.setVisibility(8);
+                this.mWiFiSettingButton.setVisibility(8);
+                this.mLayout.findViewById(C2135R.C2137id.not_found_printer_epsonsn).setVisibility(8);
+                RelativeLayout relativeLayout2 = this.mBleButton;
+                if (relativeLayout2 != null) {
+                    relativeLayout2.setVisibility(8);
+                    break;
+                }
+                break;
+            case 3:
+                this.mAddButton.setVisibility(0);
+                this.mListEmptyMessageTextView.setText(C2135R.string.printer_list_empty_message);
+                textView = this.mListEmptyMessageTextView;
+                this.mBuilder = new PrinterInfoIpBuilder(getBaseContext(), this.mLayout, 0);
+                this.mBuilder.setResource(this.printerKey);
+                this.mIpButton.setChecked(true);
+                this.mTextDetail.setText(C2135R.string.str_detailtext_ip);
+                this.mSearchButton.setVisibility(8);
+                this.mWiFiSettingButton.setVisibility(8);
+                this.mLayout.findViewById(C2135R.C2137id.not_found_printer_epsonsn).setVisibility(8);
+                RelativeLayout relativeLayout3 = this.mBleButton;
+                if (relativeLayout3 != null) {
+                    relativeLayout3.setVisibility(8);
+                    break;
+                }
+                break;
+        }
+        this.mBuilder.build();
+        this.mBuilder.refresh();
+        this.mListView.setEmptyView(textView);
+        if (this.printer_location == 2) {
+            this.mAboutRemoteButton.setVisibility(0);
+        } else {
+            this.mAboutRemoteButton.setVisibility(8);
+        }
+        this.mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+            public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
+                if (MaintainPrinterSearchActivity.this.isFocused.booleanValue()) {
+                    Boolean unused = MaintainPrinterSearchActivity.this.isFocused = false;
+                    MaintainPrinterSearchActivity maintainPrinterSearchActivity = MaintainPrinterSearchActivity.this;
+                    maintainPrinterSearchActivity.mIsClickSelect = true;
+                    Message obtainMessage = maintainPrinterSearchActivity.mHandler.obtainMessage();
+                    obtainMessage.obj = MaintainPrinterSearchActivity.this.mBuilder.getData().elementAt(i);
+                    int access$400 = MaintainPrinterSearchActivity.this.printer_location;
+                    if (access$400 == 1) {
+                        String ip = ((MyPrinter) obtainMessage.obj).getIp();
+                        if (!WiFiControl.ConnectType.NONE.equals(WiFiDirectManager.getConnectType(MaintainPrinterSearchActivity.this, ip))) {
+                            MaintainPrinterSearchActivity.this.interruptSearch();
+                            WiFiDirectManager.connect(MaintainPrinterSearchActivity.this, ip, 9);
+                        } else {
+                            obtainMessage.what = 11;
+                        }
+                    } else if (access$400 != 3) {
+                        obtainMessage.what = 4;
+                    } else {
+                        obtainMessage.what = 11;
+                    }
+                    BleAsyncTask.blePrinterCheckStop();
+                    MaintainPrinterSearchActivity.this.mHandler.sendMessageDelayed(obtainMessage, 100);
+                }
+            }
+        });
+        this.mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
+            public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long j) {
+                if (MaintainPrinterSearchActivity.this.printer_location == 1) {
+                    return true;
+                }
+                int unused = MaintainPrinterSearchActivity.this.mDeletePos = i;
+                MaintainPrinterSearchActivity maintainPrinterSearchActivity = MaintainPrinterSearchActivity.this;
+                maintainPrinterSearchActivity.registerForContextMenu(maintainPrinterSearchActivity.mListView);
+                return false;
+            }
+        });
+        this.mAddButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                switch (MaintainPrinterSearchActivity.this.printer_location) {
+                    case 2:
+                        if (MaintainPrinterSearchActivity.this.mBuilder.getData().size() >= 32) {
+                            new AlertDialog.Builder(MaintainPrinterSearchActivity.this.mContext).setCancelable(false).setTitle(MaintainPrinterSearchActivity.this.getString(C2135R.string.epsonconnect_err_regist_remote_printer_max_size_title)).setMessage(MaintainPrinterSearchActivity.this.getString(C2135R.string.epsonconnect_err_regist_remote_printer_max_size)).setPositiveButton(MaintainPrinterSearchActivity.this.getString(C2135R.string.str_yes), new DialogInterface.OnClickListener() {
+                                public void onClick(DialogInterface dialogInterface, int i) {
+                                }
+                            }).show();
+                            return;
+                        } else if (MaintainPrinterSearchActivity.this.getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).getBoolean(Constants.ENABLE_SHOW_WARNING, true)) {
+                            AlertDialog.Builder cancelable = new AlertDialog.Builder(MaintainPrinterSearchActivity.this.mContext).setCancelable(false);
+                            cancelable.setMessage(MaintainPrinterSearchActivity.this.getString(C2135R.string.epsonconnect_str_remote_print_warning) + "\n\n" + MaintainPrinterSearchActivity.this.getString(C2135R.string.epsonconnect_str_remote_print_warning2)).setPositiveButton(MaintainPrinterSearchActivity.this.getString(C2135R.string.str_yes), new DialogInterface.OnClickListener() {
+                                public void onClick(DialogInterface dialogInterface, int i) {
+                                    Message message = new Message();
+                                    message.what = 7;
+                                    message.obj = null;
+                                    MaintainPrinterSearchActivity.this.mHandler.sendMessage(message);
+                                }
+                            }).setNegativeButton(MaintainPrinterSearchActivity.this.getString(C2135R.string.str_no), new DialogInterface.OnClickListener() {
+                                public void onClick(DialogInterface dialogInterface, int i) {
+                                }
+                            }).show();
+                            return;
+                        } else {
+                            Message message = new Message();
+                            message.what = 7;
+                            message.obj = null;
+                            MaintainPrinterSearchActivity.this.mHandler.sendMessage(message);
+                            return;
+                        }
+                    case 3:
+                        if (MaintainPrinterSearchActivity.this.mBuilder.getData().size() >= 32) {
+                            new AlertDialog.Builder(MaintainPrinterSearchActivity.this.mContext).setCancelable(false).setTitle(MaintainPrinterSearchActivity.this.getString(C2135R.string.epsonconnect_err_regist_remote_printer_max_size_title)).setMessage(MaintainPrinterSearchActivity.this.getString(C2135R.string.epsonconnect_err_regist_remote_printer_max_size)).setPositiveButton(MaintainPrinterSearchActivity.this.getString(C2135R.string.str_yes), new DialogInterface.OnClickListener() {
+                                public void onClick(DialogInterface dialogInterface, int i) {
+                                }
+                            }).show();
+                            return;
+                        }
+                        Message message2 = new Message();
+                        message2.what = 10;
+                        message2.obj = null;
+                        MaintainPrinterSearchActivity.this.mHandler.sendMessage(message2);
+                        return;
+                    default:
+                        return;
+                }
+            }
+        });
+        this.mSearchButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                if (MaintainPrinterSearchActivity.this.printer_location == 1) {
+                    MaintainPrinterSearchActivity.this.mHandler.sendEmptyMessageDelayed(1, 100);
+                }
+            }
+        });
+        this.mLocalButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                if (MaintainPrinterSearchActivity.this.printer_location != 1) {
+                    MaintainPrinterSearchActivity.this.mAddButton.setVisibility(8);
+                    ((TextView) MaintainPrinterSearchActivity.this.mLayout.findViewById(C2135R.C2137id.empty)).setVisibility(0);
+                    MaintainPrinterSearchActivity.this.interruptSearch();
+                    int unused = MaintainPrinterSearchActivity.this.printer_location = 1;
+                    MaintainPrinterSearchActivity.this.buildElements();
+                    MaintainPrinterSearchActivity.this.mHandler.sendEmptyMessageDelayed(1, 100);
+                }
+            }
+        });
+        this.mRemoteButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                if (MaintainPrinterSearchActivity.this.printer_location != 2) {
+                    int unused = MaintainPrinterSearchActivity.this.printer_location = 2;
+                    MaintainPrinterSearchActivity.this.interruptSearch();
+                    ((TextView) MaintainPrinterSearchActivity.this.mLayout.findViewById(C2135R.C2137id.empty)).setVisibility(8);
+                    MaintainPrinterSearchActivity.this.mBuilder.refresh();
+                    MaintainPrinterSearchActivity.this.buildElements();
+                    MaintainPrinterSearchActivity.this.displaySearchResult();
+                    MaintainPrinterSearchActivity.this.mSearchButton.setVisibility(8);
+                }
+            }
+        });
+        this.mIpButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                if (MaintainPrinterSearchActivity.this.printer_location != 3) {
+                    int unused = MaintainPrinterSearchActivity.this.printer_location = 3;
+                    MaintainPrinterSearchActivity.this.interruptSearch();
+                    ((TextView) MaintainPrinterSearchActivity.this.mLayout.findViewById(C2135R.C2137id.empty)).setVisibility(8);
+                    MaintainPrinterSearchActivity.this.mBuilder.refresh();
+                    MaintainPrinterSearchActivity.this.buildElements();
+                    MaintainPrinterSearchActivity.this.displaySearchResult();
+                    MaintainPrinterSearchActivity.this.mSearchButton.setVisibility(8);
+                }
+            }
+        });
+    }
+
+    public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) {
+        super.onCreateContextMenu(contextMenu, view, contextMenuInfo);
+        contextMenu.setHeaderTitle(C2135R.string.str_edit_bookmark);
+        contextMenu.add(0, 1, 0, C2135R.string.str_delete);
+        contextMenu.add(0, 2, 0, C2135R.string.str_edit_bookmark);
+    }
+
+    public boolean onContextItemSelected(MenuItem menuItem) {
+        this.listItemIndex = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
+        if (this.listItemIndex == null) {
+            return true;
+        }
+        switch (menuItem.getItemId()) {
+            case 1:
+                new AlertDialog.Builder(this.mContext).setCancelable(false).setTitle(getString(C2135R.string.delete_file)).setIcon(getResources().getDrawable(C2135R.C2136drawable.delete_file)).setNegativeButton(getString(C2135R.string.str_ok), new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialogInterface, int i) {
+                        Message obtainMessage = MaintainPrinterSearchActivity.this.mHandler.obtainMessage();
+                        obtainMessage.what = 6;
+                        MaintainPrinterSearchActivity.this.mHandler.sendMessageDelayed(obtainMessage, 100);
+                    }
+                }).setPositiveButton(getString(C2135R.string.str_cancel), new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialogInterface, int i) {
+                    }
+                }).show();
+                break;
+            case 2:
+                Message message = new Message();
+                switch (this.printer_location) {
+                    case 2:
+                        message.what = 7;
+                        break;
+                    case 3:
+                        message.what = 10;
+                        break;
+                }
+                message.obj = this.mBuilder.getData().elementAt(this.mDeletePos);
+                this.mHandler.sendMessage(message);
+                break;
+        }
+        return true;
+    }
+
+    /* access modifiers changed from: protected */
+    public void onDestroy() {
+        this.mBuilder.destructor();
+        super.onDestroy();
+    }
+
+    public void onBackPressed() {
+        super.onBackPressed();
+        EPPrinterManager ePPrinterManager = new EPPrinterManager(this.mContext);
+        ePPrinterManager.rollbackRemotePrinterInfo();
+        ePPrinterManager.rollbackIPPrinterInfo();
+        finish();
+    }
+
+    /* access modifiers changed from: protected */
+    public void onResume() {
+        this.mActivityForegroundLifetime = true;
+        super.onResume();
+        EpLog.m78i(TAG, "onResume()");
+        dismissPrinterNotFoundDialog();
+        if (this.printer_location == 1) {
+            this.mHandler.sendEmptyMessageDelayed(1, 300);
+            EpLog.m70d(TAG, "Send CHECK_PRINTER Message.");
+        }
+        if (this.printer_location == 1 && this.mBleButton.getTag() == null && BleWork.isStartBleProcess(this, false)) {
+            EpLog.m71e("blePrinterCheck");
+            callBackFuncs();
+            BleAsyncTask.blePrinterCheck(this, this.mBleFind);
+        }
+    }
+
+    /* access modifiers changed from: protected */
+    public void onPause() {
+        EpLog.m76i();
+        super.onPause();
+        this.mActivityForegroundLifetime = false;
+        interruptSearch();
+        BleAsyncTask.blePrinterCheckStop();
+        removeAllDialog();
+    }
+
+    /* access modifiers changed from: protected */
+    public void onStart() {
+        super.onStart();
+    }
+
+    /* access modifiers changed from: protected */
+    public void onStop() {
+        EpLog.m76i();
+        super.onStop();
+    }
+
+    /* access modifiers changed from: protected */
+    public void onActivityResult(int i, int i2, Intent intent) {
+        super.onActivityResult(i, i2, intent);
+        interruptSearch();
+        switch (i) {
+            case 7:
+                if (i2 == -1) {
+                    ((MyPrinter) intent.getParcelableExtra(ActivityPrinterSetting.KEY_MYPRINTER)).setCurPrinter(this);
+                    commitEPPrinterInfo();
+                    ExternalFileUtils.getInstance(this).removeAreaInfo();
+                    setResult(1);
+                    finish();
+                    return;
+                }
+                return;
+            case 9:
+                if (i2 == -1) {
+                    MyPrinter myPrinter = new MyPrinter(intent.getStringExtra("name"), intent.getStringExtra(escprLib.PRINTER_IP), intent.getStringExtra("id"), intent.getStringExtra(escprLib.PRINTER_SERIAL_NO));
+                    Message obtainMessage = this.mHandler.obtainMessage();
+                    obtainMessage.what = 11;
+                    obtainMessage.obj = myPrinter;
+                    this.mHandler.sendMessage(obtainMessage);
+                    intent.getBooleanExtra(ActivityiPrintConnect.FINISH_EAYSETUP, false);
+                    return;
+                }
+                this.isFocused = true;
+                this.mIsClickSelect = false;
+                return;
+            case 10:
+                if (i2 == -1) {
+                    MyPrinter myPrinter2 = new MyPrinter(intent.getStringExtra(Constants.PRINTER_NAME), intent.getStringExtra(Constants.PRINTER_IP), intent.getStringExtra(Constants.PRINTER_ID), intent.getStringExtra(Constants.PRINTER_SERIAL_NO), "", 3);
+                    myPrinter2.setScannerId(intent.getStringExtra(Constants.SCAN_REFS_SCANNER_ID));
+                    Message obtainMessage2 = this.mHandler.obtainMessage();
+                    obtainMessage2.what = 11;
+                    obtainMessage2.obj = myPrinter2;
+                    this.mHandler.sendMessage(obtainMessage2);
+                    return;
+                }
+                return;
+            case 14:
+                if (i2 != -1) {
+                    this.bRejectLocationPermission = true;
+                    return;
+                }
+                return;
+            case 15:
+                EpLog.m76i();
+                finish();
+                return;
+            default:
+                return;
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void search() {
+        interruptSearch();
+        synchronized (mLock) {
+            this.mBuilder.refresh();
+            this.wiFiDirectPrinterListUtils.clearPrinterInfoList();
+        }
+        this.mIsClickSelect = false;
+        this.isFinishSearchPrinter = false;
+        searchButtonSetEnabled(false);
+        this.mProgressBar.setVisibility(0);
+        ((TextView) this.mLayout.findViewById(C2135R.C2137id.empty)).setText(getString(C2135R.string.searching_text));
+        this.isFocused = true;
+        if (WiFiDirectManager.getCurSSID(this) != null) {
+            this.mHandler.sendEmptyMessageDelayed(13, 5000);
+            this.isSearchSimpleAp = true;
+        } else if (WiFiDirectManager.isWifiEnabled(this)) {
+            this.mHandler.sendEmptyMessage(13);
+            this.isSearchSimpleAp = true;
+        } else {
+            boolean z = this.bCheckWiFiStatus;
+            if (!z && !z) {
+                this.bCheckWiFiStatus = true;
+                WiFiDirectManager.enableWiFi(this, -1);
+                return;
+            }
+        }
+        WiFiDirectManager.setPriorityToSimpleAP(this, true);
+        this.mPrinter.getMEscpLib().setHanlder(this.mHandler);
+        this.mSearchThread = new Thread() {
+            public void run() {
+                synchronized (MaintainPrinterSearchActivity.mLock) {
+                    boolean unused = MaintainPrinterSearchActivity.this.isFinishSearchPrinter = false;
+                }
+                MaintainPrinterSearchActivity.this.mPrinter.doFindPrinter(MaintainPrinterSearchActivity.EPS_PROTOCOL_ALL, 60);
+                if (!MaintainPrinterSearchActivity.this.isFinishSearchPrinter) {
+                    synchronized (MaintainPrinterSearchActivity.mLock) {
+                        boolean unused2 = MaintainPrinterSearchActivity.this.isFinishSearchPrinter = true;
+                        if (!MaintainPrinterSearchActivity.this.isSearchSimpleAp) {
+                            MaintainPrinterSearchActivity.this.mHandler.sendEmptyMessage(5);
+                        }
+                    }
+                }
+            }
+        };
+        this.mSearchThread.start();
+    }
+
+    /* access modifiers changed from: private */
+    /* JADX WARNING: Code restructure failed: missing block: B:12:0x003b, code lost:
+        r6.mPrinter.doCancelFindPrinter();
+        r0 = r6.mSearchThread;
+     */
+    /* JADX WARNING: Code restructure failed: missing block: B:13:0x0042, code lost:
+        if (r0 == null) goto L_0x0098;
+     */
+    /* JADX WARNING: Code restructure failed: missing block: B:15:0x0048, code lost:
+        if (r0.isAlive() == false) goto L_0x0098;
+     */
+    /* JADX WARNING: Code restructure failed: missing block: B:16:0x004a, code lost:
+        r6.mSearchThread.interrupt();
+     */
+    /* JADX WARNING: Code restructure failed: missing block: B:18:?, code lost:
+        epson.print.Util.EPLog.m305d(TAG, "mSearchThread.join() enter");
+        r6.mSearchThread.join(1000);
+     */
+    /* JADX WARNING: Code restructure failed: missing block: B:20:0x0069, code lost:
+        if (java.lang.Thread.State.RUNNABLE.equals(r6.mSearchThread.getState()) == false) goto L_0x008c;
+     */
+    /* JADX WARNING: Code restructure failed: missing block: B:21:0x006b, code lost:
+        r0 = r2 + 1;
+     */
+    /* JADX WARNING: Code restructure failed: missing block: B:22:0x006f, code lost:
+        if (r2 <= 60) goto L_0x0079;
+     */
+    /* JADX WARNING: Code restructure failed: missing block: B:23:0x0071, code lost:
+        epson.print.Util.EPLog.m318w(TAG, "mSearchThread.join() timeout");
+     */
+    /* JADX WARNING: Code restructure failed: missing block: B:24:0x0079, code lost:
+        epson.print.Util.EPLog.m305d(TAG, "retry doCancelFindPrinter()");
+        r6.mPrinter.doCancelFindPrinter();
+        r6.mSearchThread.join(1000);
+        r2 = r0;
+     */
+    /* JADX WARNING: Code restructure failed: missing block: B:25:0x008c, code lost:
+        epson.print.Util.EPLog.m305d(TAG, "mSearchThread.join() leave");
+     */
+    /* JADX WARNING: Code restructure failed: missing block: B:26:0x0094, code lost:
+        r0 = move-exception;
+     */
+    /* JADX WARNING: Code restructure failed: missing block: B:27:0x0095, code lost:
+        r0.printStackTrace();
+     */
+    /* Code decompiled incorrectly, please refer to instructions dump. */
+    public void interruptSearch() {
+        /*
+            r6 = this;
+            java.lang.String r0 = "MaintainPrinterSearchActivity"
+            java.lang.String r1 = "interruptSearch()"
+            epson.print.Util.EPLog.m305d(r0, r1)
+            android.os.Handler r0 = r6.mHandler
+            r1 = 1
+            r0.removeMessages(r1)
+            android.os.Handler r0 = r6.mHandler
+            r2 = 13
+            r0.removeMessages(r2)
+            android.os.Handler r0 = r6.mHandler
+            r2 = 0
+            r0.removeMessages(r2)
+            android.os.Handler r0 = r6.mHandler
+            r3 = 8
+            r0.removeMessages(r3)
+            java.lang.Object r0 = mLock
+            monitor-enter(r0)
+            com.epson.mobilephone.common.wifidirect.SearchWiFiDirectPrinterTask r4 = r6.searchWiFiDirectPrinter     // Catch:{ all -> 0x009e }
+            if (r4 == 0) goto L_0x0030
+            com.epson.mobilephone.common.wifidirect.SearchWiFiDirectPrinterTask r4 = r6.searchWiFiDirectPrinter     // Catch:{ all -> 0x009e }
+            r4.interrupt()     // Catch:{ all -> 0x009e }
+            r4 = 0
+            r6.searchWiFiDirectPrinter = r4     // Catch:{ all -> 0x009e }
+        L_0x0030:
+            r6.isSearchSimpleAp = r2     // Catch:{ all -> 0x009e }
+            boolean r4 = r6.isFinishSearchPrinter     // Catch:{ all -> 0x009e }
+            if (r4 != r1) goto L_0x0038
+            monitor-exit(r0)     // Catch:{ all -> 0x009e }
+            return
+        L_0x0038:
+            r6.isFinishSearchPrinter = r1     // Catch:{ all -> 0x009e }
+            monitor-exit(r0)     // Catch:{ all -> 0x009e }
+            com.epson.mobilephone.common.maintain2.MaintainPrinter2 r0 = r6.mPrinter
+            r0.doCancelFindPrinter()
+            java.lang.Thread r0 = r6.mSearchThread
+            if (r0 == 0) goto L_0x0098
+            boolean r0 = r0.isAlive()
+            if (r0 == 0) goto L_0x0098
+            java.lang.Thread r0 = r6.mSearchThread
+            r0.interrupt()
+            java.lang.String r0 = "MaintainPrinterSearchActivity"
+            java.lang.String r1 = "mSearchThread.join() enter"
+            epson.print.Util.EPLog.m305d(r0, r1)     // Catch:{ InterruptedException -> 0x0094 }
+            java.lang.Thread r0 = r6.mSearchThread     // Catch:{ InterruptedException -> 0x0094 }
+            r4 = 1000(0x3e8, double:4.94E-321)
+            r0.join(r4)     // Catch:{ InterruptedException -> 0x0094 }
+        L_0x005d:
+            java.lang.Thread$State r0 = java.lang.Thread.State.RUNNABLE     // Catch:{ InterruptedException -> 0x0094 }
+            java.lang.Thread r1 = r6.mSearchThread     // Catch:{ InterruptedException -> 0x0094 }
+            java.lang.Thread$State r1 = r1.getState()     // Catch:{ InterruptedException -> 0x0094 }
+            boolean r0 = r0.equals(r1)     // Catch:{ InterruptedException -> 0x0094 }
+            if (r0 == 0) goto L_0x008c
+            int r0 = r2 + 1
+            r1 = 60
+            if (r2 <= r1) goto L_0x0079
+            java.lang.String r0 = "MaintainPrinterSearchActivity"
+            java.lang.String r1 = "mSearchThread.join() timeout"
+            epson.print.Util.EPLog.m318w((java.lang.String) r0, (java.lang.String) r1)     // Catch:{ InterruptedException -> 0x0094 }
+            goto L_0x008c
+        L_0x0079:
+            java.lang.String r1 = "MaintainPrinterSearchActivity"
+            java.lang.String r2 = "retry doCancelFindPrinter()"
+            epson.print.Util.EPLog.m305d(r1, r2)     // Catch:{ InterruptedException -> 0x0094 }
+            com.epson.mobilephone.common.maintain2.MaintainPrinter2 r1 = r6.mPrinter     // Catch:{ InterruptedException -> 0x0094 }
+            r1.doCancelFindPrinter()     // Catch:{ InterruptedException -> 0x0094 }
+            java.lang.Thread r1 = r6.mSearchThread     // Catch:{ InterruptedException -> 0x0094 }
+            r1.join(r4)     // Catch:{ InterruptedException -> 0x0094 }
+            r2 = r0
+            goto L_0x005d
+        L_0x008c:
+            java.lang.String r0 = "MaintainPrinterSearchActivity"
+            java.lang.String r1 = "mSearchThread.join() leave"
+            epson.print.Util.EPLog.m305d(r0, r1)     // Catch:{ InterruptedException -> 0x0094 }
+            goto L_0x0098
+        L_0x0094:
+            r0 = move-exception
+            r0.printStackTrace()
+        L_0x0098:
+            android.widget.ProgressBar r0 = r6.mProgressBar
+            r0.setVisibility(r3)
+            return
+        L_0x009e:
+            r1 = move-exception
+            monitor-exit(r0)     // Catch:{ all -> 0x009e }
+            throw r1
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.maintain.activity.MaintainPrinterSearchActivity.interruptSearch():void");
+    }
+
+    public void displaySearchResult() {
+        if (!this.mIsClickSelect) {
+            boolean z = false;
+            if (this.mBuilder.getData().size() <= 0) {
+                ((TextView) this.mLayout.findViewById(C2135R.C2137id.empty)).setText(C2135R.string.str_printer_search_result_none);
+                if (this.printer_location == 1 && this.mActivityForegroundLifetime) {
+                    if (WiFiDirectManager.getCurSSID(this) == null) {
+                        z = true;
+                    }
+                    PrinterNotFoundDialogCreator.getPrinterNotFoundDialog(this, z, 1).show(getSupportFragmentManager(), DIALOG_TAG_PRINTER_NOT_FOUND);
+                }
+            } else if (Locale.getDefault().getLanguage().equalsIgnoreCase(Locale.JAPAN.getLanguage()) || Locale.getDefault().getLanguage().equalsIgnoreCase(Locale.JAPANESE.getLanguage())) {
+                ((TextView) this.mLayout.findViewById(C2135R.C2137id.empty)).setText(getString(C2135R.string.numberOfPrintersAvailable));
+            } else {
+                ((TextView) this.mLayout.findViewById(C2135R.C2137id.empty)).setText(String.format(getString(C2135R.string.numberOfPrintersAvailable), new Object[]{Integer.valueOf(this.mBuilder.getData().size())}));
+            }
+        }
+        this.mProgressBar.setVisibility(8);
+        searchButtonSetEnabled(true);
+    }
+
+    /* access modifiers changed from: protected */
+    public Dialog onCreateDialog(int i) {
+        String str;
+        Dialog onCreateDialog = super.onCreateDialog(i);
+        if (i != C2135R.string.EPS_ERR_PRINTER_NOT_FOUND_RESEARCH) {
+            switch (i) {
+                case C2135R.string.EPS_PRNERR_COMM1 /*2131624360*/:
+                    return Utils.makeMessageBox(this, getString(C2135R.string.EPS_ERR_PRINTER_NOT_FOUND_TITLE), getString(i), getString(C2135R.string.str_ok));
+                case C2135R.string.EPS_PRNERR_COMM1_NOWIFI /*2131624361*/:
+                    return Utils.makeMessageBox(this, getString(C2135R.string.EPS_ERR_PRINTER_NOT_FOUND_TITLE), getString(C2135R.string.EPS_PRNERR_COMM1_NOWIFI), getString(C2135R.string.str_ok));
+                default:
+                    return onCreateDialog;
+            }
+        } else {
+            String string = getString(i);
+            String ssid = Utils.getSSID(this);
+            if (!Utils.isConnectedWifi(this) || ssid == null) {
+                str = getString(C2135R.string.EPS_PRNERR_COMM4);
+            } else {
+                str = String.format(string, new Object[]{ssid});
+            }
+            return Utils.makeMessageBox(this, getString(C2135R.string.EPS_ERR_PRINTER_NOT_FOUND_TITLE), str, getString(C2135R.string.str_ok));
+        }
+    }
+
+    private void dismissPrinterNotFoundDialog() {
+        DialogFragment dialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(DIALOG_TAG_PRINTER_NOT_FOUND);
+        if (dialogFragment != null) {
+            dialogFragment.dismiss();
+        }
+    }
+
+    /* access modifiers changed from: package-private */
+    /* JADX WARNING: Failed to process nested try/catch */
+    /* JADX WARNING: Missing exception handler attribute for start block: B:11:0x0012 */
+    /* Code decompiled incorrectly, please refer to instructions dump. */
+    public void removeAllDialog() {
+        /*
+            r1 = this;
+            r0 = 2131624360(0x7f0e01a8, float:1.8875898E38)
+            r1.removeDialog(r0)     // Catch:{ IllegalArgumentException -> 0x0006 }
+        L_0x0006:
+            r0 = 2131624125(0x7f0e00bd, float:1.887542E38)
+            r1.removeDialog(r0)     // Catch:{ IllegalArgumentException -> 0x000c }
+        L_0x000c:
+            r0 = 2131624361(0x7f0e01a9, float:1.88759E38)
+            r1.removeDialog(r0)     // Catch:{ IllegalArgumentException -> 0x0012 }
+        L_0x0012:
+            r1.dismissPrinterNotFoundDialog()     // Catch:{ Exception -> 0x0015 }
+        L_0x0015:
+            return
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.maintain.activity.MaintainPrinterSearchActivity.removeAllDialog():void");
+    }
+
+    public void searchButtonSetEnabled(boolean z) {
+        this.mSearchButton.setVisibility(0);
+        if (z) {
+            this.mSearchButton.setEnabled(true);
+        } else {
+            this.mSearchButton.setEnabled(false);
+        }
+    }
+
+    /* access modifiers changed from: package-private */
+    public void commitEPPrinterInfo() {
+        EPPrinterManager ePPrinterManager = new EPPrinterManager(this.mContext);
+        ePPrinterManager.commitIPPrinterInfo();
+        ePPrinterManager.commitRemotePrinterInfo();
+    }
+
+    public void onLocalPositiveCallback(int i) {
+        if (i == 1) {
+            startActivity(PrinterNotFoundDialogCreator.getStartIntent(this));
+        }
+    }
+
+    private void callBackFuncs() {
+        this.mBleFind = new BLEUtility.BleWorkCallback() {
+            public void call(Object obj) {
+                ArrayList arrayList = (ArrayList) obj;
+                EpLog.m69d(" ★★ mDevicelist " + arrayList.size());
+                if (MaintainPrinterSearchActivity.this.printer_location == 1) {
+                    MaintainPrinterSearchActivity.this.mBleButton.setVisibility(0);
+                }
+                MaintainPrinterSearchActivity.this.mBleButton.setTag(arrayList);
+            }
+        };
+    }
+}

+ 47 - 0
app/src/main/java/epson/maintain/activity/NozzleGuidanceDialog.java

@@ -0,0 +1,47 @@
+package epson.maintain.activity;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.support.p000v4.app.DialogFragment;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import epson.print.C2135R;
+
+public class NozzleGuidanceDialog extends DialogFragment {
+    public Dialog onCreateDialog(Bundle bundle) {
+        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+        View inflate = getActivity().getLayoutInflater().inflate(C2135R.layout.dialog_nozzle_check_guidance, (ViewGroup) null);
+        ((Button) inflate.findViewById(C2135R.C2137id.close_button)).setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                NozzleGuidanceDialog.this.dismiss();
+            }
+        });
+        ((Button) inflate.findViewById(C2135R.C2137id.browse_button)).setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                NozzleGuidanceDialog.this.startBrowser();
+                NozzleGuidanceDialog.this.dismiss();
+            }
+        });
+        builder.setView(inflate);
+        AlertDialog create = builder.create();
+        create.setCanceledOnTouchOutside(false);
+        create.setOnKeyListener(new DialogInterface.OnKeyListener() {
+            public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
+                return keyEvent.getKeyCode() == 84;
+            }
+        });
+        return create;
+    }
+
+    /* access modifiers changed from: private */
+    public void startBrowser() {
+        MaintainActivity maintainActivity = (MaintainActivity) getActivity();
+        if (maintainActivity != null) {
+            maintainActivity.startBrowseNozzleCheckGuidance();
+        }
+    }
+}

+ 31 - 0
app/src/main/java/epson/maintain/activity/PrinterNotFoundDialogCreator.java

@@ -0,0 +1,31 @@
+package epson.maintain.activity;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import epson.common.Utils;
+import epson.print.C2135R;
+import epson.print.CommonDefine;
+import epson.print.CustomLayoutDialogFragment;
+
+public class PrinterNotFoundDialogCreator {
+    public static CustomLayoutDialogFragment getPrinterNotFoundDialog(Context context, boolean z, int i) {
+        String str;
+        if (z) {
+            str = context.getString(C2135R.string.EPS_PRNERR_COMM1_NOWIFI);
+        } else if (Utils.getPrefBoolean(context, "PrintSetting", CommonDefine.RE_SEARCH)) {
+            String ssid = Utils.getSSID(context);
+            if (!Utils.isConnectedWifi(context) || ssid == null) {
+                return CustomLayoutDialogFragment.newInstance(i, context.getString(C2135R.string.EPS_PRNERR_COMM4), (int) C2135R.string.EPS_ERR_PRINTER_NOT_FOUND_TITLE, 0, (int) C2135R.string.str_btn_close);
+            }
+            str = context.getString(C2135R.string.EPS_ERR_PRINTER_NOT_FOUND_RESEARCH2, new Object[]{ssid});
+        } else {
+            str = context.getString(C2135R.string.EPS_PRNERR_COMM1);
+        }
+        return CustomLayoutDialogFragment.newInstance(i, str + "\n\n" + context.getString(C2135R.string.confirm_browse_wlan_setup_info), (int) C2135R.string.EPS_ERR_PRINTER_NOT_FOUND_TITLE, (int) C2135R.string.browse_site, (int) C2135R.string.str_btn_close);
+    }
+
+    public static Intent getStartIntent(Context context) {
+        return new Intent("android.intent.action.VIEW", Uri.parse(context.getString(C2135R.string.printer_not_found_guidance_url)));
+    }
+}

+ 1 - 1
app/src/main/java/epson/print/storage/ConfirmCancelDialog.java

@@ -6,7 +6,7 @@ import android.os.Bundle;
 
 import android.support.p000v4.app.DialogFragment;
 import android.support.p000v4.app.FragmentActivity;
-import android.support.p003v7.app.AlertDialog;
+
 
 
 

+ 72 - 0
app/src/main/java/epson/provider/IAFileProvider.java

@@ -0,0 +1,72 @@
+package epson.provider;
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.pm.ProviderInfo;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.ParcelFileDescriptor;
+import android.support.p000v4.content.FileProvider;
+import java.io.File;
+import java.io.FileNotFoundException;
+
+public abstract class IAFileProvider extends FileProvider {
+    private static String mAuthority;
+
+    public boolean onCreate() {
+        return true;
+    }
+
+    public void attachInfo(Context context, ProviderInfo providerInfo) {
+        super.attachInfo(context, providerInfo);
+        mAuthority = providerInfo.authority;
+    }
+
+    public ParcelFileDescriptor openFile(Uri uri, String str) throws FileNotFoundException {
+        if (checkUriPath(uri)) {
+            return super.openFile(uri, str);
+        }
+        throw new FileNotFoundException();
+    }
+
+    public static Uri getUriForFile(Context context, File file) throws FileNotFoundException {
+        return getUriForFile(context, mAuthority, file);
+    }
+
+    public String getType(Uri uri) {
+        if (!checkUriPath(uri)) {
+            return null;
+        }
+        return super.getType(uri);
+    }
+
+    public Cursor query(Uri uri, String[] strArr, String str, String[] strArr2, String str2) {
+        if (!checkUriPath(uri)) {
+            return null;
+        }
+        return super.query(uri, strArr, str, strArr2, str2);
+    }
+
+    static boolean checkUriPath(Uri uri) {
+        if (uri == null) {
+            return true;
+        }
+        String path = uri.getPath();
+        if (path.contains("/../") || path.endsWith("/..")) {
+            return false;
+        }
+        return true;
+    }
+
+    public Uri insert(Uri uri, ContentValues contentValues) {
+        throw new UnsupportedOperationException("No external insert");
+    }
+
+    public int delete(Uri uri, String str, String[] strArr) {
+        throw new UnsupportedOperationException("No external delete");
+    }
+
+    public int update(Uri uri, ContentValues contentValues, String str, String[] strArr) {
+        throw new UnsupportedOperationException("No external updates");
+    }
+}

+ 4 - 0
app/src/main/java/epson/provider/ScannedFileProvider.java

@@ -0,0 +1,4 @@
+package epson.provider;
+
+public class ScannedFileProvider extends IAFileProvider {
+}

+ 414 - 0
app/src/main/java/epson/provider/SharedPreferencesProvider.java

@@ -0,0 +1,414 @@
+package epson.provider;
+
+import android.app.ActivityManager;
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.UriMatcher;
+import android.database.Cursor;
+import android.database.MatrixCursor;
+import android.net.Uri;
+import android.os.Binder;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import com.box.androidsdk.content.requests.BoxRequestsMetadata;
+import com.epson.iprint.prtlogger.AnalyticsPreferences;
+import com.epson.mobilephone.common.EpLog;
+import com.google.android.gms.actions.SearchIntents;
+import epson.print.IprintApplication;
+import epson.print.Util.EPLog;
+import java.util.Map;
+
+public class SharedPreferencesProvider extends ContentProvider {
+    private static final String ANALYTICS = "analytics";
+    public static Uri BASE_URI = null;
+    private static final String BOOLEAN_TYPE = "boolean";
+    private static final String FLOAT_TYPE = "float";
+    private static final String INT_TYPE = "integer";
+    private static final String KEY = "key";
+    private static final String LONG_TYPE = "long";
+    private static final int MATCH_DATA = 65536;
+    private static final int MATCH_DATA_ANALYTICS = 65537;
+    public static String PREFFERENCE_AUTHORITY = "epson.print.provider.SharedPreferences";
+    private static final String STRING_TYPE = "string";
+    private static final String TYPE = "type";
+    private static final String mAuthorizationPackageName = "epson.print:remote";
+    private static final String mAuthorizationPackageName2 = "epson.print";
+    /* access modifiers changed from: private */
+    public static SharedPreferences mPrefs;
+    private static UriMatcher matcher;
+    String TAG = "SharedPreferencesProvider";
+
+    private static void init(Context context) {
+        matcher = new UriMatcher(-1);
+        matcher.addURI(PREFFERENCE_AUTHORITY, "analytics/*/*", 65537);
+        matcher.addURI(PREFFERENCE_AUTHORITY, "*/*", 65536);
+        BASE_URI = Uri.parse("content://" + PREFFERENCE_AUTHORITY);
+    }
+
+    public boolean onCreate() {
+        String str = this.TAG;
+        EPLog.m305d(str, "onCreate " + Binder.getCallingPid() + ", " + Thread.currentThread().getName());
+        mPrefs = getContext().getSharedPreferences("PrintSetting", 0);
+        if (matcher != null) {
+            return true;
+        }
+        init(getContext());
+        return true;
+    }
+
+    @Nullable
+    public Cursor query(@NonNull Uri uri, @Nullable String[] strArr, @Nullable String str, @Nullable String[] strArr2, @Nullable String str2) {
+        Object obj;
+        if (uri == null || uri.getPathSegments() == null) {
+            EPLog.m306e(SearchIntents.EXTRA_QUERY);
+            throw new UnsupportedOperationException("");
+        } else if (matcher.match(uri) != 65536) {
+            MatrixCursor matrixCursor = new MatrixCursor(new String[]{KEY, BoxRequestsMetadata.UpdateItemMetadata.BoxMetadataUpdateTask.VALUE});
+            Map<String, ?> all = mPrefs.getAll();
+            for (String next : all.keySet()) {
+                matrixCursor.addRow(new Object[]{next, all.get(next)});
+            }
+            return matrixCursor;
+        } else {
+            String str3 = uri.getPathSegments().get(0);
+            String str4 = uri.getPathSegments().get(1);
+            MatrixCursor matrixCursor2 = new MatrixCursor(new String[]{str3});
+            if (!mPrefs.contains(str3)) {
+                return matrixCursor2;
+            }
+            MatrixCursor.RowBuilder newRow = matrixCursor2.newRow();
+            if (STRING_TYPE.equals(str4)) {
+                obj = mPrefs.getString(str3, (String) null);
+            } else if (BOOLEAN_TYPE.equals(str4)) {
+                obj = Integer.valueOf(mPrefs.getBoolean(str3, false) ? 1 : 0);
+            } else if (LONG_TYPE.equals(str4)) {
+                obj = Long.valueOf(mPrefs.getLong(str3, 0));
+            } else if (INT_TYPE.equals(str4)) {
+                obj = Integer.valueOf(mPrefs.getInt(str3, 0));
+            } else if (FLOAT_TYPE.equals(str4)) {
+                obj = Float.valueOf(mPrefs.getFloat(str3, 0.0f));
+            } else {
+                throw new IllegalArgumentException("Unsupported type " + uri);
+            }
+            newRow.add(obj);
+            return matrixCursor2;
+        }
+    }
+
+    @Nullable
+    private String getPackageNameFromPid(int i) {
+        for (ActivityManager.RunningAppProcessInfo next : ((ActivityManager) getContext().getSystemService("activity")).getRunningAppProcesses()) {
+            if (next.pid == i) {
+                return next.processName;
+            }
+        }
+        return null;
+    }
+
+    private static String getPackageName(int i) {
+        for (ActivityManager.RunningAppProcessInfo next : ((ActivityManager) IprintApplication.getInstance().getSystemService("activity")).getRunningAppProcesses()) {
+            if (next.pid == i) {
+                return next.processName;
+            }
+        }
+        return null;
+    }
+
+    private void checkPermission(int i) {
+        String packageNameFromPid = getPackageNameFromPid(i);
+        if (mAuthorizationPackageName.equals(packageNameFromPid) || "epson.print".equals(packageNameFromPid)) {
+            EPLog.m312i("Access OK !!: from " + packageNameFromPid);
+            return;
+        }
+        EPLog.m312i("Bad access !! : from " + packageNameFromPid);
+        throw new SecurityException();
+    }
+
+    public static boolean checkPackageUseSharedPreferencesProvider(Context context) {
+        String packageName = getPackageName(Binder.getCallingPid());
+        if (context != null) {
+            EPLog.m304d("★ PrintSetting from " + context.toString());
+        }
+        if (!mAuthorizationPackageName.equals(packageName)) {
+            return context != null && context.toString().contains("EpsonService");
+        }
+        return true;
+    }
+
+    public Uri insert(Uri uri, ContentValues contentValues) {
+        SharedPreferences.Editor editor;
+        EpLog.m77i("ContentValues     #######         " + contentValues);
+        checkPermission(Binder.getCallingPid());
+        switch (matcher.match(uri)) {
+            case 65536:
+                editor = mPrefs.edit();
+                EpLog.m77i(" !!!!!!!!    MATCH_DATA        !!!!!!!!!!!");
+                break;
+            case 65537:
+                editor = getContext().getSharedPreferences(AnalyticsPreferences.PREFS_NAME, 0).edit();
+                EpLog.m77i(" !!!!!!!!    MATCH_DATA_ANALYTICS        !!!!!!!!!!!");
+                break;
+            default:
+                throw new IllegalArgumentException("Unsupported uri " + uri);
+        }
+        switch (matcher.match(uri)) {
+            case 65536:
+            case 65537:
+                for (Map.Entry next : contentValues.valueSet()) {
+                    Object value = next.getValue();
+                    String str = (String) next.getKey();
+                    if (value == null) {
+                        editor.remove(str);
+                    } else if (value instanceof String) {
+                        editor.putString(str, (String) value);
+                    } else if (value instanceof Boolean) {
+                        editor.putBoolean(str, ((Boolean) value).booleanValue());
+                    } else if (value instanceof Long) {
+                        editor.putLong(str, ((Long) value).longValue());
+                    } else if (value instanceof Integer) {
+                        editor.putInt(str, ((Integer) value).intValue());
+                    } else if (value instanceof Float) {
+                        editor.putFloat(str, ((Float) value).floatValue());
+                    } else {
+                        throw new IllegalArgumentException("Unsupported type " + uri);
+                    }
+                }
+                editor.apply();
+                return null;
+            default:
+                throw new IllegalArgumentException("Unsupported uri " + uri);
+        }
+    }
+
+    public int update(@NonNull Uri uri, @NonNull ContentValues contentValues, @Nullable String str, @Nullable String[] strArr) {
+        EPLog.m312i("★★    update   ");
+        checkPermission(Binder.getCallingPid());
+        SharedPreferences.Editor edit = mPrefs.edit();
+        for (Map.Entry next : contentValues.valueSet()) {
+            String str2 = (String) next.getKey();
+            Object value = next.getValue();
+            if (value instanceof Integer) {
+                edit.putInt(str2, ((Integer) next.getValue()).intValue());
+            } else if (value instanceof Boolean) {
+                edit.putBoolean(str2, ((Boolean) next.getValue()).booleanValue());
+            } else {
+                EPLog.m306e("★ " + value.toString());
+            }
+        }
+        edit.apply();
+        return contentValues.size();
+    }
+
+    public int delete(@NonNull Uri uri, @NonNull String str, @Nullable String[] strArr) {
+        checkPermission(Binder.getCallingPid());
+        if (matcher.match(uri) == 65536) {
+            mPrefs.edit().clear().apply();
+            return 0;
+        }
+        throw new IllegalArgumentException("Unsupported uri " + uri);
+    }
+
+    @Nullable
+    public String getType(@NonNull Uri uri) {
+        throw new UnsupportedOperationException();
+    }
+
+    /* access modifiers changed from: private */
+    public static String getStringValue(Cursor cursor, String str) {
+        if (cursor == null) {
+            return str;
+        }
+        if (cursor.moveToFirst()) {
+            str = cursor.getString(0);
+        }
+        cursor.close();
+        return str;
+    }
+
+    /* access modifiers changed from: private */
+    public static boolean getBooleanValue(Cursor cursor, boolean z) {
+        if (cursor == null) {
+            return z;
+        }
+        if (cursor.moveToFirst()) {
+            z = false;
+            if (cursor.getInt(0) > 0) {
+                z = true;
+            }
+        }
+        cursor.close();
+        return z;
+    }
+
+    /* access modifiers changed from: private */
+    public static int getIntValue(Cursor cursor, int i) {
+        if (cursor == null) {
+            return i;
+        }
+        if (cursor.moveToFirst()) {
+            i = cursor.getInt(0);
+        }
+        cursor.close();
+        return i;
+    }
+
+    /* access modifiers changed from: private */
+    public static long getLongValue(Cursor cursor, long j) {
+        if (cursor == null) {
+            return j;
+        }
+        if (cursor.moveToFirst()) {
+            j = cursor.getLong(0);
+        }
+        cursor.close();
+        return j;
+    }
+
+    /* access modifiers changed from: private */
+    public static float getFloatValue(Cursor cursor, float f) {
+        if (cursor == null) {
+            return f;
+        }
+        if (cursor.moveToFirst()) {
+            f = cursor.getFloat(0);
+        }
+        cursor.close();
+        return f;
+    }
+
+    @NonNull
+    public static Editor edit(Context context) {
+        return new Editor(context);
+    }
+
+    @NonNull
+    public static SharedPreferencesMulti getInstace(Context context) {
+        mPrefs = context.getSharedPreferences("PrintSetting", 0);
+        return new SharedPreferencesMulti(context);
+    }
+
+    @NonNull
+    public static SharedPreferencesMulti getInstace(Context context, String str) {
+        mPrefs = context.getSharedPreferences(str, 0);
+        return new SharedPreferencesMulti(context);
+    }
+
+    public static class Editor {
+        Context context;
+        SharedPreferences.Editor editor;
+        private ContentValues values;
+
+        private Editor(Context context2) {
+            this.values = new ContentValues();
+            this.context = context2;
+            this.editor = SharedPreferencesProvider.mPrefs.edit();
+        }
+
+        public void apply() {
+            this.context.getContentResolver().insert(SharedPreferencesProvider.getContentUri(this.context, SharedPreferencesProvider.KEY, "type"), this.values);
+        }
+
+        public void apply(String str) {
+            if (((str.hashCode() == 829777079 && str.equals(AnalyticsPreferences.PREFS_NAME)) ? (char) 0 : 65535) == 0) {
+                this.context.getContentResolver().insert(SharedPreferencesProvider.getContentUri(this.context, SharedPreferencesProvider.ANALYTICS), this.values);
+                return;
+            }
+            throw new IllegalArgumentException("Unknown preference!" + str);
+        }
+
+        public void commit() {
+            apply();
+        }
+
+        public Editor putString(String str, String str2) {
+            this.values.put(str, str2);
+            return this;
+        }
+
+        public Editor putLong(String str, long j) {
+            this.values.put(str, Long.valueOf(j));
+            return this;
+        }
+
+        public Editor putBoolean(String str, boolean z) {
+            this.values.put(str, Boolean.valueOf(z));
+            return this;
+        }
+
+        public Editor putInt(String str, int i) {
+            this.values.put(str, Integer.valueOf(i));
+            return this;
+        }
+
+        public Editor putFloat(String str, float f) {
+            this.values.put(str, Float.valueOf(f));
+            return this;
+        }
+
+        public void remove(String str) {
+            this.values.putNull(str);
+        }
+
+        public void clear() {
+            if (SharedPreferencesProvider.checkPackageUseSharedPreferencesProvider(this.context)) {
+                this.context.getContentResolver().delete(SharedPreferencesProvider.getContentUri(this.context, SharedPreferencesProvider.KEY, "type"), (String) null, (String[]) null);
+            } else {
+                this.editor.clear();
+            }
+        }
+    }
+
+    public static class SharedPreferencesMulti {
+        private Context context;
+
+        private SharedPreferencesMulti(Context context2) {
+            this.context = context2;
+        }
+
+        public Editor edit() {
+            return new Editor(this.context);
+        }
+
+        public String getString(String str, String str2) {
+            return SharedPreferencesProvider.getStringValue(this.context.getContentResolver().query(SharedPreferencesProvider.getContentUri(this.context, str, SharedPreferencesProvider.STRING_TYPE), (String[]) null, (String) null, (String[]) null, (String) null), str2);
+        }
+
+        public long getLong(String str, long j) {
+            return SharedPreferencesProvider.getLongValue(this.context.getContentResolver().query(SharedPreferencesProvider.getContentUri(this.context, str, SharedPreferencesProvider.LONG_TYPE), (String[]) null, (String) null, (String[]) null, (String) null), j);
+        }
+
+        public float getFloat(String str, float f) {
+            return SharedPreferencesProvider.getFloatValue(this.context.getContentResolver().query(SharedPreferencesProvider.getContentUri(this.context, str, SharedPreferencesProvider.FLOAT_TYPE), (String[]) null, (String) null, (String[]) null, (String) null), f);
+        }
+
+        public boolean getBoolean(String str, boolean z) {
+            return SharedPreferencesProvider.getBooleanValue(this.context.getContentResolver().query(SharedPreferencesProvider.getContentUri(this.context, str, SharedPreferencesProvider.BOOLEAN_TYPE), (String[]) null, (String) null, (String[]) null, (String) null), z);
+        }
+
+        public int getInt(String str, int i) {
+            return SharedPreferencesProvider.getIntValue(this.context.getContentResolver().query(SharedPreferencesProvider.getContentUri(this.context, str, SharedPreferencesProvider.INT_TYPE), (String[]) null, (String) null, (String[]) null, (String) null), i);
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public static final Uri getContentUri(Context context, String str, String str2) {
+        if (BASE_URI == null) {
+            init(context);
+        }
+        Uri build = BASE_URI.buildUpon().appendPath(str).appendPath(str2).build();
+        EpLog.m69d("URI = " + build.toString());
+        return build;
+    }
+
+    /* access modifiers changed from: private */
+    public static final Uri getContentUri(Context context, String str) {
+        if (BASE_URI == null) {
+            init(context);
+        }
+        Uri build = BASE_URI.buildUpon().appendPath(str).appendPath(str).appendPath(str).build();
+        EpLog.m69d("URI = " + build.toString());
+        return build;
+    }
+}

+ 16 - 0
app/src/main/java/epson/scan/activity/$$Lambda$ScanContinueParam$O5_W7A8WVuIPQG0HgQ75RE2hUc.java

@@ -0,0 +1,16 @@
+package epson.scan.activity;
+
+import android.content.DialogInterface;
+
+/* renamed from: epson.scan.activity.-$$Lambda$ScanContinueParam$O5-_W7A8WVuIPQG0HgQ75RE2hUc  reason: invalid class name */
+/* compiled from: lambda */
+public final /* synthetic */ class $$Lambda$ScanContinueParam$O5_W7A8WVuIPQG0HgQ75RE2hUc implements DialogInterface.OnShowListener {
+    public static final /* synthetic */ $$Lambda$ScanContinueParam$O5_W7A8WVuIPQG0HgQ75RE2hUc INSTANCE = new $$Lambda$ScanContinueParam$O5_W7A8WVuIPQG0HgQ75RE2hUc();
+
+    private /* synthetic */ $$Lambda$ScanContinueParam$O5_W7A8WVuIPQG0HgQ75RE2hUc() {
+    }
+
+    public final void onShow(DialogInterface dialogInterface) {
+        ScanContinueParam.lambda$judgeScanContinue$0(dialogInterface);
+    }
+}

+ 61 - 0
app/src/main/java/epson/scan/activity/CustomButtonWrapper.java

@@ -0,0 +1,61 @@
+package epson.scan.activity;
+
+import android.content.res.Resources;
+import android.graphics.Color;
+import android.graphics.PorterDuff;
+import android.graphics.drawable.Drawable;
+import android.os.Build;
+import android.support.annotation.DrawableRes;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.view.View;
+import android.widget.Button;
+
+public class CustomButtonWrapper {
+    private final Button mButton;
+    private final int mDrawableId;
+
+    public CustomButtonWrapper(@NonNull Button button, @DrawableRes int i) {
+        this.mButton = button;
+        this.mButton.setText("");
+        this.mDrawableId = i;
+        setEnabled(this.mButton.isEnabled());
+    }
+
+    public void setEnabled(boolean z) {
+        setScanButtonState(this.mButton, this.mDrawableId, 0, z);
+    }
+
+    public void setOnClickListener(View.OnClickListener onClickListener) {
+        this.mButton.setOnClickListener(onClickListener);
+    }
+
+    public void setVisibility(int i) {
+        this.mButton.setVisibility(i);
+    }
+
+    public static void setScanButtonState(@NonNull Button button, @DrawableRes int i, int i2, boolean z) {
+        Drawable localGetDrawable = localGetDrawable(button.getResources(), i);
+        if (localGetDrawable != null) {
+            if (z) {
+                localGetDrawable.setColorFilter(-1, PorterDuff.Mode.MULTIPLY);
+            } else {
+                localGetDrawable.setColorFilter(Color.parseColor("#cccccc"), PorterDuff.Mode.SRC_IN);
+            }
+            button.setCompoundDrawablesWithIntrinsicBounds((Drawable) null, (Drawable) null, (Drawable) null, localGetDrawable);
+            button.setText("");
+            button.setEnabled(z);
+        }
+    }
+
+    @Nullable
+    public static Drawable localGetDrawable(Resources resources, @DrawableRes int i) {
+        if (resources == null) {
+            return null;
+        }
+        if (Build.VERSION.SDK_INT >= 21) {
+            return resources.getDrawable(i, (Resources.Theme) null);
+        }
+        return resources.getDrawable(i);
+    }
+}

+ 175 - 0
app/src/main/java/epson/scan/activity/DisplayIdConverter.java

@@ -0,0 +1,175 @@
+package epson.scan.activity;
+
+import android.content.Context;
+import com.epson.lib.escani2.EscanI2Lib;
+import com.epson.lib.escani2.ScanSize;
+import com.epson.mobilephone.common.PrintingLib.define.Constants;
+import epson.print.C2135R;
+import epson.scan.lib.ScanSizeHelper;
+
+public class DisplayIdConverter {
+    public static int getYesNoStringId(Context context, boolean z) {
+        return z ? C2135R.string.str_yes : C2135R.string.str_no;
+    }
+
+    public static int getColorStringId(EscanI2Lib.ColorMode colorMode) {
+        switch (colorMode) {
+            case COLOR_24BIT:
+                return C2135R.string.str_settings_color_color;
+            case GRAYSCALE_8BIT:
+                return C2135R.string.str_settings_color_grayscale;
+            case MONO_1BIT:
+                return C2135R.string.str_settings_color_monochrome;
+            default:
+                return 0;
+        }
+    }
+
+    public static int[] getColorModeItemIdArray(EscanI2Lib.ColorMode[] colorModeArr) {
+        if (colorModeArr == null) {
+            return null;
+        }
+        int[] iArr = new int[colorModeArr.length];
+        int i = 0;
+        for (EscanI2Lib.ColorMode colorStringId : colorModeArr) {
+            int colorStringId2 = getColorStringId(colorStringId);
+            if (colorStringId2 == 0) {
+                colorStringId2 = C2135R.string.str_blank;
+            }
+            iArr[i] = colorStringId2;
+            i++;
+        }
+        return iArr;
+    }
+
+    public static int getInputUnitStringId(EscanI2Lib.InputUnit inputUnit) {
+        switch (inputUnit) {
+            case FLATBED:
+                return C2135R.string.str_settings_source_doctable;
+            case ADF:
+                return C2135R.string.str_settings_source_adf;
+            default:
+                return 0;
+        }
+    }
+
+    public static int[] getInputUnitItemIdArray(EscanI2Lib.InputUnit[] inputUnitArr) {
+        if (inputUnitArr == null) {
+            return null;
+        }
+        int[] iArr = new int[inputUnitArr.length];
+        int i = 0;
+        for (EscanI2Lib.InputUnit inputUnitStringId : inputUnitArr) {
+            int inputUnitStringId2 = getInputUnitStringId(inputUnitStringId);
+            if (inputUnitStringId2 == 0) {
+                inputUnitStringId2 = C2135R.string.str_blank;
+            }
+            iArr[i] = inputUnitStringId2;
+            i++;
+        }
+        return iArr;
+    }
+
+    public static int getScanSizeStringId(ScanSize scanSize) {
+        if (scanSize == null) {
+            return C2135R.string.str_settings_undefine_scansize;
+        }
+        return getScanSizeStringId(scanSize.getSize());
+    }
+
+    public static int getScanSizeStringId(ScanSize.PaperSize paperSize) {
+        return (paperSize == null || paperSize == ScanSize.PaperSize.PIXEL) ? C2135R.string.str_settings_undefine_scansize : ScanSizeHelper.getScanSizeName(getEpsMediaId(paperSize));
+    }
+
+    public static int getEpsMediaId(ScanSize.PaperSize paperSize) {
+        switch (paperSize) {
+            case A4:
+                return Constants.PaperName.EPS_MSID_A4.getCode();
+            case LETTER:
+                return Constants.PaperName.EPS_MSID_LETTER.getCode();
+            case LEGAL:
+                return Constants.PaperName.EPS_MSID_LEGAL.getCode();
+            case B5:
+                return Constants.PaperName.EPS_MSID_B5.getCode();
+            case B6:
+                return Constants.PaperName.EPS_MSID_B6.getCode();
+            case A5:
+                return Constants.PaperName.EPS_MSID_A5.getCode();
+            case A6:
+                return Constants.PaperName.EPS_MSID_A6.getCode();
+            case A3:
+                return Constants.PaperName.EPS_MSID_A3.getCode();
+            case MEISHI:
+                return Constants.PaperName.EPS_MSID_BUZCARD_55X91.getCode();
+            case MAX:
+                return Constants.PaperName.EPS_MSID_USER.getCode();
+            default:
+                return -1;
+        }
+    }
+
+    public static int[] getScanSizeIdArray(ScanSize[] scanSizeArr) {
+        if (scanSizeArr == null) {
+            return null;
+        }
+        int[] iArr = new int[scanSizeArr.length];
+        int i = 0;
+        for (ScanSize scanSizeStringId : scanSizeArr) {
+            int scanSizeStringId2 = getScanSizeStringId(scanSizeStringId);
+            if (scanSizeStringId2 == 0) {
+                scanSizeStringId2 = C2135R.string.str_blank;
+            }
+            iArr[i] = scanSizeStringId2;
+            i++;
+        }
+        return iArr;
+    }
+
+    public static String[] getScanResolutionStrings(Context context, Integer[] numArr) {
+        String[] strArr = new String[numArr.length];
+        int i = 0;
+        for (Integer intValue : numArr) {
+            strArr[i] = getScanResolutionStrings(context, intValue.intValue());
+            i++;
+        }
+        return strArr;
+    }
+
+    public static String getScanResolutionStrings(Context context, int i) {
+        if (i <= 0) {
+            return context.getString(C2135R.string.str_blank);
+        }
+        return context.getString(C2135R.string.str_settings_resolution, new Object[]{Integer.valueOf(i)});
+    }
+
+    public static int[] getYesNoStringIdArray(Context context, Boolean[] boolArr) {
+        int[] iArr = new int[boolArr.length];
+        int i = 0;
+        for (Boolean booleanValue : boolArr) {
+            iArr[i] = getYesNoStringId(context, booleanValue.booleanValue());
+            i++;
+        }
+        return iArr;
+    }
+
+    public static int[] getGammaStringIdArray(Context context, EscanI2Lib.Gamma[] gammaArr) {
+        int[] iArr = new int[gammaArr.length];
+        int i = 0;
+        for (EscanI2Lib.Gamma gammaStringId : gammaArr) {
+            iArr[i] = getGammaStringId(gammaStringId);
+            i++;
+        }
+        return iArr;
+    }
+
+    public static int getGammaStringId(EscanI2Lib.Gamma gamma) {
+        switch (gamma) {
+            case GAMMA_100:
+                return C2135R.string.str_settings_gamma_10;
+            case GAMMA_180:
+                return C2135R.string.str_settings_gamma_18;
+            default:
+                return 0;
+        }
+    }
+}

+ 138 - 0
app/src/main/java/epson/scan/activity/I2DoubleSideScanSettingActivity.java

@@ -0,0 +1,138 @@
+package epson.scan.activity;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ListView;
+import epson.print.ActivityIACommon;
+import epson.print.C2135R;
+
+public class I2DoubleSideScanSettingActivity extends ActivityIACommon {
+    private static final Boolean[] DOUBLE_SIDE_VALUE_LIST = {true, false};
+    private static final String PARAM_KEY_DOUBLE_SIDE = "double-side";
+    private static final String PARAM_KEY_TURN_DIRECTION = "turn-direction";
+    private ModeListAdapter mDoubleSideAdapter;
+    private ListView mDoubleSideListView;
+    private ModeListAdapter mTurnDirectionAdapter;
+    private ListView mTurnDirectionListView;
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        setContentView((int) C2135R.layout.activity_i2_double_side_scan_setting);
+        setTitle(C2135R.string.str_settings_2sided_title);
+        setActionBar(getTitle().toString(), true);
+        this.mDoubleSideListView = (ListView) findViewById(C2135R.C2137id.upperListView);
+        this.mDoubleSideAdapter = getDoubleSideAdapter();
+        this.mDoubleSideListView.setAdapter(this.mDoubleSideAdapter);
+        this.mDoubleSideListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+            public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
+                I2DoubleSideScanSettingActivity.this.changeDoubleSide(i);
+            }
+        });
+        this.mTurnDirectionListView = (ListView) findViewById(C2135R.C2137id.lowerListView);
+        this.mTurnDirectionAdapter = getTurnDirectionAdapter();
+        this.mTurnDirectionListView.setAdapter(this.mTurnDirectionAdapter);
+        this.mTurnDirectionListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+            public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
+                I2DoubleSideScanSettingActivity.this.changeTurnDirection(i);
+            }
+        });
+        if (bundle != null) {
+            updateUiFromBundle(bundle);
+        } else {
+            updateUiFromIntent(getIntent());
+        }
+    }
+
+    private void updateUiFromBundle(Bundle bundle) {
+        updateUi(bundle.getBoolean(PARAM_KEY_DOUBLE_SIDE), bundle.getInt(PARAM_KEY_TURN_DIRECTION));
+    }
+
+    private void updateUiFromIntent(Intent intent) {
+        int i = 0;
+        boolean z = intent != null && intent.getBooleanExtra(PARAM_KEY_DOUBLE_SIDE, false);
+        if (intent != null) {
+            i = intent.getIntExtra(PARAM_KEY_TURN_DIRECTION, 0);
+        }
+        updateUi(z, i);
+    }
+
+    private void updateUi(boolean z, int i) {
+        this.mTurnDirectionAdapter.setPosition(i);
+        this.mDoubleSideAdapter.setPosition(getDoubleSidePosition(z));
+        updateTurnDirectionVisibilityFromDoubleSide();
+    }
+
+    private int getDoubleSidePosition(boolean z) {
+        int i = 0;
+        while (true) {
+            Boolean[] boolArr = DOUBLE_SIDE_VALUE_LIST;
+            if (i >= boolArr.length) {
+                return 0;
+            }
+            if (boolArr[i].booleanValue() == z) {
+                return i;
+            }
+            i++;
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void changeTurnDirection(int i) {
+        this.mTurnDirectionAdapter.setPosition(i);
+    }
+
+    /* access modifiers changed from: private */
+    public void changeDoubleSide(int i) {
+        this.mDoubleSideAdapter.setPosition(i);
+        updateTurnDirectionVisibilityFromDoubleSide();
+    }
+
+    private void updateTurnDirectionVisibilityFromDoubleSide() {
+        this.mTurnDirectionListView.setVisibility(DOUBLE_SIDE_VALUE_LIST[this.mDoubleSideAdapter.getPosition()].booleanValue() ? 0 : 4);
+    }
+
+    private ModeListAdapter getDoubleSideAdapter() {
+        return new ModeListAdapter(this, DisplayIdConverter.getYesNoStringIdArray(this, DOUBLE_SIDE_VALUE_LIST), 0);
+    }
+
+    private ModeListAdapter getTurnDirectionAdapter() {
+        return new ModeListAdapter(this, (int[]) null, new int[]{C2135R.C2136drawable.scan_counter_direction, C2135R.C2136drawable.scan_same_direction}, 0);
+    }
+
+    public void onBackPressed() {
+        Intent intent = new Intent();
+        intent.putExtra(PARAM_KEY_DOUBLE_SIDE, DOUBLE_SIDE_VALUE_LIST[this.mDoubleSideAdapter.getPosition()]);
+        intent.putExtra(PARAM_KEY_TURN_DIRECTION, this.mTurnDirectionAdapter.getPosition());
+        setResult(-1, intent);
+        finish();
+    }
+
+    /* access modifiers changed from: protected */
+    public void onSaveInstanceState(Bundle bundle) {
+        super.onSaveInstanceState(bundle);
+        bundle.putBoolean(PARAM_KEY_DOUBLE_SIDE, DOUBLE_SIDE_VALUE_LIST[this.mDoubleSideAdapter.getPosition()].booleanValue());
+        bundle.putInt(PARAM_KEY_TURN_DIRECTION, this.mTurnDirectionAdapter.getPosition());
+    }
+
+    public static Intent getStartIntent(Context context, boolean z, int i) {
+        Intent intent = new Intent(context, I2DoubleSideScanSettingActivity.class);
+        intent.putExtra(PARAM_KEY_DOUBLE_SIDE, z);
+        intent.putExtra(PARAM_KEY_TURN_DIRECTION, i);
+        return intent;
+    }
+
+    public static boolean getDoubleSideFromReturnIntent(Intent intent) {
+        return intent != null && intent.getBooleanExtra(PARAM_KEY_DOUBLE_SIDE, false);
+    }
+
+    public static int getTurnDirectionFromReturnIntent(Intent intent) {
+        if (intent == null) {
+            return 0;
+        }
+        return intent.getIntExtra(PARAM_KEY_TURN_DIRECTION, 0);
+    }
+}

+ 878 - 0
app/src/main/java/epson/scan/activity/I2ScanActivity.java

@@ -0,0 +1,878 @@
+package epson.scan.activity;
+
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.graphics.Rect;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.support.annotation.NonNull;
+import android.support.annotation.VisibleForTesting;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+import com.epson.iprint.prtlogger.CommonLog;
+import com.epson.iprint.shared.SharedParamScan;
+import com.epson.lib.escani2.EscanI2Lib;
+import com.epson.lib.escani2.I2LibScannerInfoAndCapability;
+import com.epson.lib.escani2.ScanI2Params;
+import com.epson.lib.escani2.ScanSize;
+import com.epson.lib.escani2.ScannerI2Info;
+import com.epson.mobilephone.common.wifidirect.NfcTagUtils;
+import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
+import epson.common.Constants;
+import epson.print.ActivityIACommon;
+import epson.print.ActivityNfcPrinter;
+import epson.print.ActivityPrintWeb;
+import epson.print.C2135R;
+import epson.print.CommonDefine;
+import epson.print.CustomTitleDialogFragment;
+import epson.print.EPImageUtil;
+import epson.scan.activity.I2ScanAreaView;
+import epson.scan.activity.ScanContinueParam;
+import epson.scan.i2lib.I2ScanParamManager;
+import epson.scan.i2lib.I2ScanTask;
+import epson.scan.lib.ScanInfoStorage;
+import epson.server.screens.StorageServer;
+import epson.server.utils.Define;
+import java.io.File;
+import java.io.IOException;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Locale;
+
+public class I2ScanActivity extends ActivityIACommon implements I2ScanAreaView.FlickCallback, CustomTitleDialogFragment.Callback, ScanContinueParam.ScanContinueDialogButtonClick {
+    private static final int DIALOG_ID_CONFIRM_CANCEL = 1;
+    private static final int DIALOG_ID_SCAN_ERROR = 2;
+    private static final String DIALOG_TAG_CONFIRM_CANCEL = "cancel-dialog";
+    private static final String DIALOG_TAG_SCAN_END = "scan-end";
+    private static final String DIALOG_TAG_SCAN_ERROR = "scan-error";
+    private static final String PARAM_KEY_SCAN_AUTO_START = "scan-auto-start";
+    private static final int REQUEST_CODE_I2SETTING = 1;
+    private static final int REQUEST_CODE_NFC_SCANNER_CHANGE = 5;
+    private static final int REQUEST_CODE_PRINT = 2;
+    private static final int REQUEST_CODE_START_MAIL_ACTIVITY = 3;
+    private static final int REQUEST_CODE_WIFI_DIRECT_SIMPLE_AP_CONNECT = 4;
+    public static final int RESULT_ESC_I_VERSION_CHANGE = 1;
+    private static final String TAG = "I2ScanActivity";
+    private boolean mActivityIsVisible;
+    private int mCurrentPage;
+    private SharedParamScan mExternalIntentData;
+    private I2ScanAreaView mI2ScanAreaView;
+    private I2ScanTask mI2ScanTask;
+    /* access modifiers changed from: private */
+    public final LocalHandler mLocalHandler = new LocalHandler(this);
+    private CustomButtonWrapper mMailButton;
+    private Button mNextPageButton;
+    private TextView mPageDisplayText;
+    private Button mPreviousPageButton;
+    private CustomButtonWrapper mPrintButton;
+    private ProgressCallback mProgressCallback;
+    private View mProgressViewGroup;
+    private CustomButtonWrapper mSaveButton;
+    private Button mScanButton;
+    private Button mScanCancelButton;
+    /* access modifiers changed from: private */
+    public ArrayList<String> mScanFileList;
+    private int[] mScanFileSizeAndOffset;
+    private CommonLog mScanLog;
+    private TextView mScanProgressText;
+    private boolean mStartScanAtScannerChanged;
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        setContentView((int) C2135R.layout.activity_i2_scan);
+        this.mScanFileList = new ArrayList<>();
+        this.mProgressCallback = new ProgressCallback();
+        setActionBar((int) C2135R.string.str_scan_btn, true);
+        this.mI2ScanAreaView = (I2ScanAreaView) findViewById(C2135R.C2137id.areaView);
+        this.mI2ScanAreaView.setFlickCallback(this);
+        this.mProgressViewGroup = findViewById(C2135R.C2137id.llScanningProgress);
+        this.mScanProgressText = (TextView) findViewById(C2135R.C2137id.scanProgressText);
+        this.mPageDisplayText = (TextView) findViewById(C2135R.C2137id.tvScanResult);
+        this.mSaveButton = new CustomButtonWrapper((Button) findViewById(C2135R.C2137id.btnSave), C2135R.C2136drawable.scan_save);
+        this.mSaveButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                I2ScanActivity.this.onSaveButtonClicked();
+            }
+        });
+        this.mMailButton = new CustomButtonWrapper((Button) findViewById(C2135R.C2137id.btnMail), C2135R.C2136drawable.scan_mail);
+        this.mMailButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                I2ScanActivity.this.startMailActivity();
+            }
+        });
+        this.mPrintButton = new CustomButtonWrapper((Button) findViewById(C2135R.C2137id.btnPrint), C2135R.C2136drawable.scan_print);
+        this.mPrintButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                I2ScanActivity.this.startPrintActivity();
+            }
+        });
+        this.mScanButton = (Button) findViewById(C2135R.C2137id.btnScan);
+        this.mScanButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                I2ScanActivity i2ScanActivity = I2ScanActivity.this;
+                ScanContinueParam.judgeScanContinue(i2ScanActivity, i2ScanActivity.mScanFileList);
+            }
+        });
+        this.mScanCancelButton = (Button) findViewById(C2135R.C2137id.btnCancelScan);
+        this.mScanCancelButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                I2ScanActivity.this.confirmCancelScan();
+            }
+        });
+        this.mNextPageButton = (Button) findViewById(C2135R.C2137id.btnNext);
+        this.mNextPageButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                I2ScanActivity.this.changePage(1);
+            }
+        });
+        this.mPreviousPageButton = (Button) findViewById(C2135R.C2137id.btnPrev);
+        this.mPreviousPageButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                I2ScanActivity.this.changePage(-1);
+            }
+        });
+        this.mExternalIntentData = ScanActivityCommonParams.getExternalIntentData(getIntent());
+        if (!returnToI1ActivityIfEscIVersionMismatch()) {
+            this.mProgressViewGroup.setVisibility(8);
+            if (bundle == null) {
+                resetUserDefineSize(false);
+            }
+            updateUi();
+            this.mScanLog = ScanActivityCommonParams.getCommonLog(getIntent());
+            startScanIfNeeded(getIntent());
+        }
+    }
+
+    private void startScanIfNeeded(Intent intent) {
+        if (ScanActivityCommonParams.startScanAtActivityChange(intent)) {
+            this.mStartScanAtScannerChanged = false;
+            requestStartScan();
+        }
+    }
+
+    private void resetUserDefineSize(boolean z) {
+        ScanI2Params loadScanI2Params = I2ScanParamManager.loadScanI2Params(this);
+        if (z || loadScanI2Params.scanSize.isPixelSize()) {
+            try {
+                I2ScanParamManager.updateScanSize(this, ScanSize.getLocaleDefaultSize());
+            } catch (IOException unused) {
+            }
+        }
+    }
+
+    private void updateUi() {
+        int[] iArr;
+        int[] iArr2;
+        I2LibScannerInfoAndCapability i2ScannerAllInfo = ScannerPropertyWrapper.load(this).getI2ScannerAllInfo();
+        if (i2ScannerAllInfo == null || i2ScannerAllInfo.scannerI2Info == null) {
+            ScanInfoStorage.saveEscIVersion(this, 0);
+            ScannerPropertyWrapper.clearSavedData(this);
+            returnToI1ActivityIfEscIVersionMismatch();
+            return;
+        }
+        ScannerI2Info scannerI2Info = i2ScannerAllInfo.scannerI2Info;
+        ScanI2Params loadScanI2Params = I2ScanParamManager.loadScanI2Params(this);
+        SharedParamScan sharedParamScan = this.mExternalIntentData;
+        if (sharedParamScan != null) {
+            iArr = new int[]{sharedParamScan.getPixel_main(), this.mExternalIntentData.getPixel_sub(), 0, 0};
+            iArr2 = scannerI2Info.getSensorPixelSize(loadScanI2Params.inputUnit, this.mExternalIntentData.getRes_main(), this.mExternalIntentData.getRes_sub());
+        } else {
+            iArr = loadScanI2Params.scanSize.getSize(scannerI2Info, loadScanI2Params);
+            iArr2 = scannerI2Info.getSensorPixelSize(loadScanI2Params.inputUnit, loadScanI2Params.resolutionMain, loadScanI2Params.resolutionSub);
+        }
+        if (loadScanI2Params.inputUnit == EscanI2Lib.InputUnit.ADF) {
+            this.mI2ScanAreaView.setArea(iArr[0], iArr[1]);
+        } else {
+            this.mI2ScanAreaView.setMovableAreaModeSize(iArr2[0], iArr2[1], new Rect(iArr[2], iArr[3], iArr[0] + iArr[2], iArr[1] + iArr[3]));
+        }
+        displayScanFileList();
+        if (this.mExternalIntentData != null) {
+            this.mMailButton.setVisibility(8);
+            this.mPrintButton.setVisibility(8);
+        }
+    }
+
+    private boolean returnToI1ActivityIfEscIVersionMismatch() {
+        if (ScanInfoStorage.loadEscIVersion(this) == 2) {
+            return false;
+        }
+        Intent intent = new Intent();
+        intent.putExtra(PARAM_KEY_SCAN_AUTO_START, this.mStartScanAtScannerChanged);
+        setResult(1, intent);
+        this.mStartScanAtScannerChanged = false;
+        finish();
+        return true;
+    }
+
+    /* access modifiers changed from: private */
+    public void startScan() {
+        I2ScanTask i2ScanTask = this.mI2ScanTask;
+        if (i2ScanTask == null || i2ScanTask.getStatus() == AsyncTask.Status.FINISHED) {
+            saveScanSizeIfChanged();
+            this.mScanCancelButton.setEnabled(true);
+            this.mScanCancelButton.setVisibility(0);
+            this.mScanButton.setEnabled(false);
+            this.mProgressViewGroup.setVisibility(0);
+            this.mPageDisplayText.setVisibility(8);
+            this.mNextPageButton.setVisibility(8);
+            this.mPreviousPageButton.setVisibility(8);
+            this.mI2ScanAreaView.setPromptStringVisibility(4);
+            if (!WiFiDirectManager.isNeedConnect(this, WiFiDirectManager.DEVICE_TYPE_SCANNER) || !WiFiDirectManager.reconnect(this, WiFiDirectManager.DEVICE_TYPE_SCANNER, 4)) {
+                if (!ScanContinueParam.isContinueScanning()) {
+                    ScanCount.countUpScanPage(this);
+                }
+                this.mI2ScanTask = new I2ScanTask(this, this.mProgressCallback, this.mExternalIntentData, this.mScanLog);
+                this.mI2ScanTask.execute(new Void[0]);
+            }
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void confirmCancelScan() {
+        if (this.mI2ScanTask != null && this.mActivityIsVisible) {
+            this.mProgressViewGroup.setVisibility(4);
+            CustomTitleDialogFragment.newInstance(1, getString(C2135R.string.str_msg_scan_cancel), 0, (int) C2135R.string.str_yes, (int) C2135R.string.str_no).show(getSupportFragmentManager(), DIALOG_TAG_CONFIRM_CANCEL);
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void localScanEnd(I2ScanTask.TaskError taskError) {
+        dismissCancelConfirmDialog();
+        updateScanEnd();
+        updateScanFileList(taskError);
+        displayScanFileList();
+    }
+
+    /* access modifiers changed from: private */
+    public void updateScanEnd() {
+        this.mProgressViewGroup.setVisibility(8);
+        this.mScanButton.setEnabled(true);
+    }
+
+    private void showProgressWithoutTextViewCancelButton() {
+        this.mProgressViewGroup.setVisibility(0);
+        this.mScanCancelButton.setVisibility(4);
+        this.mScanProgressText.setVisibility(4);
+    }
+
+    /* access modifiers changed from: protected */
+    public void onResume() {
+        super.onResume();
+        NfcTagUtils.enableForegroundDispatch(this, (IntentFilter[]) null, (String[][]) null);
+        this.mActivityIsVisible = true;
+    }
+
+    /* access modifiers changed from: protected */
+    public void onPause() {
+        super.onPause();
+        this.mActivityIsVisible = false;
+        NfcTagUtils.disableForegroundDispatch(this);
+    }
+
+    /* access modifiers changed from: protected */
+    public void onStop() {
+        super.onStop();
+        if (this.mProgressViewGroup.getVisibility() == 0) {
+            cancelScan();
+        }
+        dismissCancelConfirmDialog();
+    }
+
+    private void dismissCancelConfirmDialog() {
+        CustomTitleDialogFragment customTitleDialogFragment = (CustomTitleDialogFragment) getSupportFragmentManager().findFragmentByTag(DIALOG_TAG_CONFIRM_CANCEL);
+        if (customTitleDialogFragment != null) {
+            customTitleDialogFragment.dismiss();
+        }
+    }
+
+    private void cancelScan() {
+        this.mProgressViewGroup.setVisibility(0);
+        I2ScanTask i2ScanTask = this.mI2ScanTask;
+        if (i2ScanTask != null) {
+            i2ScanTask.cancelScan();
+            this.mScanCancelButton.setEnabled(false);
+        }
+    }
+
+    /* access modifiers changed from: protected */
+    public void onNewIntent(Intent intent) {
+        super.onNewIntent(intent);
+        I2ScanTask i2ScanTask = this.mI2ScanTask;
+        if ((i2ScanTask == null || i2ScanTask.getStatus() == AsyncTask.Status.FINISHED) && "android.nfc.action.NDEF_DISCOVERED".equals(intent.getAction())) {
+            checkNfcTagAndStartProcess(intent);
+        }
+    }
+
+    private void checkNfcTagAndStartProcess(Intent intent) {
+        NfcTagUtils.EpsonNfcConnectInfo parseNECTag = NfcTagUtils.parseNECTag(this, intent);
+        if (parseNECTag != null) {
+            ScannerPropertyWrapper.load(this).getScannerId();
+            Intent intent2 = new Intent();
+            intent2.setClass(this, ActivityNfcPrinter.class);
+            intent2.putExtra(ActivityNfcPrinter.CONNECTINFO, parseNECTag);
+            intent2.putExtra(ActivityNfcPrinter.CHANGEMODE, 2);
+            startActivityForResult(intent2, 5);
+            this.mStartScanAtScannerChanged = true;
+        }
+    }
+
+    /* access modifiers changed from: protected */
+    public void onSaveInstanceState(Bundle bundle) {
+        super.onSaveInstanceState(bundle);
+    }
+
+    public void onBackPressed() {
+        if (this.mProgressViewGroup.getVisibility() != 0) {
+            resetUserDefineSize(this.mI2ScanAreaView.isScanAreaModified());
+            ScanActivity.removeTempContents(this);
+            finish();
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void onSaveButtonClicked() {
+        if (this.mExternalIntentData == null) {
+            startSaveActivity();
+        } else if (!this.mScanFileList.isEmpty()) {
+            showProgressWithoutTextViewCancelButton();
+            new ImageConvertAndFinishTask(this.mExternalIntentData).execute(new ArrayList[]{this.mScanFileList});
+        }
+    }
+
+    private void startSaveActivity() {
+        ArrayList<String> arrayList = this.mScanFileList;
+        if (arrayList != null && arrayList.size() > 0) {
+            Intent intent = new Intent(this, StorageServer.class);
+            intent.putExtra(Define.PICK_SERVER_FOR, 2);
+            intent.putStringArrayListExtra(Define.SAVING_FILE_PATH, arrayList);
+            intent.putExtra(StorageServer.FOR_PRINT_LOGGER_CALL_FROM, 1);
+            startActivity(intent);
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void startMailActivity() {
+        if (!this.mScanFileList.isEmpty()) {
+            Intent intent = new Intent(this, MailActivity.class);
+            intent.putStringArrayListExtra(Define.SAVING_FILE_PATH, this.mScanFileList);
+            startActivityForResult(intent, 3);
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void startPrintActivity() {
+        if (!this.mScanFileList.isEmpty()) {
+            Intent intent = new Intent(this, ActivityPrintWeb.class);
+            intent.putExtra("from", 1);
+            intent.putStringArrayListExtra("print_web", this.mScanFileList);
+            intent.putExtra("print_log", ScanActivity.getPrintLog());
+            startActivityForResult(intent, 2);
+        }
+    }
+
+    public boolean onCreateOptionsMenu(Menu menu) {
+        getMenuInflater().inflate(C2135R.C2138menu.scan_menu, menu);
+        return true;
+    }
+
+    public boolean onOptionsItemSelected(MenuItem menuItem) {
+        if (menuItem.getItemId() != C2135R.C2137id.btn_scan_settings) {
+            return super.onOptionsItemSelected(menuItem);
+        }
+        goSettingActivity();
+        return true;
+    }
+
+    private void saveScanSizeIfChanged() {
+        if (this.mI2ScanAreaView.isScanAreaModified()) {
+            Rect movableScanArea = this.mI2ScanAreaView.getMovableScanArea();
+            try {
+                I2ScanParamManager.updateScanSize(this, new ScanSize(movableScanArea.width(), movableScanArea.height(), movableScanArea.left, movableScanArea.top));
+            } catch (IOException unused) {
+            }
+        }
+    }
+
+    private void goSettingActivity() {
+        saveScanSizeIfChanged();
+        boolean z = this.mExternalIntentData != null;
+        startActivityForResult(I2ScanSettingActivity.getStartIntent(this, z, z, this.mExternalIntentData), 1);
+    }
+
+    /* access modifiers changed from: protected */
+    public void onActivityResult(int i, int i2, Intent intent) {
+        boolean z = false;
+        if (i != 1) {
+            switch (i) {
+                case 4:
+                    if (i2 == -1) {
+                        requestStartScan();
+                        return;
+                    } else {
+                        updateScanEnd();
+                        return;
+                    }
+                case 5:
+                    onI2SettingEnd(i2, false);
+                    return;
+                default:
+                    return;
+            }
+        } else {
+            if (i2 != -1 || I2ScanSettingActivity.getOldDataValidation(intent)) {
+                z = true;
+            }
+            onI2SettingEnd(i2, z);
+        }
+    }
+
+    private void onI2SettingEnd(int i, boolean z) {
+        if (!returnToI1ActivityIfEscIVersionMismatch() && i == -1) {
+            if (!z) {
+                this.mScanFileList.clear();
+                this.mCurrentPage = 0;
+                ScanContinueParam.resetParameter();
+                ScanActivity.removeTempContents(this);
+            }
+            updateUi();
+            if (this.mStartScanAtScannerChanged) {
+                this.mStartScanAtScannerChanged = false;
+                requestStartScan();
+            }
+        }
+    }
+
+    private void requestStartScan() {
+        runOnUiThread(new Runnable() {
+            public void run() {
+                I2ScanActivity.this.startScan();
+            }
+        });
+    }
+
+    private void updateScanFileList(I2ScanTask.TaskError taskError) {
+        if (!isFinishing() && !I2ScanTask.TaskError.isInvalidScanArea(taskError)) {
+            if (this.mI2ScanTask != null) {
+                if (ScanContinueParam.isContinueScanning()) {
+                    this.mScanFileList.addAll(this.mI2ScanTask.getScanFileList());
+                } else {
+                    this.mScanFileList.clear();
+                    this.mScanFileList.addAll(this.mI2ScanTask.getScanFileList());
+                }
+                int size = this.mScanFileList.size();
+                if (size > 0) {
+                    ScanCount.saveScanCount(getApplicationContext(), size);
+                    ScanContinueParam.setScannedFileCount(size);
+                    if (ScanContinueParam.isReachMaximumScan() && I2ScanParamManager.loadScanI2Params(this).inputUnit == EscanI2Lib.InputUnit.ADF) {
+                        ScanContinueParam.showScanErrorLimit(this);
+                    }
+                    ScannerI2Info scannerI2Info = ScannerPropertyWrapper.load(this).getI2ScannerAllInfo().scannerI2Info;
+                    ScanI2Params loadScanI2Params = I2ScanParamManager.loadScanI2Params(this);
+                    SharedParamScan sharedParamScan = this.mExternalIntentData;
+                    if (sharedParamScan == null) {
+                        this.mScanFileSizeAndOffset = loadScanI2Params.scanSize.getValidScanSize(scannerI2Info, loadScanI2Params);
+                    } else {
+                        this.mScanFileSizeAndOffset = new int[]{sharedParamScan.getPixel_main(), this.mExternalIntentData.getPixel_sub(), 0, 0};
+                    }
+                }
+            } else {
+                this.mScanFileList.clear();
+            }
+            if (taskError != null && !taskError.isCancel()) {
+                displayScanError(taskError);
+            }
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void displayScanError(@NonNull I2ScanTask.TaskError taskError) {
+        String str;
+        if (this.mActivityIsVisible) {
+            int[] i2ScanErrorTitleAndMessage = getI2ScanErrorTitleAndMessage(taskError);
+            if (i2ScanErrorTitleAndMessage[1] == 0) {
+                str = "";
+            } else {
+                str = getString(i2ScanErrorTitleAndMessage[1]);
+            }
+            CustomTitleDialogFragment.newInstance(2, str, i2ScanErrorTitleAndMessage[0], (int) C2135R.string.str_ok, 0).show(getSupportFragmentManager(), DIALOG_TAG_SCAN_ERROR);
+        }
+    }
+
+    /* JADX WARNING: Code restructure failed: missing block: B:24:0x005f, code lost:
+        r1[0] = epson.print.C2135R.string.str_err_msg_scan_coveropen_title;
+        r1[1] = epson.print.C2135R.string.str_err_msg_scan_coveropen;
+     */
+    /* JADX WARNING: Code restructure failed: missing block: B:25:0x006a, code lost:
+        r1[0] = epson.print.C2135R.string.str_err_msg_scan_paperjam_title;
+        r1[1] = epson.print.C2135R.string.str_err_msg_scan_paperjam;
+     */
+    /* JADX WARNING: Code restructure failed: missing block: B:26:0x0075, code lost:
+        r1[0] = epson.print.C2135R.string.str_err_msg_scan_paperout_title;
+        r1[1] = epson.print.C2135R.string.str_err_msg_scan_paperout;
+     */
+    /* Code decompiled incorrectly, please refer to instructions dump. */
+    private int[] getI2ScanErrorTitleAndMessage(@android.support.annotation.NonNull epson.scan.i2lib.I2ScanTask.TaskError r8) {
+        /*
+            r7 = this;
+            r0 = 2
+            int[] r1 = new int[r0]
+            int r2 = r8.error1
+            r3 = 2131625131(0x7f0e04ab, float:1.8877461E38)
+            r4 = 2131625132(0x7f0e04ac, float:1.8877463E38)
+            r5 = 1
+            r6 = 0
+            switch(r2) {
+                case 1: goto L_0x0028;
+                case 2: goto L_0x0012;
+                default: goto L_0x0010;
+            }
+        L_0x0010:
+            goto L_0x00b6
+        L_0x0012:
+            int r8 = r8.error2
+            if (r8 == r0) goto L_0x001c
+            r1[r6] = r4
+            r1[r5] = r3
+            goto L_0x00b6
+        L_0x001c:
+            r8 = 2131625276(0x7f0e053c, float:1.8877755E38)
+            r1[r6] = r8
+            r8 = 2131625194(0x7f0e04ea, float:1.887759E38)
+            r1[r5] = r8
+            goto L_0x00b6
+        L_0x0028:
+            int r8 = r8.error2
+            r0 = -500001(0xfffffffffff85edf, float:NaN)
+            if (r8 == r0) goto L_0x00ac
+            r0 = -5007(0xffffffffffffec71, float:NaN)
+            if (r8 == r0) goto L_0x00a1
+            r0 = -1501(0xfffffffffffffa23, float:NaN)
+            if (r8 == r0) goto L_0x0096
+            r0 = -1300(0xfffffffffffffaec, float:NaN)
+            if (r8 == r0) goto L_0x008b
+            r0 = -1114(0xfffffffffffffba6, float:NaN)
+            if (r8 == r0) goto L_0x0080
+            r0 = -1100(0xfffffffffffffbb4, float:NaN)
+            if (r8 == r0) goto L_0x0080
+            switch(r8) {
+                case -5003: goto L_0x0075;
+                case -5002: goto L_0x006a;
+                case -5001: goto L_0x005f;
+                default: goto L_0x0046;
+            }
+        L_0x0046:
+            switch(r8) {
+                case -215: goto L_0x005f;
+                case -214: goto L_0x0080;
+                case -213: goto L_0x0096;
+                case -212: goto L_0x006a;
+                case -211: goto L_0x00a1;
+                case -210: goto L_0x0075;
+                default: goto L_0x0049;
+            }
+        L_0x0049:
+            switch(r8) {
+                case -202: goto L_0x0054;
+                case -201: goto L_0x0054;
+                default: goto L_0x004c;
+            }
+        L_0x004c:
+            switch(r8) {
+                case -102: goto L_0x0054;
+                case -101: goto L_0x0054;
+                default: goto L_0x004f;
+            }
+        L_0x004f:
+            r1[r6] = r4
+            r1[r5] = r3
+            goto L_0x00b6
+        L_0x0054:
+            r8 = 2131625073(0x7f0e0471, float:1.8877344E38)
+            r1[r6] = r8
+            r8 = 2131625120(0x7f0e04a0, float:1.8877439E38)
+            r1[r5] = r8
+            goto L_0x00b6
+        L_0x005f:
+            r8 = 2131625128(0x7f0e04a8, float:1.8877455E38)
+            r1[r6] = r8
+            r8 = 2131625127(0x7f0e04a7, float:1.8877453E38)
+            r1[r5] = r8
+            goto L_0x00b6
+        L_0x006a:
+            r8 = 2131625137(0x7f0e04b1, float:1.8877473E38)
+            r1[r6] = r8
+            r8 = 2131625136(0x7f0e04b0, float:1.8877471E38)
+            r1[r5] = r8
+            goto L_0x00b6
+        L_0x0075:
+            r8 = 2131625139(0x7f0e04b3, float:1.8877478E38)
+            r1[r6] = r8
+            r8 = 2131625138(0x7f0e04b2, float:1.8877475E38)
+            r1[r5] = r8
+            goto L_0x00b6
+        L_0x0080:
+            r8 = 2131625126(0x7f0e04a6, float:1.8877451E38)
+            r1[r6] = r8
+            r8 = 2131625125(0x7f0e04a5, float:1.887745E38)
+            r1[r5] = r8
+            goto L_0x00b6
+        L_0x008b:
+            r8 = 2131625135(0x7f0e04af, float:1.887747E38)
+            r1[r6] = r8
+            r8 = 2131625134(0x7f0e04ae, float:1.8877467E38)
+            r1[r5] = r8
+            goto L_0x00b6
+        L_0x0096:
+            r8 = 2131625124(0x7f0e04a4, float:1.8877447E38)
+            r1[r6] = r8
+            r8 = 2131625123(0x7f0e04a3, float:1.8877445E38)
+            r1[r5] = r8
+            goto L_0x00b6
+        L_0x00a1:
+            r8 = 2131625130(0x7f0e04aa, float:1.887746E38)
+            r1[r6] = r8
+            r8 = 2131625129(0x7f0e04a9, float:1.8877457E38)
+            r1[r5] = r8
+            goto L_0x00b6
+        L_0x00ac:
+            r8 = 2131624371(0x7f0e01b3, float:1.887592E38)
+            r1[r6] = r8
+            r8 = 2131625160(0x7f0e04c8, float:1.887752E38)
+            r1[r5] = r8
+        L_0x00b6:
+            return r1
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.scan.activity.I2ScanActivity.getI2ScanErrorTitleAndMessage(epson.scan.i2lib.I2ScanTask$TaskError):int[]");
+    }
+
+    /* access modifiers changed from: package-private */
+    @VisibleForTesting
+    public void setScanFileList(ArrayList<String> arrayList, int[] iArr) {
+        this.mScanFileList = arrayList;
+        if (this.mScanFileList == null) {
+            this.mScanFileList = new ArrayList<>();
+        }
+        this.mScanFileSizeAndOffset = iArr;
+        displayScanFileList();
+    }
+
+    private void displayScanFileList() {
+        if (!isFinishing()) {
+            boolean z = true;
+            int i = 0;
+            if (!this.mScanFileList.isEmpty()) {
+                this.mCurrentPage = this.mScanFileList.size() - 1;
+                if (this.mScanFileList.size() <= 1) {
+                    this.mPageDisplayText.setVisibility(8);
+                } else {
+                    this.mPageDisplayText.setVisibility(0);
+                }
+            } else {
+                this.mCurrentPage = 0;
+                z = false;
+            }
+            this.mSaveButton.setEnabled(z);
+            this.mMailButton.setEnabled(z);
+            this.mPrintButton.setEnabled(z);
+            I2ScanAreaView i2ScanAreaView = this.mI2ScanAreaView;
+            if (z) {
+                i = 4;
+            }
+            i2ScanAreaView.setPromptStringVisibility(i);
+            updateScanPreviewPage();
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void changePage(int i) {
+        this.mCurrentPage += i;
+        int i2 = this.mCurrentPage;
+        if (i2 < 0) {
+            this.mCurrentPage = 0;
+        } else if (i2 >= this.mScanFileList.size()) {
+            this.mCurrentPage = this.mScanFileList.size() - 1;
+        }
+        updateScanPreviewPage();
+    }
+
+    private void updateScanPreviewPage() {
+        int size = this.mScanFileList.size();
+        int i = 0;
+        if (size > 1) {
+            this.mPageDisplayText.setVisibility(0);
+            TextView textView = this.mPageDisplayText;
+            textView.setText((this.mCurrentPage + 1) + Constants.CROSS + size);
+        } else {
+            this.mPageDisplayText.setVisibility(8);
+        }
+        int i2 = this.mCurrentPage > 0 ? 0 : 8;
+        if (this.mCurrentPage >= this.mScanFileList.size() - 1) {
+            i = 8;
+        }
+        this.mPreviousPageButton.setVisibility(i2);
+        this.mNextPageButton.setVisibility(i);
+        if (this.mScanFileList.isEmpty()) {
+            this.mI2ScanAreaView.setPreviewImage((String) null, (int[]) null);
+        } else {
+            this.mI2ScanAreaView.setPreviewImage(this.mScanFileList.get(this.mCurrentPage), this.mScanFileSizeAndOffset);
+        }
+        this.mI2ScanAreaView.invalidate();
+    }
+
+    /* access modifiers changed from: private */
+    public void updateScanProgressPreview(int i, int i2) {
+        File scanFile = this.mI2ScanTask.getScanFile(i, i2);
+        if (scanFile != null || scanFile.canRead()) {
+            this.mI2ScanAreaView.setPreviewImage(scanFile.getPath());
+            this.mI2ScanAreaView.invalidate();
+        }
+    }
+
+    public void flick(int i) {
+        changePage(i);
+    }
+
+    public void onLocalNegativeCallback(int i) {
+        if (i == 1) {
+            this.mScanCancelButton.setEnabled(true);
+            this.mProgressViewGroup.setVisibility(0);
+        }
+    }
+
+    public void onLocalPositiveCallback(int i) {
+        if (i == 1) {
+            cancelScan();
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void finishWithScanParam(@NonNull ArrayList<String> arrayList) {
+        Intent intent = new Intent();
+        intent.putExtra("scan-file", arrayList);
+        setResult(-1, intent);
+        finish();
+    }
+
+    public void onRequestScanAction() {
+        startScan();
+    }
+
+    private class ProgressCallback implements I2ScanTask.ScanResultReceiver {
+        private ProgressCallback() {
+        }
+
+        public void onProgressUpdate(int i, int i2) {
+            I2ScanActivity.this.mLocalHandler.sendUpdateScanProgressPreviewMessage(i, i2);
+        }
+
+        public void onScanEnd(I2ScanTask.TaskError taskError) {
+            I2ScanActivity.this.localScanEnd(taskError);
+        }
+    }
+
+    static boolean getAutoStartRequestedFromReturnIntent(Intent intent) {
+        if (intent == null) {
+            return false;
+        }
+        return intent.getBooleanExtra(PARAM_KEY_SCAN_AUTO_START, false);
+    }
+
+    private static class LocalHandler extends Handler {
+        static final int MESSAGE_UPDATE_PREVIEW = 1;
+        private final WeakReference<I2ScanActivity> mActivity;
+
+        LocalHandler(I2ScanActivity i2ScanActivity) {
+            this.mActivity = new WeakReference<>(i2ScanActivity);
+        }
+
+        public void handleMessage(Message message) {
+            I2ScanActivity i2ScanActivity;
+            if (message.what == 1 && (i2ScanActivity = (I2ScanActivity) this.mActivity.get()) != null && !i2ScanActivity.isFinishing()) {
+                i2ScanActivity.updateScanProgressPreview(message.arg1, message.arg2);
+            }
+        }
+
+        /* access modifiers changed from: package-private */
+        public void sendUpdateScanProgressPreviewMessage(int i, int i2) {
+            removeMessages(1);
+            sendMessage(obtainMessage(1, i, i2));
+        }
+    }
+
+    private class ImageConvertAndFinishTask extends AsyncTask<ArrayList<String>, Void, Integer> {
+        private final int ERROR_CODE_FILE_WRITE_ERROR = 2;
+        private final int ERROR_CODE_NO_ERROR = 0;
+        private final int ERROR_CODE_NO_FILE = 1;
+        private ArrayList<String> mScanFileList;
+        private SharedParamScan mScanParams;
+
+        ImageConvertAndFinishTask(@NonNull SharedParamScan sharedParamScan) {
+            this.mScanParams = sharedParamScan;
+        }
+
+        /* access modifiers changed from: protected */
+        public Integer doInBackground(ArrayList<String>... arrayListArr) {
+            int i;
+            if (arrayListArr.length <= 0) {
+                return 1;
+            }
+            ArrayList<String> arrayList = arrayListArr[0];
+            if (arrayList.size() <= 0) {
+                return 1;
+            }
+            File file = new File(this.mScanParams.getFolder_name());
+            if (!file.exists() && !file.mkdirs()) {
+                return 2;
+            }
+            this.mScanFileList = new ArrayList<>();
+            EPImageUtil ePImageUtil = new EPImageUtil();
+            String str = file.getPath() + CommonDefine.SLASH + this.mScanParams.getFile_name() + "_%03d.bmp";
+            boolean z = this.mScanParams.getScan_type() == 3;
+            Iterator<String> it = arrayList.iterator();
+            int i2 = 0;
+            while (it.hasNext()) {
+                String next = it.next();
+                i2++;
+                String format = String.format(Locale.US, str, new Object[]{Integer.valueOf(i2)});
+                if (z) {
+                    i = EPImageUtil.jpegTo1BitBmpPixelRoundDown(next, format, 127);
+                } else {
+                    i = ePImageUtil.jpg2bmp(next, format, 1);
+                }
+                if (i != 0) {
+                    return 2;
+                }
+                this.mScanFileList.add(format);
+            }
+            return 0;
+        }
+
+        /* access modifiers changed from: protected */
+        public void onPostExecute(Integer num) {
+            I2ScanActivity.this.updateScanEnd();
+            if (num != null && num.intValue() != 1) {
+                if (num.intValue() == 0) {
+                    ArrayList<String> arrayList = this.mScanFileList;
+                    if (arrayList != null) {
+                        I2ScanActivity.this.finishWithScanParam(arrayList);
+                        return;
+                    }
+                    return;
+                }
+                I2ScanActivity.this.displayScanError(convertError(num.intValue()));
+            }
+        }
+
+        @NonNull
+        private I2ScanTask.TaskError convertError(int i) {
+            return new I2ScanTask.TaskError(1, i != 2 ? EscanI2Lib.ERROR_CODE_GENERAL_ERROR : -202);
+        }
+    }
+}

+ 526 - 0
app/src/main/java/epson/scan/activity/I2ScanAreaView.java

@@ -0,0 +1,526 @@
+package epson.scan.activity;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.DashPathEffect;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.PathEffect;
+import android.graphics.Rect;
+import android.support.p000v4.view.GestureDetectorCompat;
+import android.support.p000v4.view.ViewCompat;
+import android.text.TextPaint;
+import android.util.AttributeSet;
+import android.view.GestureDetector;
+import android.view.MotionEvent;
+import android.view.View;
+import epson.common.ImageUtil;
+import epson.print.C2135R;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+public class I2ScanAreaView extends View {
+    private static final int CONTOUR_AREA_BACK_COLOR = -1;
+    private final int SCAN_AREA_CORNER_LENGTH_DP = 30;
+    private final int SCAN_AREA_CORNER_LONG_TAP_AREA_WIDTH_DP = 60;
+    private final int SCAN_AREA_CORNER_WIDTH_DP = 4;
+    private final int SCAN_AREA_MOVE_MODE_AREA_MOVE = 3;
+    private final int SCAN_AREA_MOVE_MODE_LEFT_UPPER = 1;
+    private final int SCAN_AREA_MOVE_MODE_NONE = 0;
+    private final int SCAN_AREA_MOVE_MODE_RIGHT_LOWER = 2;
+    private ArrayList<String> mBreakStrings;
+    private float[] mDashInterval;
+    private Rect mDisplayContourArea;
+    private float mDisplayDensity;
+    private Rect mDisplayMovableArea;
+    private Rect mDisplayPreviewImageRect;
+    private double mDisplayRate;
+    private float mDisplayTextLeft;
+    private ArrayList<Float> mDisplayTextYPosition;
+    private FlickCallback mFlickCallback;
+    private GestureDetectorCompat mGestureDetectorCompat;
+    private final GestureDetector.SimpleOnGestureListener mGestureListener = new GestureDetector.SimpleOnGestureListener() {
+        public boolean onDown(MotionEvent motionEvent) {
+            return true;
+        }
+
+        public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent2, float f, float f2) {
+            return true;
+        }
+
+        public boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent2, float f, float f2) {
+            I2ScanAreaView.this.checkFlick(f);
+            return true;
+        }
+
+        public void onLongPress(MotionEvent motionEvent) {
+            boolean unused = I2ScanAreaView.this.checkMoveMode(motionEvent.getX(), motionEvent.getY());
+        }
+    };
+    private boolean mMovableAreaMode;
+    private int mOrgContourHeight;
+    private int mOrgContourWidth;
+    private Rect mOrgMovableArea;
+    private Rect mOrgPreviewImageRect;
+    private Paint mPaint;
+    private float mPhase;
+    private float mPrevX;
+    private float mPrevY;
+    private Bitmap mPreviewImageBitmap;
+    private String mPreviewImageFile;
+    private int mPromptTextColor = -16776961;
+    private boolean mPromptTextDisplay;
+    private float mPromptTextSize = 10.0f;
+    private Bitmap mScanAreaCenterBitmap;
+    private int mScanAreaCornerLengthPixel;
+    private int mScanAreaCornerLogTapAreaWidthPixel;
+    private int mScanAreaCornerWidthPixel;
+    private boolean mScanAreaModified;
+    private int mScanAreaMoveMode;
+    private final Path mScanAreaPath = new Path();
+    private String mScanPromptString;
+    private TextPaint mTextPaint;
+
+    interface FlickCallback {
+        void flick(int i);
+    }
+
+    public boolean isScanAreaModified() {
+        return this.mMovableAreaMode && this.mScanAreaModified;
+    }
+
+    public Rect getMovableScanArea() {
+        return this.mOrgMovableArea;
+    }
+
+    public int[] getOrgContour() {
+        return new int[]{this.mOrgContourWidth, this.mOrgContourHeight};
+    }
+
+    public I2ScanAreaView(Context context) {
+        super(context);
+        init((AttributeSet) null, 0);
+    }
+
+    public I2ScanAreaView(Context context, AttributeSet attributeSet) {
+        super(context, attributeSet);
+        init(attributeSet, 0);
+    }
+
+    public I2ScanAreaView(Context context, AttributeSet attributeSet, int i) {
+        super(context, attributeSet, i);
+        init(attributeSet, i);
+    }
+
+    private void init(AttributeSet attributeSet, int i) {
+        TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attributeSet, C2135R.styleable.I2ScanAreaView, i, 0);
+        this.mScanPromptString = obtainStyledAttributes.getString(0);
+        this.mPromptTextColor = obtainStyledAttributes.getColor(1, this.mPromptTextColor);
+        this.mPromptTextSize = obtainStyledAttributes.getDimension(2, this.mPromptTextSize);
+        obtainStyledAttributes.recycle();
+        this.mTextPaint = new TextPaint();
+        this.mTextPaint.setFlags(1);
+        this.mTextPaint.setTextAlign(Paint.Align.LEFT);
+        this.mPaint = new Paint();
+        this.mPromptTextDisplay = true;
+        this.mScanAreaMoveMode = 0;
+        float f = getResources().getDisplayMetrics().density;
+        this.mScanAreaCornerLengthPixel = Math.round(30.0f * f);
+        this.mScanAreaCornerWidthPixel = Math.round(4.0f * f);
+        this.mScanAreaCornerLogTapAreaWidthPixel = Math.round(60.0f * f);
+        this.mScanAreaCenterBitmap = BitmapFactory.decodeResource(getResources(), C2135R.C2136drawable.area_center);
+        this.mDashInterval = new float[]{10.0f * f, 2.0f * f};
+        this.mDisplayDensity = f;
+        this.mScanAreaModified = false;
+        this.mGestureDetectorCompat = new GestureDetectorCompat(getContext(), this.mGestureListener);
+        invalidateTextPaintAndMeasurements();
+    }
+
+    public void setFlickCallback(FlickCallback flickCallback) {
+        this.mFlickCallback = flickCallback;
+    }
+
+    private void invalidateTextPaintAndMeasurements() {
+        this.mTextPaint.setTextSize(this.mPromptTextSize);
+        this.mTextPaint.setColor(this.mPromptTextColor);
+    }
+
+    /* access modifiers changed from: protected */
+    public void onSizeChanged(int i, int i2, int i3, int i4) {
+        super.onSizeChanged(i, i2, i3, i4);
+        calcDrawSize(i, i2);
+    }
+
+    private void calcDrawSize(int i, int i2) {
+        if (i != 0 && i2 != 0 && this.mOrgContourWidth != 0 && this.mOrgContourHeight != 0) {
+            int paddingLeft = (i - getPaddingLeft()) - getPaddingRight();
+            int paddingTop = (i2 - getPaddingTop()) - getPaddingBottom();
+            if (paddingLeft <= 0 || paddingTop <= 0) {
+                this.mDisplayContourArea = null;
+                return;
+            }
+            double max = Math.max(((double) this.mOrgContourWidth) / ((double) paddingLeft), ((double) this.mOrgContourHeight) / ((double) paddingTop));
+            this.mDisplayRate = max;
+            int i3 = (int) (((double) this.mOrgContourWidth) / max);
+            int i4 = (int) (((double) this.mOrgContourHeight) / max);
+            this.mDisplayContourArea = new Rect(0, 0, i3, i4);
+            this.mDisplayContourArea.offsetTo(getPaddingLeft() + ((paddingLeft - i3) / 2), getPaddingTop() + ((paddingTop - i4) / 2));
+            if (this.mMovableAreaMode) {
+                Rect rect = this.mOrgMovableArea;
+                if (rect != null) {
+                    this.mDisplayMovableArea = new Rect((int) Math.round(((double) rect.left) / max), (int) Math.round(((double) this.mOrgMovableArea.top) / max), (int) Math.round(((double) this.mOrgMovableArea.right) / max), (int) Math.round(((double) this.mOrgMovableArea.bottom) / max));
+                    this.mDisplayMovableArea.offset(this.mDisplayContourArea.left, this.mDisplayContourArea.top);
+                }
+            } else {
+                this.mDisplayMovableArea = null;
+            }
+            Rect rect2 = this.mOrgPreviewImageRect;
+            if (rect2 != null) {
+                this.mDisplayPreviewImageRect = new Rect((int) Math.round(((double) rect2.left) / max), (int) Math.round(((double) this.mOrgPreviewImageRect.top) / max), (int) Math.round(((double) this.mOrgPreviewImageRect.right) / max), (int) Math.round(((double) this.mOrgPreviewImageRect.bottom) / max));
+                if (!this.mMovableAreaMode) {
+                    this.mDisplayPreviewImageRect.offsetTo((this.mDisplayContourArea.width() - this.mDisplayPreviewImageRect.width()) / 2, 0);
+                }
+                this.mDisplayPreviewImageRect.offset(this.mDisplayContourArea.left, this.mDisplayContourArea.top);
+            }
+            readPreviewBitmap();
+            String str = this.mScanPromptString;
+            if (str != null && !str.isEmpty()) {
+                calcText(this.mDisplayContourArea);
+            }
+        }
+    }
+
+    private void calcText(Rect rect) {
+        float width = ((float) rect.width()) * 0.9f;
+        int length = this.mScanPromptString.length();
+        Rect rect2 = new Rect();
+        this.mBreakStrings = new ArrayList<>();
+        ArrayList arrayList = new ArrayList();
+        int i = 0;
+        float f = 0.0f;
+        while (i < length) {
+            int breakText = this.mTextPaint.breakText(this.mScanPromptString.substring(i, length), true, width, (float[]) null);
+            int i2 = i + breakText;
+            String substring = this.mScanPromptString.substring(i, i2);
+            this.mTextPaint.getTextBounds(substring, 0, breakText, rect2);
+            f += (float) rect2.height();
+            arrayList.add(Float.valueOf((float) rect2.height()));
+            this.mBreakStrings.add(substring);
+            i = i2;
+        }
+        this.mDisplayTextLeft = ((float) rect.left) + (width * 0.050000012f);
+        float height = ((float) rect.top) + ((((float) rect.height()) - f) / 2.0f);
+        this.mDisplayTextYPosition = new ArrayList<>();
+        Iterator it = arrayList.iterator();
+        while (it.hasNext()) {
+            this.mDisplayTextYPosition.add(Float.valueOf(height));
+            height += ((Float) it.next()).floatValue();
+        }
+    }
+
+    /* access modifiers changed from: protected */
+    public void onDraw(Canvas canvas) {
+        ArrayList<Float> arrayList;
+        super.onDraw(canvas);
+        if (this.mDisplayContourArea != null) {
+            this.mPaint.setColor(-1);
+            this.mPaint.setStyle(Paint.Style.FILL);
+            canvas.drawRect(this.mDisplayContourArea, this.mPaint);
+            Bitmap bitmap = this.mPreviewImageBitmap;
+            if (bitmap != null) {
+                canvas.drawBitmap(bitmap, (Rect) null, this.mDisplayPreviewImageRect, this.mPaint);
+            }
+            if (this.mDisplayMovableArea != null) {
+                drawScanArea(canvas);
+            }
+            if (this.mPromptTextDisplay && this.mScanPromptString != null && this.mPreviewImageBitmap == null && this.mBreakStrings != null && (arrayList = this.mDisplayTextYPosition) != null) {
+                Iterator<Float> it = arrayList.iterator();
+                Iterator<String> it2 = this.mBreakStrings.iterator();
+                while (it2.hasNext()) {
+                    String next = it2.next();
+                    if (it.hasNext()) {
+                        canvas.drawText(next, this.mDisplayTextLeft, it.next().floatValue(), this.mTextPaint);
+                    }
+                }
+            }
+        }
+    }
+
+    private void drawScanArea(Canvas canvas) {
+        if (this.mDisplayMovableArea != null) {
+            this.mPaint.setColor(ViewCompat.MEASURED_STATE_MASK);
+            if (this.mScanAreaMoveMode == 3) {
+                canvas.drawBitmap(this.mScanAreaCenterBitmap, (float) (this.mDisplayMovableArea.centerX() - (this.mScanAreaCenterBitmap.getWidth() / 2)), (float) (this.mDisplayMovableArea.centerY() - (this.mScanAreaCenterBitmap.getHeight() / 2)), this.mPaint);
+            }
+            this.mScanAreaPath.reset();
+            this.mScanAreaPath.moveTo((float) this.mDisplayMovableArea.left, (float) this.mDisplayMovableArea.top);
+            this.mScanAreaPath.lineTo((float) this.mDisplayMovableArea.left, (float) this.mDisplayMovableArea.bottom);
+            this.mScanAreaPath.lineTo((float) this.mDisplayMovableArea.right, (float) this.mDisplayMovableArea.bottom);
+            this.mScanAreaPath.lineTo((float) this.mDisplayMovableArea.right, (float) this.mDisplayMovableArea.top);
+            this.mScanAreaPath.close();
+            if (this.mScanAreaMoveMode > 0) {
+                this.mPaint.setPathEffect(new DashPathEffect(this.mDashInterval, this.mPhase));
+                this.mPhase += this.mDisplayDensity;
+                if (this.mPhase > 10000.0f) {
+                    this.mPhase = 0.0f;
+                }
+                postInvalidate();
+            } else {
+                this.mPaint.setPathEffect((PathEffect) null);
+            }
+            this.mPaint.setStyle(Paint.Style.STROKE);
+            this.mPaint.setStrokeWidth(1.0f);
+            canvas.drawPath(this.mScanAreaPath, this.mPaint);
+            int i = this.mScanAreaCornerWidthPixel;
+            int i2 = this.mScanAreaCornerLengthPixel;
+            if (this.mScanAreaMoveMode == 1) {
+                i *= 2;
+                i2 *= 2;
+            }
+            this.mPaint.setStrokeWidth((float) i);
+            this.mPaint.setPathEffect((PathEffect) null);
+            this.mPaint.setStrokeCap(Paint.Cap.SQUARE);
+            int i3 = i / 2;
+            int i4 = this.mDisplayMovableArea.left - i3;
+            int i5 = this.mDisplayMovableArea.top - i3;
+            float f = (float) i4;
+            float f2 = (float) i5;
+            Canvas canvas2 = canvas;
+            float f3 = f;
+            float f4 = f2;
+            canvas2.drawLine(f3, f4, (float) (i4 + i2), f2, this.mPaint);
+            canvas2.drawLine(f3, f4, f, (float) (i5 + i2), this.mPaint);
+            int i6 = this.mScanAreaCornerWidthPixel;
+            int i7 = this.mScanAreaCornerLengthPixel;
+            if (this.mScanAreaMoveMode == 2) {
+                i6 *= 2;
+                i7 *= 2;
+            }
+            this.mPaint.setStrokeWidth((float) i6);
+            int i8 = i6 / 2;
+            int i9 = this.mDisplayMovableArea.right + i8;
+            int i10 = this.mDisplayMovableArea.bottom + i8;
+            float f5 = (float) i9;
+            float f6 = (float) i10;
+            Canvas canvas3 = canvas;
+            float f7 = f5;
+            float f8 = f6;
+            canvas3.drawLine(f7, f8, f5, (float) (i10 - i7), this.mPaint);
+            canvas3.drawLine(f7, f8, (float) (i9 - i7), f6, this.mPaint);
+        }
+    }
+
+    public boolean onTouchEvent(MotionEvent motionEvent) {
+        if (this.mScanAreaMoveMode > 0) {
+            if (checkTouchEvent(motionEvent) || super.onTouchEvent(motionEvent)) {
+                return true;
+            }
+            return false;
+        } else if (this.mGestureDetectorCompat.onTouchEvent(motionEvent) || super.onTouchEvent(motionEvent)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private boolean checkTouchEvent(MotionEvent motionEvent) {
+        switch (motionEvent.getAction()) {
+            case 0:
+                return true;
+            case 1:
+                if (this.mScanAreaMoveMode <= 0) {
+                    return false;
+                }
+                this.mScanAreaMoveMode = 0;
+                updateOrgScanArea();
+                postInvalidate();
+                return true;
+            case 2:
+                return moveScanArea(motionEvent.getX(), motionEvent.getY());
+            default:
+                return false;
+        }
+    }
+
+    private void updateOrgScanArea() {
+        Rect rect = this.mDisplayMovableArea;
+        if (rect != null) {
+            Rect rect2 = this.mOrgMovableArea;
+            rect2.left = 0;
+            rect2.top = 0;
+            rect2.right = (int) Math.round(((double) (rect.width() - 1)) * this.mDisplayRate);
+            this.mOrgMovableArea.bottom = (int) Math.round(((double) (this.mDisplayMovableArea.height() - 1)) * this.mDisplayRate);
+            this.mOrgMovableArea.offsetTo((int) Math.round(((double) (this.mDisplayMovableArea.left - this.mDisplayContourArea.left)) * this.mDisplayRate), (int) Math.round(((double) (this.mDisplayMovableArea.top - this.mDisplayContourArea.top)) * this.mDisplayRate));
+        }
+    }
+
+    private boolean moveScanArea(float f, float f2) {
+        if (this.mDisplayMovableArea == null) {
+            return false;
+        }
+        int round = Math.round(f - this.mPrevX);
+        int round2 = Math.round(f2 - this.mPrevY);
+        switch (this.mScanAreaMoveMode) {
+            case 1:
+                this.mDisplayMovableArea.left += round;
+                this.mDisplayMovableArea.top += round2;
+                break;
+            case 2:
+                this.mDisplayMovableArea.right += round;
+                this.mDisplayMovableArea.bottom += round2;
+                break;
+            case 3:
+                this.mDisplayMovableArea.left += round;
+                this.mDisplayMovableArea.top += round2;
+                this.mDisplayMovableArea.right += round;
+                this.mDisplayMovableArea.bottom += round2;
+                break;
+            default:
+                return false;
+        }
+        if (this.mDisplayMovableArea.left > this.mDisplayMovableArea.right) {
+            int i = this.mDisplayMovableArea.left;
+            Rect rect = this.mDisplayMovableArea;
+            rect.left = rect.right;
+            this.mDisplayMovableArea.right = i;
+        }
+        if (this.mDisplayMovableArea.top > this.mDisplayMovableArea.bottom) {
+            int i2 = this.mDisplayMovableArea.top;
+            Rect rect2 = this.mDisplayMovableArea;
+            rect2.top = rect2.bottom;
+            this.mDisplayMovableArea.bottom = i2;
+        }
+        if (this.mDisplayMovableArea.left < 0) {
+            this.mDisplayMovableArea.left = 0;
+        }
+        if (this.mDisplayMovableArea.top < 0) {
+            this.mDisplayMovableArea.top = 0;
+        }
+        if (this.mDisplayMovableArea.right >= getWidth()) {
+            this.mDisplayMovableArea.right = getWidth() - 1;
+        }
+        if (this.mDisplayMovableArea.bottom >= getHeight()) {
+            this.mDisplayMovableArea.bottom = getHeight() - 1;
+        }
+        this.mPrevX = f;
+        this.mPrevY = f2;
+        postInvalidate();
+        return false;
+    }
+
+    public String getPromptString() {
+        return this.mScanPromptString;
+    }
+
+    public void setPromptString(String str) {
+        this.mScanPromptString = str;
+        invalidateTextPaintAndMeasurements();
+    }
+
+    public int getPromptTextColor() {
+        return this.mPromptTextColor;
+    }
+
+    public void setPromptTextColor(int i) {
+        this.mPromptTextColor = i;
+        invalidateTextPaintAndMeasurements();
+    }
+
+    public float getPromptTextSize() {
+        return this.mPromptTextSize;
+    }
+
+    public void setPromptTextSize(float f) {
+        this.mPromptTextSize = f;
+        invalidateTextPaintAndMeasurements();
+    }
+
+    public void setPromptStringVisibility(int i) {
+        this.mPromptTextDisplay = i == 0;
+        invalidate();
+    }
+
+    public void setArea(int i, int i2) {
+        this.mScanAreaModified = false;
+        this.mOrgContourWidth = i;
+        this.mOrgContourHeight = i2;
+        this.mMovableAreaMode = false;
+        calcDrawSize(getWidth(), getHeight());
+    }
+
+    public void setMovableAreaModeSize(int i, int i2, Rect rect) {
+        this.mScanAreaModified = false;
+        this.mOrgContourWidth = i;
+        this.mOrgContourHeight = i2;
+        this.mMovableAreaMode = true;
+        this.mOrgMovableArea = new Rect(rect);
+        calcDrawSize(getWidth(), getHeight());
+    }
+
+    public void setPreviewImage(String str, int[] iArr) {
+        this.mPreviewImageFile = str;
+        if (str == null || iArr == null || iArr.length < 4) {
+            this.mOrgPreviewImageRect = null;
+            this.mPreviewImageBitmap = null;
+        } else {
+            this.mOrgPreviewImageRect = new Rect(iArr[2], iArr[3], iArr[2] + iArr[0], iArr[3] + iArr[1]);
+        }
+        calcDrawSize(getWidth(), getHeight());
+    }
+
+    public void setPreviewImage(String str) {
+        this.mPreviewImageFile = str;
+        if (this.mMovableAreaMode) {
+            this.mOrgPreviewImageRect = new Rect(this.mOrgMovableArea);
+        } else {
+            this.mOrgPreviewImageRect = new Rect(0, 0, this.mOrgContourWidth, this.mOrgContourHeight);
+        }
+        calcDrawSize(getWidth(), getHeight());
+    }
+
+    private void readPreviewBitmap() {
+        String str = this.mPreviewImageFile;
+        if (str == null) {
+            this.mPreviewImageBitmap = null;
+        } else {
+            this.mPreviewImageBitmap = ImageUtil.loadBitmap(str, this.mDisplayPreviewImageRect.width(), this.mDisplayPreviewImageRect.height(), true, false);
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void checkFlick(float f) {
+        if (this.mFlickCallback != null) {
+            float min = ((float) Math.min(getWidth(), getHeight())) * 0.1f;
+            if (f < (-min)) {
+                this.mFlickCallback.flick(1);
+            } else if (f > min) {
+                this.mFlickCallback.flick(-1);
+            }
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public boolean checkMoveMode(float f, float f2) {
+        Rect rect = this.mDisplayMovableArea;
+        if (rect == null) {
+            return false;
+        }
+        this.mPrevX = f;
+        this.mPrevY = f2;
+        if (Math.hypot((double) (((float) rect.left) - f), (double) (((float) this.mDisplayMovableArea.top) - f2)) < ((double) this.mScanAreaCornerLogTapAreaWidthPixel)) {
+            this.mScanAreaMoveMode = 1;
+        } else if (Math.hypot((double) (((float) this.mDisplayMovableArea.right) - f), (double) (((float) this.mDisplayMovableArea.bottom) - f2)) < ((double) this.mScanAreaCornerLogTapAreaWidthPixel)) {
+            this.mScanAreaMoveMode = 2;
+        } else if (f < ((float) this.mDisplayMovableArea.left) || f > ((float) this.mDisplayMovableArea.right) || f2 < ((float) this.mDisplayMovableArea.top) || f2 > ((float) this.mDisplayMovableArea.bottom)) {
+            return false;
+        } else {
+            this.mScanAreaMoveMode = 3;
+        }
+        this.mScanAreaModified = true;
+        postInvalidate();
+        return true;
+    }
+}

+ 480 - 0
app/src/main/java/epson/scan/activity/I2ScanSettingActivity.java

@@ -0,0 +1,480 @@
+package epson.scan.activity;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+import com.epson.iprint.shared.SharedParamScan;
+import com.epson.lib.escani2.EscanI2Lib;
+import com.epson.lib.escani2.ScanI2Params;
+import epson.print.ActivityIACommon;
+import epson.print.C2135R;
+import epson.print.EPPrinterManager;
+import epson.scan.activity.ModeListAdapter;
+import epson.scan.activity.StringListAdapter;
+import epson.scan.i2lib.I2ScanParamArbiter;
+import epson.scan.i2lib.I2ScanParamManager;
+import java.io.IOException;
+import java.util.Locale;
+
+public class I2ScanSettingActivity extends ActivityIACommon implements View.OnClickListener {
+    private static final String PARAM_KEY_EXTERNAL_SCAN_PARAMS = "external-scan-params";
+    private static final String PARAM_KEY_HIDE_COLOR_MODE = "hide-color-mode";
+    private static final String PARAM_KEY_HIDE_RESOLUTION = "hide-resolution";
+    private static final int REQUEST_CODE_CHANGE_ESC_I_VERSION = 100;
+    private static final int REQUEST_CODE_SELECT_BRIGHTNESS = 8;
+    private static final int REQUEST_CODE_SELECT_COLOR_MODE = 3;
+    private static final int REQUEST_CODE_SELECT_DUPLEX = 5;
+    private static final int REQUEST_CODE_SELECT_GAMMA = 6;
+    private static final int REQUEST_CODE_SELECT_INPUT_UNIT = 1;
+    private static final int REQUEST_CODE_SELECT_RESOLUTION = 4;
+    private static final int REQUEST_CODE_SELECT_SCANNER = 7;
+    private static final int REQUEST_CODE_SELECT_SCAN_SIZE = 2;
+    private static final String RETURN_KEY_OLD_PREVIEW_VALID = "old-preview-valid";
+    private View mBrightnessSeparator;
+    private TextView mBrightnessText;
+    private View mBrightnessViewGroup;
+    private View mColorModeSeparator;
+    private TextView mColorModeText;
+    private View mColorModeViewGroup;
+    private View mDuplexSeparator;
+    private TextView mDuplexText;
+    private View mDuplexViewGroup;
+    private SharedParamScan mExternalScanParams;
+    private TextView mGammaText;
+    private View mGammaViewGroup;
+    private boolean mHideColorMode;
+    private boolean mHideResolutionMode;
+    private I2ScanParamArbiter mI2ScanParamArbiter;
+    private View mInputUnitSeparator;
+    private TextView mInputUnitText;
+    private View mInputUnitViewGroup;
+    private ImageView mPrinterLocationIcon;
+    private View mProgressBarLayout;
+    private TextView mScanResolutionText;
+    private View mScanResolutionViewGroup;
+    private boolean mScanSizeSelected;
+    private View mScanSizeSeparator;
+    private TextView mScanSizeText;
+    private View mScanSizeViewGroup;
+    private boolean mScannerChanged;
+    private TextView mScannerNameText;
+    private View mScannerNameViewGroup;
+    private ScannerPropertyWrapper mScannerPropertyWrapper;
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        this.mI2ScanParamArbiter = new I2ScanParamArbiter();
+        this.mScanSizeSelected = false;
+        setContentView((int) C2135R.layout.activity_i2_scan_setting);
+        setActionBar((int) C2135R.string.str_lbl_title_scan_settings, true);
+        this.mScannerNameViewGroup = findViewById(C2135R.C2137id.llScannerName);
+        this.mScannerNameViewGroup.setOnClickListener(this);
+        this.mScannerNameText = (TextView) findViewById(C2135R.C2137id.tvScannerName);
+        this.mPrinterLocationIcon = (ImageView) findViewById(C2135R.C2137id.imageViewPrinterLocation);
+        this.mInputUnitViewGroup = findViewById(C2135R.C2137id.llScanSettingsSource);
+        this.mInputUnitViewGroup.setOnClickListener(this);
+        this.mInputUnitText = (TextView) findViewById(C2135R.C2137id.tvScannerSource);
+        this.mScanSizeViewGroup = findViewById(C2135R.C2137id.llScanSettingsSize);
+        this.mScanSizeViewGroup.setOnClickListener(this);
+        this.mScanSizeText = (TextView) findViewById(C2135R.C2137id.tvScannerSize);
+        this.mScanSizeSeparator = findViewById(C2135R.C2137id.scanSizeSeparator);
+        this.mColorModeViewGroup = findViewById(C2135R.C2137id.llScanSettingsColor);
+        this.mColorModeViewGroup.setOnClickListener(this);
+        this.mColorModeText = (TextView) findViewById(C2135R.C2137id.tvScannerColor);
+        this.mColorModeSeparator = findViewById(C2135R.C2137id.colorModeSeparator);
+        this.mScanResolutionViewGroup = findViewById(C2135R.C2137id.llScanSettingsResolution);
+        this.mScanResolutionViewGroup.setOnClickListener(this);
+        this.mScanResolutionText = (TextView) findViewById(C2135R.C2137id.tvScannerResolution);
+        this.mDuplexViewGroup = findViewById(C2135R.C2137id.llScanSettingsAdvance2Sided);
+        this.mDuplexViewGroup.setOnClickListener(this);
+        this.mDuplexText = (TextView) findViewById(C2135R.C2137id.tvScanner2Sided);
+        this.mBrightnessViewGroup = findViewById(C2135R.C2137id.llScanSettingsDensity);
+        this.mBrightnessViewGroup.setVisibility(8);
+        this.mBrightnessViewGroup.setOnClickListener(this);
+        this.mBrightnessText = (TextView) findViewById(C2135R.C2137id.tvScannerDensity);
+        findViewById(C2135R.C2137id.brightnessSeparator).setVisibility(8);
+        this.mGammaViewGroup = findViewById(C2135R.C2137id.llScanSettingsGamma);
+        this.mGammaViewGroup.setOnClickListener(this);
+        this.mGammaText = (TextView) findViewById(C2135R.C2137id.tvScannerGamma);
+        this.mInputUnitSeparator = findViewById(C2135R.C2137id.viewScanSettingsSource);
+        this.mDuplexSeparator = findViewById(C2135R.C2137id.viewScanSettingsAdvance2Sided);
+        this.mBrightnessSeparator = findViewById(C2135R.C2137id.brightnessSeparator);
+        this.mProgressBarLayout = findViewById(C2135R.C2137id.progressGetOption);
+        setFieldFromIntent(getIntent());
+        if (!readEscIVersionChangeIntent(getIntent())) {
+            loadData();
+        }
+        updateScanParamDisplay();
+    }
+
+    private void setFieldFromIntent(@Nullable Intent intent) {
+        if (intent == null) {
+            this.mHideColorMode = false;
+            this.mHideResolutionMode = false;
+            this.mExternalScanParams = null;
+        }
+        this.mHideColorMode = intent.getBooleanExtra("hide-color-mode", false);
+        this.mHideResolutionMode = intent.getBooleanExtra("hide-resolution", false);
+        this.mExternalScanParams = (SharedParamScan) intent.getSerializableExtra("external-scan-params");
+    }
+
+    private boolean readEscIVersionChangeIntent(Intent intent) {
+        if (intent == null) {
+            return false;
+        }
+        this.mScannerPropertyWrapper = SettingActivityParams.getScannerPropertyWrapper(intent);
+        ScannerPropertyWrapper scannerPropertyWrapper = this.mScannerPropertyWrapper;
+        if (scannerPropertyWrapper == null || scannerPropertyWrapper.getEscIVersion() != 2) {
+            return false;
+        }
+        this.mScannerChanged = true;
+        this.mI2ScanParamArbiter.notifyScannerChanged(this, this.mScannerPropertyWrapper.getI2ScannerAllInfo());
+        return true;
+    }
+
+    private void loadData() {
+        this.mScannerPropertyWrapper = ScannerPropertyWrapper.load(this);
+        this.mI2ScanParamArbiter.makeSelectionList(this, this.mScannerPropertyWrapper.getI2ScannerAllInfo(), I2ScanParamManager.loadScanI2Params(this));
+    }
+
+    private void hideProgress() {
+        this.mProgressBarLayout.setVisibility(8);
+    }
+
+    private void updateScanParamDisplay() {
+        updateScannerName();
+        displayScannerLocationIcon();
+        updateInputUnitDisplay();
+        updateScanSize();
+        updateImageType();
+        updateResolution();
+        updateDuplexDisplay();
+        updateGammaDisplay();
+        updateBrightnessDisplay();
+        updateScanSizeSeparator();
+    }
+
+    private void updateScanSizeSeparator() {
+        this.mScanSizeSeparator.setVisibility((this.mColorModeViewGroup.getVisibility() == 0 || this.mScanResolutionViewGroup.getVisibility() == 0) ? 0 : 8);
+    }
+
+    private void displayScannerLocationIcon() {
+        String modelName = this.mScannerPropertyWrapper.getModelName();
+        if (modelName == null || modelName.isEmpty()) {
+            this.mPrinterLocationIcon.setVisibility(8);
+            return;
+        }
+        this.mPrinterLocationIcon.setVisibility(0);
+        int i = C2135R.C2136drawable.print_local;
+        if (this.mScannerPropertyWrapper.getLocation() == 3) {
+            i = C2135R.C2136drawable.print_ip;
+        }
+        this.mPrinterLocationIcon.setImageResource(i);
+    }
+
+    private void updateScannerName() {
+        String ipPrinterUserName;
+        if (this.mScannerPropertyWrapper.getLocation() != 3 || (ipPrinterUserName = new EPPrinterManager(this).getIpPrinterUserName(this.mScannerPropertyWrapper.getScannerId())) == null) {
+            String modelName = this.mScannerPropertyWrapper.getModelName();
+            if (modelName == null || modelName.isEmpty()) {
+                this.mScannerNameText.setText(C2135R.string.str_lbl_title_scan);
+            } else {
+                this.mScannerNameText.setText(modelName);
+            }
+        } else {
+            this.mScannerNameText.setText(ipPrinterUserName);
+        }
+    }
+
+    private void updateInputUnitDisplay() {
+        int i = this.mI2ScanParamArbiter.getInputUnitCandidates().length <= 1 ? 8 : 0;
+        this.mInputUnitViewGroup.setVisibility(i);
+        this.mInputUnitSeparator.setVisibility(i);
+        this.mInputUnitText.setText(DisplayIdConverter.getInputUnitStringId(this.mI2ScanParamArbiter.getInputUnit()));
+    }
+
+    private void updateScanSize() {
+        if (this.mScanSizeSelected) {
+            this.mScanSizeText.setText(DisplayIdConverter.getScanSizeStringId(this.mI2ScanParamArbiter.getScanSize()));
+            return;
+        }
+        this.mScanSizeText.setText(C2135R.string.str_settings_undefine_scansize);
+    }
+
+    private void updateImageType() {
+        if (this.mHideColorMode) {
+            this.mColorModeViewGroup.setVisibility(8);
+            this.mColorModeSeparator.setVisibility(8);
+            return;
+        }
+        this.mColorModeViewGroup.setVisibility(0);
+        this.mColorModeSeparator.setVisibility(0);
+        int colorStringId = DisplayIdConverter.getColorStringId(this.mI2ScanParamArbiter.getColorMode());
+        if (colorStringId == 0) {
+            colorStringId = C2135R.string.str_blank;
+        }
+        this.mColorModeText.setText(colorStringId);
+    }
+
+    private void updateResolution() {
+        if (this.mHideResolutionMode) {
+            this.mScanResolutionViewGroup.setVisibility(8);
+            return;
+        }
+        this.mScanResolutionViewGroup.setVisibility(0);
+        this.mScanResolutionText.setText(DisplayIdConverter.getScanResolutionStrings((Context) this, this.mI2ScanParamArbiter.getResolution().intValue()));
+    }
+
+    private void updateDuplexDisplay() {
+        int i = this.mI2ScanParamArbiter.isDuplexSupported() ? 0 : 8;
+        this.mDuplexSeparator.setVisibility(i);
+        this.mDuplexViewGroup.setVisibility(i);
+        this.mDuplexText.setText(DisplayIdConverter.getYesNoStringId(this, this.mI2ScanParamArbiter.getDuplex().booleanValue()));
+    }
+
+    private void updateBrightnessDisplay() {
+        int i = this.mI2ScanParamArbiter.getColorMode() == EscanI2Lib.ColorMode.MONO_1BIT ? 0 : 8;
+        SharedParamScan sharedParamScan = this.mExternalScanParams;
+        if (sharedParamScan != null) {
+            i = sharedParamScan.getScan_type() == 3 ? 0 : 8;
+        }
+        this.mBrightnessViewGroup.setVisibility(i);
+        this.mBrightnessSeparator.setVisibility(i);
+        if (i == 0) {
+            this.mBrightnessText.setText(String.format(Locale.US, "%d", new Object[]{Integer.valueOf(255 - this.mI2ScanParamArbiter.getDensity())}));
+        }
+    }
+
+    private void updateGammaDisplay() {
+        this.mGammaText.setText(DisplayIdConverter.getGammaStringId(this.mI2ScanParamArbiter.getGamma()));
+    }
+
+    public boolean onCreateOptionsMenu(Menu menu) {
+        getMenuInflater().inflate(C2135R.C2138menu.menu_done, menu);
+        return true;
+    }
+
+    public boolean onOptionsItemSelected(MenuItem menuItem) {
+        if (menuItem.getItemId() != C2135R.C2137id.menuSettingsDone) {
+            return super.onOptionsItemSelected(menuItem);
+        }
+        saveSettingsAndFinish();
+        return true;
+    }
+
+    private void saveSettingsAndFinish() {
+        try {
+            ScanI2Params scanParam = this.mI2ScanParamArbiter.getScanParam();
+            boolean isOldPreviewValid = isOldPreviewValid(this.mScannerPropertyWrapper, scanParam);
+            I2ScanParamManager.saveParams(this, scanParam);
+            this.mScannerPropertyWrapper.saveData(this, this.mScannerChanged);
+            new EPPrinterManager(this).commitIPPrinterInfo();
+            Intent intent = new Intent();
+            intent.putExtra(RETURN_KEY_OLD_PREVIEW_VALID, isOldPreviewValid);
+            setResult(-1, intent);
+            finish();
+        } catch (IOException unused) {
+        }
+    }
+
+    private boolean isOldPreviewValid(ScannerPropertyWrapper scannerPropertyWrapper, ScanI2Params scanI2Params) {
+        ScannerPropertyWrapper load = ScannerPropertyWrapper.load(this);
+        if (scannerPropertyWrapper.getEscIVersion() != scannerPropertyWrapper.getEscIVersion() || !load.getModelName().equals(scannerPropertyWrapper.getModelName())) {
+            return false;
+        }
+        ScanI2Params loadScanI2Params = I2ScanParamManager.loadScanI2Params(this);
+        if (loadScanI2Params.inputUnit == scanI2Params.inputUnit && loadScanI2Params.colorMode == scanI2Params.colorMode && loadScanI2Params.resolutionMain == scanI2Params.resolutionMain && loadScanI2Params.resolutionSub == scanI2Params.resolutionSub && loadScanI2Params.duplexTurnDirection == scanI2Params.duplexTurnDirection && loadScanI2Params.duplex == scanI2Params.duplex && loadScanI2Params.manualAdfAlignment == scanI2Params.manualAdfAlignment && loadScanI2Params.density == scanI2Params.density && loadScanI2Params.userGamma == scanI2Params.userGamma) {
+            return true;
+        }
+        return false;
+    }
+
+    public void onBackPressed() {
+        new EPPrinterManager(this).rollbackIPPrinterInfo();
+        super.onBackPressed();
+    }
+
+    public void onClick(View view) {
+        int id = view.getId();
+        if (id == C2135R.C2137id.llScannerName) {
+            startSelectScannerActivity();
+        } else if (id == C2135R.C2137id.llScanSettingsSource) {
+            goInputUnitSelection();
+        } else if (id == C2135R.C2137id.llScanSettingsSize) {
+            goScanSizeSelection();
+        } else if (id == C2135R.C2137id.llScanSettingsColor) {
+            goImageTypeSelection();
+        } else if (id == C2135R.C2137id.llScanSettingsResolution) {
+            goScanResolutionSelection();
+        } else if (id == C2135R.C2137id.llScanSettingsAdvance2Sided) {
+            goDuplicateSelection();
+        } else if (id == C2135R.C2137id.llScanSettingsDensity) {
+            goBrightnessSelection();
+        } else if (id == C2135R.C2137id.llScanSettingsGamma) {
+            goGammaSelection();
+        }
+    }
+
+    private void startSelectScannerActivity() {
+        startActivityForResult(ScanSearchActivity.getStartIntent(this, this.mScannerPropertyWrapper.getScannerId(), this.mScannerPropertyWrapper.getLocation(), this.mScannerPropertyWrapper.getSimpleApSsid()), 7);
+    }
+
+    private void goImageTypeSelection() {
+        startActivityForResult(I2SettingDetailActivity.getStartIntent(this, new ModeListAdapter.Builder(DisplayIdConverter.getColorModeItemIdArray(this.mI2ScanParamArbiter.getColorModeCandidates()), this.mI2ScanParamArbiter.getColorModePosition()), C2135R.string.str_settings_color_title), 3);
+    }
+
+    private void goInputUnitSelection() {
+        startActivityForResult(InputUnitSettingActivity.getStartIntent(this, this.mI2ScanParamArbiter.getInputUnit() == EscanI2Lib.InputUnit.ADF ? 1 : 0, this.mI2ScanParamArbiter.isAdfAlignmentMenuValid() ? this.mI2ScanParamArbiter.getManualAdfAlignmentValue() : -1), 1);
+    }
+
+    private void goScanSizeSelection() {
+        startActivityForResult(I2SettingDetailActivity.getStartIntent(this, new ModeListAdapter.Builder(DisplayIdConverter.getScanSizeIdArray(this.mI2ScanParamArbiter.getScanSizeCandidates()), this.mScanSizeSelected ? this.mI2ScanParamArbiter.getScanSizePosition() : -1), C2135R.string.str_scanning_size), 2);
+    }
+
+    private void goScanResolutionSelection() {
+        startActivityForResult(I2SettingDetailActivity.getStartIntent(this, new StringListAdapter.Builder(DisplayIdConverter.getScanResolutionStrings((Context) this, this.mI2ScanParamArbiter.getResolutionCandidates()), this.mI2ScanParamArbiter.getResolutionPosition()), C2135R.string.str_settings_resolution_title), 4);
+    }
+
+    private void goDuplicateSelection() {
+        startActivityForResult(I2DoubleSideScanSettingActivity.getStartIntent(this, this.mI2ScanParamArbiter.getDuplex().booleanValue(), this.mI2ScanParamArbiter.getDuplexTurnDirection()), 5);
+    }
+
+    private void goBrightnessSelection() {
+        startActivityForResult(ScanSettingsAdvanceDensityActivity.getStartIntent(this, this.mI2ScanParamArbiter.getDensity(), this.mI2ScanParamArbiter.getDensityChangeable()), 8);
+    }
+
+    private void goGammaSelection() {
+        startActivityForResult(I2SettingDetailActivity.getStartIntent(this, new ModeListAdapter.Builder(DisplayIdConverter.getGammaStringIdArray(this, this.mI2ScanParamArbiter.getGammaCandidates()), this.mI2ScanParamArbiter.getGammaPosition()), C2135R.string.str_settings_gamma_title), 6);
+    }
+
+    /* access modifiers changed from: protected */
+    public void onActivityResult(int i, int i2, Intent intent) {
+        if (i != 100) {
+            switch (i) {
+                case 1:
+                    this.mI2ScanParamArbiter.setInputUnitPosition(InputUnitSettingActivity.getInputUnit(intent));
+                    int adfAlignment = InputUnitSettingActivity.getAdfAlignment(intent);
+                    if (adfAlignment != -1) {
+                        this.mI2ScanParamArbiter.setManualAdfAlignmentValue(adfAlignment);
+                    }
+                    updateScanParamDisplay();
+                    return;
+                case 2:
+                    if (i2 == -1 && intent != null) {
+                        this.mScanSizeSelected = true;
+                        this.mI2ScanParamArbiter.setScanSizePosition(I2SettingDetailActivity.getResultPosition(intent));
+                        updateScanParamDisplay();
+                        return;
+                    }
+                    return;
+                case 3:
+                    if (i2 == -1 && intent != null) {
+                        this.mI2ScanParamArbiter.setColorModePosition(I2SettingDetailActivity.getResultPosition(intent));
+                        updateScanParamDisplay();
+                        return;
+                    }
+                    return;
+                case 4:
+                    if (i2 == -1 && intent != null) {
+                        this.mI2ScanParamArbiter.setResolutionPosition(I2SettingDetailActivity.getResultPosition(intent));
+                        updateScanParamDisplay();
+                        return;
+                    }
+                    return;
+                case 5:
+                    if (i2 == -1 && intent != null) {
+                        this.mI2ScanParamArbiter.setDuplexValue(I2DoubleSideScanSettingActivity.getDoubleSideFromReturnIntent(intent));
+                        this.mI2ScanParamArbiter.setDuplexTurnDirection(I2DoubleSideScanSettingActivity.getTurnDirectionFromReturnIntent(intent));
+                        updateScanParamDisplay();
+                        return;
+                    }
+                    return;
+                case 6:
+                    if (i2 == -1 && intent != null) {
+                        this.mI2ScanParamArbiter.setGammaPosition(I2SettingDetailActivity.getResultPosition(intent));
+                        updateScanParamDisplay();
+                        return;
+                    }
+                    return;
+                case 7:
+                    onScannerSelectResult(i2, intent);
+                    return;
+                case 8:
+                    if (i2 == -1 && intent != null) {
+                        this.mI2ScanParamArbiter.setDensity(ScanSettingsAdvanceDensityActivity.getDensityFromReturnIntent(intent), ScanSettingsAdvanceDensityActivity.getChangeAble(intent));
+                        updateScanParamDisplay();
+                        return;
+                    }
+                    return;
+                default:
+                    return;
+            }
+        } else if (i2 == 1) {
+            onScannerSelectResult(-1, intent);
+        } else {
+            setResult(i2, intent);
+            finish();
+        }
+    }
+
+    private void onScannerSelectResult(int i, Intent intent) {
+        if (i != -1) {
+            updateIfIpAddressPrinter();
+            if (!this.mScannerPropertyWrapper.isPrinterSet()) {
+                transitI1SettingActivity();
+                return;
+            }
+            return;
+        }
+        this.mScannerChanged = true;
+        this.mScanSizeSelected = false;
+        this.mScannerPropertyWrapper = SettingActivityParams.getScannerPropertyWrapper(intent);
+        ScannerPropertyWrapper scannerPropertyWrapper = this.mScannerPropertyWrapper;
+        if (scannerPropertyWrapper == null) {
+            transitI1SettingActivity();
+        } else if (scannerPropertyWrapper.getEscIVersion() != 2) {
+            transitI1SettingActivity();
+        } else {
+            this.mI2ScanParamArbiter.notifyScannerChanged(this, this.mScannerPropertyWrapper.getI2ScannerAllInfo());
+            updateScanParamDisplay();
+        }
+    }
+
+    private void transitI1SettingActivity() {
+        if (SettingActivityParams.returnIfEscIVersionChanged(getIntent())) {
+            setResult(1, SettingActivityParams.getSettingReturnIntent(this.mScannerPropertyWrapper));
+            finish();
+            return;
+        }
+        startActivityForResult(SettingActivityParams.getChangeSettingActivityStartIntent(this, this.mScannerPropertyWrapper, true, this.mHideColorMode, this.mHideResolutionMode, this.mExternalScanParams), 100);
+    }
+
+    private void updateIfIpAddressPrinter() {
+        if (this.mScannerPropertyWrapper.getLocation() == 3 && !new EPPrinterManager(this).doseContainScannerIdInIpPrinterList(this.mScannerPropertyWrapper.getScannerId())) {
+            this.mScannerPropertyWrapper.resetScanner();
+            this.mI2ScanParamArbiter.tmpReset();
+            updateScanParamDisplay();
+        }
+    }
+
+    public static boolean getOldDataValidation(@Nullable Intent intent) {
+        return intent == null || intent.getBooleanExtra(RETURN_KEY_OLD_PREVIEW_VALID, false);
+    }
+
+    @NonNull
+    public static Intent getStartIntent(Context context, boolean z, boolean z2, @Nullable SharedParamScan sharedParamScan) {
+        Intent intent = new Intent(context, I2ScanSettingActivity.class);
+        intent.putExtra("hide-color-mode", z);
+        intent.putExtra("hide-resolution", z2);
+        intent.putExtra("external-scan-params", sharedParamScan);
+        return intent;
+    }
+}

+ 68 - 0
app/src/main/java/epson/scan/activity/I2SettingDetailActivity.java

@@ -0,0 +1,68 @@
+package epson.scan.activity;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ListAdapter;
+import android.widget.ListView;
+import epson.print.ActivityIACommon;
+import epson.print.C2135R;
+
+public class I2SettingDetailActivity extends ActivityIACommon {
+    private static final String KEY_ADAPTOR = "adaptor";
+    private static final String KEY_TITLE = "title";
+    private static final String RESULT_KEY_SELECTED = "selected-position";
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        setContentView((int) C2135R.layout.activity_i2_setting_detail);
+        setActionBar(getTitle().toString(), true);
+        ListView listView = (ListView) findViewById(C2135R.C2137id.listView);
+        Intent intent = getIntent();
+        LocalListAdapterBuilder localListAdapterBuilder = (LocalListAdapterBuilder) intent.getSerializableExtra(KEY_ADAPTOR);
+        if (localListAdapterBuilder != null) {
+            ListAdapter build = localListAdapterBuilder.build(this);
+            if (build != null) {
+                listView.setAdapter(build);
+                listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+                    public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
+                        I2SettingDetailActivity.this.localItemSelected(i);
+                    }
+                });
+                int intExtra = intent.getIntExtra(KEY_TITLE, 0);
+                if (intExtra != 0) {
+                    setTitle(intExtra);
+                    return;
+                }
+                return;
+            }
+            throw new IllegalArgumentException();
+        }
+        throw new IllegalArgumentException("intent extra 'adaptor' == null.");
+    }
+
+    /* access modifiers changed from: private */
+    public void localItemSelected(int i) {
+        Intent intent = new Intent();
+        intent.putExtra(RESULT_KEY_SELECTED, i);
+        setResult(-1, intent);
+        finish();
+    }
+
+    public static Intent getStartIntent(Context context, LocalListAdapterBuilder localListAdapterBuilder, int i) {
+        Intent intent = new Intent(context, I2SettingDetailActivity.class);
+        intent.putExtra(KEY_ADAPTOR, localListAdapterBuilder);
+        intent.putExtra(KEY_TITLE, i);
+        return intent;
+    }
+
+    public static int getResultPosition(Intent intent) {
+        if (intent == null) {
+            return -1;
+        }
+        return intent.getIntExtra(RESULT_KEY_SELECTED, -1);
+    }
+}

+ 138 - 0
app/src/main/java/epson/scan/activity/InputUnitSettingActivity.java

@@ -0,0 +1,138 @@
+package epson.scan.activity;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ListView;
+import epson.common.Constants;
+import epson.common.CustomListRowAdapter;
+import epson.common.CustomListRowImpl;
+import epson.print.ActivityIACommon;
+import epson.print.C2135R;
+import epson.scan.activity.ScanSettingsDetailAdapter;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+public class InputUnitSettingActivity extends ActivityIACommon {
+    public static final int IGNORE_ADF_ALIGNMENT = -1;
+    private static final String SCAN_SETTINGS_ADF_ALIGNMENT = "adf-alignment";
+    private static final String SCAN_SETTINGS_LAST_VALUE = "SCAN_SETTINGS_LAST_VALUE";
+    private boolean displayAdfAlignment;
+    /* access modifiers changed from: private */
+    public int lastAdfGuide;
+    /* access modifiers changed from: private */
+    public int lastValue;
+    private ListView listSelect;
+    /* access modifiers changed from: private */
+    public ListView listSelect2;
+    private final AdapterView.OnItemClickListener mListOptionClick = new AdapterView.OnItemClickListener() {
+        public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
+            int unused = InputUnitSettingActivity.this.lastValue = ((ScanSettingsDetailAdapter.DetailSettingHolder) view.getTag()).value;
+            InputUnitSettingActivity.this.ssdAdapter.setSelected(InputUnitSettingActivity.this.lastValue);
+            InputUnitSettingActivity.this.ssdAdapter.notifyDataSetChanged();
+            if (InputUnitSettingActivity.this.lastValue == 1) {
+                InputUnitSettingActivity.this.listSelect2.setVisibility(0);
+            } else {
+                InputUnitSettingActivity.this.listSelect2.setVisibility(8);
+            }
+        }
+    };
+    private final AdapterView.OnItemClickListener mListOptionClick2 = new AdapterView.OnItemClickListener() {
+        public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
+            int unused = InputUnitSettingActivity.this.lastAdfGuide = i;
+            switch (i) {
+                case 0:
+                    InputUnitSettingActivity.this.mlAdapter.setList(0, CustomListRowImpl.create().addText(InputUnitSettingActivity.this.getString(C2135R.string.str_settings_right_aligned)).prefixImage(Integer.valueOf(C2135R.C2136drawable.adf_left_adst)).suffixImage(Integer.valueOf(C2135R.C2136drawable.selected)));
+                    InputUnitSettingActivity.this.mlAdapter.setList(1, CustomListRowImpl.create().addText(InputUnitSettingActivity.this.getString(C2135R.string.str_settings_center_aligned)).prefixImage(Integer.valueOf(C2135R.C2136drawable.adf_center_adst)));
+                    break;
+                case 1:
+                    InputUnitSettingActivity.this.mlAdapter.setList(0, CustomListRowImpl.create().addText(InputUnitSettingActivity.this.getString(C2135R.string.str_settings_right_aligned)).prefixImage(Integer.valueOf(C2135R.C2136drawable.adf_left_adst)));
+                    InputUnitSettingActivity.this.mlAdapter.setList(1, CustomListRowImpl.create().addText(InputUnitSettingActivity.this.getString(C2135R.string.str_settings_center_aligned)).prefixImage(Integer.valueOf(C2135R.C2136drawable.adf_center_adst)).suffixImage(Integer.valueOf(C2135R.C2136drawable.selected)));
+                    break;
+            }
+            InputUnitSettingActivity.this.mlAdapter.notifyDataSetChanged();
+        }
+    };
+    /* access modifiers changed from: private */
+    public CustomListRowAdapter mlAdapter;
+    /* access modifiers changed from: private */
+    public ScanSettingsDetailAdapter ssdAdapter;
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        setContentView((int) C2135R.layout.scan_settings_detail_2);
+        Bundle extras = getIntent().getExtras();
+        this.lastValue = extras.getInt(SCAN_SETTINGS_LAST_VALUE);
+        this.lastAdfGuide = extras.getInt(SCAN_SETTINGS_ADF_ALIGNMENT);
+        if (this.lastAdfGuide >= 0) {
+            this.displayAdfAlignment = true;
+        } else {
+            this.displayAdfAlignment = false;
+        }
+        this.listSelect = (ListView) findViewById(C2135R.C2137id.lvScannerSettingOptions);
+        this.listSelect2 = (ListView) findViewById(C2135R.C2137id.lvScannerSettingOptions2);
+        makeListCorrespondenceOptions();
+        setActionBar(getTitle().toString(), true);
+    }
+
+    private void makeListCorrespondenceOptions() {
+        setTitle(getString(C2135R.string.str_settings_source_title));
+        ArrayList arrayList = new ArrayList();
+        switch (this.lastAdfGuide) {
+            case 0:
+                arrayList.add(CustomListRowImpl.create().addText(getString(C2135R.string.str_settings_right_aligned)).prefixImage(Integer.valueOf(C2135R.C2136drawable.adf_left_adst)).suffixImage(Integer.valueOf(C2135R.C2136drawable.selected)));
+                arrayList.add(CustomListRowImpl.create().addText(getString(C2135R.string.str_settings_center_aligned)).prefixImage(Integer.valueOf(C2135R.C2136drawable.adf_center_adst)));
+                break;
+            case 1:
+                arrayList.add(CustomListRowImpl.create().addText(getString(C2135R.string.str_settings_right_aligned)).prefixImage(Integer.valueOf(C2135R.C2136drawable.adf_left_adst)));
+                arrayList.add(CustomListRowImpl.create().addText(getString(C2135R.string.str_settings_center_aligned)).prefixImage(Integer.valueOf(C2135R.C2136drawable.adf_center_adst)).suffixImage(Integer.valueOf(C2135R.C2136drawable.selected)));
+                break;
+        }
+        this.mlAdapter = new CustomListRowAdapter(this, C2135R.layout.com_customline_row, arrayList);
+        this.listSelect2.setAdapter(this.mlAdapter);
+        this.listSelect2.setOnItemClickListener(this.mListOptionClick2);
+        if (this.lastValue == 1) {
+            this.listSelect2.setVisibility(0);
+        } else {
+            this.listSelect2.setVisibility(8);
+        }
+        LinkedHashMap linkedHashMap = new LinkedHashMap();
+        linkedHashMap.put(getString(C2135R.string.str_settings_source_doctable), 0);
+        linkedHashMap.put(getString(C2135R.string.str_settings_source_adf), 1);
+        this.ssdAdapter = new ScanSettingsDetailAdapter(getBaseContext(), linkedHashMap, this.lastValue);
+        this.listSelect.setAdapter(this.ssdAdapter);
+        this.listSelect.setOnItemClickListener(this.mListOptionClick);
+    }
+
+    public void onBackPressed() {
+        Intent intent = new Intent();
+        intent.putExtra(Constants.SCAN_REFS_SETTINGS_SOURCE, this.lastValue);
+        intent.putExtra(SCAN_SETTINGS_ADF_ALIGNMENT, this.displayAdfAlignment ? this.lastAdfGuide : -1);
+        setResult(-1, intent);
+        finish();
+    }
+
+    public static Intent getStartIntent(Context context, int i, int i2) {
+        Intent intent = new Intent(context, InputUnitSettingActivity.class);
+        intent.putExtra(SCAN_SETTINGS_LAST_VALUE, i);
+        intent.putExtra(SCAN_SETTINGS_ADF_ALIGNMENT, i2);
+        return intent;
+    }
+
+    public static int getInputUnit(Intent intent) {
+        if (intent == null) {
+            return 0;
+        }
+        return intent.getIntExtra(Constants.SCAN_REFS_SETTINGS_SOURCE, 0);
+    }
+
+    public static int getAdfAlignment(Intent intent) {
+        if (intent == null) {
+            return -1;
+        }
+        return intent.getIntExtra(SCAN_SETTINGS_ADF_ALIGNMENT, -1);
+    }
+}

+ 9 - 0
app/src/main/java/epson/scan/activity/LocalListAdapterBuilder.java

@@ -0,0 +1,9 @@
+package epson.scan.activity;
+
+import android.content.Context;
+import android.widget.ListAdapter;
+import java.io.Serializable;
+
+public interface LocalListAdapterBuilder extends Serializable {
+    ListAdapter build(Context context);
+}

+ 207 - 0
app/src/main/java/epson/scan/activity/MailActivity.java

@@ -0,0 +1,207 @@
+package epson.scan.activity;
+
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.p000v4.media.session.PlaybackStateCompat;
+import android.text.Editable;
+import android.text.InputFilter;
+import android.text.TextWatcher;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.RadioGroup;
+import android.widget.TextView;
+import android.widget.Toast;
+import epson.common.Constants;
+import epson.common.ExternalFileUtils;
+import epson.print.ActivityIACommon;
+import epson.print.C2135R;
+import epson.print.CommonDefine;
+import epson.print.ScanFileNumber;
+import epson.print.Util.EPLog;
+import epson.print.Util.Utils;
+import epson.print.fileBrower;
+import epson.provider.ScannedFileProvider;
+import epson.scan.lib.libHaru;
+import epson.server.utils.Define;
+import epson.server.utils.MyUtility;
+import java.io.File;
+import java.util.ArrayList;
+
+public class MailActivity extends ActivityIACommon implements View.OnClickListener, CommonDefine {
+    private RadioGroup chooseFileType;
+    /* access modifiers changed from: private */
+    public Button clearBtn;
+    private int count;
+    private Intent emailIntent;
+    private File fileAttachment;
+    private Long fileSizeInByte;
+    private float fileSizeInKb;
+    /* access modifiers changed from: private */
+    public EditText mFileName;
+    /* access modifiers changed from: private */
+    public String mFileType = Constants.PDF_TYPE;
+    /* access modifiers changed from: private */
+    public Button saveBtn;
+    private ArrayList<String> saveFilePathArray = new ArrayList<>();
+    private float totalFileSize = 0.0f;
+    private Utils utils = new Utils();
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        setContentView((int) C2135R.layout.save_as);
+        setActionBar((int) C2135R.string.str_btn_mail, true);
+        this.mFileName = (EditText) findViewById(C2135R.C2137id.save_as_dialog_file_name);
+        this.mFileName.setFilters(new InputFilter[]{new InputFilter.LengthFilter(64)});
+        this.mFileName.setOnFocusChangeListener(new View.OnFocusChangeListener() {
+            public void onFocusChange(View view, boolean z) {
+                if (!z) {
+                    MailActivity.this.mFileName.extendSelection(0);
+                    MailActivity.this.mFileName.setSelection(0);
+                }
+            }
+        });
+        this.chooseFileType = (RadioGroup) findViewById(C2135R.C2137id.file_type_for_save_as);
+        this.saveBtn = (Button) findViewById(C2135R.C2137id.save_button);
+        this.saveBtn.setText(C2135R.string.str_btn_mail);
+        this.saveBtn.setOnClickListener(this);
+        this.clearBtn = (Button) findViewById(C2135R.C2137id.clear_mail_title_btn);
+        this.clearBtn.setOnClickListener(this);
+        this.chooseFileType.check(C2135R.C2137id.save_as_pdf_type);
+        this.chooseFileType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+            public void onCheckedChanged(RadioGroup radioGroup, int i) {
+                switch (i) {
+                    case C2135R.C2137id.save_as_jpeg_type /*2131231434*/:
+                        String unused = MailActivity.this.mFileType = Constants.JPEG_TYPE;
+                        return;
+                    case C2135R.C2137id.save_as_pdf_type /*2131231435*/:
+                        String unused2 = MailActivity.this.mFileType = Constants.PDF_TYPE;
+                        return;
+                    default:
+                        return;
+                }
+            }
+        });
+        this.saveFilePathArray = getIntent().getStringArrayListExtra(Define.SAVING_FILE_PATH);
+        this.count = ScanFileNumber.getCount(this);
+        EditText editText = this.mFileName;
+        editText.setText(getString(C2135R.string.f448epson) + this.utils.editNumber(this.count));
+        for (int i = 0; i < this.saveFilePathArray.size(); i++) {
+            this.fileAttachment = new File(this.saveFilePathArray.get(i));
+            this.fileSizeInByte = Long.valueOf(this.fileAttachment.length());
+            this.fileSizeInKb = (float) (this.fileSizeInByte.longValue() / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID);
+            EPLog.m313i("Data", " " + this.fileSizeInKb);
+            this.totalFileSize = this.totalFileSize + this.fileSizeInKb;
+        }
+        if (this.totalFileSize > 500.0f) {
+            ((TextView) findViewById(C2135R.C2137id.save_as_file_size)).setText("" + MyUtility.mathRound((double) (this.totalFileSize / 1024.0f), 2) + "MB");
+        } else {
+            ((TextView) findViewById(C2135R.C2137id.save_as_file_size)).setText("" + MyUtility.mathRound((double) this.totalFileSize, 2) + "KB");
+        }
+        if (this.mFileName.getText().toString().length() > 0) {
+            this.clearBtn.setVisibility(0);
+        }
+        this.mFileName.addTextChangedListener(new TextWatcher() {
+            public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
+            }
+
+            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
+            }
+
+            public void afterTextChanged(Editable editable) {
+                if (MailActivity.this.mFileName.getText().toString().equals("")) {
+                    MailActivity.this.clearBtn.setVisibility(8);
+                    MailActivity.this.saveBtn.setEnabled(false);
+                    return;
+                }
+                MailActivity.this.clearBtn.setVisibility(0);
+                MailActivity.this.saveBtn.setEnabled(true);
+            }
+        });
+    }
+
+    public void onClick(View view) {
+        String str;
+        boolean z;
+        int id = view.getId();
+        if (id != C2135R.C2137id.clear_mail_title_btn) {
+            if (id == C2135R.C2137id.save_button) {
+                if (!fileBrower.isAvailableFileName(this.mFileName.getText().toString())) {
+                    Toast.makeText(getApplicationContext(), C2135R.string.str_error_Filename, 1).show();
+                    return;
+                }
+                this.saveBtn.setEnabled(false);
+                if (this.mFileType.equals(Constants.PDF_TYPE)) {
+                    str = this.mFileName.getText().toString();
+                    z = false;
+                } else {
+                    String obj = this.mFileName.getText().toString();
+                    if (!obj.equals("EPSON" + this.utils.editNumber(this.count))) {
+                        str = this.mFileName.getText().toString();
+                        z = true;
+                    } else if (this.saveFilePathArray.size() == 1) {
+                        str = this.mFileName.getText().toString();
+                        z = false;
+                    } else {
+                        str = "EPSON";
+                        z = false;
+                    }
+                }
+                try {
+                    if (this.mFileType.equals(Constants.PDF_TYPE)) {
+                        libHaru libharu = new libHaru();
+                        String scannedImageDir = ExternalFileUtils.getInstance(this).getScannedImageDir();
+                        String path = new File(scannedImageDir, str + CommonDefine.FileType_PDF).getPath();
+                        libharu.createPDF(this.saveFilePathArray, path);
+                        this.emailIntent = new Intent("android.intent.action.SEND");
+                        this.fileAttachment = new File(path);
+                        Uri uriForFile = ScannedFileProvider.getUriForFile(this, this.fileAttachment);
+                        this.emailIntent = new Intent("android.intent.action.SEND");
+                        this.emailIntent.putExtra("android.intent.extra.STREAM", uriForFile);
+                    } else if (this.mFileType.equals(Constants.JPEG_TYPE)) {
+                        ArrayList arrayList = new ArrayList();
+                        this.emailIntent = new Intent("android.intent.action.SEND_MULTIPLE");
+                        int i = this.count;
+                        ExternalFileUtils.getInstance(this).createTempFolder(ExternalFileUtils.getInstance(this).getScannedImageDir());
+                        if (this.saveFilePathArray.size() == 1) {
+                            this.fileAttachment = MyUtility.createTempFile(this, this.saveFilePathArray.get(0), str + ".jpg");
+                            arrayList.add(ScannedFileProvider.getUriForFile(this, this.fileAttachment));
+                        } else {
+                            if (z) {
+                                i = 1;
+                            }
+                            for (int i2 = 0; i2 < this.saveFilePathArray.size(); i2++) {
+                                this.fileAttachment = MyUtility.createTempFile(this, this.saveFilePathArray.get(i2), str + this.utils.editNumber(i) + ".jpg");
+                                i++;
+                                arrayList.add(ScannedFileProvider.getUriForFile(this, this.fileAttachment));
+                            }
+                        }
+                        this.emailIntent.putParcelableArrayListExtra("android.intent.extra.STREAM", arrayList);
+                    }
+                    this.emailIntent.setType("message/rfc822");
+                    this.emailIntent.putExtra("android.intent.extra.SUBJECT", getString(C2135R.string.app_name));
+                    this.emailIntent.putExtra("android.intent.extra.TEXT", getString(C2135R.string.using_Epson_iPrint));
+                    startActivityForResult(Intent.createChooser(this.emailIntent, "Send mail..."), 1);
+                    return;
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            } else {
+                return;
+            }
+        }
+        this.mFileName.setText("");
+    }
+
+    /* access modifiers changed from: protected */
+    public void onActivityResult(int i, int i2, Intent intent) {
+        super.onActivityResult(i, i2, intent);
+        if (i == 1 && i2 == 0) {
+            setResult(-1);
+            finish();
+        }
+        this.saveBtn.setEnabled(true);
+    }
+}

+ 101 - 0
app/src/main/java/epson/scan/activity/ModeListAdapter.java

@@ -0,0 +1,101 @@
+package epson.scan.activity;
+
+import android.content.Context;
+import android.support.annotation.DrawableRes;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.annotation.StringRes;
+import android.support.annotation.UiThread;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ImageView;
+import android.widget.ListAdapter;
+import android.widget.TextView;
+import epson.print.C2135R;
+
+public class ModeListAdapter extends BaseAdapter {
+    private int mCurrentPosition;
+    private LayoutInflater mLayoutInflater;
+    @DrawableRes
+    private int[] mLeftImageId;
+    private int[] mStringIdArray;
+
+    public long getItemId(int i) {
+        return (long) i;
+    }
+
+    public ModeListAdapter(@NonNull Context context, @StringRes int[] iArr, int i) {
+        this.mLayoutInflater = LayoutInflater.from(context);
+        this.mStringIdArray = iArr;
+        this.mCurrentPosition = i;
+        this.mLeftImageId = null;
+    }
+
+    public ModeListAdapter(@NonNull Context context, @Nullable @StringRes int[] iArr, @DrawableRes int[] iArr2, int i) {
+        this.mLayoutInflater = LayoutInflater.from(context);
+        this.mStringIdArray = iArr == null ? new int[iArr2.length] : iArr;
+        this.mCurrentPosition = i;
+        this.mLeftImageId = iArr2;
+    }
+
+    public int getCount() {
+        return this.mStringIdArray.length;
+    }
+
+    public Object getItem(int i) {
+        return 0;
+    }
+
+    @UiThread
+    public void setPosition(int i) {
+        this.mCurrentPosition = i;
+        int i2 = this.mCurrentPosition;
+        if (i2 < 0) {
+            this.mCurrentPosition = 0;
+        } else if (i2 >= getCount()) {
+            this.mCurrentPosition = getCount() - 1;
+        }
+        notifyDataSetChanged();
+    }
+
+    public int getPosition() {
+        return this.mCurrentPosition;
+    }
+
+    public View getView(int i, View view, ViewGroup viewGroup) {
+        int i2 = 0;
+        if (view == null) {
+            view = this.mLayoutInflater.inflate(C2135R.layout.i2_scan_setting_item, viewGroup, false);
+        }
+        if (this.mLeftImageId != null) {
+            ImageView imageView = (ImageView) view.findViewById(C2135R.C2137id.leftImageView);
+            imageView.setImageResource(this.mLeftImageId[i]);
+            imageView.setVisibility(0);
+        }
+        if (this.mStringIdArray[0] != 0) {
+            ((TextView) view.findViewById(C2135R.C2137id.tvSettingName)).setText(this.mStringIdArray[i]);
+        }
+        ImageView imageView2 = (ImageView) view.findViewById(C2135R.C2137id.ivSettingSelected);
+        if (i != this.mCurrentPosition) {
+            i2 = 8;
+        }
+        imageView2.setVisibility(i2);
+        return view;
+    }
+
+    public static class Builder implements LocalListAdapterBuilder {
+        private int mCurrentPosition;
+        private int[] mStringIdArray;
+
+        public Builder(int[] iArr, int i) {
+            this.mStringIdArray = iArr;
+            this.mCurrentPosition = i;
+        }
+
+        public ListAdapter build(Context context) {
+            return new ModeListAdapter(context, this.mStringIdArray, this.mCurrentPosition);
+        }
+    }
+}

+ 2010 - 0
app/src/main/java/epson/scan/activity/ScanActivity.java

@@ -0,0 +1,2010 @@
+package epson.scan.activity;
+
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.SharedPreferences;
+import android.content.res.Configuration;
+import android.graphics.Bitmap;
+import android.graphics.Point;
+import android.graphics.RectF;
+import android.os.AsyncTask;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.StatFs;
+import android.support.annotation.Nullable;
+import android.view.Display;
+import android.view.GestureDetector;
+import android.view.KeyEvent;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewTreeObserver;
+import android.widget.Button;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import com.epson.iprint.prtlogger.Analytics;
+import com.epson.iprint.prtlogger.CommonLog;
+import com.epson.iprint.prtlogger.PrintLog;
+import com.epson.iprint.shared.EpsoniPrintSharedActivity;
+import com.epson.iprint.shared.SharedParamScan;
+import com.epson.mobilephone.common.PrintingLib.define.Constants;
+import com.epson.mobilephone.common.wifidirect.NfcTagUtils;
+import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
+import epson.common.Constants;
+import epson.common.ExternalFileUtils;
+import epson.common.Utils;
+import epson.print.ActivityNfcPrinter;
+import epson.print.ActivityPrintWeb;
+import epson.print.ActivityRequestPermissions;
+import epson.print.C2135R;
+import epson.print.CommonDefine;
+import epson.print.Util.EPLog;
+import epson.print.Util.Photo;
+import epson.scan.activity.ScanBaseView;
+import epson.scan.activity.ScanContinueParam;
+import epson.scan.lib.I1ScanParams;
+import epson.scan.lib.ScanInfoStorage;
+import epson.scan.lib.ScanSizeHelper;
+import epson.scan.lib.ScannerInfo;
+import epson.scan.lib.escanLib;
+import epson.server.screens.StorageServer;
+import epson.server.utils.Define;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import org.opencv.videoio.Videoio;
+
+public class ScanActivity extends ScanBaseView implements ScanContinueParam.ScanContinueDialogButtonClick {
+    private static final int MESSAGE_CHECK_STATUS_AND_START_SCAN = 20;
+    public static final String PARAM_KEY_SCAN_LOG = "scan-log";
+    private static final int REQEST_RUNTIMEPERMMISSION = 4;
+    private static final int REQUEST_CODE_ESC_I_VERSION_CHANGE = 20;
+    static final String RETURN_KEY_SCAN_FILE = "scan-file";
+    private static final int SCAN_CANCELED = -2;
+    private static final int SCAN_DISMISS = -3;
+    public static final int SCAN_ENDPAGE_CB = 11;
+    private static final int SCAN_ERROR = -1;
+    private static final int SCAN_FINISHED = 2;
+    public static final int SCAN_RECV_IMGBLOCK_CB = 10;
+    private static final int SCAN_REDRAWBITMAP = -100;
+    private static final int START_SCAN = 0;
+    private static final String TAG = "ScanActivity";
+    /* access modifiers changed from: private */
+    public RectF area;
+    /* access modifiers changed from: private */
+    public int areaHeightOnScreen = 0;
+    /* access modifiers changed from: private */
+    public int areaWidthOnScreen = 0;
+    private boolean bAutoStartScan = false;
+    private Button btnCancelScan;
+    private Button btnMail;
+    /* access modifiers changed from: private */
+    public Button btnNext;
+    /* access modifiers changed from: private */
+    public Button btnPrev;
+    private Button btnPrint;
+    private Button btnSave;
+    private Button btnScan;
+    /* access modifiers changed from: private */
+    public AlertDialog confirmAlertDialog;
+    /* access modifiers changed from: private */
+    public int convertCount = 0;
+    /* access modifiers changed from: private */
+    public Thread doscan;
+    /* access modifiers changed from: private */
+    public int error = 0;
+    /* access modifiers changed from: private */
+    public AlertDialog errorDialog;
+    /* access modifiers changed from: private */
+    public escanLib escan;
+    /* access modifiers changed from: private */
+    public SharedParamScan extParam;
+    /* access modifiers changed from: private */
+    public FrameLayout flScanResult;
+    /* access modifiers changed from: private */
+    public GestureDetector gestureDetector;
+    private View.OnTouchListener gestureListener;
+    /* access modifiers changed from: private */
+    public boolean isConfirmCancel = false;
+    /* access modifiers changed from: private */
+    public boolean isCustomAction = false;
+    /* access modifiers changed from: private */
+    public boolean isDecoding = false;
+    private boolean isNeedClearBm = false;
+    private boolean isNeedDeleteTempFile = true;
+    /* access modifiers changed from: private */
+    public boolean isNeedGetScanSize = true;
+    /* access modifiers changed from: private */
+    public boolean isNeedRedrawBitmap = false;
+    /* access modifiers changed from: private */
+    public boolean isNeedScale = false;
+    /* access modifiers changed from: private */
+    public boolean isNeedUpdateScanningArea = false;
+    /* access modifiers changed from: private */
+    public boolean isStopScan = false;
+    /* access modifiers changed from: private */
+    public LinearLayout llScanArea;
+    /* access modifiers changed from: private */
+    public LinearLayout llScanAreaBackground;
+    private LinearLayout llScanningProgress;
+    /* access modifiers changed from: private */
+    public boolean mActivityPaused;
+    private View.OnClickListener mButtonCancelScanListener = new View.OnClickListener() {
+        public void onClick(View view) {
+            String localClassName = ScanActivity.this.getLocalClassName();
+            EPLog.m313i(localClassName, "isStopScan = " + ScanActivity.this.isStopScan);
+            if (!ScanActivity.this.escan.isJobDone() && !ScanActivity.this.isStopScan) {
+                ScanActivity.this.hideScanningPop();
+                ScanActivity scanActivity = ScanActivity.this;
+                scanActivity.confirmationDialog(scanActivity.getString(C2135R.string.str_msg_scan_cancel));
+            }
+        }
+    };
+    private View.OnClickListener mButtonMailListener = new View.OnClickListener() {
+        public void onClick(View view) {
+            if (ScanActivity.this.totalScanned > 0 && ScanActivity.this.isCompletedScanProcess()) {
+                Intent intent = new Intent(ScanActivity.this, MailActivity.class);
+                intent.putStringArrayListExtra(Define.SAVING_FILE_PATH, ScanActivity.this.getListSavedJPGFilePath());
+                ScanActivity.this.startActivityForResult(intent, 1);
+            }
+        }
+    };
+    private View.OnClickListener mButtonNextListener = new View.OnClickListener() {
+        public void onClick(View view) {
+            if (ScanActivity.this.isCompletedScanProcess()) {
+                ScanActivity.this.curentViewingFile++;
+                if (ScanActivity.this.curentViewingFile > 300 || ScanActivity.this.curentViewingFile > ScanActivity.this.totalScanned) {
+                    ScanActivity scanActivity = ScanActivity.this;
+                    scanActivity.curentViewingFile--;
+                    return;
+                }
+                ScanActivity scanActivity2 = ScanActivity.this;
+                scanActivity2.updateThumbResult(scanActivity2.curentViewingFile);
+                ScanActivity.this.showDisplayingResult();
+                ScanActivity.this.scanArea.postInvalidate();
+            }
+        }
+    };
+    private View.OnClickListener mButtonPrevListener = new View.OnClickListener() {
+        public void onClick(View view) {
+            if (ScanActivity.this.isCompletedScanProcess()) {
+                ScanActivity.this.curentViewingFile--;
+                if (ScanActivity.this.curentViewingFile < 1) {
+                    ScanActivity.this.curentViewingFile++;
+                    return;
+                }
+                ScanActivity scanActivity = ScanActivity.this;
+                scanActivity.updateThumbResult(scanActivity.curentViewingFile);
+                ScanActivity.this.showDisplayingResult();
+                ScanActivity.this.scanArea.postInvalidate();
+            }
+        }
+    };
+    private View.OnClickListener mButtonPrintListener = new View.OnClickListener() {
+        public void onClick(View view) {
+            if (ScanActivity.this.totalScanned > 0) {
+                Intent intent = new Intent(ScanActivity.this, ActivityPrintWeb.class);
+                intent.putExtra("from", 1);
+                intent.putStringArrayListExtra("print_web", ScanActivity.this.getListSavedJPGFilePath());
+                intent.putExtra("print_log", ScanActivity.getPrintLog());
+                ScanActivity.this.startActivityForResult(intent, 3);
+            }
+        }
+    };
+    private View.OnClickListener mButtonSaveListener = new View.OnClickListener() {
+        public void onClick(View view) {
+            if (ScanActivity.this.totalScanned > 0 && ScanActivity.this.isCompletedScanProcess()) {
+                if (ScanActivity.this.isCustomAction) {
+                    Intent intent = new Intent();
+                    if (ScanActivity.this.extParam != null) {
+                        intent.putExtra(ScanActivity.RETURN_KEY_SCAN_FILE, ScanActivity.this.extParam.getArrayOutFilePath());
+                        ScanActivity.this.setResult(-1, intent);
+                        ScanActivity.this.finish();
+                        return;
+                    }
+                    return;
+                }
+                Intent intent2 = new Intent(ScanActivity.this, StorageServer.class);
+                intent2.putExtra(Define.PICK_SERVER_FOR, 2);
+                intent2.putStringArrayListExtra(Define.SAVING_FILE_PATH, ScanActivity.this.getListSavedJPGFilePath());
+                intent2.putExtra(StorageServer.FOR_PRINT_LOGGER_CALL_FROM, 1);
+                ScanActivity.this.startActivityForResult(intent2, 1);
+            }
+        }
+    };
+    private View.OnClickListener mButtonScanListener = new View.OnClickListener() {
+        public void onClick(View view) {
+            ScanActivity.this.check3GAndStartPrint();
+        }
+    };
+    /* access modifiers changed from: private */
+    public I1ScanParams mI1ScanParams;
+    private ViewTreeObserver.OnPreDrawListener mOnPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
+        public boolean onPreDraw() {
+            int i;
+            RectF bmRectF;
+            if (!ScanActivity.this.mActivityPaused && ScanActivity.this.mScanAreaBackgroundViewSizeChanged) {
+                boolean unused = ScanActivity.this.mScanAreaBackgroundViewSizeChanged = false;
+                boolean unused2 = ScanActivity.this.isNeedGetScanSize = true;
+                boolean unused3 = ScanActivity.this.isNeedScale = true;
+                ScanActivity.this.llScanArea.invalidate();
+                ScanActivity.this.llScanAreaBackground.invalidate();
+                ScanActivity.this.scanArea.invalidate();
+                ScanActivity.this.scanAreaBackground.invalidate();
+                ScanActivity.this.flScanResult.invalidate();
+            }
+            if (ScanActivity.this.isNeedGetScanSize) {
+                if (ScanActivity.this.isDoctable) {
+                    ScanActivity scanActivity = ScanActivity.this;
+                    scanActivity.setMaxwidth(Utils.getPrefInt(scanActivity.getContext(), Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_MAX_WIDTH));
+                    ScanActivity scanActivity2 = ScanActivity.this;
+                    scanActivity2.setMaxheight(Utils.getPrefInt(scanActivity2.getContext(), Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_MAX_HEIGHT));
+                }
+                if (ScanActivity.this.getMaxwidth() == 0) {
+                    ScanActivity.this.setMaxwidth(Constants.SCAN_MAX_WIDTH);
+                }
+                if (ScanActivity.this.getMaxheight() == 0) {
+                    ScanActivity.this.setMaxheight(Constants.SCAN_MAX_HEIGHT);
+                }
+                int prefInt = !"".equals(Utils.getPrefString(ScanActivity.this.getContext(), Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SCANNER_MODEL)) ? Utils.getPrefInt(ScanActivity.this.getContext(), Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_RESOLUTION) : 150;
+                if (prefInt == ScanActivity.this.resolution && !ScanActivity.this.isDoctable) {
+                    boolean unused4 = ScanActivity.this.isNeedUpdateScanningArea = true;
+                }
+                int unused5 = ScanActivity.this.resolution = prefInt;
+                ScanActivity scanActivity3 = ScanActivity.this;
+                int unused6 = scanActivity3.areaHeightOnScreen = scanActivity3.llScanAreaBackground.getHeight();
+                ScanActivity scanActivity4 = ScanActivity.this;
+                int unused7 = scanActivity4.areaWidthOnScreen = scanActivity4.llScanAreaBackground.getWidth();
+            }
+            ScanActivity.this.initFrameWithScreensize();
+            Point point = ScanActivity.this.getmBaseTop();
+            Point point2 = ScanActivity.this.getmBaseBot();
+            int i2 = point2.x - point.x;
+            int i3 = point2.y - point.y;
+            ScanActivity scanActivity5 = ScanActivity.this;
+            scanActivity5.setmBaseTop(new Point(((int) (((double) scanActivity5.areaWidthOnScreen) - ScanActivity.this.getMaxScanWidthOnScreen())) / 2, ScanActivity.this.MARGIN_TOP_BOT));
+            ScanActivity scanActivity6 = ScanActivity.this;
+            scanActivity6.setmBaseBot(new Point(scanActivity6.areaWidthOnScreen - ScanActivity.this.getmBaseTop().x, ScanActivity.this.areaHeightOnScreen - ScanActivity.this.MARGIN_TOP_BOT));
+            if (!ScanActivity.this.isDoctable && !ScanActivity.this.isNeedGetScanSize) {
+                ScanActivity scanActivity7 = ScanActivity.this;
+                scanActivity7.setPiBaseTop(new ScanBaseView.PointInfo((double) scanActivity7.getmBaseTop().x, (double) ScanActivity.this.getmBaseTop().y));
+                ScanActivity scanActivity8 = ScanActivity.this;
+                scanActivity8.setPiBaseBot(new ScanBaseView.PointInfo((double) scanActivity8.getmBaseBot().x, (double) ScanActivity.this.getmBaseBot().y));
+                ScanActivity scanActivity9 = ScanActivity.this;
+                scanActivity9.setmTop(scanActivity9.getmBaseTop());
+                ScanActivity scanActivity10 = ScanActivity.this;
+                scanActivity10.setmBot(scanActivity10.getmBaseBot());
+            }
+            if (ScanActivity.this.isNeedGetScanSize) {
+                if (ScanActivity.this.isNeedUpdateScanningArea) {
+                    ScanActivity scanActivity11 = ScanActivity.this;
+                    scanActivity11.setPiBaseTop(new ScanBaseView.PointInfo((double) scanActivity11.getmBaseTop().x, (double) ScanActivity.this.getmBaseTop().y));
+                    ScanActivity scanActivity12 = ScanActivity.this;
+                    scanActivity12.setPiBaseBot(new ScanBaseView.PointInfo((double) scanActivity12.getmBaseBot().x, (double) ScanActivity.this.getmBaseBot().y));
+                    ScanActivity scanActivity13 = ScanActivity.this;
+                    scanActivity13.setmTop(scanActivity13.getmBaseTop());
+                    ScanActivity scanActivity14 = ScanActivity.this;
+                    scanActivity14.setmBot(scanActivity14.getmBaseBot());
+                    ScanActivity.this.setScreenStatus(1);
+                }
+                if (ScanActivity.this.isNeedScale) {
+                    boolean unused8 = ScanActivity.this.isNeedScale = false;
+                    Point point3 = new Point();
+                    float f = (float) i2;
+                    point2.x = (int) (((float) ScanActivity.this.getmBaseTop().x) + (((float) ((ScanActivity.this.getmBaseBot().x - ScanActivity.this.getmBaseTop().x) * (ScanActivity.this.getmTop().x - point.x))) / f));
+                    float f2 = (float) i3;
+                    point2.y = (int) (((float) ScanActivity.this.getmBaseTop().y) + (((float) ((ScanActivity.this.getmBaseBot().y - ScanActivity.this.getmBaseTop().y) * (ScanActivity.this.getmTop().y - point.y))) / f2));
+                    point3.x = (int) (((float) ScanActivity.this.getmBaseTop().x) + (((float) ((ScanActivity.this.getmBaseBot().x - ScanActivity.this.getmBaseTop().x) * (ScanActivity.this.getmBot().x - point.x))) / f));
+                    point3.y = (int) (((float) ScanActivity.this.getmBaseTop().y) + (((float) ((ScanActivity.this.getmBaseBot().y - ScanActivity.this.getmBaseTop().y) * (ScanActivity.this.getmBot().y - point.y))) / f2));
+                    ScanActivity scanActivity15 = ScanActivity.this;
+                    scanActivity15.setPiBaseTop(new ScanBaseView.PointInfo((double) point2.x, (double) point2.y));
+                    ScanActivity scanActivity16 = ScanActivity.this;
+                    scanActivity16.setPiBaseBot(new ScanBaseView.PointInfo((double) point3.x, (double) point3.y));
+                    ScanActivity.this.setmTop(point2);
+                    ScanActivity.this.setmBot(point3);
+                    if (!ScanActivity.this.isNeedRedrawBitmap && (bmRectF = ScanActivity.this.getBmRectF()) != null) {
+                        bmRectF.left = ((float) ScanActivity.this.getmBaseTop().x) + ((((float) (ScanActivity.this.getmBaseBot().x - ScanActivity.this.getmBaseTop().x)) * (bmRectF.left - ((float) point.x))) / f);
+                        bmRectF.top = ((float) ScanActivity.this.getmBaseTop().y) + ((((float) (ScanActivity.this.getmBaseBot().y - ScanActivity.this.getmBaseTop().y)) * (bmRectF.top - ((float) point.y))) / f2);
+                        bmRectF.right = ((float) ScanActivity.this.getmBaseTop().x) + ((((float) (ScanActivity.this.getmBaseBot().x - ScanActivity.this.getmBaseTop().x)) * (bmRectF.right - ((float) point.x))) / f);
+                        bmRectF.bottom = ((float) ScanActivity.this.getmBaseTop().y) + ((((float) (ScanActivity.this.getmBaseBot().y - ScanActivity.this.getmBaseTop().y)) * (bmRectF.bottom - ((float) point.y))) / f2);
+                        ScanActivity.this.setBmRectF(bmRectF);
+                    }
+                }
+                ScanActivity scanActivity17 = ScanActivity.this;
+                scanActivity17.setmCenter(scanActivity17.calculateTheCenterPoint(scanActivity17.getmTop(), ScanActivity.this.getmBot()));
+                ScanActivity scanActivity18 = ScanActivity.this;
+                scanActivity18.setInSampleSize(Math.round((float) (100 / ((scanActivity18.areaHeightOnScreen * 100) / 650))));
+                ScanActivity.this.get_bmOption().inSampleSize = ScanActivity.this.getInSampleSize();
+                ScanActivity.this.setupScanArea();
+                boolean unused9 = ScanActivity.this.isNeedGetScanSize = false;
+                ScanActivity.this.setSetSize(true);
+                SharedPreferences sharedPreferences = ScanActivity.this.context.getSharedPreferences(Constants.SCAN_REFS_USED_SCANNER_PATH, 0);
+                if (ScanActivity.this.isDoctable) {
+                    i = sharedPreferences.getInt(Constants.SCAN_REFS_SCANNER_CHOSEN_SIZE_DOC, Constants.PaperName.EPS_MSID_UNKNOWN.getCode());
+                } else {
+                    i = sharedPreferences.getInt(epson.common.Constants.SCAN_REFS_SCANNER_CHOSEN_SIZE_ADF, Constants.PaperName.EPS_MSID_UNKNOWN.getCode());
+                }
+                if (ScanActivity.this.isNeedUpdateScanningArea) {
+                    if (i == Constants.PaperName.EPS_MSID_UNKNOWN.getCode()) {
+                        ScanActivity.this.chooseScanSize(ScanSizeHelper.getDefaultScanSize());
+                    } else {
+                        ScanActivity.this.chooseScanSize(i);
+                    }
+                }
+                ScanActivity.this.scanArea.redrawCBHandler = ScanActivity.this.scanningProgressHandler;
+                boolean unused10 = ScanActivity.this.isNeedUpdateScanningArea = false;
+            }
+            return true;
+        }
+    };
+    /* access modifiers changed from: private */
+    public boolean mScanAreaBackgroundViewSizeChanged;
+    private CommonLog mScanLog;
+    private String oldScannerId;
+    /* access modifiers changed from: private */
+    public int previousTotalScanned = 0;
+    /* access modifiers changed from: private */
+    public int resolution = 0;
+    /* access modifiers changed from: private */
+    public ScanBaseView.ScanAreaSet scanArea;
+    /* access modifiers changed from: private */
+    public ScanBaseView.ScanAreaBackground scanAreaBackground;
+    private int scanOrigin = 2;
+    /* access modifiers changed from: private */
+    public Handler scanningProgressHandler = new Handler(new Handler.Callback() {
+        /* JADX WARNING: Can't fix incorrect switch cases order */
+        /* Code decompiled incorrectly, please refer to instructions dump. */
+        public boolean handleMessage(android.os.Message r9) {
+            /*
+                r8 = this;
+                epson.scan.activity.ScanActivity r0 = epson.scan.activity.ScanActivity.this
+                boolean r0 = r0.isFinishing()
+                r1 = -3
+                r2 = -100
+                r3 = 20
+                r4 = 2
+                r5 = 1
+                if (r0 == 0) goto L_0x0021
+                int r0 = r9.what
+                if (r0 == r2) goto L_0x0020
+                if (r0 == r1) goto L_0x0020
+                if (r0 == r4) goto L_0x0020
+                if (r0 == r3) goto L_0x0020
+                switch(r0) {
+                    case -1: goto L_0x0020;
+                    case 0: goto L_0x0020;
+                    default: goto L_0x001c;
+                }
+            L_0x001c:
+                switch(r0) {
+                    case 10: goto L_0x0020;
+                    case 11: goto L_0x0020;
+                    default: goto L_0x001f;
+                }
+            L_0x001f:
+                goto L_0x0021
+            L_0x0020:
+                return r5
+            L_0x0021:
+                int r9 = r9.what
+                r0 = 0
+                if (r9 == r2) goto L_0x044e
+                r2 = -1
+                if (r9 == r4) goto L_0x03b2
+                if (r9 == r3) goto L_0x0382
+                r6 = 1000(0x3e8, double:4.94E-321)
+                switch(r9) {
+                    case -3: goto L_0x037b;
+                    case -2: goto L_0x02a0;
+                    case -1: goto L_0x01a1;
+                    case 0: goto L_0x00ea;
+                    default: goto L_0x0030;
+                }
+            L_0x0030:
+                switch(r9) {
+                    case 10: goto L_0x0093;
+                    case 11: goto L_0x0035;
+                    default: goto L_0x0033;
+                }
+            L_0x0033:
+                goto L_0x047f
+            L_0x0035:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                epson.scan.lib.escanLib r1 = r9.escan
+                java.util.List r1 = r1.getListScannedFile()
+                int r1 = r1.size()
+                r9.totalScanned = r1
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                int r9 = r9.totalScanned
+                if (r9 >= r5) goto L_0x004c
+                return r0
+            L_0x004c:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                java.lang.String r9 = r9.getLocalClassName()
+                java.lang.String r1 = "end page, waiting..."
+                epson.print.Util.EPLog.m313i(r9, r1)
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                int r9 = r9.convertCount
+                epson.scan.activity.ScanActivity r1 = epson.scan.activity.ScanActivity.this
+                epson.scan.lib.escanLib r1 = r1.escan
+                java.util.List r1 = r1.getListScannedFile()
+                int r1 = r1.size()
+                if (r9 >= r1) goto L_0x0086
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                epson.scan.lib.escanLib r1 = r9.escan
+                java.util.List r1 = r1.getListScannedFile()
+                epson.scan.activity.ScanActivity r2 = epson.scan.activity.ScanActivity.this
+                int r2 = r2.convertCount
+                java.lang.Object r1 = r1.get(r2)
+                java.lang.String r1 = (java.lang.String) r1
+                r9.convert(r1)
+            L_0x0086:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                java.lang.String r9 = r9.getLocalClassName()
+                java.lang.String r1 = "done add to list"
+                epson.print.Util.EPLog.m313i(r9, r1)
+                goto L_0x047f
+            L_0x0093:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                epson.scan.lib.escanLib r1 = r9.escan
+                java.util.List r1 = r1.getListScannedFile()
+                int r1 = r1.size()
+                r9.totalScanned = r1
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                int r9 = r9.totalScanned
+                if (r9 >= r5) goto L_0x00aa
+                return r0
+            L_0x00aa:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                epson.scan.lib.escanLib r9 = r9.escan
+                boolean r9 = r9.isJobDone()
+                if (r9 == 0) goto L_0x00b7
+                return r5
+            L_0x00b7:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this     // Catch:{ RejectedExecutionException -> 0x00e4 }
+                boolean r9 = r9.isDecoding     // Catch:{ RejectedExecutionException -> 0x00e4 }
+                if (r9 != 0) goto L_0x047f
+                epson.scan.activity.ScanActivity$BitmapTask r9 = new epson.scan.activity.ScanActivity$BitmapTask     // Catch:{ RejectedExecutionException -> 0x00e4 }
+                epson.scan.activity.ScanActivity r1 = epson.scan.activity.ScanActivity.this     // Catch:{ RejectedExecutionException -> 0x00e4 }
+                r9.<init>()     // Catch:{ RejectedExecutionException -> 0x00e4 }
+                java.lang.String[] r1 = new java.lang.String[r5]     // Catch:{ RejectedExecutionException -> 0x00e4 }
+                epson.scan.activity.ScanActivity r2 = epson.scan.activity.ScanActivity.this     // Catch:{ RejectedExecutionException -> 0x00e4 }
+                epson.scan.lib.escanLib r2 = r2.escan     // Catch:{ RejectedExecutionException -> 0x00e4 }
+                java.util.List r2 = r2.getListScannedFile()     // Catch:{ RejectedExecutionException -> 0x00e4 }
+                epson.scan.activity.ScanActivity r3 = epson.scan.activity.ScanActivity.this     // Catch:{ RejectedExecutionException -> 0x00e4 }
+                int r3 = r3.totalScanned     // Catch:{ RejectedExecutionException -> 0x00e4 }
+                int r3 = r3 - r5
+                java.lang.Object r2 = r2.get(r3)     // Catch:{ RejectedExecutionException -> 0x00e4 }
+                java.lang.String r2 = (java.lang.String) r2     // Catch:{ RejectedExecutionException -> 0x00e4 }
+                r1[r0] = r2     // Catch:{ RejectedExecutionException -> 0x00e4 }
+                r9.execute(r1)     // Catch:{ RejectedExecutionException -> 0x00e4 }
+                goto L_0x047f
+            L_0x00e4:
+                r9 = move-exception
+                r9.printStackTrace()
+                goto L_0x047f
+            L_0x00ea:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                java.lang.String r9 = r9.getCallingPackage()
+                java.lang.String r1 = "[EPSON SCAN] START SCAN"
+                epson.print.Util.EPLog.m313i(r9, r1)
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                boolean unused = r9.isStopScan = r0
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                boolean unused = r9.isConfirmCancel = r0
+                boolean r9 = epson.scan.activity.ScanContinueParam.isContinueScanning()
+                if (r9 != 0) goto L_0x010a
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                int unused = r9.convertCount = r0
+            L_0x010a:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                boolean unused = r9.isDecoding = r0
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                android.view.WindowManager r9 = r9.getWindowManager()
+                android.view.Display r9 = r9.getDefaultDisplay()
+                epson.scan.activity.ScanActivity r1 = epson.scan.activity.ScanActivity.this
+                android.content.res.Resources r1 = r1.getResources()
+                android.content.res.Configuration r1 = r1.getConfiguration()
+                java.lang.String r2 = "display;"
+                int r3 = r1.orientation
+                java.lang.String r3 = java.lang.String.valueOf(r3)
+                epson.print.Util.EPLog.m313i(r2, r3)
+                java.lang.String r2 = "display;"
+                int r3 = r9.getRotation()
+                java.lang.String r3 = java.lang.String.valueOf(r3)
+                epson.print.Util.EPLog.m313i(r2, r3)
+                int r9 = r9.getRotation()
+                r2 = 9
+                r3 = 8
+                switch(r9) {
+                    case 0: goto L_0x018b;
+                    case 1: goto L_0x017b;
+                    case 2: goto L_0x0161;
+                    case 3: goto L_0x0147;
+                    default: goto L_0x0146;
+                }
+            L_0x0146:
+                goto L_0x019a
+            L_0x0147:
+                int r9 = android.os.Build.VERSION.SDK_INT
+                if (r9 <= r3) goto L_0x015b
+                int r9 = r1.orientation
+                if (r9 != r5) goto L_0x0155
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                r9.setRequestedOrientation(r5)
+                goto L_0x019a
+            L_0x0155:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                r9.setRequestedOrientation(r3)
+                goto L_0x019a
+            L_0x015b:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                r9.setRequestedOrientation(r5)
+                goto L_0x019a
+            L_0x0161:
+                int r9 = android.os.Build.VERSION.SDK_INT
+                if (r9 <= r3) goto L_0x0175
+                int r9 = r1.orientation
+                if (r9 != r4) goto L_0x016f
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                r9.setRequestedOrientation(r3)
+                goto L_0x019a
+            L_0x016f:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                r9.setRequestedOrientation(r2)
+                goto L_0x019a
+            L_0x0175:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                r9.setRequestedOrientation(r5)
+                goto L_0x019a
+            L_0x017b:
+                int r9 = r1.orientation
+                if (r9 != r5) goto L_0x0185
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                r9.setRequestedOrientation(r2)
+                goto L_0x019a
+            L_0x0185:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                r9.setRequestedOrientation(r0)
+                goto L_0x019a
+            L_0x018b:
+                int r9 = r1.orientation
+                if (r9 != r4) goto L_0x0195
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                r9.setRequestedOrientation(r0)
+                goto L_0x019a
+            L_0x0195:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                r9.setRequestedOrientation(r5)
+            L_0x019a:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                r9.showScanningPop()
+                goto L_0x047f
+            L_0x01a1:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                android.app.AlertDialog r9 = r9.confirmAlertDialog
+                if (r9 == 0) goto L_0x01be
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                android.app.AlertDialog r9 = r9.confirmAlertDialog
+                boolean r9 = r9.isShowing()
+                if (r9 == 0) goto L_0x01be
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                android.app.AlertDialog r9 = r9.confirmAlertDialog
+                r9.dismiss()
+            L_0x01be:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                boolean unused = r9.isStopScan = r5
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                android.os.Handler r9 = r9.scanningProgressHandler
+                r9.sendEmptyMessage(r1)
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                boolean r9 = r9.isCompletedScanProcess()
+                if (r9 != 0) goto L_0x01df
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                android.os.Handler r9 = r9.scanningProgressHandler
+                r9.sendEmptyMessageDelayed(r2, r6)
+                goto L_0x047f
+            L_0x01df:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                r9.updateScreenPreviewToLastData()
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                boolean r9 = r9.isConfirmCancel
+                if (r9 == 0) goto L_0x01ee
+                goto L_0x047f
+            L_0x01ee:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                android.app.AlertDialog r9 = r9.errorDialog
+                if (r9 == 0) goto L_0x037b
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                android.app.AlertDialog r9 = r9.errorDialog
+                boolean r9 = r9.isShowing()
+                if (r9 != 0) goto L_0x037b
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                epson.scan.lib.escanLib r9 = r9.escan
+                int[] r9 = r9.getStatus()
+                epson.scan.activity.ScanActivity r1 = epson.scan.activity.ScanActivity.this
+                int r1 = r1.error
+                r2 = -1100(0xfffffffffffffbb4, float:NaN)
+                if (r1 != r2) goto L_0x0227
+                r1 = r9[r5]
+                r2 = 5
+                if (r1 != r2) goto L_0x025d
+                r1 = r9[r4]
+                if (r1 == 0) goto L_0x025d
+                epson.scan.activity.ScanActivity r1 = epson.scan.activity.ScanActivity.this
+                r9 = r9[r4]
+                int unused = r1.error = r9
+                goto L_0x025d
+            L_0x0227:
+                epson.scan.activity.ScanActivity r1 = epson.scan.activity.ScanActivity.this
+                int r1 = r1.error
+                r3 = 2131625174(0x7f0e04d6, float:1.8877549E38)
+                if (r1 == r3) goto L_0x025d
+                epson.scan.activity.ScanActivity r1 = epson.scan.activity.ScanActivity.this
+                int r1 = r1.error
+                r3 = -1300(0xfffffffffffffaec, float:NaN)
+                if (r1 == r3) goto L_0x025d
+                epson.scan.activity.ScanActivity r1 = epson.scan.activity.ScanActivity.this
+                int r1 = r1.error
+                if (r1 == r2) goto L_0x025d
+                epson.scan.activity.ScanActivity r1 = epson.scan.activity.ScanActivity.this
+                int r1 = r1.error
+                if (r1 == r5) goto L_0x025d
+                r1 = r9[r4]
+                r2 = 100
+                if (r1 == r2) goto L_0x025d
+                r1 = r9[r4]
+                if (r1 == 0) goto L_0x025d
+                epson.scan.activity.ScanActivity r1 = epson.scan.activity.ScanActivity.this
+                r9 = r9[r4]
+                int unused = r1.error = r9
+            L_0x025d:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                java.lang.String r9 = r9.getCallingPackage()
+                java.lang.StringBuilder r1 = new java.lang.StringBuilder
+                r1.<init>()
+                java.lang.String r2 = "error = "
+                r1.append(r2)
+                epson.scan.activity.ScanActivity r2 = epson.scan.activity.ScanActivity.this
+                int r2 = r2.error
+                r1.append(r2)
+                java.lang.String r1 = r1.toString()
+                epson.print.Util.EPLog.m313i(r9, r1)
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                int r1 = r9.error
+                r9.setupErrorMessage(r1)
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                android.app.AlertDialog r9 = r9.errorDialog
+                r9.show()
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                android.content.Context r9 = r9.context
+                java.lang.String r1 = "scanner"
+                epson.scan.activity.ScanActivity r2 = epson.scan.activity.ScanActivity.this
+                java.lang.String r2 = r2.usingScannerIp
+                com.epson.mobilephone.common.wifidirect.WiFiDirectManager.disconnect(r9, r1, r2)
+                goto L_0x037b
+            L_0x02a0:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                boolean unused = r9.isStopScan = r5
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                java.lang.Thread r9 = r9.doscan
+                if (r9 == 0) goto L_0x02c2
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                java.lang.Thread r9 = r9.doscan
+                boolean r9 = r9.isAlive()
+                if (r9 == 0) goto L_0x02c2
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                java.lang.Thread r9 = r9.doscan
+                r9.interrupt()
+            L_0x02c2:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                epson.scan.lib.escanLib r9 = r9.escan
+                boolean r9 = r9.isScanning()
+                if (r9 != 0) goto L_0x02e7
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                java.lang.String r9 = r9.getLocalClassName()
+                java.lang.String r1 = "scan, cancel find"
+                epson.print.Util.EPLog.m313i(r9, r1)
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                epson.scan.lib.escanLib r9 = r9.escan
+                r9.escanWrapperCancelFindScanner()
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                r9.hideScanningPop()
+            L_0x02e7:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                epson.scan.lib.escanLib r9 = r9.escan
+                boolean r9 = r9.isScanning()
+                r1 = -2
+                if (r9 == 0) goto L_0x034f
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                epson.scan.lib.escanLib r9 = r9.escan
+                boolean r9 = r9.isJobDone()
+                if (r9 != 0) goto L_0x034f
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                epson.scan.lib.escanLib r9 = r9.escan
+                boolean r9 = r9.isCanselOK()
+                if (r9 != r5) goto L_0x032c
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                java.lang.String r9 = r9.getLocalClassName()
+                java.lang.String r2 = "isCanselOK OK"
+                epson.print.Util.EPLog.m313i(r9, r2)
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                java.lang.String r9 = r9.getLocalClassName()
+                java.lang.String r2 = "scan, cancel scan job"
+                epson.print.Util.EPLog.m313i(r9, r2)
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                epson.scan.lib.escanLib r9 = r9.escan
+                r9.cancelScanJob()
+                goto L_0x034f
+            L_0x032c:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                java.lang.String r9 = r9.getLocalClassName()
+                java.lang.String r2 = "isCanselOK NO"
+                epson.print.Util.EPLog.m313i(r9, r2)
+                java.lang.Thread.sleep(r6)     // Catch:{ InterruptedException -> 0x033b }
+                goto L_0x033f
+            L_0x033b:
+                r9 = move-exception
+                r9.printStackTrace()
+            L_0x033f:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                android.os.Handler r9 = r9.scanningProgressHandler
+                r9.sendEmptyMessage(r1)
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                boolean unused = r9.isConfirmCancel = r0
+                goto L_0x047f
+            L_0x034f:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                boolean unused = r9.isConfirmCancel = r0
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                boolean r9 = r9.isCompletedScanProcess()
+                if (r9 != 0) goto L_0x0367
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                android.os.Handler r9 = r9.scanningProgressHandler
+                r9.sendEmptyMessageDelayed(r1, r6)
+                goto L_0x047f
+            L_0x0367:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                r9.updateScreenPreviewToLastData()
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                android.content.Context r9 = r9.context
+                epson.scan.activity.ScanActivity r1 = epson.scan.activity.ScanActivity.this
+                java.lang.String r1 = r1.usingScannerIp
+                epson.scan.lib.ScannerConnection.disconnectIfSimpleAp(r9, r1)
+                goto L_0x047f
+            L_0x037b:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                r9.hideScanningPop()
+                goto L_0x047f
+            L_0x0382:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                java.lang.Thread r9 = r9.doscan
+                if (r9 == 0) goto L_0x0396
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                java.lang.Thread r9 = r9.doscan
+                boolean r9 = r9.isAlive()
+                if (r9 != 0) goto L_0x039e
+            L_0x0396:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                boolean r9 = r9.isValidArea()
+                if (r9 != 0) goto L_0x03ab
+            L_0x039e:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                android.os.Handler r9 = r9.scanningProgressHandler
+                r1 = 300(0x12c, double:1.48E-321)
+                r9.sendEmptyMessageDelayed(r3, r1)
+                goto L_0x047f
+            L_0x03ab:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                r9.scanStart()
+                goto L_0x047f
+            L_0x03b2:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                java.lang.String r9 = r9.getLocalClassName()
+                java.lang.String r1 = "MESSAGE SCAN FINISHED!!!"
+                epson.print.Util.EPLog.m313i(r9, r1)
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                epson.scan.lib.escanLib r1 = r9.escan
+                java.util.List r1 = r1.getListScannedFile()
+                int r1 = r1.size()
+                r9.totalScanned = r1
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                int r9 = r9.totalScanned
+                epson.scan.activity.ScanActivity r1 = epson.scan.activity.ScanActivity.this
+                epson.scan.activity.ScanCount.saveScanCount(r1, r9)
+                epson.scan.activity.ScanActivity r1 = epson.scan.activity.ScanActivity.this
+                epson.scan.lib.escanLib r1 = r1.escan
+                r1.setJobDone(r5)
+                epson.scan.activity.ScanActivity r1 = epson.scan.activity.ScanActivity.this
+                android.content.Context r1 = r1.getApplicationContext()
+                int r1 = com.epson.iprint.prtlogger.Analytics.getConnectionType(r1)
+                epson.scan.activity.ScanActivity r3 = epson.scan.activity.ScanActivity.this
+                android.app.AlertDialog r3 = r3.confirmAlertDialog
+                if (r3 == 0) goto L_0x0406
+                epson.scan.activity.ScanActivity r3 = epson.scan.activity.ScanActivity.this
+                android.app.AlertDialog r3 = r3.confirmAlertDialog
+                boolean r3 = r3.isShowing()
+                if (r3 == 0) goto L_0x0406
+                epson.scan.activity.ScanActivity r3 = epson.scan.activity.ScanActivity.this
+                android.app.AlertDialog r3 = r3.confirmAlertDialog
+                r3.dismiss()
+            L_0x0406:
+                epson.scan.activity.ScanActivity r3 = epson.scan.activity.ScanActivity.this
+                r3.updateDoneScanJob()
+                epson.scan.activity.ScanActivity r3 = epson.scan.activity.ScanActivity.this
+                java.util.ArrayList r3 = r3.getListSavedJPGFilePath()
+                int r3 = r3.size()
+                epson.scan.activity.ScanContinueParam.setScannedFileCount(r3)
+                boolean r3 = epson.scan.activity.ScanContinueParam.isReachMaximumScan()
+                if (r3 == 0) goto L_0x0431
+                epson.scan.activity.ScanActivity r3 = epson.scan.activity.ScanActivity.this
+                android.content.Context r3 = r3.context
+                java.lang.String r4 = "epson.scanner.SelectedScanner"
+                java.lang.String r6 = "SCAN_REFS_SETTINGS_SOURCE"
+                int r3 = epson.common.Utils.getPrefInt(r3, r4, r6)
+                if (r3 != r5) goto L_0x0431
+                epson.scan.activity.ScanActivity r3 = epson.scan.activity.ScanActivity.this
+                epson.scan.activity.ScanContinueParam.showScanErrorLimit(r3)
+            L_0x0431:
+                epson.scan.activity.ScanActivity r3 = epson.scan.activity.ScanActivity.this
+                r3.setRequestedOrientation(r2)
+                epson.scan.activity.ScanActivity r2 = epson.scan.activity.ScanActivity.this
+                android.content.Context r2 = r2.context
+                epson.scan.activity.ScanActivity r3 = epson.scan.activity.ScanActivity.this
+                java.lang.String r3 = r3.usingScannerIp
+                epson.scan.lib.ScannerConnection.disconnectIfSimpleAp(r2, r3)
+                epson.scan.activity.ScanActivity r2 = epson.scan.activity.ScanActivity.this
+                r2.loggerScanCountUp()
+                epson.scan.activity.ScanActivity r2 = epson.scan.activity.ScanActivity.this
+                r2.checkLoggerServer(r9, r1)
+                goto L_0x047f
+            L_0x044e:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                epson.scan.activity.ScanBaseView$ScanAreaSet r9 = r9.scanArea
+                r1 = 0
+                r9.redrawCBHandler = r1
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                boolean r9 = r9.isNeedRedrawBitmap
+                if (r9 != r5) goto L_0x0476
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                boolean unused = r9.isNeedRedrawBitmap = r0
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                android.graphics.RectF r1 = r9.getRectScanArea()
+                android.graphics.RectF unused = r9.area = r1
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                android.graphics.RectF r1 = r9.area
+                r9.setBmRectF(r1)
+            L_0x0476:
+                epson.scan.activity.ScanActivity r9 = epson.scan.activity.ScanActivity.this
+                epson.scan.activity.ScanBaseView$ScanAreaSet r9 = r9.scanArea
+                r9.postInvalidate()
+            L_0x047f:
+                return r0
+            */
+            throw new UnsupportedOperationException("Method not decompiled: epson.scan.activity.ScanActivity.C240214.handleMessage(android.os.Message):boolean");
+        }
+    });
+    private TextView tvScanResult;
+    /* access modifiers changed from: private */
+    public String usingScannerId;
+    /* access modifiers changed from: private */
+    public String usingScannerIp;
+    /* access modifiers changed from: private */
+    public int usingScannerLocation;
+    private String usingScannerModel;
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        setContentView((int) C2135R.layout.scan);
+        setActionBar((int) C2135R.string.str_scan_btn, true);
+        setContext(this);
+        this.mActivityPaused = true;
+        this.mScanAreaBackgroundViewSizeChanged = false;
+        ExternalFileUtils.getInstance(this).initTempViewDir();
+        ExternalFileUtils.getInstance(this).initPrintDir();
+        Intent intent = getIntent();
+        if (intent.getAction() == null || !intent.getAction().equals(EpsoniPrintSharedActivity.ACTION_SCAN)) {
+            this.extParam = new SharedParamScan();
+        } else {
+            this.isCustomAction = true;
+            this.extParam = (SharedParamScan) intent.getSerializableExtra("extParam");
+        }
+        try {
+            this.mScanLog = (CommonLog) intent.getSerializableExtra(PARAM_KEY_SCAN_LOG);
+        } catch (ClassCastException unused) {
+        }
+        if (this.mScanLog == null) {
+            this.mScanLog = new CommonLog();
+        }
+        this.btnScan = (Button) findViewById(C2135R.C2137id.btnScan);
+        this.btnScan.setOnClickListener(this.mButtonScanListener);
+        this.btnSave = (Button) findViewById(C2135R.C2137id.btnSave);
+        this.btnSave.setOnClickListener(this.mButtonSaveListener);
+        this.btnMail = (Button) findViewById(C2135R.C2137id.btnMail);
+        this.btnMail.setOnClickListener(this.mButtonMailListener);
+        this.btnPrint = (Button) findViewById(C2135R.C2137id.btnPrint);
+        this.btnPrint.setOnClickListener(this.mButtonPrintListener);
+        getSelectedScannerInfo();
+        disableFunctionButtons();
+        if (this.isCustomAction) {
+            this.btnMail.setVisibility(8);
+            this.btnPrint.setVisibility(8);
+        }
+        this.llScanAreaBackground = (LinearLayout) findViewById(C2135R.C2137id.llScanAreaBackground);
+        this.scanAreaBackground = new ScanBaseView.ScanAreaBackground(getContext());
+        this.llScanAreaBackground.addView(this.scanAreaBackground);
+        this.tvScanResult = (TextView) findViewById(C2135R.C2137id.tvScanResult);
+        this.scanArea = new ScanBaseView.ScanAreaSet(getContext());
+        this.flScanResult = (FrameLayout) findViewById(C2135R.C2137id.flScanResult);
+        this.gestureDetector = new GestureDetector(this, new ScanAreaGestureDetector());
+        this.gestureListener = new View.OnTouchListener() {
+            public boolean onTouch(View view, MotionEvent motionEvent) {
+                ScanActivity.this.gestureDetector.onTouchEvent(motionEvent);
+                ScanActivity.this.scanArea.onTouchEvent(motionEvent);
+                return true;
+            }
+        };
+        this.flScanResult.setOnTouchListener(this.gestureListener);
+        this.btnNext = (Button) findViewById(C2135R.C2137id.btnNext);
+        this.btnNext.setOnClickListener(this.mButtonNextListener);
+        this.btnNext.setOnTouchListener(new View.OnTouchListener() {
+            public boolean onTouch(View view, MotionEvent motionEvent) {
+                switch (motionEvent.getAction()) {
+                    case 0:
+                        ScanActivity.this.btnNext.setBackgroundResource(C2135R.C2136drawable.bt_right_hover);
+                        return false;
+                    case 1:
+                        ScanActivity.this.btnNext.setBackgroundResource(C2135R.C2136drawable.bt_right_1);
+                        return false;
+                    default:
+                        return false;
+                }
+            }
+        });
+        this.btnPrev = (Button) findViewById(C2135R.C2137id.btnPrev);
+        this.btnPrev.setOnClickListener(this.mButtonPrevListener);
+        this.btnPrev.setOnTouchListener(new View.OnTouchListener() {
+            public boolean onTouch(View view, MotionEvent motionEvent) {
+                switch (motionEvent.getAction()) {
+                    case 0:
+                        ScanActivity.this.btnPrev.setBackgroundResource(C2135R.C2136drawable.bt_left_hover);
+                        return false;
+                    case 1:
+                        ScanActivity.this.btnPrev.setBackgroundResource(C2135R.C2136drawable.bt_left);
+                        return false;
+                    default:
+                        return false;
+                }
+            }
+        });
+        this.btnNext.setVisibility(8);
+        this.btnPrev.setVisibility(8);
+        this.errorDialog = new AlertDialog.Builder(this).create();
+        this.escan = getEscan();
+        this.escan.escanWrapperInitDriver(this);
+        this.escan.setScanHandler(this.scanningProgressHandler);
+        this.llScanArea = (LinearLayout) findViewById(C2135R.C2137id.llScanArea);
+        this.llScanArea.addView(this.scanArea);
+        this.llScanningProgress = (LinearLayout) findViewById(C2135R.C2137id.llScanningProgress);
+        this.btnCancelScan = (Button) findViewById(C2135R.C2137id.btnCancelScan);
+        this.btnCancelScan.setOnClickListener(this.mButtonCancelScanListener);
+        this.llScanArea.getViewTreeObserver().addOnPreDrawListener(this.mOnPreDrawListener);
+        if (ActivityRequestPermissions.isRuntimePermissionSupported()) {
+            String[] strArr = {"android.permission.WRITE_EXTERNAL_STORAGE"};
+            ActivityRequestPermissions.Permission permission = new ActivityRequestPermissions.Permission(strArr[0], new String[]{getString(C2135R.string.permission_dialog_title), getString(C2135R.string.permission_dialog_title)}, new String[]{ActivityRequestPermissions.DialogParameter.setMessage2((Context) this, getString(C2135R.string.permission_dialog_message_storage)), ActivityRequestPermissions.DialogParameter.setMessage3A((Context) this, getString(C2135R.string.permission_dialog_message_storage), getString(C2135R.string.permission_function_storage))});
+            if (!ActivityRequestPermissions.checkPermission(this, strArr)) {
+                ActivityRequestPermissions.requestPermission((Activity) this, permission, 4);
+                return;
+            }
+        }
+        if (bundle == null && !startI2ActivityIfEscIVersionMismatch()) {
+        }
+    }
+
+    private boolean startI2ActivityIfEscIVersionMismatch() {
+        if (ScanInfoStorage.loadEscIVersion(this) != 2) {
+            return false;
+        }
+        SharedParamScan sharedParamScan = null;
+        setBm((Bitmap) null);
+        boolean z = this.bAutoStartScan;
+        if (this.isCustomAction) {
+            sharedParamScan = this.extParam;
+        }
+        startActivityForResult(ScanActivityCommonParams.getEscIVersionChangeIntent(this, 2, z, sharedParamScan, this.mScanLog), 20);
+        return true;
+    }
+
+    public void onScanAreaSizeChange() {
+        this.mScanAreaBackgroundViewSizeChanged = true;
+    }
+
+    public boolean onKeyDown(int i, KeyEvent keyEvent) {
+        LinearLayout linearLayout = this.llScanningProgress;
+        if (linearLayout == null || linearLayout.getVisibility() != 0) {
+            return super.onKeyDown(i, keyEvent);
+        }
+        return true;
+    }
+
+    /* access modifiers changed from: protected */
+    public void onRestart() {
+        this.isNeedDeleteTempFile = false;
+        super.onRestart();
+    }
+
+    /* access modifiers changed from: protected */
+    public void onStart() {
+        if (this.isNeedDeleteTempFile) {
+            removeTempContents(this);
+        }
+        super.onStart();
+    }
+
+    public void onBackPressed() {
+        super.onBackPressed();
+        this.escan.escanWrapperReleaseDriver();
+        removeTempContents(this);
+        finish();
+    }
+
+    /* access modifiers changed from: protected */
+    public void onDestroy() {
+        removeTempContents(this);
+        if (this.isCustomAction) {
+            ArrayList<String> listSavedJPGFilePath = getListSavedJPGFilePath();
+            for (int i = 0; i < listSavedJPGFilePath.size(); i++) {
+                Utils.deleteTempFile(listSavedJPGFilePath.get(i));
+            }
+        }
+        System.gc();
+        super.onDestroy();
+    }
+
+    /* access modifiers changed from: protected */
+    public void onResume() {
+        super.onResume();
+        NfcTagUtils.enableForegroundDispatch(this, (IntentFilter[]) null, (String[][]) null);
+        this.mActivityPaused = false;
+    }
+
+    /* access modifiers changed from: protected */
+    public void onPause() {
+        super.onPause();
+        NfcTagUtils.disableForegroundDispatch(this);
+        this.mActivityPaused = true;
+        if (isFinishing()) {
+            this.escan.escanWrapperReleaseDriver();
+        }
+    }
+
+    /* access modifiers changed from: protected */
+    public void onNewIntent(Intent intent) {
+        NfcTagUtils.EpsonNfcConnectInfo parseNECTag;
+        super.onNewIntent(intent);
+        String action = intent.getAction();
+        Thread thread = this.doscan;
+        if ((thread == null || !thread.isAlive()) && "android.nfc.action.NDEF_DISCOVERED".equals(action) && (parseNECTag = NfcTagUtils.parseNECTag(this, intent)) != null) {
+            Intent intent2 = new Intent();
+            intent2.setClass(this, ActivityNfcPrinter.class);
+            intent2.putExtra(ActivityNfcPrinter.CONNECTINFO, parseNECTag);
+            intent2.putExtra(ActivityNfcPrinter.CHANGEMODE, 2);
+            startActivityForResult(intent2, 2);
+            this.bAutoStartScan = true;
+        }
+    }
+
+    public static void removeTempContents(Context context) {
+        File file = new File(ExternalFileUtils.getInstance(context).getScannedImageDir());
+        if (file.exists()) {
+            if (file.isDirectory()) {
+                for (File file2 : file.listFiles()) {
+                    if (file2.isFile()) {
+                        file2.delete();
+                    }
+                }
+            }
+            if (file.isFile()) {
+                file.delete();
+            }
+        }
+    }
+
+    /* access modifiers changed from: protected */
+    public void onStop() {
+        this.isStopScan = true;
+        this.escan.setJobDone(false);
+        Thread thread = this.doscan;
+        if (thread != null && thread.isAlive()) {
+            this.scanningProgressHandler.sendEmptyMessage(-2);
+        }
+        AlertDialog alertDialog = this.errorDialog;
+        if (alertDialog != null && alertDialog.isShowing()) {
+            this.errorDialog.dismiss();
+        }
+        LinearLayout linearLayout = this.llScanningProgress;
+        if (linearLayout != null && linearLayout.getVisibility() == 0) {
+            this.llScanningProgress.setVisibility(8);
+        }
+        super.onStop();
+    }
+
+    public void onConfigurationChanged(Configuration configuration) {
+        super.onConfigurationChanged(configuration);
+        this.isNeedGetScanSize = true;
+        this.isNeedScale = true;
+        RectF rectF = this.area;
+        if (rectF != null) {
+            this.area = getRectScanArea();
+            if (((int) rectF.left) == ((int) this.area.left) && ((int) rectF.top) == ((int) this.area.top) && ((int) rectF.right) == ((int) this.area.right) && ((int) rectF.bottom) == ((int) this.area.bottom)) {
+                this.isNeedRedrawBitmap = true;
+            } else {
+                this.isNeedRedrawBitmap = false;
+            }
+        }
+        if (this.mActivityPaused) {
+            this.mScanAreaBackgroundViewSizeChanged = true;
+        }
+    }
+
+    public boolean onCreateOptionsMenu(Menu menu) {
+        getMenuInflater().inflate(C2135R.C2138menu.scan_menu, menu);
+        super.onCreateOptionsMenu(menu);
+        return true;
+    }
+
+    public boolean onOptionsItemSelected(MenuItem menuItem) {
+        if (menuItem.getItemId() != C2135R.C2137id.btn_scan_settings) {
+            return super.onOptionsItemSelected(menuItem);
+        }
+        callScanSetting();
+        return true;
+    }
+
+    /* access modifiers changed from: private */
+    public void initFrameWithScreensize() {
+        int i = 20;
+        while (true) {
+            int i2 = this.areaHeightOnScreen;
+            if (i < i2) {
+                this.MARGIN_TOP_BOT = i;
+                setMaxScanHeightOnScreen((double) (i2 - (this.MARGIN_TOP_BOT * 2)));
+                setScale(((double) getMaxheight()) / getMaxScanHeightOnScreen());
+                setMaxScanWidthOnScreen(((double) getMaxwidth()) / getScale());
+                if (getMaxScanWidthOnScreen() > ((double) (this.areaWidthOnScreen - 20))) {
+                    i += 10;
+                } else {
+                    return;
+                }
+            } else {
+                return;
+            }
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void chooseScanSize(int i) {
+        int i2;
+        int i3;
+        int i4 = i;
+        if (i4 == Constants.PaperName.EPS_MSID_USER.getCode()) {
+            int i5 = this.resolution;
+            double d = i5 != 75 ? i5 != 300 ? 1.0d : 2.0d : 0.5d;
+            i3 = Utils.getPrefInt(this.context, epson.common.Constants.SCAN_REFS_SUPPORTED_OPTIONS, epson.common.Constants.SCAN_REFS_MAX_WIDTH);
+            i2 = Utils.getPrefInt(this.context, epson.common.Constants.SCAN_REFS_SUPPORTED_OPTIONS, epson.common.Constants.SCAN_REFS_MAX_HEIGHT);
+            if (i3 == 0) {
+                i3 = (int) (1275.0d * d);
+            }
+            if (i2 == 0) {
+                i2 = (int) (d * 1755.0d);
+            }
+        } else {
+            Point paperSize = ScanSizeHelper.getPaperSize(i4, this.resolution);
+            int i6 = paperSize.x;
+            i2 = paperSize.y;
+            i3 = i6;
+        }
+        if (this.isDoctable) {
+            if (this.scanOrigin == 2) {
+                setmTop(getmBaseTop());
+                double d2 = (double) i3;
+                double d3 = (double) i2;
+                setmBot(new Point((int) Math.ceil(((double) getmBaseTop().x) + ((getMaxScanWidthOnScreen() * d2) / ((double) getMaxwidth()))), (int) Math.round(((double) getmBaseTop().y) + ((getMaxScanHeightOnScreen() * d3) / ((double) getMaxheight())))));
+                setPiBaseTop(new ScanBaseView.PointInfo((double) getmBaseTop().x, (double) getmBaseTop().y));
+                setPiBaseBot(new ScanBaseView.PointInfo(((double) getmBaseTop().x) + ((d2 * getMaxScanWidthOnScreen()) / ((double) getMaxwidth())), ((double) getmBaseTop().y) + ((d3 * getMaxScanHeightOnScreen()) / ((double) getMaxheight()))));
+                setScreenStatus(1);
+            }
+            hideTotalScanned();
+        } else {
+            setMaxwidth(i3);
+            setMaxheight(i2);
+            setScale(((double) getMaxheight()) / getMaxScanHeightOnScreen());
+            setMaxScanWidthOnScreen((double) ((int) (((double) getMaxwidth()) / getScale())));
+            setmBaseTop(new Point(((int) (((double) this.areaWidthOnScreen) - getMaxScanWidthOnScreen())) / 2, this.MARGIN_TOP_BOT));
+            setmBaseBot(new Point(this.areaWidthOnScreen - getmBaseTop().x, this.areaHeightOnScreen - this.MARGIN_TOP_BOT));
+            setmTop(getmBaseTop());
+            setmBot(getmBaseBot());
+            setPiBaseTop(new ScanBaseView.PointInfo((((double) this.areaWidthOnScreen) - getMaxScanWidthOnScreen()) / 2.0d, (double) this.MARGIN_TOP_BOT));
+            setPiBaseBot(new ScanBaseView.PointInfo((double) (this.areaWidthOnScreen - getmBaseTop().x), (double) (this.areaHeightOnScreen - this.MARGIN_TOP_BOT)));
+            if (this.isNeedClearBm) {
+                hideTotalScanned();
+                setBm((Bitmap) null);
+            }
+        }
+        setmCenter(calculateTheCenterPoint(getmTop(), getmBot()));
+        setSetSize(true);
+        this.scanArea.postInvalidate();
+        this.scanAreaBackground.postInvalidate();
+        if (this.isDoctable) {
+            Utils.savePref(getApplicationContext(), epson.common.Constants.SCAN_REFS_USED_SCANNER_PATH, epson.common.Constants.SCAN_REFS_SCANNER_CHOSEN_SIZE_DOC, i4);
+        } else {
+            Utils.savePref(getApplicationContext(), epson.common.Constants.SCAN_REFS_USED_SCANNER_PATH, epson.common.Constants.SCAN_REFS_SCANNER_CHOSEN_SIZE_ADF, i4);
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void nextPage() {
+        this.curentViewingFile++;
+        if (this.curentViewingFile > 300 || this.curentViewingFile > this.totalScanned) {
+            this.curentViewingFile--;
+            return;
+        }
+        updateThumbResult(this.curentViewingFile);
+        showDisplayingResult();
+        this.scanArea.postInvalidate();
+    }
+
+    /* access modifiers changed from: private */
+    public void prevPage() {
+        this.curentViewingFile--;
+        if (this.curentViewingFile < 1) {
+            this.curentViewingFile++;
+            return;
+        }
+        updateThumbResult(this.curentViewingFile);
+        showDisplayingResult();
+        this.scanArea.postInvalidate();
+    }
+
+    /* access modifiers changed from: private */
+    public void scanStart() {
+        if (this.usingScannerModel.equals(getString(C2135R.string.str_lbl_title_scan)) || this.usingScannerModel.equals("")) {
+            new AlertDialog.Builder(this.context).setCancelable(false).setTitle(C2135R.string.scanner_not_select).setMessage(getString(C2135R.string.scanner_notselect_warning)).setPositiveButton(getString(C2135R.string.str_ok), new DialogInterface.OnClickListener() {
+                public void onClick(DialogInterface dialogInterface, int i) {
+                }
+            }).show();
+            return;
+        }
+        if (this.isCustomAction) {
+            this.extParam.clearArrayOutFilePath();
+        }
+        Thread thread = this.doscan;
+        if ((thread == null || !thread.isAlive()) && isValidArea()) {
+            this.error = 0;
+            setBm((Bitmap) null);
+            this.isNeedClearBm = false;
+            this.scanAreaBackground.hideText(true);
+            this.scanAreaBackground.invalidate();
+            preparingForScan();
+            this.scanningProgressHandler.sendEmptyMessage(0);
+            this.doscan = new Thread() {
+                public void run() {
+                    if (!WiFiDirectManager.isNeedConnect(ScanActivity.this, WiFiDirectManager.DEVICE_TYPE_SCANNER) || !WiFiDirectManager.reconnect(ScanActivity.this, WiFiDirectManager.DEVICE_TYPE_SCANNER, 10)) {
+                        if (!ScanContinueParam.isContinueScanning()) {
+                            ScanCount.countUpScanPage(ScanActivity.this.getApplicationContext());
+                        }
+                        if (!Utils.isMediaMounted()) {
+                            int unused = ScanActivity.this.error = 101;
+                            ScanActivity.this.scanningProgressHandler.sendEmptyMessage(-1);
+                        } else if (!ScanActivity.this.canStartScan()) {
+                            int unused2 = ScanActivity.this.error = -1001;
+                            ScanActivity.this.scanningProgressHandler.sendEmptyMessage(-1);
+                        } else if (ScanActivity.this.usingScannerId == null || ScanActivity.this.usingScannerId.trim().length() < 1) {
+                            int unused3 = ScanActivity.this.error = -1300;
+                            ScanActivity.this.scanningProgressHandler.sendEmptyMessage(-1);
+                        } else {
+                            if (ScanActivity.this.usingScannerLocation != 3) {
+                                ScanActivity scanActivity = ScanActivity.this;
+                                int unused4 = scanActivity.error = scanActivity.escan.probeScannerById(ScanActivity.this.usingScannerId, ScanActivity.this.usingScannerIp);
+                                if (ScanActivity.this.error == -1051) {
+                                    EPLog.m307e(ScanActivity.this.getLocalClassName(), "scan, ESCAN_ERR_LIB_NOT_INITIALIZED");
+                                    ScanActivity.this.escan.escanWrapperInitDriver(ScanActivity.this);
+                                    ScanActivity scanActivity2 = ScanActivity.this;
+                                    int unused5 = scanActivity2.error = scanActivity2.escan.probeScannerById(ScanActivity.this.usingScannerId, ScanActivity.this.usingScannerIp);
+                                }
+                            } else {
+                                ScanActivity scanActivity3 = ScanActivity.this;
+                                int unused6 = scanActivity3.error = scanActivity3.escan.probeScannerByIp(ScanActivity.this.usingScannerId, ScanActivity.this.usingScannerIp);
+                                if (ScanActivity.this.error == -1051) {
+                                    EPLog.m307e(ScanActivity.this.getLocalClassName(), "scan, ESCAN_ERR_LIB_NOT_INITIALIZED");
+                                    ScanActivity.this.escan.escanWrapperInitDriver(ScanActivity.this);
+                                    ScanActivity scanActivity4 = ScanActivity.this;
+                                    int unused7 = scanActivity4.error = scanActivity4.escan.probeScannerByIp(ScanActivity.this.usingScannerId, ScanActivity.this.usingScannerIp);
+                                }
+                            }
+                            if (ScanActivity.this.error == 0) {
+                                EPLog.m313i(ScanActivity.this.getLocalClassName(), "scan, done probe");
+                                if (ScanActivity.this.escan.getListFoundScanner() == null || ScanActivity.this.escan.getListFoundScanner().size() < 1) {
+                                    EPLog.m307e(ScanActivity.this.getLocalClassName(), "scan, ESCAN_ERR_SCANNER_NOT_FOUND");
+                                    int unused8 = ScanActivity.this.error = -1300;
+                                    if (!ScanActivity.this.isStopScan) {
+                                        ScanActivity.this.scanningProgressHandler.sendEmptyMessage(-1);
+                                        return;
+                                    }
+                                    return;
+                                }
+                                ScanActivity scanActivity5 = ScanActivity.this;
+                                int unused9 = scanActivity5.error = scanActivity5.escan.escanWrapperSetScanner(0);
+                                if (ScanActivity.this.error != 0) {
+                                    int unused10 = ScanActivity.this.error = -1300;
+                                    ScanActivity.this.scanningProgressHandler.sendEmptyMessage(-1);
+                                    return;
+                                }
+                                ScanActivity scanActivity6 = ScanActivity.this;
+                                String unused11 = scanActivity6.usingScannerIp = scanActivity6.escan.getListFoundScanner().get(0).getIp();
+                                ScanActivity.this.escan.resetEscanLib();
+                                if (ScanActivity.this.escan.getListScannedFile() == null) {
+                                    EPLog.m313i(ScanActivity.this.getLocalClassName(), "scan, getListScannedFile == NULL");
+                                    ScanActivity.this.escan.setListScannedFile(new ArrayList());
+                                } else if (!ScanContinueParam.isContinueScanning()) {
+                                    EPLog.m313i(ScanActivity.this.getLocalClassName(), "scan, getListScannedFile != NULL");
+                                    ScanActivity.this.escan.getListScannedFile().clear();
+                                    int unused12 = ScanActivity.this.previousTotalScanned = 0;
+                                }
+                                ScanActivity scanActivity7 = ScanActivity.this;
+                                int unused13 = scanActivity7.error = scanActivity7.escan.GetSupportedOption();
+                                ScanActivity.this.escan.makeJobAttribute(ScanActivity.this.getContext(), ScanActivity.this.extParam);
+                                synchronized (ScanActivity.this) {
+                                    I1ScanParams unused14 = ScanActivity.this.mI1ScanParams = ScanActivity.this.escan.getScanParams();
+                                }
+                                if (ScanActivity.this.isStopScan || ScanActivity.this.escan.isScanning()) {
+                                    EPLog.m307e(ScanActivity.this.getLocalClassName(), "scan, after makeJobAttribute");
+                                    return;
+                                }
+                                ScanActivity scanActivity8 = ScanActivity.this;
+                                String access$3300 = scanActivity8.makeImageName(scanActivity8.extParam);
+                                String localClassName = ScanActivity.this.getLocalClassName();
+                                EPLog.m313i(localClassName, "scan, fname = " + access$3300);
+                                ScanActivity scanActivity9 = ScanActivity.this;
+                                int unused15 = scanActivity9.error = scanActivity9.escan.startScanJob(access$3300);
+                                String localClassName2 = ScanActivity.this.getLocalClassName();
+                                EPLog.m313i(localClassName2, "[ESCAN][DONE] escanLib().startScanJob - return - " + ScanActivity.this.error);
+                                if (ScanActivity.this.error == 40) {
+                                    boolean unused16 = ScanActivity.this.isStopScan = true;
+                                    int unused17 = ScanActivity.this.error = 0;
+                                }
+                                if (!ScanActivity.this.isStopScan) {
+                                    EPLog.m307e(ScanActivity.this.getLocalClassName(), "IN-> isStopScan.");
+                                    if (!(ScanActivity.this.escan.getStatus()[2] == 4 || (ScanActivity.this.error == 0 && ScanActivity.this.escan.getStatus()[2] == 0))) {
+                                        ScanActivity.this.scanningProgressHandler.sendEmptyMessage(-1);
+                                        if (ScanActivity.this.escan.getListScannedFile().size() > 0) {
+                                            EPLog.m307e(ScanActivity.this.getLocalClassName(), "END SCAN because error.");
+                                            ScanActivity.this.scanningProgressHandler.sendEmptyMessageDelayed(2, 500);
+                                        }
+                                        EPLog.m307e(ScanActivity.this.getLocalClassName(), "SCAN error.");
+                                        return;
+                                    }
+                                }
+                                EPLog.m313i(ScanActivity.this.getLocalClassName(), "END SCAN NORMALY.");
+                                ScanActivity.this.scanningProgressHandler.sendEmptyMessage(2);
+                            } else if (!ScanActivity.this.isStopScan) {
+                                ScanActivity.this.scanningProgressHandler.sendEmptyMessage(-1);
+                            }
+                        }
+                    }
+                }
+            };
+            this.doscan.start();
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void check3GAndStartPrint() {
+        ScanContinueParam.judgeScanContinue(this, getListSavedJPGFilePath());
+    }
+
+    /* access modifiers changed from: private */
+    public boolean canStartScan() {
+        StatFs statFs = new StatFs(CommonDefine.DEFAULT_DIR);
+        double availableBlocksLong = ((double) statFs.getAvailableBlocksLong()) * ((double) statFs.getBlockSizeLong());
+        double maxwidth = (double) (getMaxwidth() * getMaxheight() * 3);
+        if (availableBlocksLong > (!this.isDoctable ? maxwidth * ((double) (ScanContinueParam.getAvailableScanPageCount() + 1)) : maxwidth * 2.0d)) {
+            return true;
+        }
+        return false;
+    }
+
+    /* access modifiers changed from: private */
+    public String makeImageName(SharedParamScan sharedParamScan) {
+        StringBuilder sb;
+        if (sharedParamScan.isAvailable()) {
+            File file = new File(sharedParamScan.getFolder_name());
+            file.mkdirs();
+            sb = new StringBuilder(file.getPath());
+            sb.append(CommonDefine.SLASH);
+            sb.append(sharedParamScan.getFile_name());
+        } else {
+            File file2 = new File(ExternalFileUtils.getInstance(this).getScannedImageDir());
+            file2.mkdirs();
+            if (!ScanContinueParam.isContinueScanning()) {
+                removeTempScannedImage(file2);
+                ScanContinueParam.resetParameter();
+            }
+            Calendar instance = Calendar.getInstance();
+            sb = new StringBuilder(file2.getPath());
+            sb.append(CommonDefine.SLASH);
+            sb.append(instance.get(1));
+            sb.append(instance.get(2) + 1);
+            sb.append(instance.get(5));
+            sb.append(instance.get(11));
+            sb.append(instance.get(12));
+            sb.append(instance.get(13));
+        }
+        return sb.toString();
+    }
+
+    private static void removeTempScannedImage(File file) {
+        if (!file.exists()) {
+            return;
+        }
+        if (file.isDirectory()) {
+            for (File file2 : file.listFiles()) {
+                if (file2.isFile()) {
+                    file2.delete();
+                }
+            }
+        } else if (file.isFile()) {
+            file.delete();
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void setupErrorMessage(int i) {
+        if (i != -500001) {
+            if (i != -1501) {
+                if (i != -1300) {
+                    if (i != -1100) {
+                        if (i == -1001) {
+                            this.errorDialog = Utils.makeMessageBox(getContext(), getString(C2135R.string.str_blank), getString(C2135R.string.str_err_msg_out_of_memory_title), getString(C2135R.string.str_ok));
+                            return;
+                        } else if (i != C2135R.string.str_lbl_title_scan) {
+                            switch (i) {
+                                case 2:
+                                    this.errorDialog = Utils.makeMessageBox(getContext(), getString(C2135R.string.str_err_msg_scan_coveropen_title), getString(C2135R.string.str_err_msg_scan_coveropen), getString(C2135R.string.str_ok));
+                                    return;
+                                case 3:
+                                    this.errorDialog = Utils.makeMessageBox(getContext(), getString(C2135R.string.str_err_msg_scan_paperjam_title), getString(C2135R.string.str_err_msg_scan_paperjam), getString(C2135R.string.str_ok));
+                                    return;
+                                case 4:
+                                    this.errorDialog = Utils.makeMessageBox(getContext(), getString(C2135R.string.str_err_msg_scan_paperout_title), getString(C2135R.string.str_err_msg_scan_paperout), getString(C2135R.string.str_ok));
+                                    return;
+                                case 5:
+                                    break;
+                                case 6:
+                                    break;
+                                default:
+                                    switch (i) {
+                                        case 100:
+                                            this.errorDialog = Utils.makeMessageBox(getContext(), getString(C2135R.string.str_err_msg_scan_adf_paperout_title), getString(C2135R.string.str_err_msg_scan_adf_paperout), getString(C2135R.string.str_ok));
+                                            return;
+                                        case 101:
+                                            this.errorDialog = Utils.makeMessageBox(getContext(), getString(C2135R.string.unknow_error_title), getString(C2135R.string.str_no_sdcard), getString(C2135R.string.str_ok));
+                                            return;
+                                        default:
+                                            this.errorDialog = Utils.makeMessageBox(getContext(), getString(C2135R.string.str_err_msg_scan_generic_internal_title), getString(C2135R.string.str_err_msg_scan_generic_internal), getString(C2135R.string.str_ok));
+                                            return;
+                                    }
+                            }
+                        } else {
+                            this.errorDialog = Utils.makeMessageBox(getContext(), getString(C2135R.string.str_lbl_title_scan), getString(C2135R.string.str_ok));
+                            return;
+                        }
+                    }
+                    this.errorDialog = Utils.makeMessageBox(getContext(), getString(C2135R.string.str_err_msg_scan_comm_title), getString(C2135R.string.str_err_msg_scan_comm), getString(C2135R.string.str_ok));
+                    return;
+                }
+                this.errorDialog = Utils.makeMessageBox(getContext(), getString(C2135R.string.str_err_msg_scan_not_found_title), getString(C2135R.string.str_err_msg_scan_not_found_research), getString(C2135R.string.str_ok));
+                return;
+            }
+            this.errorDialog = Utils.makeMessageBox(getContext(), getString(C2135R.string.str_err_msg_scan_busy_title), getString(C2135R.string.str_err_msg_scan_busy), getString(C2135R.string.str_ok));
+            return;
+        }
+        this.errorDialog = Utils.makeMessageBox(this.context, getString(C2135R.string.EPS_PRNERR_COMM_TITLE2), getString(C2135R.string.str_ipprinter_comerror), getString(C2135R.string.str_ok));
+    }
+
+    /* access modifiers changed from: private */
+    public void showScanningPop() {
+        LinearLayout linearLayout = this.llScanningProgress;
+        if (linearLayout != null) {
+            linearLayout.setVisibility(0);
+            findViewById(C2135R.C2137id.llScanFunctionBar).invalidate();
+        }
+        EPLog.m313i(TAG, "addFlags : FLAG_KEEP_SCREEN_ON ");
+        getWindow().addFlags(128);
+    }
+
+    /* access modifiers changed from: private */
+    public void hideScanningPop() {
+        LinearLayout linearLayout = this.llScanningProgress;
+        if (linearLayout != null) {
+            linearLayout.setVisibility(8);
+            findViewById(C2135R.C2137id.llScanFunctionBar).invalidate();
+        }
+        EPLog.m313i(TAG, "clearFlags : FLAG_KEEP_SCREEN_ON ");
+        getWindow().clearFlags(128);
+    }
+
+    static PrintLog getPrintLog() {
+        PrintLog printLog = new PrintLog();
+        printLog.uiRoute = 4;
+        return printLog;
+    }
+
+    private void getSelectedScannerInfo() {
+        if (this.isNeedGetScanSize) {
+            String prefString = Utils.getPrefString(getApplicationContext(), epson.common.Constants.SCAN_REFS_USED_SCANNER_PATH, epson.common.Constants.SCAN_REFS_SCANNER_ID);
+            if (!this.isNeedUpdateScanningArea) {
+                if (prefString.equals(this.usingScannerId)) {
+                    this.isNeedUpdateScanningArea = false;
+                } else {
+                    this.isNeedUpdateScanningArea = true;
+                    setBm((Bitmap) null);
+                }
+            }
+            this.usingScannerId = prefString;
+            this.usingScannerModel = Utils.getPrefString(getApplicationContext(), epson.common.Constants.SCAN_REFS_USED_SCANNER_PATH, epson.common.Constants.SCAN_REFS_SCANNER_MODEL);
+            this.usingScannerIp = Utils.getPrefString(getApplicationContext(), epson.common.Constants.SCAN_REFS_USED_SCANNER_PATH, epson.common.Constants.SCAN_REFS_SCANNER_IP);
+            this.usingScannerLocation = Utils.getPrefInt(getApplicationContext(), epson.common.Constants.SCAN_REFS_USED_SCANNER_PATH, epson.common.Constants.SCAN_REFS_SCANNER_LOCATION);
+            boolean z = Utils.getPrefInt(this.context, epson.common.Constants.SCAN_REFS_USED_SCANNER_PATH, epson.common.Constants.SCAN_REFS_SETTINGS_SOURCE) == 0;
+            if (z != this.isDoctable) {
+                this.isNeedClearBm = true;
+                setBm((Bitmap) null);
+            } else {
+                this.isNeedClearBm = false;
+            }
+            if (!z && z == this.isDoctable && !this.isNeedUpdateScanningArea) {
+                this.isNeedUpdateScanningArea = false;
+            }
+            if (z && z == this.isDoctable && !this.isNeedUpdateScanningArea) {
+                this.isNeedUpdateScanningArea = false;
+            } else {
+                this.isNeedUpdateScanningArea = true;
+            }
+            this.isDoctable = z;
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void loggerScanCountUp() {
+        if (this.totalScanned > 0) {
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public boolean isCompletedScanProcess() {
+        return getListSavedJPGFilePath().size() == this.totalScanned;
+    }
+
+    private void preparingForScan() {
+        this.escan.setJobDone(false);
+        this.escan.setScanning(false);
+        this.isConfirmCancel = false;
+        this.previousTotalScanned = this.escan.getListScannedFile().size();
+        this.area = getRectScanArea();
+        if (!ScanContinueParam.isContinueScanning()) {
+            this.totalScanned = 0;
+            this.curentViewingFile = 0;
+            hideTotalScanned();
+            disableFunctionButtons();
+            getListSavedJPGFilePath().clear();
+        }
+    }
+
+    private void showTotalScanned() {
+        this.tvScanResult.setVisibility(0);
+        TextView textView = this.tvScanResult;
+        textView.setText(this.curentViewingFile + epson.common.Constants.CROSS + this.totalScanned);
+    }
+
+    private void hideTotalScanned() {
+        this.tvScanResult.setVisibility(8);
+        this.btnNext.setVisibility(8);
+        this.btnPrev.setVisibility(8);
+    }
+
+    /* access modifiers changed from: private */
+    public void showDisplayingResult() {
+        TextView textView = this.tvScanResult;
+        textView.setText(this.curentViewingFile + epson.common.Constants.CROSS + this.totalScanned);
+    }
+
+    /* access modifiers changed from: private */
+    public void updateDoneScanJob() {
+        this.totalScanned = this.escan.getListScannedFile().size();
+        if (this.totalScanned == this.previousTotalScanned) {
+            if (Utils.getPrefInt(this.context, epson.common.Constants.SCAN_REFS_USED_SCANNER_PATH, epson.common.Constants.SCAN_REFS_SETTINGS_SOURCE) == 1) {
+                this.error = 100;
+                this.scanningProgressHandler.sendEmptyMessage(-1);
+                return;
+            }
+            this.totalScanned = this.escan.getListScannedFile().size();
+            if (this.totalScanned == this.previousTotalScanned) {
+                this.error = -1100;
+                this.scanningProgressHandler.sendEmptyMessage(-1);
+                return;
+            }
+        }
+        if (this.totalScanned > 0) {
+            enableFunctionButtons();
+        }
+        if (this.totalScanned > 1) {
+            this.curentViewingFile = this.totalScanned;
+            this.btnNext.setVisibility(0);
+            this.btnPrev.setVisibility(8);
+            showTotalScanned();
+        }
+        if (!isCompletedScanProcess()) {
+            this.scanningProgressHandler.sendEmptyMessageDelayed(2, 1000);
+            return;
+        }
+        this.scanningProgressHandler.sendEmptyMessage(-3);
+        updateThumbResult(this.curentViewingFile);
+    }
+
+    /* access modifiers changed from: private */
+    public void updateScreenPreviewToLastData() {
+        if (this.totalScanned > 1) {
+            this.curentViewingFile = this.totalScanned;
+            showTotalScanned();
+            updateThumbResult(this.curentViewingFile);
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void updateThumbResult(int i) {
+        if (this.totalScanned >= 1) {
+            if (this.totalScanned > 1) {
+                if (this.curentViewingFile == this.totalScanned) {
+                    this.btnNext.setVisibility(8);
+                } else {
+                    this.btnNext.setVisibility(0);
+                }
+                if (this.curentViewingFile == 1) {
+                    this.btnPrev.setVisibility(8);
+                } else {
+                    this.btnPrev.setVisibility(0);
+                }
+            }
+            if (i < 1) {
+                i = 1;
+            }
+            if (i > this.totalScanned) {
+                i = this.totalScanned;
+            }
+            String str = getListSavedJPGFilePath().get(i - 1);
+            try {
+                int width = (int) this.area.width();
+                int height = (int) this.area.height();
+                if (width * height < 819200) {
+                    width = 1024;
+                    height = Videoio.CAP_PVAPI;
+                }
+                Bitmap createBitmapWithUri = Photo.createBitmapWithUri(str, width, height, false);
+                setBmRectF(this.area);
+                setBm(createBitmapWithUri);
+                this.scanArea.postInvalidate();
+            } catch (IOException e) {
+                e.printStackTrace();
+            } catch (OutOfMemoryError e2) {
+                e2.printStackTrace();
+            }
+        }
+    }
+
+    private void disableFunctionButtons() {
+        CustomButtonWrapper.setScanButtonState(this.btnSave, C2135R.C2136drawable.scan_save, C2135R.string.str_save, false);
+        CustomButtonWrapper.setScanButtonState(this.btnMail, C2135R.C2136drawable.scan_mail, C2135R.string.str_btn_mail, false);
+        CustomButtonWrapper.setScanButtonState(this.btnPrint, C2135R.C2136drawable.scan_print, C2135R.string.str_print, false);
+    }
+
+    private void enableFunctionButtons() {
+        CustomButtonWrapper.setScanButtonState(this.btnSave, C2135R.C2136drawable.scan_save, C2135R.string.str_save, true);
+        CustomButtonWrapper.setScanButtonState(this.btnMail, C2135R.C2136drawable.scan_mail, C2135R.string.str_btn_mail, true);
+        CustomButtonWrapper.setScanButtonState(this.btnPrint, C2135R.C2136drawable.scan_print, C2135R.string.str_print, true);
+    }
+
+    /* access modifiers changed from: private */
+    public void confirmationDialog(String str) {
+        if (!this.isConfirmCancel) {
+            this.confirmAlertDialog = new AlertDialog.Builder(this.context).create();
+            this.confirmAlertDialog.setIcon(C2135R.C2136drawable.ic_action_warning);
+            this.confirmAlertDialog.setCancelable(false);
+            this.confirmAlertDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
+                public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
+                    return keyEvent.getKeyCode() == 84;
+                }
+            });
+            this.confirmAlertDialog.setMessage(str);
+            this.confirmAlertDialog.setButton(-2, getText(C2135R.string.str_no), new DialogInterface.OnClickListener() {
+                public void onClick(DialogInterface dialogInterface, int i) {
+                    if (!ScanActivity.this.escan.isJobDone()) {
+                        ScanActivity.this.showScanningPop();
+                    }
+                    boolean unused = ScanActivity.this.isConfirmCancel = false;
+                }
+            });
+            this.confirmAlertDialog.setButton(-1, getText(C2135R.string.str_yes), new DialogInterface.OnClickListener() {
+                public void onClick(DialogInterface dialogInterface, int i) {
+                    boolean unused = ScanActivity.this.isConfirmCancel = true;
+                    String localClassName = ScanActivity.this.getLocalClassName();
+                    EPLog.m313i(localClassName, "yes pressed, isConfirmCancel = " + ScanActivity.this.isConfirmCancel);
+                    if (!ScanActivity.this.escan.isJobDone()) {
+                        ScanActivity.this.showScanningPop();
+                    }
+                    ScanActivity.this.scanningProgressHandler.sendEmptyMessage(-2);
+                }
+            });
+            this.confirmAlertDialog.show();
+        }
+    }
+
+    /* access modifiers changed from: protected */
+    public void onActivityResult(int i, int i2, Intent intent) {
+        super.onActivityResult(i, i2, intent);
+        if (i != 10) {
+            if (i != 20) {
+                switch (i) {
+                    case 2:
+                        this.escan.resetEscanLib();
+                        this.escan.escanWrapperInitDriver(this);
+                        this.escan.setScanHandler(this.scanningProgressHandler);
+                        onScanSettingEnd(i2, intent);
+                        this.bAutoStartScan = false;
+                        return;
+                    case 4:
+                        if (i2 != -1) {
+                            onBackPressed();
+                            return;
+                        } else if (!startI2ActivityIfEscIVersionMismatch()) {
+                            return;
+                        } else {
+                            return;
+                        }
+                    default:
+                        return;
+                }
+            } else if (i2 == 1) {
+                this.bAutoStartScan = I2ScanActivity.getAutoStartRequestedFromReturnIntent(intent);
+                Intent intent2 = new Intent();
+                intent2.putExtra(ScanSettingsActivity.IS_NEW_SAVE, true);
+                intent2.putExtra(ScanSettingsActivity.NO_CLEAR_RESULT, false);
+                onScanSettingEnd(-1, intent2);
+                this.bAutoStartScan = false;
+            } else if (this.isCustomAction) {
+                setResult(i2, intent);
+                finish();
+            } else {
+                finish();
+            }
+        } else if (i2 != -1) {
+            hideScanningPop();
+        } else {
+            this.mButtonScanListener.onClick(this.btnScan);
+            EPLog.m305d(TAG, "Send CHECK_PRINTER Message.");
+        }
+    }
+
+    private void onScanSettingEnd(int i, Intent intent) {
+        if (i == -1) {
+            if (!startI2ActivityIfEscIVersionMismatch() && intent != null) {
+                Bundle extras = intent.getExtras();
+                String string = extras.getString(epson.common.Constants.ACT_RESULT);
+                if (string == null || !string.equals(epson.common.Constants.ACT_RESULT_BACK)) {
+                    this.isNeedGetScanSize = extras.getBoolean(ScanSettingsActivity.IS_NEW_SAVE);
+                    boolean z = extras.getBoolean(ScanSettingsActivity.NO_CLEAR_RESULT);
+                    if (!z) {
+                        setBm((Bitmap) null);
+                        hideTotalScanned();
+                        disableFunctionButtons();
+                        removeTempContents(getApplicationContext());
+                        if (this.escan.getListScannedFile() != null) {
+                            this.escan.getListScannedFile().clear();
+                            this.totalScanned = 0;
+                            this.curentViewingFile = 0;
+                        }
+                        if (getListSavedJPGFilePath() != null) {
+                            getListSavedJPGFilePath().clear();
+                        }
+                        ScanContinueParam.resetParameter();
+                    }
+                    getSelectedScannerInfo();
+                    int prefInt = Utils.getPrefInt(getContext(), epson.common.Constants.SCAN_REFS_USED_SCANNER_PATH, epson.common.Constants.SCAN_REFS_SCANNER_CHOSEN_SIZE);
+                    if (prefInt != Constants.PaperName.EPS_MSID_UNKNOWN.getCode()) {
+                        chooseScanSize(prefInt);
+                    } else {
+                        String str = this.oldScannerId;
+                        if (str == null || str.length() == 0 || this.usingScannerId.length() == 0 || this.oldScannerId.equals(this.usingScannerId)) {
+                            int prefInt2 = Utils.getPrefInt(getContext(), epson.common.Constants.SCAN_REFS_SUPPORTED_OPTIONS, epson.common.Constants.SCAN_REFS_MAX_WIDTH);
+                            int prefInt3 = Utils.getPrefInt(getContext(), epson.common.Constants.SCAN_REFS_SUPPORTED_OPTIONS, epson.common.Constants.SCAN_REFS_MAX_HEIGHT);
+                            if (prefInt2 < getMaxwidth() || prefInt3 < getMaxheight()) {
+                                chooseScanSize(ScanSizeHelper.getDefaultScanSize());
+                            }
+                        } else {
+                            chooseScanSize(ScanSizeHelper.getDefaultScanSize());
+                        }
+                    }
+                    if (!z) {
+                        this.isNeedGetScanSize = true;
+                        this.isNeedUpdateScanningArea = true;
+                    }
+                    if (this.bAutoStartScan) {
+                        this.mButtonScanListener.onClick(this.btnScan);
+                        EPLog.m305d(TAG, "Send CHECK_PRINTER Message.");
+                    }
+                }
+            }
+        } else if (i == 0 && !startI2ActivityIfEscIVersionMismatch()) {
+            this.isNeedGetScanSize = false;
+        }
+    }
+
+    public void onRequestScanAction() {
+        scanStart();
+    }
+
+    class ScanAreaGestureDetector extends GestureDetector.SimpleOnGestureListener {
+        ScanAreaGestureDetector() {
+        }
+
+        public void onLongPress(MotionEvent motionEvent) {
+            ScanActivity scanActivity = ScanActivity.this;
+            scanActivity.bLongTouch = true;
+            scanActivity.scanArea.postInvalidate();
+            super.onLongPress(motionEvent);
+        }
+
+        public boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent2, float f, float f2) {
+            Display defaultDisplay = ScanActivity.this.getWindowManager().getDefaultDisplay();
+            Point point = new Point();
+            defaultDisplay.getSize(point);
+            float f3 = (float) point.y;
+            float f4 = (float) point.x;
+            if (f3 > f4) {
+                f3 = f4;
+            }
+            double rawX = (double) ((int) (motionEvent.getRawX() - motionEvent2.getRawX()));
+            if (rawX < ((double) (-f3)) * 0.1d) {
+                ScanActivity.this.prevPage();
+                return false;
+            } else if (rawX <= ((double) f3) * 0.1d) {
+                return false;
+            } else {
+                ScanActivity.this.nextPage();
+                return false;
+            }
+        }
+    }
+
+    private void callScanSetting() {
+        this.escan.escanWrapperReleaseDriver();
+        this.oldScannerId = this.usingScannerId;
+        Intent intent = new Intent(this, ScanSettingsActivity.class);
+        if (this.isCustomAction) {
+            if (this.extParam.getRes_main() > 0 && this.extParam.getRes_sub() > 0) {
+                intent.putExtra(ScanSettingsActivity.HIDE_RESOLUTION, true);
+            }
+            intent.putExtra(ScanSettingsActivity.HIDE_COLOR_MODE, true);
+            intent.putExtra(ScanSettingsActivity.PARAM_KEY_EXTERNAL_DATA, this.extParam);
+        }
+        intent.setAction("android.intent.action.VIEW");
+        startActivityForResult(intent, 2);
+    }
+
+    class BitmapTask extends AsyncTask<String, Void, Bitmap> {
+        public BitmapTask() {
+        }
+
+        /* access modifiers changed from: protected */
+        public Bitmap doInBackground(String... strArr) {
+            if (ScanActivity.this.escan.isJobDone()) {
+                return null;
+            }
+            return ScanActivity.this.showBitmap(strArr[0]);
+        }
+
+        /* access modifiers changed from: protected */
+        public void onPostExecute(Bitmap bitmap) {
+            ScanActivity.this.displayPreview(bitmap);
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public Bitmap showBitmap(String str) {
+        Bitmap bitmap;
+        this.isDecoding = true;
+        EPLog.m313i(getCallingPackage(), "start decode for preview ");
+        File file = new File(str);
+        if (file.exists() && file.isFile()) {
+            try {
+                bitmap = Utils.decodeFile(file, this.areaHeightOnScreen - (this.MARGIN_TOP_BOT * 2));
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            } catch (OutOfMemoryError e2) {
+                e2.printStackTrace();
+            }
+            EPLog.m313i(getCallingPackage(), "end decode for preview ");
+            return bitmap;
+        }
+        bitmap = null;
+        EPLog.m313i(getCallingPackage(), "end decode for preview ");
+        return bitmap;
+    }
+
+    /* access modifiers changed from: private */
+    public void displayPreview(Bitmap bitmap) {
+        if (!this.escan.isJobDone()) {
+            EPLog.m313i(EpsoniPrintSharedActivity.ACTIVITY_SCAN, "update UI");
+            setBm(bitmap);
+            setBmRectF(this.area);
+            this.scanArea.postInvalidate();
+        }
+        this.isDecoding = false;
+    }
+
+    /* access modifiers changed from: private */
+    public void convert(String str) {
+        getListSavedJPGFilePath().add(str.substring(0, str.length() - 4).concat(".jpg"));
+        if (this.isCustomAction) {
+            this.extParam.setArrayOutFilePath(str);
+        } else {
+            Utils.deleteTempFile(str);
+        }
+        this.convertCount++;
+        updateThumbResult(this.convertCount);
+    }
+
+    @SuppressLint({"NewApi"})
+    static void localSetAllCaps(TextView textView, boolean z) {
+        if (Build.VERSION.SDK_INT >= 21) {
+            textView.setAllCaps(z);
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void checkLoggerServer(int i, int i2) {
+        I1ScanParams i1ScanParams;
+        if (this.mScanLog.action == 0) {
+            this.mScanLog.action = PrintLog.ACTION_SCAN;
+        }
+        CommonLog commonLog = this.mScanLog;
+        commonLog.numberOfSheet = i - this.previousTotalScanned;
+        commonLog.connectionType = i2;
+        ScannerInfo scannerInfo = new ScannerInfo();
+        ScanInfoStorage.getInstance().loadScannerConnectivityInfo(this, scannerInfo);
+        this.mScanLog.printerName = scannerInfo.getModelName();
+        synchronized (this) {
+            i1ScanParams = this.mI1ScanParams;
+        }
+        if (this.mScanLog.numberOfSheet > 0 && i1ScanParams != null) {
+            Analytics.sendScanI1Log(this, i1ScanParams, this.mScanLog, ScanContinueParam.isContinueScanning());
+        }
+    }
+
+    public static ArrayList<String> getScanFileListFromReturnIntent(@Nullable Intent intent) {
+        if (intent == null) {
+            return null;
+        }
+        return intent.getStringArrayListExtra(RETURN_KEY_SCAN_FILE);
+    }
+}

+ 53 - 0
app/src/main/java/epson/scan/activity/ScanActivityCommonParams.java

@@ -0,0 +1,53 @@
+package epson.scan.activity;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import com.epson.iprint.prtlogger.CommonLog;
+import com.epson.iprint.shared.SharedParamScan;
+
+class ScanActivityCommonParams {
+    private static final Class<? extends Activity> ESC_I1_SCAN_ACTIVITY = ScanActivity.class;
+    private static final Class<? extends Activity> ESC_I2_SCAN_ACTIVITY = I2ScanActivity.class;
+    private static final String PARAM_KEY_EXTERNAL_INTENT_DATA = "external-intent-data";
+    private static final String PARAM_KEY_START_SCAN_AT_ACTIVITY_CHANGE = "start-scan-at-activity-change";
+
+    ScanActivityCommonParams() {
+    }
+
+    @NonNull
+    static Intent getEscIVersionChangeIntent(@NonNull Context context, int i, boolean z, @Nullable SharedParamScan sharedParamScan, @Nullable CommonLog commonLog) {
+        Intent intent = new Intent(context, getScanActivityClass(i));
+        intent.putExtra(PARAM_KEY_START_SCAN_AT_ACTIVITY_CHANGE, z);
+        intent.putExtra(PARAM_KEY_EXTERNAL_INTENT_DATA, sharedParamScan);
+        intent.putExtra(ScanActivity.PARAM_KEY_SCAN_LOG, commonLog);
+        return intent;
+    }
+
+    private static Class<?> getScanActivityClass(int i) {
+        if (i != 2) {
+            return ESC_I1_SCAN_ACTIVITY;
+        }
+        return ESC_I2_SCAN_ACTIVITY;
+    }
+
+    static boolean startScanAtActivityChange(@Nullable Intent intent) {
+        return intent != null && intent.getBooleanExtra(PARAM_KEY_START_SCAN_AT_ACTIVITY_CHANGE, false);
+    }
+
+    static SharedParamScan getExternalIntentData(@Nullable Intent intent) {
+        if (intent == null) {
+            return null;
+        }
+        return (SharedParamScan) intent.getSerializableExtra(PARAM_KEY_EXTERNAL_INTENT_DATA);
+    }
+
+    static CommonLog getCommonLog(@Nullable Intent intent) {
+        if (intent == null) {
+            return null;
+        }
+        return (CommonLog) intent.getSerializableExtra(ScanActivity.PARAM_KEY_SCAN_LOG);
+    }
+}

+ 897 - 0
app/src/main/java/epson/scan/activity/ScanBaseView.java

@@ -0,0 +1,897 @@
+package epson.scan.activity;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.DashPathEffect;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.Point;
+import android.graphics.Rect;
+import android.graphics.RectF;
+import android.os.Build;
+import android.os.Handler;
+import android.support.p000v4.view.ViewCompat;
+import android.view.MotionEvent;
+import android.view.View;
+import android.widget.EditText;
+import epson.common.Constants;
+import epson.common.Utils;
+import epson.print.ActivityIACommon;
+import epson.print.C2135R;
+import epson.print.Util.EPLog;
+import epson.scan.lib.escanLib;
+import java.util.ArrayList;
+import java.util.Locale;
+
+public class ScanBaseView extends ActivityIACommon {
+    public static int SCAN_AREA_HOTSPOT_SIZE = 40;
+    private static final int SCAN_REDRAWBITMAP = -100;
+    private static final String TAG = "ScanBaseView";
+    public final int LINE_AREA_BORDER = 2;
+    public final int LINE_CORNER_BIG = 18;
+    public final int LINE_CORNER_BIG_WIDTH = 150;
+    public final int LINE_CORNER_SMALL = 6;
+    public final int LINE_CORNER_SMALL_WIDTH = 60;
+    public final int MARGIN_LEFT_RIGHT = 10;
+    public int MARGIN_TOP_BOT = 60;
+    final int MAX_DASHEFFECT_PHASE;
+    public final int SCREEN_STATUS_BOTLEFT_TOPRIGHT = 2;
+    public final int SCREEN_STATUS_BOTRIGHT_TOPLEFT = 3;
+    public final int SCREEN_STATUS_TOPLEFT_BOTRIGHT = 1;
+    public final int SCREEN_STATUS_TOPRIGHT_BOTLEFT = 4;
+    /* access modifiers changed from: private */
+    public BitmapFactory.Options _bmOption;
+    public boolean bLongTouch = false;
+    public Bitmap bmCenter;
+    private RectF bmRectF;
+    Context context;
+    int curentViewingFile;
+    escanLib escan;
+    private PointInfo first;
+    /* access modifiers changed from: private */
+    public int inSampleSize;
+    /* access modifiers changed from: private */
+    public boolean isDisplayResult;
+    public boolean isDoctable = false;
+    /* access modifiers changed from: private */
+    public boolean isSetSize = false;
+    private boolean isValidArea;
+    private ArrayList<String> listSavedJPGFilePath;
+    private Point mBaseBot;
+    private Point mBaseTop;
+    private Bitmap mBitmap;
+    Point mBot;
+    Point mCenter;
+    Point mFirstTouch;
+    private Paint mPaint;
+    Point mTop;
+    Point mTouch;
+    int mWhere;
+    private double maxScanHeightOnScreen = 0.0d;
+    private double maxScanWidthOnScreen = 0.0d;
+    private int maxheight = 0;
+    private int maxwidth = 0;
+    int phase;
+    private PointInfo piBaseBot;
+    private PointInfo piBaseTop;
+    private RectF rectScanArea;
+    private double scale;
+    /* access modifiers changed from: private */
+    public int screenStatus = 1;
+    private PointInfo second;
+    int totalScanned;
+
+    class PointInfo {
+        /* access modifiers changed from: private */
+
+        /* renamed from: x */
+        public double f411x = 0.0d;
+        /* access modifiers changed from: private */
+
+        /* renamed from: y */
+        public double f412y = 0.0d;
+
+        public PointInfo(double d, double d2) {
+            this.f411x = d;
+            this.f412y = d2;
+        }
+
+        public double getX() {
+            return this.f411x;
+        }
+
+        public void setX(double d) {
+            this.f411x = d;
+        }
+
+        public double getY() {
+            return this.f412y;
+        }
+
+        public void setY(double d) {
+            this.f412y = d;
+        }
+
+        public String toString() {
+            return String.format(Locale.US, "(%.2f,%.2f)", new Object[]{Double.valueOf(this.f411x), Double.valueOf(this.f412y)});
+        }
+    }
+
+    public PointInfo getPiBaseTop() {
+        return this.piBaseTop;
+    }
+
+    public void setPiBaseTop(PointInfo pointInfo) {
+        this.piBaseTop = pointInfo;
+    }
+
+    public PointInfo getPiBaseBot() {
+        return this.piBaseBot;
+    }
+
+    public void setPiBaseBot(PointInfo pointInfo) {
+        this.piBaseBot = pointInfo;
+    }
+
+    public Context getContext() {
+        return this.context;
+    }
+
+    public void setContext(Context context2) {
+        this.context = context2;
+    }
+
+    public Point getmBaseTop() {
+        return this.mBaseTop;
+    }
+
+    public void setmBaseTop(Point point) {
+        this.mBaseTop = point;
+    }
+
+    public Point getmBaseBot() {
+        return this.mBaseBot;
+    }
+
+    public void setmBaseBot(Point point) {
+        this.mBaseBot = point;
+    }
+
+    public RectF getRectScanArea() {
+        return this.rectScanArea;
+    }
+
+    public void setRectScanArea(RectF rectF) {
+        this.rectScanArea = rectF;
+    }
+
+    public escanLib getEscan() {
+        return this.escan;
+    }
+
+    public void setEscan(escanLib escanlib) {
+        this.escan = escanlib;
+    }
+
+    public double getScale() {
+        return this.scale;
+    }
+
+    public void setScale(double d) {
+        this.scale = d;
+    }
+
+    public int getMaxwidth() {
+        return this.maxwidth;
+    }
+
+    public void setMaxwidth(int i) {
+        this.maxwidth = i;
+    }
+
+    public int getMaxheight() {
+        return this.maxheight;
+    }
+
+    public void setMaxheight(int i) {
+        this.maxheight = i;
+    }
+
+    public Point getmTop() {
+        return this.mTop;
+    }
+
+    public void setmTop(Point point) {
+        this.mTop = point;
+    }
+
+    public Point getmBot() {
+        return this.mBot;
+    }
+
+    public void setmBot(Point point) {
+        this.mBot = point;
+    }
+
+    public Point getmCenter() {
+        return this.mCenter;
+    }
+
+    public void setmCenter(Point point) {
+        this.mCenter = point;
+    }
+
+    public Point getmTouch() {
+        return this.mTouch;
+    }
+
+    public void setmTouch(Point point) {
+        this.mTouch = point;
+    }
+
+    public Point getmFirstTouch() {
+        return this.mFirstTouch;
+    }
+
+    public void setmFirstTouch(Point point) {
+        this.mFirstTouch = point;
+    }
+
+    public Bitmap getBmCenter() {
+        return this.bmCenter;
+    }
+
+    public void setBmCenter(Bitmap bitmap) {
+        this.bmCenter = bitmap;
+    }
+
+    public int getScreenStatus() {
+        return this.screenStatus;
+    }
+
+    public void setScreenStatus(int i) {
+        this.screenStatus = i;
+    }
+
+    public BitmapFactory.Options get_bmOption() {
+        return this._bmOption;
+    }
+
+    public void set_bmOption(BitmapFactory.Options options) {
+        this._bmOption = options;
+    }
+
+    public int getInSampleSize() {
+        return this.inSampleSize;
+    }
+
+    public void setInSampleSize(int i) {
+        this.inSampleSize = i;
+    }
+
+    public boolean isSetSize() {
+        return this.isSetSize;
+    }
+
+    public void setSetSize(boolean z) {
+        this.isSetSize = z;
+    }
+
+    public RectF getBmRectF() {
+        return this.bmRectF;
+    }
+
+    public void setBmRectF(RectF rectF) {
+        this.bmRectF = rectF;
+    }
+
+    public Bitmap getBm() {
+        return this.mBitmap;
+    }
+
+    public void setBm(Bitmap bitmap) {
+        this.mBitmap = bitmap;
+    }
+
+    public int getmWhere() {
+        return this.mWhere;
+    }
+
+    public void setmWhere(int i) {
+        this.mWhere = i;
+    }
+
+    public Paint getmPaint() {
+        return this.mPaint;
+    }
+
+    public void setmPaint(Paint paint) {
+        this.mPaint = paint;
+    }
+
+    public void setListSavedJPGFilePath(ArrayList<String> arrayList) {
+        this.listSavedJPGFilePath = arrayList;
+    }
+
+    public ArrayList<String> getListSavedJPGFilePath() {
+        return this.listSavedJPGFilePath;
+    }
+
+    public double getMaxScanHeightOnScreen() {
+        return this.maxScanHeightOnScreen;
+    }
+
+    public void setMaxScanHeightOnScreen(double d) {
+        this.maxScanHeightOnScreen = d;
+    }
+
+    public double getMaxScanWidthOnScreen() {
+        return this.maxScanWidthOnScreen;
+    }
+
+    public void setMaxScanWidthOnScreen(double d) {
+        this.maxScanWidthOnScreen = d;
+    }
+
+    public ScanBaseView() {
+        this.piBaseTop = new PointInfo(0.0d, 0.0d);
+        this.piBaseBot = new PointInfo(0.0d, 0.0d);
+        this.mBaseTop = new Point();
+        this.mBaseBot = new Point();
+        this.mTop = new Point();
+        this.mBot = new Point();
+        this.mCenter = new Point();
+        this.mTouch = new Point();
+        this.mFirstTouch = new Point();
+        this.curentViewingFile = 1;
+        this.totalScanned = 0;
+        this.mWhere = 2;
+        this.first = new PointInfo(0.0d, 0.0d);
+        this.second = new PointInfo(0.0d, 0.0d);
+        this.isValidArea = false;
+        this.isDisplayResult = false;
+        this.phase = 0;
+        this.MAX_DASHEFFECT_PHASE = 1000;
+        this.escan = new escanLib();
+        this.escan.setJobDone(false);
+        this._bmOption = new BitmapFactory.Options();
+        if (this.mPaint == null) {
+            this.mPaint = new Paint();
+            this.mPaint.setStrokeWidth(2.0f);
+            this.mPaint.setColor(ViewCompat.MEASURED_STATE_MASK);
+        }
+        this.listSavedJPGFilePath = new ArrayList<>();
+    }
+
+    public void setupScanArea() {
+        double unused = this.first.f411x = Math.min(this.piBaseTop.f411x, this.piBaseBot.f411x);
+        double unused2 = this.first.f412y = Math.min(this.piBaseTop.f412y, this.piBaseBot.f412y);
+        double unused3 = this.second.f411x = Math.max(this.piBaseTop.f411x, this.piBaseBot.f411x);
+        double unused4 = this.second.f412y = Math.max(this.piBaseTop.f412y, this.piBaseBot.f412y);
+        if (this.first.f411x < ((double) getmBaseTop().x)) {
+            double unused5 = this.first.f411x = (double) getmBaseTop().x;
+        }
+        if (this.first.f412y < ((double) getmBaseTop().y)) {
+            double unused6 = this.first.f412y = (double) getmBaseTop().y;
+        }
+        if (this.second.f411x > ((double) getmBaseBot().x)) {
+            double unused7 = this.second.f411x = (double) getmBaseBot().x;
+        }
+        if (this.second.f412y > ((double) getmBaseBot().y)) {
+            double unused8 = this.second.f412y = (double) getmBaseBot().y;
+        }
+        if (this.second.f411x <= ((double) getmBaseTop().x) || this.first.f411x >= ((double) getmBaseBot().x) || this.second.f412y <= ((double) getmBaseTop().y) || this.first.f412y >= ((double) getmBaseBot().y)) {
+            this.isValidArea = false;
+        } else {
+            this.isValidArea = true;
+        }
+        this.escan.setOffsetX((int) Math.max((Math.abs(this.first.f411x - ((double) getmBaseTop().x)) * ((double) getMaxwidth())) / getMaxScanWidthOnScreen(), 0.0d));
+        this.escan.setOffsetY((int) Math.max((Math.abs(this.first.f412y - ((double) getmBaseTop().y)) * ((double) getMaxheight())) / getMaxScanHeightOnScreen(), 0.0d));
+        int min = (int) Math.min((Math.abs(this.first.f411x - this.second.f411x) * ((double) getMaxwidth())) / getMaxScanWidthOnScreen(), (double) (getMaxwidth() - this.escan.getOffsetX()));
+        int min2 = (int) Math.min((Math.abs(this.first.f412y - this.second.f412y) * ((double) getMaxheight())) / getMaxScanHeightOnScreen(), (double) (getMaxheight() - this.escan.getOffsetY()));
+        if (min == 0) {
+            escanLib escanlib = this.escan;
+            escanlib.setOffsetX(escanlib.getOffsetX() - 1);
+            min = 1;
+        }
+        if (min2 == 0) {
+            escanLib escanlib2 = this.escan;
+            escanlib2.setOffsetY(escanlib2.getOffsetY() - 1);
+            min2 = 1;
+        }
+        this.escan.setScanAreaWidth(min);
+        this.escan.setScanAreaHeight(min2);
+        if (Utils.getPrefInt(this.context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_2SIDED) == 1 || !this.isDoctable) {
+            this.escan.setOffsetX(Utils.getPrefInt(getContext(), Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_MAX_WIDTH) - min);
+        }
+        this.rectScanArea = new RectF((float) ((int) Math.max(this.first.f411x, (double) getmBaseTop().x)), (float) ((int) Math.max(this.first.f412y, (double) getmBaseTop().y)), (float) ((int) Math.min(this.second.f411x, (double) getmBaseBot().x)), (float) ((int) Math.min(this.second.f412y, (double) getmBaseBot().y)));
+    }
+
+    public Point calculateTheCenterPoint(Point point, Point point2) {
+        Point point3 = new Point();
+        point3.x = Math.min(point.x, point2.x) + Math.round((float) (Math.abs(point.x - point2.x) / 2));
+        point3.y = Math.min(point.y, point2.y) + Math.round((float) (Math.abs(point.y - point2.y) / 2));
+        return point3;
+    }
+
+    public boolean isValidArea() {
+        return this.isValidArea;
+    }
+
+    public void setValidArea(boolean z) {
+        this.isValidArea = z;
+    }
+
+    class ScanAreaSet extends View {
+        private Point _pBaseBottomRight;
+        private Point _pBaseCenter;
+        private Point _pBaseTopLeft;
+        int _touchtime = 0;
+        public Handler redrawCBHandler = null;
+
+        public ScanAreaSet(Context context) {
+            super(context);
+            ScanBaseView.SCAN_AREA_HOTSPOT_SIZE = (int) ((((float) ScanBaseView.SCAN_AREA_HOTSPOT_SIZE) * getResources().getDisplayMetrics().density) + 0.5f);
+        }
+
+        /* access modifiers changed from: protected */
+        public void onSizeChanged(int i, int i2, int i3, int i4) {
+            super.onSizeChanged(i, i2, i3, i4);
+        }
+
+        /* access modifiers changed from: protected */
+        public void onDraw(Canvas canvas) {
+            super.onDraw(canvas);
+            if (ScanBaseView.this.bLongTouch && ScanBaseView.this.mWhere != 2) {
+                invalidate();
+                ScanBaseView.this.phase += 2;
+                if (ScanBaseView.this.phase > 1000) {
+                    ScanBaseView.this.phase = 0;
+                }
+            }
+            drawScanArea(canvas);
+            Handler handler = this.redrawCBHandler;
+            if (handler != null) {
+                handler.sendEmptyMessage(-100);
+            }
+        }
+
+        private synchronized void drawScanArea(Canvas canvas) {
+            this._pBaseTopLeft = ScanBaseView.this.getmTop();
+            this._pBaseBottomRight = ScanBaseView.this.getmBot();
+            if (!ScanBaseView.this.isDisplayResult && ScanBaseView.this.getBm() != null) {
+                if (Build.VERSION.SDK_INT >= 14) {
+                    EPLog.m313i("drawScanArea", "14");
+                    Bitmap bm = ScanBaseView.this.getBm();
+                    RectF bmRectF = ScanBaseView.this.getBmRectF();
+                    Bitmap createScaledBitmap = Bitmap.createScaledBitmap(bm, (int) bmRectF.width(), (int) bmRectF.height(), true);
+                    ScanBaseView.this.setBm(createScaledBitmap);
+                    canvas.drawBitmap(createScaledBitmap, ScanBaseView.this.getBmRectF().left, ScanBaseView.this.getBmRectF().top, (Paint) null);
+                } else {
+                    canvas.drawBitmap(ScanBaseView.this.getBm(), (Rect) null, ScanBaseView.this.getBmRectF(), ScanBaseView.this.getmPaint());
+                }
+            }
+            if (ScanBaseView.this.isDoctable) {
+                if (ScanBaseView.this.isSetSize) {
+                    drawNormalCorner(canvas);
+                    this._pBaseCenter = ScanBaseView.this.getmCenter();
+                }
+                Paint paint = new Paint();
+                if (!ScanBaseView.this.bLongTouch || ScanBaseView.this.mWhere == 2) {
+                    Paint paint2 = ScanBaseView.this.getmPaint();
+                    canvas.drawLine((float) this._pBaseTopLeft.x, (float) this._pBaseTopLeft.y, (float) this._pBaseBottomRight.x, (float) this._pBaseTopLeft.y, paint2);
+                    canvas.drawLine((float) this._pBaseBottomRight.x, (float) this._pBaseTopLeft.y, (float) this._pBaseBottomRight.x, (float) this._pBaseBottomRight.y, paint2);
+                    canvas.drawLine((float) this._pBaseBottomRight.x, (float) this._pBaseBottomRight.y, (float) this._pBaseTopLeft.x, (float) this._pBaseBottomRight.y, paint2);
+                    canvas.drawLine((float) this._pBaseTopLeft.x, (float) this._pBaseBottomRight.y, (float) this._pBaseTopLeft.x, (float) this._pBaseTopLeft.y, paint2);
+                } else {
+                    Path path = new Path();
+                    path.addRect((float) this._pBaseTopLeft.x, (float) this._pBaseTopLeft.y, (float) this._pBaseBottomRight.x, (float) this._pBaseBottomRight.y, Path.Direction.CW);
+                    paint.setPathEffect(new DashPathEffect(new float[]{10.0f, 2.0f}, (float) ScanBaseView.this.phase));
+                    paint.setStrokeWidth(1.5f);
+                    paint.setStyle(Paint.Style.STROKE);
+                    canvas.drawPath(path, paint);
+                }
+                if (ScanBaseView.this.bLongTouch) {
+                    drawTheCornerImage(canvas, ScanBaseView.this.getmPaint());
+                } else {
+                    drawNormalCorner(canvas);
+                }
+            }
+            if (ScanBaseView.this.isSetSize) {
+                ScanBaseView.this.setupScanArea();
+                ScanBaseView.this.setSetSize(false);
+            }
+        }
+
+        private void drawTheCornerImage(Canvas canvas, Paint paint) {
+            switch (ScanBaseView.this.screenStatus) {
+                case 1:
+                    int i = ScanBaseView.this.mWhere;
+                    if (i != -1) {
+                        if (i == 1) {
+                            drawCornerTopLeft(canvas, this._pBaseTopLeft);
+                            drawCornerBotRightMoving(canvas, this._pBaseBottomRight);
+                            break;
+                        } else {
+                            drawCornerTopLeft(canvas, this._pBaseTopLeft);
+                            drawCornerBotRight(canvas, this._pBaseBottomRight);
+                            break;
+                        }
+                    } else {
+                        drawCornerTopLeftMoving(canvas, this._pBaseTopLeft);
+                        drawCornerBotRight(canvas, this._pBaseBottomRight);
+                        break;
+                    }
+                case 2:
+                    int i2 = ScanBaseView.this.mWhere;
+                    if (i2 != -1) {
+                        if (i2 == 1) {
+                            drawCornerBotLeft(canvas, this._pBaseTopLeft);
+                            drawCornerTopRightMoving(canvas, this._pBaseBottomRight);
+                            break;
+                        } else {
+                            drawCornerBotLeft(canvas, this._pBaseTopLeft);
+                            drawCornerTopRight(canvas, this._pBaseBottomRight);
+                            break;
+                        }
+                    } else {
+                        drawCornerBotLeftMoving(canvas, this._pBaseTopLeft);
+                        drawCornerTopRight(canvas, this._pBaseBottomRight);
+                        break;
+                    }
+                case 3:
+                    int i3 = ScanBaseView.this.mWhere;
+                    if (i3 != -1) {
+                        if (i3 == 1) {
+                            drawCornerBotRight(canvas, this._pBaseTopLeft);
+                            drawCornerTopLeftMoving(canvas, this._pBaseBottomRight);
+                            break;
+                        } else {
+                            drawCornerBotRight(canvas, this._pBaseTopLeft);
+                            drawCornerTopLeft(canvas, this._pBaseBottomRight);
+                            break;
+                        }
+                    } else {
+                        drawCornerBotRightMoving(canvas, this._pBaseTopLeft);
+                        drawCornerTopLeft(canvas, this._pBaseBottomRight);
+                        break;
+                    }
+                case 4:
+                    int i4 = ScanBaseView.this.mWhere;
+                    if (i4 != -1) {
+                        if (i4 == 1) {
+                            drawCornerTopRight(canvas, this._pBaseTopLeft);
+                            drawCornerBotLeftMoving(canvas, this._pBaseBottomRight);
+                            break;
+                        } else {
+                            drawCornerTopRight(canvas, this._pBaseTopLeft);
+                            drawCornerBotLeft(canvas, this._pBaseBottomRight);
+                            break;
+                        }
+                    } else {
+                        drawCornerTopRightMoving(canvas, this._pBaseTopLeft);
+                        drawCornerBotLeft(canvas, this._pBaseBottomRight);
+                        break;
+                    }
+            }
+            if (ScanBaseView.this.bLongTouch) {
+                String localClassName = ScanBaseView.this.getLocalClassName();
+                EPLog.m313i(localClassName, "mWhere = " + ScanBaseView.this.mWhere);
+                if (ScanBaseView.this.mWhere == 0 && ScanBaseView.this.bmCenter == null) {
+                    ScanBaseView.this.bmCenter = BitmapFactory.decodeResource(getResources(), C2135R.C2136drawable.area_center, ScanBaseView.this._bmOption);
+                }
+                if (ScanBaseView.this.bmCenter != null) {
+                    if (this._pBaseCenter == null) {
+                        this._pBaseCenter = ScanBaseView.this.getmCenter();
+                    }
+                    if (ScanBaseView.this.inSampleSize != 0) {
+                        canvas.drawBitmap(ScanBaseView.this.bmCenter, (float) (this._pBaseCenter.x - ((ScanBaseView.this.bmCenter.getWidth() / 2) * ScanBaseView.this.getInSampleSize())), (float) (this._pBaseCenter.y - ((ScanBaseView.this.bmCenter.getHeight() / 2) * ScanBaseView.this.getInSampleSize())), (Paint) null);
+                    } else {
+                        canvas.drawBitmap(ScanBaseView.this.bmCenter, (float) (this._pBaseCenter.x - (ScanBaseView.this.bmCenter.getWidth() / 2)), (float) (this._pBaseCenter.y - (ScanBaseView.this.bmCenter.getHeight() / 2)), (Paint) null);
+                    }
+                }
+            }
+        }
+
+        public boolean onTouchEvent(MotionEvent motionEvent) {
+            if (!ScanBaseView.this.isDoctable) {
+                return true;
+            }
+            Point point = new Point((int) motionEvent.getX(), (int) motionEvent.getY());
+            ScanBaseView.this.setmTouch(point);
+            ScanBaseView.this.detectTheScreenStatus();
+            switch (motionEvent.getAction()) {
+                case 0:
+                    ScanBaseView.this.setmWhere(2);
+                    ScanBaseView.this.detectTheTouchPoint();
+                    ScanBaseView.this.setmFirstTouch(point);
+                    break;
+                case 1:
+                    ScanBaseView.this.setmWhere(2);
+                    ScanBaseView.this.setBmCenter((Bitmap) null);
+                    ScanBaseView scanBaseView = ScanBaseView.this;
+                    scanBaseView.phase = 0;
+                    this._touchtime = 0;
+                    scanBaseView.setupScanArea();
+                    ScanBaseView.this.bLongTouch = false;
+                    break;
+                case 2:
+                    if (ScanBaseView.this.bLongTouch) {
+                        moveTheTouchPoint();
+                        break;
+                    }
+                    break;
+                default:
+                    return false;
+            }
+            postInvalidate();
+            return true;
+        }
+
+        public void moveTheTouchPoint() {
+            switch (ScanBaseView.this.getmWhere()) {
+                case -1:
+                    this._pBaseTopLeft = ScanBaseView.this.getmTouch();
+                    this._pBaseCenter = ScanBaseView.this.calculateTheCenterPoint(this._pBaseTopLeft, this._pBaseBottomRight);
+                    break;
+                case 0:
+                    moveCenter();
+                    ScanBaseView.this.setmCenter(this._pBaseCenter);
+                    break;
+                case 1:
+                    this._pBaseBottomRight = ScanBaseView.this.getmTouch();
+                    this._pBaseCenter = ScanBaseView.this.calculateTheCenterPoint(this._pBaseTopLeft, this._pBaseBottomRight);
+                    break;
+            }
+            ScanBaseView.this.setmTop(this._pBaseTopLeft);
+            ScanBaseView.this.setmBot(this._pBaseBottomRight);
+            ScanBaseView scanBaseView = ScanBaseView.this;
+            scanBaseView.setPiBaseTop(new PointInfo((double) this._pBaseTopLeft.x, (double) this._pBaseTopLeft.y));
+            ScanBaseView scanBaseView2 = ScanBaseView.this;
+            scanBaseView2.setPiBaseBot(new PointInfo((double) this._pBaseBottomRight.x, (double) this._pBaseBottomRight.y));
+            ScanBaseView.this.setmCenter(this._pBaseCenter);
+        }
+
+        private void moveCenter() {
+            Point point = ScanBaseView.this.getmFirstTouch();
+            Point point2 = ScanBaseView.this.getmTouch();
+            int i = point2.x - point.x;
+            int i2 = point2.y - point.y;
+            this._pBaseTopLeft.x += i;
+            this._pBaseTopLeft.y += i2;
+            this._pBaseBottomRight.x += i;
+            this._pBaseBottomRight.y += i2;
+            this._pBaseCenter.x += i;
+            this._pBaseCenter.y += i2;
+            ScanBaseView.this.setmFirstTouch(point2);
+        }
+
+        private void drawNormalCorner(Canvas canvas) {
+            switch (ScanBaseView.this.screenStatus) {
+                case 2:
+                    drawCornerBotLeft(canvas, ScanBaseView.this.mTop);
+                    drawCornerTopRight(canvas, ScanBaseView.this.mBot);
+                    return;
+                case 3:
+                    drawCornerBotRight(canvas, ScanBaseView.this.mTop);
+                    drawCornerTopLeft(canvas, ScanBaseView.this.mBot);
+                    return;
+                case 4:
+                    drawCornerTopRight(canvas, ScanBaseView.this.mTop);
+                    drawCornerBotLeft(canvas, ScanBaseView.this.mBot);
+                    return;
+                default:
+                    drawCornerTopLeft(canvas, ScanBaseView.this.mTop);
+                    drawCornerBotRight(canvas, ScanBaseView.this.mBot);
+                    return;
+            }
+        }
+
+        private void drawCornerTopLeft(Canvas canvas, Point point) {
+            Canvas canvas2 = canvas;
+            canvas2.drawRect((float) (point.x - 6), (float) (point.y - 6), (float) ((point.x - 6) + 60), (float) point.y, ScanBaseView.this.getmPaint());
+            canvas2.drawRect((float) (point.x - 6), (float) (point.y - 6), (float) point.x, (float) ((point.y - 6) + 60), ScanBaseView.this.getmPaint());
+        }
+
+        private void drawCornerBotRight(Canvas canvas, Point point) {
+            Canvas canvas2 = canvas;
+            canvas2.drawRect((float) ((point.x + 6) - 60), (float) point.y, (float) (point.x + 6), (float) (point.y + 6), ScanBaseView.this.getmPaint());
+            canvas2.drawRect((float) point.x, (float) ((point.y + 6) - 60), (float) (point.x + 6), (float) (point.y + 6), ScanBaseView.this.getmPaint());
+        }
+
+        private void drawCornerBotLeft(Canvas canvas, Point point) {
+            Canvas canvas2 = canvas;
+            canvas2.drawRect((float) (point.x - 6), (float) point.y, (float) ((point.x - 6) + 60), (float) (point.y + 6), ScanBaseView.this.getmPaint());
+            canvas2.drawRect((float) (point.x - 6), (float) ((point.y + 6) - 60), (float) point.x, (float) (point.y + 6), ScanBaseView.this.getmPaint());
+        }
+
+        private void drawCornerTopRight(Canvas canvas, Point point) {
+            Canvas canvas2 = canvas;
+            canvas2.drawRect((float) ((point.x + 6) - 60), (float) (point.y - 6), (float) (point.x + 6), (float) point.y, ScanBaseView.this.getmPaint());
+            canvas2.drawRect((float) point.x, (float) (point.y - 6), (float) (point.x + 6), (float) ((point.y - 6) + 60), ScanBaseView.this.getmPaint());
+        }
+
+        private void drawCornerTopLeftMoving(Canvas canvas, Point point) {
+            Canvas canvas2 = canvas;
+            canvas2.drawRect((float) (point.x - 18), (float) (point.y - 18), (float) ((point.x - 18) + 150), (float) point.y, ScanBaseView.this.getmPaint());
+            canvas2.drawRect((float) (point.x - 18), (float) (point.y - 18), (float) point.x, (float) ((point.y - 18) + 150), ScanBaseView.this.getmPaint());
+        }
+
+        private void drawCornerBotRightMoving(Canvas canvas, Point point) {
+            Canvas canvas2 = canvas;
+            canvas2.drawRect((float) ((point.x + 18) - 150), (float) point.y, (float) (point.x + 18), (float) (point.y + 18), ScanBaseView.this.getmPaint());
+            canvas2.drawRect((float) point.x, (float) ((point.y + 18) - 150), (float) (point.x + 18), (float) (point.y + 18), ScanBaseView.this.getmPaint());
+        }
+
+        private void drawCornerBotLeftMoving(Canvas canvas, Point point) {
+            Canvas canvas2 = canvas;
+            canvas2.drawRect((float) (point.x - 18), (float) point.y, (float) ((point.x - 18) + 150), (float) (point.y + 18), ScanBaseView.this.getmPaint());
+            canvas2.drawRect((float) (point.x - 18), (float) ((point.y + 18) - 150), (float) point.x, (float) (point.y + 18), ScanBaseView.this.getmPaint());
+        }
+
+        private void drawCornerTopRightMoving(Canvas canvas, Point point) {
+            Canvas canvas2 = canvas;
+            canvas2.drawRect((float) ((point.x + 18) - 150), (float) (point.y - 18), (float) (point.x + 18), (float) point.y, ScanBaseView.this.getmPaint());
+            canvas2.drawRect((float) point.x, (float) (point.y - 18), (float) (point.x + 18), (float) ((point.y - 18) + 150), ScanBaseView.this.getmPaint());
+        }
+    }
+
+    public void detectTheTouchPoint() {
+        if (this.mTouch.x > Math.max(this.mTop.x, this.mBot.x) || this.mTouch.x < Math.min(this.mTop.x, this.mBot.x) || this.mTouch.y > Math.max(this.mTop.y, this.mBot.y) || this.mTouch.y < Math.min(this.mTop.y, this.mBot.y)) {
+            EPLog.m313i(getLocalClassName(), "touche out");
+            if ((Math.abs(Math.min(this.mTop.x, this.mBot.x) - this.mTouch.x) >= SCAN_AREA_HOTSPOT_SIZE && Math.abs(this.mTouch.x - Math.max(this.mTop.x, this.mBot.x)) >= SCAN_AREA_HOTSPOT_SIZE) || (Math.abs(Math.min(this.mTop.y, this.mBot.y) - this.mTouch.y) >= SCAN_AREA_HOTSPOT_SIZE && Math.abs(this.mTouch.y - Math.max(this.mTop.y, this.mBot.y)) >= SCAN_AREA_HOTSPOT_SIZE)) {
+                this.mWhere = 2;
+            } else if (this.mTop.x >= this.mBot.x || this.mTop.y >= this.mBot.y) {
+                if (this.mTop.x >= this.mBot.x || this.mTop.y <= this.mBot.y) {
+                    if (this.mTop.x <= this.mBot.x || this.mTop.y <= this.mBot.y) {
+                        if ((this.mTouch.x > this.mTop.x && Math.abs(this.mTouch.y - this.mTop.y) < SCAN_AREA_HOTSPOT_SIZE) || Math.abs(this.mTop.x - this.mTouch.x) < SCAN_AREA_HOTSPOT_SIZE) {
+                            this.mWhere = -1;
+                        } else if ((this.mTouch.x >= this.mBot.x || Math.abs(this.mTouch.y - this.mBot.y) >= SCAN_AREA_HOTSPOT_SIZE) && Math.abs(this.mTouch.x - this.mBot.x) >= SCAN_AREA_HOTSPOT_SIZE) {
+                            this.mWhere = 0;
+                        } else {
+                            this.mWhere = 1;
+                        }
+                    } else if ((this.mTouch.x > this.mTop.x && Math.abs(this.mTouch.y - this.mTop.y) < SCAN_AREA_HOTSPOT_SIZE) || Math.abs(this.mTop.x - this.mTouch.x) < SCAN_AREA_HOTSPOT_SIZE) {
+                        this.mWhere = -1;
+                    } else if ((this.mTouch.x >= this.mBot.x || Math.abs(this.mTouch.y - this.mBot.y) >= SCAN_AREA_HOTSPOT_SIZE) && Math.abs(this.mTouch.x - this.mBot.x) >= SCAN_AREA_HOTSPOT_SIZE) {
+                        this.mWhere = 0;
+                    } else {
+                        this.mWhere = 1;
+                    }
+                } else if ((this.mTouch.x < this.mTop.x && Math.abs(this.mTouch.y - this.mTop.y) < SCAN_AREA_HOTSPOT_SIZE) || Math.abs(this.mTouch.x - this.mTop.x) < SCAN_AREA_HOTSPOT_SIZE) {
+                    this.mWhere = -1;
+                } else if ((this.mTouch.x <= this.mBot.x || Math.abs(this.mTouch.y - this.mBot.y) >= SCAN_AREA_HOTSPOT_SIZE) && Math.abs(this.mBot.x - this.mTouch.x) >= SCAN_AREA_HOTSPOT_SIZE) {
+                    this.mWhere = 0;
+                } else {
+                    this.mWhere = 1;
+                }
+            } else if ((this.mTouch.x < this.mTop.x && Math.abs(this.mTouch.y - this.mTop.y) < SCAN_AREA_HOTSPOT_SIZE) || Math.abs(this.mTouch.x - this.mTop.x) < SCAN_AREA_HOTSPOT_SIZE) {
+                this.mWhere = -1;
+            } else if ((this.mTouch.x <= this.mBot.x || Math.abs(this.mTouch.y - this.mBot.y) >= SCAN_AREA_HOTSPOT_SIZE) && Math.abs(this.mBot.x - this.mTouch.x) >= SCAN_AREA_HOTSPOT_SIZE) {
+                this.mWhere = 0;
+            } else {
+                this.mWhere = 1;
+            }
+        } else {
+            EPLog.m313i(getLocalClassName(), "touche in");
+            if (this.mTop.x >= this.mBot.x || this.mTop.y >= this.mBot.y) {
+                if (this.mTop.x >= this.mBot.x || this.mTop.y <= this.mBot.y) {
+                    if (this.mTop.x <= this.mBot.x || this.mTop.y <= this.mBot.y) {
+                        if (Math.abs(this.mTop.x - this.mTouch.x) < SCAN_AREA_HOTSPOT_SIZE && this.mTouch.y - this.mTop.y < SCAN_AREA_HOTSPOT_SIZE) {
+                            this.mWhere = -1;
+                        } else if (Math.abs(this.mTouch.x - this.mBot.x) >= SCAN_AREA_HOTSPOT_SIZE || this.mBot.y - this.mTouch.y >= SCAN_AREA_HOTSPOT_SIZE) {
+                            this.mWhere = 0;
+                        } else {
+                            this.mWhere = 1;
+                        }
+                    } else if (Math.abs(this.mTop.x - this.mTouch.x) < SCAN_AREA_HOTSPOT_SIZE && this.mTop.y - this.mTouch.y < SCAN_AREA_HOTSPOT_SIZE) {
+                        this.mWhere = -1;
+                    } else if (Math.abs(this.mTouch.x - this.mBot.x) >= SCAN_AREA_HOTSPOT_SIZE || this.mTouch.y - this.mBot.y >= SCAN_AREA_HOTSPOT_SIZE) {
+                        this.mWhere = 0;
+                    } else {
+                        this.mWhere = 1;
+                    }
+                } else if (Math.abs(this.mTouch.x - this.mTop.x) < SCAN_AREA_HOTSPOT_SIZE && this.mTop.y - this.mTouch.y < SCAN_AREA_HOTSPOT_SIZE) {
+                    this.mWhere = -1;
+                } else if (Math.abs(this.mBot.x - this.mTouch.x) >= SCAN_AREA_HOTSPOT_SIZE || this.mTouch.y - this.mBot.y >= SCAN_AREA_HOTSPOT_SIZE) {
+                    this.mWhere = 0;
+                } else {
+                    this.mWhere = 1;
+                }
+            } else if (Math.abs(this.mTouch.x - this.mTop.x) < SCAN_AREA_HOTSPOT_SIZE && this.mTouch.y - this.mTop.y < SCAN_AREA_HOTSPOT_SIZE) {
+                this.mWhere = -1;
+            } else if (Math.abs(this.mBot.x - this.mTouch.x) >= SCAN_AREA_HOTSPOT_SIZE || this.mBot.y - this.mTouch.y >= SCAN_AREA_HOTSPOT_SIZE) {
+                this.mWhere = 0;
+            } else {
+                this.mWhere = 1;
+            }
+        }
+    }
+
+    public void detectTheScreenStatus() {
+        if (this.mTop.x < this.mBot.x && this.mTop.y < this.mBot.y) {
+            this.screenStatus = 1;
+        } else if (this.mTop.x < this.mBot.x && this.mTop.y > this.mBot.y) {
+            this.screenStatus = 2;
+        } else if (this.mTop.x <= this.mBot.x || this.mTop.y <= this.mBot.y) {
+            this.screenStatus = 4;
+        } else {
+            this.screenStatus = 3;
+        }
+    }
+
+    class ScanAreaBackground extends View {
+        Paint _paint = new Paint();
+        Paint _textPaint;
+        boolean hideText;
+        ScanActivity mScanActivity;
+        String text;
+
+        /* access modifiers changed from: protected */
+        public void onSizeChanged(int i, int i2, int i3, int i4) {
+            super.onSizeChanged(i, i2, i3, i4);
+            this.mScanActivity.onScanAreaSizeChange();
+        }
+
+        /* access modifiers changed from: package-private */
+        public void drawTextInCanvas(Canvas canvas) {
+            String str = new String();
+            float f = ((float) (ScanBaseView.this.getmBaseBot().x - ScanBaseView.this.getmBaseTop().x)) * 0.9f;
+            float f2 = (float) (ScanBaseView.this.getmBaseBot().y - ScanBaseView.this.getmBaseTop().y);
+            Rect rect = new Rect();
+            int length = this.text.length();
+            String str2 = str;
+            int i = 0;
+            int i2 = 0;
+            while (i < length) {
+                int breakText = this._textPaint.breakText(this.text.substring(i, length), true, f, (float[]) null) + i;
+                String substring = this.text.substring(i, breakText);
+                this._textPaint.getTextBounds(substring, 0, substring.length(), rect);
+                i2 += rect.height();
+                str2 = (str2 + substring) + Constants.BREAK_LINE;
+                i = breakText;
+            }
+            int i3 = (int) (((float) ScanBaseView.this.getmBaseTop().x) + (((float) (ScanBaseView.this.getmBaseBot().x - ScanBaseView.this.getmBaseTop().x)) * 0.05f));
+            int i4 = (int) ((((float) ScanBaseView.this.getmBaseTop().y) + (f2 / 2.0f)) - ((float) (i2 / 2)));
+            String[] split = str2.split(Constants.BREAK_LINE);
+            int i5 = 0;
+            for (int i6 = 0; i6 < split.length; i6++) {
+                canvas.drawText(split[i6], (float) i3, (float) (i4 + i5), this._textPaint);
+                this._textPaint.getTextBounds(split[i6], 0, split[i6].length(), rect);
+                i5 += rect.height();
+            }
+        }
+
+        public void hideText(boolean z) {
+            this.hideText = z;
+        }
+
+        public ScanAreaBackground(Context context) {
+            super(context);
+            this.mScanActivity = (ScanActivity) context;
+            this._paint.setColor(-1);
+            this._paint.setShadowLayer(5.5f, 6.0f, 6.0f, C2135R.color.light_gray);
+            this._textPaint = new Paint();
+            this._textPaint.setColor(getResources().getColor(C2135R.color.light_gray));
+            this._textPaint.setAntiAlias(true);
+            this._textPaint.setTextAlign(Paint.Align.LEFT);
+            this._textPaint.setTextSize(new EditText(getContext()).getTextSize());
+            this.text = ScanBaseView.this.getString(C2135R.string.str_msg_scan_viewbase);
+        }
+
+        /* access modifiers changed from: protected */
+        public void onDraw(Canvas canvas) {
+            super.onDraw(canvas);
+            drawTheDefaultBackground(canvas);
+        }
+
+        private void drawTheDefaultBackground(Canvas canvas) {
+            canvas.drawRect((float) ScanBaseView.this.getmBaseTop().x, (float) ScanBaseView.this.getmBaseTop().y, (float) ScanBaseView.this.getmBaseBot().x, (float) ScanBaseView.this.getmBaseBot().y, this._paint);
+            if (!this.hideText) {
+                drawTextInCanvas(canvas);
+            }
+        }
+    }
+}

+ 126 - 0
app/src/main/java/epson/scan/activity/ScanContinueParam.java

@@ -0,0 +1,126 @@
+package epson.scan.activity;
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+import epson.print.C2135R;
+import java.util.ArrayList;
+
+public class ScanContinueParam {
+    public static final int SCAN_ADF_MAX_PAGES_LIMIT = 50;
+    public static final int SCAN_CONTINUE_MAX_PAGES_LIMIT = 300;
+    private static boolean mIsContinueScanning;
+    private static boolean mIsNeedShowErrorLimit;
+    private static int mScannedFileCount;
+
+    public interface ScanContinueDialogButtonClick {
+        void onRequestScanAction();
+    }
+
+    public static void showScanErrorLimit(Context context) {
+        if (mIsNeedShowErrorLimit) {
+            ScanContinueDialogButtonClick scanContinueDialogButtonClick = (ScanContinueDialogButtonClick) context;
+            AlertDialog.Builder message = new AlertDialog.Builder(context).setMessage(C2135R.string.scan_alert_upper_limit_message);
+            message.setPositiveButton(C2135R.string.str_ok, new DialogInterface.OnClickListener() {
+                public void onClick(DialogInterface dialogInterface, int i) {
+                    dialogInterface.dismiss();
+                }
+            });
+            AlertDialog create = message.create();
+            create.setCancelable(false);
+            create.show();
+        }
+    }
+
+    public static void judgeScanContinue(Context context, ArrayList<String> arrayList) {
+        final ScanContinueDialogButtonClick scanContinueDialogButtonClick = (ScanContinueDialogButtonClick) context;
+        if (!arrayList.isEmpty()) {
+            View inflate = LayoutInflater.from(context).inflate(C2135R.layout.dialog_scan_continue_confirmation, (ViewGroup) null);
+            AlertDialog.Builder view = new AlertDialog.Builder(context).setView(inflate);
+            TextView textView = (TextView) inflate.findViewById(C2135R.C2137id.scanContinue_title_tv);
+            TextView textView2 = (TextView) inflate.findViewById(C2135R.C2137id.scanContinue_msg_tv);
+            if (!isReachMaximumScan()) {
+                textView.setVisibility(0);
+                textView.setText(C2135R.string.scan_dialog_title);
+                textView2.setText(C2135R.string.scan_dialog_message);
+                view.setPositiveButton(C2135R.string.scan_dialog_button_continue, new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialogInterface, int i) {
+                        ScanContinueParam.setContinueScanningFlag(true);
+                        scanContinueDialogButtonClick.onRequestScanAction();
+                    }
+                });
+            } else {
+                textView.setVisibility(8);
+                textView2.setText(C2135R.string.scan_alert_and_scan_message);
+            }
+            view.setNeutralButton(C2135R.string.scan_dialog_button_cancel, new DialogInterface.OnClickListener() {
+                public void onClick(DialogInterface dialogInterface, int i) {
+                    dialogInterface.dismiss();
+                }
+            }).setNegativeButton(C2135R.string.scan_dialog_button_overwrite, new DialogInterface.OnClickListener() {
+                public void onClick(DialogInterface dialogInterface, int i) {
+                    ScanContinueParam.setContinueScanningFlag(false);
+                    scanContinueDialogButtonClick.onRequestScanAction();
+                }
+            });
+            AlertDialog create = view.create();
+            create.setCanceledOnTouchOutside(false);
+            create.setOnShowListener($$Lambda$ScanContinueParam$O5_W7A8WVuIPQG0HgQ75RE2hUc.INSTANCE);
+            create.show();
+            return;
+        }
+        setContinueScanningFlag(false);
+        scanContinueDialogButtonClick.onRequestScanAction();
+    }
+
+    static /* synthetic */ void lambda$judgeScanContinue$0(DialogInterface dialogInterface) {
+        AlertDialog alertDialog = (AlertDialog) dialogInterface;
+        alertDialog.getButton(-1).setAllCaps(false);
+        alertDialog.getButton(-2).setAllCaps(false);
+        alertDialog.getButton(-3).setAllCaps(false);
+    }
+
+    public static void setContinueScanningFlag(boolean z) {
+        mIsContinueScanning = z;
+    }
+
+    public static boolean isContinueScanning() {
+        return mIsContinueScanning;
+    }
+
+    public static void resetParameter() {
+        mIsContinueScanning = false;
+        mScannedFileCount = 0;
+    }
+
+    public static void setScannedFileCount(int i) {
+        mScannedFileCount = i;
+    }
+
+    public static int getAvailableScanPageCount() {
+        int i = 300 - mScannedFileCount;
+        if (i <= 0) {
+            i = 1;
+        }
+        if (!mIsContinueScanning) {
+            i = 50;
+        }
+        setIsNeedShowErrorLimitFlag(i);
+        if (i >= 50) {
+            return 50;
+        }
+        return i;
+    }
+
+    public static void setIsNeedShowErrorLimitFlag(int i) {
+        mIsNeedShowErrorLimit = i < 50;
+    }
+
+    public static boolean isReachMaximumScan() {
+        return mScannedFileCount >= 300;
+    }
+}

+ 30 - 0
app/src/main/java/epson/scan/activity/ScanCount.java

@@ -0,0 +1,30 @@
+package epson.scan.activity;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.support.annotation.NonNull;
+import epson.print.CommonDefine;
+import epson.print.ScanFileNumber;
+
+class ScanCount {
+    ScanCount() {
+    }
+
+    private static int getScanCount(@NonNull Context context) {
+        return getPreferences(context).getInt(CommonDefine.PREFS_NAME_PRESCAN_COUNT_NUMBER, 0);
+    }
+
+    static void saveScanCount(@NonNull Context context, int i) {
+        SharedPreferences.Editor edit = getPreferences(context).edit();
+        edit.putInt(CommonDefine.PREFS_NAME_PRESCAN_COUNT_NUMBER, i);
+        edit.commit();
+    }
+
+    private static SharedPreferences getPreferences(@NonNull Context context) {
+        return context.getSharedPreferences(CommonDefine.PREFS_NAME_PRESCAN_COUNT_NUMBER, 0);
+    }
+
+    static void countUpScanPage(@NonNull Context context) {
+        ScanFileNumber.addCount(context, getScanCount(context));
+    }
+}

+ 1105 - 0
app/src/main/java/epson/scan/activity/ScanSearchActivity.java

@@ -0,0 +1,1105 @@
+package epson.scan.activity;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.support.annotation.NonNull;
+import android.support.annotation.UiThread;
+import android.support.p000v4.app.DialogFragment;
+import android.view.ContextMenu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.Button;
+import android.widget.ListView;
+import android.widget.ProgressBar;
+import android.widget.RadioButton;
+import android.widget.TextView;
+import com.epson.mobilephone.common.wifidirect.ActivityWiFiDirectStart;
+import com.epson.mobilephone.common.wifidirect.ActivityiPrintConnect;
+import com.epson.mobilephone.common.wifidirect.MacAddrUtils;
+import com.epson.mobilephone.common.wifidirect.SearchWiFiDirectPrinterTask;
+import com.epson.mobilephone.common.wifidirect.WiFiControl;
+import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
+import com.epson.mobilephone.common.wifidirect.WiFiDirectPrinterListUtils;
+import com.epson.mobilephone.common.wifidirect.escprLib;
+import epson.common.Constants;
+import epson.common.Utils;
+import epson.maintain.activity.PrinterNotFoundDialogCreator;
+import epson.print.ActivityIACommon;
+import epson.print.C2135R;
+import epson.print.CommonDefine;
+import epson.print.CustomLayoutDialogFragment;
+import epson.print.CustomTitleDialogFragment;
+import epson.print.MyPrinter;
+import epson.print.Util.EPLog;
+import epson.print.screen.WorkingDialog;
+import epson.print.widgets.ListControlHelper;
+import epson.print.widgets.PrinterInfoBuilder;
+import epson.scan.lib.CancelableFind;
+import epson.scan.lib.CancelablePropertyTaker;
+import epson.scan.lib.EscanLibException;
+import epson.scan.lib.escanLib;
+import java.util.Locale;
+import java.util.concurrent.Semaphore;
+
+public class ScanSearchActivity extends ActivityIACommon implements CustomTitleDialogFragment.Callback {
+    private static final int DIALOG_ID_PRINTER_NOT_FOUND_WITH_WEB_GUIDANCE = 1;
+    private static final String DIALOG_TAG_PRINTER_NOT_FOUND = "printer_not_found_dialog";
+    private static final int Menu_Delete = 1;
+    private static final int Menu_Edit = 2;
+    private static final String PARAM_KEY_SCANNER_ID = "scanner-id";
+    private static final String PARAM_KEY_SCANNER_LOCATION = "scanner-location";
+    private static final String PARAM_KEY_SCANNER_SSID = "scanner-ssid";
+    private static final String TAG = "ScanSearch";
+    /* access modifiers changed from: private */
+    public static final Semaphore sEscanLibSemaphore = new Semaphore(1);
+    private final int ADD_SCANER = 8;
+    private final String COMMONDEVICENAME = "commonDeviceName";
+    private final int CONNECT_SIMPLEAP = 7;
+    private final int DELAY = 100;
+    private final int DELETE_PRINTER = 9;
+    private final int EDIT_IPPRINTER = 10;
+    private final int FINISH_FIND_SCANER = 5;
+    private final int FOUND_SIMPLEAP = 6;
+    private final String PRINTER_ID = "id";
+    private final String PRINTER_IP = escprLib.PRINTER_IP;
+    private final String PRINTER_NAME = "name";
+    private final int PROBE_SCANNER = 11;
+    private final String SCANER_ID = "id";
+    private final String SCANER_INDEX = "index";
+    private final String SCANER_IP = escprLib.PRINTER_IP;
+    private final String SCANER_LOCATION = "location";
+    private final String SCANER_NAME = "name";
+    private final int SEARCH_PRINTER_P2P = 12;
+    private final int SEARCH_SCANER = 1;
+    private final int SELECT_SCANER = 4;
+    private boolean bCheckWiFiStatus = false;
+    private String connectionInfo = null;
+    private AlertDialog errorDialog;
+    ListControlHelper helper = null;
+    /* access modifiers changed from: private */
+    public volatile boolean isFinishSearchScanner = true;
+    /* access modifiers changed from: private */
+    public Boolean isFocused = true;
+    private boolean isJapaneseLocale = false;
+    /* access modifiers changed from: private */
+    public volatile boolean isSearchSimpleAp = false;
+    /* access modifiers changed from: private */
+    public boolean isSelected = false;
+    private AdapterView.AdapterContextMenuInfo listItemIndex;
+    /* access modifiers changed from: private */
+    public volatile boolean mActivityBackRequested;
+    private boolean mActivityForegroundLifetime;
+    Button mAddButton;
+    ScannerListAdapter mBuilder;
+    /* access modifiers changed from: private */
+    public Context mContext = null;
+    int mDeletePos;
+    /* access modifiers changed from: private */
+    public escanLib mEscanLib;
+    private FindScannerTask mFindScannerTask;
+    private GetScannerCapabilityAndFinishTask mGetScannerCapabilityAndFinishTask;
+    /* access modifiers changed from: private */
+    public Handler mHandler = new Handler(new Handler.Callback() {
+        /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r7v24, resolved type: java.lang.Object} */
+        /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r0v30, resolved type: epson.print.MyPrinter} */
+        /* JADX WARNING: Multi-variable type inference failed */
+        /* Code decompiled incorrectly, please refer to instructions dump. */
+        public boolean handleMessage(android.os.Message r7) {
+            /*
+                r6 = this;
+                epson.scan.activity.ScanSearchActivity r0 = epson.scan.activity.ScanSearchActivity.this
+                boolean r0 = r0.isFinishing()
+                r1 = 1
+                r2 = 0
+                if (r0 != 0) goto L_0x0012
+                epson.scan.activity.ScanSearchActivity r0 = epson.scan.activity.ScanSearchActivity.this
+                boolean r0 = r0.mActivityBackRequested
+                if (r0 == 0) goto L_0x001d
+            L_0x0012:
+                int r0 = r7.what
+                if (r0 == r1) goto L_0x0183
+                r3 = 8
+                if (r0 == r3) goto L_0x0183
+                switch(r0) {
+                    case 5: goto L_0x0183;
+                    case 6: goto L_0x0183;
+                    default: goto L_0x001d;
+                }
+            L_0x001d:
+                int r0 = r7.what
+                r3 = -1
+                switch(r0) {
+                    case 1: goto L_0x017d;
+                    case 2: goto L_0x0023;
+                    case 3: goto L_0x0023;
+                    case 4: goto L_0x0023;
+                    case 5: goto L_0x0172;
+                    case 6: goto L_0x012f;
+                    case 7: goto L_0x0023;
+                    case 8: goto L_0x00de;
+                    case 9: goto L_0x008a;
+                    case 10: goto L_0x0044;
+                    case 11: goto L_0x0023;
+                    case 12: goto L_0x0025;
+                    default: goto L_0x0023;
+                }
+            L_0x0023:
+                goto L_0x0182
+            L_0x0025:
+                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
+                android.os.Handler r0 = r7.mHandler
+                r1 = 6
+                r3 = 60
+                com.epson.mobilephone.common.wifidirect.SearchWiFiDirectPrinterTask r0 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.searchWiFiDirectPrinter(r7, r0, r1, r3)
+                com.epson.mobilephone.common.wifidirect.SearchWiFiDirectPrinterTask unused = r7.searchWiFiDirectPrinter = r0
+                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
+                com.epson.mobilephone.common.wifidirect.SearchWiFiDirectPrinterTask r7 = r7.searchWiFiDirectPrinter
+                if (r7 != 0) goto L_0x0182
+                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
+                boolean unused = r7.isSearchSimpleAp = r2
+                goto L_0x0182
+            L_0x0044:
+                epson.scan.activity.ScanSearchActivity r0 = epson.scan.activity.ScanSearchActivity.this
+                r0.interruptSearch()
+                r0 = 0
+                java.lang.Object r1 = r7.obj
+                if (r1 == 0) goto L_0x0053
+                java.lang.Object r7 = r7.obj
+                r0 = r7
+                epson.print.MyPrinter r0 = (epson.print.MyPrinter) r0
+            L_0x0053:
+                android.content.Intent r7 = new android.content.Intent
+                epson.scan.activity.ScanSearchActivity r1 = epson.scan.activity.ScanSearchActivity.this
+                java.lang.Class<epson.print.screen.ActivityIpPrinterSetting> r4 = epson.print.screen.ActivityIpPrinterSetting.class
+                r7.<init>(r1, r4)
+                android.os.Bundle r1 = new android.os.Bundle
+                r1.<init>()
+                if (r0 == 0) goto L_0x0073
+                java.lang.String r4 = r0.getPrinterId()
+                if (r4 == 0) goto L_0x0073
+                java.lang.String r4 = "PRINTER_KEY"
+                java.lang.String r0 = r0.getPrinterId()
+                r1.putString(r4, r0)
+                goto L_0x007a
+            L_0x0073:
+                java.lang.String r0 = "PRINTER_KEY"
+                java.lang.String r4 = ""
+                r1.putString(r0, r4)
+            L_0x007a:
+                epson.scan.activity.ScanSearchActivity r0 = epson.scan.activity.ScanSearchActivity.this
+                r0.mDeletePos = r3
+                r7.putExtras(r1)
+                epson.scan.activity.ScanSearchActivity r0 = epson.scan.activity.ScanSearchActivity.this
+                r1 = 10
+                r0.startActivityForResult(r7, r1)
+                goto L_0x0182
+            L_0x008a:
+                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
+                int r7 = r7.mDeletePos
+                if (r7 < 0) goto L_0x0182
+                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
+                int r7 = r7.scanner_location
+                r0 = 3
+                if (r7 == r0) goto L_0x009a
+                goto L_0x00d8
+            L_0x009a:
+                epson.print.EPPrinterManager r7 = new epson.print.EPPrinterManager
+                epson.scan.activity.ScanSearchActivity r0 = epson.scan.activity.ScanSearchActivity.this
+                android.content.Context r0 = r0.mContext
+                r7.<init>(r0)
+                epson.scan.activity.ScanSearchActivity r0 = epson.scan.activity.ScanSearchActivity.this
+                epson.scan.activity.ScannerListAdapter r0 = r0.mBuilder
+                java.util.Vector r0 = r0.getData()
+                epson.scan.activity.ScanSearchActivity r1 = epson.scan.activity.ScanSearchActivity.this
+                int r1 = r1.mDeletePos
+                java.lang.Object r0 = r0.elementAt(r1)
+                epson.print.MyPrinter r0 = (epson.print.MyPrinter) r0
+                java.lang.String r0 = r0.getPrinterId()
+                r7.deleteIpPrinterInfo(r0)
+                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
+                epson.scan.activity.ScannerListAdapter r7 = r7.mBuilder
+                android.widget.BaseAdapter r7 = r7.getAdapter()
+                epson.scan.activity.ScanSearchActivity r0 = epson.scan.activity.ScanSearchActivity.this
+                epson.scan.activity.ScannerListAdapter r0 = r0.mBuilder
+                java.util.Vector r0 = r0.getData()
+                epson.scan.activity.ScanSearchActivity r1 = epson.scan.activity.ScanSearchActivity.this
+                int r1 = r1.mDeletePos
+                r0.remove(r1)
+                r7.notifyDataSetChanged()
+            L_0x00d8:
+                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
+                r7.mDeletePos = r3
+                goto L_0x0182
+            L_0x00de:
+                epson.scan.activity.ScanSearchActivity r0 = epson.scan.activity.ScanSearchActivity.this
+                int r0 = r0.scanner_location
+                if (r0 == r1) goto L_0x00e8
+                goto L_0x0182
+            L_0x00e8:
+                android.os.Bundle r7 = r7.getData()
+                java.lang.String r0 = "name"
+                java.lang.String r0 = r7.getString(r0)
+                if (r0 == 0) goto L_0x0182
+                epson.print.MyPrinter r0 = new epson.print.MyPrinter
+                java.lang.String r1 = "name"
+                java.lang.String r1 = r7.getString(r1)
+                java.lang.String r3 = "ip"
+                java.lang.String r3 = r7.getString(r3)
+                java.lang.String r4 = ""
+                java.lang.String r5 = ""
+                r0.<init>(r1, r3, r4, r5)
+                java.lang.String r1 = "id"
+                java.lang.String r1 = r7.getString(r1)
+                r0.setScannerId(r1)
+                java.lang.String r1 = "commonDeviceName"
+                java.lang.String r7 = r7.getString(r1)
+                r0.setCommonDeviceName(r7)
+                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
+                com.epson.mobilephone.common.wifidirect.WiFiDirectPrinterListUtils r7 = r7.wiFiDirectPrinterListUtils
+                java.lang.String r1 = r0.getIp()
+                java.lang.String r3 = r0.getScannerId()
+                java.lang.String r3 = com.epson.mobilephone.common.wifidirect.MacAddrUtils.getMacAddressFromScannerId(r3)
+                r7.addPrinter(r0, r2, r1, r3)
+                goto L_0x0182
+            L_0x012f:
+                android.os.Bundle r7 = r7.getData()
+                if (r7 == 0) goto L_0x015f
+                boolean r0 = r7.isEmpty()
+                if (r0 != 0) goto L_0x015f
+                java.lang.String r0 = "ssid"
+                java.lang.String r0 = r7.getString(r0)
+                java.lang.String r1 = "name"
+                java.lang.String r1 = r7.getString(r1)
+                java.lang.String r3 = "addr_infra"
+                java.lang.String r7 = r7.getString(r3)
+                if (r1 != 0) goto L_0x0150
+                r1 = r0
+            L_0x0150:
+                epson.print.MyPrinter r3 = new epson.print.MyPrinter
+                java.lang.String r4 = ""
+                r3.<init>(r1, r0, r7, r4)
+                epson.scan.activity.ScanSearchActivity r1 = epson.scan.activity.ScanSearchActivity.this
+                com.epson.mobilephone.common.wifidirect.WiFiDirectPrinterListUtils r1 = r1.wiFiDirectPrinterListUtils
+                r1.addPrinter(r3, r2, r0, r7)
+                goto L_0x0182
+            L_0x015f:
+                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
+                boolean unused = r7.isSearchSimpleAp = r2
+                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
+                boolean r7 = r7.isFinishSearchScanner
+                if (r7 == 0) goto L_0x0182
+                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
+                r7.updateFindScannerResult()
+                goto L_0x0182
+            L_0x0172:
+                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
+                r7.interruptSearch()
+                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
+                r7.updateFindScannerResult()
+                goto L_0x0182
+            L_0x017d:
+                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
+                r7.search()
+            L_0x0182:
+                return r2
+            L_0x0183:
+                return r2
+            */
+            throw new UnsupportedOperationException("Method not decompiled: epson.scan.activity.ScanSearchActivity.C242011.handleMessage(android.os.Message):boolean");
+        }
+    });
+    RadioButton mIpButton;
+    ViewGroup mLayout;
+    private TextView mListEmptyMessageTextView;
+    /* access modifiers changed from: private */
+    public ListView mListView;
+    RadioButton mLocalButton;
+    private String mMyPrinterForSimpleApDisconnect;
+    private volatile boolean mProgress;
+    ProgressBar mProgressBar;
+    WorkingDialog mProgressDialog;
+    /* access modifiers changed from: private */
+    public volatile boolean mScannerFindCancelRequested;
+    Button mSearchButton;
+    /* access modifiers changed from: private */
+    public String mSimpleApSsid;
+    TextView mTextDetail;
+    View mWiFiSettingButton;
+    private String scannerId;
+    private String scannerKey;
+    /* access modifiers changed from: private */
+    public int scanner_location;
+    /* access modifiers changed from: private */
+    public SearchWiFiDirectPrinterTask searchWiFiDirectPrinter = null;
+    private TextView tvResult;
+    WiFiDirectPrinterListUtils wiFiDirectPrinterListUtils = null;
+
+    public void onLocalNegativeCallback(int i) {
+    }
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        if (Locale.getDefault().getLanguage().equalsIgnoreCase(Locale.JAPAN.getLanguage()) || Locale.getDefault().getLanguage().equalsIgnoreCase(Locale.JAPANESE.getLanguage())) {
+            this.isJapaneseLocale = true;
+        } else {
+            this.isJapaneseLocale = false;
+        }
+        this.mLayout = (ViewGroup) getLayoutInflater().inflate(C2135R.layout.search_printer_layout, (ViewGroup) null);
+        addWiFiSetupButton();
+        this.mEscanLib = new escanLib();
+        this.mEscanLib.escanWrapperInitDriver(this);
+        Bundle extras = getIntent().getExtras();
+        this.scanner_location = extras.getInt(PARAM_KEY_SCANNER_LOCATION);
+        if (this.scanner_location == 0) {
+            this.scanner_location = 1;
+        }
+        if (this.scanner_location != 3) {
+            this.scannerId = extras.getString(PARAM_KEY_SCANNER_ID);
+            this.connectionInfo = extras.getString(PARAM_KEY_SCANNER_SSID);
+        } else {
+            this.scannerKey = extras.getString(PARAM_KEY_SCANNER_ID);
+        }
+        setContentView((View) this.mLayout);
+        this.tvResult = (TextView) this.mLayout.findViewById(C2135R.C2137id.empty);
+        this.tvResult.setText(getString(C2135R.string.lbl_scanner_search_processing));
+        this.mListEmptyMessageTextView = (TextView) this.mLayout.findViewById(C2135R.C2137id.list_empty_message);
+        this.mListView = (ListView) this.mLayout.findViewById(16908298);
+        EPLog.m313i("epson.scan.activity.ScanSearchActivity", "builElements");
+        buildElements();
+        setNotFoundPrinterButton();
+        setActionBar((int) C2135R.string.title_addprint, true);
+        this.mContext = this;
+    }
+
+    private void setNotFoundPrinterButton() {
+        this.mLayout.findViewById(C2135R.C2137id.not_found_printer_epsonsn).setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                ScanSearchActivity scanSearchActivity = ScanSearchActivity.this;
+                scanSearchActivity.startActivity(PrinterNotFoundDialogCreator.getStartIntent(scanSearchActivity.getApplicationContext()));
+            }
+        });
+    }
+
+    /* access modifiers changed from: package-private */
+    public void addWiFiSetupButton() {
+        this.mWiFiSettingButton = this.mLayout.findViewById(C2135R.C2137id.rlWifiSettings);
+        if (this.isJapaneseLocale) {
+            ((TextView) this.mWiFiSettingButton).setText(C2135R.string.str_goto_wifidirect_settings);
+        } else {
+            ((TextView) this.mWiFiSettingButton).setText(C2135R.string.str_wifidirect_settings);
+        }
+        this.mWiFiSettingButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                ScanSearchActivity.this.startWifiPrinterSelect();
+            }
+        });
+    }
+
+    /* access modifiers changed from: private */
+    public void startWifiPrinterSelect() {
+        startActivityForResult(new Intent(this, ActivityWiFiDirectStart.class), 7);
+    }
+
+    /* access modifiers changed from: private */
+    public void buildElements() {
+        this.mLocalButton = (RadioButton) this.mLayout.findViewById(C2135R.C2137id.btn_local);
+        this.mIpButton = (RadioButton) this.mLayout.findViewById(C2135R.C2137id.btn_ip);
+        this.mSearchButton = (Button) this.mLayout.findViewById(C2135R.C2137id.function_button);
+        this.mProgressBar = (ProgressBar) this.mLayout.findViewById(C2135R.C2137id.progress_bar);
+        this.mAddButton = (Button) this.mLayout.findViewById(C2135R.C2137id.edit_button);
+        this.mTextDetail = (TextView) this.mLayout.findViewById(C2135R.C2137id.detail);
+        this.mTextDetail.setVisibility(0);
+        findViewById(C2135R.C2137id.btn_remote).setVisibility(8);
+        this.mIpButton.setBackground(getResources().getDrawable(C2135R.C2136drawable.printer_selector_background_remote));
+        this.mLayout.findViewById(C2135R.C2137id.ble_wifi_setting).setVisibility(8);
+        Utils.setDrawble2TextView(this, this.mLocalButton, C2135R.C2136drawable.printer_selector_icon_local);
+        Utils.setDrawble2TextView(this, this.mIpButton, C2135R.C2136drawable.printer_selector_icon_ip);
+        TextView textView = null;
+        if (this.scanner_location != 3) {
+            this.mListView.setEmptyView((View) null);
+            this.mListEmptyMessageTextView.setText((CharSequence) null);
+            this.mListEmptyMessageTextView.setVisibility(8);
+            this.mAddButton.setVisibility(8);
+            this.mSearchButton.setVisibility(0);
+            searchButtonSetEnabled(false);
+            this.mProgressBar.setVisibility(0);
+            this.tvResult.setVisibility(0);
+            this.mWiFiSettingButton.setVisibility(0);
+            this.mBuilder = new ScannerListAdapter(this, this.mLayout, 2);
+            this.mBuilder.setResource(WiFiDirectPrinterListUtils.getCurPrinterString(this, this.scannerId, this.connectionInfo));
+            this.helper = new ListControlHelper((PrinterInfoBuilder) this.mBuilder.getBuilder());
+            this.wiFiDirectPrinterListUtils = new WiFiDirectPrinterListUtils(this, this.mBuilder.getData(), this.helper, this.connectionInfo);
+            this.mLocalButton.setChecked(true);
+            this.mTextDetail.setText(C2135R.string.str_detailtext_local_scan);
+            this.mLayout.findViewById(C2135R.C2137id.not_found_printer_epsonsn).setVisibility(0);
+        } else {
+            this.mListEmptyMessageTextView.setText(C2135R.string.printer_list_empty_message);
+            textView = this.mListEmptyMessageTextView;
+            this.mAddButton.setVisibility(0);
+            this.mSearchButton.setVisibility(8);
+            this.mProgressBar.setVisibility(8);
+            this.tvResult.setVisibility(8);
+            this.mWiFiSettingButton.setVisibility(8);
+            this.mBuilder = new ScannerListAdapter(this, this.mLayout, 1);
+            this.mBuilder.setResource(this.scannerKey);
+            this.mIpButton.setChecked(true);
+            this.mTextDetail.setText(C2135R.string.str_detailtext_ip_scan);
+            this.mLayout.findViewById(C2135R.C2137id.not_found_printer_epsonsn).setVisibility(8);
+        }
+        this.mBuilder.build();
+        this.mBuilder.refresh();
+        this.mListView.setEmptyView(textView);
+        this.mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+            public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
+                if (!ScanSearchActivity.this.isSelected && ScanSearchActivity.this.isFocused.booleanValue()) {
+                    Boolean unused = ScanSearchActivity.this.isFocused = false;
+                    boolean unused2 = ScanSearchActivity.this.isSelected = true;
+                    MyPrinter myPrinter = (MyPrinter) ScanSearchActivity.this.mBuilder.getData().elementAt(i);
+                    String ip = myPrinter.getIp();
+                    if (!WiFiControl.ConnectType.NONE.equals(WiFiDirectManager.getConnectType(ScanSearchActivity.this, ip))) {
+                        ScanSearchActivity.this.interruptSearch();
+                        WiFiDirectManager.connect(ScanSearchActivity.this, ip, 7);
+                        return;
+                    }
+                    myPrinter.setLocation(ScanSearchActivity.this.scanner_location);
+                    ScanSearchActivity scanSearchActivity = ScanSearchActivity.this;
+                    String unused3 = scanSearchActivity.mSimpleApSsid = scanSearchActivity.getSimpleApSsid(myPrinter);
+                    ScanSearchActivity.this.startGetCapabilityAndFinishTask(myPrinter);
+                }
+            }
+        });
+        this.mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
+            public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long j) {
+                if (ScanSearchActivity.this.scanner_location == 1) {
+                    return true;
+                }
+                ScanSearchActivity scanSearchActivity = ScanSearchActivity.this;
+                scanSearchActivity.mDeletePos = i;
+                scanSearchActivity.registerForContextMenu(scanSearchActivity.mListView);
+                return false;
+            }
+        });
+        this.mAddButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                if (ScanSearchActivity.this.scanner_location == 3) {
+                    if (ScanSearchActivity.this.mBuilder.getData().size() >= 32) {
+                        new AlertDialog.Builder(ScanSearchActivity.this.mContext).setCancelable(false).setTitle(ScanSearchActivity.this.getString(C2135R.string.epsonconnect_err_regist_remote_printer_max_size_title)).setMessage(ScanSearchActivity.this.getString(C2135R.string.epsonconnect_err_regist_remote_printer_max_size)).setPositiveButton(ScanSearchActivity.this.getString(C2135R.string.str_yes), new DialogInterface.OnClickListener() {
+                            public void onClick(DialogInterface dialogInterface, int i) {
+                            }
+                        }).show();
+                        return;
+                    }
+                    Message message = new Message();
+                    message.what = 10;
+                    message.obj = null;
+                    ScanSearchActivity.this.mHandler.sendMessage(message);
+                }
+            }
+        });
+        this.mSearchButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                ScanSearchActivity.this.mHandler.sendEmptyMessageDelayed(1, 100);
+            }
+        });
+        this.mLocalButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                if (ScanSearchActivity.this.scanner_location != 1) {
+                    int unused = ScanSearchActivity.this.scanner_location = 1;
+                    ScanSearchActivity.this.buildElements();
+                    ScanSearchActivity.this.mHandler.sendEmptyMessageDelayed(1, 100);
+                }
+            }
+        });
+        this.mIpButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                if (ScanSearchActivity.this.scanner_location != 3) {
+                    ScanSearchActivity.this.interruptSearch();
+                    int unused = ScanSearchActivity.this.scanner_location = 3;
+                    ScanSearchActivity.this.buildElements();
+                }
+            }
+        });
+    }
+
+    public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) {
+        super.onCreateContextMenu(contextMenu, view, contextMenuInfo);
+        contextMenu.setHeaderTitle(C2135R.string.str_edit_bookmark);
+        contextMenu.add(0, 1, 0, C2135R.string.str_delete);
+        contextMenu.add(0, 2, 0, C2135R.string.str_edit_bookmark);
+    }
+
+    public boolean onContextItemSelected(MenuItem menuItem) {
+        this.listItemIndex = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
+        if (this.listItemIndex == null) {
+            return true;
+        }
+        switch (menuItem.getItemId()) {
+            case 1:
+                new AlertDialog.Builder(this.mContext).setCancelable(false).setTitle(getString(C2135R.string.delete_file)).setIcon(getResources().getDrawable(C2135R.C2136drawable.delete_file)).setNegativeButton(getString(C2135R.string.str_ok), new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialogInterface, int i) {
+                        Message obtainMessage = ScanSearchActivity.this.mHandler.obtainMessage();
+                        obtainMessage.what = 9;
+                        ScanSearchActivity.this.mHandler.sendMessageDelayed(obtainMessage, 100);
+                    }
+                }).setPositiveButton(getString(C2135R.string.str_cancel), new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialogInterface, int i) {
+                    }
+                }).show();
+                break;
+            case 2:
+                Message message = new Message();
+                if (this.scanner_location == 3) {
+                    message.what = 10;
+                }
+                message.obj = this.mBuilder.getData().elementAt(this.mDeletePos);
+                this.mHandler.sendMessage(message);
+                break;
+        }
+        return true;
+    }
+
+    /* access modifiers changed from: protected */
+    public void onDestroy() {
+        EPLog.m313i("epson.scan.activity.ScanSearchActivity", "Destroy search screen");
+        interruptSearch();
+        this.mBuilder.destructor();
+        super.onDestroy();
+    }
+
+    public void onBackPressed() {
+        if (!this.mProgress) {
+            this.mActivityBackRequested = true;
+            if (sEscanLibSemaphore.availablePermits() <= 0) {
+                interruptSearch();
+                new CancelWaitTask().execute(new Void[0]);
+                return;
+            }
+            releaseAndFinish();
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void releaseAndFinish() {
+        this.mEscanLib.escanWrapperReleaseDriver();
+        setResult(0);
+        finish();
+    }
+
+    /* access modifiers changed from: protected */
+    public void onActivityResult(int i, int i2, Intent intent) {
+        super.onActivityResult(i, i2, intent);
+        if (i != 7) {
+            if (i == 10 && i2 == -1) {
+                this.mBuilder.refresh();
+                MyPrinter myPrinter = new MyPrinter(intent.getStringExtra(Constants.PRINTER_NAME), intent.getStringExtra(Constants.PRINTER_IP), intent.getStringExtra(Constants.SCAN_REFS_SCANNER_ID), (String) null);
+                myPrinter.setLocation(3);
+                startGetCapabilityAndFinishTask(myPrinter);
+            }
+        } else if (i2 == -1) {
+            this.isSelected = true;
+            intent.getBooleanExtra(ActivityiPrintConnect.FINISH_EAYSETUP, false);
+            MyPrinter myPrinter2 = new MyPrinter(intent.getStringExtra("name"), intent.getStringExtra(escprLib.PRINTER_IP), intent.getStringExtra("id"), (String) null);
+            myPrinter2.setLocation(this.scanner_location);
+            this.mSimpleApSsid = getSimpleApSsid(myPrinter2);
+            startGetCapabilityAndFinishTask(myPrinter2);
+        } else {
+            forceSetPrinterSearchEnd();
+        }
+    }
+
+    /* access modifiers changed from: private */
+    @UiThread
+    public void search() {
+        interruptSearch();
+        this.mScannerFindCancelRequested = false;
+        this.mEscanLib.resetEscanLib();
+        this.mBuilder.refresh();
+        this.mBuilder.destructor();
+        this.wiFiDirectPrinterListUtils.clearPrinterInfoList();
+        if (WiFiDirectManager.getCurSSID(this) != null) {
+            this.mHandler.sendEmptyMessageDelayed(12, 5000);
+            this.isSearchSimpleAp = true;
+        } else if (WiFiDirectManager.isWifiEnabled(this)) {
+            this.mHandler.sendEmptyMessage(12);
+            this.isSearchSimpleAp = true;
+        } else {
+            boolean z = this.bCheckWiFiStatus;
+            if (!z && !z) {
+                this.bCheckWiFiStatus = true;
+                WiFiDirectManager.enableWiFi(this, -1);
+                return;
+            }
+        }
+        WiFiDirectManager.setPriorityToSimpleAP(this, true);
+        searchButtonSetEnabled(false);
+        this.mProgressBar.setVisibility(0);
+        this.tvResult.setText(getString(C2135R.string.lbl_scanner_search_processing));
+        this.isFinishSearchScanner = false;
+        this.mEscanLib.setScanHandler(this.mHandler);
+        this.mFindScannerTask = new FindScannerTask(this.mEscanLib);
+        this.mFindScannerTask.execute(new Void[0]);
+    }
+
+    /* access modifiers changed from: private */
+    @UiThread
+    public void interruptSearch() {
+        this.mScannerFindCancelRequested = true;
+        this.mHandler.removeMessages(1);
+        this.mHandler.removeMessages(12);
+        EPLog.m313i("epson.scan.activity.ScanSettingsActivity", "Cancel search scanner");
+        this.mHandler.removeMessages(8);
+        this.mHandler.removeMessages(6);
+        SearchWiFiDirectPrinterTask searchWiFiDirectPrinterTask = this.searchWiFiDirectPrinter;
+        if (searchWiFiDirectPrinterTask != null) {
+            searchWiFiDirectPrinterTask.interrupt();
+            this.searchWiFiDirectPrinter = null;
+        }
+        this.isSearchSimpleAp = false;
+        FindScannerTask findScannerTask = this.mFindScannerTask;
+        if (findScannerTask != null) {
+            findScannerTask.cancelFind();
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void updateFindScannerResult() {
+        if (!isFinishing()) {
+            this.mProgressBar.setVisibility(8);
+            searchButtonSetEnabled(true);
+            int size = this.mBuilder.getData().size();
+            if (size <= 0) {
+                this.tvResult.setText(C2135R.string.lbl_scanner_search_result_none);
+                if (this.mActivityForegroundLifetime) {
+                    showPrinterNotFoundDialog(getPrinterNotFoundDialog(this.isSearchSimpleAp));
+                }
+            } else if (Locale.getDefault().getLanguage().equalsIgnoreCase(Locale.JAPAN.getLanguage()) || Locale.getDefault().getLanguage().equalsIgnoreCase(Locale.JAPANESE.getLanguage())) {
+                this.tvResult.setText(getString(C2135R.string.lbl_scanner_search_result));
+            } else {
+                this.tvResult.setText(String.format(getString(C2135R.string.lbl_scanner_search_result), new Object[]{Integer.valueOf(size)}));
+            }
+        }
+    }
+
+    private DialogFragment getPrinterNotFoundDialog(boolean z) {
+        String str;
+        String str2;
+        if (z) {
+            str = getString(C2135R.string.EPS_PRNERR_COMM1_NOWIFI);
+            str2 = getString(C2135R.string.str_err_msg_scan_not_found_title);
+        } else {
+            str2 = getString(C2135R.string.str_err_msg_scan_not_found_title);
+            if (Utils.getPrefBoolean(getApplicationContext(), Constants.SCAN_REFS_USED_SCANNER_PATH, CommonDefine.RE_SEARCH)) {
+                str = getString(C2135R.string.str_err_msg_scan_not_found_research);
+                String ssid = Utils.getSSID(this);
+                if (!Utils.isConnectedWifi(this) || ssid == null) {
+                    return CustomLayoutDialogFragment.newInstance(1, str, str2, 0, (int) C2135R.string.str_btn_close);
+                }
+                str2 = str2 + "\nSSID: " + ssid;
+            } else {
+                str = getString(C2135R.string.str_err_msg_scan_not_found);
+            }
+        }
+        return CustomLayoutDialogFragment.newInstance(1, str + "\n\n" + getString(C2135R.string.confirm_browse_wlan_setup_info), str2, (int) C2135R.string.browse_site, (int) C2135R.string.str_btn_close);
+    }
+
+    private void showPrinterNotFoundDialog(DialogFragment dialogFragment) {
+        if (!isFinishing()) {
+            dialogFragment.show(getSupportFragmentManager(), DIALOG_TAG_PRINTER_NOT_FOUND);
+        }
+    }
+
+    /* access modifiers changed from: protected */
+    public Dialog onCreateDialog(int i) {
+        Dialog onCreateDialog = super.onCreateDialog(i);
+        if (i == C2135R.string.EPS_PRNERR_COMM1_NOWIFI) {
+            return Utils.makeMessageBox(this, getString(C2135R.string.str_err_msg_scan_not_found_title), getString(C2135R.string.EPS_PRNERR_COMM1_NOWIFI), getString(C2135R.string.str_ok));
+        }
+        switch (i) {
+            case C2135R.string.str_err_msg_scan_not_found /*2131625133*/:
+            case C2135R.string.str_err_msg_scan_not_found_research /*2131625134*/:
+                String str = "";
+                String ssid = Utils.getSSID(this);
+                if (Utils.isConnectedWifi(this) && ssid != null) {
+                    str = "\nSSID: " + ssid;
+                }
+                return Utils.makeMessageBox(this, getString(C2135R.string.str_err_msg_scan_not_found_title) + str, getString(i), getString(C2135R.string.str_ok));
+            default:
+                return onCreateDialog;
+        }
+    }
+
+    /* access modifiers changed from: package-private */
+    /* JADX WARNING: Failed to process nested try/catch */
+    /* JADX WARNING: Missing exception handler attribute for start block: B:11:0x0012 */
+    /* Code decompiled incorrectly, please refer to instructions dump. */
+    public void removeAllDialog() {
+        /*
+            r1 = this;
+            r0 = 2131625133(0x7f0e04ad, float:1.8877465E38)
+            r1.removeDialog(r0)     // Catch:{ IllegalArgumentException -> 0x0006 }
+        L_0x0006:
+            r0 = 2131625134(0x7f0e04ae, float:1.8877467E38)
+            r1.removeDialog(r0)     // Catch:{ IllegalArgumentException -> 0x000c }
+        L_0x000c:
+            r0 = 2131624361(0x7f0e01a9, float:1.88759E38)
+            r1.removeDialog(r0)     // Catch:{ IllegalArgumentException -> 0x0012 }
+        L_0x0012:
+            r1.dismissPrinterNotFoundDialog()     // Catch:{ Exception -> 0x0015 }
+        L_0x0015:
+            return
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.scan.activity.ScanSearchActivity.removeAllDialog():void");
+    }
+
+    private void dismissPrinterNotFoundDialog() {
+        DialogFragment dialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(DIALOG_TAG_PRINTER_NOT_FOUND);
+        if (dialogFragment != null) {
+            dialogFragment.dismiss();
+        }
+    }
+
+    public void searchButtonSetEnabled(boolean z) {
+        this.mSearchButton.setVisibility(0);
+        if (z) {
+            this.mSearchButton.setEnabled(true);
+        } else {
+            this.mSearchButton.setEnabled(false);
+        }
+    }
+
+    /* access modifiers changed from: protected */
+    public void onResume() {
+        super.onResume();
+        EPLog.m307e("Epson", "ScanSearchActivity.java call onResume()");
+        this.mActivityForegroundLifetime = true;
+        dismissPrinterNotFoundDialog();
+        if (this.scanner_location != 3) {
+            if (!this.isSelected) {
+                this.mHandler.removeMessages(1);
+                this.mHandler.sendEmptyMessageDelayed(1, 100);
+            }
+            EPLog.m305d("ScanSearchActivity", "Send CHECK_PRINTER Message.");
+        }
+    }
+
+    /* access modifiers changed from: protected */
+    public void onPause() {
+        EPLog.m305d("SearchPrinterScr", "onPause");
+        super.onPause();
+        this.mActivityForegroundLifetime = false;
+        interruptSearch();
+        if (!this.isSelected) {
+            removeAllDialog();
+        }
+        GetScannerCapabilityAndFinishTask getScannerCapabilityAndFinishTask = this.mGetScannerCapabilityAndFinishTask;
+        if (getScannerCapabilityAndFinishTask != null) {
+            getScannerCapabilityAndFinishTask.cancelTask();
+        }
+    }
+
+    /* access modifiers changed from: package-private */
+    @UiThread
+    public void showErrorDialog(EscanLibException escanLibException) {
+        int[] iArr;
+        if (!isFinishing()) {
+            if (escanLibException.getEscIVersion() == 1) {
+                iArr = getEscanI1ErrorTitleAndMessageId(escanLibException.getEscanLibErrorCode());
+            } else {
+                iArr = getEscanI2ErrorTitleAndMessageId(escanLibException.getEscanLibErrorCode());
+            }
+            this.errorDialog = Utils.makeMessageBox(this, getString(iArr[0]), getString(iArr[1]), getString(C2135R.string.str_ok));
+            this.errorDialog.show();
+        }
+    }
+
+    @NonNull
+    private static int[] getEscanI1ErrorTitleAndMessageId(int i) {
+        if (i == -500001) {
+            return new int[]{C2135R.string.EPS_PRNERR_COMM_TITLE2, C2135R.string.str_ipprinter_comerror};
+        }
+        if (i != -1501) {
+            if (i == -1300) {
+                return new int[]{C2135R.string.str_err_msg_scan_not_found_title, C2135R.string.str_err_msg_scan_not_found_research};
+            }
+            if (i != -1100) {
+                switch (i) {
+                    case 5:
+                        break;
+                    case 6:
+                        break;
+                    default:
+                        return new int[]{C2135R.string.str_err_msg_scan_generic_internal_title, C2135R.string.str_err_msg_scan_generic_internal};
+                }
+            }
+            return new int[]{C2135R.string.str_err_msg_scan_comm_title, C2135R.string.str_err_msg_scan_comm};
+        }
+        return new int[]{C2135R.string.str_err_msg_scan_busy_title, C2135R.string.str_err_msg_scan_busy};
+    }
+
+    @NonNull
+    private static int[] getEscanI2ErrorTitleAndMessageId(int i) {
+        int[] iArr = new int[2];
+        switch (i) {
+            case Constants.ESCAN_ERR_SCANNER_OCCUPIED:
+            case -213:
+                iArr[0] = C2135R.string.str_err_msg_scan_busy_title;
+                iArr[1] = C2135R.string.str_err_msg_scan_busy;
+                break;
+            case -1300:
+                iArr[0] = C2135R.string.str_err_msg_scan_not_found_title;
+                iArr[1] = C2135R.string.str_err_msg_scan_not_found_research;
+                break;
+            case -1114:
+            case -1100:
+            case -214:
+                iArr[0] = C2135R.string.str_err_msg_scan_comm_title;
+                iArr[1] = C2135R.string.str_err_msg_scan_comm;
+                break;
+            case -202:
+            case -201:
+            case -102:
+            case -101:
+                iArr[0] = C2135R.string.str_blank;
+                iArr[1] = C2135R.string.str_err_msg_out_of_memory_title;
+                break;
+            default:
+                iArr[0] = C2135R.string.str_err_msg_scan_generic_internal_title;
+                iArr[1] = C2135R.string.str_err_msg_scan_generic_internal;
+                break;
+        }
+        return iArr;
+    }
+
+    /* access modifiers changed from: private */
+    public void forceSetPrinterSearchEnd() {
+        this.isFocused = true;
+        this.isSelected = false;
+    }
+
+    /* access modifiers changed from: private */
+    public void localFinish(ScannerPropertyWrapper scannerPropertyWrapper) {
+        scannerPropertyWrapper.setSimpleApSsid(this.mSimpleApSsid);
+        setResult(-1, SettingActivityParams.getScanSearchReturnIntent(scannerPropertyWrapper));
+        finish();
+    }
+
+    /* access modifiers changed from: private */
+    public String getSimpleApSsid(MyPrinter myPrinter) {
+        String macAddressFromScannerId = MacAddrUtils.getMacAddressFromScannerId(myPrinter.getScannerId());
+        if (macAddressFromScannerId == null) {
+            macAddressFromScannerId = MacAddrUtils.getMacAddressFromPrinterId(myPrinter.getPrinterId());
+        }
+        String curConnectInfo = WiFiDirectManager.getCurConnectInfo(this, macAddressFromScannerId);
+        return curConnectInfo != null ? curConnectInfo : "";
+    }
+
+    public void onLocalPositiveCallback(int i) {
+        if (i == 1) {
+            startActivity(PrinterNotFoundDialogCreator.getStartIntent(this));
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void showProgress() {
+        this.mProgress = true;
+        this.mProgressDialog = new WorkingDialog(this);
+        this.mProgressDialog.show();
+    }
+
+    /* access modifiers changed from: private */
+    public void dismissProgress() {
+        if (this.mProgressBar != null && this.mProgressDialog.isShowing()) {
+            this.mProgressDialog.dismiss();
+        }
+        this.mProgress = false;
+    }
+
+    /* access modifiers changed from: private */
+    public void startGetCapabilityAndFinishTask(MyPrinter myPrinter) {
+        this.mMyPrinterForSimpleApDisconnect = myPrinter.getIp();
+        interruptSearch();
+        this.mGetScannerCapabilityAndFinishTask = new GetScannerCapabilityAndFinishTask(this.mEscanLib, myPrinter);
+        this.mGetScannerCapabilityAndFinishTask.execute(new Void[0]);
+    }
+
+    /* access modifiers changed from: private */
+    public void disconnectSimpleAp() {
+        WiFiDirectManager.disconnect(getApplicationContext(), WiFiDirectManager.DEVICE_TYPE_SCANNER, this.mMyPrinterForSimpleApDisconnect);
+        WiFiDirectManager.disconnectSimpleAP(getApplicationContext(), WiFiDirectManager.getCurSSID(this), this.mMyPrinterForSimpleApDisconnect);
+    }
+
+    public static Intent getStartIntent(Context context, String str, int i, String str2) {
+        Intent intent = new Intent(context, ScanSearchActivity.class);
+        intent.putExtra(PARAM_KEY_SCANNER_LOCATION, i);
+        intent.putExtra(PARAM_KEY_SCANNER_ID, str);
+        intent.putExtra(PARAM_KEY_SCANNER_SSID, str2);
+        return intent;
+    }
+
+    private class FindScannerTask extends AsyncTask<Void, Void, Boolean> {
+        private CancelableFind mCancelableFind = new CancelableFind();
+
+        /* access modifiers changed from: protected */
+        public void onCancelled(Boolean bool) {
+        }
+
+        FindScannerTask(escanLib escanlib) {
+            this.mCancelableFind.setEscanLib(escanlib);
+        }
+
+        /* access modifiers changed from: protected */
+        public Boolean doInBackground(Void... voidArr) {
+            if (ScanSearchActivity.this.mScannerFindCancelRequested) {
+                return true;
+            }
+            try {
+                ScanSearchActivity.sEscanLibSemaphore.acquire();
+                this.mCancelableFind.setEscanLib(ScanSearchActivity.this.mEscanLib);
+                this.mCancelableFind.findScanner(ScanSearchActivity.this.getApplicationContext(), ScanSearchActivity.this.mHandler);
+            } catch (InterruptedException unused) {
+            } catch (Throwable th) {
+                ScanSearchActivity.sEscanLibSemaphore.release();
+                throw th;
+            }
+            ScanSearchActivity.sEscanLibSemaphore.release();
+            return true;
+        }
+
+        /* access modifiers changed from: protected */
+        public void onPostExecute(Boolean bool) {
+            boolean unused = ScanSearchActivity.this.isFinishSearchScanner = true;
+            if (!this.mCancelableFind.isCanceled() && !ScanSearchActivity.this.isSearchSimpleAp) {
+                ScanSearchActivity.this.updateFindScannerResult();
+            }
+        }
+
+        public void cancelFind() {
+            this.mCancelableFind.cancel();
+        }
+    }
+
+    private class GetScannerCapabilityAndFinishTask extends AsyncTask<Void, Void, Boolean> {
+        private boolean mCancelRequested;
+        private CancelablePropertyTaker mCancelablePropertyTaker;
+        private EscanLibException mEscanErrorCode = null;
+        private escanLib mEscanLib;
+        private MyPrinter mMyPrinter;
+        private ScannerPropertyWrapper mScannerPropertyWrapper;
+
+        public GetScannerCapabilityAndFinishTask(escanLib escanlib, MyPrinter myPrinter) {
+            this.mEscanLib = escanlib;
+            this.mMyPrinter = myPrinter;
+        }
+
+        /* access modifiers changed from: protected */
+        public Boolean doInBackground(Void... voidArr) {
+            if (ScanSearchActivity.this.mActivityBackRequested) {
+                return false;
+            }
+            try {
+                ScanSearchActivity.sEscanLibSemaphore.acquire();
+                if (!ScanSearchActivity.this.mActivityBackRequested) {
+                    if (!this.mCancelRequested) {
+                        synchronized (this) {
+                            this.mCancelablePropertyTaker = new CancelablePropertyTaker(this.mEscanLib);
+                        }
+                        this.mScannerPropertyWrapper = this.mCancelablePropertyTaker.getScannerProperty(this.mMyPrinter);
+                        if (!ScanSearchActivity.this.mActivityBackRequested) {
+                            if (!this.mCancelRequested) {
+                                if (this.mScannerPropertyWrapper == null) {
+                                    this.mEscanErrorCode = new EscanLibException(1, -1300);
+                                    ScanSearchActivity.this.disconnectSimpleAp();
+                                    ScanSearchActivity.sEscanLibSemaphore.release();
+                                    return false;
+                                }
+                                this.mEscanLib.escanWrapperReleaseDriver();
+                                ScanSearchActivity.this.disconnectSimpleAp();
+                                ScanSearchActivity.sEscanLibSemaphore.release();
+                                return true;
+                            }
+                        }
+                        ScanSearchActivity.this.disconnectSimpleAp();
+                        ScanSearchActivity.sEscanLibSemaphore.release();
+                        return false;
+                    }
+                }
+                ScanSearchActivity.this.disconnectSimpleAp();
+                ScanSearchActivity.sEscanLibSemaphore.release();
+                return false;
+            } catch (EscanLibException e) {
+                try {
+                    this.mEscanErrorCode = e;
+                    return false;
+                } finally {
+                    ScanSearchActivity.this.disconnectSimpleAp();
+                    ScanSearchActivity.sEscanLibSemaphore.release();
+                }
+            } catch (InterruptedException unused) {
+            }
+        }
+
+        /* access modifiers changed from: protected */
+        public void onPostExecute(Boolean bool) {
+            EscanLibException escanLibException;
+            if (!ScanSearchActivity.this.isFinishing()) {
+                ScanSearchActivity.this.dismissProgress();
+                if (!bool.booleanValue()) {
+                    ScanSearchActivity.this.forceSetPrinterSearchEnd();
+                    if (!this.mCancelRequested && (escanLibException = this.mEscanErrorCode) != null) {
+                        ScanSearchActivity.this.showErrorDialog(escanLibException);
+                        return;
+                    }
+                    return;
+                }
+                ScanSearchActivity.this.localFinish(this.mScannerPropertyWrapper);
+            }
+        }
+
+        /* access modifiers changed from: protected */
+        public void onPreExecute() {
+            ScanSearchActivity.this.showProgress();
+        }
+
+        /* access modifiers changed from: package-private */
+        public void cancelTask() {
+            this.mCancelRequested = true;
+            synchronized (this) {
+                if (this.mCancelablePropertyTaker != null) {
+                    this.mCancelablePropertyTaker.cancel();
+                }
+            }
+        }
+    }
+
+    class CancelWaitTask extends AsyncTask<Void, Void, Void> {
+        CancelWaitTask() {
+        }
+
+        /* access modifiers changed from: protected */
+        public Void doInBackground(Void... voidArr) {
+            try {
+                ScanSearchActivity.sEscanLibSemaphore.acquire();
+                ScanSearchActivity.this.disconnectSimpleAp();
+                ScanSearchActivity.sEscanLibSemaphore.release();
+                return null;
+            } catch (InterruptedException unused) {
+                return null;
+            }
+        }
+
+        /* access modifiers changed from: protected */
+        public void onPostExecute(Void voidR) {
+            ScanSearchActivity.this.releaseAndFinish();
+        }
+    }
+}

+ 644 - 0
app/src/main/java/epson/scan/activity/ScanSettingsActivity.java

@@ -0,0 +1,644 @@
+package epson.scan.activity;
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.Intent;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import com.epson.iprint.shared.SharedParamScan;
+import com.epson.mobilephone.common.PrintingLib.define.Constants;
+import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
+import epson.common.Constants;
+import epson.common.Utils;
+import epson.print.ActivityIACommon;
+import epson.print.C2135R;
+import epson.print.EPPrinterManager;
+import epson.print.Util.EPLog;
+import epson.scan.lib.ScanCommonParams;
+import epson.scan.lib.ScanInfoStorage;
+import epson.scan.lib.ScanSettingHelper;
+import epson.scan.lib.ScanSizeHelper;
+import epson.scan.lib.ScannerInfo;
+
+public class ScanSettingsActivity extends ActivityIACommon {
+    public static final String HIDE_COLOR_MODE = "hide-color-mode";
+    public static final String HIDE_RESOLUTION = "hide-resolution";
+    public static final String IS_NEW_SAVE = "IS_NEW_SAVE";
+    public static final String NO_CLEAR_RESULT = "NO_CLEAR_RESULT";
+    public static final String PARAM_KEY_EXTERNAL_DATA = "external-scan-params";
+    private static final int REQUEST_CODE_BRIGHTNESS = 8;
+    private static final int REQUEST_CODE_CHANGE_ESC_I_VERSION = 100;
+    private static final int REQUEST_CODE_SELECT_SCANNER = 1;
+    private static final String SCAN_SETTINGS_LAST_DENSITY = "SCAN_SETTINGS_LAST_DENSITY";
+    private static final String SCAN_SETTINGS_LAST_DENSITY_STATUS = "SCAN_SETTINGS_LAST_DENSITY_STATUS";
+    private static final String SCAN_SETTINGS_LAST_VALUE = "SCAN_SETTINGS_LAST_VALUE";
+    private static final String SCAN_SUPPORTED_RESOLUTION_LIST = "SCAN_SUPPORTED_RESOLUTION_LIST";
+    private static final String SCAN_SUPPORTED_SIZE_LIST = "SCAN_SUPPORTED_SIZE_LIST";
+    /* access modifiers changed from: private */
+    public String autoConnectSsid = null;
+    private Context context;
+    private AlertDialog errorDialog;
+    private boolean isNeedSaveSupportedOptions = false;
+    /* access modifiers changed from: private */
+    public LinearLayout llScanName;
+    private LinearLayout llScanSettingsAdvance2Sided;
+    private LinearLayout llScanSettingsColor;
+    private LinearLayout llScanSettingsDensity;
+    private LinearLayout llScanSettingsGamma;
+    private LinearLayout llScanSettingsResolution;
+    private LinearLayout llScanSettingsSize;
+    private LinearLayout llScanSettingsSource;
+    private View mBrightnessSeparator;
+    private SharedParamScan mExternalIntentData;
+    private boolean mHideColorMode;
+    private boolean mHideResolution;
+    private View.OnClickListener mLLScanNameClick = new View.OnClickListener() {
+        public void onClick(View view) {
+            ScanSettingsActivity.this.llScanName.setClickable(false);
+            new AsyncTask<Void, Void, Void>() {
+                /* access modifiers changed from: protected */
+                public void onPreExecute() {
+                }
+
+                /* access modifiers changed from: protected */
+                public Void doInBackground(Void... voidArr) {
+                    WiFiDirectManager.disconnect(ScanSettingsActivity.this.getApplicationContext(), WiFiDirectManager.DEVICE_TYPE_SCANNER, ScanSettingsActivity.this.scanInfo.getIp());
+                    WiFiDirectManager.disconnectSimpleAP(ScanSettingsActivity.this.getApplicationContext(), ScanSettingsActivity.this.autoConnectSsid, ScanSettingsActivity.this.scanInfo.getIp());
+                    return null;
+                }
+
+                /* access modifiers changed from: protected */
+                public void onPostExecute(Void voidR) {
+                    ScanSettingsActivity.this.startActivityForResult(ScanSearchActivity.getStartIntent(ScanSettingsActivity.this.getApplicationContext(), ScanSettingsActivity.this.scanInfo.getScannerId(), ScanSettingsActivity.this.scanInfo.getLocation(), ScanSettingsActivity.this.autoConnectSsid), 1);
+                    ScanSettingsActivity.this.llScanName.setClickable(true);
+                }
+            }.execute(new Void[0]);
+        }
+    };
+    private View.OnClickListener mLLScanSettings2Sided = new View.OnClickListener() {
+        public void onClick(View view) {
+            ScanSettingsActivity scanSettingsActivity = ScanSettingsActivity.this;
+            scanSettingsActivity.goToSettingAdvanceDetailsScreen(Constants.SCAN_SETTINGS_DETAIL_TITLE, C2135R.string.str_settings_2sided_title, scanSettingsActivity.scanInfo.getTwoSidedScanningValue(), 7);
+        }
+    };
+    private View.OnClickListener mLLScanSettingsColor = new View.OnClickListener() {
+        public void onClick(View view) {
+            if (ScanSettingsActivity.this.scanInfo.getIp().equals("")) {
+                return;
+            }
+            if (ScanSettingsActivity.this.progressGetOption == null || !ScanSettingsActivity.this.progressGetOption.isShown()) {
+                ScanSettingsActivity scanSettingsActivity = ScanSettingsActivity.this;
+                scanSettingsActivity.startDetailSettingScreenForResult(Constants.SCAN_SETTINGS_DETAIL_TITLE, C2135R.string.str_settings_color_title, scanSettingsActivity.scanInfo.getColorValue(), 5);
+            }
+        }
+    };
+    private View.OnClickListener mLLScanSettingsDensity = new View.OnClickListener() {
+        public void onClick(View view) {
+            ScanSettingsActivity.this.goToSettingAdvanceDensityScreen();
+        }
+    };
+    private View.OnClickListener mLLScanSettingsGamma = new View.OnClickListener() {
+        public void onClick(View view) {
+            ScanSettingsActivity scanSettingsActivity = ScanSettingsActivity.this;
+            scanSettingsActivity.goToSettingAdvanceDetailsScreen(Constants.SCAN_SETTINGS_DETAIL_TITLE, C2135R.string.str_settings_gamma_title, scanSettingsActivity.scanInfo.getGammaValue(), 9);
+        }
+    };
+    private View.OnClickListener mLLScanSettingsResolution = new View.OnClickListener() {
+        public void onClick(View view) {
+            if (ScanSettingsActivity.this.scanInfo.getIp().equals("")) {
+                return;
+            }
+            if (ScanSettingsActivity.this.progressGetOption == null || !ScanSettingsActivity.this.progressGetOption.isShown()) {
+                ScanSettingsActivity scanSettingsActivity = ScanSettingsActivity.this;
+                scanSettingsActivity.startDetailSettingScreenForResult(Constants.SCAN_SETTINGS_DETAIL_TITLE, C2135R.string.str_settings_resolution_title, scanSettingsActivity.scanInfo.getResolutionValue(), 6);
+            }
+        }
+    };
+    private View.OnClickListener mLLScanSettingsSize = new View.OnClickListener() {
+        public void onClick(View view) {
+            ScanSettingsActivity scanSettingsActivity = ScanSettingsActivity.this;
+            scanSettingsActivity.startDetailSettingScreenForResult(Constants.SCAN_SETTINGS_DETAIL_TITLE, C2135R.string.str_scanning_size, scanSettingsActivity.scanInfo.getSizeValue(), 11);
+        }
+    };
+    private View.OnClickListener mLLScanSettingsSource = new View.OnClickListener() {
+        public void onClick(View view) {
+            if (ScanSettingsActivity.this.scanInfo.getIp().equals("")) {
+                return;
+            }
+            if (ScanSettingsActivity.this.progressGetOption == null || !ScanSettingsActivity.this.progressGetOption.isShown()) {
+                ScanSettingsActivity.this.startInputUnitSettingActivity();
+            }
+        }
+    };
+    private ScanInfoStorage mScanInfoStorage;
+    /* access modifiers changed from: private */
+    public View progressGetOption;
+    /* access modifiers changed from: private */
+    public ScannerInfo scanInfo;
+    private ScannerInfo siOrigin;
+    private TextView tvScanner2Sided;
+    private TextView tvScannerColor;
+    private TextView tvScannerDensity;
+    private TextView tvScannerGamma;
+    private TextView tvScannerName;
+    private TextView tvScannerResolution;
+    private TextView tvScannerSize;
+    private TextView tvScannerSource;
+    private View viewScanSettingsAdvance2Sided;
+    private View viewScanSettingsSource;
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        this.mScanInfoStorage = ScanInfoStorage.getInstance();
+        setContentView((int) C2135R.layout.scan_settings_main);
+        setActionBar((int) C2135R.string.str_lbl_title_scan_settings, true);
+        this.context = this;
+        this.llScanName = (LinearLayout) findViewById(C2135R.C2137id.llScannerName);
+        this.llScanName.setOnClickListener(this.mLLScanNameClick);
+        this.llScanSettingsSource = (LinearLayout) findViewById(C2135R.C2137id.llScanSettingsSource);
+        this.llScanSettingsSource.setOnClickListener(this.mLLScanSettingsSource);
+        this.llScanSettingsSize = (LinearLayout) findViewById(C2135R.C2137id.llScanSettingsSize);
+        this.llScanSettingsSize.setOnClickListener(this.mLLScanSettingsSize);
+        this.viewScanSettingsSource = findViewById(C2135R.C2137id.viewScanSettingsSource);
+        this.llScanSettingsColor = (LinearLayout) findViewById(C2135R.C2137id.llScanSettingsColor);
+        this.llScanSettingsColor.setOnClickListener(this.mLLScanSettingsColor);
+        this.llScanSettingsResolution = (LinearLayout) findViewById(C2135R.C2137id.llScanSettingsResolution);
+        this.llScanSettingsResolution.setOnClickListener(this.mLLScanSettingsResolution);
+        this.tvScannerName = (TextView) findViewById(C2135R.C2137id.tvScannerName);
+        this.tvScannerSource = (TextView) findViewById(C2135R.C2137id.tvScannerSource);
+        this.tvScannerSize = (TextView) findViewById(C2135R.C2137id.tvScannerSize);
+        this.tvScannerColor = (TextView) findViewById(C2135R.C2137id.tvScannerColor);
+        this.tvScannerResolution = (TextView) findViewById(C2135R.C2137id.tvScannerResolution);
+        this.progressGetOption = findViewById(C2135R.C2137id.progressGetOption);
+        this.llScanSettingsAdvance2Sided = (LinearLayout) findViewById(C2135R.C2137id.llScanSettingsAdvance2Sided);
+        this.llScanSettingsAdvance2Sided.setOnClickListener(this.mLLScanSettings2Sided);
+        this.viewScanSettingsAdvance2Sided = findViewById(C2135R.C2137id.viewScanSettingsAdvance2Sided);
+        this.llScanSettingsDensity = (LinearLayout) findViewById(C2135R.C2137id.llScanSettingsDensity);
+        this.llScanSettingsDensity.setOnClickListener(this.mLLScanSettingsDensity);
+        this.mBrightnessSeparator = findViewById(C2135R.C2137id.brightnessSeparator);
+        this.llScanSettingsGamma = (LinearLayout) findViewById(C2135R.C2137id.llScanSettingsGamma);
+        this.llScanSettingsGamma.setOnClickListener(this.mLLScanSettingsGamma);
+        this.tvScanner2Sided = (TextView) findViewById(C2135R.C2137id.tvScanner2Sided);
+        this.tvScannerDensity = (TextView) findViewById(C2135R.C2137id.tvScannerDensity);
+        this.tvScannerGamma = (TextView) findViewById(C2135R.C2137id.tvScannerGamma);
+        Intent intent = getIntent();
+        this.mHideResolution = intent.getBooleanExtra(HIDE_RESOLUTION, false);
+        if (this.mHideResolution) {
+            this.llScanSettingsResolution.setVisibility(8);
+        }
+        this.mHideColorMode = intent.getBooleanExtra(HIDE_COLOR_MODE, false);
+        if (this.mHideColorMode) {
+            this.llScanSettingsColor.setVisibility(8);
+        }
+        this.mExternalIntentData = (SharedParamScan) intent.getSerializableExtra(PARAM_KEY_EXTERNAL_DATA);
+        this.scanInfo = new ScannerInfo();
+        getScannerSavedSettings();
+        if (this.scanInfo.getIp().equals("")) {
+            setBlankSettings();
+            showNewSelectedScannerInfo();
+        } else {
+            setResolutionClickable();
+            setColorModeClickable();
+        }
+        this.siOrigin = new ScannerInfo(this.scanInfo);
+        updateScannerInfoIfEscIVersionChanged(getIntent());
+    }
+
+    private void updateScannerInfoIfEscIVersionChanged(Intent intent) {
+        ScannerPropertyWrapper scannerPropertyWrapper = SettingActivityParams.getScannerPropertyWrapper(intent);
+        if (scannerPropertyWrapper != null) {
+            if (!scannerPropertyWrapper.isPrinterSet()) {
+                resetSettings();
+                return;
+            }
+            ScannerInfo i1ScannerInfo = scannerPropertyWrapper.getI1ScannerInfo();
+            if (i1ScannerInfo != null) {
+                this.isNeedSaveSupportedOptions = true;
+                updateSelectedScannerInfo(i1ScannerInfo, scannerPropertyWrapper.getSimpleApSsid());
+            }
+        }
+    }
+
+    private void updatePrinterIcon() {
+        if (this.scanInfo.isModelNameEmpty()) {
+            ((ImageView) findViewById(C2135R.C2137id.imageViewPrinterLocation)).setVisibility(8);
+            return;
+        }
+        ((ImageView) findViewById(C2135R.C2137id.imageViewPrinterLocation)).setVisibility(0);
+        switch (this.scanInfo.getLocation()) {
+            case 1:
+                ((ImageView) findViewById(C2135R.C2137id.imageViewPrinterLocation)).setImageResource(C2135R.C2136drawable.print_local);
+                return;
+            case 2:
+                ((ImageView) findViewById(C2135R.C2137id.imageViewPrinterLocation)).setImageResource(C2135R.C2136drawable.print_remote);
+                return;
+            case 3:
+                ((ImageView) findViewById(C2135R.C2137id.imageViewPrinterLocation)).setImageResource(C2135R.C2136drawable.print_ip);
+                return;
+            default:
+                return;
+        }
+    }
+
+    private void getScannerSavedSettings() {
+        EPLog.m313i("epson.scan.activity.ScanSettingsActivity", "Start get saved option");
+        loadRefScannerName();
+        loadRefScannerSourceSetting();
+        loadRefScannerColorSetting();
+        loadRefScannerResolutionSetting();
+        loadRefScannerBasicOptions();
+        this.scanInfo.setSizeValue(Constants.PaperName.EPS_MSID_UNKNOWN.getCode());
+        this.mScanInfoStorage.loadScanSetting(this, this.scanInfo);
+        int[] iArr = new int[64];
+        for (int i = 0; i < 64; i++) {
+            Context context2 = this.context;
+            iArr[i] = Utils.getPrefInt(context2, epson.common.Constants.SCAN_REFS_SUPPORTED_OPTIONS, epson.common.Constants.SCAN_REFS_OPTIONS_RESOLUTION_ + i);
+        }
+        this.scanInfo.setSupportedResolutionList(iArr);
+        this.autoConnectSsid = WiFiDirectManager.getConnectInfo(this, WiFiDirectManager.DEVICE_TYPE_SCANNER);
+        updateScanner2SidedSetting(this.scanInfo.getTwoSidedScanningName(), this.scanInfo.getSupportedAdfDuplex());
+        this.tvScannerDensity.setText(String.valueOf(255 - this.scanInfo.getDensityValue()));
+        this.tvScannerGamma.setText(this.scanInfo.getGammaName());
+    }
+
+    @Deprecated
+    private void loadRefScannerName() {
+        this.mScanInfoStorage.loadScannerConnectivityInfo(this, this.scanInfo);
+        displayScannerName();
+        updatePrinterIcon();
+    }
+
+    private void displayScannerName() {
+        String ipPrinterUserName;
+        if (this.scanInfo.getLocation() != 3 || (ipPrinterUserName = new EPPrinterManager(this).getIpPrinterUserName(this.scanInfo.getScannerId())) == null) {
+            String modelName = this.scanInfo.getModelName();
+            if (modelName == null || modelName.isEmpty()) {
+                this.tvScannerName.setText(C2135R.string.str_lbl_title_scan);
+            } else {
+                this.tvScannerName.setText(modelName);
+            }
+        } else {
+            this.tvScannerName.setText(ipPrinterUserName);
+        }
+    }
+
+    @Deprecated
+    private void loadRefScannerSourceSetting() {
+        this.mScanInfoStorage.loadSupportedAdfSize(this, this.scanInfo);
+        this.mScanInfoStorage.loadReadUnitValue(this, this.scanInfo);
+        this.tvScannerSource.setText(getString(this.scanInfo.getSourceName()));
+        if (this.scanInfo.getSupportedAdfHeight() == 0 && this.scanInfo.getSupportedAdfWidth() == 0) {
+            this.llScanSettingsSource.setVisibility(8);
+            this.viewScanSettingsSource.setVisibility(8);
+            return;
+        }
+        this.llScanSettingsSource.setVisibility(0);
+        this.viewScanSettingsSource.setVisibility(0);
+    }
+
+    @Deprecated
+    private void loadRefScannerColorSetting() {
+        this.mScanInfoStorage.loadColorValue(this, this.scanInfo);
+        this.tvScannerColor.setText(getString(this.scanInfo.getColorName()));
+    }
+
+    @Deprecated
+    private void loadRefScannerResolutionSetting() {
+        this.mScanInfoStorage.loadResolution(this, this.scanInfo);
+        this.tvScannerResolution.setText(this.scanInfo.getResolutionName(this));
+    }
+
+    private void loadRefScannerBasicOptions() {
+        this.mScanInfoStorage.loadSupportedValue(this, this.scanInfo);
+    }
+
+    /* access modifiers changed from: private */
+    public void startInputUnitSettingActivity() {
+        if (this.scanInfo.getSupportedAdfWidth() > 0 && this.scanInfo.getSupportedAdfHeight() > 0) {
+            startActivityForResult(InputUnitSettingActivity.getStartIntent(this, this.scanInfo.getSourceValue(), this.scanInfo.getAdfPaperGuide()), 4);
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void startDetailSettingScreenForResult(String str, int i, int i2, int i3) {
+        Intent intent = new Intent(this, ScanSettingsDetailActivity.class);
+        intent.putExtra(str, i);
+        intent.putExtra(SCAN_SETTINGS_LAST_VALUE, i2);
+        intent.putExtra(epson.common.Constants.SCAN_REFS_OPTIONS_ADF_WIDTH, this.scanInfo.getSupportedAdfWidth());
+        intent.putExtra(epson.common.Constants.SCAN_REFS_OPTIONS_ADF_HEIGHT, this.scanInfo.getSupportedAdfHeight());
+        intent.putExtra(SCAN_SUPPORTED_RESOLUTION_LIST, this.scanInfo.getSupportedResolutionList());
+        intent.putExtra(epson.common.Constants.SCAN_REFS_SETTINGS_ADF_PAPER_GUIDE, this.scanInfo.getAdfPaperGuide());
+        int[] iArr = new int[0];
+        switch (this.scanInfo.getSourceValue()) {
+            case 0:
+                iArr = ScanSizeHelper.getSupportedScanSizeList(this.scanInfo.getSourceValue(), 0, this.scanInfo.getSupportedBasicWidth(), this.scanInfo.getSupportedBasicHeight(), this.scanInfo.getSupportedBasicResolution());
+                break;
+            case 1:
+                iArr = ScanSizeHelper.getSupportedScanSizeList(this.scanInfo.getSourceValue(), this.scanInfo.getTwoSidedScanningValue(), this.scanInfo.getSupportedAdfWidth(), this.scanInfo.getSupportedAdfHeight(), this.scanInfo.getSupportedBasicResolution());
+                break;
+        }
+        intent.putExtra(SCAN_SUPPORTED_SIZE_LIST, iArr);
+        intent.setAction("android.intent.action.VIEW");
+        startActivityForResult(intent, i3);
+    }
+
+    /* access modifiers changed from: private */
+    public void goToSettingAdvanceDensityScreen() {
+        startActivityForResult(ScanSettingsAdvanceDensityActivity.getStartIntent(this, this.scanInfo.getDensityValue(), this.scanInfo.isDensityStatus()), 8);
+    }
+
+    /* access modifiers changed from: private */
+    public void goToSettingAdvanceDetailsScreen(String str, int i, int i2, int i3) {
+        Intent intent = new Intent(this, ScanSettingsAdvanceDetailActivity.class);
+        intent.putExtra(str, i);
+        intent.putExtra(SCAN_SETTINGS_LAST_VALUE, i2);
+        intent.putExtra(epson.common.Constants.SCAN_REFS_OPTIONS_SUPPORTED_ADF_DUPLEX, this.scanInfo.getSupportedAdfDuplex());
+        int i4 = 1;
+        if (!this.scanInfo.isAdfDuplexRotaitonYes()) {
+            i4 = 0;
+        }
+        intent.putExtra(epson.common.Constants.SCAN_REFS_SETTINGS_ROTATE, i4);
+        intent.setAction("android.intent.action.VIEW");
+        startActivityForResult(intent, i3);
+    }
+
+    /* access modifiers changed from: protected */
+    public void onActivityResult(int i, int i2, Intent intent) {
+        super.onActivityResult(i, i2, intent);
+        if (i == 1) {
+            onScannerSelectResult(i2, intent);
+        } else if (i != 100) {
+            if (i2 == -1) {
+                Bundle extras = intent.getExtras();
+                boolean z = false;
+                switch (i) {
+                    case 4:
+                        this.scanInfo.setSourceValue(InputUnitSettingActivity.getInputUnit(intent));
+                        int adfAlignment = InputUnitSettingActivity.getAdfAlignment(intent);
+                        if (adfAlignment >= 0) {
+                            this.scanInfo.setAdfPaperGuide(adfAlignment);
+                        }
+                        this.tvScannerSource.setText(this.scanInfo.getSourceName());
+                        if (this.scanInfo.getSourceValue() == 0) {
+                            this.scanInfo.setTwoSidedScanningValue(0);
+                        }
+                        updateScanner2SidedSetting(this.scanInfo.getTwoSidedScanningName(), this.scanInfo.getSupportedAdfDuplex());
+                        this.scanInfo.setSizeValue(Constants.PaperName.EPS_MSID_UNKNOWN.getCode());
+                        this.tvScannerSize.setText(getString(ScanSizeHelper.getScanSizeName(this.scanInfo.getSizeValue())));
+                        break;
+                    case 5:
+                        this.scanInfo.setColorValue(extras.getInt(epson.common.Constants.SCAN_REFS_SETTINGS_COLOR));
+                        this.tvScannerColor.setText(getString(this.scanInfo.getColorName()));
+                        break;
+                    case 6:
+                        this.scanInfo.setResolutionValue(extras.getInt(epson.common.Constants.SCAN_REFS_SETTINGS_RESOLUTION));
+                        this.tvScannerResolution.setText(this.scanInfo.getResolutionName(this));
+                        break;
+                    case 7:
+                        this.scanInfo.setTwoSidedScanningValue(extras.getInt(epson.common.Constants.SCAN_REFS_SETTINGS_2SIDED));
+                        String string = extras.getString(epson.common.Constants.SCAN_REFS_SETTINGS_2SIDED_NAME);
+                        int i3 = C2135R.string.str_yes;
+                        if (!string.equals(getString(C2135R.string.str_yes))) {
+                            i3 = C2135R.string.str_no;
+                        }
+                        this.tvScanner2Sided.setText(i3);
+                        ScannerInfo scannerInfo = this.scanInfo;
+                        if (extras.getInt(epson.common.Constants.SCAN_REFS_SETTINGS_ROTATE) == 1) {
+                            z = true;
+                        }
+                        scannerInfo.setAdfDuplexRotaitonYes(z);
+                        if (this.scanInfo.getTwoSidedScanningValue() == 1) {
+                            this.scanInfo.setSourceValue(1);
+                            this.tvScannerSource.setText(getString(this.scanInfo.getSourceName()));
+                        }
+                        this.scanInfo.setSizeValue(Constants.PaperName.EPS_MSID_UNKNOWN.getCode());
+                        this.tvScannerSize.setText(getString(ScanSizeHelper.getScanSizeName(this.scanInfo.getSizeValue())));
+                        break;
+                    case 8:
+                        this.scanInfo.setDensityValue(ScanSettingsAdvanceDensityActivity.getDensityFromReturnIntent(intent));
+                        this.scanInfo.setDensityStatus(ScanSettingsAdvanceDensityActivity.getChangeAble(intent));
+                        this.tvScannerDensity.setText(String.valueOf(255 - this.scanInfo.getDensityValue()));
+                        break;
+                    case 9:
+                        this.scanInfo.setGammaValue(extras.getInt(epson.common.Constants.SCAN_REFS_SETTINGS_GAMMA));
+                        String string2 = extras.getString(epson.common.Constants.SCAN_REFS_SETTINGS_GAMMA_NAME);
+                        int i4 = C2135R.string.str_settings_gamma_10;
+                        if (!string2.equals(getString(C2135R.string.str_settings_gamma_10))) {
+                            i4 = C2135R.string.str_settings_gamma_18;
+                        }
+                        this.tvScannerGamma.setText(i4);
+                        break;
+                    case 11:
+                        this.scanInfo.setSizeValue(extras.getInt(epson.common.Constants.SCAN_REFS_SCANNER_CHOSEN_SIZE));
+                        this.tvScannerSize.setText(getString(ScanSizeHelper.getScanSizeName(this.scanInfo.getSizeValue())));
+                        break;
+                }
+            }
+            EPLog.m313i(getLocalClassName(), "back to settings");
+        } else if (i2 == 1) {
+            onScannerSelectResult(-1, intent);
+        } else {
+            setResult(i2, intent);
+            finish();
+        }
+    }
+
+    private void onScannerSelectResult(int i, Intent intent) {
+        if (i == -1) {
+            ScannerPropertyWrapper scannerPropertyWrapper = SettingActivityParams.getScannerPropertyWrapper(intent);
+            if (scannerPropertyWrapper != null) {
+                if (scannerPropertyWrapper.getEscIVersion() != 2) {
+                    ScannerInfo i1ScannerInfo = scannerPropertyWrapper.getI1ScannerInfo();
+                    if (i1ScannerInfo != null) {
+                        updateSelectedScannerInfo(i1ScannerInfo, scannerPropertyWrapper.getSimpleApSsid());
+                    }
+                } else if (SettingActivityParams.returnIfEscIVersionChanged(getIntent())) {
+                    setResult(1, SettingActivityParams.getSettingReturnIntent(scannerPropertyWrapper));
+                    finish();
+                } else {
+                    startActivityForResult(SettingActivityParams.getChangeSettingActivityStartIntent(this, scannerPropertyWrapper, true, this.mHideColorMode, this.mHideResolution, this.mExternalIntentData), 100);
+                }
+            }
+        } else {
+            updateIpAddressPrinter();
+        }
+    }
+
+    private void updateIpAddressPrinter() {
+        if (this.scanInfo.getLocation() == 3 && !new EPPrinterManager(this).doseContainScannerIdInIpPrinterList(this.scanInfo.getScannerId())) {
+            resetSettings();
+        }
+    }
+
+    private void updateSelectedScannerInfo(ScannerInfo scannerInfo, String str) {
+        this.isNeedSaveSupportedOptions = true;
+        this.scanInfo.setScannerId(scannerInfo.getScannerId());
+        this.scanInfo.setIp(scannerInfo.getIp());
+        this.scanInfo.setLocation(scannerInfo.getLocation());
+        this.scanInfo.setModelName(scannerInfo.getModelName());
+        this.autoConnectSsid = str;
+        displayScannerName();
+        updatePrinterIcon();
+        this.scanInfo.setSupportedOptions(new int[7]);
+        this.scanInfo.setSupportedResolutionList(new int[64]);
+        ScanSettingHelper.updateNewSelectedScannerSupportedOptions(this.scanInfo);
+        setBlankSettings();
+        this.scanInfo.setSupportedOptions(scannerInfo.getSupportedOptions());
+        this.scanInfo.setSupportedResolutionList(scannerInfo.getSupportedResolutionList());
+        ScanSettingHelper.updateNewSelectedScannerSupportedOptions(this.scanInfo);
+        ScanSettingHelper.setDefaultSettings3(ScanCommonParams.load(this), this.scanInfo);
+        showNewSelectedScannerInfo();
+        if (!this.scanInfo.getIp().equals("")) {
+            setResolutionClickable();
+            setColorModeClickable();
+            this.llScanSettingsDensity.setClickable(true);
+            this.llScanSettingsGamma.setClickable(true);
+        }
+    }
+
+    private void setBlankSettings() {
+        this.scanInfo.setSourceValue(0);
+        this.scanInfo.setSupportedAdfHeight(0);
+        this.scanInfo.setSupportedAdfWidth(0);
+        this.scanInfo.setSupportedAdfDuplex(0);
+        this.scanInfo.setTwoSidedScanningValue(0);
+        this.scanInfo.setResolutionValue(150);
+        this.scanInfo.setSizeValue(Constants.PaperName.EPS_MSID_UNKNOWN.getCode());
+        this.scanInfo.setColorValue(1);
+        this.scanInfo.setDensityStatus(false);
+        this.scanInfo.setDensityValue(128);
+        this.scanInfo.setGammaValue(1);
+        this.llScanSettingsResolution.setClickable(false);
+        this.llScanSettingsColor.setClickable(false);
+        this.llScanSettingsDensity.setClickable(false);
+        this.llScanSettingsGamma.setClickable(false);
+    }
+
+    private void showNewSelectedScannerInfo() {
+        displayNewDocumentSourceSetting();
+        this.tvScannerSize.setText(getString(ScanSizeHelper.getScanSizeName(this.scanInfo.getSizeValue())));
+        this.tvScannerColor.setText(getString(this.scanInfo.getColorName()));
+        this.tvScannerResolution.setText(this.scanInfo.getResolutionName(this));
+        this.tvScannerDensity.setText(String.valueOf(255 - this.scanInfo.getDensityValue()));
+        this.tvScannerGamma.setText(this.scanInfo.getGammaName());
+    }
+
+    private void displayNewDocumentSourceSetting() {
+        if (this.scanInfo.getSupportedAdfHeight() == 0 && this.scanInfo.getSupportedAdfWidth() == 0) {
+            this.llScanSettingsSource.setVisibility(8);
+            this.viewScanSettingsSource.setVisibility(8);
+        } else {
+            this.llScanSettingsSource.setVisibility(0);
+            this.viewScanSettingsSource.setVisibility(0);
+            this.tvScannerSource.setText(getString(this.scanInfo.getSourceName()));
+        }
+        updateScanner2SidedSetting(this.scanInfo.getTwoSidedScanningName(), this.scanInfo.getSupportedAdfDuplex());
+    }
+
+    private void updateScanner2SidedSetting(int i, int i2) {
+        this.tvScanner2Sided.setText(i);
+        if (i2 != 1) {
+            this.llScanSettingsAdvance2Sided.setVisibility(8);
+            this.viewScanSettingsAdvance2Sided.setVisibility(8);
+            return;
+        }
+        this.llScanSettingsAdvance2Sided.setVisibility(0);
+        this.viewScanSettingsAdvance2Sided.setVisibility(0);
+    }
+
+    private void setResolutionClickable() {
+        if (!this.mHideResolution) {
+            this.llScanSettingsResolution.setClickable(true);
+        }
+    }
+
+    private void setColorModeClickable() {
+        if (!this.mHideColorMode) {
+            this.llScanSettingsColor.setClickable(true);
+        }
+    }
+
+    public void onBackPressed() {
+        new EPPrinterManager(this).rollbackIPPrinterInfo();
+        setResult(0);
+        finish();
+    }
+
+    private void onSettingDone() {
+        if (this.progressGetOption.getVisibility() == 8) {
+            if (!this.scanInfo.isReSearch() && !this.scanInfo.getIp().equals("")) {
+                this.scanInfo.setReSearch(true);
+            }
+            if (this.isNeedSaveSupportedOptions) {
+                ScanSettingHelper.saveSupportedOptionToRef(this.context, this.scanInfo);
+                String str = this.autoConnectSsid;
+                if (str == null || str.length() <= 0) {
+                    WiFiDirectManager.resetConnectInfo(this, WiFiDirectManager.DEVICE_TYPE_SCANNER);
+                } else {
+                    WiFiDirectManager.setConnectInfo(this, this.autoConnectSsid, WiFiDirectManager.DEVICE_TYPE_SCANNER, this.scanInfo.getModelName());
+                }
+            }
+            boolean z = false;
+            this.isNeedSaveSupportedOptions = false;
+            if (this.scanInfo.getModelName().equals(this.siOrigin.getModelName()) && this.scanInfo.getSourceValue() == this.siOrigin.getSourceValue() && this.scanInfo.getColorValue() == this.siOrigin.getColorValue() && this.scanInfo.getResolutionValue() == this.siOrigin.getResolutionValue() && this.scanInfo.getTwoSidedScanningValue() == this.siOrigin.getTwoSidedScanningValue() && this.scanInfo.isAdfDuplexRotaitonYes() == this.siOrigin.isAdfDuplexRotaitonYes() && this.scanInfo.getAdfPaperGuide() == this.siOrigin.getAdfPaperGuide() && this.scanInfo.getDensityValue() == this.siOrigin.getDensityValue() && this.scanInfo.getGammaValue() == this.siOrigin.getGammaValue()) {
+                z = true;
+            }
+            ScanInfoStorage.saveEscIVersion(this, 1);
+            ScanSettingHelper.saveAllUserSettingsToRef(this.context, this.scanInfo);
+            backToScanScreen(z);
+        }
+    }
+
+    private void backToScanScreen(boolean z) {
+        new EPPrinterManager(this).commitIPPrinterInfo();
+        Intent intent = getIntent();
+        intent.putExtra(epson.common.Constants.ACT_RESULT, epson.common.Constants.ACT_RESULT_SAVE);
+        intent.putExtra(IS_NEW_SAVE, true);
+        intent.putExtra(NO_CLEAR_RESULT, z);
+        setResult(-1, intent);
+        finish();
+    }
+
+    /* access modifiers changed from: protected */
+    public void onStop() {
+        super.onStop();
+        EPLog.m313i(getLocalClassName(), "scannsetting screen, onStop");
+        this.progressGetOption.setVisibility(8);
+        AlertDialog alertDialog = this.errorDialog;
+        if (alertDialog != null && alertDialog.isShowing()) {
+            this.errorDialog.dismiss();
+        }
+    }
+
+    private void resetSettings() {
+        this.scanInfo.setScannerId("");
+        this.scanInfo.setIp("");
+        this.scanInfo.setModelName("");
+        this.scanInfo.setLocation(1);
+        this.autoConnectSsid = "";
+        setBlankSettings();
+        showNewSelectedScannerInfo();
+        displayScannerName();
+        updatePrinterIcon();
+    }
+
+    public boolean onCreateOptionsMenu(Menu menu) {
+        getMenuInflater().inflate(C2135R.C2138menu.menu_done, menu);
+        return super.onCreateOptionsMenu(menu);
+    }
+
+    public boolean onOptionsItemSelected(MenuItem menuItem) {
+        if (menuItem.getItemId() != C2135R.C2137id.menuSettingsDone) {
+            return super.onOptionsItemSelected(menuItem);
+        }
+        onSettingDone();
+        return true;
+    }
+}

+ 110 - 0
app/src/main/java/epson/scan/activity/ScanSettingsAdvanceDensityActivity.java

@@ -0,0 +1,110 @@
+package epson.scan.activity;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.view.View;
+import android.widget.SeekBar;
+import android.widget.Switch;
+import android.widget.TextView;
+import epson.common.Constants;
+import epson.print.ActivityIACommon;
+import epson.print.C2135R;
+
+public class ScanSettingsAdvanceDensityActivity extends ActivityIACommon {
+    private static final int DEFAULT_DENSITY = 128;
+    private static final String PARAM_KEY_DENSITY = "SCAN_SETTINGS_LAST_DENSITY";
+    private static final String PARAM_KEY_DENSITY_STATUS = "SCAN_SETTINGS_LAST_DENSITY_STATUS";
+    /* access modifiers changed from: private */
+    public boolean densityStatus;
+    /* access modifiers changed from: private */
+    public int densityValue;
+    private SeekBar.OnSeekBarChangeListener mSeekDensityChangeListener = new SeekBar.OnSeekBarChangeListener() {
+        public void onStartTrackingTouch(SeekBar seekBar) {
+        }
+
+        public void onStopTrackingTouch(SeekBar seekBar) {
+        }
+
+        public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
+            int unused = ScanSettingsAdvanceDensityActivity.this.densityValue = 255 - i;
+            ScanSettingsAdvanceDensityActivity.this.tvDensityValue.setText(String.format(Constants.DENSITY_VALUE, new Object[]{Integer.valueOf(255 - ScanSettingsAdvanceDensityActivity.this.densityValue)}));
+        }
+    };
+    private View.OnClickListener mToogleDensityListener = new View.OnClickListener() {
+        public void onClick(View view) {
+            ScanSettingsAdvanceDensityActivity scanSettingsAdvanceDensityActivity = ScanSettingsAdvanceDensityActivity.this;
+            boolean unused = scanSettingsAdvanceDensityActivity.densityStatus = scanSettingsAdvanceDensityActivity.toggleDensity.isChecked();
+            if (!ScanSettingsAdvanceDensityActivity.this.densityStatus) {
+                ScanSettingsAdvanceDensityActivity.this.seekDensity.setProgress(127);
+                ScanSettingsAdvanceDensityActivity.this.seekDensity.setEnabled(false);
+                return;
+            }
+            ScanSettingsAdvanceDensityActivity.this.seekDensity.setEnabled(true);
+        }
+    };
+    /* access modifiers changed from: private */
+    public SeekBar seekDensity;
+    /* access modifiers changed from: private */
+    public Switch toggleDensity;
+    /* access modifiers changed from: private */
+    public TextView tvDensityValue;
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        setContentView((int) C2135R.layout.scan_settings_advance_density);
+        setActionBar((int) C2135R.string.brightness, true);
+        Bundle extras = getIntent().getExtras();
+        extras.getInt(Constants.SCAN_SETTINGS_DETAIL_TITLE);
+        this.densityValue = extras.getInt(PARAM_KEY_DENSITY);
+        this.densityStatus = extras.getBoolean(PARAM_KEY_DENSITY_STATUS);
+        this.seekDensity = (SeekBar) findViewById(C2135R.C2137id.seekDensity);
+        this.seekDensity.setProgress(this.densityValue);
+        this.seekDensity.setOnSeekBarChangeListener(this.mSeekDensityChangeListener);
+        this.tvDensityValue = (TextView) findViewById(C2135R.C2137id.tvDensityValue);
+        this.tvDensityValue.setText(String.format(Constants.DENSITY_VALUE, new Object[]{String.valueOf(255 - this.densityValue)}));
+        this.seekDensity.setProgress(255 - this.densityValue);
+        this.toggleDensity = (Switch) findViewById(C2135R.C2137id.toggleDensity);
+        this.toggleDensity.setChecked(this.densityStatus);
+        this.toggleDensity.setOnClickListener(this.mToogleDensityListener);
+        if (!this.toggleDensity.isChecked()) {
+            this.seekDensity.setEnabled(false);
+        } else {
+            this.seekDensity.setEnabled(true);
+        }
+    }
+
+    public void onBackPressed() {
+        Intent intent = getIntent();
+        intent.putExtra(PARAM_KEY_DENSITY, this.densityValue);
+        intent.putExtra(PARAM_KEY_DENSITY_STATUS, this.densityStatus);
+        setResult(-1, intent);
+        finish();
+        super.onBackPressed();
+    }
+
+    @NonNull
+    public static Intent getStartIntent(@NonNull Context context, int i, boolean z) {
+        Intent intent = new Intent(context, ScanSettingsAdvanceDensityActivity.class);
+        intent.putExtra(PARAM_KEY_DENSITY, i);
+        intent.putExtra(PARAM_KEY_DENSITY_STATUS, z);
+        return intent;
+    }
+
+    public static int getDensityFromReturnIntent(@Nullable Intent intent) {
+        if (intent == null) {
+            return 128;
+        }
+        return intent.getIntExtra(PARAM_KEY_DENSITY, 128);
+    }
+
+    public static boolean getChangeAble(@Nullable Intent intent) {
+        if (intent == null) {
+            return false;
+        }
+        return intent.getBooleanExtra(PARAM_KEY_DENSITY_STATUS, false);
+    }
+}

+ 165 - 0
app/src/main/java/epson/scan/activity/ScanSettingsAdvanceDetailActivity.java

@@ -0,0 +1,165 @@
+package epson.scan.activity;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ListView;
+import epson.common.Constants;
+import epson.common.CustomListRow;
+import epson.common.CustomListRowAdapter;
+import epson.common.CustomListRowImpl;
+import epson.print.ActivityIACommon;
+import epson.print.C2135R;
+import epson.print.Util.EPLog;
+import epson.scan.activity.ScanSettingsDetailAdapter;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+public class ScanSettingsAdvanceDetailActivity extends ActivityIACommon {
+    private static final String SCAN_SETTINGS_LAST_VALUE = "SCAN_SETTINGS_LAST_VALUE";
+    private List<CustomListRow> items;
+    /* access modifiers changed from: private */
+    public int lastAdfRotate;
+    /* access modifiers changed from: private */
+    public int lastValue;
+    private LinkedHashMap<String, Integer> lhmListOptionValue;
+    private ListView listSelect;
+    /* access modifiers changed from: private */
+    public ListView listSelect2;
+    private AdapterView.OnItemClickListener mListOptionClick = new AdapterView.OnItemClickListener() {
+        public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
+            if (view.getTag() instanceof ScanSettingsDetailAdapter.DetailSettingHolder) {
+                ScanSettingsDetailAdapter.DetailSettingHolder detailSettingHolder = (ScanSettingsDetailAdapter.DetailSettingHolder) view.getTag();
+                Intent intent = ScanSettingsAdvanceDetailActivity.this.getIntent();
+                int access$000 = ScanSettingsAdvanceDetailActivity.this.screenId;
+                if (access$000 == C2135R.string.str_settings_2sided_title) {
+                    int unused = ScanSettingsAdvanceDetailActivity.this.lastValue = detailSettingHolder.value;
+                    String unused2 = ScanSettingsAdvanceDetailActivity.this.strSelText = detailSettingHolder.text.getText().toString();
+                    ScanSettingsAdvanceDetailActivity.this.ssdAdapter.setSelected(ScanSettingsAdvanceDetailActivity.this.lastValue);
+                    ScanSettingsAdvanceDetailActivity.this.ssdAdapter.notifyDataSetChanged();
+                    if (ScanSettingsAdvanceDetailActivity.this.lastValue == 1) {
+                        ScanSettingsAdvanceDetailActivity.this.listSelect2.setVisibility(0);
+                    } else {
+                        ScanSettingsAdvanceDetailActivity.this.listSelect2.setVisibility(8);
+                    }
+                } else if (access$000 == C2135R.string.str_settings_gamma_title) {
+                    intent.putExtra(Constants.SCAN_REFS_SETTINGS_GAMMA, detailSettingHolder.value);
+                    intent.putExtra(Constants.SCAN_REFS_SETTINGS_GAMMA_NAME, detailSettingHolder.text.getText().toString());
+                    ScanSettingsAdvanceDetailActivity.this.setResult(-1, intent);
+                    ScanSettingsAdvanceDetailActivity.this.finish();
+                }
+            }
+        }
+    };
+    private AdapterView.OnItemClickListener mListOptionClick2 = new AdapterView.OnItemClickListener() {
+        public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
+            EPLog.m313i("mListOptionClick2", "[position]" + i);
+            EPLog.m313i("mListOptionClick2", "[id]" + j);
+            int unused = ScanSettingsAdvanceDetailActivity.this.lastAdfRotate = i;
+            switch (i) {
+                case 0:
+                    ScanSettingsAdvanceDetailActivity.this.mlAdapter.setList(0, CustomListRowImpl.create().addText("").prefixImage(Integer.valueOf(C2135R.C2136drawable.scan_counter_direction)).suffixImage(Integer.valueOf(C2135R.C2136drawable.selected)));
+                    ScanSettingsAdvanceDetailActivity.this.mlAdapter.setList(1, CustomListRowImpl.create().addText("").prefixImage(Integer.valueOf(C2135R.C2136drawable.scan_same_direction)));
+                    break;
+                case 1:
+                    ScanSettingsAdvanceDetailActivity.this.mlAdapter.setList(0, CustomListRowImpl.create().addText("").prefixImage(Integer.valueOf(C2135R.C2136drawable.scan_counter_direction)));
+                    ScanSettingsAdvanceDetailActivity.this.mlAdapter.setList(1, CustomListRowImpl.create().addText("").prefixImage(Integer.valueOf(C2135R.C2136drawable.scan_same_direction)).suffixImage(Integer.valueOf(C2135R.C2136drawable.selected)));
+                    break;
+            }
+            ScanSettingsAdvanceDetailActivity.this.mlAdapter.notifyDataSetChanged();
+        }
+    };
+    /* access modifiers changed from: private */
+    public CustomListRowAdapter mlAdapter;
+    /* access modifiers changed from: private */
+    public int screenId;
+    private String screenTitle;
+    /* access modifiers changed from: private */
+    public ScanSettingsDetailAdapter ssdAdapter;
+    /* access modifiers changed from: private */
+    public String strSelText;
+    private int supportedAdfDuplex;
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        setContentView((int) C2135R.layout.scan_settings_detail_2);
+        Bundle extras = getIntent().getExtras();
+        this.screenId = extras.getInt(Constants.SCAN_SETTINGS_DETAIL_TITLE);
+        this.lastValue = extras.getInt(SCAN_SETTINGS_LAST_VALUE);
+        this.supportedAdfDuplex = extras.getInt(Constants.SCAN_REFS_OPTIONS_SUPPORTED_ADF_DUPLEX);
+        this.lastAdfRotate = extras.getInt(Constants.SCAN_REFS_SETTINGS_ROTATE);
+        this.listSelect = (ListView) findViewById(C2135R.C2137id.lvScannerSettingOptions);
+        this.listSelect2 = (ListView) findViewById(C2135R.C2137id.lvScannerSettingOptions2);
+        getListCorespondenceOptions(this.screenId);
+        setListCorespondenceOptions(this.screenId);
+        setActionBar(getTitle().toString(), true);
+    }
+
+    private void getListCorespondenceOptions(int i) {
+        this.items = new ArrayList();
+        this.lhmListOptionValue = new LinkedHashMap<>();
+        if (i == C2135R.string.str_settings_2sided_title) {
+            this.screenTitle = getString(C2135R.string.str_settings_2sided_title);
+            if (this.supportedAdfDuplex == 1) {
+                this.lhmListOptionValue.put(getString(C2135R.string.str_yes), 1);
+            }
+            this.lhmListOptionValue.put(getString(C2135R.string.str_no), 0);
+            switch (this.lastAdfRotate) {
+                case 0:
+                    this.items.add(CustomListRowImpl.create().addText(" ").prefixImage(Integer.valueOf(C2135R.C2136drawable.scan_counter_direction)).suffixImage(Integer.valueOf(C2135R.C2136drawable.selected)));
+                    this.items.add(CustomListRowImpl.create().addText("").prefixImage(Integer.valueOf(C2135R.C2136drawable.scan_same_direction)));
+                    return;
+                case 1:
+                    this.items.add(CustomListRowImpl.create().addText(" ").prefixImage(Integer.valueOf(C2135R.C2136drawable.scan_counter_direction)));
+                    this.items.add(CustomListRowImpl.create().addText("").prefixImage(Integer.valueOf(C2135R.C2136drawable.scan_same_direction)).suffixImage(Integer.valueOf(C2135R.C2136drawable.selected)));
+                    return;
+                default:
+                    return;
+            }
+        } else if (i == C2135R.string.str_settings_gamma_title) {
+            this.screenTitle = getString(C2135R.string.str_settings_gamma_title);
+            this.lhmListOptionValue.put(getString(C2135R.string.str_settings_gamma_10), 0);
+            this.lhmListOptionValue.put(getString(C2135R.string.str_settings_gamma_18), 1);
+        }
+    }
+
+    private void setListCorespondenceOptions(int i) {
+        setTitle(this.screenTitle);
+        if (i == C2135R.string.str_settings_2sided_title) {
+            this.mlAdapter = new CustomListRowAdapter(this, C2135R.layout.com_customline_row, this.items);
+            this.listSelect2.setAdapter(this.mlAdapter);
+            this.listSelect2.setOnItemClickListener(this.mListOptionClick2);
+            if (this.lastValue == 1) {
+                this.listSelect2.setVisibility(0);
+            } else {
+                this.listSelect2.setVisibility(8);
+            }
+        }
+        this.ssdAdapter = new ScanSettingsDetailAdapter(getBaseContext(), this.lhmListOptionValue, this.lastValue);
+        this.listSelect.setAdapter(this.ssdAdapter);
+        this.listSelect.setOnItemClickListener(this.mListOptionClick);
+    }
+
+    public void onBackPressed() {
+        Intent intent = getIntent();
+        int i = this.screenId;
+        if (i == C2135R.string.str_settings_2sided_title) {
+            if (this.lastValue == 1) {
+                this.strSelText = getString(C2135R.string.str_yes);
+            } else {
+                this.strSelText = getString(C2135R.string.str_no);
+            }
+            intent.putExtra(Constants.SCAN_REFS_SETTINGS_2SIDED, this.lastValue);
+            intent.putExtra(Constants.SCAN_REFS_SETTINGS_2SIDED_NAME, this.strSelText);
+            intent.putExtra(Constants.SCAN_REFS_SETTINGS_ROTATE, this.lastAdfRotate);
+            setResult(-1, intent);
+        } else if (i == C2135R.string.str_settings_gamma_title) {
+            setResult(0, intent);
+        }
+        finish();
+        super.onBackPressed();
+    }
+}

+ 223 - 0
app/src/main/java/epson/scan/activity/ScanSettingsDetailActivity.java

@@ -0,0 +1,223 @@
+package epson.scan.activity;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ListView;
+import epson.common.Constants;
+import epson.common.CustomListRow;
+import epson.common.CustomListRowAdapter;
+import epson.common.CustomListRowImpl;
+import epson.print.ActivityIACommon;
+import epson.print.C2135R;
+import epson.print.Util.EPLog;
+import epson.scan.activity.ScanSettingsDetailAdapter;
+import epson.scan.lib.ScanSizeHelper;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+public class ScanSettingsDetailActivity extends ActivityIACommon {
+    private static final String SCAN_SETTINGS_LAST_VALUE = "SCAN_SETTINGS_LAST_VALUE";
+    private static final String SCAN_SUPPORTED_RESOLUTION_LIST = "SCAN_SUPPORTED_RESOLUTION_LIST";
+    private static final String SCAN_SUPPORTED_SIZE_LIST = "SCAN_SUPPORTED_SIZE_LIST";
+    int adfHeight;
+    int adfWidth;
+    Context context;
+    private List<CustomListRow> items;
+    /* access modifiers changed from: private */
+    public int lastAdfGuid;
+    int lastValue;
+    LinkedHashMap<String, Integer> lhmListOptionValue;
+    int[] listResolution;
+    private ListView listSelect;
+    /* access modifiers changed from: private */
+    public ListView listSelect2;
+    int[] listSize;
+    private AdapterView.OnItemClickListener mListOptionClick = new AdapterView.OnItemClickListener() {
+        public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
+            if (view.getTag() instanceof ScanSettingsDetailAdapter.DetailSettingHolder) {
+                ScanSettingsDetailAdapter.DetailSettingHolder detailSettingHolder = (ScanSettingsDetailAdapter.DetailSettingHolder) view.getTag();
+                if (ScanSettingsDetailActivity.this.screenId == C2135R.string.str_settings_source_title) {
+                    ScanSettingsDetailActivity.this.lastValue = detailSettingHolder.value;
+                    String unused = ScanSettingsDetailActivity.this.strSelText = detailSettingHolder.text.getText().toString();
+                    ScanSettingsDetailActivity.this.ssdAdapter.setSelected(ScanSettingsDetailActivity.this.lastValue);
+                    ScanSettingsDetailActivity.this.ssdAdapter.notifyDataSetChanged();
+                    if (ScanSettingsDetailActivity.this.lastValue == 1) {
+                        ScanSettingsDetailActivity.this.listSelect2.setVisibility(0);
+                    } else {
+                        ScanSettingsDetailActivity.this.listSelect2.setVisibility(8);
+                    }
+                } else {
+                    Intent intent = ScanSettingsDetailActivity.this.getIntent();
+                    int i2 = ScanSettingsDetailActivity.this.screenId;
+                    if (i2 != C2135R.string.str_advance_setting) {
+                        if (i2 == C2135R.string.str_scanning_size) {
+                            intent.putExtra(Constants.SCAN_REFS_SCANNER_CHOSEN_SIZE, detailSettingHolder.value);
+                        } else if (i2 != C2135R.string.str_settings_color_title) {
+                            if (i2 == C2135R.string.str_settings_resolution_title) {
+                                intent.putExtra(Constants.SCAN_REFS_SETTINGS_RESOLUTION, detailSettingHolder.value);
+                                intent.putExtra(Constants.SCAN_REFS_SETTINGS_RESOLUTION_NAME, detailSettingHolder.text.getText().toString());
+                            }
+                        }
+                        intent.putExtra(Constants.SCAN_REFS_SETTINGS_COLOR, detailSettingHolder.value);
+                        intent.putExtra(Constants.SCAN_REFS_SETTINGS_COLOR_NAME, detailSettingHolder.text.getText().toString());
+                    }
+                    ScanSettingsDetailActivity.this.setResult(-1, intent);
+                    ScanSettingsDetailActivity.this.finish();
+                }
+            }
+        }
+    };
+    private AdapterView.OnItemClickListener mListOptionClick2 = new AdapterView.OnItemClickListener() {
+        public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
+            EPLog.m313i("mListOptionClick2", "[position]" + i);
+            EPLog.m313i("mListOptionClick2", "[id]" + j);
+            int unused = ScanSettingsDetailActivity.this.lastAdfGuid = i;
+            switch (i) {
+                case 0:
+                    ScanSettingsDetailActivity.this.mlAdapter.setList(0, CustomListRowImpl.create().addText(ScanSettingsDetailActivity.this.getString(C2135R.string.str_settings_right_aligned)).prefixImage(Integer.valueOf(C2135R.C2136drawable.adf_left_adst)).suffixImage(Integer.valueOf(C2135R.C2136drawable.selected)));
+                    ScanSettingsDetailActivity.this.mlAdapter.setList(1, CustomListRowImpl.create().addText(ScanSettingsDetailActivity.this.getString(C2135R.string.str_settings_center_aligned)).prefixImage(Integer.valueOf(C2135R.C2136drawable.adf_center_adst)));
+                    break;
+                case 1:
+                    ScanSettingsDetailActivity.this.mlAdapter.setList(0, CustomListRowImpl.create().addText(ScanSettingsDetailActivity.this.getString(C2135R.string.str_settings_right_aligned)).prefixImage(Integer.valueOf(C2135R.C2136drawable.adf_left_adst)));
+                    ScanSettingsDetailActivity.this.mlAdapter.setList(1, CustomListRowImpl.create().addText(ScanSettingsDetailActivity.this.getString(C2135R.string.str_settings_center_aligned)).prefixImage(Integer.valueOf(C2135R.C2136drawable.adf_center_adst)).suffixImage(Integer.valueOf(C2135R.C2136drawable.selected)));
+                    break;
+            }
+            ScanSettingsDetailActivity.this.mlAdapter.notifyDataSetChanged();
+        }
+    };
+    /* access modifiers changed from: private */
+    public CustomListRowAdapter mlAdapter;
+    int screenId;
+    String screenTitle;
+    /* access modifiers changed from: private */
+    public ScanSettingsDetailAdapter ssdAdapter;
+    /* access modifiers changed from: private */
+    public String strSelText;
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        setContentView((int) C2135R.layout.scan_settings_detail_2);
+        Bundle extras = getIntent().getExtras();
+        this.screenId = extras.getInt(Constants.SCAN_SETTINGS_DETAIL_TITLE);
+        this.lastValue = extras.getInt(SCAN_SETTINGS_LAST_VALUE);
+        this.adfWidth = extras.getInt(Constants.SCAN_REFS_OPTIONS_ADF_WIDTH);
+        this.adfHeight = extras.getInt(Constants.SCAN_REFS_OPTIONS_ADF_HEIGHT);
+        this.listResolution = extras.getIntArray(SCAN_SUPPORTED_RESOLUTION_LIST);
+        this.listSize = extras.getIntArray(SCAN_SUPPORTED_SIZE_LIST);
+        this.lastAdfGuid = extras.getInt(Constants.SCAN_REFS_SETTINGS_ADF_PAPER_GUIDE);
+        this.listSelect = (ListView) findViewById(C2135R.C2137id.lvScannerSettingOptions);
+        this.listSelect2 = (ListView) findViewById(C2135R.C2137id.lvScannerSettingOptions2);
+        this.context = this;
+        makeListCorespondenceOptions(this.screenId);
+        setListCorespondenceOptions(this.screenId);
+        setActionBar(getTitle().toString(), true);
+    }
+
+    private void makeListCorespondenceOptions(int i) {
+        this.items = new ArrayList();
+        this.lhmListOptionValue = new LinkedHashMap<>();
+        switch (i) {
+            case C2135R.string.str_advance_setting /*2131625070*/:
+                this.screenTitle = getString(C2135R.string.str_advance_setting);
+                return;
+            case C2135R.string.str_scanning_size /*2131625215*/:
+                this.screenTitle = getString(C2135R.string.str_scanning_size);
+                for (int i2 : this.listSize) {
+                    this.lhmListOptionValue.put(getString(ScanSizeHelper.getScanSizeName(i2)), Integer.valueOf(i2));
+                }
+                return;
+            case C2135R.string.str_settings_color_title /*2131625225*/:
+                this.screenTitle = getString(C2135R.string.str_settings_color_title);
+                this.lhmListOptionValue.put(getString(C2135R.string.str_settings_color_color), 1);
+                this.lhmListOptionValue.put(getString(C2135R.string.str_settings_color_grayscale), 2);
+                this.lhmListOptionValue.put(getString(C2135R.string.str_settings_color_monochrome), 3);
+                return;
+            case C2135R.string.str_settings_resolution_title /*2131625231*/:
+                this.screenTitle = getString(C2135R.string.str_settings_resolution_title);
+                int i3 = 0;
+                while (true) {
+                    int[] iArr = this.listResolution;
+                    if (i3 < iArr.length) {
+                        int i4 = iArr[i3];
+                        if (i4 == 75 || i4 == 150 || i4 == 300) {
+                            this.lhmListOptionValue.put(String.format(getString(C2135R.string.str_settings_resolution), new Object[]{Integer.valueOf(this.listResolution[i3])}), Integer.valueOf(this.listResolution[i3]));
+                        }
+                        i3++;
+                    } else {
+                        return;
+                    }
+                }
+                break;
+            case C2135R.string.str_settings_source_title /*2131625235*/:
+                this.screenTitle = getString(C2135R.string.str_settings_source_title);
+                this.lhmListOptionValue.put(getString(C2135R.string.str_settings_source_doctable), 0);
+                if (this.adfWidth > 0 && this.adfHeight > 0) {
+                    this.lhmListOptionValue.put(getString(C2135R.string.str_settings_source_adf), 1);
+                }
+                switch (this.lastAdfGuid) {
+                    case 0:
+                        this.items.add(CustomListRowImpl.create().addText(getString(C2135R.string.str_settings_right_aligned)).prefixImage(Integer.valueOf(C2135R.C2136drawable.adf_left_adst)).suffixImage(Integer.valueOf(C2135R.C2136drawable.selected)));
+                        this.items.add(CustomListRowImpl.create().addText(getString(C2135R.string.str_settings_center_aligned)).prefixImage(Integer.valueOf(C2135R.C2136drawable.adf_center_adst)));
+                        return;
+                    case 1:
+                        this.items.add(CustomListRowImpl.create().addText(getString(C2135R.string.str_settings_right_aligned)).prefixImage(Integer.valueOf(C2135R.C2136drawable.adf_left_adst)));
+                        this.items.add(CustomListRowImpl.create().addText(getString(C2135R.string.str_settings_center_aligned)).prefixImage(Integer.valueOf(C2135R.C2136drawable.adf_center_adst)).suffixImage(Integer.valueOf(C2135R.C2136drawable.selected)));
+                        return;
+                    default:
+                        return;
+                }
+            default:
+                return;
+        }
+    }
+
+    private void setListCorespondenceOptions(int i) {
+        setTitle(this.screenTitle);
+        switch (i) {
+            case C2135R.string.str_scanning_size /*2131625215*/:
+            case C2135R.string.str_settings_color_title /*2131625225*/:
+            case C2135R.string.str_settings_resolution_title /*2131625231*/:
+                break;
+            case C2135R.string.str_settings_source_title /*2131625235*/:
+                this.mlAdapter = new CustomListRowAdapter(this, C2135R.layout.com_customline_row, this.items);
+                this.listSelect2.setAdapter(this.mlAdapter);
+                this.listSelect2.setOnItemClickListener(this.mListOptionClick2);
+                if (this.lastValue != 1) {
+                    this.listSelect2.setVisibility(8);
+                    break;
+                } else {
+                    this.listSelect2.setVisibility(0);
+                    break;
+                }
+            default:
+                return;
+        }
+        this.ssdAdapter = new ScanSettingsDetailAdapter(getBaseContext(), this.lhmListOptionValue, this.lastValue);
+        this.listSelect.setAdapter(this.ssdAdapter);
+        this.listSelect.setOnItemClickListener(this.mListOptionClick);
+    }
+
+    public void onBackPressed() {
+        Intent intent = getIntent();
+        if (this.screenId != C2135R.string.str_settings_source_title) {
+            setResult(0, intent);
+        } else {
+            if (this.lastValue == 1) {
+                this.strSelText = getString(C2135R.string.str_settings_source_adf);
+            } else {
+                this.strSelText = getString(C2135R.string.str_settings_source_doctable);
+            }
+            intent.putExtra(Constants.SCAN_REFS_SETTINGS_SOURCE, this.lastValue);
+            intent.putExtra(Constants.SCAN_REFS_SETTINGS_SOURCE_NAME, this.strSelText);
+            intent.putExtra(Constants.SCAN_REFS_SETTINGS_ADF_PAPER_GUIDE, this.lastAdfGuid);
+            setResult(-1, intent);
+        }
+        finish();
+        super.onBackPressed();
+    }
+}

+ 84 - 0
app/src/main/java/epson/scan/activity/ScanSettingsDetailAdapter.java

@@ -0,0 +1,84 @@
+package epson.scan.activity;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+import epson.print.C2135R;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+
+public class ScanSettingsDetailAdapter extends BaseAdapter {
+    private LinkedHashMap<String, Integer> lhmListSettingsSupport;
+    private LayoutInflater mInflater;
+    private int selectedValue;
+
+    public long getItemId(int i) {
+        return (long) i;
+    }
+
+    public ScanSettingsDetailAdapter(Context context, LinkedHashMap<String, Integer> linkedHashMap, int i) {
+        this.mInflater = LayoutInflater.from(context);
+        this.lhmListSettingsSupport = linkedHashMap;
+        this.selectedValue = i;
+    }
+
+    public int getCount() {
+        return this.lhmListSettingsSupport.size();
+    }
+
+    public Object getItem(int i) {
+        return this.lhmListSettingsSupport.get(Integer.valueOf(i));
+    }
+
+    public void setSelected(int i) {
+        this.selectedValue = i;
+    }
+
+    public View getView(int i, View view, ViewGroup viewGroup) {
+        DetailSettingHolder detailSettingHolder;
+        if (view == null) {
+            view = this.mInflater.inflate(C2135R.layout.scan_settings_item, (ViewGroup) null);
+            detailSettingHolder = new DetailSettingHolder();
+            detailSettingHolder.text = (TextView) view.findViewById(C2135R.C2137id.tvSettingName);
+            detailSettingHolder.img = (ImageView) view.findViewById(C2135R.C2137id.ivSettingSelected);
+            detailSettingHolder.img.setBackgroundResource(C2135R.C2136drawable.selected);
+            view.setTag(detailSettingHolder);
+        } else {
+            detailSettingHolder = (DetailSettingHolder) view.getTag();
+        }
+        Iterator<String> it = this.lhmListSettingsSupport.keySet().iterator();
+        int i2 = 0;
+        while (true) {
+            if (!it.hasNext()) {
+                break;
+            }
+            String next = it.next();
+            if (i2 == i) {
+                int intValue = this.lhmListSettingsSupport.get(next).intValue();
+                detailSettingHolder.text.setText(next);
+                if (intValue == this.selectedValue) {
+                    detailSettingHolder.img.setVisibility(0);
+                } else {
+                    detailSettingHolder.img.setVisibility(4);
+                }
+                detailSettingHolder.value = intValue;
+            } else {
+                i2++;
+            }
+        }
+        return view;
+    }
+
+    static class DetailSettingHolder {
+        ImageView img;
+        TextView text;
+        int value;
+
+        DetailSettingHolder() {
+        }
+    }
+}

+ 69 - 0
app/src/main/java/epson/scan/activity/ScannerListAdapter.java

@@ -0,0 +1,69 @@
+package epson.scan.activity;
+
+import android.content.Context;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import epson.print.MyPrinter;
+import epson.print.widgets.AbstractListBuilder;
+import epson.print.widgets.PrinterInfoBuilder;
+import epson.print.widgets.PrinterInfoIpBuilder;
+import java.util.ArrayList;
+import java.util.Vector;
+
+class ScannerListAdapter {
+    public static final int TYPE_IP_ADDRESS = 2;
+    public static final int TYPE_LOCAL = 1;
+    private AbstractListBuilder mBuilder;
+    private ArrayList<Integer> mEscIVersion = new ArrayList<>();
+
+    public ScannerListAdapter(Context context, ViewGroup viewGroup, int i) {
+        switch (i) {
+            case 1:
+                this.mBuilder = new PrinterInfoIpBuilder(context, viewGroup, 1);
+                break;
+            case 2:
+                this.mBuilder = new PrinterInfoBuilder(context, viewGroup, 1);
+                break;
+        }
+        this.mEscIVersion.clear();
+    }
+
+    public void addPrinter(MyPrinter myPrinter) {
+        AbstractListBuilder abstractListBuilder = this.mBuilder;
+        if (abstractListBuilder instanceof PrinterInfoBuilder) {
+            ((PrinterInfoBuilder) abstractListBuilder).addPrinter(myPrinter);
+        }
+    }
+
+    public void addPrinter(String[] strArr) {
+        this.mBuilder.addPrinter(strArr);
+    }
+
+    public void setResource(Object obj) {
+        this.mBuilder.setResource(obj);
+    }
+
+    public BaseAdapter getAdapter() {
+        return this.mBuilder.getAdapter();
+    }
+
+    public void refresh() {
+        this.mBuilder.refresh();
+    }
+
+    public void destructor() {
+        this.mBuilder.destructor();
+    }
+
+    public void build() {
+        this.mBuilder.build();
+    }
+
+    public Vector<Object> getData() {
+        return this.mBuilder.getData();
+    }
+
+    public AbstractListBuilder getBuilder() {
+        return this.mBuilder;
+    }
+}

+ 145 - 0
app/src/main/java/epson/scan/activity/ScannerPropertyWrapper.java

@@ -0,0 +1,145 @@
+package epson.scan.activity;
+
+import android.content.Context;
+import com.epson.lib.escani2.I2LibScannerInfoAndCapability;
+import com.epson.mobilephone.common.wifidirect.MacAddrUtils;
+import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
+import epson.scan.i2lib.I2ScanParamManager;
+import epson.scan.lib.ScanInfoStorage;
+import epson.scan.lib.ScannerInfo;
+import java.io.IOException;
+import java.io.Serializable;
+
+public class ScannerPropertyWrapper implements Serializable {
+    private int mEscIVersion;
+    private I2LibScannerInfoAndCapability mI2LibScannerInfoAndCapability;
+    private ScannerInfo mScannerInfo;
+    private String mSimpleApSsid;
+
+    private ScannerPropertyWrapper() {
+        this.mEscIVersion = -1;
+        this.mScannerInfo = null;
+        this.mI2LibScannerInfoAndCapability = null;
+    }
+
+    public ScannerPropertyWrapper(ScannerInfo scannerInfo) {
+        this.mEscIVersion = 1;
+        this.mScannerInfo = scannerInfo;
+        this.mI2LibScannerInfoAndCapability = null;
+    }
+
+    public ScannerPropertyWrapper(ScannerInfo scannerInfo, I2LibScannerInfoAndCapability i2LibScannerInfoAndCapability) {
+        this.mEscIVersion = 2;
+        this.mScannerInfo = scannerInfo;
+        this.mI2LibScannerInfoAndCapability = i2LibScannerInfoAndCapability;
+    }
+
+    public String getSimpleApSsid() {
+        return this.mSimpleApSsid;
+    }
+
+    public void setSimpleApSsid(String str) {
+        this.mSimpleApSsid = str;
+    }
+
+    public int getEscIVersion() {
+        return this.mEscIVersion;
+    }
+
+    public I2LibScannerInfoAndCapability getI2ScannerAllInfo() {
+        return this.mI2LibScannerInfoAndCapability;
+    }
+
+    public ScannerInfo getI1ScannerInfo() {
+        return this.mScannerInfo;
+    }
+
+    public void saveData(Context context, boolean z) throws IOException {
+        if (isPrinterSet()) {
+            ScanInfoStorage.saveEscIVersion(context, getEscIVersion());
+            if (this.mEscIVersion == 2) {
+                i2ScannerInfoSaveSettings(context);
+                I2ScanParamManager.saveI2AllInfo(context, this.mI2LibScannerInfoAndCapability);
+                if (z) {
+                    saveSimpleApSsid(context);
+                }
+            }
+        }
+    }
+
+    private void saveSimpleApSsid(Context context) {
+        String str = this.mSimpleApSsid;
+        if (str == null || str.length() <= 0) {
+            WiFiDirectManager.resetConnectInfo(context, WiFiDirectManager.DEVICE_TYPE_SCANNER);
+        } else {
+            WiFiDirectManager.setConnectInfo(context, this.mSimpleApSsid, WiFiDirectManager.DEVICE_TYPE_SCANNER, this.mScannerInfo.getModelName());
+        }
+    }
+
+    public static ScannerPropertyWrapper load(Context context) {
+        ScannerPropertyWrapper scannerPropertyWrapper = new ScannerPropertyWrapper();
+        scannerPropertyWrapper.mEscIVersion = ScanInfoStorage.loadEscIVersion(context);
+        scannerPropertyWrapper.loadScannerInfoConnectivitySettings(context);
+        if (scannerPropertyWrapper.mEscIVersion == 2) {
+            scannerPropertyWrapper.loadI2Data(context);
+        }
+        return scannerPropertyWrapper;
+    }
+
+    private void loadI2Data(Context context) {
+        this.mI2LibScannerInfoAndCapability = I2ScanParamManager.loadI2AllInfo(context);
+    }
+
+    public void resetScanner() {
+        this.mScannerInfo = ScannerInfo.getInstance();
+        this.mEscIVersion = -1;
+    }
+
+    public static void clearSavedData(Context context) {
+        ScannerPropertyWrapper scannerPropertyWrapper = new ScannerPropertyWrapper();
+        scannerPropertyWrapper.resetScanner();
+        scannerPropertyWrapper.i2ScannerInfoSaveSettings(context);
+        ScanInfoStorage.saveEscIVersion(context, -1);
+        I2ScanParamManager.deleteAllInfoFile(context);
+    }
+
+    private void loadScannerInfoConnectivitySettings(Context context) {
+        this.mScannerInfo = ScannerInfo.getInstance();
+        ScanInfoStorage.getInstance().loadScannerConnectivityInfo(context, this.mScannerInfo);
+        this.mSimpleApSsid = WiFiDirectManager.getConnectInfo(context, WiFiDirectManager.DEVICE_TYPE_SCANNER);
+    }
+
+    public boolean isPrinterSet() {
+        String modelName = getModelName();
+        return modelName != null && !modelName.isEmpty();
+    }
+
+    public String getIp() {
+        return this.mScannerInfo.getIp();
+    }
+
+    public String getModelName() {
+        return this.mScannerInfo.getModelName();
+    }
+
+    public int getLocation() {
+        return this.mScannerInfo.getLocation();
+    }
+
+    public String getScannerId() {
+        return this.mScannerInfo.getScannerId();
+    }
+
+    private void i2ScannerInfoSaveSettings(Context context) {
+        ScanInfoStorage.saveScannerConnectivityInfo(context, this.mScannerInfo.getModelName(), this.mScannerInfo.getIp(), this.mScannerInfo.getScannerId(), this.mScannerInfo.getLocation());
+    }
+
+    public void updateSetSimpleApSsid(Context context) {
+        String curConnectInfo = WiFiDirectManager.getCurConnectInfo(context, MacAddrUtils.getMacAddressFromScannerId(this.mScannerInfo.getScannerId()));
+        if (this.mScannerInfo.getLocation() != 1 || curConnectInfo == null) {
+            this.mSimpleApSsid = null;
+        } else {
+            this.mSimpleApSsid = curConnectInfo;
+        }
+    }
+}

+ 65 - 0
app/src/main/java/epson/scan/activity/SettingActivityParams.java

@@ -0,0 +1,65 @@
+package epson.scan.activity;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import com.epson.iprint.shared.SharedParamScan;
+
+class SettingActivityParams {
+    private static final Class<? extends Activity> ESC_I1_SETTING_ACTIVITY = ScanSettingsActivity.class;
+    private static final Class<? extends Activity> ESC_I2_SETTING_ACTIVITY = I2ScanSettingActivity.class;
+    static final String PARAM_KEY_EXTERNAL_SCAN_PARAMS = "external-scan-params";
+    static final String PARAM_KEY_HIDE_COLOR_MODE = "hide-color-mode";
+    static final String PARAM_KEY_HIDE_RESOLUTION = "hide-resolution";
+    private static final String PARAM_RETURN_IF_ESC_I_VERSION_CHANGED = "return-if-esc-i-version-changed";
+    private static final String PARAM_SCANNER_PROPERTY_WRAPPER = "scanner-property-wrapper";
+    static final int RESULT_ESC_I_VERSION_CHANGED = 1;
+
+    SettingActivityParams() {
+    }
+
+    static boolean returnIfEscIVersionChanged(Intent intent) {
+        return intent.getBooleanExtra(PARAM_RETURN_IF_ESC_I_VERSION_CHANGED, false);
+    }
+
+    @NonNull
+    static Intent getChangeSettingActivityStartIntent(Context context, ScannerPropertyWrapper scannerPropertyWrapper, boolean z, boolean z2, boolean z3, SharedParamScan sharedParamScan) {
+        Intent intent = new Intent(context, getSettingActivityClass(scannerPropertyWrapper.getEscIVersion()));
+        intent.putExtra(PARAM_RETURN_IF_ESC_I_VERSION_CHANGED, z);
+        intent.putExtra(PARAM_SCANNER_PROPERTY_WRAPPER, scannerPropertyWrapper);
+        intent.putExtra("hide-color-mode", z2);
+        intent.putExtra("hide-resolution", z3);
+        intent.putExtra("external-scan-params", sharedParamScan);
+        return intent;
+    }
+
+    private static Class<?> getSettingActivityClass(int i) {
+        if (i != 2) {
+            return ESC_I1_SETTING_ACTIVITY;
+        }
+        return ESC_I2_SETTING_ACTIVITY;
+    }
+
+    @Nullable
+    static ScannerPropertyWrapper getScannerPropertyWrapper(Intent intent) {
+        if (intent == null) {
+            return null;
+        }
+        return (ScannerPropertyWrapper) intent.getSerializableExtra(PARAM_SCANNER_PROPERTY_WRAPPER);
+    }
+
+    @NonNull
+    static Intent getSettingReturnIntent(@Nullable ScannerPropertyWrapper scannerPropertyWrapper) {
+        Intent intent = new Intent();
+        intent.putExtra(PARAM_SCANNER_PROPERTY_WRAPPER, scannerPropertyWrapper);
+        return intent;
+    }
+
+    static Intent getScanSearchReturnIntent(ScannerPropertyWrapper scannerPropertyWrapper) {
+        Intent intent = new Intent();
+        intent.putExtra(PARAM_SCANNER_PROPERTY_WRAPPER, scannerPropertyWrapper);
+        return intent;
+    }
+}

+ 63 - 0
app/src/main/java/epson/scan/activity/StringListAdapter.java

@@ -0,0 +1,63 @@
+package epson.scan.activity;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ImageView;
+import android.widget.ListAdapter;
+import android.widget.TextView;
+import epson.print.C2135R;
+
+public class StringListAdapter extends BaseAdapter {
+    private int mCurrentPosition;
+    private LayoutInflater mLayoutInflater;
+    private String[] mStringArray;
+
+    public long getItemId(int i) {
+        return (long) i;
+    }
+
+    public StringListAdapter(Context context, String[] strArr, int i) {
+        this.mLayoutInflater = LayoutInflater.from(context);
+        this.mStringArray = strArr;
+        this.mCurrentPosition = i;
+    }
+
+    public int getCount() {
+        return this.mStringArray.length;
+    }
+
+    public Object getItem(int i) {
+        return 0;
+    }
+
+    public View getView(int i, View view, ViewGroup viewGroup) {
+        int i2 = 0;
+        if (view == null) {
+            view = this.mLayoutInflater.inflate(C2135R.layout.i2_scan_setting_item, viewGroup, false);
+        }
+        ((TextView) view.findViewById(C2135R.C2137id.tvSettingName)).setText(this.mStringArray[i]);
+        ImageView imageView = (ImageView) view.findViewById(C2135R.C2137id.ivSettingSelected);
+        if (i != this.mCurrentPosition) {
+            i2 = 8;
+        }
+        imageView.setVisibility(i2);
+        return view;
+    }
+
+    public static class Builder implements LocalListAdapterBuilder {
+        private int mCurrentPosition;
+        private String[] mStringArray;
+
+        public Builder(String[] strArr, int i) {
+            this.mStringArray = strArr;
+            this.mCurrentPosition = i;
+        }
+
+        public ListAdapter build(Context context) {
+            return new StringListAdapter(context, this.mStringArray, this.mCurrentPosition);
+        }
+    }
+}

+ 517 - 0
app/src/main/java/epson/scan/i2lib/I2ScanParamArbiter.java

@@ -0,0 +1,517 @@
+package epson.scan.i2lib;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.annotation.VisibleForTesting;
+import com.epson.lib.escani2.EscanI2Lib;
+import com.epson.lib.escani2.I2LibScannerInfoAndCapability;
+import com.epson.lib.escani2.ScanI2Params;
+import com.epson.lib.escani2.ScanSize;
+import com.epson.mobilephone.common.PrintingLib.define.Constants;
+import epson.scan.activity.ScannerPropertyWrapper;
+import epson.scan.lib.ScanCommonParams;
+import epson.scan.lib.ScanSizeHelper;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class I2ScanParamArbiter {
+    private static final EscanI2Lib.InputUnit[] ALL_INPUT_UNITS = {EscanI2Lib.InputUnit.FLATBED, EscanI2Lib.InputUnit.ADF};
+    private Selector<ScanSize> mAdfDuplexScanSizeSelector;
+    private Selector<ScanSize> mAdfNonDuplexScanSizeSelector;
+    private ScanSize mAltScanSize;
+    private Selector<EscanI2Lib.ColorMode> mColorModeSelector;
+    private int mDensity;
+    private boolean mDensityChangeable;
+    private Selector<Boolean> mDuplexSelector;
+    private int mDuplexTurnDirection;
+    private Selector<ScanSize> mFlatbedScanSizeSelector;
+    private Selector<EscanI2Lib.Gamma> mGammaSelector;
+    private Selector<EscanI2Lib.InputUnit> mInputUnitSelector;
+    private int mManualAdfAlignmentI1Value;
+    private Selector<Integer> mResolutionSelector;
+    private Selector<ScanSize> mScanSizeSelector;
+    private int mScannerAdfAlignment;
+
+    public I2ScanParamArbiter() {
+        init();
+    }
+
+    private void init() {
+        this.mInputUnitSelector = new Selector<>();
+        this.mInputUnitSelector.setCandidateArray(ALL_INPUT_UNITS);
+        this.mFlatbedScanSizeSelector = new Selector<>();
+        this.mFlatbedScanSizeSelector.setCandidateArray(new ScanSize[]{new ScanSize(ScanSize.PaperSize.MAX, true)});
+        this.mScanSizeSelector = this.mFlatbedScanSizeSelector;
+        this.mAltScanSize = null;
+        this.mColorModeSelector = new Selector<>();
+        this.mColorModeSelector.setCandidateArray(new EscanI2Lib.ColorMode[]{EscanI2Lib.ColorMode.COLOR_24BIT});
+        this.mResolutionSelector = new Selector<>();
+        setDefaultResolutionCandidate();
+        this.mDuplexSelector = new Selector<>();
+        this.mDuplexSelector.setCandidateArray(new Boolean[]{false});
+        this.mGammaSelector = new Selector<>();
+        this.mGammaSelector.setCandidateArray(new EscanI2Lib.Gamma[]{EscanI2Lib.Gamma.GAMMA_180});
+        this.mManualAdfAlignmentI1Value = 0;
+    }
+
+    public EscanI2Lib.InputUnit[] getInputUnitCandidates() {
+        return (EscanI2Lib.InputUnit[]) this.mInputUnitSelector.getCandidateArray();
+    }
+
+    public EscanI2Lib.InputUnit getInputUnit() {
+        return this.mInputUnitSelector.getValue();
+    }
+
+    public int getInputUnitPosition() {
+        return this.mInputUnitSelector.getPosition();
+    }
+
+    public void setInputUnitPosition(int i) {
+        this.mInputUnitSelector.setPosition(i);
+        if (getInputUnit() == EscanI2Lib.InputUnit.FLATBED && this.mDuplexSelector.getValue().booleanValue()) {
+            this.mDuplexSelector.setSelectedValue(false);
+        }
+        selectSizeSelectorFromInputUnitAndDuplex(getInputUnit());
+    }
+
+    private void setInputUnit(EscanI2Lib.InputUnit inputUnit) {
+        this.mInputUnitSelector.setSelectedValue(inputUnit);
+        selectSizeSelectorFromInputUnitAndDuplex(inputUnit);
+    }
+
+    public boolean isAdfAlignmentMenuValid() {
+        return this.mScannerAdfAlignment == 255;
+    }
+
+    public int getManualAdfAlignmentValue() {
+        return this.mManualAdfAlignmentI1Value;
+    }
+
+    public void setManualAdfAlignmentValue(int i) {
+        this.mManualAdfAlignmentI1Value = i;
+    }
+
+    private void selectSizeSelectorFromInputUnitAndDuplex(EscanI2Lib.InputUnit inputUnit) {
+        ScanSize scanSize = getScanSize();
+        if (inputUnit == EscanI2Lib.InputUnit.ADF) {
+            this.mScanSizeSelector = getDuplex().booleanValue() ? this.mAdfDuplexScanSizeSelector : this.mAdfNonDuplexScanSizeSelector;
+        } else {
+            this.mScanSizeSelector = this.mFlatbedScanSizeSelector;
+        }
+        this.mAltScanSize = null;
+        this.mScanSizeSelector.setSelectedValue(scanSize);
+        checkAndAdjustScanSize();
+    }
+
+    private void checkAndAdjustScanSize() {
+        if (getScanSizePosition() < 0) {
+            this.mScanSizeSelector.setSelectedValue(ScanSize.getLocaleDefaultSize());
+            if (this.mScanSizeSelector.getPosition() < 0) {
+                this.mScanSizeSelector.setSelectedValue(new ScanSize(ScanSize.PaperSize.MAX, true));
+                if (this.mScanSizeSelector.getPosition() < 0) {
+                    this.mScanSizeSelector.setPosition(0);
+                }
+            }
+        }
+    }
+
+    public ScanSize[] getScanSizeCandidates() {
+        return (ScanSize[]) this.mScanSizeSelector.getCandidateArray();
+    }
+
+    public ScanSize getScanSize() {
+        return this.mScanSizeSelector.getPosition() < 0 ? this.mAltScanSize : this.mScanSizeSelector.getValue();
+    }
+
+    public int getScanSizePosition() {
+        return this.mScanSizeSelector.getPosition();
+    }
+
+    public void setScanSizePosition(int i) {
+        this.mScanSizeSelector.setPosition(i);
+        this.mAltScanSize = null;
+    }
+
+    public EscanI2Lib.ColorMode[] getColorModeCandidates() {
+        return (EscanI2Lib.ColorMode[]) this.mColorModeSelector.getCandidateArray();
+    }
+
+    public EscanI2Lib.ColorMode getColorMode() {
+        return this.mColorModeSelector.getValue();
+    }
+
+    public int getColorModePosition() {
+        return this.mColorModeSelector.getPosition();
+    }
+
+    public void setColorModePosition(int i) {
+        this.mColorModeSelector.setPosition(i);
+    }
+
+    public Integer[] getResolutionCandidates() {
+        return (Integer[]) this.mResolutionSelector.getCandidateArray();
+    }
+
+    public Integer getResolution() {
+        return this.mResolutionSelector.getValue();
+    }
+
+    public int getResolutionPosition() {
+        return this.mResolutionSelector.getPosition();
+    }
+
+    public void setResolutionPosition(int i) {
+        int position = this.mResolutionSelector.getPosition();
+        this.mResolutionSelector.setPosition(i);
+        if (position != i) {
+            this.mAltScanSize = null;
+            checkAndAdjustScanSize();
+        }
+    }
+
+    public Boolean[] getDuplexCandidates() {
+        return (Boolean[]) this.mDuplexSelector.getCandidateArray();
+    }
+
+    public Boolean getDuplex() {
+        return this.mDuplexSelector.getValue();
+    }
+
+    public int getDuplexPosition() {
+        return this.mDuplexSelector.getPosition();
+    }
+
+    public boolean isDuplexSupported() {
+        for (Boolean booleanValue : (Boolean[]) this.mDuplexSelector.getCandidateArray()) {
+            if (booleanValue.booleanValue()) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public void setDuplexPosition(int i) {
+        this.mDuplexSelector.setPosition(i);
+        changeInputUnitFromDuplexIfNeeded();
+    }
+
+    public void setDuplexValue(boolean z) {
+        this.mDuplexSelector.setSelectedValue(Boolean.valueOf(z));
+        changeInputUnitFromDuplexIfNeeded();
+    }
+
+    private void changeInputUnitFromDuplexIfNeeded() {
+        if (!this.mDuplexSelector.getValue().booleanValue() || this.mInputUnitSelector.getValue() != EscanI2Lib.InputUnit.FLATBED) {
+            selectSizeSelectorFromInputUnitAndDuplex(getInputUnit());
+        } else {
+            setInputUnit(EscanI2Lib.InputUnit.ADF);
+        }
+    }
+
+    public void setDuplexTurnDirection(int i) {
+        this.mDuplexTurnDirection = i;
+    }
+
+    public int getDuplexTurnDirection() {
+        return this.mDuplexTurnDirection;
+    }
+
+    public void setDensity(int i, boolean z) {
+        this.mDensity = i;
+        this.mDensityChangeable = z;
+    }
+
+    public int getDensity() {
+        return this.mDensity;
+    }
+
+    public boolean getDensityChangeable() {
+        return this.mDensityChangeable;
+    }
+
+    public EscanI2Lib.Gamma[] getGammaCandidates() {
+        return (EscanI2Lib.Gamma[]) this.mGammaSelector.getCandidateArray();
+    }
+
+    public EscanI2Lib.Gamma getGamma() {
+        return this.mGammaSelector.getValue();
+    }
+
+    public int getGammaPosition() {
+        return this.mGammaSelector.getPosition();
+    }
+
+    public void setGammaPosition(int i) {
+        this.mGammaSelector.setPosition(i);
+    }
+
+    public void notifyScannerChanged(Context context, I2LibScannerInfoAndCapability i2LibScannerInfoAndCapability) {
+        internalAdjust(i2LibScannerInfoAndCapability, ScanCommonParams.load(context));
+        this.mManualAdfAlignmentI1Value = 0;
+    }
+
+    public void adjust(Context context, I2LibScannerInfoAndCapability i2LibScannerInfoAndCapability) {
+        internalAdjust(i2LibScannerInfoAndCapability, ScanCommonParams.load(context));
+    }
+
+    /* access modifiers changed from: package-private */
+    @VisibleForTesting
+    public void internalAdjust(I2LibScannerInfoAndCapability i2LibScannerInfoAndCapability, @NonNull ScanCommonParams scanCommonParams) {
+        ScanI2Params defaultScanI2Params = I2ScanParamManager.getDefaultScanI2Params();
+        this.mScannerAdfAlignment = i2LibScannerInfoAndCapability.getAlignment(EscanI2Lib.InputUnit.ADF);
+        this.mColorModeSelector = new Selector<>();
+        this.mColorModeSelector.setCandidateArray(new EscanI2Lib.ColorMode[]{EscanI2Lib.ColorMode.COLOR_24BIT, EscanI2Lib.ColorMode.GRAYSCALE_8BIT, EscanI2Lib.ColorMode.MONO_1BIT});
+        this.mColorModeSelector.setSelectedValue(defaultScanI2Params.colorMode);
+        this.mGammaSelector = new Selector<>();
+        this.mGammaSelector.setCandidateArray(new EscanI2Lib.Gamma[]{EscanI2Lib.Gamma.GAMMA_100, EscanI2Lib.Gamma.GAMMA_180});
+        this.mGammaSelector.setSelectedValue(defaultScanI2Params.userGamma);
+        adjustResolution(i2LibScannerInfoAndCapability);
+        setResolutionInitValue();
+        adjustInputUnitSelector(i2LibScannerInfoAndCapability);
+        this.mInputUnitSelector.setSelectedValue(scanCommonParams.getI2ScanSourceUnit());
+        if (this.mInputUnitSelector.getPosition() < 0) {
+            this.mInputUnitSelector.setPosition(0);
+        }
+        adjustDuplexSelector(i2LibScannerInfoAndCapability);
+        adjustDuplexAndInputUnit(scanCommonParams.getI2Duplex());
+        makeAllScanSizeSelector(i2LibScannerInfoAndCapability);
+        this.mAltScanSize = null;
+        selectSizeSelectorFromInputUnitAndDuplex(getInputUnit());
+        this.mScanSizeSelector.setSelectedValue(defaultScanI2Params.scanSize);
+        checkAndAdjustScanSize();
+        this.mDensity = defaultScanI2Params.density;
+        this.mDensityChangeable = defaultScanI2Params.densityChangeable;
+    }
+
+    public void makeSelectionList(@NonNull Context context, @NonNull I2LibScannerInfoAndCapability i2LibScannerInfoAndCapability, @NonNull ScanI2Params scanI2Params) {
+        adjust(context, i2LibScannerInfoAndCapability);
+        this.mColorModeSelector.setSelectedValue(scanI2Params.colorMode);
+        this.mGammaSelector.setSelectedValue(scanI2Params.userGamma);
+        this.mResolutionSelector.setSelectedValue(Integer.valueOf(scanI2Params.resolutionMain));
+        if (-1 == this.mResolutionSelector.getPosition()) {
+            this.mResolutionSelector.setSelectedValue(150);
+        }
+        this.mInputUnitSelector.setSelectedValue(scanI2Params.inputUnit);
+        this.mDuplexSelector.setSelectedValue(Boolean.valueOf(scanI2Params.duplex));
+        setDuplexPosition(this.mDuplexSelector.getPosition());
+        this.mDuplexTurnDirection = scanI2Params.duplexTurnDirection;
+        this.mDensity = scanI2Params.density;
+        this.mDensityChangeable = scanI2Params.densityChangeable;
+        ScanSize scanSize = scanI2Params.scanSize;
+        if (scanSize.isPixelSize()) {
+            this.mScanSizeSelector.setPosition(-1);
+            this.mAltScanSize = scanI2Params.scanSize;
+        } else {
+            this.mScanSizeSelector.setSelectedValue(scanSize);
+            checkAndAdjustScanSize();
+            this.mAltScanSize = null;
+        }
+        this.mManualAdfAlignmentI1Value = scanI2Params.manualAdfAlignment;
+    }
+
+    private void adjustInputUnitSelector(I2LibScannerInfoAndCapability i2LibScannerInfoAndCapability) {
+        ArrayList arrayList = new ArrayList();
+        if (i2LibScannerInfoAndCapability == null) {
+            arrayList.add(EscanI2Lib.InputUnit.FLATBED);
+        } else {
+            if (i2LibScannerInfoAndCapability.isFlatbedAvailable()) {
+                arrayList.add(EscanI2Lib.InputUnit.FLATBED);
+            }
+            if (i2LibScannerInfoAndCapability.isAdfAvailable()) {
+                arrayList.add(EscanI2Lib.InputUnit.ADF);
+            }
+        }
+        if (arrayList.size() > 0) {
+            this.mInputUnitSelector.setCandidateArray(arrayList.toArray(new EscanI2Lib.InputUnit[arrayList.size()]));
+            return;
+        }
+        throw new RuntimeException();
+    }
+
+    private void adjustDuplexSelector(I2LibScannerInfoAndCapability i2LibScannerInfoAndCapability) {
+        if (i2LibScannerInfoAndCapability == null || !i2LibScannerInfoAndCapability.canDoubleSideScan()) {
+            this.mDuplexSelector.setCandidateArray(new Boolean[]{false});
+            return;
+        }
+        this.mDuplexSelector.setCandidateArray(new Boolean[]{true, false});
+    }
+
+    private void adjustDuplexAndInputUnit(boolean z) {
+        if (((Boolean[]) this.mDuplexSelector.getCandidateArray()).length >= 2) {
+            this.mDuplexSelector.setSelectedValue(Boolean.valueOf(z));
+        } else {
+            this.mDuplexSelector.setSelectedValue(false);
+        }
+        if (this.mDuplexSelector.getPosition() < 0) {
+            this.mDuplexSelector.setPosition(0);
+        }
+    }
+
+    /* access modifiers changed from: package-private */
+    public void adjustResolution(I2LibScannerInfoAndCapability i2LibScannerInfoAndCapability) {
+        if (i2LibScannerInfoAndCapability == null) {
+            setDefaultResolutionCandidate();
+            return;
+        }
+        int[] iArr = (int[]) i2LibScannerInfoAndCapability.scannerI2Capability.mainScanResolutions.clone();
+        int[] iArr2 = i2LibScannerInfoAndCapability.scannerI2Capability.subScanResolutions;
+        if (iArr == null || iArr2 == null) {
+            setDefaultResolutionCandidate();
+            return;
+        }
+        List<Integer> makeList = makeList(new int[]{75, 150, 300});
+        List<Integer> makeList2 = makeList(iArr2);
+        ArrayList arrayList = new ArrayList();
+        Arrays.sort(iArr);
+        for (int i : iArr) {
+            if (makeList2.contains(Integer.valueOf(i)) && makeList.contains(Integer.valueOf(i))) {
+                arrayList.add(Integer.valueOf(i));
+            }
+        }
+        this.mResolutionSelector.setCandidateArray((Integer[]) arrayList.toArray(new Integer[arrayList.size()]));
+    }
+
+    private void setDefaultResolutionCandidate() {
+        this.mResolutionSelector.setCandidateArray(new Integer[]{150});
+    }
+
+    private void setResolutionInitValue() {
+        this.mResolutionSelector.setSelectedValue(150);
+        if (-1 == this.mResolutionSelector.getPosition()) {
+            this.mResolutionSelector.setPosition(0);
+        }
+    }
+
+    private void makeAllScanSizeSelector(I2LibScannerInfoAndCapability i2LibScannerInfoAndCapability) {
+        if (i2LibScannerInfoAndCapability == null) {
+            this.mFlatbedScanSizeSelector = new Selector<>();
+            this.mFlatbedScanSizeSelector.setCandidateArray(new ScanSize[]{new ScanSize(ScanSize.PaperSize.MAX, true)});
+            this.mScanSizeSelector = this.mFlatbedScanSizeSelector;
+            return;
+        }
+        int sensorSizeBaseResolution = i2LibScannerInfoAndCapability.scannerI2Info.getSensorSizeBaseResolution();
+        this.mFlatbedScanSizeSelector = makeScanSizeSelector(EscanI2Lib.InputUnit.FLATBED, false, i2LibScannerInfoAndCapability.getSensorSize(EscanI2Lib.InputUnit.FLATBED), sensorSizeBaseResolution);
+        this.mAdfDuplexScanSizeSelector = makeScanSizeSelector(EscanI2Lib.InputUnit.ADF, true, i2LibScannerInfoAndCapability.getSensorSize(EscanI2Lib.InputUnit.ADF), sensorSizeBaseResolution);
+        this.mAdfNonDuplexScanSizeSelector = makeScanSizeSelector(EscanI2Lib.InputUnit.ADF, false, i2LibScannerInfoAndCapability.getSensorSize(EscanI2Lib.InputUnit.ADF), sensorSizeBaseResolution);
+    }
+
+    private Selector<ScanSize> makeScanSizeSelector(EscanI2Lib.InputUnit inputUnit, boolean z, @Nullable int[] iArr, int i) {
+        if (iArr == null) {
+            Selector<ScanSize> selector = new Selector<>();
+            selector.setCandidateArray(new ScanSize[]{new ScanSize(ScanSize.PaperSize.MAX, true)});
+            return selector;
+        }
+        int[] supportedScanSizeList = ScanSizeHelper.getSupportedScanSizeList(inputUnit == EscanI2Lib.InputUnit.ADF ? 1 : 0, z ? 1 : 0, iArr[0], iArr[1], i);
+        ArrayList arrayList = new ArrayList();
+        for (int i2ScanSize : supportedScanSizeList) {
+            ScanSize i2ScanSize2 = getI2ScanSize(i2ScanSize);
+            if (i2ScanSize2 != null) {
+                arrayList.add(i2ScanSize2);
+            }
+        }
+        if (inputUnit != EscanI2Lib.InputUnit.ADF) {
+            arrayList.add(new ScanSize(ScanSize.PaperSize.MAX, true));
+        } else if (arrayList.isEmpty()) {
+            arrayList.add(new ScanSize(ScanSize.PaperSize.MAX, true));
+        }
+        Selector<ScanSize> selector2 = new Selector<>();
+        selector2.setCandidateArray((ScanSize[]) arrayList.toArray(new ScanSize[arrayList.size()]));
+        return selector2;
+    }
+
+    public ScanI2Params getScanParam() {
+        ScanI2Params scanI2Params = new ScanI2Params();
+        int intValue = getResolution().intValue();
+        scanI2Params.resolutionMain = intValue;
+        scanI2Params.resolutionSub = intValue;
+        scanI2Params.inputUnit = getInputUnit();
+        scanI2Params.scanSize = getScanSize();
+        scanI2Params.colorMode = getColorMode();
+        scanI2Params.userGamma = getGamma();
+        scanI2Params.duplex = getDuplex().booleanValue();
+        scanI2Params.duplexTurnDirection = this.mDuplexTurnDirection;
+        scanI2Params.density = this.mDensity;
+        scanI2Params.densityChangeable = this.mDensityChangeable;
+        scanI2Params.manualAdfAlignment = this.mManualAdfAlignmentI1Value;
+        return scanI2Params;
+    }
+
+    public static ScanSize getI2ScanSize(int i) {
+        if (i == Constants.PaperName.EPS_MSID_B5.getCode()) {
+            return new ScanSize(ScanSize.PaperSize.B5, true);
+        }
+        if (i == Constants.PaperName.EPS_MSID_A4.getCode()) {
+            return new ScanSize(ScanSize.PaperSize.A4, true);
+        }
+        if (i == Constants.PaperName.EPS_MSID_LETTER.getCode()) {
+            return new ScanSize(ScanSize.PaperSize.LETTER, true);
+        }
+        if (i == Constants.PaperName.EPS_MSID_LEGAL.getCode()) {
+            return new ScanSize(ScanSize.PaperSize.LEGAL, true);
+        }
+        if (i == Constants.PaperName.EPS_MSID_A3.getCode()) {
+            return new ScanSize(ScanSize.PaperSize.A3, true);
+        }
+        return null;
+    }
+
+    private static List<Integer> makeList(int[] iArr) {
+        ArrayList arrayList = new ArrayList(iArr.length);
+        for (int valueOf : iArr) {
+            arrayList.add(Integer.valueOf(valueOf));
+        }
+        return arrayList;
+    }
+
+    public void tmpReset() {
+        init();
+    }
+
+    public static ScanI2Params getAdjustedParams(@NonNull Context context, @NonNull ScannerPropertyWrapper scannerPropertyWrapper) {
+        I2LibScannerInfoAndCapability i2ScannerAllInfo = scannerPropertyWrapper.getI2ScannerAllInfo();
+        I2ScanParamArbiter i2ScanParamArbiter = new I2ScanParamArbiter();
+        i2ScanParamArbiter.adjust(context, i2ScannerAllInfo);
+        return i2ScanParamArbiter.getScanParam();
+    }
+
+    private static class Selector<E> {
+        public static final int UNKNOWN_POSITION = -1;
+        private E[] mCandidates;
+        private int mSelectedPosition = -1;
+
+        public int getPosition() {
+            return this.mSelectedPosition;
+        }
+
+        public void setPosition(int i) {
+            this.mSelectedPosition = i;
+        }
+
+        public void setSelectedValue(E e) {
+            setPosition(Arrays.asList(this.mCandidates).indexOf(e));
+        }
+
+        public E getValue() {
+            int position = getPosition();
+            if (position < 0) {
+                position = 0;
+            }
+            return this.mCandidates[position];
+        }
+
+        public void setCandidateArray(E[] eArr) {
+            this.mCandidates = eArr;
+            if (eArr.length > 0) {
+                setPosition(0);
+            } else {
+                setPosition(-1);
+            }
+        }
+
+        public E[] getCandidateArray() {
+            return this.mCandidates;
+        }
+    }
+}

+ 319 - 0
app/src/main/java/epson/scan/i2lib/I2ScanParamManager.java

@@ -0,0 +1,319 @@
+package epson.scan.i2lib;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.annotation.VisibleForTesting;
+import com.epson.lib.escani2.EscanI2Lib;
+import com.epson.lib.escani2.I2LibScannerInfoAndCapability;
+import com.epson.lib.escani2.ScanI2Params;
+import com.epson.lib.escani2.ScanSize;
+import java.io.File;
+import java.io.IOException;
+
+public class I2ScanParamManager {
+    static final int DEFAULT_RESOLUTION = 150;
+    private static final String I2SCAN_ALL_INFO_FILE_NAME = "i2_all_info";
+    private static final String I2SCAN_PARAM_FILE_NAME = "i2_scan_params.bin";
+    private static final String TAG = "I2ScanParamManager";
+    private static I2ScanParamManager sI2ScanParamManager;
+
+    public static synchronized I2ScanParamManager getInstance() {
+        I2ScanParamManager i2ScanParamManager;
+        synchronized (I2ScanParamManager.class) {
+            if (sI2ScanParamManager == null) {
+                sI2ScanParamManager = new I2ScanParamManager();
+            }
+            i2ScanParamManager = sI2ScanParamManager;
+        }
+        return i2ScanParamManager;
+    }
+
+    @VisibleForTesting
+    protected static void replaceInstance(@Nullable I2ScanParamManager i2ScanParamManager) {
+        sI2ScanParamManager = i2ScanParamManager;
+    }
+
+    @VisibleForTesting
+    protected I2ScanParamManager() {
+    }
+
+    public static void saveParams(@NonNull Context context, @NonNull ScanI2Params scanI2Params) throws IOException {
+        getInstance().saveParamsNonStatic(context, scanI2Params);
+    }
+
+    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r0v1, resolved type: java.io.ObjectOutputStream} */
+    /* JADX WARNING: type inference failed for: r0v0 */
+    /* JADX WARNING: type inference failed for: r0v2 */
+    /* JADX WARNING: type inference failed for: r0v3, types: [java.lang.Throwable] */
+    /* JADX WARNING: type inference failed for: r0v5 */
+    /* access modifiers changed from: protected */
+    /* JADX WARNING: Multi-variable type inference failed */
+    /* JADX WARNING: Removed duplicated region for block: B:15:0x001f A[SYNTHETIC, Splitter:B:15:0x001f] */
+    @android.support.annotation.VisibleForTesting
+    /* Code decompiled incorrectly, please refer to instructions dump. */
+    public void saveParamsNonStatic(@android.support.annotation.NonNull android.content.Context r5, @android.support.annotation.NonNull com.epson.lib.escani2.ScanI2Params r6) throws java.io.IOException {
+        /*
+            r4 = this;
+            r0 = 0
+            java.io.ObjectOutputStream r1 = new java.io.ObjectOutputStream     // Catch:{ all -> 0x001c }
+            java.lang.String r2 = "i2_scan_params.bin"
+            r3 = 0
+            java.io.FileOutputStream r5 = r5.openFileOutput(r2, r3)     // Catch:{ all -> 0x001c }
+            r1.<init>(r5)     // Catch:{ all -> 0x001c }
+            r1.writeObject(r6)     // Catch:{ all -> 0x0019 }
+            r1.close()     // Catch:{ IOException -> 0x0014 }
+            goto L_0x0015
+        L_0x0014:
+            r0 = move-exception
+        L_0x0015:
+            if (r0 != 0) goto L_0x0018
+            return
+        L_0x0018:
+            throw r0
+        L_0x0019:
+            r5 = move-exception
+            r0 = r1
+            goto L_0x001d
+        L_0x001c:
+            r5 = move-exception
+        L_0x001d:
+            if (r0 == 0) goto L_0x0022
+            r0.close()     // Catch:{ IOException -> 0x0022 }
+        L_0x0022:
+            throw r5
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.scan.i2lib.I2ScanParamManager.saveParamsNonStatic(android.content.Context, com.epson.lib.escani2.ScanI2Params):void");
+    }
+
+    @NonNull
+    public static ScanI2Params loadScanI2Params(@NonNull Context context) {
+        return getInstance().loadScanI2ParamsNonStatic(context);
+    }
+
+    /* access modifiers changed from: protected */
+    /* JADX WARNING: Exception block dominator not found, dom blocks: [B:16:0x001f, B:23:0x0029] */
+    /* JADX WARNING: Missing exception handler attribute for start block: B:16:0x001f */
+    /* JADX WARNING: Missing exception handler attribute for start block: B:23:0x0029 */
+    /* JADX WARNING: Removed duplicated region for block: B:19:0x0025 A[SYNTHETIC, Splitter:B:19:0x0025] */
+    /* JADX WARNING: Removed duplicated region for block: B:26:0x002f A[SYNTHETIC, Splitter:B:26:0x002f] */
+    /* JADX WARNING: Removed duplicated region for block: B:31:0x0035 A[SYNTHETIC, Splitter:B:31:0x0035] */
+    /* JADX WARNING: Unknown top exception splitter block from list: {B:23:0x0029=Splitter:B:23:0x0029, B:16:0x001f=Splitter:B:16:0x001f} */
+    @android.support.annotation.VisibleForTesting
+    @android.support.annotation.NonNull
+    /* Code decompiled incorrectly, please refer to instructions dump. */
+    public com.epson.lib.escani2.ScanI2Params loadScanI2ParamsNonStatic(@android.support.annotation.NonNull android.content.Context r4) {
+        /*
+            r3 = this;
+            r0 = 0
+            java.io.ObjectInputStream r1 = new java.io.ObjectInputStream     // Catch:{ FileNotFoundException -> 0x0029, IOException | ClassNotFoundException -> 0x001f }
+            java.lang.String r2 = "i2_scan_params.bin"
+            java.io.FileInputStream r4 = r4.openFileInput(r2)     // Catch:{ FileNotFoundException -> 0x0029, IOException | ClassNotFoundException -> 0x001f }
+            r1.<init>(r4)     // Catch:{ FileNotFoundException -> 0x0029, IOException | ClassNotFoundException -> 0x001f }
+            java.lang.Object r4 = r1.readObject()     // Catch:{ FileNotFoundException -> 0x001b, IOException | ClassNotFoundException -> 0x0019, all -> 0x0016 }
+            com.epson.lib.escani2.ScanI2Params r4 = (com.epson.lib.escani2.ScanI2Params) r4     // Catch:{ FileNotFoundException -> 0x001b, IOException | ClassNotFoundException -> 0x0019, all -> 0x0016 }
+            r1.close()     // Catch:{ IOException -> 0x0015 }
+        L_0x0015:
+            return r4
+        L_0x0016:
+            r4 = move-exception
+            r0 = r1
+            goto L_0x0033
+        L_0x0019:
+            r0 = r1
+            goto L_0x001f
+        L_0x001b:
+            r0 = r1
+            goto L_0x0029
+        L_0x001d:
+            r4 = move-exception
+            goto L_0x0033
+        L_0x001f:
+            com.epson.lib.escani2.ScanI2Params r4 = getDefaultScanI2Params()     // Catch:{ all -> 0x001d }
+            if (r0 == 0) goto L_0x0028
+            r0.close()     // Catch:{ IOException -> 0x0028 }
+        L_0x0028:
+            return r4
+        L_0x0029:
+            com.epson.lib.escani2.ScanI2Params r4 = getDefaultScanI2Params()     // Catch:{ all -> 0x001d }
+            if (r0 == 0) goto L_0x0032
+            r0.close()     // Catch:{ IOException -> 0x0032 }
+        L_0x0032:
+            return r4
+        L_0x0033:
+            if (r0 == 0) goto L_0x0038
+            r0.close()     // Catch:{ IOException -> 0x0038 }
+        L_0x0038:
+            throw r4
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.scan.i2lib.I2ScanParamManager.loadScanI2ParamsNonStatic(android.content.Context):com.epson.lib.escani2.ScanI2Params");
+    }
+
+    public static void deleteScanI2Params(@NonNull Context context) {
+        getInstance().deleteAllInfoFileNonStatic(context);
+    }
+
+    /* access modifiers changed from: protected */
+    @VisibleForTesting
+    public void deleteScanI2ParamsNonStatic(@NonNull Context context) {
+        File fileStreamPath = context.getFileStreamPath(I2SCAN_PARAM_FILE_NAME);
+        if (fileStreamPath.exists()) {
+            fileStreamPath.delete();
+        }
+    }
+
+    public static ScanI2Params getDefaultScanI2Params() {
+        ScanI2Params scanI2Params = new ScanI2Params();
+        scanI2Params.resolutionMain = 150;
+        scanI2Params.resolutionSub = 150;
+        scanI2Params.inputUnit = EscanI2Lib.InputUnit.ADF;
+        scanI2Params.scanSize = ScanSize.getLocaleDefaultSize();
+        scanI2Params.colorMode = EscanI2Lib.ColorMode.COLOR_24BIT;
+        scanI2Params.userGamma = EscanI2Lib.Gamma.GAMMA_180;
+        scanI2Params.autoCrop = EscanI2Lib.AutoCrop.FALSE;
+        scanI2Params.autoSkew = EscanI2Lib.AutoSkew.FALSE;
+        scanI2Params.lookupTableNo = 0;
+        scanI2Params.duplex = false;
+        scanI2Params.overScan = false;
+        scanI2Params.density = 128;
+        scanI2Params.densityChangeable = false;
+        scanI2Params.doubleFeedLevel = EscanI2Lib.DoubleFeedLevel.LEVEL_NONE;
+        scanI2Params.maxScanSheets = 30;
+        scanI2Params.maxWriteSheets = 30;
+        scanI2Params.qualityHW = 90;
+        scanI2Params.qualitySW = 90;
+        return scanI2Params;
+    }
+
+    public static void updateScanSize(Context context, ScanSize scanSize) throws IOException {
+        getInstance().updateScanSizeNonStatic(context, scanSize);
+    }
+
+    /* access modifiers changed from: protected */
+    @VisibleForTesting
+    public void updateScanSizeNonStatic(Context context, ScanSize scanSize) throws IOException {
+        ScanI2Params loadScanI2Params = loadScanI2Params(context);
+        loadScanI2Params.scanSize = scanSize;
+        saveParams(context, loadScanI2Params);
+    }
+
+    public static void saveI2AllInfo(@NonNull Context context, I2LibScannerInfoAndCapability i2LibScannerInfoAndCapability) throws IOException {
+        getInstance().saveI2AllInfoNonStatic(context, i2LibScannerInfoAndCapability);
+    }
+
+    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r0v1, resolved type: java.io.ObjectOutputStream} */
+    /* JADX WARNING: type inference failed for: r0v0 */
+    /* JADX WARNING: type inference failed for: r0v2 */
+    /* JADX WARNING: type inference failed for: r0v3, types: [java.lang.Throwable] */
+    /* JADX WARNING: type inference failed for: r0v5 */
+    /* access modifiers changed from: protected */
+    /* JADX WARNING: Multi-variable type inference failed */
+    /* JADX WARNING: Removed duplicated region for block: B:15:0x001f A[SYNTHETIC, Splitter:B:15:0x001f] */
+    @android.support.annotation.VisibleForTesting
+    /* Code decompiled incorrectly, please refer to instructions dump. */
+    public void saveI2AllInfoNonStatic(@android.support.annotation.NonNull android.content.Context r5, com.epson.lib.escani2.I2LibScannerInfoAndCapability r6) throws java.io.IOException {
+        /*
+            r4 = this;
+            r0 = 0
+            java.io.ObjectOutputStream r1 = new java.io.ObjectOutputStream     // Catch:{ all -> 0x001c }
+            java.lang.String r2 = "i2_all_info"
+            r3 = 0
+            java.io.FileOutputStream r5 = r5.openFileOutput(r2, r3)     // Catch:{ all -> 0x001c }
+            r1.<init>(r5)     // Catch:{ all -> 0x001c }
+            r1.writeObject(r6)     // Catch:{ all -> 0x0019 }
+            r1.close()     // Catch:{ IOException -> 0x0014 }
+            goto L_0x0015
+        L_0x0014:
+            r0 = move-exception
+        L_0x0015:
+            if (r0 != 0) goto L_0x0018
+            return
+        L_0x0018:
+            throw r0
+        L_0x0019:
+            r5 = move-exception
+            r0 = r1
+            goto L_0x001d
+        L_0x001c:
+            r5 = move-exception
+        L_0x001d:
+            if (r0 == 0) goto L_0x0022
+            r0.close()     // Catch:{ IOException -> 0x0022 }
+        L_0x0022:
+            throw r5
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.scan.i2lib.I2ScanParamManager.saveI2AllInfoNonStatic(android.content.Context, com.epson.lib.escani2.I2LibScannerInfoAndCapability):void");
+    }
+
+    @Nullable
+    public static I2LibScannerInfoAndCapability loadI2AllInfo(@NonNull Context context) {
+        return getInstance().loadI2AllInfoNonStatic(context);
+    }
+
+    /* access modifiers changed from: protected */
+    /* JADX WARNING: Removed duplicated region for block: B:15:0x0021 A[SYNTHETIC, Splitter:B:15:0x0021] */
+    /* JADX WARNING: Removed duplicated region for block: B:30:? A[RETURN, SYNTHETIC] */
+    /* JADX WARNING: Removed duplicated region for block: B:31:? A[RETURN, SYNTHETIC] */
+    @android.support.annotation.Nullable
+    @android.support.annotation.VisibleForTesting
+    /* Code decompiled incorrectly, please refer to instructions dump. */
+    public com.epson.lib.escani2.I2LibScannerInfoAndCapability loadI2AllInfoNonStatic(@android.support.annotation.NonNull android.content.Context r4) {
+        /*
+            r3 = this;
+            r0 = 0
+            java.io.ObjectInputStream r1 = new java.io.ObjectInputStream     // Catch:{ FileNotFoundException -> 0x002c, IOException | ClassNotFoundException -> 0x0025, all -> 0x001e }
+            java.lang.String r2 = "i2_all_info"
+            java.io.FileInputStream r4 = r4.openFileInput(r2)     // Catch:{ FileNotFoundException -> 0x002c, IOException | ClassNotFoundException -> 0x0025, all -> 0x001e }
+            r1.<init>(r4)     // Catch:{ FileNotFoundException -> 0x002c, IOException | ClassNotFoundException -> 0x0025, all -> 0x001e }
+            java.lang.Object r4 = r1.readObject()     // Catch:{ FileNotFoundException -> 0x001c, IOException | ClassNotFoundException -> 0x001a, all -> 0x0017 }
+            com.epson.lib.escani2.I2LibScannerInfoAndCapability r4 = (com.epson.lib.escani2.I2LibScannerInfoAndCapability) r4     // Catch:{ FileNotFoundException -> 0x001c, IOException | ClassNotFoundException -> 0x001a, all -> 0x0017 }
+            r1.close()     // Catch:{ IOException -> 0x0015 }
+        L_0x0015:
+            r0 = r4
+            goto L_0x0030
+        L_0x0017:
+            r4 = move-exception
+            r0 = r1
+            goto L_0x001f
+        L_0x001a:
+            goto L_0x0026
+        L_0x001c:
+            goto L_0x002d
+        L_0x001e:
+            r4 = move-exception
+        L_0x001f:
+            if (r0 == 0) goto L_0x0024
+            r0.close()     // Catch:{ IOException -> 0x0024 }
+        L_0x0024:
+            throw r4
+        L_0x0025:
+            r1 = r0
+        L_0x0026:
+            if (r1 == 0) goto L_0x0030
+        L_0x0028:
+            r1.close()     // Catch:{ IOException -> 0x0030 }
+            goto L_0x0030
+        L_0x002c:
+            r1 = r0
+        L_0x002d:
+            if (r1 == 0) goto L_0x0030
+            goto L_0x0028
+        L_0x0030:
+            return r0
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.scan.i2lib.I2ScanParamManager.loadI2AllInfoNonStatic(android.content.Context):com.epson.lib.escani2.I2LibScannerInfoAndCapability");
+    }
+
+    public static void deleteAllInfoFile(@NonNull Context context) {
+        getInstance().deleteAllInfoFileNonStatic(context);
+    }
+
+    /* access modifiers changed from: protected */
+    @VisibleForTesting
+    public void deleteAllInfoFileNonStatic(@NonNull Context context) {
+        File fileStreamPath = context.getFileStreamPath(I2SCAN_ALL_INFO_FILE_NAME);
+        if (fileStreamPath.exists()) {
+            fileStreamPath.delete();
+        }
+    }
+}

+ 592 - 0
app/src/main/java/epson/scan/i2lib/I2ScanTask.java

@@ -0,0 +1,592 @@
+package epson.scan.i2lib;
+
+import android.content.Context;
+import android.os.AsyncTask;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.annotation.UiThread;
+import android.support.annotation.VisibleForTesting;
+import android.support.annotation.WorkerThread;
+import com.epson.iprint.prtlogger.Analytics;
+import com.epson.iprint.prtlogger.CommonLog;
+import com.epson.iprint.prtlogger.PrintLog;
+import com.epson.iprint.shared.SharedParamScan;
+import com.epson.lib.escani2.EscanI2Lib;
+import com.epson.lib.escani2.ScanI2Params;
+import com.epson.lib.escani2.ScanI2Runner;
+import com.epson.lib.escani2.ScanSize;
+import com.epson.lib.escani2.ScannerI2Info;
+import epson.common.ExternalFileUtils;
+import epson.scan.activity.ScanContinueParam;
+import epson.scan.activity.ScannerPropertyWrapper;
+import epson.scan.lib.CancelableScannerProbe;
+import epson.scan.lib.EscanLibException;
+import epson.scan.lib.I1ScanParams;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Calendar;
+
+public class I2ScanTask extends AsyncTask<Void, Void, TaskError> {
+    private static final String LOG_TAG = "I2ScanTask";
+    private Context mApplicationContext;
+    private volatile boolean mCancelRequested;
+    private CancelableScannerProbe mCancelableScannerProbe;
+    private CommonLog mCommonLog;
+    private ImageProcessController mImageProcessController;
+    private ArrayList<String> mResScanFileList;
+    private ScanI2Params mScanI2Params;
+    private ScanI2Runner mScanI2Runner = new ScanI2Runner();
+    private final ScanResultReceiver mScanResultReceiver;
+    private ScannerPropertyWrapper mScannerPropertyWrapper;
+
+    public interface ScanResultReceiver {
+        @WorkerThread
+        void onProgressUpdate(int i, int i2);
+
+        @UiThread
+        void onScanEnd(TaskError taskError);
+    }
+
+    /* access modifiers changed from: protected */
+    public void onPreExecute() {
+    }
+
+    public ArrayList<String> getScanFileList() {
+        return this.mResScanFileList;
+    }
+
+    @Nullable
+    public File getScanFile(int i, int i2) {
+        if (this.mScanI2Runner == null) {
+            return null;
+        }
+        return this.mImageProcessController.getAllProcessFile(i, i2);
+    }
+
+    public I2ScanTask(@NonNull Context context, @Nullable ScanResultReceiver scanResultReceiver, @Nullable SharedParamScan sharedParamScan, CommonLog commonLog) {
+        this.mApplicationContext = context;
+        ScanI2Params loadAndAdjustScanParams = loadAndAdjustScanParams(context);
+        margeScanI2Params(loadAndAdjustScanParams, sharedParamScan);
+        this.mScanI2Params = loadAndAdjustScanParams;
+        this.mScannerPropertyWrapper = ScannerPropertyWrapper.load(context);
+        ScannerPropertyWrapper scannerPropertyWrapper = this.mScannerPropertyWrapper;
+        if (scannerPropertyWrapper == null) {
+            throw new IllegalStateException("ScannerPropertyWrapper.load() error!");
+        } else if (scannerPropertyWrapper.getEscIVersion() == 2) {
+            this.mImageProcessController = new ImageProcessController(this, loadAndAdjustScanParams.duplex, loadAndAdjustScanParams.duplexTurnDirection, this.mScannerPropertyWrapper.getI2ScannerAllInfo().scannerI2Info.adfDuplexType, loadAndAdjustScanParams.colorMode == EscanI2Lib.ColorMode.MONO_1BIT, loadAndAdjustScanParams.density);
+            this.mImageProcessController.init(getSaveDirectory(context), Calendar.getInstance());
+            this.mScanResultReceiver = scanResultReceiver;
+            this.mResScanFileList = new ArrayList<>();
+            this.mCommonLog = commonLog;
+            if (this.mCommonLog == null) {
+                this.mCommonLog = new CommonLog();
+            }
+        } else {
+            throw new IllegalStateException("ScannerPropertyWrapper.load() error! ESC/I version != 2");
+        }
+    }
+
+    private void margeScanI2Params(@NonNull ScanI2Params scanI2Params, @Nullable SharedParamScan sharedParamScan) {
+        if (sharedParamScan != null) {
+            scanI2Params.resolutionMain = sharedParamScan.getRes_main();
+            scanI2Params.resolutionSub = sharedParamScan.getRes_sub();
+            scanI2Params.scanSize = new ScanSize(sharedParamScan.getPixel_main(), sharedParamScan.getPixel_sub(), 0, 0);
+            EscanI2Lib.ColorMode colorMode = EscanI2Lib.ColorMode.COLOR_24BIT;
+            switch (sharedParamScan.getScan_type()) {
+                case 2:
+                    colorMode = EscanI2Lib.ColorMode.GRAYSCALE_8BIT;
+                    break;
+                case 3:
+                    colorMode = EscanI2Lib.ColorMode.MONO_1BIT;
+                    break;
+            }
+            scanI2Params.colorMode = colorMode;
+        }
+    }
+
+    private File getSaveDirectory(Context context) {
+        File file = new File(ExternalFileUtils.getInstance(context).getScannedImageDir());
+        if (file.exists() || file.mkdirs()) {
+            return file;
+        }
+        throw new RuntimeException("mkdirs error '" + file + "'");
+    }
+
+    private ScanI2Params loadAndAdjustScanParams(Context context) {
+        ScanI2Params loadScanI2Params = I2ScanParamManager.loadScanI2Params(context);
+        loadScanI2Params.autoCrop = EscanI2Lib.AutoCrop.FALSE;
+        loadScanI2Params.autoSkew = EscanI2Lib.AutoSkew.FALSE;
+        loadScanI2Params.lookupTableNo = 0;
+        loadScanI2Params.overScan = false;
+        loadScanI2Params.doubleFeedLevel = EscanI2Lib.DoubleFeedLevel.LEVEL_NONE;
+        if (loadScanI2Params.inputUnit == EscanI2Lib.InputUnit.ADF) {
+            loadScanI2Params.maxScanSheets = ScanContinueParam.getAvailableScanPageCount();
+            loadScanI2Params.maxWriteSheets = ScanContinueParam.getAvailableScanPageCount();
+        } else {
+            loadScanI2Params.maxScanSheets = 1;
+            loadScanI2Params.maxWriteSheets = 1;
+        }
+        loadScanI2Params.qualityHW = 90;
+        loadScanI2Params.qualitySW = 90;
+        return loadScanI2Params;
+    }
+
+    public int[] getScanPages() {
+        return (int[]) this.mScanI2Runner.getScanPages().clone();
+    }
+
+    /* access modifiers changed from: protected */
+    /* JADX WARNING: Missing exception handler attribute for start block: B:78:0x0174 */
+    /* JADX WARNING: Removed duplicated region for block: B:75:0x0160  */
+    /* JADX WARNING: Removed duplicated region for block: B:81:0x017b  */
+    /* JADX WARNING: Removed duplicated region for block: B:85:0x0191  */
+    /* JADX WARNING: Unknown top exception splitter block from list: {B:72:0x0150=Splitter:B:72:0x0150, B:78:0x0174=Splitter:B:78:0x0174} */
+    /* Code decompiled incorrectly, please refer to instructions dump. */
+    public epson.scan.i2lib.I2ScanTask.TaskError doInBackground(java.lang.Void... r9) {
+        /*
+            r8 = this;
+            java.lang.String r9 = ""
+            r0 = 0
+            r1 = 1
+            r8.checkCancel()     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            boolean r2 = epson.common.Utils.isMediaMounted()     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            r3 = 2
+            if (r2 != 0) goto L_0x0025
+            r8.checkCancel()     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            epson.scan.i2lib.I2ScanTask$TaskError r2 = new epson.scan.i2lib.I2ScanTask$TaskError     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            r2.<init>(r3, r3)     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            android.content.Context r0 = r8.mApplicationContext
+            int r0 = com.epson.iprint.prtlogger.Analytics.getConnectionType(r0)
+            android.content.Context r1 = r8.mApplicationContext
+            epson.scan.lib.ScannerConnection.disconnectIfSimpleAp(r1, r9)
+            r8.sendLog(r0)
+            return r2
+        L_0x0025:
+            android.content.Context r2 = r8.mApplicationContext     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            java.io.File r2 = r8.getSaveDirectory(r2)     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            com.epson.lib.escani2.ScanI2Params r4 = r8.mScanI2Params     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            epson.scan.activity.ScannerPropertyWrapper r5 = r8.mScannerPropertyWrapper     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            com.epson.lib.escani2.I2LibScannerInfoAndCapability r5 = r5.getI2ScannerAllInfo()     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            com.epson.lib.escani2.ScannerI2Info r5 = r5.scannerI2Info     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            int r4 = r8.checkScanParams(r2, r4, r5)     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            r5 = -202(0xffffffffffffff36, float:NaN)
+            switch(r4) {
+                case 0: goto L_0x0058;
+                case 1: goto L_0x0043;
+                default: goto L_0x003e;
+            }     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+        L_0x003e:
+            r8.checkCancel()     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            goto L_0x0139
+        L_0x0043:
+            epson.scan.i2lib.I2ScanTask$TaskError r2 = new epson.scan.i2lib.I2ScanTask$TaskError     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            r4 = 3
+            r2.<init>(r3, r4)     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            android.content.Context r0 = r8.mApplicationContext
+            int r0 = com.epson.iprint.prtlogger.Analytics.getConnectionType(r0)
+            android.content.Context r1 = r8.mApplicationContext
+            epson.scan.lib.ScannerConnection.disconnectIfSimpleAp(r1, r9)
+            r8.sendLog(r0)
+            return r2
+        L_0x0058:
+            boolean r3 = epson.scan.activity.ScanContinueParam.isContinueScanning()     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            if (r3 != 0) goto L_0x006e
+            android.content.Context r3 = r8.mApplicationContext     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            epson.common.ExternalFileUtils r3 = epson.common.ExternalFileUtils.getInstance(r3)     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            java.lang.String r2 = r2.getPath()     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            r3.clearTempFoler(r2)     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            epson.scan.activity.ScanContinueParam.resetParameter()     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+        L_0x006e:
+            r8.checkCancel()     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            android.content.Context r2 = r8.mApplicationContext     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            epson.scan.activity.ScannerPropertyWrapper r3 = r8.mScannerPropertyWrapper     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            java.lang.String r9 = r8.probeScanner(r2, r3)     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            r8.checkCancel()     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            if (r9 != 0) goto L_0x0094
+            epson.scan.i2lib.I2ScanTask$TaskError r2 = new epson.scan.i2lib.I2ScanTask$TaskError     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            r3 = -214(0xffffffffffffff2a, float:NaN)
+            r2.<init>(r1, r3)     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            android.content.Context r0 = r8.mApplicationContext
+            int r0 = com.epson.iprint.prtlogger.Analytics.getConnectionType(r0)
+            android.content.Context r1 = r8.mApplicationContext
+            epson.scan.lib.ScannerConnection.disconnectIfSimpleAp(r1, r9)
+            r8.sendLog(r0)
+            return r2
+        L_0x0094:
+            epson.scan.i2lib.ImageProcessController r2 = r8.mImageProcessController     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+            r2.startThread()     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+            com.epson.lib.escani2.ScanI2Params r2 = r8.mScanI2Params     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+            com.epson.lib.escani2.ScanI2Params r2 = r2.clone()     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+            com.epson.lib.escani2.EscanI2Lib$ColorMode r3 = r2.colorMode     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+            com.epson.lib.escani2.EscanI2Lib$ColorMode r4 = com.epson.lib.escani2.EscanI2Lib.ColorMode.MONO_1BIT     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+            if (r3 != r4) goto L_0x00a9
+            com.epson.lib.escani2.EscanI2Lib$ColorMode r3 = com.epson.lib.escani2.EscanI2Lib.ColorMode.GRAYSCALE_8BIT     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+            r2.colorMode = r3     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+        L_0x00a9:
+            epson.scan.i2lib.ImageProcessController r3 = r8.mImageProcessController     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+            java.lang.String[] r3 = r3.getScanOutFilenameFormat()     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+            r8.checkCancel()     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+            com.epson.lib.escani2.ScanI2Runner r4 = r8.mScanI2Runner     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+            epson.scan.i2lib.I2ScanTask$TaskObserver r6 = new epson.scan.i2lib.I2ScanTask$TaskObserver     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+            r7 = 0
+            r6.<init>(r8, r7)     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+            int r2 = r4.doScan(r9, r2, r3, r6)     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+            boolean r3 = r8.mCancelRequested     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+            if (r3 == 0) goto L_0x00c9
+            epson.scan.i2lib.ImageProcessController r3 = r8.mImageProcessController     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+            r3.cancelThread()     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+            r3 = 0
+            goto L_0x00cf
+        L_0x00c9:
+            epson.scan.i2lib.ImageProcessController r3 = r8.mImageProcessController     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+            r3.requestFinishThread()     // Catch:{ LocalCancel -> 0x0137, EscanLibException -> 0x0134, all -> 0x0130 }
+            r3 = 1
+        L_0x00cf:
+            if (r2 == 0) goto L_0x00d9
+            if (r2 == r1) goto L_0x00d9
+            epson.scan.i2lib.I2ScanTask$TaskError r4 = new epson.scan.i2lib.I2ScanTask$TaskError     // Catch:{ LocalCancel -> 0x012e, EscanLibException -> 0x012b, all -> 0x0128 }
+            r4.<init>(r1, r2)     // Catch:{ LocalCancel -> 0x012e, EscanLibException -> 0x012b, all -> 0x0128 }
+            goto L_0x00da
+        L_0x00d9:
+            r4 = r7
+        L_0x00da:
+            epson.scan.i2lib.ImageProcessController r6 = r8.mImageProcessController     // Catch:{ LocalCancel -> 0x012e, EscanLibException -> 0x012b, all -> 0x0128 }
+            boolean r6 = r6.waitUntilThreadEnd()     // Catch:{ LocalCancel -> 0x012e, EscanLibException -> 0x012b, all -> 0x0128 }
+            if (r6 != 0) goto L_0x00e9
+            if (r4 != 0) goto L_0x00e9
+            epson.scan.i2lib.I2ScanTask$TaskError r4 = new epson.scan.i2lib.I2ScanTask$TaskError     // Catch:{ LocalCancel -> 0x012e, EscanLibException -> 0x012b, all -> 0x0128 }
+            r4.<init>(r1, r5)     // Catch:{ LocalCancel -> 0x012e, EscanLibException -> 0x012b, all -> 0x0128 }
+        L_0x00e9:
+            r8.convertFile()     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            if (r4 == 0) goto L_0x00fd
+            android.content.Context r0 = r8.mApplicationContext
+            int r0 = com.epson.iprint.prtlogger.Analytics.getConnectionType(r0)
+            android.content.Context r1 = r8.mApplicationContext
+            epson.scan.lib.ScannerConnection.disconnectIfSimpleAp(r1, r9)
+            r8.sendLog(r0)
+            return r4
+        L_0x00fd:
+            java.util.ArrayList<java.lang.String> r3 = r8.mResScanFileList     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            boolean r3 = r3.isEmpty()     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            if (r3 == 0) goto L_0x0119
+            epson.scan.i2lib.I2ScanTask$TaskError r3 = new epson.scan.i2lib.I2ScanTask$TaskError     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            r3.<init>(r1, r2)     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            android.content.Context r0 = r8.mApplicationContext
+            int r0 = com.epson.iprint.prtlogger.Analytics.getConnectionType(r0)
+            android.content.Context r1 = r8.mApplicationContext
+            epson.scan.lib.ScannerConnection.disconnectIfSimpleAp(r1, r9)
+            r8.sendLog(r0)
+            return r3
+        L_0x0119:
+            android.content.Context r0 = r8.mApplicationContext
+            int r0 = com.epson.iprint.prtlogger.Analytics.getConnectionType(r0)
+            android.content.Context r1 = r8.mApplicationContext
+            epson.scan.lib.ScannerConnection.disconnectIfSimpleAp(r1, r9)
+            r8.sendLog(r0)
+            return r7
+        L_0x0128:
+            r1 = move-exception
+            r0 = r3
+            goto L_0x018f
+        L_0x012b:
+            r2 = move-exception
+            r0 = r3
+            goto L_0x0150
+        L_0x012e:
+            r0 = r3
+            goto L_0x0174
+        L_0x0130:
+            r0 = move-exception
+            r1 = r0
+            r0 = 1
+            goto L_0x018f
+        L_0x0134:
+            r2 = move-exception
+            r0 = 1
+            goto L_0x0150
+        L_0x0137:
+            r0 = 1
+            goto L_0x0174
+        L_0x0139:
+            epson.scan.i2lib.I2ScanTask$TaskError r2 = new epson.scan.i2lib.I2ScanTask$TaskError     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            r2.<init>(r1, r5)     // Catch:{ LocalCancel -> 0x0174, EscanLibException -> 0x014f }
+            android.content.Context r0 = r8.mApplicationContext
+            int r0 = com.epson.iprint.prtlogger.Analytics.getConnectionType(r0)
+            android.content.Context r1 = r8.mApplicationContext
+            epson.scan.lib.ScannerConnection.disconnectIfSimpleAp(r1, r9)
+            r8.sendLog(r0)
+            return r2
+        L_0x014d:
+            r1 = move-exception
+            goto L_0x018f
+        L_0x014f:
+            r2 = move-exception
+        L_0x0150:
+            epson.scan.i2lib.ImageProcessController r3 = r8.mImageProcessController     // Catch:{ all -> 0x014d }
+            r3.cancelThread()     // Catch:{ all -> 0x014d }
+            epson.scan.i2lib.I2ScanTask$TaskError r3 = new epson.scan.i2lib.I2ScanTask$TaskError     // Catch:{ all -> 0x014d }
+            int r2 = r2.getEscanLibErrorCode()     // Catch:{ all -> 0x014d }
+            r3.<init>(r1, r2)     // Catch:{ all -> 0x014d }
+            if (r0 == 0) goto L_0x0165
+            epson.scan.i2lib.ImageProcessController r0 = r8.mImageProcessController
+            r0.cancelThread()
+        L_0x0165:
+            android.content.Context r0 = r8.mApplicationContext
+            int r0 = com.epson.iprint.prtlogger.Analytics.getConnectionType(r0)
+            android.content.Context r1 = r8.mApplicationContext
+            epson.scan.lib.ScannerConnection.disconnectIfSimpleAp(r1, r9)
+            r8.sendLog(r0)
+            return r3
+        L_0x0174:
+            epson.scan.i2lib.I2ScanTask$TaskError r2 = new epson.scan.i2lib.I2ScanTask$TaskError     // Catch:{ all -> 0x014d }
+            r2.<init>(r1, r1)     // Catch:{ all -> 0x014d }
+            if (r0 == 0) goto L_0x0180
+            epson.scan.i2lib.ImageProcessController r0 = r8.mImageProcessController
+            r0.cancelThread()
+        L_0x0180:
+            android.content.Context r0 = r8.mApplicationContext
+            int r0 = com.epson.iprint.prtlogger.Analytics.getConnectionType(r0)
+            android.content.Context r1 = r8.mApplicationContext
+            epson.scan.lib.ScannerConnection.disconnectIfSimpleAp(r1, r9)
+            r8.sendLog(r0)
+            return r2
+        L_0x018f:
+            if (r0 == 0) goto L_0x0196
+            epson.scan.i2lib.ImageProcessController r0 = r8.mImageProcessController
+            r0.cancelThread()
+        L_0x0196:
+            android.content.Context r0 = r8.mApplicationContext
+            int r0 = com.epson.iprint.prtlogger.Analytics.getConnectionType(r0)
+            android.content.Context r2 = r8.mApplicationContext
+            epson.scan.lib.ScannerConnection.disconnectIfSimpleAp(r2, r9)
+            r8.sendLog(r0)
+            throw r1
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.scan.i2lib.I2ScanTask.doInBackground(java.lang.Void[]):epson.scan.i2lib.I2ScanTask$TaskError");
+    }
+
+    private void sendLog(int i) {
+        CommonLog commonLog = this.mCommonLog;
+        if (commonLog != null) {
+            commonLog.connectionType = i;
+            commonLog.numberOfSheet = getScanFileList().size();
+            if (this.mCommonLog.action == 0) {
+                this.mCommonLog.action = PrintLog.ACTION_SCAN;
+            }
+            ScannerPropertyWrapper scannerPropertyWrapper = this.mScannerPropertyWrapper;
+            if (scannerPropertyWrapper != null) {
+                this.mCommonLog.printerName = scannerPropertyWrapper.getModelName();
+            }
+            if (this.mCommonLog.numberOfSheet > 0) {
+                Analytics.sendScanI1Log(this.mApplicationContext, convertScanParams(this.mScanI2Params), this.mCommonLog, ScanContinueParam.isContinueScanning());
+            }
+        }
+    }
+
+    private I1ScanParams convertScanParams(@NonNull ScanI2Params scanI2Params) {
+        I1ScanParams i1ScanParams = new I1ScanParams();
+        if (C24451.$SwitchMap$com$epson$lib$escani2$EscanI2Lib$InputUnit[scanI2Params.inputUnit.ordinal()] != 1) {
+            i1ScanParams.inputDevice = 0;
+        } else {
+            i1ScanParams.inputDevice = 1;
+        }
+        switch (scanI2Params.colorMode) {
+            case MONO_1BIT:
+                i1ScanParams.colorType = 3;
+                break;
+            case GRAYSCALE_8BIT:
+                i1ScanParams.colorType = 2;
+                break;
+            default:
+                i1ScanParams.colorType = 1;
+                break;
+        }
+        i1ScanParams.resolution = scanI2Params.resolutionMain;
+        i1ScanParams.twoSide = scanI2Params.duplex ? 1 : 0;
+        if (C24451.$SwitchMap$com$epson$lib$escani2$EscanI2Lib$Gamma[scanI2Params.userGamma.ordinal()] != 1) {
+            i1ScanParams.gamma = 1;
+        } else {
+            i1ScanParams.gamma = 0;
+        }
+        i1ScanParams.brightness = 255 - scanI2Params.density;
+        if (scanI2Params.colorMode != EscanI2Lib.ColorMode.MONO_1BIT) {
+            i1ScanParams.brightness = 127;
+        }
+        return i1ScanParams;
+    }
+
+    /* renamed from: epson.scan.i2lib.I2ScanTask$1 */
+    static /* synthetic */ class C24451 {
+        static final /* synthetic */ int[] $SwitchMap$com$epson$lib$escani2$EscanI2Lib$Gamma = new int[EscanI2Lib.Gamma.values().length];
+        static final /* synthetic */ int[] $SwitchMap$com$epson$lib$escani2$EscanI2Lib$InputUnit = new int[EscanI2Lib.InputUnit.values().length];
+
+        /* JADX WARNING: Can't wrap try/catch for region: R(17:0|1|2|3|5|6|7|9|10|11|12|13|14|15|17|18|(3:19|20|22)) */
+        /* JADX WARNING: Failed to process nested try/catch */
+        /* JADX WARNING: Missing exception handler attribute for start block: B:11:0x0032 */
+        /* JADX WARNING: Missing exception handler attribute for start block: B:13:0x003c */
+        /* JADX WARNING: Missing exception handler attribute for start block: B:19:0x005a */
+        static {
+            /*
+                com.epson.lib.escani2.EscanI2Lib$Gamma[] r0 = com.epson.lib.escani2.EscanI2Lib.Gamma.values()
+                int r0 = r0.length
+                int[] r0 = new int[r0]
+                $SwitchMap$com$epson$lib$escani2$EscanI2Lib$Gamma = r0
+                r0 = 1
+                int[] r1 = $SwitchMap$com$epson$lib$escani2$EscanI2Lib$Gamma     // Catch:{ NoSuchFieldError -> 0x0014 }
+                com.epson.lib.escani2.EscanI2Lib$Gamma r2 = com.epson.lib.escani2.EscanI2Lib.Gamma.GAMMA_100     // Catch:{ NoSuchFieldError -> 0x0014 }
+                int r2 = r2.ordinal()     // Catch:{ NoSuchFieldError -> 0x0014 }
+                r1[r2] = r0     // Catch:{ NoSuchFieldError -> 0x0014 }
+            L_0x0014:
+                r1 = 2
+                int[] r2 = $SwitchMap$com$epson$lib$escani2$EscanI2Lib$Gamma     // Catch:{ NoSuchFieldError -> 0x001f }
+                com.epson.lib.escani2.EscanI2Lib$Gamma r3 = com.epson.lib.escani2.EscanI2Lib.Gamma.GAMMA_180     // Catch:{ NoSuchFieldError -> 0x001f }
+                int r3 = r3.ordinal()     // Catch:{ NoSuchFieldError -> 0x001f }
+                r2[r3] = r1     // Catch:{ NoSuchFieldError -> 0x001f }
+            L_0x001f:
+                com.epson.lib.escani2.EscanI2Lib$ColorMode[] r2 = com.epson.lib.escani2.EscanI2Lib.ColorMode.values()
+                int r2 = r2.length
+                int[] r2 = new int[r2]
+                $SwitchMap$com$epson$lib$escani2$EscanI2Lib$ColorMode = r2
+                int[] r2 = $SwitchMap$com$epson$lib$escani2$EscanI2Lib$ColorMode     // Catch:{ NoSuchFieldError -> 0x0032 }
+                com.epson.lib.escani2.EscanI2Lib$ColorMode r3 = com.epson.lib.escani2.EscanI2Lib.ColorMode.MONO_1BIT     // Catch:{ NoSuchFieldError -> 0x0032 }
+                int r3 = r3.ordinal()     // Catch:{ NoSuchFieldError -> 0x0032 }
+                r2[r3] = r0     // Catch:{ NoSuchFieldError -> 0x0032 }
+            L_0x0032:
+                int[] r2 = $SwitchMap$com$epson$lib$escani2$EscanI2Lib$ColorMode     // Catch:{ NoSuchFieldError -> 0x003c }
+                com.epson.lib.escani2.EscanI2Lib$ColorMode r3 = com.epson.lib.escani2.EscanI2Lib.ColorMode.GRAYSCALE_8BIT     // Catch:{ NoSuchFieldError -> 0x003c }
+                int r3 = r3.ordinal()     // Catch:{ NoSuchFieldError -> 0x003c }
+                r2[r3] = r1     // Catch:{ NoSuchFieldError -> 0x003c }
+            L_0x003c:
+                int[] r2 = $SwitchMap$com$epson$lib$escani2$EscanI2Lib$ColorMode     // Catch:{ NoSuchFieldError -> 0x0047 }
+                com.epson.lib.escani2.EscanI2Lib$ColorMode r3 = com.epson.lib.escani2.EscanI2Lib.ColorMode.COLOR_24BIT     // Catch:{ NoSuchFieldError -> 0x0047 }
+                int r3 = r3.ordinal()     // Catch:{ NoSuchFieldError -> 0x0047 }
+                r4 = 3
+                r2[r3] = r4     // Catch:{ NoSuchFieldError -> 0x0047 }
+            L_0x0047:
+                com.epson.lib.escani2.EscanI2Lib$InputUnit[] r2 = com.epson.lib.escani2.EscanI2Lib.InputUnit.values()
+                int r2 = r2.length
+                int[] r2 = new int[r2]
+                $SwitchMap$com$epson$lib$escani2$EscanI2Lib$InputUnit = r2
+                int[] r2 = $SwitchMap$com$epson$lib$escani2$EscanI2Lib$InputUnit     // Catch:{ NoSuchFieldError -> 0x005a }
+                com.epson.lib.escani2.EscanI2Lib$InputUnit r3 = com.epson.lib.escani2.EscanI2Lib.InputUnit.ADF     // Catch:{ NoSuchFieldError -> 0x005a }
+                int r3 = r3.ordinal()     // Catch:{ NoSuchFieldError -> 0x005a }
+                r2[r3] = r0     // Catch:{ NoSuchFieldError -> 0x005a }
+            L_0x005a:
+                int[] r0 = $SwitchMap$com$epson$lib$escani2$EscanI2Lib$InputUnit     // Catch:{ NoSuchFieldError -> 0x0064 }
+                com.epson.lib.escani2.EscanI2Lib$InputUnit r2 = com.epson.lib.escani2.EscanI2Lib.InputUnit.FLATBED     // Catch:{ NoSuchFieldError -> 0x0064 }
+                int r2 = r2.ordinal()     // Catch:{ NoSuchFieldError -> 0x0064 }
+                r0[r2] = r1     // Catch:{ NoSuchFieldError -> 0x0064 }
+            L_0x0064:
+                return
+            */
+            throw new UnsupportedOperationException("Method not decompiled: epson.scan.i2lib.I2ScanTask.C24451.<clinit>():void");
+        }
+    }
+
+    private int checkScanParams(@NonNull File file, @NonNull ScanI2Params scanI2Params, @NonNull ScannerI2Info scannerI2Info) {
+        int[] validScanSize = scanI2Params.scanSize.getValidScanSize(scannerI2Info, scanI2Params);
+        if (validScanSize == null) {
+            return 1;
+        }
+        if (file.getFreeSpace() < ((long) ((scanI2Params.inputUnit == EscanI2Lib.InputUnit.ADF ? ScanContinueParam.getAvailableScanPageCount() : 1) + 1)) * ((long) (validScanSize[0] * validScanSize[1] * 3))) {
+            return 2;
+        }
+        return 0;
+    }
+
+    private String probeScanner(Context context, ScannerPropertyWrapper scannerPropertyWrapper) throws EscanLibException {
+        synchronized (this) {
+            this.mCancelableScannerProbe = new CancelableScannerProbe();
+        }
+        String probeScanner = this.mCancelableScannerProbe.probeScanner(scannerPropertyWrapper, context);
+        synchronized (this) {
+            this.mCancelableScannerProbe = null;
+        }
+        return probeScanner;
+    }
+
+    private void convertFile() {
+        this.mResScanFileList = this.mImageProcessController.getScanFiles(this.mScanI2Runner.getScanPages());
+    }
+
+    /* access modifiers changed from: package-private */
+    @VisibleForTesting
+    public void scanProgressCallback(int i, int i2) {
+        this.mImageProcessController.putScanResult(i, i2);
+    }
+
+    /* access modifiers changed from: protected */
+    public void onPostExecute(TaskError taskError) {
+        ScanResultReceiver scanResultReceiver = this.mScanResultReceiver;
+        if (scanResultReceiver != null) {
+            scanResultReceiver.onScanEnd(taskError);
+        }
+    }
+
+    public void cancelScan() {
+        this.mCancelRequested = true;
+        synchronized (this) {
+            if (this.mCancelableScannerProbe != null) {
+                this.mCancelableScannerProbe.cancel();
+            }
+        }
+        this.mScanI2Runner.cancelScan();
+        this.mImageProcessController.cancelThread();
+    }
+
+    private void checkCancel() throws LocalCancel {
+        if (this.mCancelRequested) {
+            throw new LocalCancel();
+        }
+    }
+
+    /* access modifiers changed from: package-private */
+    public void onImageProcessEnd(int i, int i2) {
+        ScanResultReceiver scanResultReceiver = this.mScanResultReceiver;
+        if (scanResultReceiver != null) {
+            scanResultReceiver.onProgressUpdate(i, i2);
+        }
+    }
+
+    private class TaskObserver implements EscanI2Lib.Observer {
+        private TaskObserver() {
+        }
+
+        /* synthetic */ TaskObserver(I2ScanTask i2ScanTask, C24451 r2) {
+            this();
+        }
+
+        public void update(int i, int i2) {
+            if (i2 > 0) {
+                I2ScanTask.this.scanProgressCallback(i, i2 - 1);
+            }
+        }
+    }
+
+    public static class TaskError {
+        public static final int ERROR_SD_CARD_NOT_MOUNTED = 2;
+        public static final int ESC_I2_ERROR = 1;
+        public static final int OTHER_ERROR = 2;
+        public static final int OTHER_ERROR_INVALID_SCAN_AREA = 3;
+        public int error1;
+        public int error2;
+
+        public TaskError(int i, int i2) {
+            this.error1 = i;
+            this.error2 = i2;
+        }
+
+        public boolean isCancel() {
+            return this.error1 == 1 && this.error2 == 1;
+        }
+
+        public static boolean isInvalidScanArea(@Nullable TaskError taskError) {
+            return taskError != null && taskError.error1 == 2 && taskError.error2 == 3;
+        }
+    }
+
+    static class LocalCancel extends Throwable {
+        LocalCancel() {
+        }
+    }
+}

+ 257 - 0
app/src/main/java/epson/scan/i2lib/ImageProcessController.java

@@ -0,0 +1,257 @@
+package epson.scan.i2lib;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.VisibleForTesting;
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Locale;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.LinkedBlockingDeque;
+
+public class ImageProcessController {
+    private static final String LOG_TAG = "ImageProcessController";
+    private boolean mBackSideRotate180;
+    private int mBlackAndWhiteThresh;
+    private LinkedBlockingDeque<ImageProcessInfo> mBlockingDeque = new LinkedBlockingDeque<>();
+    private volatile boolean mCancelRequested;
+    private boolean mConvertBlackAndWhite;
+    private boolean mDuplex;
+    private boolean mError;
+    private I2ScanTask mI2ScanTask;
+    private String[] mImageProcessOutFilenameFormat;
+    private ImageProcessThread mImageProcessThread;
+    private final CountDownLatch mProcessEndLatch = new CountDownLatch(1);
+    private String[] mScanOutFilenameFormat;
+
+    public ImageProcessController(@NonNull I2ScanTask i2ScanTask, boolean z, int i, int i2, boolean z2, int i3) {
+        this.mI2ScanTask = i2ScanTask;
+        this.mDuplex = z;
+        this.mConvertBlackAndWhite = z2;
+        this.mBlackAndWhiteThresh = i3;
+        setBackSideRotation(i, i2);
+    }
+
+    private void setBackSideRotation(int i, int i2) {
+        if (this.mDuplex) {
+            boolean z = true;
+            if (i2 != 0) {
+                if (i != 1) {
+                    z = false;
+                }
+                this.mBackSideRotate180 = z;
+                return;
+            }
+            if (i != 0) {
+                z = false;
+            }
+            this.mBackSideRotate180 = z;
+            return;
+        }
+        this.mBackSideRotate180 = false;
+    }
+
+    /* access modifiers changed from: package-private */
+    @NonNull
+    public ArrayList<String> getScanFiles(int[] iArr) {
+        int i = this.mDuplex ? 2 : 1;
+        ArrayList<String> arrayList = new ArrayList<>();
+        int i2 = 0;
+        while (true) {
+            for (int i3 = 0; i3 < i; i3++) {
+                if (i2 >= iArr[i3]) {
+                    return arrayList;
+                }
+                File allProcessFile = getAllProcessFile(i3, i2);
+                if (!allProcessFile.canRead()) {
+                    return arrayList;
+                }
+                arrayList.add(allProcessFile.getPath());
+            }
+            i2++;
+        }
+    }
+
+    public void init(File file, Calendar calendar) {
+        makeScanFilenameFormat(file, calendar);
+    }
+
+    public void startThread() {
+        checkStatus();
+        this.mImageProcessThread = new ImageProcessThread(this, this.mBlackAndWhiteThresh);
+        this.mImageProcessThread.start();
+    }
+
+    public void cancelThread() {
+        this.mCancelRequested = true;
+        if (this.mImageProcessThread == null) {
+            this.mProcessEndLatch.countDown();
+            return;
+        }
+        this.mBlockingDeque.clear();
+        try {
+            this.mBlockingDeque.putFirst(ImageProcessInfo.getEndRequestInfo());
+        } catch (InterruptedException unused) {
+            this.mProcessEndLatch.countDown();
+        }
+    }
+
+    public void requestFinishThread() {
+        checkThreadStatus();
+        try {
+            this.mBlockingDeque.putLast(ImageProcessInfo.getEndRequestInfo());
+        } catch (InterruptedException unused) {
+            this.mProcessEndLatch.countDown();
+        }
+    }
+
+    public boolean waitUntilThreadEnd() {
+        try {
+            this.mProcessEndLatch.await();
+            return !this.mError;
+        } catch (InterruptedException unused) {
+            return false;
+        }
+    }
+
+    @NonNull
+    public String[] getScanOutFilenameFormat() {
+        checkStatus();
+        return this.mScanOutFilenameFormat;
+    }
+
+    public File getAllProcessFile(int i, int i2) {
+        checkStatus();
+        return getFile((getProcessType(i, i2) == ImageProcessInfo.PROCESS_TYPE_EMPTY ? this.mScanOutFilenameFormat : this.mImageProcessOutFilenameFormat)[i], i2);
+    }
+
+    private static File getFile(String str, int i) {
+        return new File(String.format(Locale.US, str, new Object[]{Integer.valueOf(i)}));
+    }
+
+    private void checkStatus() {
+        if (this.mScanOutFilenameFormat == null) {
+            throw new IllegalStateException("init() is not called");
+        }
+    }
+
+    private void checkThreadStatus() {
+        if (this.mImageProcessThread == null) {
+            throw new IllegalStateException("startThread() is not called");
+        }
+    }
+
+    private void makeScanFilenameFormat(@NonNull File file, @NonNull Calendar calendar) {
+        File file2 = new File(file, geDateFormat(calendar) + "a_%d.jpg");
+        this.mScanOutFilenameFormat = new String[]{file2.toString(), new File(file, geDateFormat(calendar) + "b_%d.jpg").toString()};
+        File file3 = new File(file, geDateFormat(calendar) + "a2_%d.jpg");
+        this.mImageProcessOutFilenameFormat = new String[]{file3.toString(), new File(file, geDateFormat(calendar) + "b2_%d.jpg").toString()};
+    }
+
+    @VisibleForTesting
+    @NonNull
+    static String geDateFormat(@NonNull Calendar calendar) {
+        return new SimpleDateFormat("MMdd_HHmmss_SSS", Locale.US).format(calendar.getTime());
+    }
+
+    public boolean putScanResult(int i, int i2) {
+        String str;
+        checkThreadStatus();
+        if (this.mCancelRequested) {
+            return true;
+        }
+        int processType = getProcessType(i, i2);
+        String path = getFile(this.mScanOutFilenameFormat[i], i2).getPath();
+        if (processType == ImageProcessInfo.PROCESS_TYPE_EMPTY) {
+            str = null;
+        } else {
+            str = getAllProcessFile(i, i2).getPath();
+        }
+        try {
+            this.mBlockingDeque.putLast(new ImageProcessInfo(processType, path, str, i, i2));
+            return true;
+        } catch (InterruptedException unused) {
+            this.mProcessEndLatch.countDown();
+            return false;
+        }
+    }
+
+    public ImageProcessInfo checkNexImageProcessRequest() throws InterruptedException {
+        return this.mBlockingDeque.takeFirst();
+    }
+
+    public void putImageProcessEnd(@NonNull ImageProcessInfo imageProcessInfo, boolean z) {
+        if (imageProcessInfo.endRequested() || !z) {
+            this.mError = !z;
+            this.mProcessEndLatch.countDown();
+            return;
+        }
+        this.mI2ScanTask.onImageProcessEnd(imageProcessInfo.getSide(), imageProcessInfo.getPage());
+    }
+
+    private int getProcessType(int i, int i2) {
+        int i3 = ImageProcessInfo.PROCESS_TYPE_EMPTY;
+        if (i == 1 && this.mBackSideRotate180) {
+            i3 |= ImageProcessInfo.PROCESS_TYPE_ROTATE_180;
+        }
+        return this.mConvertBlackAndWhite ? i3 | ImageProcessInfo.PROCESS_TYPE_BLACK_AND_WHITE : i3;
+    }
+
+    public static class ImageProcessInfo {
+        public static int PROCESS_TYPE_BLACK_AND_WHITE = 32;
+        public static int PROCESS_TYPE_EMPTY = 0;
+        public static int PROCESS_TYPE_END = 1;
+        public static int PROCESS_TYPE_ROTATE_180 = 16;
+        private String mInputFilename;
+        private String mOutputFilename;
+        private int mPage;
+        private int mProcessType;
+        private int mSide;
+
+        @NonNull
+        public static ImageProcessInfo getEndRequestInfo() {
+            return new ImageProcessInfo(PROCESS_TYPE_END, (String) null, (String) null, -1, -1);
+        }
+
+        public ImageProcessInfo(int i, String str, String str2, int i2, int i3) {
+            this.mProcessType = i;
+            this.mInputFilename = str;
+            this.mOutputFilename = str2;
+            this.mSide = i2;
+            this.mPage = i3;
+        }
+
+        public String getInputFilename() {
+            return this.mInputFilename;
+        }
+
+        public String getOutputFilename() {
+            return this.mOutputFilename;
+        }
+
+        public int getProcessType() {
+            return this.mProcessType;
+        }
+
+        public boolean rotate180() {
+            return (this.mProcessType & PROCESS_TYPE_ROTATE_180) != 0;
+        }
+
+        public boolean blackAndWhite() {
+            return (this.mProcessType & PROCESS_TYPE_BLACK_AND_WHITE) != 0;
+        }
+
+        public boolean endRequested() {
+            return (this.mProcessType & PROCESS_TYPE_END) != 0;
+        }
+
+        public int getSide() {
+            return this.mSide;
+        }
+
+        public int getPage() {
+            return this.mPage;
+        }
+    }
+}

+ 112 - 0
app/src/main/java/epson/scan/i2lib/ImageProcessThread.java

@@ -0,0 +1,112 @@
+package epson.scan.i2lib;
+
+import android.support.annotation.NonNull;
+import epson.scan.i2lib.ImageProcessController;
+import org.opencv.core.Core;
+import org.opencv.core.Mat;
+import org.opencv.imgcodecs.Imgcodecs;
+import org.opencv.imgproc.Imgproc;
+
+public class ImageProcessThread extends Thread {
+    private static final String LOG_TAG = "ImageProcessThread";
+    private final int mBlackAndWhiteThreshold;
+    private final ImageProcessController mImageProcessController;
+
+    static {
+        System.loadLibrary("opencv_java3");
+    }
+
+    public ImageProcessThread(@NonNull ImageProcessController imageProcessController, int i) {
+        super(LOG_TAG);
+        this.mImageProcessController = imageProcessController;
+        this.mBlackAndWhiteThreshold = i;
+    }
+
+    public void run() {
+        while (!isInterrupted()) {
+            try {
+                ImageProcessController.ImageProcessInfo checkNexImageProcessRequest = this.mImageProcessController.checkNexImageProcessRequest();
+                if (checkNexImageProcessRequest.endRequested()) {
+                    this.mImageProcessController.putImageProcessEnd(checkNexImageProcessRequest, true);
+                    return;
+                } else if (!processImage(checkNexImageProcessRequest, this.mBlackAndWhiteThreshold)) {
+                    this.mImageProcessController.putImageProcessEnd(checkNexImageProcessRequest, false);
+                    return;
+                } else {
+                    this.mImageProcessController.putImageProcessEnd(checkNexImageProcessRequest, true);
+                }
+            } catch (InterruptedException unused) {
+                return;
+            }
+        }
+    }
+
+    /* JADX WARNING: Removed duplicated region for block: B:12:0x0031  */
+    /* JADX WARNING: Removed duplicated region for block: B:15:0x0044 A[RETURN] */
+    /* JADX WARNING: Removed duplicated region for block: B:17:? A[RETURN, SYNTHETIC] */
+    /* Code decompiled incorrectly, please refer to instructions dump. */
+    private boolean processImage(@android.support.annotation.NonNull epson.scan.i2lib.ImageProcessController.ImageProcessInfo r6, int r7) {
+        /*
+            r5 = this;
+            boolean r0 = r6.rotate180()
+            boolean r1 = r6.blackAndWhite()
+            if (r0 != 0) goto L_0x000c
+            if (r1 == 0) goto L_0x0045
+        L_0x000c:
+            org.opencv.core.Mat r2 = new org.opencv.core.Mat
+            r2.<init>()
+            java.lang.String r3 = r6.getInputFilename()
+            org.opencv.core.Mat r3 = openImageFile(r3)
+            r4 = 0
+            if (r3 != 0) goto L_0x001d
+            return r4
+        L_0x001d:
+            if (r1 == 0) goto L_0x002d
+            blackAndWhite(r3, r2, r7)
+            if (r0 == 0) goto L_0x002d
+            r3.release()
+            org.opencv.core.Mat r7 = new org.opencv.core.Mat
+            r7.<init>()
+            goto L_0x002f
+        L_0x002d:
+            r7 = r2
+            r2 = r3
+        L_0x002f:
+            if (r0 == 0) goto L_0x0034
+            rotate180(r2, r7)
+        L_0x0034:
+            java.lang.String r6 = r6.getOutputFilename()
+            boolean r6 = org.opencv.imgcodecs.Imgcodecs.imwrite(r6, r7)
+            r7.release()
+            r2.release()
+            if (r6 != 0) goto L_0x0045
+            return r4
+        L_0x0045:
+            r6 = 1
+            return r6
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.scan.i2lib.ImageProcessThread.processImage(epson.scan.i2lib.ImageProcessController$ImageProcessInfo, int):boolean");
+    }
+
+    private static Mat openImageFile(@NonNull String str) {
+        Mat imread = Imgcodecs.imread(str, -1);
+        if (imread != null && imread.width() > 0 && imread.height() > 0) {
+            return imread;
+        }
+        return null;
+    }
+
+    private static void rotate180(@NonNull Mat mat, @NonNull Mat mat2) {
+        if (mat.width() <= 0 || mat.height() <= 0) {
+            throw new IllegalArgumentException("orgImage size error");
+        }
+        Core.flip(mat, mat2, -1);
+    }
+
+    private static void blackAndWhite(@NonNull Mat mat, @NonNull Mat mat2, int i) {
+        if (mat.width() <= 0 || mat.height() <= 0) {
+            throw new IllegalArgumentException("orgImage size error");
+        }
+        Imgproc.threshold(mat, mat2, (double) i, 255.0d, 0);
+    }
+}

+ 54 - 0
app/src/main/java/epson/scan/lib/CancelableFind.java

@@ -0,0 +1,54 @@
+package epson.scan.lib;
+
+import android.content.Context;
+import android.os.Handler;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+public class CancelableFind {
+    private static final Object sLock = new Object();
+    private final String TAG = "CFind";
+    private volatile boolean isFinishSearchScanner = false;
+    private volatile boolean mCanceled = false;
+    private escanLib mEscanLib;
+
+    public void setEscanLib(escanLib escanlib) {
+        this.mEscanLib = escanlib;
+    }
+
+    public int findScanner(@NonNull Context context, @Nullable Handler handler) {
+        int escanWrapperFindScanner;
+        if (this.mCanceled) {
+            return 40;
+        }
+        synchronized (sLock) {
+            this.isFinishSearchScanner = false;
+            this.mEscanLib.setSearchStt(true);
+            this.mEscanLib.resetIPAdressCheck();
+            escanWrapperFindScanner = this.mEscanLib.escanWrapperFindScanner(60);
+            this.mEscanLib.setSearchStt(false);
+            this.mEscanLib.setJobDone(true);
+            this.isFinishSearchScanner = true;
+            if (escanWrapperFindScanner == -1051) {
+                throw new IllegalStateException("escanWrapperFindScanner() returns ESCAN_ERR_LIB_NOT_INITIALIZED");
+            }
+        }
+        return escanWrapperFindScanner;
+    }
+
+    public void cancel() {
+        if (!this.isFinishSearchScanner) {
+            this.isFinishSearchScanner = true;
+            this.mCanceled = true;
+            escanLib escanlib = this.mEscanLib;
+            if (escanlib != null) {
+                escanlib.setSearchStt(false);
+                this.mEscanLib.escanWrapperCancelFindScanner();
+            }
+        }
+    }
+
+    public boolean isCanceled() {
+        return this.mCanceled;
+    }
+}

+ 79 - 0
app/src/main/java/epson/scan/lib/CancelablePropertyTaker.java

@@ -0,0 +1,79 @@
+package epson.scan.lib;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import com.epson.lib.escani2.I2LibScannerInfoAndCapability;
+import com.epson.lib.escani2.ScanI2PropertyTaker;
+import epson.print.MyPrinter;
+import epson.scan.activity.ScannerPropertyWrapper;
+
+public class CancelablePropertyTaker {
+    private volatile boolean mCancelRequested;
+    private escanLib mEscanLib;
+
+    public CancelablePropertyTaker(@NonNull escanLib escanlib) {
+        this.mEscanLib = escanlib;
+    }
+
+    @Nullable
+    public ScannerPropertyWrapper getScannerProperty(MyPrinter myPrinter) throws EscanLibException {
+        ScannerPropertyWrapper scannerPropertyWrapper;
+        ScannerInfo instance = ScannerInfo.getInstance();
+        instance.setLocation(myPrinter.getLocation());
+        instance.setModelName(myPrinter.getName());
+        instance.setScannerId(myPrinter.getScannerId());
+        instance.setIp(myPrinter.getIp());
+        String scannerId = instance.getScannerId();
+        if (scannerId == null || scannerId.isEmpty()) {
+            scannerId = null;
+        }
+        this.mEscanLib.resetEscanLib();
+        if (this.mCancelRequested) {
+            return null;
+        }
+        int probeScannerByIp = this.mEscanLib.probeScannerByIp(scannerId, instance.getIp());
+        if (probeScannerByIp != 0) {
+            throw new EscanLibException(probeScannerByIp);
+        } else if (this.mCancelRequested) {
+            return null;
+        } else {
+            if (instance.getScannerId() == null || instance.getScannerId().length() <= 0) {
+                instance.setScannerId(this.mEscanLib.getListFoundScanner().get(0).getScannerId());
+            }
+            int escIVersion = this.mEscanLib.getEscIVersion(0);
+            if (this.mCancelRequested) {
+                return null;
+            }
+            if (escIVersion != 2) {
+                int i1SupportedOptions = ScanSettingHelper.getI1SupportedOptions(this.mEscanLib, instance);
+                if (i1SupportedOptions == 0) {
+                    scannerPropertyWrapper = new ScannerPropertyWrapper(instance);
+                } else {
+                    throw new EscanLibException(i1SupportedOptions);
+                }
+            } else {
+                ScanI2PropertyTaker scanI2PropertyTaker = new ScanI2PropertyTaker();
+                I2LibScannerInfoAndCapability scannerInfoAndCapability = scanI2PropertyTaker.getScannerInfoAndCapability(myPrinter.getIp());
+                if (scannerInfoAndCapability != null) {
+                    scannerPropertyWrapper = new ScannerPropertyWrapper(instance, scannerInfoAndCapability);
+                } else {
+                    throw new EscanLibException(2, scanI2PropertyTaker.getEscanI2LibError());
+                }
+            }
+            if (this.mCancelRequested) {
+                return null;
+            }
+            return scannerPropertyWrapper;
+        }
+    }
+
+    public void cancel() {
+        this.mCancelRequested = true;
+        this.mEscanLib.escanWrapperCancelFindScanner();
+    }
+
+    @Nullable
+    public static ScannerPropertyWrapper getScannerProperty(escanLib escanlib, MyPrinter myPrinter) throws EscanLibException {
+        return new CancelablePropertyTaker(escanlib).getScannerProperty(myPrinter);
+    }
+}

+ 387 - 0
app/src/main/java/epson/scan/lib/CancelableScannerProbe.java

@@ -0,0 +1,387 @@
+package epson.scan.lib;
+
+import java.util.List;
+
+public class CancelableScannerProbe {
+    private escanLib mEscanLib;
+    private volatile boolean mProbingScanner;
+
+    /*  JADX ERROR: IndexOutOfBoundsException in pass: RegionMakerVisitor
+        java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
+        	at java.util.ArrayList.rangeCheck(ArrayList.java:657)
+        	at java.util.ArrayList.get(ArrayList.java:433)
+        	at jadx.core.dex.nodes.InsnNode.getArg(InsnNode.java:101)
+        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:611)
+        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
+        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
+        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
+        	at jadx.core.dex.visitors.regions.RegionMaker.processMonitorEnter(RegionMaker.java:561)
+        	at jadx.core.dex.visitors.regions.RegionMaker.traverse(RegionMaker.java:133)
+        	at jadx.core.dex.visitors.regions.RegionMaker.makeRegion(RegionMaker.java:86)
+        	at jadx.core.dex.visitors.regions.RegionMaker.processHandlersOutBlocks(RegionMaker.java:1008)
+        	at jadx.core.dex.visitors.regions.RegionMaker.processTryCatchBlocks(RegionMaker.java:978)
+        	at jadx.core.dex.visitors.regions.RegionMakerVisitor.visit(RegionMakerVisitor.java:52)
+        */
+    public java.lang.String probeScanner_test(epson.scan.activity.ScannerPropertyWrapper r7, android.content.Context r8) {
+        /*
+            r6 = this;
+            r0 = 0
+            r6.mEscanLib = r0
+            r1 = 0
+            monitor-enter(r6)     // Catch:{ all -> 0x00d2 }
+            epson.scan.lib.escanLib r2 = new epson.scan.lib.escanLib     // Catch:{ all -> 0x00cf }
+            r2.<init>()     // Catch:{ all -> 0x00cf }
+            r6.mEscanLib = r2     // Catch:{ all -> 0x00cf }
+            monitor-exit(r6)     // Catch:{ all -> 0x00cf }
+            r2 = 0
+        L_0x000e:
+            epson.scan.lib.escanLib r3 = r6.mEscanLib     // Catch:{ all -> 0x00cd }
+            int r3 = r3.escanWrapperInitDriver(r8)     // Catch:{ all -> 0x00cd }
+            r4 = -1050(0xfffffffffffffbe6, float:NaN)
+            r5 = 1
+            if (r3 == r4) goto L_0x0035
+            if (r3 == 0) goto L_0x0033
+            monitor-enter(r6)
+            r6.mProbingScanner = r1     // Catch:{ all -> 0x0030 }
+            monitor-exit(r6)     // Catch:{ all -> 0x0030 }
+            epson.scan.lib.escanLib r7 = r6.mEscanLib
+            if (r7 == 0) goto L_0x0028
+            if (r2 == 0) goto L_0x0028
+            r7.escanWrapperReleaseDriver()
+        L_0x0028:
+            monitor-enter(r6)
+            r6.mEscanLib = r0     // Catch:{ all -> 0x002d }
+            monitor-exit(r6)     // Catch:{ all -> 0x002d }
+            return r0
+        L_0x002d:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x002d }
+            throw r7
+        L_0x0030:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x0030 }
+            throw r7
+        L_0x0033:
+            r2 = 1
+            goto L_0x003a
+        L_0x0035:
+            epson.scan.lib.escanLib r3 = r6.mEscanLib     // Catch:{ all -> 0x00cd }
+            r3.escanWrapperReleaseDriver()     // Catch:{ all -> 0x00cd }
+        L_0x003a:
+            if (r2 == 0) goto L_0x000e
+            java.lang.String r8 = r7.getIp()     // Catch:{ all -> 0x00cd }
+            java.lang.String r3 = r7.getScannerId()     // Catch:{ all -> 0x00cd }
+            monitor-enter(r6)     // Catch:{ all -> 0x00cd }
+            r6.mProbingScanner = r5     // Catch:{ all -> 0x00ca }
+            monitor-exit(r6)     // Catch:{ all -> 0x00ca }
+            if (r8 == 0) goto L_0x00ac
+            boolean r4 = r8.isEmpty()     // Catch:{ all -> 0x00cd }
+            if (r4 != 0) goto L_0x00ac
+            epson.scan.lib.escanLib r4 = r6.mEscanLib     // Catch:{ all -> 0x00cd }
+            int r4 = r4.probeScannerByIp(r3, r8)     // Catch:{ all -> 0x00cd }
+            if (r4 != 0) goto L_0x0070
+            monitor-enter(r6)
+            r6.mProbingScanner = r1     // Catch:{ all -> 0x006d }
+            monitor-exit(r6)     // Catch:{ all -> 0x006d }
+            epson.scan.lib.escanLib r7 = r6.mEscanLib
+            if (r7 == 0) goto L_0x0065
+            if (r2 == 0) goto L_0x0065
+            r7.escanWrapperReleaseDriver()
+        L_0x0065:
+            monitor-enter(r6)
+            r6.mEscanLib = r0     // Catch:{ all -> 0x006a }
+            monitor-exit(r6)     // Catch:{ all -> 0x006a }
+            return r8
+        L_0x006a:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x006a }
+            throw r7
+        L_0x006d:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x006d }
+            throw r7
+        L_0x0070:
+            int r7 = r7.getLocation()     // Catch:{ all -> 0x00cd }
+            if (r7 == r5) goto L_0x008e
+            monitor-enter(r6)
+            r6.mProbingScanner = r1     // Catch:{ all -> 0x008b }
+            monitor-exit(r6)     // Catch:{ all -> 0x008b }
+            epson.scan.lib.escanLib r7 = r6.mEscanLib
+            if (r7 == 0) goto L_0x0083
+            if (r2 == 0) goto L_0x0083
+            r7.escanWrapperReleaseDriver()
+        L_0x0083:
+            monitor-enter(r6)
+            r6.mEscanLib = r0     // Catch:{ all -> 0x0088 }
+            monitor-exit(r6)     // Catch:{ all -> 0x0088 }
+            return r0
+        L_0x0088:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x0088 }
+            throw r7
+        L_0x008b:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x008b }
+            throw r7
+        L_0x008e:
+            epson.scan.lib.escanLib r7 = r6.mEscanLib     // Catch:{ all -> 0x00cd }
+            java.lang.String r7 = localProbeById(r7, r3, r8)     // Catch:{ all -> 0x00cd }
+            monitor-enter(r6)
+            r6.mProbingScanner = r1     // Catch:{ all -> 0x00a9 }
+            monitor-exit(r6)     // Catch:{ all -> 0x00a9 }
+            epson.scan.lib.escanLib r8 = r6.mEscanLib
+            if (r8 == 0) goto L_0x00a1
+            if (r2 == 0) goto L_0x00a1
+            r8.escanWrapperReleaseDriver()
+        L_0x00a1:
+            monitor-enter(r6)
+            r6.mEscanLib = r0     // Catch:{ all -> 0x00a6 }
+            monitor-exit(r6)     // Catch:{ all -> 0x00a6 }
+            return r7
+        L_0x00a6:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x00a6 }
+            throw r7
+        L_0x00a9:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x00a9 }
+            throw r7
+        L_0x00ac:
+            epson.scan.lib.escanLib r7 = r6.mEscanLib     // Catch:{ all -> 0x00cd }
+            java.lang.String r7 = localProbeById(r7, r3, r8)     // Catch:{ all -> 0x00cd }
+            monitor-enter(r6)
+            r6.mProbingScanner = r1     // Catch:{ all -> 0x00c7 }
+            monitor-exit(r6)     // Catch:{ all -> 0x00c7 }
+            epson.scan.lib.escanLib r8 = r6.mEscanLib
+            if (r8 == 0) goto L_0x00bf
+            if (r2 == 0) goto L_0x00bf
+            r8.escanWrapperReleaseDriver()
+        L_0x00bf:
+            monitor-enter(r6)
+            r6.mEscanLib = r0     // Catch:{ all -> 0x00c4 }
+            monitor-exit(r6)     // Catch:{ all -> 0x00c4 }
+            return r7
+        L_0x00c4:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x00c4 }
+            throw r7
+        L_0x00c7:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x00c7 }
+            throw r7
+        L_0x00ca:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x00ca }
+            throw r7     // Catch:{ all -> 0x00cd }
+        L_0x00cd:
+            r7 = move-exception
+            goto L_0x00d4
+        L_0x00cf:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x00cf }
+            throw r7     // Catch:{ all -> 0x00d2 }
+        L_0x00d2:
+            r7 = move-exception
+            r2 = 0
+        L_0x00d4:
+            monitor-enter(r6)
+            r6.mProbingScanner = r1     // Catch:{ all -> 0x00e9 }
+            monitor-exit(r6)     // Catch:{ all -> 0x00e9 }
+            epson.scan.lib.escanLib r8 = r6.mEscanLib
+            if (r8 == 0) goto L_0x00e1
+            if (r2 == 0) goto L_0x00e1
+            r8.escanWrapperReleaseDriver()
+        L_0x00e1:
+            monitor-enter(r6)
+            r6.mEscanLib = r0     // Catch:{ all -> 0x00e6 }
+            monitor-exit(r6)     // Catch:{ all -> 0x00e6 }
+            throw r7
+        L_0x00e6:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x00e6 }
+            throw r7
+        L_0x00e9:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x00e9 }
+            throw r7
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.scan.lib.CancelableScannerProbe.probeScanner_test(epson.scan.activity.ScannerPropertyWrapper, android.content.Context):java.lang.String");
+    }
+
+    /*  JADX ERROR: IndexOutOfBoundsException in pass: RegionMakerVisitor
+        java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
+        	at java.util.ArrayList.rangeCheck(ArrayList.java:657)
+        	at java.util.ArrayList.get(ArrayList.java:433)
+        	at jadx.core.dex.nodes.InsnNode.getArg(InsnNode.java:101)
+        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:611)
+        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
+        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
+        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
+        	at jadx.core.dex.visitors.regions.RegionMaker.processMonitorEnter(RegionMaker.java:561)
+        	at jadx.core.dex.visitors.regions.RegionMaker.traverse(RegionMaker.java:133)
+        	at jadx.core.dex.visitors.regions.RegionMaker.makeRegion(RegionMaker.java:86)
+        	at jadx.core.dex.visitors.regions.RegionMaker.processHandlersOutBlocks(RegionMaker.java:1008)
+        	at jadx.core.dex.visitors.regions.RegionMaker.processTryCatchBlocks(RegionMaker.java:978)
+        	at jadx.core.dex.visitors.regions.RegionMakerVisitor.visit(RegionMakerVisitor.java:52)
+        */
+    public java.lang.String probeScanner(epson.scan.activity.ScannerPropertyWrapper r7, android.content.Context r8) throws epson.scan.lib.EscanLibException {
+        /*
+            r6 = this;
+            r0 = 0
+            r6.mEscanLib = r0
+            r1 = 0
+            monitor-enter(r6)     // Catch:{ all -> 0x009b }
+            epson.scan.lib.escanLib r2 = new epson.scan.lib.escanLib     // Catch:{ all -> 0x0098 }
+            r2.<init>()     // Catch:{ all -> 0x0098 }
+            r6.mEscanLib = r2     // Catch:{ all -> 0x0098 }
+            monitor-exit(r6)     // Catch:{ all -> 0x0098 }
+            r2 = 0
+        L_0x000e:
+            epson.scan.lib.escanLib r3 = r6.mEscanLib     // Catch:{ all -> 0x0096 }
+            int r3 = r3.escanWrapperInitDriver(r8)     // Catch:{ all -> 0x0096 }
+            r4 = -1050(0xfffffffffffffbe6, float:NaN)
+            r5 = 1
+            if (r3 == r4) goto L_0x0035
+            if (r3 == 0) goto L_0x0033
+            monitor-enter(r6)
+            r6.mProbingScanner = r1     // Catch:{ all -> 0x0030 }
+            monitor-exit(r6)     // Catch:{ all -> 0x0030 }
+            epson.scan.lib.escanLib r7 = r6.mEscanLib
+            if (r7 == 0) goto L_0x0028
+            if (r2 == 0) goto L_0x0028
+            r7.escanWrapperReleaseDriver()
+        L_0x0028:
+            monitor-enter(r6)
+            r6.mEscanLib = r0     // Catch:{ all -> 0x002d }
+            monitor-exit(r6)     // Catch:{ all -> 0x002d }
+            return r0
+        L_0x002d:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x002d }
+            throw r7
+        L_0x0030:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x0030 }
+            throw r7
+        L_0x0033:
+            r2 = 1
+            goto L_0x003a
+        L_0x0035:
+            epson.scan.lib.escanLib r3 = r6.mEscanLib     // Catch:{ all -> 0x0096 }
+            r3.escanWrapperReleaseDriver()     // Catch:{ all -> 0x0096 }
+        L_0x003a:
+            if (r2 == 0) goto L_0x000e
+            java.lang.String r8 = r7.getIp()     // Catch:{ all -> 0x0096 }
+            java.lang.String r3 = r7.getScannerId()     // Catch:{ all -> 0x0096 }
+            monitor-enter(r6)     // Catch:{ all -> 0x0096 }
+            r6.mProbingScanner = r5     // Catch:{ all -> 0x0093 }
+            monitor-exit(r6)     // Catch:{ all -> 0x0093 }
+            int r7 = r7.getLocation()     // Catch:{ all -> 0x0096 }
+            r4 = 3
+            if (r7 != r4) goto L_0x0075
+            epson.scan.lib.escanLib r7 = r6.mEscanLib     // Catch:{ all -> 0x0096 }
+            int r7 = r7.probeScannerByIp(r3, r8)     // Catch:{ all -> 0x0096 }
+            if (r7 != 0) goto L_0x006f
+            monitor-enter(r6)
+            r6.mProbingScanner = r1     // Catch:{ all -> 0x006c }
+            monitor-exit(r6)     // Catch:{ all -> 0x006c }
+            epson.scan.lib.escanLib r7 = r6.mEscanLib
+            if (r7 == 0) goto L_0x0064
+            if (r2 == 0) goto L_0x0064
+            r7.escanWrapperReleaseDriver()
+        L_0x0064:
+            monitor-enter(r6)
+            r6.mEscanLib = r0     // Catch:{ all -> 0x0069 }
+            monitor-exit(r6)     // Catch:{ all -> 0x0069 }
+            return r8
+        L_0x0069:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x0069 }
+            throw r7
+        L_0x006c:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x006c }
+            throw r7
+        L_0x006f:
+            epson.scan.lib.EscanLibException r8 = new epson.scan.lib.EscanLibException     // Catch:{ all -> 0x0096 }
+            r8.<init>(r7)     // Catch:{ all -> 0x0096 }
+            throw r8     // Catch:{ all -> 0x0096 }
+        L_0x0075:
+            epson.scan.lib.escanLib r7 = r6.mEscanLib     // Catch:{ all -> 0x0096 }
+            java.lang.String r7 = localProbeById(r7, r3, r8)     // Catch:{ all -> 0x0096 }
+            monitor-enter(r6)
+            r6.mProbingScanner = r1     // Catch:{ all -> 0x0090 }
+            monitor-exit(r6)     // Catch:{ all -> 0x0090 }
+            epson.scan.lib.escanLib r8 = r6.mEscanLib
+            if (r8 == 0) goto L_0x0088
+            if (r2 == 0) goto L_0x0088
+            r8.escanWrapperReleaseDriver()
+        L_0x0088:
+            monitor-enter(r6)
+            r6.mEscanLib = r0     // Catch:{ all -> 0x008d }
+            monitor-exit(r6)     // Catch:{ all -> 0x008d }
+            return r7
+        L_0x008d:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x008d }
+            throw r7
+        L_0x0090:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x0090 }
+            throw r7
+        L_0x0093:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x0093 }
+            throw r7     // Catch:{ all -> 0x0096 }
+        L_0x0096:
+            r7 = move-exception
+            goto L_0x009d
+        L_0x0098:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x0098 }
+            throw r7     // Catch:{ all -> 0x009b }
+        L_0x009b:
+            r7 = move-exception
+            r2 = 0
+        L_0x009d:
+            monitor-enter(r6)
+            r6.mProbingScanner = r1     // Catch:{ all -> 0x00b2 }
+            monitor-exit(r6)     // Catch:{ all -> 0x00b2 }
+            epson.scan.lib.escanLib r8 = r6.mEscanLib
+            if (r8 == 0) goto L_0x00aa
+            if (r2 == 0) goto L_0x00aa
+            r8.escanWrapperReleaseDriver()
+        L_0x00aa:
+            monitor-enter(r6)
+            r6.mEscanLib = r0     // Catch:{ all -> 0x00af }
+            monitor-exit(r6)     // Catch:{ all -> 0x00af }
+            throw r7
+        L_0x00af:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x00af }
+            throw r7
+        L_0x00b2:
+            r7 = move-exception
+            monitor-exit(r6)     // Catch:{ all -> 0x00b2 }
+            throw r7
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.scan.lib.CancelableScannerProbe.probeScanner(epson.scan.activity.ScannerPropertyWrapper, android.content.Context):java.lang.String");
+    }
+
+    private static String localProbeById(escanLib escanlib, String str, String str2) {
+        List<ScannerInfo> listFoundScanner;
+        escanlib.resetEscanLib();
+        if (escanlib.probeScannerById(str, str2) == 0 && (listFoundScanner = escanlib.getListFoundScanner()) != null && listFoundScanner.size() > 0) {
+            return listFoundScanner.get(0).getIp();
+        }
+        return null;
+    }
+
+    public void cancel() {
+        synchronized (this) {
+            if (this.mProbingScanner && this.mEscanLib != null) {
+                this.mEscanLib.escanWrapperCancelFindScanner();
+            }
+        }
+    }
+}

+ 24 - 0
app/src/main/java/epson/scan/lib/EscanLibException.java

@@ -0,0 +1,24 @@
+package epson.scan.lib;
+
+public class EscanLibException extends Exception {
+    private int mEscIVersion;
+    private int mEscanLibErrorCode;
+
+    public EscanLibException(int i) {
+        this.mEscIVersion = 1;
+        this.mEscanLibErrorCode = i;
+    }
+
+    public EscanLibException(int i, int i2) {
+        this.mEscIVersion = i;
+        this.mEscanLibErrorCode = i2;
+    }
+
+    public int getEscanLibErrorCode() {
+        return this.mEscanLibErrorCode;
+    }
+
+    public int getEscIVersion() {
+        return this.mEscIVersion;
+    }
+}

+ 37 - 0
app/src/main/java/epson/scan/lib/EscanLibInterface.java

@@ -0,0 +1,37 @@
+package epson.scan.lib;
+
+import android.content.Context;
+import android.os.Parcelable;
+import java.util.List;
+
+public interface EscanLibInterface extends Parcelable {
+    int GetSupportedOption();
+
+    int escanProbeScannerById(int i, char[] cArr, char[] cArr2);
+
+    int escanWrapperCancelFindScanner();
+
+    int escanWrapperInitDriver(Context context);
+
+    int escanWrapperReleaseDriver();
+
+    int escanWrapperSetScanner(int i);
+
+    int[] getEscanSupportOption();
+
+    int[] getEscanSupportResolution();
+
+    List<ScannerInfo> getListFoundScanner();
+
+    boolean getSearchStt();
+
+    int[] getStatus();
+
+    int probeScannerById(String str, String str2);
+
+    int probeScannerByIp(String str, String str2);
+
+    void setEscanSupportOption(int[] iArr);
+
+    void setSearchStt(boolean z);
+}

+ 10 - 0
app/src/main/java/epson/scan/lib/I1ScanParams.java

@@ -0,0 +1,10 @@
+package epson.scan.lib;
+
+public class I1ScanParams {
+    public int brightness;
+    public int colorType;
+    public int gamma;
+    public int inputDevice;
+    public int resolution;
+    public int twoSide;
+}

+ 94 - 0
app/src/main/java/epson/scan/lib/ScanCommonParams.java

@@ -0,0 +1,94 @@
+package epson.scan.lib;
+
+import android.content.Context;
+import com.epson.lib.escani2.EscanI2Lib;
+import com.epson.lib.escani2.ScanI2Params;
+import epson.scan.i2lib.I2ScanParamManager;
+
+public abstract class ScanCommonParams {
+    public static boolean convertYesNo(int i) {
+        return i == 1;
+    }
+
+    public abstract int getScanSourceUnit();
+
+    public abstract int getTwoSideValue();
+
+    public static ScanCommonParams load(Context context) {
+        if (ScanInfoStorage.loadEscIVersion(context) != 2) {
+            return I1ParamWrapper.load(context);
+        }
+        return I2ParamWrapper.load(context);
+    }
+
+    public EscanI2Lib.InputUnit getI2ScanSourceUnit() {
+        return convertInputUnit(getScanSourceUnit());
+    }
+
+    public boolean getI2Duplex() {
+        return convertYesNo(getTwoSideValue());
+    }
+
+    public static EscanI2Lib.InputUnit convertInputUnit(int i) {
+        if (i != 1) {
+            return EscanI2Lib.InputUnit.FLATBED;
+        }
+        return EscanI2Lib.InputUnit.ADF;
+    }
+
+    public static class I1ParamWrapper extends ScanCommonParams {
+        private ScannerInfo mI1ScannerInfo = ScannerInfo.getInstance();
+
+        public static I1ParamWrapper load(Context context) {
+            I1ParamWrapper i1ParamWrapper = new I1ParamWrapper();
+            ScanInfoStorage instance = ScanInfoStorage.getInstance();
+            i1ParamWrapper.mI1ScannerInfo.setSourceValue(instance.getScanSourceUnit(context));
+            i1ParamWrapper.mI1ScannerInfo.setTwoSidedScanningValue(instance.getTwoSideValue(context));
+            return i1ParamWrapper;
+        }
+
+        private I1ParamWrapper() {
+        }
+
+        public int getScanSourceUnit() {
+            return this.mI1ScannerInfo.getSourceValue();
+        }
+
+        public int getTwoSideValue() {
+            return this.mI1ScannerInfo.getTwoSidedScanningValue();
+        }
+    }
+
+    public static class I2ParamWrapper extends ScanCommonParams {
+        private ScanI2Params mScanI2Params = new ScanI2Params();
+
+        public static I2ParamWrapper load(Context context) {
+            I2ParamWrapper i2ParamWrapper = new I2ParamWrapper();
+            i2ParamWrapper.mScanI2Params = I2ScanParamManager.loadScanI2Params(context);
+            return i2ParamWrapper;
+        }
+
+        private I2ParamWrapper() {
+        }
+
+        public int getScanSourceUnit() {
+            return C24461.$SwitchMap$com$epson$lib$escani2$EscanI2Lib$InputUnit[this.mScanI2Params.inputUnit.ordinal()] != 1 ? 1 : 0;
+        }
+
+        public int getTwoSideValue() {
+            return this.mScanI2Params.duplex ? 1 : 0;
+        }
+    }
+
+    /* renamed from: epson.scan.lib.ScanCommonParams$1 */
+    static /* synthetic */ class C24461 {
+        static final /* synthetic */ int[] $SwitchMap$com$epson$lib$escani2$EscanI2Lib$InputUnit = new int[EscanI2Lib.InputUnit.values().length];
+
+        static {
+            try {
+                $SwitchMap$com$epson$lib$escani2$EscanI2Lib$InputUnit[EscanI2Lib.InputUnit.FLATBED.ordinal()] = 1;
+            } catch (NoSuchFieldError unused) {
+            }
+        }
+    }
+}

+ 130 - 0
app/src/main/java/epson/scan/lib/ScanInfoStorage.java

@@ -0,0 +1,130 @@
+package epson.scan.lib;
+
+import android.content.Context;
+import android.support.annotation.VisibleForTesting;
+import epson.common.Constants;
+import epson.common.Utils;
+import epson.print.CommonDefine;
+
+public class ScanInfoStorage {
+    private static final String PREFS_KEY_ESC_I_VERSION = "esc/i-version";
+    private static ScanInfoStorage sScanInfoStorage;
+
+    public static ScanInfoStorage getInstance() {
+        if (sScanInfoStorage == null) {
+            sScanInfoStorage = new ScanInfoStorage();
+        }
+        return sScanInfoStorage;
+    }
+
+    @VisibleForTesting
+    protected static void setInstance(ScanInfoStorage scanInfoStorage) {
+        sScanInfoStorage = scanInfoStorage;
+    }
+
+    static void saveSettings(Context context, ScannerInfo scannerInfo) {
+        Utils.savePref(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_SOURCE, scannerInfo.getSourceValue());
+        Utils.savePref(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SCANNER_CHOSEN_SIZE, scannerInfo.getSizeValue());
+        Utils.savePref(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_COLOR, scannerInfo.getColorValue());
+        Utils.savePref(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_RESOLUTION, scannerInfo.getResolutionValue());
+        Utils.savePref(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_2SIDED, scannerInfo.getTwoSidedScanningValue());
+        Utils.savePref(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_DENSITY, scannerInfo.getDensityValue());
+        Utils.savePref(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_DENSITY_STATUS, scannerInfo.isDensityStatus());
+        Utils.savePref(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_GAMMA, scannerInfo.getGammaValue());
+        Utils.savePref(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_ROTATE, scannerInfo.isAdfDuplexRotaitonYes());
+        Utils.savePref(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_ADF_PAPER_GUIDE, scannerInfo.getAdfPaperGuide());
+        Utils.savePref(context, Constants.SCAN_REFS_USED_SCANNER_PATH, CommonDefine.RE_SEARCH, true);
+    }
+
+    static void saveSelectedScannerSupportedOptions(Context context, int[] iArr) {
+        Utils.savePref(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_VERSION, iArr[0]);
+        Utils.savePref(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_BASIC_RESOLUTION, iArr[1]);
+        Utils.savePref(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_WIDTH, iArr[2]);
+        Utils.savePref(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_HEIGHT, iArr[3]);
+        Utils.savePref(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_ADF_WIDTH, iArr[4]);
+        Utils.savePref(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_ADF_HEIGHT, iArr[5]);
+        Utils.savePref(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_SUPPORTED_ADF_DUPLEX, iArr[6]);
+    }
+
+    public static void saveScannerConnectivityInfo(Context context, String str, String str2, String str3, int i) {
+        getInstance().saveScannerConnectivityInfoNonStatic(context, str, str2, str3, i);
+    }
+
+    /* access modifiers changed from: protected */
+    public void saveScannerConnectivityInfoNonStatic(Context context, String str, String str2, String str3, int i) {
+        Utils.savePref(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SCANNER_MODEL, str);
+        Utils.savePref(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SCANNER_IP, str2);
+        Utils.savePref(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SCANNER_ID, str3);
+        Utils.savePref(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SCANNER_LOCATION, i);
+    }
+
+    public void loadScannerConnectivityInfo(Context context, ScannerInfo scannerInfo) {
+        scannerInfo.setScannerId(Utils.getPrefString(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SCANNER_ID));
+        scannerInfo.setModelName(Utils.getPrefString(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SCANNER_MODEL));
+        scannerInfo.setIp(Utils.getPrefString(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SCANNER_IP));
+        scannerInfo.setLocation(Utils.getPrefInt(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SCANNER_LOCATION));
+    }
+
+    public void loadScanSetting(Context context, ScannerInfo scannerInfo) {
+        scannerInfo.setSupportedAdfDuplex(Utils.getPrefInt(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_SUPPORTED_ADF_DUPLEX));
+        scannerInfo.setTwoSidedScanningValue(Utils.getPrefInt(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_2SIDED));
+        scannerInfo.setDensityValue(Utils.getPrefInt(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_DENSITY));
+        scannerInfo.setDensityStatus(Utils.getPrefBoolean(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_DENSITY_STATUS));
+        scannerInfo.setGammaValue(Utils.getPrefInt(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_GAMMA));
+        scannerInfo.setAdfDuplexRotaitonYes(Utils.getPrefBoolean(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_ROTATE));
+        scannerInfo.setAdfPaperGuide(Utils.getPrefInt(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_ADF_PAPER_GUIDE));
+    }
+
+    public void loadSupportedValue(Context context, ScannerInfo scannerInfo) {
+        scannerInfo.setSupportedBasicResolution(Utils.getPrefInt(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_BASIC_RESOLUTION));
+        scannerInfo.setSupportedBasicWidth(Utils.getPrefInt(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_WIDTH));
+        scannerInfo.setSupportedBasicHeight(Utils.getPrefInt(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_HEIGHT));
+        scannerInfo.setSupportedAdfWidth(Utils.getPrefInt(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_ADF_WIDTH));
+        scannerInfo.setSupportedAdfHeight(Utils.getPrefInt(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_ADF_HEIGHT));
+    }
+
+    public void loadSupportedAdfSize(Context context, ScannerInfo scannerInfo) {
+        scannerInfo.setSupportedAdfWidth(Utils.getPrefInt(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_ADF_WIDTH));
+        scannerInfo.setSupportedAdfHeight(Utils.getPrefInt(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_ADF_HEIGHT));
+    }
+
+    public void loadColorValue(Context context, ScannerInfo scannerInfo) {
+        scannerInfo.setColorValue(Utils.getPrefInt(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_COLOR));
+    }
+
+    public void loadResolution(Context context, ScannerInfo scannerInfo) {
+        scannerInfo.setResolutionValue(Utils.getPrefInt(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_RESOLUTION));
+    }
+
+    public void loadReadUnitValue(Context context, ScannerInfo scannerInfo) {
+        scannerInfo.setSourceValue(Utils.getPrefInt(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_SOURCE));
+    }
+
+    public int getScanSourceUnit(Context context, int i) {
+        return context.getSharedPreferences(Constants.SCAN_REFS_USED_SCANNER_PATH, 0).getInt(Constants.SCAN_REFS_SETTINGS_SOURCE, i);
+    }
+
+    public int getScanSourceUnit(Context context) {
+        return getScanSourceUnit(context, 1);
+    }
+
+    public int getTwoSideValue(Context context) {
+        return Utils.getPrefInt(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_2SIDED);
+    }
+
+    public void saveEscIVersionNonStatic(Context context, int i) {
+        Utils.savePref(context, Constants.SCAN_REFS_USED_SCANNER_PATH, PREFS_KEY_ESC_I_VERSION, i);
+    }
+
+    public int loadEscIVersionNonStatic(Context context) {
+        return context.getSharedPreferences(Constants.SCAN_REFS_USED_SCANNER_PATH, 0).getInt(PREFS_KEY_ESC_I_VERSION, 1);
+    }
+
+    public static void saveEscIVersion(Context context, int i) {
+        getInstance().saveEscIVersionNonStatic(context, i);
+    }
+
+    public static int loadEscIVersion(Context context) {
+        return getInstance().loadEscIVersionNonStatic(context);
+    }
+}

+ 217 - 0
app/src/main/java/epson/scan/lib/ScanSettingHelper.java

@@ -0,0 +1,217 @@
+package epson.scan.lib;
+
+import android.content.Context;
+import android.graphics.Point;
+import android.support.annotation.NonNull;
+import android.support.annotation.VisibleForTesting;
+import com.epson.mobilephone.common.PrintingLib.define.Constants;
+import com.epson.mobilephone.common.wifidirect.MacAddrUtils;
+import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
+import epson.common.Constants;
+import epson.common.Utils;
+import epson.print.C2135R;
+import epson.print.MyPrinter;
+import epson.print.Util.EPLog;
+import epson.scan.activity.ScannerPropertyWrapper;
+import epson.scan.i2lib.I2ScanParamArbiter;
+import epson.scan.i2lib.I2ScanParamManager;
+import java.io.IOException;
+import java.util.Arrays;
+
+public class ScanSettingHelper {
+    private static final String TAG = "ScanSettingHelper";
+
+    public static void saveSupportedOptionToRef(Context context, ScannerInfo scannerInfo) {
+        ScanInfoStorage.saveSelectedScannerSupportedOptions(context, scannerInfo.getSupportedOptions());
+        saveSelectedScannerSupportedResolutionList(context, scannerInfo.getSupportedResolutionList());
+    }
+
+    public static void saveAllUserSettingsToRef(Context context, ScannerInfo scannerInfo) {
+        ScanInfoStorage.saveScannerConnectivityInfo(context, scannerInfo.getModelName(), scannerInfo.getIp(), scannerInfo.getScannerId(), scannerInfo.getLocation());
+        ScanInfoStorage.saveSettings(context, scannerInfo);
+        saveScanDefaultMaxSize(context, scannerInfo);
+    }
+
+    private static void saveSelectedScannerSupportedResolutionList(Context context, int[] iArr) {
+        for (int i = 0; i < iArr.length; i++) {
+            int i2 = iArr[i];
+            if (i2 == 75 || i2 == 150 || i2 == 300) {
+                Utils.savePref(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_RESOLUTION_ + i, iArr[i]);
+            }
+        }
+    }
+
+    public static void saveScanDefaultMaxSize(Context context, ScannerInfo scannerInfo) {
+        int i;
+        int i2;
+        int supportedBasicResolution = scannerInfo.getSupportedBasicResolution();
+        int resolutionValue = scannerInfo.getResolutionValue();
+        int i3 = Constants.SCAN_MAX_HEIGHT;
+        int i4 = Constants.SCAN_MAX_WIDTH;
+        if (supportedBasicResolution > 0) {
+            if (scannerInfo.getSourceValue() == 1) {
+                Point maxScanSize = ScanSizeHelper.getMaxScanSize(scannerInfo.getSourceValue(), scannerInfo.getTwoSidedScanningValue(), scannerInfo.getSupportedAdfWidth(), scannerInfo.getSupportedAdfHeight(), supportedBasicResolution);
+                i = maxScanSize.x;
+                i2 = maxScanSize.y;
+            } else {
+                i = scannerInfo.getSupportedBasicWidth();
+                i2 = scannerInfo.getSupportedBasicHeight();
+            }
+            if (resolutionValue > supportedBasicResolution) {
+                int i5 = resolutionValue / supportedBasicResolution;
+                i *= i5;
+                i2 *= i5;
+            } else if (resolutionValue < supportedBasicResolution) {
+                int i6 = supportedBasicResolution / resolutionValue;
+                i /= i6;
+                i2 /= i6;
+            }
+            if (i != 0) {
+                i4 = i;
+            }
+            if (i2 != 0) {
+                i3 = i2;
+            }
+        }
+        scannerInfo.setMaxWidth(i4);
+        scannerInfo.setMaxHeight(i3);
+        Utils.savePref(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_MAX_WIDTH, scannerInfo.getMaxWidth());
+        Utils.savePref(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_MAX_HEIGHT, scannerInfo.getMaxHeight());
+    }
+
+    public static void saveErroredBlankSettings(Context context) {
+        Utils.savePref(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_VALIDATION, false);
+        ScanInfoStorage.saveScannerConnectivityInfo(context, context.getString(C2135R.string.str_lbl_title_scan), "", "", 0);
+        Utils.savePref(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_SOURCE, 0);
+        Utils.savePref(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_ADF_HEIGHT, 0);
+        Utils.savePref(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_ADF_WIDTH, 0);
+        Utils.savePref(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SCANNER_CHOSEN_SIZE_ADF, Constants.PaperName.EPS_MSID_UNKNOWN.getCode());
+        Utils.savePref(context, epson.common.Constants.SCAN_REFS_USED_SCANNER_PATH, epson.common.Constants.SCAN_REFS_SCANNER_CHOSEN_SIZE_DOC, Constants.PaperName.EPS_MSID_UNKNOWN.getCode());
+        Utils.savePref(context, epson.common.Constants.SCAN_REFS_USED_SCANNER_PATH, epson.common.Constants.SCAN_REFS_SCANNER_CHOSEN_SIZE, Constants.PaperName.EPS_MSID_UNKNOWN.getCode());
+        Utils.savePref(context, epson.common.Constants.SCAN_REFS_USED_SCANNER_PATH, epson.common.Constants.SCAN_REFS_SETTINGS_COLOR, 1);
+        Utils.savePref(context, epson.common.Constants.SCAN_REFS_USED_SCANNER_PATH, epson.common.Constants.SCAN_REFS_SETTINGS_RESOLUTION, 150);
+        Utils.savePref(context, epson.common.Constants.SCAN_REFS_SUPPORTED_OPTIONS, epson.common.Constants.SCAN_REFS_MAX_WIDTH, (int) epson.common.Constants.SCAN_MAX_WIDTH);
+        Utils.savePref(context, epson.common.Constants.SCAN_REFS_SUPPORTED_OPTIONS, epson.common.Constants.SCAN_REFS_MAX_HEIGHT, (int) epson.common.Constants.SCAN_MAX_HEIGHT);
+    }
+
+    public static int getI1SupportedOptions(escanLib escanlib, ScannerInfo scannerInfo) {
+        if (escanlib.escanWrapperSetScanner(0) != 0) {
+            return -1300;
+        }
+        int GetSupportedOption = escanlib.GetSupportedOption();
+        scannerInfo.setSupportedOptions(escanlib.getEscanSupportOption());
+        scannerInfo.setSupportedResolutionList(escanlib.getEscanSupportResolution());
+        updateNewSelectedScannerSupportedOptions(scannerInfo);
+        return GetSupportedOption;
+    }
+
+    public static void updateNewSelectedScannerSupportedOptions(ScannerInfo scannerInfo) {
+        scannerInfo.setVersion(scannerInfo.getSupportedOptions()[0]);
+        scannerInfo.setSupportedBasicResolution(scannerInfo.getSupportedOptions()[1]);
+        scannerInfo.setSupportedBasicWidth(scannerInfo.getSupportedOptions()[2]);
+        scannerInfo.setSupportedBasicHeight(scannerInfo.getSupportedOptions()[3]);
+        scannerInfo.setSupportedAdfWidth(scannerInfo.getSupportedOptions()[4]);
+        scannerInfo.setSupportedAdfHeight(scannerInfo.getSupportedOptions()[5]);
+        scannerInfo.setSupportedAdfDuplex(scannerInfo.getSupportedOptions()[6]);
+    }
+
+    public static void setDefaultSettings2(@NonNull Context context, @NonNull ScanInfoStorage scanInfoStorage, @NonNull ScannerInfo scannerInfo) {
+        scannerInfo.setSourceValue(0);
+        scannerInfo.setTwoSidedScanningValue(0);
+        scannerInfo.setAdfDuplexRotaitonYes(false);
+        if (scannerInfo.getSupportedAdfHeight() > 0 && scannerInfo.getSupportedAdfWidth() > 0) {
+            scannerInfo.setSourceValue(1);
+            if (scanInfoStorage.getScanSourceUnit(context, 0) != 1) {
+                int scanSourceUnit = scanInfoStorage.getScanSourceUnit(context, -1);
+                if (scanSourceUnit != -1) {
+                    scannerInfo.setSourceValue(scanSourceUnit);
+                }
+            } else if (scannerInfo.getSupportedAdfDuplex() == 1) {
+                scannerInfo.setTwoSidedScanningValue(scanInfoStorage.getTwoSideValue(context));
+            }
+        }
+        int[] iArr = (int[]) scannerInfo.getSupportedResolutionList().clone();
+        Arrays.sort(iArr);
+        if (Arrays.binarySearch(iArr, 150) > 0) {
+            scannerInfo.setResolutionValue(150);
+        } else if (Arrays.binarySearch(iArr, 75) > 0) {
+            scannerInfo.setResolutionValue(75);
+        } else if (Arrays.binarySearch(iArr, 300) > 0) {
+            scannerInfo.setResolutionValue(300);
+        } else {
+            scannerInfo.setResolutionValue(0);
+        }
+        scannerInfo.setColorValue(1);
+        scannerInfo.setDensityStatus(false);
+        scannerInfo.setDensityValue(128);
+        scannerInfo.setGammaValue(1);
+    }
+
+    public static void setDefaultSettings3(@NonNull ScanCommonParams scanCommonParams, @NonNull ScannerInfo scannerInfo) {
+        scannerInfo.setSourceValue(0);
+        scannerInfo.setTwoSidedScanningValue(0);
+        scannerInfo.setAdfDuplexRotaitonYes(false);
+        if (scannerInfo.getSupportedAdfHeight() > 0 && scannerInfo.getSupportedAdfWidth() > 0) {
+            scannerInfo.setSourceValue(1);
+            if (scanCommonParams.getScanSourceUnit() != 1) {
+                scannerInfo.setSourceValue(scanCommonParams.getScanSourceUnit());
+            } else if (scannerInfo.getSupportedAdfDuplex() == 1) {
+                scannerInfo.setTwoSidedScanningValue(scanCommonParams.getTwoSideValue());
+            }
+        }
+        int[] iArr = (int[]) scannerInfo.getSupportedResolutionList().clone();
+        Arrays.sort(iArr);
+        if (Arrays.binarySearch(iArr, 150) > 0) {
+            scannerInfo.setResolutionValue(150);
+        } else if (Arrays.binarySearch(iArr, 75) > 0) {
+            scannerInfo.setResolutionValue(75);
+        } else if (Arrays.binarySearch(iArr, 300) > 0) {
+            scannerInfo.setResolutionValue(300);
+        } else {
+            scannerInfo.setResolutionValue(0);
+        }
+        scannerInfo.setColorValue(1);
+        scannerInfo.setDensityStatus(false);
+        scannerInfo.setDensityValue(128);
+        scannerInfo.setGammaValue(1);
+    }
+
+    private static void changeScanner(Context context, ScannerInfo scannerInfo) {
+        String prefString = Utils.getPrefString(context, epson.common.Constants.SCAN_REFS_USED_SCANNER_PATH, epson.common.Constants.SCAN_REFS_SCANNER_ID);
+        int prefInt = Utils.getPrefInt(context, epson.common.Constants.SCAN_REFS_USED_SCANNER_PATH, epson.common.Constants.SCAN_REFS_SCANNER_LOCATION);
+        if (prefString == null || !prefString.equals(scannerInfo.getScannerId()) || prefInt != scannerInfo.getLocation()) {
+            EPLog.m305d(TAG, "changeScanner scannerId=" + scannerInfo.getScannerId());
+            saveAllUserSettingsToRef(context, scannerInfo);
+            saveSupportedOptionToRef(context, scannerInfo);
+            String curConnectInfo = WiFiDirectManager.getCurConnectInfo(context, MacAddrUtils.getMacAddressFromScannerId(scannerInfo.getScannerId()));
+            if (scannerInfo.getLocation() != 1 || curConnectInfo == null) {
+                WiFiDirectManager.resetConnectInfo(context, WiFiDirectManager.DEVICE_TYPE_SCANNER);
+            } else {
+                WiFiDirectManager.setConnectInfo(context, curConnectInfo, WiFiDirectManager.DEVICE_TYPE_SCANNER, scannerInfo.getModelName());
+            }
+        }
+    }
+
+    public static ScannerPropertyWrapper recodeScannerInfo(escanLib escanlib, Context context, MyPrinter myPrinter) throws EscanLibException, IOException {
+        ScannerPropertyWrapper scannerProperty = CancelablePropertyTaker.getScannerProperty(escanlib, myPrinter);
+        if (scannerProperty != null) {
+            adjustAndSaveScanParams(context, scannerProperty);
+            return scannerProperty;
+        }
+        throw new EscanLibException(-1001);
+    }
+
+    @VisibleForTesting
+    static void adjustAndSaveScanParams(@NonNull Context context, @NonNull ScannerPropertyWrapper scannerPropertyWrapper) throws IOException {
+        if (scannerPropertyWrapper.getEscIVersion() == 2) {
+            I2ScanParamManager.saveParams(context, I2ScanParamArbiter.getAdjustedParams(context, scannerPropertyWrapper));
+            scannerPropertyWrapper.updateSetSimpleApSsid(context);
+            scannerPropertyWrapper.saveData(context, true);
+            return;
+        }
+        ScannerInfo i1ScannerInfo = scannerPropertyWrapper.getI1ScannerInfo();
+        setDefaultSettings3(ScanCommonParams.load(context), i1ScannerInfo);
+        scannerPropertyWrapper.saveData(context, true);
+        changeScanner(context, i1ScannerInfo);
+    }
+}

+ 148 - 0
app/src/main/java/epson/scan/lib/ScanSizeHelper.java

@@ -0,0 +1,148 @@
+package epson.scan.lib;
+
+import android.graphics.Point;
+import com.epson.mobilephone.common.PrintingLib.define.Constants;
+import com.epson.mobilephone.common.escpr.MediaInfo;
+import epson.print.C2135R;
+import java.util.ArrayList;
+import java.util.Locale;
+
+public class ScanSizeHelper {
+    public static final int SUPPORT_A3 = 3;
+    public static final int SUPPORT_A4 = 1;
+    public static final int SUPPORT_LEGAL = 2;
+    public static final int SUPPORT_NONE = 0;
+
+    public static Point getPaperSize(int i, int i2) {
+        Point point;
+        Point point2 = new Point(0, 0);
+        if (i2 == 0) {
+            return point2;
+        }
+        if (i == 5) {
+            point = new Point(1820, 2570);
+        } else if (i != 62) {
+            switch (i) {
+                case 0:
+                    point = new Point(2100, 2970);
+                    break;
+                case 1:
+                    point = new Point(2159, 2794);
+                    break;
+                case 2:
+                    point = new Point(2159, 3556);
+                    break;
+                default:
+                    if (getDefaultScanSize() == 1) {
+                        point = new Point(2159, 2794);
+                        break;
+                    } else {
+                        point = new Point(2100, 2970);
+                        break;
+                    }
+            }
+        } else {
+            point = new Point(2970, 4200);
+        }
+        return new Point((int) (((float) (point.x * i2)) * 0.003937008f), (int) (((float) (point.y * i2)) * 0.003937008f));
+    }
+
+    private static int getMaxScanSize(int i, int i2, int i3) {
+        if (i3 == 0) {
+            return 0;
+        }
+        Point paperSize = getPaperSize(Constants.PaperName.EPS_MSID_A3.getCode(), i3);
+        if (i >= paperSize.x && i2 >= paperSize.y) {
+            return 3;
+        }
+        Point paperSize2 = getPaperSize(Constants.PaperName.EPS_MSID_LEGAL.getCode(), i3);
+        if (i >= paperSize2.x && i2 >= paperSize2.y) {
+            return 2;
+        }
+        Point paperSize3 = getPaperSize(Constants.PaperName.EPS_MSID_A4.getCode(), i3);
+        if (i < paperSize3.x || i2 < paperSize3.y) {
+            return 0;
+        }
+        return 1;
+    }
+
+    public static int[] getSupportedScanSizeList(int i, int i2, int i3, int i4, int i5) {
+        ArrayList arrayList = new ArrayList();
+        int maxScanSize = getMaxScanSize(i3, i4, i5);
+        switch (i) {
+            case 0:
+                if (maxScanSize >= 1) {
+                    arrayList.add(Integer.valueOf(Constants.PaperName.EPS_MSID_B5.getCode()));
+                    arrayList.add(Integer.valueOf(Constants.PaperName.EPS_MSID_A4.getCode()));
+                    arrayList.add(Integer.valueOf(Constants.PaperName.EPS_MSID_LETTER.getCode()));
+                }
+                if (maxScanSize >= 2) {
+                    arrayList.add(Integer.valueOf(Constants.PaperName.EPS_MSID_LEGAL.getCode()));
+                }
+                if (maxScanSize >= 3) {
+                    arrayList.add(Integer.valueOf(Constants.PaperName.EPS_MSID_A3.getCode()));
+                }
+                arrayList.add(Integer.valueOf(Constants.PaperName.EPS_MSID_USER.getCode()));
+                break;
+            case 1:
+                switch (i2) {
+                    case 0:
+                        if (maxScanSize >= 1) {
+                            arrayList.add(Integer.valueOf(Constants.PaperName.EPS_MSID_A4.getCode()));
+                            arrayList.add(Integer.valueOf(Constants.PaperName.EPS_MSID_LETTER.getCode()));
+                        }
+                        if (maxScanSize >= 2) {
+                            arrayList.add(Integer.valueOf(Constants.PaperName.EPS_MSID_LEGAL.getCode()));
+                        }
+                        if (maxScanSize >= 3) {
+                            arrayList.add(Integer.valueOf(Constants.PaperName.EPS_MSID_A3.getCode()));
+                            break;
+                        }
+                        break;
+                    case 1:
+                        if (maxScanSize >= 1) {
+                            arrayList.add(Integer.valueOf(Constants.PaperName.EPS_MSID_A4.getCode()));
+                            arrayList.add(Integer.valueOf(Constants.PaperName.EPS_MSID_LETTER.getCode()));
+                            break;
+                        }
+                        break;
+                }
+        }
+        int[] iArr = new int[arrayList.size()];
+        for (int i6 = 0; i6 < arrayList.size(); i6++) {
+            iArr[i6] = ((Integer) arrayList.get(i6)).intValue();
+        }
+        return iArr;
+    }
+
+    public static Point getMaxScanSize(int i, int i2, int i3, int i4, int i5) {
+        Point point = new Point(0, 0);
+        switch (i) {
+            case 0:
+                return new Point(i3, i4);
+            case 1:
+                int[] supportedScanSizeList = getSupportedScanSizeList(i, i2, i3, i4, i5);
+                return supportedScanSizeList.length > 0 ? getPaperSize(supportedScanSizeList[supportedScanSizeList.length - 1], i5) : point;
+            default:
+                return point;
+        }
+    }
+
+    public static int getDefaultScanSize() {
+        String country = Locale.getDefault().getCountry();
+        if (country.equals(Locale.US.getCountry()) || country.equals(Locale.CANADA.getCountry())) {
+            return Constants.PaperName.EPS_MSID_LETTER.getCode();
+        }
+        return Constants.PaperName.EPS_MSID_A4.getCode();
+    }
+
+    public static int getScanSizeName(int i) {
+        if (i == Constants.PaperName.EPS_MSID_UNKNOWN.getCode()) {
+            return C2135R.string.str_settings_undefine_scansize;
+        }
+        if (i == Constants.PaperName.EPS_MSID_USER.getCode()) {
+            return C2135R.string.str_scanning_size_max;
+        }
+        return new MediaInfo.PaperSize().getStringId(i);
+    }
+}

+ 17 - 0
app/src/main/java/epson/scan/lib/ScannerConnection.java

@@ -0,0 +1,17 @@
+package epson.scan.lib;
+
+import android.content.Context;
+import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
+
+public class ScannerConnection {
+    public static void disconnectIfSimpleAp(Context context, String str) {
+        if (WiFiDirectManager.isSimpleAP(context)) {
+            try {
+                Thread.sleep(5000);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+            WiFiDirectManager.disconnect(context, WiFiDirectManager.DEVICE_TYPE_SCANNER, str);
+        }
+    }
+}

+ 386 - 0
app/src/main/java/epson/scan/lib/ScannerInfo.java

@@ -0,0 +1,386 @@
+package epson.scan.lib;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import epson.print.C2135R;
+import java.io.Serializable;
+
+public class ScannerInfo implements Serializable {
+    private int adfPaperGuide = 0;
+    private int colorValue;
+    private String commonDeviceName;
+    private boolean densityStatus;
+    private int densityValue;
+    private String friendlyName;
+    private int gammaValue;
+
+    /* renamed from: ip */
+    private String f413ip;
+    private boolean isAdfDuplexRotaitonYes = false;
+    private boolean isAdfDuplexYes = false;
+    private boolean isReSearch;
+    private int location;
+    private int maxHeight;
+    private int maxWidth;
+    private String modelName;
+    private int resolutionValue;
+    private String scannerId;
+    private int sizeValue;
+    private int sourceValue;
+    private int supportedAdfDuplex;
+    private int supportedAdfHeight;
+    private int supportedAdfWidth;
+    private int supportedBasicHeight;
+    private int supportedBasicResolution;
+    private int supportedBasicWidth;
+    private int[] supportedOptions;
+    private int[] supportedResolutionList;
+    private int supportedVersion;
+    private int twoSidedScanningValue;
+    private int version;
+
+    public ScannerInfo() {
+    }
+
+    public ScannerInfo(ScannerInfo scannerInfo) {
+        this.modelName = scannerInfo.getModelName();
+        this.f413ip = scannerInfo.getIp();
+        this.friendlyName = scannerInfo.getFriendlyName();
+        this.scannerId = scannerInfo.getScannerId();
+        this.colorValue = scannerInfo.getColorValue();
+        this.densityStatus = scannerInfo.densityStatus;
+        this.densityValue = scannerInfo.densityValue;
+        this.gammaValue = scannerInfo.getGammaValue();
+        this.sizeValue = scannerInfo.getSizeValue();
+        this.isReSearch = scannerInfo.isReSearch();
+        this.maxHeight = scannerInfo.getMaxHeight();
+        this.maxWidth = scannerInfo.getMaxWidth();
+        this.resolutionValue = scannerInfo.getResolutionValue();
+        this.sourceValue = scannerInfo.getSourceValue();
+        this.supportedAdfDuplex = scannerInfo.getSupportedAdfDuplex();
+        this.supportedAdfHeight = scannerInfo.getSupportedAdfHeight();
+        this.supportedAdfWidth = scannerInfo.getSupportedAdfWidth();
+        this.supportedBasicHeight = scannerInfo.getSupportedBasicHeight();
+        this.supportedBasicResolution = scannerInfo.getSupportedBasicResolution();
+        this.supportedBasicWidth = scannerInfo.getSupportedBasicWidth();
+        this.supportedOptions = scannerInfo.getSupportedOptions();
+        this.supportedResolutionList = scannerInfo.getSupportedResolutionList();
+        this.supportedVersion = scannerInfo.getSupportedVersion();
+        this.twoSidedScanningValue = scannerInfo.getTwoSidedScanningValue();
+        this.isAdfDuplexYes = scannerInfo.isAdfDuplexYes();
+        this.isAdfDuplexRotaitonYes = scannerInfo.isAdfDuplexRotaitonYes();
+        this.adfPaperGuide = scannerInfo.getAdfPaperGuide();
+    }
+
+    public String getModelName() {
+        return this.modelName;
+    }
+
+    public boolean isModelNameEmpty() {
+        String str = this.modelName;
+        return str == null || str.isEmpty();
+    }
+
+    public void setModelName(String str) {
+        this.modelName = str;
+    }
+
+    public String getIp() {
+        return this.f413ip;
+    }
+
+    public void setIp(String str) {
+        this.f413ip = str;
+    }
+
+    public String getFriendlyName() {
+        return this.friendlyName;
+    }
+
+    public void setFriendlyName(String str) {
+        this.friendlyName = str;
+    }
+
+    public String getScannerId() {
+        return this.scannerId;
+    }
+
+    public void setScannerId(String str) {
+        this.scannerId = str;
+    }
+
+    public String getCommonDeviceName() {
+        return this.commonDeviceName;
+    }
+
+    public void setCommonDeviceName(String str) {
+        this.commonDeviceName = str;
+    }
+
+    public int getLocation() {
+        return this.location;
+    }
+
+    public void setLocation(int i) {
+        this.location = i;
+    }
+
+    public int[] getSupportedOptions() {
+        return this.supportedOptions;
+    }
+
+    public void setSupportedOptions(int[] iArr) {
+        this.supportedOptions = iArr;
+    }
+
+    public int getVersion() {
+        return this.version;
+    }
+
+    public void setVersion(int i) {
+        this.version = i;
+    }
+
+    public String getResolutionName(Context context) {
+        int resolutionValue2 = getResolutionValue();
+        if (resolutionValue2 == 0) {
+            return context.getString(C2135R.string.str_blank);
+        }
+        return String.format(context.getString(C2135R.string.str_settings_resolution), new Object[]{Integer.valueOf(resolutionValue2)});
+    }
+
+    public int getResolutionValue() {
+        return this.resolutionValue;
+    }
+
+    public void setResolutionValue(int i) {
+        this.resolutionValue = i;
+    }
+
+    public int getColorName() {
+        switch (getColorValue()) {
+            case 1:
+                return C2135R.string.str_settings_color_color;
+            case 2:
+                return C2135R.string.str_settings_color_grayscale;
+            case 3:
+                return C2135R.string.str_settings_color_monochrome;
+            default:
+                return C2135R.string.str_blank;
+        }
+    }
+
+    public int getColorValue() {
+        return this.colorValue;
+    }
+
+    public void setColorValue(int i) {
+        this.colorValue = i;
+    }
+
+    public int getSourceName() {
+        switch (getSourceValue()) {
+            case 0:
+                return C2135R.string.str_settings_source_doctable;
+            case 1:
+                return C2135R.string.str_settings_source_adf;
+            default:
+                return C2135R.string.str_blank;
+        }
+    }
+
+    public int getSourceValue() {
+        return this.sourceValue;
+    }
+
+    public void setSourceValue(int i) {
+        this.sourceValue = i;
+    }
+
+    public int getTwoSidedScanningName() {
+        switch (getTwoSidedScanningValue()) {
+            case 0:
+                return C2135R.string.str_no;
+            case 1:
+                return C2135R.string.str_yes;
+            default:
+                return C2135R.string.str_blank;
+        }
+    }
+
+    public int getTwoSidedScanningValue() {
+        return this.twoSidedScanningValue;
+    }
+
+    public void setTwoSidedScanningValue(int i) {
+        this.twoSidedScanningValue = i;
+    }
+
+    public int getDensityValue() {
+        return this.densityValue;
+    }
+
+    public void setDensityValue(int i) {
+        this.densityValue = i;
+    }
+
+    public boolean isDensityStatus() {
+        return this.densityStatus;
+    }
+
+    public void setDensityStatus(boolean z) {
+        this.densityStatus = z;
+    }
+
+    public int getGammaName() {
+        switch (getGammaValue()) {
+            case 0:
+                return C2135R.string.str_settings_gamma_10;
+            case 1:
+                return C2135R.string.str_settings_gamma_18;
+            default:
+                return C2135R.string.str_blank;
+        }
+    }
+
+    public int getGammaValue() {
+        return this.gammaValue;
+    }
+
+    public void setGammaValue(int i) {
+        this.gammaValue = i;
+    }
+
+    public int getSizeValue() {
+        return this.sizeValue;
+    }
+
+    public void setSizeValue(int i) {
+        this.sizeValue = i;
+    }
+
+    public int getSupportedVersion() {
+        return this.supportedVersion;
+    }
+
+    public void setSupportedVersion(int i) {
+        this.supportedVersion = i;
+    }
+
+    public int getSupportedBasicResolution() {
+        return this.supportedBasicResolution;
+    }
+
+    public void setSupportedBasicResolution(int i) {
+        this.supportedBasicResolution = i;
+    }
+
+    public int getSupportedBasicHeight() {
+        return this.supportedBasicHeight;
+    }
+
+    public void setSupportedBasicHeight(int i) {
+        this.supportedBasicHeight = i;
+    }
+
+    public int getSupportedBasicWidth() {
+        return this.supportedBasicWidth;
+    }
+
+    public void setSupportedBasicWidth(int i) {
+        this.supportedBasicWidth = i;
+    }
+
+    public int getSupportedAdfHeight() {
+        return this.supportedAdfHeight;
+    }
+
+    public void setSupportedAdfHeight(int i) {
+        this.supportedAdfHeight = i;
+    }
+
+    public int getSupportedAdfWidth() {
+        return this.supportedAdfWidth;
+    }
+
+    public void setSupportedAdfWidth(int i) {
+        this.supportedAdfWidth = i;
+    }
+
+    public int getSupportedAdfDuplex() {
+        return this.supportedAdfDuplex;
+    }
+
+    public void setSupportedAdfDuplex(int i) {
+        this.supportedAdfDuplex = i;
+    }
+
+    public int[] getSupportedResolutionList() {
+        return this.supportedResolutionList;
+    }
+
+    public void setSupportedResolutionList(int[] iArr) {
+        this.supportedResolutionList = iArr;
+    }
+
+    public boolean isReSearch() {
+        return this.isReSearch;
+    }
+
+    public void setReSearch(boolean z) {
+        this.isReSearch = z;
+    }
+
+    public int getMaxWidth() {
+        return this.maxWidth;
+    }
+
+    public void setMaxWidth(int i) {
+        this.maxWidth = i;
+    }
+
+    public int getMaxHeight() {
+        return this.maxHeight;
+    }
+
+    public void setMaxHeight(int i) {
+        this.maxHeight = i;
+    }
+
+    public boolean isAdfDuplexYes() {
+        return this.isAdfDuplexYes;
+    }
+
+    public void setAdfDuplexYes(boolean z) {
+        this.isAdfDuplexYes = z;
+    }
+
+    public boolean isAdfDuplexRotaitonYes() {
+        return this.isAdfDuplexRotaitonYes;
+    }
+
+    public void setAdfDuplexRotaitonYes(boolean z) {
+        this.isAdfDuplexRotaitonYes = z;
+    }
+
+    public int getAdfPaperGuide() {
+        return this.adfPaperGuide;
+    }
+
+    public void setAdfPaperGuide(int i) {
+        this.adfPaperGuide = i;
+    }
+
+    @NonNull
+    public static ScannerInfo getInstance() {
+        ScannerInfo scannerInfo = new ScannerInfo();
+        scannerInfo.setScannerId("");
+        scannerInfo.setIp("");
+        scannerInfo.setModelName("");
+        scannerInfo.setLocation(1);
+        scannerInfo.setCommonDeviceName("");
+        scannerInfo.setSupportedOptions(new int[7]);
+        scannerInfo.setSupportedResolutionList(new int[64]);
+        return scannerInfo;
+    }
+}

+ 502 - 0
app/src/main/java/epson/scan/lib/escanLib.java

@@ -0,0 +1,502 @@
+package epson.scan.lib;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.support.annotation.Nullable;
+import com.epson.iprint.shared.SharedParamScan;
+import com.epson.mobilephone.common.wifidirect.escprLib;
+import epson.common.Constants;
+import epson.common.ExternalFileUtils;
+import epson.common.Utils;
+import epson.print.Util.EPLog;
+import epson.scan.activity.ScanContinueParam;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+public class escanLib implements Parcelable, EscanLibInterface {
+    public static final Parcelable.Creator<escanLib> CREATOR = new Parcelable.Creator<escanLib>() {
+        public escanLib createFromParcel(Parcel parcel) {
+            return new escanLib();
+        }
+
+        public escanLib[] newArray(int i) {
+            return new escanLib[i];
+        }
+    };
+    private static int[] escanJobAttrib;
+    private static int[] escanStatus;
+    volatile boolean bInvalidId = false;
+    private String cachePath = null;
+    private String debugString = "";
+    int error = 0;
+    private int[] escanSupportOption;
+    private int[] escanSupportResolution;
+    private boolean isAdfRotate = false;
+    private boolean isCanselOK = false;
+    private boolean isJobDone = true;
+    private boolean isScanning;
+    private List<ScannerInfo> listFoundScanner;
+    private List<String> listScannedFile = new ArrayList();
+    private ArrayList<Integer> mEscIVersionList = new ArrayList<>();
+    private boolean mIsSearch;
+    private int offsetX;
+    private int offsetY;
+    private String printerList = "";
+    private int scanAreaHeight;
+    private int scanAreaWidth;
+    private Handler scanHandler;
+    private String scanner = "";
+    volatile String scannerId;
+    volatile String scannerIp;
+
+    /* renamed from: si */
+    ScannerInfo f414si;
+    int[] status = new int[3];
+
+    private native int escanWrapperInitDriver();
+
+    public native int BMPAppendRaster(char[] cArr, char[] cArr2, int i);
+
+    public native int BMPClose(char[] cArr);
+
+    public native int BMPCreate(char[] cArr, int i, int i2, int i3);
+
+    public int describeContents() {
+        return 0;
+    }
+
+    public native int doScan(int i, int i2, int i3, boolean z, int i4);
+
+    public native int escanProbeScanner(int i, int i2, char[] cArr, int i3);
+
+    public native int escanProbeScannerById(int i, char[] cArr, char[] cArr2);
+
+    public native int escanWrapperCancelFindScanner();
+
+    public native int escanWrapperCancelJob();
+
+    public native int escanWrapperEndJob();
+
+    public native int escanWrapperEndPage(int i);
+
+    public native int escanWrapperFindScanner(int i);
+
+    public native int escanWrapperGetScanningImageInfo(int[] iArr);
+
+    public native int escanWrapperGetStatus(int[] iArr);
+
+    public native int escanWrapperGetSupportedOption(int[] iArr, int[] iArr2);
+
+    public native int escanWrapperRecvScanImageBlock(int[] iArr);
+
+    public native int escanWrapperReleaseDriver();
+
+    public native int escanWrapperSetImageName(String str);
+
+    public native int escanWrapperSetScanner(int i);
+
+    public native int escanWrapperSetWaitingConfirmFlag(boolean z);
+
+    public native int escanWrapperStartJob(int[] iArr);
+
+    public native int escanWrapperStartPage();
+
+    public void writeToParcel(Parcel parcel, int i) {
+    }
+
+    static {
+        System.loadLibrary("escan");
+    }
+
+    public int escanWrapperInitDriver(Context context) {
+        this.cachePath = new File(ExternalFileUtils.getInstance(context).getScannedImageDir(), "escan.cache").getPath();
+        return escanWrapperInitDriver();
+    }
+
+    private void updateStatusCB(int[] iArr) {
+        this.status = iArr;
+        EPLog.m313i("escanLib.java", "ESCAN SCAN status = " + this.status[0] + PreferencesConstants.COOKIE_DELIMITER + this.status[1] + PreferencesConstants.COOKIE_DELIMITER + this.status[2]);
+    }
+
+    private void findScannerCB() {
+        String str = this.scanner;
+        if (str != null && str.length() > 0) {
+            String name = getClass().getName();
+            EPLog.m313i(name, "EXTRACT Scanner information: " + this.scanner);
+            String[] split = this.scanner.split("\\|\\|");
+            this.f414si = new ScannerInfo();
+            this.f414si.setModelName(split[1]);
+            this.f414si.setIp(split[2]);
+            this.f414si.setFriendlyName(split[3]);
+            this.f414si.setScannerId(split[4]);
+            if (split.length > 6) {
+                this.f414si.setCommonDeviceName(split[6]);
+            } else {
+                this.f414si.setCommonDeviceName((String) null);
+            }
+            if (this.scannerIp == null || this.scannerId == null || !this.scannerIp.equals(this.f414si.getIp()) || this.scannerId.equals(this.f414si.getScannerId())) {
+                if (this.listFoundScanner == null) {
+                    this.listFoundScanner = new ArrayList();
+                    this.mEscIVersionList = new ArrayList<>();
+                }
+                if (this.listFoundScanner.size() > 0) {
+                    for (ScannerInfo next : this.listFoundScanner) {
+                        if (next.getScannerId() != null && this.f414si.getScannerId().equals(next.getScannerId())) {
+                            return;
+                        }
+                    }
+                }
+                if (this.mIsSearch && this.scanHandler != null) {
+                    Message obtain = Message.obtain();
+                    obtain.what = 8;
+                    Bundle bundle = new Bundle();
+                    bundle.putString("name", split[1]);
+                    bundle.putString(escprLib.PRINTER_IP, split[2]);
+                    bundle.putString("id", split[4]);
+                    if (split.length > 6) {
+                        bundle.putString("commonDeviceName", split[6]);
+                    }
+                    obtain.setData(bundle);
+                    this.scanHandler.sendMessage(obtain);
+                }
+                this.listFoundScanner.add(this.f414si);
+                this.mEscIVersionList.add(Integer.valueOf(extractEscVersion(split[5])));
+            } else {
+                this.bInvalidId = true;
+                String name2 = getClass().getName();
+                EPLog.m307e(name2, "Invalid IP Printer: Expected = " + this.scannerId);
+            }
+        }
+        this.scanner = "";
+    }
+
+    private int extractEscVersion(String str) {
+        if (str == null) {
+            return -1;
+        }
+        switch (str.charAt(0)) {
+            case '1':
+                return 1;
+            case '2':
+                return 2;
+            default:
+                return -1;
+        }
+    }
+
+    private void recvScanImageBlockCB() {
+        Handler handler = this.scanHandler;
+        if (handler != null) {
+            handler.sendEmptyMessage(10);
+        }
+    }
+
+    private void endPageCB() {
+        Handler handler = this.scanHandler;
+        if (handler != null) {
+            handler.sendEmptyMessage(11);
+        }
+        this.isCanselOK = false;
+    }
+
+    private void javaDebugCB(String str) {
+        EPLog.m313i(getClass().getName(), str.toString());
+    }
+
+    private void newFileNotifyCB(String str) {
+        this.listScannedFile.add(str.toString());
+        this.mEscIVersionList.add(-1);
+        String name = getClass().getName();
+        EPLog.m313i(name, "newFileNotifyCB() call, Scan new file: " + str.toString() + ", totals: " + this.listScannedFile.size());
+        this.isCanselOK = true;
+    }
+
+    public void resetEscanLib() {
+        this.isJobDone = false;
+        this.error = 0;
+        this.status = new int[3];
+        this.listFoundScanner = new ArrayList();
+        this.mEscIVersionList.clear();
+    }
+
+    public int probeScannerById(String str, String str2) {
+        resetEscanLib();
+        resetIPAdressCheck();
+        int escanProbeScannerById = escanProbeScannerById(120, str.toCharArray(), str2.toCharArray());
+        EPLog.m313i("EPSON escanLib", "scanners.probeScannerById() error = " + String.valueOf(escanProbeScannerById));
+        return escanProbeScannerById;
+    }
+
+    public int probeScannerByIp(String str, String str2) {
+        resetEscanLib();
+        resetIPAdressCheck();
+        this.scannerId = str;
+        this.scannerIp = str2;
+        int escanProbeScanner = escanProbeScanner(120, 2, str2.toCharArray(), str2.toCharArray().length);
+        if (escanProbeScanner != 0 || !this.bInvalidId) {
+            return escanProbeScanner;
+        }
+        return -500001;
+    }
+
+    public void resetIPAdressCheck() {
+        this.scannerId = null;
+        this.scannerId = null;
+        this.bInvalidId = false;
+    }
+
+    public int startScanJob(String str) {
+        this.isScanning = true;
+        this.isCanselOK = false;
+        this.error = escanWrapperSetImageName(str);
+        if (this.error != 0) {
+            EPLog.m313i("EPSON escanLib", "scanners.escanWrapperSetImageName(scannedImageNamePath) error = " + String.valueOf(this.error));
+            return this.error;
+        }
+        EPLog.m313i("EPSON escanLib", escanJobAttrib[0] + PreferencesConstants.COOKIE_DELIMITER + escanJobAttrib[1] + PreferencesConstants.COOKIE_DELIMITER + escanJobAttrib[2] + PreferencesConstants.COOKIE_DELIMITER + escanJobAttrib[3] + PreferencesConstants.COOKIE_DELIMITER + escanJobAttrib[4] + PreferencesConstants.COOKIE_DELIMITER + escanJobAttrib[5] + PreferencesConstants.COOKIE_DELIMITER + escanJobAttrib[6] + PreferencesConstants.COOKIE_DELIMITER + escanJobAttrib[7] + PreferencesConstants.COOKIE_DELIMITER + escanJobAttrib[8] + PreferencesConstants.COOKIE_DELIMITER + escanJobAttrib[9] + PreferencesConstants.COOKIE_DELIMITER + escanJobAttrib[10] + PreferencesConstants.COOKIE_DELIMITER + escanJobAttrib[11] + PreferencesConstants.COOKIE_DELIMITER + escanJobAttrib[12]);
+        this.error = escanWrapperStartJob(escanJobAttrib);
+        if (this.error != 0) {
+            EPLog.m313i("EPSON escanLib", "scanners.escanWrapperStartJob(escanJobAttrib) error = " + String.valueOf(this.error));
+            return this.error;
+        }
+        EPLog.m313i("**** isAdfRotate = ", String.valueOf(this.isAdfRotate));
+        this.error = doScan(0, 0, 0, this.isAdfRotate, ScanContinueParam.getAvailableScanPageCount());
+        escanWrapperEndJob();
+        this.isScanning = false;
+        return this.error;
+    }
+
+    public int cancelScanJob() {
+        this.error = escanWrapperCancelJob();
+        return this.error;
+    }
+
+    public int GetSupportedOption() {
+        this.escanSupportOption = new int[7];
+        this.escanSupportResolution = new int[64];
+        this.error = escanWrapperGetSupportedOption(this.escanSupportOption, this.escanSupportResolution);
+        EPLog.m313i("epson.print.escanLib", "getSupportedOption: " + this.escanSupportOption[1] + PreferencesConstants.COOKIE_DELIMITER + this.escanSupportOption[2] + PreferencesConstants.COOKIE_DELIMITER + this.escanSupportOption[3] + PreferencesConstants.COOKIE_DELIMITER + this.escanSupportOption[4] + PreferencesConstants.COOKIE_DELIMITER + this.escanSupportOption[5] + PreferencesConstants.COOKIE_DELIMITER + this.escanSupportOption[6]);
+        return this.error;
+    }
+
+    public void makeJobAttribute(Context context, SharedParamScan sharedParamScan) {
+        escanJobAttrib = new int[13];
+        escanJobAttrib[0] = Utils.getPrefInt(context, Constants.SCAN_REFS_SUPPORTED_OPTIONS, Constants.SCAN_REFS_OPTIONS_VERSION);
+        setScanArea(context, sharedParamScan);
+        escanJobAttrib[7] = sharedParamScan.isAvailable() ? sharedParamScan.getScan_type() : Utils.getPrefInt(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_COLOR);
+        if (Utils.getPrefInt(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_2SIDED) == 1 && Utils.getPrefInt(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_SOURCE) == 1) {
+            escanJobAttrib[8] = 2;
+        } else if (Utils.getPrefInt(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_2SIDED) == 0 && Utils.getPrefInt(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_SOURCE) == 1) {
+            escanJobAttrib[8] = 1;
+        } else {
+            escanJobAttrib[8] = 0;
+        }
+        int[] iArr = escanJobAttrib;
+        iArr[9] = 1;
+        iArr[10] = Utils.getPrefInt(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_GAMMA);
+        escanJobAttrib[11] = Utils.getPrefInt(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_DENSITY);
+        if (escanJobAttrib[8] == 2) {
+            this.isAdfRotate = Utils.getPrefBoolean(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_ROTATE);
+        } else {
+            this.isAdfRotate = false;
+        }
+        escanJobAttrib[12] = Utils.getPrefInt(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_ADF_PAPER_GUIDE);
+        EPLog.m313i("makeJobAttribute", "**** PAPER_GUIDE =  " + escanJobAttrib[12]);
+    }
+
+    public void setScanArea(Context context, SharedParamScan sharedParamScan) {
+        int i;
+        int[] iArr = escanJobAttrib;
+        if (sharedParamScan.isAvailable()) {
+            i = sharedParamScan.getRes_main();
+        } else {
+            i = Utils.getPrefInt(context, Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_RESOLUTION);
+        }
+        iArr[1] = i;
+        int[] iArr2 = escanJobAttrib;
+        iArr2[2] = this.offsetX;
+        iArr2[3] = this.offsetY;
+        iArr2[4] = sharedParamScan.isAvailable() ? sharedParamScan.getPixel_main() : this.scanAreaWidth;
+        escanJobAttrib[5] = sharedParamScan.isAvailable() ? sharedParamScan.getPixel_sub() : this.scanAreaHeight;
+        int[] iArr3 = escanJobAttrib;
+        int i2 = iArr3[1];
+        if (i2 == 75) {
+            iArr3[6] = 16;
+        } else if (i2 != 300) {
+            iArr3[6] = 8;
+        } else {
+            iArr3[6] = 4;
+        }
+    }
+
+    public int getError() {
+        return this.error;
+    }
+
+    public void setError(int i) {
+        this.error = i;
+    }
+
+    public void setJobDone(boolean z) {
+        this.isJobDone = z;
+    }
+
+    public boolean isJobDone() {
+        return this.isJobDone;
+    }
+
+    public int[] getEscanSupportOption() {
+        return this.escanSupportOption;
+    }
+
+    public void setEscanSupportOption(int[] iArr) {
+        this.escanSupportOption = iArr;
+    }
+
+    public int[] getEscanSupportResolution() {
+        return this.escanSupportResolution;
+    }
+
+    public void setEscanSupportResolution(int[] iArr) {
+        this.escanSupportResolution = iArr;
+    }
+
+    public int getOffsetX() {
+        return this.offsetX;
+    }
+
+    public void setOffsetX(int i) {
+        this.offsetX = i;
+    }
+
+    public int getOffsetY() {
+        return this.offsetY;
+    }
+
+    public void setOffsetY(int i) {
+        this.offsetY = i;
+    }
+
+    public int getScanAreaWidth() {
+        return this.scanAreaWidth;
+    }
+
+    public void setScanAreaWidth(int i) {
+        this.scanAreaWidth = i;
+    }
+
+    public int getScanAreaHeight() {
+        return this.scanAreaHeight;
+    }
+
+    public void setScanAreaHeight(int i) {
+        this.scanAreaHeight = i;
+    }
+
+    public List<ScannerInfo> getListFoundScanner() {
+        return this.listFoundScanner;
+    }
+
+    public void setListFoundScanner(List<ScannerInfo> list) {
+        this.listFoundScanner = list;
+    }
+
+    public List<String> getListScannedFile() {
+        return this.listScannedFile;
+    }
+
+    public void setListScannedFile(List<String> list) {
+        this.listScannedFile = list;
+    }
+
+    public int getEscIVersion(int i) {
+        if (i < 0 || i >= this.mEscIVersionList.size()) {
+            return -1;
+        }
+        return this.mEscIVersionList.get(i).intValue();
+    }
+
+    public boolean isScanning() {
+        return this.isScanning;
+    }
+
+    public void setScanning(boolean z) {
+        this.isScanning = z;
+    }
+
+    public int[] getStatus() {
+        return this.status;
+    }
+
+    public void setStatus(int[] iArr) {
+        this.status = iArr;
+    }
+
+    public boolean isCanselOK() {
+        return this.isCanselOK;
+    }
+
+    public Handler getScanHandler() {
+        return this.scanHandler;
+    }
+
+    public void setScanHandler(Handler handler) {
+        this.scanHandler = handler;
+    }
+
+    public void setSearchStt(boolean z) {
+        this.mIsSearch = z;
+    }
+
+    public boolean getSearchStt() {
+        return this.mIsSearch;
+    }
+
+    public ScannerInfo probeByIpAndGetScannerInfo(String str, String str2) {
+        List<ScannerInfo> listFoundScanner2;
+        resetEscanLib();
+        if (str == null || str.isEmpty()) {
+            str = null;
+        }
+        if (probeScannerByIp(str, str2) == 0 && (listFoundScanner2 = getListFoundScanner()) != null) {
+            return listFoundScanner2.get(0);
+        }
+        return null;
+    }
+
+    @Nullable
+    public I1ScanParams getScanParams() {
+        int[] iArr = escanJobAttrib;
+        if (iArr == null || iArr.length < 3) {
+            return null;
+        }
+        I1ScanParams i1ScanParams = new I1ScanParams();
+        switch (escanJobAttrib[8]) {
+            case 0:
+                i1ScanParams.inputDevice = 0;
+                i1ScanParams.twoSide = 0;
+                break;
+            case 1:
+                i1ScanParams.inputDevice = 1;
+                i1ScanParams.twoSide = 0;
+                break;
+            case 2:
+                i1ScanParams.inputDevice = 1;
+                i1ScanParams.twoSide = 1;
+                break;
+            default:
+                return null;
+        }
+        int[] iArr2 = escanJobAttrib;
+        i1ScanParams.colorType = iArr2[7];
+        i1ScanParams.resolution = iArr2[1];
+        i1ScanParams.gamma = iArr2[10];
+        i1ScanParams.brightness = 255 - iArr2[11];
+        return i1ScanParams;
+    }
+}

+ 29 - 0
app/src/main/java/epson/scan/lib/libHaru.java

@@ -0,0 +1,29 @@
+package epson.scan.lib;
+
+import java.util.ArrayList;
+
+public class libHaru {
+    public native int EndDoc(String str);
+
+    public native int addPage(String str);
+
+    public native int initDoc();
+
+    static {
+        System.loadLibrary("haru");
+    }
+
+    public int createPDF(ArrayList<String> arrayList, String str) {
+        int initDoc = initDoc();
+        if (initDoc != 0) {
+            return initDoc;
+        }
+        for (int i = 0; i < arrayList.size(); i++) {
+            int addPage = addPage(arrayList.get(i));
+            if (addPage != 0) {
+                return addPage;
+            }
+        }
+        return EndDoc(str);
+    }
+}

+ 253 - 0
app/src/main/java/epson/server/screens/StorageServer.java

@@ -0,0 +1,253 @@
+package epson.server.screens;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.AsyncTask;
+import android.os.Build;
+import android.os.Bundle;
+import android.view.View;
+import com.epson.iprint.storage.StorageProcessActivity;
+import com.epson.iprint.storage.StorageProcessDownloadActivity;
+import com.epson.iprint.storage.StorageServiceClient;
+import com.epson.iprint.storage.gdrivev3.ListAndDownloadActivity;
+import com.epson.iprint.storage.onedrive.OneDriveStorageProcessUploadActivity;
+import epson.common.ExternalFileUtils;
+import epson.print.ActivityIACommon;
+import epson.print.ActivityRequestPermissions;
+import epson.print.C2135R;
+import epson.print.CommonDefine;
+import epson.print.SimpleMessageDialogFragment;
+import epson.print.Util.EPLog;
+import epson.print.Util.Utils;
+import epson.print.screen.WorkingDialog;
+import epson.server.utils.Define;
+import epson.server.utils.MyUtility;
+import java.util.ArrayList;
+
+public class StorageServer extends ActivityIACommon implements CommonDefine {
+    public static final String FOR_PRINT_LOGGER_CALL_FROM = "forLoggerCallFrom";
+    public static final int FOR_PRINT_LOGGER_CALL_FROM_NO_INFO = 0;
+    public static final int FOR_PRINT_LOGGER_CALL_FROM_SCAN = 1;
+    private static final int REQEST_RUNTIMEPERMMISSION = 1;
+    int mNumOfFiles;
+    boolean mScanSaveAction = false;
+    /* access modifiers changed from: private */
+    public ArrayList<String> mScanedFilePath = new ArrayList<>();
+
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        setContentView((int) C2135R.layout.choose_storage_server);
+        setActionBar((int) C2135R.string.network_storage_title, true);
+        new AsyncTask<Void, Void, Boolean>() {
+            WorkingDialog workingDialog = new WorkingDialog(StorageServer.this);
+
+            /* access modifiers changed from: protected */
+            public void onPreExecute() {
+                super.onPreExecute();
+                this.workingDialog.show();
+            }
+
+            /* access modifiers changed from: protected */
+            public Boolean doInBackground(Void... voidArr) {
+                if (!Utils.getInstance().isNetworkAvailable(StorageServer.this)) {
+                    return false;
+                }
+                if (new MyUtility().doNet(StorageServer.this) == "") {
+                    return false;
+                }
+                return true;
+            }
+
+            /* access modifiers changed from: protected */
+            public void onPostExecute(Boolean bool) {
+                super.onPostExecute(bool);
+                this.workingDialog.dismiss();
+                StorageServer.this.initStorageItem(bool.booleanValue());
+            }
+        }.execute(new Void[0]);
+    }
+
+    /* access modifiers changed from: protected */
+    public void onActivityResult(int i, int i2, Intent intent) {
+        super.onActivityResult(i, i2, intent);
+        if (i == 1 && i2 == -1) {
+            saveLocalMemory();
+        }
+    }
+
+    /* access modifiers changed from: package-private */
+    public void initStorageItem(boolean z) {
+        if (getIntent().getIntExtra(FOR_PRINT_LOGGER_CALL_FROM, 0) == 1) {
+            this.mScanSaveAction = true;
+        } else {
+            this.mScanSaveAction = false;
+        }
+        final int intExtra = getIntent().getIntExtra(Define.PICK_SERVER_FOR, 1);
+        if (!z) {
+            findViewById(C2135R.C2137id.evernote).setEnabled(false);
+            findViewById(C2135R.C2137id.google_doc).setEnabled(false);
+            findViewById(C2135R.C2137id.drop_box).setEnabled(false);
+            findViewById(C2135R.C2137id.box_net).setEnabled(false);
+            findViewById(C2135R.C2137id.onedrive).setEnabled(false);
+            findViewById(C2135R.C2137id.evernote_next).setVisibility(8);
+            findViewById(C2135R.C2137id.google_doc_next).setVisibility(8);
+            findViewById(C2135R.C2137id.drop_box_next).setVisibility(8);
+            findViewById(C2135R.C2137id.box_net_next).setVisibility(8);
+            findViewById(C2135R.C2137id.onedrive_next).setVisibility(8);
+            new AlertDialog.Builder(this).setCancelable(false).setMessage(getString(C2135R.string.str_no_network)).setPositiveButton(getString(C2135R.string.str_ok), new DialogInterface.OnClickListener() {
+                public void onClick(DialogInterface dialogInterface, int i) {
+                }
+            }).show();
+        }
+        if (intExtra == 2) {
+            this.mScanedFilePath = getIntent().getStringArrayListExtra(Define.SAVING_FILE_PATH);
+            findViewById(C2135R.C2137id.save_to_local_section).setVisibility(0);
+            setTitle(C2135R.string.save_to_title_name);
+        }
+        findViewById(C2135R.C2137id.evernote).setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                boolean z = StorageServer.this.mScanSaveAction;
+                switch (intExtra) {
+                    case 1:
+                        StorageServer.this.startActivity(StorageProcessDownloadActivity.getStartIntent(StorageServer.this.getApplicationContext(), StorageServiceClient.STORAGE_EVERNOTE));
+                        return;
+                    case 2:
+                        Intent processIntent = StorageProcessActivity.getProcessIntent(StorageServer.this.getBaseContext(), StorageServiceClient.STORAGE_EVERNOTE, StorageProcessActivity.ProcessType.UPLOAD);
+                        processIntent.putStringArrayListExtra(StorageProcessActivity.EXTRA_UPLOADFILE_LIST, StorageServer.this.mScanedFilePath);
+                        StorageServer.this.startActivity(processIntent);
+                        return;
+                    default:
+                        return;
+                }
+            }
+        });
+        findViewById(C2135R.C2137id.google_doc).setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                switch (intExtra) {
+                    case 1:
+                        StorageServer.this.startActivity(new Intent(StorageServer.this.getApplicationContext(), ListAndDownloadActivity.class));
+                        return;
+                    case 2:
+                        Intent processIntent = StorageProcessActivity.getProcessIntent(StorageServer.this.getBaseContext(), StorageServiceClient.STORAGE_GOOGLEDRIVE, StorageProcessActivity.ProcessType.UPLOAD);
+                        processIntent.putStringArrayListExtra(StorageProcessActivity.EXTRA_UPLOADFILE_LIST, StorageServer.this.mScanedFilePath);
+                        StorageServer.this.startActivity(processIntent);
+                        return;
+                    default:
+                        return;
+                }
+            }
+        });
+        findViewById(C2135R.C2137id.drop_box).setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                boolean z = StorageServer.this.mScanSaveAction;
+                switch (intExtra) {
+                    case 1:
+                        StorageServer.this.startActivity(StorageProcessDownloadActivity.getStartIntent(StorageServer.this.getApplicationContext(), StorageServiceClient.STORAGE_DROPBOX));
+                        return;
+                    case 2:
+                        Intent processIntent = StorageProcessActivity.getProcessIntent(StorageServer.this.getBaseContext(), StorageServiceClient.STORAGE_DROPBOX, StorageProcessActivity.ProcessType.UPLOAD);
+                        processIntent.putStringArrayListExtra(StorageProcessActivity.EXTRA_UPLOADFILE_LIST, StorageServer.this.mScanedFilePath);
+                        StorageServer.this.startActivity(processIntent);
+                        return;
+                    default:
+                        return;
+                }
+            }
+        });
+        findViewById(C2135R.C2137id.box_net).setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                if (Build.VERSION.SDK_INT <= 20) {
+                    StorageServer.this.showCannotUseDialog();
+                    return;
+                }
+                switch (intExtra) {
+                    case 1:
+                        StorageServer.this.startActivity(StorageProcessDownloadActivity.getStartIntent(StorageServer.this.getApplicationContext(), StorageServiceClient.STORAGE_BOX));
+                        return;
+                    case 2:
+                        Intent processIntent = StorageProcessActivity.getProcessIntent(StorageServer.this.getBaseContext(), StorageServiceClient.STORAGE_BOX, StorageProcessActivity.ProcessType.UPLOAD);
+                        processIntent.putStringArrayListExtra(StorageProcessActivity.EXTRA_UPLOADFILE_LIST, StorageServer.this.mScanedFilePath);
+                        StorageServer.this.startActivity(processIntent);
+                        return;
+                    default:
+                        return;
+                }
+            }
+        });
+        findViewById(C2135R.C2137id.onedrive).setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                switch (intExtra) {
+                    case 1:
+                        StorageServer.this.startActivity(StorageProcessDownloadActivity.getStartIntent(StorageServer.this.getApplicationContext(), StorageServiceClient.STORAGE_ONEDRIVE));
+                        return;
+                    case 2:
+                        Intent processIntent = OneDriveStorageProcessUploadActivity.getProcessIntent(StorageServer.this.getBaseContext(), StorageServiceClient.STORAGE_ONEDRIVE, StorageProcessActivity.ProcessType.UPLOAD);
+                        processIntent.putStringArrayListExtra(StorageProcessActivity.EXTRA_UPLOADFILE_LIST, StorageServer.this.mScanedFilePath);
+                        StorageServer.this.startActivity(processIntent);
+                        return;
+                    default:
+                        return;
+                }
+            }
+        });
+        findViewById(C2135R.C2137id.local_memory).setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                if (ActivityRequestPermissions.isRuntimePermissionSupported()) {
+                    String[] strArr = {"android.permission.WRITE_EXTERNAL_STORAGE"};
+                    String[] strArr2 = {StorageServer.this.getString(C2135R.string.permission_dialog_title), StorageServer.this.getString(C2135R.string.permission_dialog_title)};
+                    StorageServer storageServer = StorageServer.this;
+                    StorageServer storageServer2 = StorageServer.this;
+                    ActivityRequestPermissions.Permission permission = new ActivityRequestPermissions.Permission(strArr[0], strArr2, new String[]{ActivityRequestPermissions.DialogParameter.setMessage2((Context) storageServer, storageServer.getString(C2135R.string.permission_dialog_message_storage)), ActivityRequestPermissions.DialogParameter.setMessage3A((Context) storageServer2, storageServer2.getString(C2135R.string.permission_dialog_message_storage), StorageServer.this.getString(C2135R.string.permission_function_storage))});
+                    if (!ActivityRequestPermissions.checkPermission(StorageServer.this, strArr)) {
+                        ActivityRequestPermissions.requestPermission((Activity) StorageServer.this, permission, 1);
+                        return;
+                    }
+                }
+                StorageServer.this.saveLocalMemory();
+            }
+        });
+        findViewById(C2135R.C2137id.open_in).setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                boolean z = StorageServer.this.mScanSaveAction;
+                Intent intent = new Intent();
+                intent.putStringArrayListExtra(Define.SAVING_FILE_PATH, StorageServer.this.mScanedFilePath);
+                intent.putExtra("for", 6);
+                intent.setClass(StorageServer.this.getBaseContext(), UploadScreen.class);
+                StorageServer.this.startActivity(intent);
+            }
+        });
+    }
+
+    /* access modifiers changed from: private */
+    public void showCannotUseDialog() {
+        SimpleMessageDialogFragment.newInstance(C2135R.string.box_button_message).show(getSupportFragmentManager(), "can-not-use-dialog");
+    }
+
+    /* access modifiers changed from: package-private */
+    public void saveLocalMemory() {
+        Intent intent = new Intent();
+        intent.putStringArrayListExtra(Define.SAVING_FILE_PATH, this.mScanedFilePath);
+        intent.putExtra("for", 7);
+        intent.setClass(getBaseContext(), UploadScreen.class);
+        startActivity(intent);
+    }
+
+    /* access modifiers changed from: protected */
+    public void onResume() {
+        super.onResume();
+    }
+
+    /* access modifiers changed from: protected */
+    public void onDestroy() {
+        super.onDestroy();
+    }
+
+    public void onBackPressed() {
+        super.onBackPressed();
+        EPLog.m313i("StorageServer ", "(onBackPressed)");
+        ExternalFileUtils.getInstance(this).initDownloadDir();
+    }
+}

+ 521 - 0
app/src/main/java/epson/server/screens/UploadScreen.java

@@ -0,0 +1,521 @@
+package epson.server.screens;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.content.Intent;
+import android.media.MediaScannerConnection;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.os.Parcelable;
+import android.support.media.ExifInterface;
+import android.support.p000v4.media.session.PlaybackStateCompat;
+import android.text.Editable;
+import android.text.InputFilter;
+import android.text.TextWatcher;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.RadioGroup;
+import android.widget.TextView;
+import android.widget.Toast;
+import epson.common.Constants;
+import epson.common.ExternalFileUtils;
+import epson.print.ActivityIACommon;
+import epson.print.C2135R;
+import epson.print.CommonDefine;
+import epson.print.ScanFileNumber;
+import epson.print.Util.EPLog;
+import epson.print.Util.Utils;
+import epson.print.fileBrower;
+import epson.provider.ScannedFileProvider;
+import epson.scan.lib.libHaru;
+import epson.server.utils.Define;
+import epson.server.utils.MyUtility;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Vector;
+
+public class UploadScreen extends ActivityIACommon implements CommonDefine {
+    private static final int LOCAL_SAVED = 16;
+    private static final int SET_SCREENSTATE = 0;
+    private static final String TAG = "UploadScreen";
+    private final int MAX_COPY_COUNT = 99;
+    private RadioGroup chooseFileType;
+    /* access modifiers changed from: private */
+    public int count;
+    String currentFileName;
+    Dialog errorDialog;
+    boolean isSaved = false;
+    /* access modifiers changed from: private */
+    public Button mClear;
+    /* access modifiers changed from: private */
+    public EditText mFileName;
+    /* access modifiers changed from: private */
+    public String mFileType = Constants.PDF_TYPE;
+    /* access modifiers changed from: private */
+    public Handler mHandler = new Handler(new Handler.Callback() {
+        public boolean handleMessage(Message message) {
+            int i = message.what;
+            if (i == 0) {
+                UploadScreen.this.setScreenState(false);
+            } else if (i == 16) {
+                EPLog.m313i("createUploadThread", "5:" + UploadScreen.this.isSaved);
+                if (UploadScreen.this.isSaved) {
+                    UploadScreen.this.setResult(-1, UploadScreen.this.getIntent());
+                    UploadScreen.this.finish();
+                } else {
+                    EPLog.m313i("createUploadThread", "6:" + UploadScreen.this.isSaved);
+                    UploadScreen uploadScreen = UploadScreen.this;
+                    uploadScreen.errorDialog = new ErrorDialog(uploadScreen, C2135R.style.AppTheme_Translucent, 4, 0, false);
+                    UploadScreen.this.errorDialog.show();
+                    UploadScreen.this.setScreenState(false);
+                }
+            }
+            return false;
+        }
+    });
+    /* access modifiers changed from: private */
+    public boolean mIsRename;
+    /* access modifiers changed from: private */
+    public ArrayList<String> mListFilePath;
+    /* access modifiers changed from: private */
+    public Button mSaveBtn;
+    /* access modifiers changed from: private */
+    public Vector<File> mSaveFiles = new Vector<>();
+    /* access modifiers changed from: private */
+    public Utils utils = new Utils();
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        setContentView((int) C2135R.layout.upload_dialog);
+        setActionBar("", true);
+        this.mSaveBtn = (Button) findViewById(C2135R.C2137id.save_button);
+        this.mFileName = (EditText) findViewById(C2135R.C2137id.upload_dialog_file_name);
+        this.mFileName.setFilters(new InputFilter[]{new InputFilter.LengthFilter(64)});
+        this.mFileName.setOnFocusChangeListener(new View.OnFocusChangeListener() {
+            public void onFocusChange(View view, boolean z) {
+                if (!z) {
+                    UploadScreen.this.mFileName.extendSelection(0);
+                    UploadScreen.this.mFileName.setSelection(0);
+                }
+            }
+        });
+        this.mClear = (Button) findViewById(C2135R.C2137id.clear_name_btn);
+        this.count = ScanFileNumber.getCount(this);
+        EditText editText = this.mFileName;
+        editText.setText("EPSON" + this.utils.editNumber(this.count));
+        if (this.mFileName.getText().toString().length() > 0) {
+            this.mClear.setVisibility(0);
+        }
+        this.mFileName.addTextChangedListener(new TextWatcher() {
+            public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
+            }
+
+            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
+            }
+
+            public void afterTextChanged(Editable editable) {
+                if (UploadScreen.this.mFileName.getText().toString().length() > 0) {
+                    UploadScreen.this.mClear.setVisibility(0);
+                    UploadScreen.this.mSaveBtn.setEnabled(true);
+                    return;
+                }
+                UploadScreen.this.mClear.setVisibility(8);
+                UploadScreen.this.mSaveBtn.setEnabled(false);
+            }
+        });
+        this.mClear.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                UploadScreen.this.mFileName.getText().clear();
+            }
+        });
+        this.chooseFileType = (RadioGroup) findViewById(C2135R.C2137id.file_type_for_upload);
+        this.chooseFileType.check(C2135R.C2137id.pdf_type);
+        this.mFileType = Constants.PDF_TYPE;
+        this.chooseFileType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+            public void onCheckedChanged(RadioGroup radioGroup, int i) {
+                if (i == C2135R.C2137id.jpeg_type) {
+                    String unused = UploadScreen.this.mFileType = Constants.JPEG_TYPE;
+                    EPLog.m313i("checkedId", "....." + UploadScreen.this.mFileType);
+                } else if (i == C2135R.C2137id.pdf_type) {
+                    String unused2 = UploadScreen.this.mFileType = Constants.PDF_TYPE;
+                    EPLog.m313i("checkedId", "....." + UploadScreen.this.mFileType);
+                }
+            }
+        });
+        this.mListFilePath = getIntent().getStringArrayListExtra(Define.SAVING_FILE_PATH);
+        Long l = 0L;
+        Iterator<String> it = this.mListFilePath.iterator();
+        while (it.hasNext()) {
+            l = Long.valueOf(l.longValue() + new File(it.next()).length());
+        }
+        float longValue = (float) (l.longValue() / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID);
+        if (longValue > 500.0f) {
+            ((TextView) findViewById(C2135R.C2137id.file_size)).setText("" + MyUtility.mathRound((double) (longValue / 1024.0f), 2) + "MB");
+        } else {
+            ((TextView) findViewById(C2135R.C2137id.file_size)).setText("" + MyUtility.mathRound((double) longValue, 2) + "KB");
+        }
+        switch (getIntent().getIntExtra("for", 7)) {
+            case 6:
+                setTitle(getString(C2135R.string.open_in));
+                this.mSaveBtn.setText(getString(C2135R.string.open_in));
+                this.mSaveBtn.setOnClickListener(new View.OnClickListener() {
+                    public void onClick(View view) {
+                        String str;
+                        boolean z;
+                        Intent intent = new Intent();
+                        try {
+                            if (!fileBrower.isAvailableFileName(UploadScreen.this.mFileName.getText().toString())) {
+                                Toast.makeText(UploadScreen.this.getApplicationContext(), C2135R.string.str_error_Filename, 1).show();
+                                return;
+                            }
+                            intent.setAction("android.intent.action.SEND");
+                            if (UploadScreen.this.mFileType.equals(Constants.PDF_TYPE)) {
+                                ArrayList arrayList = new ArrayList();
+                                Iterator it = UploadScreen.this.mListFilePath.iterator();
+                                while (it.hasNext()) {
+                                    arrayList.add((String) it.next());
+                                }
+                                libHaru libharu = new libHaru();
+                                String scannedImageDir = ExternalFileUtils.getInstance(UploadScreen.this).getScannedImageDir();
+                                File file = new File(scannedImageDir, UploadScreen.this.mFileName.getText().toString() + CommonDefine.FileType_PDF);
+                                libharu.createPDF(arrayList, file.getAbsolutePath());
+                                intent.putExtra("android.intent.extra.STREAM", ScannedFileProvider.getUriForFile(UploadScreen.this, file));
+                                intent.setType("application/pdf");
+                            } else {
+                                String obj = UploadScreen.this.mFileName.getText().toString();
+                                if (!obj.equals("EPSON" + UploadScreen.this.utils.editNumber(UploadScreen.this.count))) {
+                                    str = UploadScreen.this.mFileName.getText().toString();
+                                    z = true;
+                                } else if (UploadScreen.this.mListFilePath.size() == 1) {
+                                    str = UploadScreen.this.mFileName.getText().toString();
+                                    z = false;
+                                } else {
+                                    str = "EPSON";
+                                    z = false;
+                                }
+                                ArrayList arrayList2 = new ArrayList();
+                                int access$500 = UploadScreen.this.count;
+                                ExternalFileUtils.getInstance(UploadScreen.this).createTempFolder(ExternalFileUtils.getInstance(UploadScreen.this).getScannedImageDir());
+                                if (UploadScreen.this.mListFilePath.size() == 1) {
+                                    UploadScreen uploadScreen = UploadScreen.this;
+                                    arrayList2.add(ScannedFileProvider.getUriForFile(UploadScreen.this, MyUtility.createTempFile(uploadScreen, (String) UploadScreen.this.mListFilePath.get(0), str + ".jpg")));
+                                } else {
+                                    if (z) {
+                                        access$500 = 1;
+                                    }
+                                    for (int i = 0; i < UploadScreen.this.mListFilePath.size(); i++) {
+                                        UploadScreen uploadScreen2 = UploadScreen.this;
+                                        access$500++;
+                                        arrayList2.add(ScannedFileProvider.getUriForFile(UploadScreen.this, MyUtility.createTempFile(uploadScreen2, (String) UploadScreen.this.mListFilePath.get(i), str + UploadScreen.this.utils.editNumber(access$500) + ".jpg")));
+                                    }
+                                }
+                                if (arrayList2.size() <= 1) {
+                                    intent.putExtra("android.intent.extra.STREAM", (Parcelable) arrayList2.get(0));
+                                } else {
+                                    intent.setAction("android.intent.action.SEND_MULTIPLE");
+                                    intent.putParcelableArrayListExtra("android.intent.extra.STREAM", arrayList2);
+                                }
+                                intent.setType("image/jpg");
+                            }
+                            UploadScreen.this.startActivity(Intent.createChooser(intent, UploadScreen.this.getString(C2135R.string.open_in)));
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+                });
+                return;
+            case 7:
+                setTitle(getString(C2135R.string.local_memory));
+                ((TextView) findViewById(C2135R.C2137id.upload_dialog_save_path)).setText(EPSONIPRINT_FOLDER);
+                findViewById(C2135R.C2137id.upload_dialog_save_path).setVisibility(0);
+                this.mSaveBtn.setText(getString(C2135R.string.str_save));
+                this.mSaveBtn.setOnClickListener(new View.OnClickListener() {
+                    public void onClick(View view) {
+                        String str;
+                        if (!fileBrower.isAvailableFileName(UploadScreen.this.mFileName.getText().toString())) {
+                            Toast.makeText(UploadScreen.this.getApplicationContext(), C2135R.string.str_error_Filename, 1).show();
+                        } else if (UploadScreen.this.mFileName.getText().toString().length() > 0) {
+                            UploadScreen.this.setScreenState(true);
+                            Iterator it = UploadScreen.this.mListFilePath.iterator();
+                            while (it.hasNext()) {
+                                UploadScreen.this.mSaveFiles.add(new File((String) it.next()));
+                            }
+                            String obj = UploadScreen.this.mFileName.getText().toString();
+                            if (!obj.equals("EPSON" + UploadScreen.this.utils.editNumber(UploadScreen.this.count))) {
+                                boolean unused = UploadScreen.this.mIsRename = true;
+                                str = UploadScreen.this.mFileName.getText().toString();
+                            } else if (UploadScreen.this.mSaveFiles.size() == 1) {
+                                boolean unused2 = UploadScreen.this.mIsRename = false;
+                                str = UploadScreen.this.mFileName.getText().toString();
+                            } else {
+                                boolean unused3 = UploadScreen.this.mIsRename = false;
+                                str = "EPSON";
+                            }
+                            UploadScreen uploadScreen = UploadScreen.this;
+                            uploadScreen.currentFileName = str;
+                            uploadScreen.createUploadThread();
+                        }
+                    }
+                });
+                return;
+            default:
+                return;
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void createUploadThread() {
+        new Thread() {
+            public void run() {
+                File file;
+                UploadScreen.this.isSaved = false;
+                try {
+                    MyUtility.createFolder(CommonDefine.EPSONIPRINT_FOLDER);
+                    int access$500 = UploadScreen.this.count;
+                    if (UploadScreen.this.mSaveFiles.size() != 1) {
+                        if (UploadScreen.this.mIsRename) {
+                            access$500 = 1;
+                        }
+                        if (!UploadScreen.this.mFileType.equals(Constants.PDF_TYPE)) {
+                            Iterator it = UploadScreen.this.mSaveFiles.iterator();
+                            while (true) {
+                                if (!it.hasNext()) {
+                                    break;
+                                }
+                                UploadScreen.this.isSaved = true;
+                                UploadScreen uploadScreen = UploadScreen.this;
+                                String absolutePath = ((File) it.next()).getAbsolutePath();
+                                File createTempFile = MyUtility.createTempFile(uploadScreen, absolutePath, UploadScreen.this.currentFileName + UploadScreen.this.utils.editNumber(access$500) + ".jpg");
+                                if (createTempFile == null) {
+                                    UploadScreen.this.isSaved = false;
+                                    break;
+                                }
+                                File file2 = new File(CommonDefine.EPSONIPRINT_FOLDER + UploadScreen.this.currentFileName + UploadScreen.this.utils.editNumber(access$500) + ".jpg");
+                                if (file2.exists() && !UploadScreen.this.mIsRename) {
+                                    int i = 1;
+                                    while (true) {
+                                        File file3 = new File(CommonDefine.EPSONIPRINT_FOLDER + UploadScreen.this.currentFileName + UploadScreen.this.utils.editNumber(access$500) + " (" + i + ")" + ".jpg");
+                                        if (!file3.exists()) {
+                                            file2 = file3;
+                                            break;
+                                        } else if (i >= 99) {
+                                            file2 = new File(CommonDefine.EPSONIPRINT_FOLDER + UploadScreen.this.currentFileName + UploadScreen.this.utils.editNumber(access$500) + " (" + 99 + ")" + ".jpg");
+                                            break;
+                                        } else {
+                                            i++;
+                                        }
+                                    }
+                                }
+                                access$500++;
+                                MyUtility.copy(createTempFile, file2);
+                                UploadScreen.this.addMediaStorage(file2.getAbsolutePath());
+                                if (createTempFile.isFile()) {
+                                    createTempFile.delete();
+                                }
+                            }
+                        } else {
+                            ArrayList arrayList = new ArrayList();
+                            Iterator it2 = UploadScreen.this.mSaveFiles.iterator();
+                            while (it2.hasNext()) {
+                                arrayList.add(((File) it2.next()).getAbsolutePath());
+                            }
+                            libHaru libharu = new libHaru();
+                            if (UploadScreen.this.mIsRename) {
+                                file = new File(CommonDefine.EPSONIPRINT_FOLDER + UploadScreen.this.currentFileName + CommonDefine.FileType_PDF);
+                            } else {
+                                file = new File(CommonDefine.EPSONIPRINT_FOLDER + UploadScreen.this.currentFileName + UploadScreen.this.utils.editNumber(access$500) + CommonDefine.FileType_PDF);
+                            }
+                            if (file.exists() && !UploadScreen.this.mIsRename) {
+                                int i2 = 1;
+                                while (true) {
+                                    File file4 = new File(CommonDefine.EPSONIPRINT_FOLDER + UploadScreen.this.currentFileName + UploadScreen.this.utils.editNumber(access$500) + " (" + i2 + ")" + CommonDefine.FileType_PDF);
+                                    if (!file4.exists()) {
+                                        file = file4;
+                                        break;
+                                    } else if (i2 >= 99) {
+                                        file = new File(CommonDefine.EPSONIPRINT_FOLDER + UploadScreen.this.currentFileName + UploadScreen.this.utils.editNumber(access$500) + " (" + 99 + ")" + CommonDefine.FileType_PDF);
+                                        break;
+                                    } else {
+                                        i2++;
+                                    }
+                                }
+                            }
+                            if (libharu.createPDF(arrayList, file.getAbsolutePath()) == 0) {
+                                UploadScreen.this.isSaved = true;
+                                UploadScreen.this.addMediaStorage(file.getAbsolutePath());
+                            }
+                        }
+                    } else if (UploadScreen.this.mFileType.equals(Constants.PDF_TYPE)) {
+                        ArrayList arrayList2 = new ArrayList();
+                        Iterator it3 = UploadScreen.this.mSaveFiles.iterator();
+                        while (it3.hasNext()) {
+                            arrayList2.add(((File) it3.next()).getAbsolutePath());
+                        }
+                        libHaru libharu2 = new libHaru();
+                        File file5 = new File(CommonDefine.EPSONIPRINT_FOLDER + UploadScreen.this.currentFileName + CommonDefine.FileType_PDF);
+                        if (file5.exists() && !UploadScreen.this.mIsRename) {
+                            int i3 = 1;
+                            while (true) {
+                                File file6 = new File(CommonDefine.EPSONIPRINT_FOLDER + UploadScreen.this.currentFileName + " (" + i3 + ")" + CommonDefine.FileType_PDF);
+                                if (!file6.exists()) {
+                                    file5 = file6;
+                                    break;
+                                } else if (i3 >= 99) {
+                                    file5 = new File(CommonDefine.EPSONIPRINT_FOLDER + UploadScreen.this.currentFileName + " (" + 99 + ")" + CommonDefine.FileType_PDF);
+                                    break;
+                                } else {
+                                    i3++;
+                                }
+                            }
+                        }
+                        if (libharu2.createPDF(arrayList2, file5.getAbsolutePath()) == 0) {
+                            UploadScreen.this.isSaved = true;
+                            UploadScreen.this.addMediaStorage(file5.getAbsolutePath());
+                        }
+                    } else {
+                        EPLog.m313i("createUploadThread", "1");
+                        UploadScreen uploadScreen2 = UploadScreen.this;
+                        String absolutePath2 = ((File) UploadScreen.this.mSaveFiles.get(0)).getAbsolutePath();
+                        File createTempFile2 = MyUtility.createTempFile(uploadScreen2, absolutePath2, UploadScreen.this.currentFileName + ".jpg");
+                        EPLog.m313i("createUploadThread", ExifInterface.GPS_MEASUREMENT_2D + createTempFile2);
+                        if (createTempFile2 != null) {
+                            File file7 = new File(CommonDefine.EPSONIPRINT_FOLDER + UploadScreen.this.currentFileName + ".jpg");
+                            StringBuilder sb = new StringBuilder();
+                            sb.append(ExifInterface.GPS_MEASUREMENT_3D);
+                            sb.append(file7);
+                            EPLog.m313i("createUploadThread", sb.toString());
+                            if (file7.exists() && !UploadScreen.this.mIsRename) {
+                                int i4 = 1;
+                                while (true) {
+                                    File file8 = new File(CommonDefine.EPSONIPRINT_FOLDER + UploadScreen.this.currentFileName + " (" + i4 + ")" + ".jpg");
+                                    if (!file8.exists()) {
+                                        file7 = file8;
+                                        break;
+                                    } else if (i4 >= 99) {
+                                        file7 = new File(CommonDefine.EPSONIPRINT_FOLDER + UploadScreen.this.currentFileName + " (" + 99 + ")" + ".jpg");
+                                        break;
+                                    } else {
+                                        i4++;
+                                    }
+                                }
+                            }
+                            MyUtility.copy(createTempFile2, file7);
+                            UploadScreen.this.addMediaStorage(file7.getAbsolutePath());
+                            if (createTempFile2.isFile()) {
+                                createTempFile2.delete();
+                            }
+                            UploadScreen.this.isSaved = true;
+                            EPLog.m313i("createUploadThread", "4:" + UploadScreen.this.isSaved);
+                        }
+                    }
+                    UploadScreen.this.mSaveFiles.clear();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+                UploadScreen.this.mHandler.sendEmptyMessageDelayed(16, 1500);
+            }
+        }.start();
+    }
+
+    /* access modifiers changed from: package-private */
+    public void addMediaStorage(String str) {
+        EPLog.m313i(TAG, "MediaScannerConnection.scanFile path=" + str);
+        MediaScannerConnection.scanFile(this, new String[]{str}, (String[]) null, (MediaScannerConnection.OnScanCompletedListener) null);
+    }
+
+    private class ErrorDialog extends Dialog {
+        private int mErrorCode;
+        /* access modifiers changed from: private */
+        public int mExtraCode;
+        /* access modifiers changed from: private */
+        public boolean mIsCloseDialog;
+
+        public ErrorDialog(Context context, int i, int i2, int i3, boolean z) {
+            super(context, i);
+            this.mErrorCode = i2;
+            this.mIsCloseDialog = z;
+            this.mExtraCode = i3;
+        }
+
+        /* access modifiers changed from: protected */
+        public void onCreate(Bundle bundle) {
+            requestWindowFeature(1);
+            super.onCreate(bundle);
+            View inflate = getLayoutInflater().inflate(C2135R.layout.my_dialog_layout, (ViewGroup) null);
+            int i = this.mErrorCode;
+            if (i != 16) {
+                switch (i) {
+                    case 0:
+                        ((TextView) inflate.findViewById(C2135R.C2137id.dialog_title)).setText(UploadScreen.this.getString(C2135R.string.authenticate_error_title));
+                        ((TextView) inflate.findViewById(C2135R.C2137id.dialog_content)).setText(UploadScreen.this.getString(C2135R.string.authenticate_error_mes));
+                        break;
+                    case 1:
+                        ((TextView) inflate.findViewById(C2135R.C2137id.dialog_title)).setText(UploadScreen.this.getString(C2135R.string.download_error_title));
+                        ((TextView) inflate.findViewById(C2135R.C2137id.dialog_content)).setText(UploadScreen.this.getString(C2135R.string.download_error_mes));
+                        break;
+                    case 2:
+                        ((TextView) inflate.findViewById(C2135R.C2137id.dialog_title)).setText(UploadScreen.this.getString(C2135R.string.upload_error_title));
+                        ((TextView) inflate.findViewById(C2135R.C2137id.dialog_content)).setText(UploadScreen.this.getString(C2135R.string.upload_error_mes));
+                        break;
+                    case 3:
+                        ((TextView) inflate.findViewById(C2135R.C2137id.dialog_title)).setText(UploadScreen.this.getString(C2135R.string.error));
+                        ((TextView) inflate.findViewById(C2135R.C2137id.dialog_content)).setText(UploadScreen.this.getString(C2135R.string.network_error_mes));
+                        break;
+                    case 4:
+                        ((TextView) inflate.findViewById(C2135R.C2137id.dialog_title)).setText(UploadScreen.this.getString(C2135R.string.upload_error_title));
+                        ((TextView) inflate.findViewById(C2135R.C2137id.dialog_content)).setText(UploadScreen.this.getString(C2135R.string.str_error_Filename));
+                        break;
+                }
+            } else {
+                ((TextView) inflate.findViewById(C2135R.C2137id.dialog_title)).setText(UploadScreen.this.getString(C2135R.string.unknow_error_title));
+                ((TextView) inflate.findViewById(C2135R.C2137id.dialog_content)).setText(UploadScreen.this.getString(C2135R.string.unknow_error_mes));
+            }
+            ((Button) inflate.findViewById(C2135R.C2137id.f337ok)).setOnClickListener(new View.OnClickListener() {
+                public void onClick(View view) {
+                    ErrorDialog.this.dismiss();
+                    int unused = UploadScreen.this.count = 0;
+                    if (ErrorDialog.this.mIsCloseDialog) {
+                        int unused2 = ErrorDialog.this.mExtraCode;
+                        int unused3 = ErrorDialog.this.mExtraCode;
+                    }
+                }
+            });
+            setContentView(inflate);
+        }
+
+        public boolean onKeyDown(int i, KeyEvent keyEvent) {
+            return keyEvent.getAction() == 0 && i == 84;
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void setScreenState(Boolean bool) {
+        if (!bool.booleanValue()) {
+            findViewById(C2135R.C2137id.in_progress).setVisibility(8);
+            this.mSaveBtn.setEnabled(true);
+            this.chooseFileType.setEnabled(true);
+            return;
+        }
+        this.mSaveBtn.setEnabled(false);
+        this.chooseFileType.setEnabled(false);
+        findViewById(C2135R.C2137id.in_progress).setVisibility(0);
+    }
+
+    private void copyFile(File file, File file2) throws Exception {
+        FileChannel channel = new FileInputStream(file).getChannel();
+        FileChannel channel2 = new FileOutputStream(file2).getChannel();
+        channel.transferTo(0, channel.size(), channel2);
+        channel.close();
+        channel2.close();
+    }
+}

+ 25 - 0
app/src/main/java/epson/server/service/EvernoteClient.java

@@ -0,0 +1,25 @@
+package epson.server.service;
+
+import android.content.Context;
+import com.epson.iprint.storage.SecureKeyStore;
+import com.evernote.client.android.EvernoteSession;
+
+public class EvernoteClient {
+    static EvernoteSession session;
+
+    public static EvernoteSession getEvernoteSession(Context context) {
+        EvernoteSession evernoteSession = session;
+        if (evernoteSession != null) {
+            return evernoteSession;
+        }
+        session = new EvernoteSession.Builder(context).setEvernoteService(EvernoteSession.EvernoteService.PRODUCTION).setSupportAppLinkedNotebooks(false).build(new SecureKeyStore().getApiKeyB(context), new SecureKeyStore().getSecKeyB(context)).asSingleton();
+        return session;
+    }
+
+    public static void logout(Context context) {
+        try {
+            getEvernoteSession(context).logOut();
+        } catch (Exception unused) {
+        }
+    }
+}

+ 53 - 0
app/src/main/java/epson/server/utils/Define.java

@@ -0,0 +1,53 @@
+package epson.server.utils;
+
+public class Define {
+    public static final String ACCESS_KEY_NAME = "FolderViewer.ACCESS_KEY";
+    public static final String ACCESS_SECRET_NAME = "FolderViewer.ACCESS_SECRET";
+    public static final int AUTHENTICATE_ERROR = 0;
+    public static final String BOXNET_ACCOUNT_REMEMBERED = "BOXNET_ACCOUNT_REMBERED";
+    public static final String BOXNET_AUTH_INFO_V4 = "FolderViewer.BOXNET_AUTO_INFO_V4";
+    public static final String BOXNET_LAST_AUTHENTICATED_USER_ID = "FolderViewer.BOXNET_LAST_USER_ID";
+    public static final String BOXNET_PASSOWRD = "FolderViewer.BOXNET_PASSWORD";
+    public static final String BOXNET_TOKEN = "FolderViewer.BOXNET_TOKEN";
+    public static final String BOXNET_USERNAME = "FolderViewer.BOXNET_USERNAME";
+    public static final String BROWSE_FOLDER_FOR = "BROWSE_FOLDER_FOR";
+    public static final int BROWSE_FOLDER_FOR_GET = 0;
+    public static final int BROWSE_FOLDER_FOR_SAVE = 1;
+    public static final String DEFAULT_NAME_FOR_SAVING = "EPSON";
+    public static final int DOWNLOAD_ERROR = 1;
+    public static final int DROPBOX = 4;
+    public static final String DROPBOX_ACCESS_KEY = "FolderViewer.DROPBOX_ACCESS_KEY";
+    public static final String DROPBOX_ACCESS_SECRET = "FolderViewer.DROPBOX_ACCESS_SECRET";
+    public static final String DROPBOX_ACCOUNT_REMEMBERED = "DROPBOX_ACCOUNT_REMBERED";
+    public static final String DROPBOX_PASSWORD = "FolderViewer.ROPBOX_PASSWORD";
+    public static final String DROPBOX_USERNAME = "FolderViewer.DROPBOX_USERNAME";
+    public static final String DROPBOX_V2_TOKEN = "FolderViewer.DROPBOX_V2_TOKEN";
+    public static final int EVERNOTE = 1;
+    public static final String EVERNOTE_ACCOUNT_REMEMBERED = "EVERNOTE_ACCOUNT_REMBERED";
+    public static final String EVERNOTE_HOST = "FolderViewer.EVERNOTE_HOST";
+    public static final String EVERNOTE_ISAPPLINKEDNOTEBOOK = "FolderViewer.EVERNOTE_ISAPPLINKEDNOTEBOOK";
+    public static final String EVERNOTE_NOTESTOREURL = "FolderViewer.EVERNOTE_NOTESTOREURL";
+    public static final String EVERNOTE_PASSWORD = "FolderViewer.EVERNOTE_PASSWORD";
+    public static final String EVERNOTE_TOKEN = "FolderViewer.EVERNOTE_TOKEN";
+    public static final String EVERNOTE_USERID = "FolderViewer.EVERNOTE_USERID";
+    public static final String EVERNOTE_USERNAME = "FolderViewer.EVERNOTE_USERNAME";
+    public static final String EVERNOTE_WEBAPIURLPREFIX = "FolderViewer.EVERNOTE_WEBAPIURLPREFIX";
+    public static final int FILENAME_ERROR = 4;
+    public static final int FOR_GETTING_FILE = 1;
+    public static final int FOR_SAVING_FILE = 2;
+    public static final int FOR_SETTING = 0;
+    public static final int GOOGLEDOCS = 3;
+    public static final String GOOGLE_ACCOUNT_REMEMBERED = "GOOGLE_ACCOUNT_REMBERED";
+    public static final String GOOGLE_PASSWORD = "FolderViewer.GOOGLE_PASSWORD";
+    public static final String GOOGLE_USERNAME = "FolderViewer.GOOGLE_USERNAME";
+    public static final int LOCAL = 7;
+    public static final int NETWORK_ERROR = 3;
+    public static final String ONEDRIVE_TOKEN = "FolderViewer.ONEDRIVE_V2_TOKEN";
+    public static final int OPEN_IN = 6;
+    public static final String PICK_SERVER_FOR = "PICK_SERVER_FOR";
+    public static final String SAVING_FILE_PATH = "SAVING_FILE_PATH";
+    public static final String SHARED_PREFERENCES_NAME = "login_server";
+    public static final String SHARED_PREFERENCES_NAME2 = "LOGIN_PREFERENCES";
+    public static final int UNKNOW_ERROR = 16;
+    public static final int UPLOAD_ERROR = 2;
+}

+ 141 - 0
app/src/main/java/epson/server/utils/MyUtility.java

@@ -0,0 +1,141 @@
+package epson.server.utils;
+
+import android.content.Context;
+import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
+import com.evernote.edam.limits.Constants;
+import epson.common.ExternalFileUtils;
+import epson.print.CommonDefine;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+
+public final class MyUtility {
+    public static File createTempFile(Context context, String str, String str2) {
+        if (str2.indexOf(CommonDefine.SLASH) != -1 || str2.indexOf("\\") != -1) {
+            return null;
+        }
+        File file = new File(ExternalFileUtils.getInstance(context).getScannedImageDir(), str2);
+        try {
+            FileInputStream fileInputStream = new FileInputStream(new File(str));
+            FileOutputStream fileOutputStream = new FileOutputStream(file);
+            byte[] bArr = new byte[1024];
+            while (true) {
+                int read = fileInputStream.read(bArr);
+                if (read > 0) {
+                    fileOutputStream.write(bArr, 0, read);
+                } else {
+                    fileInputStream.close();
+                    fileOutputStream.close();
+                    return file;
+                }
+            }
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+            return null;
+        } catch (IOException e2) {
+            e2.printStackTrace();
+            return null;
+        }
+    }
+
+    /* JADX WARNING: Can't wrap try/catch for region: R(5:10|11|12|13|32) */
+    /* JADX WARNING: Code restructure failed: missing block: B:33:?, code lost:
+        return;
+     */
+    /* JADX WARNING: Failed to process nested try/catch */
+    /* JADX WARNING: Missing exception handler attribute for start block: B:12:0x0018 */
+    /* JADX WARNING: Removed duplicated region for block: B:24:0x002a A[SYNTHETIC, Splitter:B:24:0x002a] */
+    /* JADX WARNING: Removed duplicated region for block: B:28:0x0031 A[SYNTHETIC, Splitter:B:28:0x0031] */
+    /* Code decompiled incorrectly, please refer to instructions dump. */
+    public static void copy(java.io.File r3, java.io.File r4) throws java.io.IOException {
+        /*
+            r0 = 0
+            java.io.FileInputStream r1 = new java.io.FileInputStream     // Catch:{ all -> 0x0026 }
+            r1.<init>(r3)     // Catch:{ all -> 0x0026 }
+            java.io.FileOutputStream r3 = new java.io.FileOutputStream     // Catch:{ all -> 0x0024 }
+            r3.<init>(r4)     // Catch:{ all -> 0x0024 }
+            r4 = 8192(0x2000, float:1.14794E-41)
+            byte[] r4 = new byte[r4]     // Catch:{ all -> 0x0021 }
+        L_0x000f:
+            int r0 = r1.read(r4)     // Catch:{ all -> 0x0021 }
+            if (r0 > 0) goto L_0x001c
+            r1.close()     // Catch:{ IOException -> 0x0018 }
+        L_0x0018:
+            r3.close()     // Catch:{ IOException -> 0x001b }
+        L_0x001b:
+            return
+        L_0x001c:
+            r2 = 0
+            r3.write(r4, r2, r0)     // Catch:{ all -> 0x0021 }
+            goto L_0x000f
+        L_0x0021:
+            r4 = move-exception
+            r0 = r3
+            goto L_0x0028
+        L_0x0024:
+            r4 = move-exception
+            goto L_0x0028
+        L_0x0026:
+            r4 = move-exception
+            r1 = r0
+        L_0x0028:
+            if (r1 == 0) goto L_0x002f
+            r1.close()     // Catch:{ IOException -> 0x002e }
+            goto L_0x002f
+        L_0x002e:
+        L_0x002f:
+            if (r0 == 0) goto L_0x0034
+            r0.close()     // Catch:{ IOException -> 0x0034 }
+        L_0x0034:
+            throw r4
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.server.utils.MyUtility.copy(java.io.File, java.io.File):void");
+    }
+
+    public static void createFolder(String str) {
+        File file = new File(str);
+        if (!file.exists()) {
+            file.mkdirs();
+        }
+    }
+
+    public static double mathRound(double d, int i) {
+        if (i <= 0) {
+            return 0.0d;
+        }
+        int i2 = 1;
+        for (int i3 = 0; i3 < i; i3++) {
+            i2 *= 10;
+        }
+        double d2 = (double) i2;
+        return ((double) Math.round(d * d2)) / d2;
+    }
+
+    public String doNet(Context context) {
+        String str = "";
+        WiFiDirectManager.setPriorityToSimpleAP(context, false);
+        try {
+            URLConnection openConnection = new URL("https://support.epson.net/healthcheck/iPrint.html").openConnection();
+            openConnection.setConnectTimeout(Constants.EDAM_BUSINESS_NOTEBOOKS_MAX);
+            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(openConnection.getInputStream()));
+            while (true) {
+                String readLine = bufferedReader.readLine();
+                if (readLine == null) {
+                    return str;
+                }
+                str = str + readLine;
+            }
+        } catch (MalformedURLException unused) {
+            return str;
+        } catch (IOException unused2) {
+            return str;
+        }
+    }
+}

+ 73 - 0
app/src/main/java/epson/server/utils/NetworkConnectivityListener.java

@@ -0,0 +1,73 @@
+package epson.server.utils;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Handler;
+import android.os.Message;
+import epson.print.Util.EPLog;
+import epson.print.Util.Utils;
+
+public class NetworkConnectivityListener {
+    public static final int CREATE_DIALOG = 1;
+    private static final int DOWNLOAD_FINISH = 4;
+    /* access modifiers changed from: private */
+    public boolean isOnline;
+    /* access modifiers changed from: private */
+    public Handler mActivityHandler;
+    private Context mContext;
+    private boolean mListening;
+    private ConnectivityBroadcastReceiver mReceiver = new ConnectivityBroadcastReceiver();
+
+    public NetworkConnectivityListener(Handler handler) {
+        this.mActivityHandler = handler;
+    }
+
+    private class ConnectivityBroadcastReceiver extends BroadcastReceiver {
+        private ConnectivityBroadcastReceiver() {
+        }
+
+        public void onReceive(Context context, Intent intent) {
+            if (Utils.getInstance().isNetworkAvailable(context)) {
+                boolean unused = NetworkConnectivityListener.this.isOnline = true;
+                EPLog.m307e("ConnectivityBroadcastReceiver:  ", "===========OKKKKKKKKKKKKKKKKKKKK");
+                return;
+            }
+            boolean unused2 = NetworkConnectivityListener.this.isOnline = false;
+            cancelDownload();
+            EPLog.m307e("ConnectivityBroadcastReceiver:  ", "============FALSEEEEEEEEEEEEEEEEE");
+        }
+
+        private void cancelDownload() {
+            NetworkConnectivityListener.this.mActivityHandler.sendEmptyMessage(4);
+            Message message = new Message();
+            message.what = 1;
+            message.arg1 = 1;
+            NetworkConnectivityListener.this.mActivityHandler.sendMessage(message);
+            NetworkConnectivityListener.this.stopListening();
+        }
+    }
+
+    public synchronized void startListening(Context context) {
+        if (!this.mListening) {
+            this.mContext = context;
+            IntentFilter intentFilter = new IntentFilter();
+            intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
+            context.registerReceiver(this.mReceiver, intentFilter);
+            this.mListening = true;
+        }
+    }
+
+    public synchronized void stopListening() {
+        if (this.mListening) {
+            this.mContext.unregisterReceiver(this.mReceiver);
+            this.mContext = null;
+            this.mListening = false;
+        }
+    }
+
+    public boolean getIsOnline() {
+        return this.isOnline;
+    }
+}

+ 501 - 0
app/src/main/java/epson/support/DeviceInformationActivity.java

@@ -0,0 +1,501 @@
+package epson.support;
+
+import android.bluetooth.BluetoothAdapter;
+import android.content.Context;
+import android.net.wifi.WifiManager;
+import android.os.AsyncTask;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+import com.epson.memcardacc.DirectorySelecterActivity;
+import com.epson.mobilephone.common.EpLog;
+import com.epson.mobilephone.common.maintain2.MaintainPrinter2;
+import com.epson.mobilephone.common.wifidirect.ManageDefaultNetwork;
+import com.epson.mobilephone.common.wifidirect.WiFiControl;
+import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
+import com.epson.mobilephone.common.wifidirect.WifiP2pUtils;
+import epson.common.Constants;
+import epson.common.IPAddressUtils;
+import epson.common.Utils;
+import epson.print.ActivityIACommon;
+import epson.print.C2135R;
+import epson.print.MyPrinter;
+import epson.print.Util.EPLog;
+import java.lang.ref.WeakReference;
+import java.math.BigInteger;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.UnknownHostException;
+import java.nio.ByteOrder;
+import java.util.Collections;
+
+public class DeviceInformationActivity extends ActivityIACommon {
+    private static final int EPS_COMM_BID = 2;
+    private static final int EPS_ERR_PRINTER_NOT_FOUND = -1300;
+    private static final int EPS_PRNERR_COMM = 102;
+    private static final int PROBE_ERROR = 1;
+    private static final int STATUS_ERROR = 2;
+    private static final int UPDATE_PRINTER_STATUS = 0;
+    TextView PrinterIPInfo;
+    ProgressBar PrinterProbeProgress;
+    TextView PrinterStatusInfo;
+    /* access modifiers changed from: private */
+    public String TAG = "Device Information";
+    TextView TextBluetoothStatus;
+    TextView TextIPAddress;
+    TextView TextOSVersion;
+    TextView TextPrinterIP;
+    TextView TextPrinterName;
+    TextView TextPrinterStatus;
+    TextView TextWiFiName;
+    TextView TextWiFiState;
+    Handler mHandler = new Handler(new Handler.Callback() {
+        public boolean handleMessage(Message message) {
+            String str;
+            String str2;
+            EPLog.m313i("IprintHome", "HandlerCallback");
+            int i = message.getData().getInt(Constants.PRINTER_LOCATION);
+            EpLog.m69d("printerLocation " + i);
+            boolean z = false;
+            switch (message.what) {
+                case 0:
+                    EPLog.m313i(DeviceInformationActivity.this.TAG, "UPDATE_PRINTER_STATUS");
+                    int[] mStatus = DeviceInformationActivity.this.mPrinter.getMPrinterInfor().getMStatus();
+                    EpLog.m69d("status " + mStatus[0]);
+                    if (i == 1 && WiFiDirectManager.getConnectInfo(DeviceInformationActivity.this.getApplicationContext(), WiFiDirectManager.DEVICE_TYPE_PRINTER) != null) {
+                        str = DeviceInformationActivity.this.getString(C2135R.string.wifi_direct_status);
+                        z = true;
+                    } else if (i == 1 || (i == 3 && Utils.isConnectedWifi(DeviceInformationActivity.this.getApplicationContext()))) {
+                        str = DeviceInformationActivity.this.getString(C2135R.string.printer_ready);
+                        z = true;
+                    } else if (i != 2 && (i != 3 || Utils.isConnectedWifi(DeviceInformationActivity.this.getApplicationContext()))) {
+                        str = DeviceInformationActivity.this.getString(C2135R.string.not_select_status);
+                    } else if (!Utils.isOnline(DeviceInformationActivity.this.getApplicationContext())) {
+                        str = DeviceInformationActivity.this.getString(C2135R.string.cannot_connect);
+                    } else {
+                        str = DeviceInformationActivity.this.getString(C2135R.string.remote_can_connect);
+                    }
+                    DeviceInformationActivity.this.setPrinterInfo(str, z);
+                    String access$000 = DeviceInformationActivity.this.TAG;
+                    EPLog.m313i(access$000, "Stt title: " + str);
+                    break;
+                case 1:
+                    EPLog.m313i(DeviceInformationActivity.this.TAG, "PROBE_ERROR");
+                    if (i != 1 || WiFiDirectManager.getConnectInfo(DeviceInformationActivity.this.getApplicationContext(), WiFiDirectManager.DEVICE_TYPE_PRINTER) == null) {
+                        str2 = DeviceInformationActivity.this.getString(C2135R.string.comm_error);
+                    } else {
+                        str2 = DeviceInformationActivity.this.getString(C2135R.string.wifi_direct_status);
+                    }
+                    DeviceInformationActivity.this.setPrinterInfo(str2, false);
+                    String access$0002 = DeviceInformationActivity.this.TAG;
+                    EPLog.m313i(access$0002, "Stt title: " + str2);
+                    break;
+                case 2:
+                    EPLog.m313i(DeviceInformationActivity.this.TAG, "STATUS_ERROR");
+                    int[] intArray = message.getData().getIntArray("STATUS_ERROR");
+                    if (i != 1 || WiFiDirectManager.getConnectInfo(DeviceInformationActivity.this.getApplicationContext(), WiFiDirectManager.DEVICE_TYPE_PRINTER) == null) {
+                        if (intArray == null) {
+                            DeviceInformationActivity deviceInformationActivity = DeviceInformationActivity.this;
+                            deviceInformationActivity.setPrinterInfo(deviceInformationActivity.getString(C2135R.string.upon_error), true);
+                            String access$0003 = DeviceInformationActivity.this.TAG;
+                            EPLog.m313i(access$0003, "Stt titlef: " + DeviceInformationActivity.this.getString(C2135R.string.upon_error));
+                            break;
+                        } else {
+                            String access$0004 = DeviceInformationActivity.this.TAG;
+                            EPLog.m313i(access$0004, "statusError[0] : " + intArray[0]);
+                            String access$0005 = DeviceInformationActivity.this.TAG;
+                            EPLog.m313i(access$0005, "statusError[1] : " + intArray[1]);
+                            if (intArray[0] != 2 && intArray[0] != 1 && intArray[0] != 3) {
+                                if (intArray[0] != 4 || (intArray[1] != 102 && intArray[1] != -1300)) {
+                                    DeviceInformationActivity deviceInformationActivity2 = DeviceInformationActivity.this;
+                                    deviceInformationActivity2.setPrinterInfo(deviceInformationActivity2.getString(C2135R.string.upon_error), true);
+                                    String access$0006 = DeviceInformationActivity.this.TAG;
+                                    EPLog.m313i(access$0006, "Stt title: " + DeviceInformationActivity.this.getString(C2135R.string.upon_error));
+                                    break;
+                                } else {
+                                    DeviceInformationActivity deviceInformationActivity3 = DeviceInformationActivity.this;
+                                    deviceInformationActivity3.setPrinterInfo(deviceInformationActivity3.getString(C2135R.string.comm_error), false);
+                                    String access$0007 = DeviceInformationActivity.this.TAG;
+                                    EPLog.m313i(access$0007, "Stt title: " + DeviceInformationActivity.this.getString(C2135R.string.comm_error));
+                                    break;
+                                }
+                            } else {
+                                DeviceInformationActivity deviceInformationActivity4 = DeviceInformationActivity.this;
+                                deviceInformationActivity4.setPrinterInfo(deviceInformationActivity4.getString(C2135R.string.printer_ready), true);
+                                String access$0008 = DeviceInformationActivity.this.TAG;
+                                EPLog.m313i(access$0008, "Stt title: " + DeviceInformationActivity.this.getString(C2135R.string.printer_ready));
+                                break;
+                            }
+                        }
+                    } else {
+                        DeviceInformationActivity deviceInformationActivity5 = DeviceInformationActivity.this;
+                        deviceInformationActivity5.setPrinterInfo(deviceInformationActivity5.getString(C2135R.string.wifi_direct_status), true);
+                        String access$0009 = DeviceInformationActivity.this.TAG;
+                        EPLog.m313i(access$0009, "Stt title: " + DeviceInformationActivity.this.getString(C2135R.string.printer_ready));
+                        break;
+                    }
+                    break;
+                default:
+                    EPLog.m313i("IprintHome", DirectorySelecterActivity.PARAM_DEFAULT_DIR);
+                    DeviceInformationActivity deviceInformationActivity6 = DeviceInformationActivity.this;
+                    deviceInformationActivity6.setPrinterInfo(deviceInformationActivity6.getString(C2135R.string.printer_not_select), false);
+                    break;
+            }
+            DeviceInformationActivity.this.hideLoadProgressBar();
+            return true;
+        }
+    });
+    /* access modifiers changed from: private */
+    public MaintainPrinter2 mPrinter = MaintainPrinter2.getInstance();
+    private ProbePrinter task;
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        setContentView((int) C2135R.layout.device_information);
+        setActionBar((int) C2135R.string.str_deviceInformation_Info, true);
+        checkSmartPhoneInfo();
+        checkPrinterInfo();
+        checkWiFiInfo();
+    }
+
+    public void onBackPressed() {
+        super.onBackPressed();
+        stopProbePrinter();
+    }
+
+    public void onDestroy() {
+        stopProbePrinter();
+        super.onDestroy();
+    }
+
+    private void stopProbePrinter() {
+        if (this.task != null) {
+            EPLog.m313i(this.TAG, "stopProbePrinter");
+            this.mPrinter.doCancelFindPrinter();
+            this.task.cancel(true);
+            this.task = null;
+        }
+    }
+
+    private void checkPrinterInfo() {
+        this.TextPrinterName = (TextView) findViewById(C2135R.C2137id.tv_devicePrinterName);
+        MyPrinter curPrinter = MyPrinter.getCurPrinter(getApplicationContext());
+        int location = curPrinter.getLocation();
+        if (curPrinter.getName() != null) {
+            this.TextPrinterName.setText(curPrinter.getName());
+            showLoadProgressBar();
+            if (location == 1 || (location == 3 && Utils.isConnectedWifi(getApplicationContext()))) {
+                ManageDefaultNetwork.getInstance(this).setDefaultNetworkSimpleAp();
+                EpLog.m70d("IprintHome", "Update printer status after execute Probing");
+                this.task = new ProbePrinter(curPrinter, this.mPrinter, this.mHandler);
+                this.task.execute(new Context[]{this});
+                return;
+            }
+            EpLog.m70d("IprintHome", "Update printer status without execute Probing ");
+            sendUpdatePrinterStatus(this.mHandler, location);
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void setPrinterInfo(String str, boolean z) {
+        this.TextPrinterStatus = (TextView) findViewById(C2135R.C2137id.tv_devicePrinterStatus);
+        this.TextPrinterIP = (TextView) findViewById(C2135R.C2137id.tv_devicePrinterIPAddress);
+        this.TextPrinterStatus.setText(str);
+        if (z) {
+            this.TextPrinterIP.setText(MyPrinter.getCurPrinter(getApplicationContext()).getIp());
+        }
+    }
+
+    private void checkSmartPhoneInfo() {
+        StringBuilder sb = new StringBuilder();
+        this.TextBluetoothStatus = (TextView) findViewById(C2135R.C2137id.tv_deviceBluetoothStatus);
+        this.TextOSVersion = (TextView) findViewById(C2135R.C2137id.tv_deviceOSVersion);
+        sb.append("Android ");
+        sb.append(Build.VERSION.RELEASE);
+        this.TextOSVersion.setText(sb.toString());
+        BluetoothAdapter defaultAdapter = BluetoothAdapter.getDefaultAdapter();
+        if (defaultAdapter == null) {
+            this.TextBluetoothStatus.setText(C2135R.string.str_deviceInformation_BluetoothOFF);
+        } else if (!defaultAdapter.isEnabled()) {
+            this.TextBluetoothStatus.setText(C2135R.string.str_deviceInformation_BluetoothOFF);
+        } else {
+            this.TextBluetoothStatus.setText(C2135R.string.str_deviceInformation_BluetoothON);
+        }
+    }
+
+    /* JADX WARNING: Removed duplicated region for block: B:11:0x009e  */
+    /* JADX WARNING: Removed duplicated region for block: B:15:0x00b5  */
+    /* Code decompiled incorrectly, please refer to instructions dump. */
+    private void checkWiFiInfo() {
+        /*
+            r4 = this;
+            android.content.Context r0 = r4.getApplicationContext()
+            epson.print.MyPrinter r0 = epson.print.MyPrinter.getCurPrinter(r0)
+            java.lang.String r0 = r0.getPrinterId()
+            r1 = 2131231595(0x7f08036b, float:1.8079275E38)
+            android.view.View r1 = r4.findViewById(r1)
+            android.widget.TextView r1 = (android.widget.TextView) r1
+            r4.TextWiFiState = r1
+            r1 = 2131231594(0x7f08036a, float:1.8079273E38)
+            android.view.View r1 = r4.findViewById(r1)
+            android.widget.TextView r1 = (android.widget.TextView) r1
+            r4.TextWiFiName = r1
+            r1 = 2131231586(0x7f080362, float:1.8079257E38)
+            android.view.View r1 = r4.findViewById(r1)
+            android.widget.TextView r1 = (android.widget.TextView) r1
+            r4.TextIPAddress = r1
+            android.content.Context r1 = r4.getApplicationContext()
+            java.lang.String r2 = "printer"
+            java.lang.String r1 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.getConnectInfo(r1, r2)
+            android.content.Context r2 = r4.getApplicationContext()
+            com.epson.mobilephone.common.wifidirect.WiFiControl$ConnectType r2 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.getConnectType(r2, r1)
+            int[] r3 = epson.support.DeviceInformationActivity.C24682.f415x793e0ec3
+            int r2 = r2.ordinal()
+            r2 = r3[r2]
+            r3 = 1
+            if (r2 == r3) goto L_0x004b
+            goto L_0x0088
+        L_0x004b:
+            android.content.Context r2 = r4.getApplicationContext()
+            com.epson.mobilephone.common.wifidirect.WifiP2pUtils r2 = com.epson.mobilephone.common.wifidirect.WifiP2pUtils.getInstance(r2)
+            com.epson.mobilephone.common.wifidirect.WifiP2pUtils$ConnectionInfo r2 = r2.getConnectionInfo()
+            android.content.Context r3 = r4.getApplicationContext()
+            java.lang.String r0 = com.epson.mobilephone.common.wifidirect.MacAddrUtils.getMacAddressFromPrinterId(r0)
+            java.lang.String r0 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.getCurConnectInfo(r3, r0)
+            if (r2 == 0) goto L_0x0088
+            if (r1 == 0) goto L_0x0088
+            boolean r0 = r1.equals(r0)
+            if (r0 == 0) goto L_0x0088
+            android.content.Context r0 = r4.getApplicationContext()
+            com.epson.mobilephone.common.wifidirect.WiFiControl r0 = com.epson.mobilephone.common.wifidirect.WiFiControl.getInstance(r0)
+            java.lang.String r2 = r2.p2PMacAdder
+            java.lang.String r2 = com.epson.mobilephone.common.wifidirect.MacAddrUtils.p2pAddr2MacAddrStr(r2)
+            java.lang.String r0 = r0.getEstimateSSID(r1, r2)
+            android.content.Context r1 = r4.getApplicationContext()
+            java.lang.String r1 = getIpAddressFromP2P(r1)
+            goto L_0x0094
+        L_0x0088:
+            android.content.Context r0 = r4.getApplicationContext()
+            java.lang.String r0 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.getCurSSID(r0)
+            java.lang.String r1 = r4.getIpAddressFromWiFi()
+        L_0x0094:
+            android.content.Context r2 = r4.getApplicationContext()
+            boolean r2 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.isWifiEnabled(r2)
+            if (r2 == 0) goto L_0x00b5
+            android.widget.TextView r2 = r4.TextWiFiState
+            r3 = 2131625113(0x7f0e0499, float:1.8877425E38)
+            r2.setText(r3)
+            if (r0 == 0) goto L_0x00bd
+            if (r1 == 0) goto L_0x00bd
+            android.widget.TextView r2 = r4.TextWiFiName
+            r2.setText(r0)
+            android.widget.TextView r0 = r4.TextIPAddress
+            r0.setText(r1)
+            goto L_0x00bd
+        L_0x00b5:
+            android.widget.TextView r0 = r4.TextWiFiState
+            r1 = 2131625112(0x7f0e0498, float:1.8877423E38)
+            r0.setText(r1)
+        L_0x00bd:
+            return
+        */
+        throw new UnsupportedOperationException("Method not decompiled: epson.support.DeviceInformationActivity.checkWiFiInfo():void");
+    }
+
+    /* renamed from: epson.support.DeviceInformationActivity$2 */
+    static /* synthetic */ class C24682 {
+
+        /* renamed from: $SwitchMap$com$epson$mobilephone$common$wifidirect$WiFiControl$ConnectType */
+        static final /* synthetic */ int[] f415x793e0ec3 = new int[WiFiControl.ConnectType.values().length];
+
+        /* JADX WARNING: Can't wrap try/catch for region: R(8:0|1|2|3|4|5|6|8) */
+        /* JADX WARNING: Failed to process nested try/catch */
+        /* JADX WARNING: Missing exception handler attribute for start block: B:3:0x0014 */
+        /* JADX WARNING: Missing exception handler attribute for start block: B:5:0x001f */
+        static {
+            /*
+                com.epson.mobilephone.common.wifidirect.WiFiControl$ConnectType[] r0 = com.epson.mobilephone.common.wifidirect.WiFiControl.ConnectType.values()
+                int r0 = r0.length
+                int[] r0 = new int[r0]
+                f415x793e0ec3 = r0
+                int[] r0 = f415x793e0ec3     // Catch:{ NoSuchFieldError -> 0x0014 }
+                com.epson.mobilephone.common.wifidirect.WiFiControl$ConnectType r1 = com.epson.mobilephone.common.wifidirect.WiFiControl.ConnectType.WiFiP2P     // Catch:{ NoSuchFieldError -> 0x0014 }
+                int r1 = r1.ordinal()     // Catch:{ NoSuchFieldError -> 0x0014 }
+                r2 = 1
+                r0[r1] = r2     // Catch:{ NoSuchFieldError -> 0x0014 }
+            L_0x0014:
+                int[] r0 = f415x793e0ec3     // Catch:{ NoSuchFieldError -> 0x001f }
+                com.epson.mobilephone.common.wifidirect.WiFiControl$ConnectType r1 = com.epson.mobilephone.common.wifidirect.WiFiControl.ConnectType.SimpleAP     // Catch:{ NoSuchFieldError -> 0x001f }
+                int r1 = r1.ordinal()     // Catch:{ NoSuchFieldError -> 0x001f }
+                r2 = 2
+                r0[r1] = r2     // Catch:{ NoSuchFieldError -> 0x001f }
+            L_0x001f:
+                int[] r0 = f415x793e0ec3     // Catch:{ NoSuchFieldError -> 0x002a }
+                com.epson.mobilephone.common.wifidirect.WiFiControl$ConnectType r1 = com.epson.mobilephone.common.wifidirect.WiFiControl.ConnectType.NONE     // Catch:{ NoSuchFieldError -> 0x002a }
+                int r1 = r1.ordinal()     // Catch:{ NoSuchFieldError -> 0x002a }
+                r2 = 3
+                r0[r1] = r2     // Catch:{ NoSuchFieldError -> 0x002a }
+            L_0x002a:
+                return
+            */
+            throw new UnsupportedOperationException("Method not decompiled: epson.support.DeviceInformationActivity.C24682.<clinit>():void");
+        }
+    }
+
+    private String getIpAddressFromWiFi() {
+        int ipAddress = ((WifiManager) getApplicationContext().getSystemService("wifi")).getConnectionInfo().getIpAddress();
+        if (ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN)) {
+            ipAddress = Integer.reverseBytes(ipAddress);
+        }
+        try {
+            return InetAddress.getByAddress(BigInteger.valueOf((long) ipAddress).toByteArray()).getHostAddress();
+        } catch (UnknownHostException unused) {
+            EpLog.m72e(this.TAG, "Unable to get host address.");
+            return null;
+        }
+    }
+
+    public static String getIpAddressFromP2P(Context context) {
+        try {
+            NetworkInterface p2PInterfaceInfo = WifiP2pUtils.getInstance(context).getP2PInterfaceInfo();
+            if (p2PInterfaceInfo == null) {
+                return null;
+            }
+            for (T t : Collections.list(p2PInterfaceInfo.getInetAddresses())) {
+                if (!t.isLoopbackAddress()) {
+                    String upperCase = t.getHostAddress().toUpperCase();
+                    if (IPAddressUtils.isIPv4Address(upperCase)) {
+                        return upperCase;
+                    }
+                }
+            }
+            return null;
+        } catch (Exception unused) {
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public static void sendUpdatePrinterStatus(@Nullable Handler handler, int i) {
+        if (handler != null) {
+            Message obtainMessage = handler.obtainMessage();
+            obtainMessage.what = 0;
+            Bundle bundle = new Bundle();
+            bundle.putInt(Constants.PRINTER_LOCATION, i);
+            obtainMessage.setData(bundle);
+            handler.sendMessage(obtainMessage);
+        }
+    }
+
+    private static class ProbePrinter extends AsyncTask<Context, Void, Boolean> {
+        private final WeakReference<Handler> mHandlerReference;
+        private final MyPrinter mMyPrinter;
+        private MaintainPrinter2 mPrinter;
+        private int mPrinterLocation;
+
+        /* access modifiers changed from: protected */
+        public void onPreExecute() {
+        }
+
+        public ProbePrinter(@NonNull MyPrinter myPrinter, @NonNull MaintainPrinter2 maintainPrinter2, @Nullable Handler handler) {
+            this.mHandlerReference = new WeakReference<>(handler);
+            this.mPrinter = maintainPrinter2;
+            this.mMyPrinter = myPrinter;
+        }
+
+        /* access modifiers changed from: protected */
+        public Boolean doInBackground(Context... contextArr) {
+            EpLog.m77i("ProbePrinter doInBackground");
+            this.mPrinter.doInitDriver(contextArr[0], 2);
+            this.mPrinterLocation = this.mMyPrinter.getLocation();
+            int i = this.mPrinterLocation;
+            if (i == 1 || i == 3) {
+                if (this.mMyPrinter.getPrinterId() == null) {
+                    this.mPrinterLocation = 0;
+                } else if (this.mPrinter.doProbePrinter(60, this.mMyPrinter.getPrinterId(), this.mMyPrinter.getIp(), this.mPrinterLocation) != 0) {
+                    localSendMessage(1);
+                    return false;
+                } else {
+                    int doSetPrinter = this.mPrinter.doSetPrinter();
+                    EpLog.m77i("Set Printer result: " + doSetPrinter);
+                    if (doSetPrinter != 0) {
+                        localSendMessage(1);
+                        return false;
+                    }
+                    int doGetStatus = this.mPrinter.doGetStatus();
+                    EpLog.m77i("Printer Status result: " + doGetStatus);
+                    if (doGetStatus != 0) {
+                        localSendMessage(1);
+                        return false;
+                    }
+                    int[] mStatus = this.mPrinter.getMPrinterInfor().getMStatus();
+                    if (mStatus[0] != 0) {
+                        sendStatusError(mStatus);
+                        return false;
+                    }
+                }
+            }
+            return true;
+        }
+
+        private void sendStatusError(int[] iArr) {
+            Handler handler = (Handler) this.mHandlerReference.get();
+            if (handler != null) {
+                Message obtainMessage = handler.obtainMessage();
+                obtainMessage.what = 2;
+                Bundle bundle = new Bundle();
+                bundle.putIntArray("STATUS_ERROR", iArr);
+                bundle.putInt(Constants.PRINTER_LOCATION, this.mPrinterLocation);
+                obtainMessage.setData(bundle);
+                handler.sendMessage(obtainMessage);
+            }
+        }
+
+        private void localSendMessage(int i) {
+            Handler handler = (Handler) this.mHandlerReference.get();
+            if (handler != null) {
+                Message obtainMessage = handler.obtainMessage();
+                obtainMessage.what = i;
+                Bundle bundle = new Bundle();
+                bundle.putInt(Constants.PRINTER_LOCATION, this.mPrinterLocation);
+                obtainMessage.setData(bundle);
+                handler.sendMessage(obtainMessage);
+            }
+        }
+
+        /* access modifiers changed from: protected */
+        public void onCancelled() {
+            EpLog.m77i("ProbePrinter onCancelled");
+            super.onCancelled();
+        }
+
+        /* access modifiers changed from: protected */
+        public void onPostExecute(Boolean bool) {
+            EpLog.m77i("ProbePrinter onPostExecute");
+            if (bool.booleanValue()) {
+                DeviceInformationActivity.sendUpdatePrinterStatus((Handler) this.mHandlerReference.get(), this.mPrinterLocation);
+            }
+        }
+    }
+
+    private void showLoadProgressBar() {
+        this.PrinterProbeProgress = (ProgressBar) findViewById(C2135R.C2137id.progress_status);
+        this.PrinterStatusInfo = (TextView) findViewById(C2135R.C2137id.tv_devicePrinterStatusInfo);
+        this.PrinterIPInfo = (TextView) findViewById(C2135R.C2137id.tv_devicePrinterIPAddressInfo);
+        this.PrinterProbeProgress.setVisibility(0);
+        this.PrinterStatusInfo.setTextColor(getApplicationContext().getResources().getColor(C2135R.color.light_gray));
+        this.PrinterIPInfo.setTextColor(getApplicationContext().getResources().getColor(C2135R.color.light_gray));
+    }
+
+    /* access modifiers changed from: private */
+    public void hideLoadProgressBar() {
+        this.PrinterProbeProgress.setVisibility(8);
+        this.PrinterStatusInfo.setTextColor(getApplicationContext().getResources().getColor(C2135R.color.black));
+        this.PrinterIPInfo.setTextColor(getApplicationContext().getResources().getColor(C2135R.color.black));
+    }
+}

+ 28 - 0
app/src/main/java/epson/support/SupportAboutActivity.java

@@ -0,0 +1,28 @@
+package epson.support;
+
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.TextView;
+import epson.print.ActivityIACommon;
+import epson.print.C2135R;
+
+public class SupportAboutActivity extends ActivityIACommon implements View.OnClickListener {
+    public void onClick(View view) {
+    }
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        setContentView((int) C2135R.layout.help_about);
+        setActionBar((int) C2135R.string.tv_help_about, true);
+        try {
+            PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 128);
+            int i = packageInfo.versionCode;
+            ((TextView) findViewById(C2135R.C2137id.version)).setText(getResources().getString(C2135R.string.about_ver) + " " + packageInfo.versionName + " (" + getString(C2135R.string.build_type) + getString(C2135R.string.build_count) + ")");
+        } catch (PackageManager.NameNotFoundException e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 160 - 0
app/src/main/java/epson/support/SupportActivity.java

@@ -0,0 +1,160 @@
+package epson.support;
+
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.view.View;
+import android.widget.CompoundButton;
+import android.widget.Switch;
+import com.epson.mobilephone.common.guide.NoticeGuideActivity;
+import com.epson.mobilephone.common.license.InfoDisplayActivity;
+import com.epson.mobilephone.common.license.UserSurveyInvitationActivity;
+import epson.common.InformationGuide;
+import epson.common.IprintLicenseInfo;
+import epson.common.IprintUserSurveyInfo;
+import epson.print.ActivityIACommon;
+import epson.print.C2135R;
+import epson.print.CommonDefine;
+import epson.print.ThreeButtonDialog;
+import epson.print.Util.BuyInkUrl;
+
+public class SupportActivity extends ActivityIACommon implements CommonDefine, View.OnClickListener, ThreeButtonDialog.DialogCallback {
+    private static final int REQUEST_CODE_USER_SURVEY = 1;
+    private static final String TUTORIAL_URL = "https://www.epsonconnect.com/iguide/";
+    private SwitchAdapter mUserSurveySwitch;
+
+    public void callback(int i) {
+    }
+
+    /* access modifiers changed from: protected */
+    public void onCreate(Bundle bundle) {
+        super.onCreate(bundle);
+        setContentView((int) C2135R.layout.main_support);
+        setActionBar((int) C2135R.string.title_support, true);
+        findViewById(C2135R.C2137id.linearLayoutIprintNews).setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                InformationGuide informationGuide = new InformationGuide(SupportActivity.this.getApplicationContext());
+                Intent intent = new Intent(SupportActivity.this, NoticeGuideActivity.class);
+                intent.putExtra(NoticeGuideActivity.KEY_HTML_PATH, informationGuide.getHtmlPath());
+                intent.putExtra(NoticeGuideActivity.KEY_GUIDE_VER, InformationGuide.GUIDE_VER);
+                intent.putExtra(NoticeGuideActivity.KEY_BOOT_MODE, NoticeGuideActivity.MODE_MANUAL);
+                SupportActivity.this.startActivity(intent);
+            }
+        });
+        final String faqUrlString = BuyInkUrl.getFaqUrlString(this);
+        findViewById(C2135R.C2137id.linearLayoutFAQ).setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                SupportActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(faqUrlString)));
+            }
+        });
+        findViewById(C2135R.C2137id.linearLayoutTutorial).setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                SupportActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(SupportActivity.TUTORIAL_URL)));
+            }
+        });
+        this.mUserSurveySwitch = new SwitchAdapter((Switch) findViewById(C2135R.C2137id.tb_send_usageinformation), new CompoundButton.OnCheckedChangeListener() {
+            public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
+                SupportActivity.this.onCheckChanged(z);
+            }
+        });
+        updateUserSurveySwitch();
+        findViewById(C2135R.C2137id.linearLayoutPrivacy).setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                SupportActivity.this.startDocumentDisplayActivity(2);
+            }
+        });
+        findViewById(C2135R.C2137id.linearLayoutAbout).setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                SupportActivity.this.startActivity(new Intent(SupportActivity.this, SupportAboutActivity.class));
+            }
+        });
+        findViewById(C2135R.C2137id.linearLayoutLicense).setOnClickListener(this);
+        findViewById(C2135R.C2137id.ossLicenseLayout).setOnClickListener(this);
+        findViewById(C2135R.C2137id.linearLayoutDeviceInformation).setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                SupportActivity.this.startActivity(new Intent(SupportActivity.this, DeviceInformationActivity.class));
+            }
+        });
+    }
+
+    /* access modifiers changed from: private */
+    public void onCheckChanged(boolean z) {
+        IprintUserSurveyInfo iprintUserSurveyInfo = new IprintUserSurveyInfo();
+        if (!z) {
+            iprintUserSurveyInfo.setUserSurveyAgreement(this, false);
+        } else {
+            startUserSurveyInvitationActivity();
+        }
+    }
+
+    private void startUserSurveyInvitationActivity() {
+        startActivityForResult(UserSurveyInvitationActivity.getStartIntent(this, new IprintUserSurveyInfo(), new IprintLicenseInfo()), 1);
+    }
+
+    public void onClick(View view) {
+        if (view.getId() == C2135R.C2137id.linearLayoutLicense) {
+            startDocumentDisplayActivity(1);
+        } else if (view.getId() == C2135R.C2137id.ossLicenseLayout) {
+            startDocumentDisplayActivity(3);
+        }
+    }
+
+    /* access modifiers changed from: private */
+    public void startDocumentDisplayActivity(int i) {
+        startActivity(InfoDisplayActivity.getStartIntent(this, new IprintLicenseInfo(), i));
+    }
+
+    /* access modifiers changed from: protected */
+    public void onActivityResult(int i, int i2, Intent intent) {
+        if (i == 1) {
+            updateUserSurveySwitch();
+        }
+    }
+
+    private void updateUserSurveySwitch() {
+        this.mUserSurveySwitch.setCheckWithoutCallback(new IprintUserSurveyInfo().isUserSurveyEnabled(this));
+    }
+
+    /* access modifiers changed from: protected */
+    public void onPause() {
+        super.onPause();
+        this.mUserSurveySwitch.setListenerEnabled(false);
+    }
+
+    /* access modifiers changed from: protected */
+    public void onResume() {
+        super.onResume();
+        this.mUserSurveySwitch.setListenerEnabled(true);
+    }
+
+    private static class SwitchAdapter implements CompoundButton.OnCheckedChangeListener {
+        private boolean mOriginalChangeListenerEnabled = false;
+        private CompoundButton.OnCheckedChangeListener mOriginalListener;
+        private Switch mSwitch;
+
+        public SwitchAdapter(@NonNull Switch switchR, CompoundButton.OnCheckedChangeListener onCheckedChangeListener) {
+            this.mSwitch = switchR;
+            this.mOriginalListener = onCheckedChangeListener;
+            switchR.setOnCheckedChangeListener(this);
+        }
+
+        public void setListenerEnabled(boolean z) {
+            this.mOriginalChangeListenerEnabled = z;
+        }
+
+        public void setCheckWithoutCallback(boolean z) {
+            boolean z2 = this.mOriginalChangeListenerEnabled;
+            this.mOriginalChangeListenerEnabled = false;
+            this.mSwitch.setChecked(z);
+            this.mOriginalChangeListenerEnabled = z2;
+        }
+
+        public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
+            CompoundButton.OnCheckedChangeListener onCheckedChangeListener;
+            if (this.mOriginalChangeListenerEnabled && (onCheckedChangeListener = this.mOriginalListener) != null) {
+                onCheckedChangeListener.onCheckedChanged(compoundButton, z);
+            }
+        }
+    }
+}