Tinger 1 gadu atpakaļ
revīzija
bf58b0992f
61 mainītis faili ar 1848 papildinājumiem un 0 dzēšanām
  1. 16 0
      .gitignore
  2. 8 0
      .idea/.gitignore
  3. 6 0
      .idea/compiler.xml
  4. 18 0
      .idea/gradle.xml
  5. 30 0
      .idea/jarRepositories.xml
  6. 56 0
      .idea/misc.xml
  7. 124 0
      .idea/uiDesigner.xml
  8. 6 0
      .idea/vcs.xml
  9. 1 0
      app/.gitignore
  10. 40 0
      app/build.gradle
  11. 21 0
      app/proguard-rules.pro
  12. 28 0
      app/src/androidTest/java/hm/wine/seller/ExampleInstrumentedTest.java
  13. 46 0
      app/src/main/AndroidManifest.xml
  14. BIN
      app/src/main/app_icon-playstore.png
  15. 20 0
      app/src/main/java/hm/wine/seller/AutoStart.java
  16. 51 0
      app/src/main/java/hm/wine/seller/KeepAlive.java
  17. 171 0
      app/src/main/java/hm/wine/seller/MainActivity.java
  18. 32 0
      app/src/main/java/hm/wine/seller/Weight/Publisher.java
  19. 5 0
      app/src/main/java/hm/wine/seller/Weight/Subscriber.java
  20. 35 0
      app/src/main/java/hm/wine/seller/bean/HttpResp.java
  21. 33 0
      app/src/main/java/hm/wine/seller/bean/HttpRespData.java
  22. 31 0
      app/src/main/java/hm/wine/seller/lib/Alarm.java
  23. 51 0
      app/src/main/java/hm/wine/seller/lib/DownloadCallback.java
  24. 5 0
      app/src/main/java/hm/wine/seller/lib/DownloadFinish.java
  25. 194 0
      app/src/main/java/hm/wine/seller/lib/JsBridge.java
  26. 237 0
      app/src/main/java/hm/wine/seller/lib/ShellUtils.java
  27. 71 0
      app/src/main/java/hm/wine/seller/lib/UartUtils.java
  28. 23 0
      app/src/main/java/hm/wine/seller/lib/WakeLock.java
  29. 14 0
      app/src/main/java/linux-auto.sh
  30. 74 0
      app/src/main/res/drawable/app_icon_background.xml
  31. 6 0
      app/src/main/res/drawable/border.xml
  32. 11 0
      app/src/main/res/layout/main_activity.xml
  33. 5 0
      app/src/main/res/mipmap-anydpi-v26/app_icon.xml
  34. 5 0
      app/src/main/res/mipmap-anydpi-v26/app_icon_round.xml
  35. BIN
      app/src/main/res/mipmap-hdpi/app_icon.png
  36. BIN
      app/src/main/res/mipmap-hdpi/app_icon_foreground.png
  37. BIN
      app/src/main/res/mipmap-hdpi/app_icon_round.png
  38. BIN
      app/src/main/res/mipmap-mdpi/app_icon.png
  39. BIN
      app/src/main/res/mipmap-mdpi/app_icon_foreground.png
  40. BIN
      app/src/main/res/mipmap-mdpi/app_icon_round.png
  41. BIN
      app/src/main/res/mipmap-xhdpi/app_icon.png
  42. BIN
      app/src/main/res/mipmap-xhdpi/app_icon_foreground.png
  43. BIN
      app/src/main/res/mipmap-xhdpi/app_icon_round.png
  44. BIN
      app/src/main/res/mipmap-xxhdpi/app_icon.png
  45. BIN
      app/src/main/res/mipmap-xxhdpi/app_icon_foreground.png
  46. BIN
      app/src/main/res/mipmap-xxhdpi/app_icon_round.png
  47. BIN
      app/src/main/res/mipmap-xxxhdpi/app_icon.png
  48. BIN
      app/src/main/res/mipmap-xxxhdpi/app_icon_foreground.png
  49. BIN
      app/src/main/res/mipmap-xxxhdpi/app_icon_round.png
  50. 17 0
      app/src/main/res/values-night/themes.xml
  51. 10 0
      app/src/main/res/values/colors.xml
  52. 5 0
      app/src/main/res/values/strings.xml
  53. 17 0
      app/src/main/res/values/themes.xml
  54. 17 0
      app/src/test/java/hm/wine/seller/ExampleUnitTest.java
  55. 25 0
      build.gradle
  56. 19 0
      gradle.properties
  57. BIN
      gradle/wrapper/gradle-wrapper.jar
  58. 6 0
      gradle/wrapper/gradle-wrapper.properties
  59. 172 0
      gradlew
  60. 84 0
      gradlew.bat
  61. 2 0
      settings.gradle

+ 16 - 0
.gitignore

@@ -0,0 +1,16 @@
+*.iml
+.gradle
+app/build
+/local.properties
+/.idea/caches
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
+.DS_Store
+/build
+/captures
+.externalNativeBuild
+.cxx
+local.properties

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/

+ 6 - 0
.idea/compiler.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <bytecodeTargetLevel target="11" />
+  </component>
+</project>

+ 18 - 0
.idea/gradle.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="GradleMigrationSettings" migrationVersion="1" />
+  <component name="GradleSettings">
+    <option name="linkedExternalProjectsSettings">
+      <GradleProjectSettings>
+        <option name="distributionType" value="DEFAULT_WRAPPED" />
+        <option name="externalProjectPath" value="$PROJECT_DIR$" />
+        <option name="modules">
+          <set>
+            <option value="$PROJECT_DIR$" />
+            <option value="$PROJECT_DIR$/app" />
+          </set>
+        </option>
+      </GradleProjectSettings>
+    </option>
+  </component>
+</project>

+ 30 - 0
.idea/jarRepositories.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="RemoteRepositoriesConfiguration">
+    <remote-repository>
+      <option name="id" value="central" />
+      <option name="name" value="Maven Central repository" />
+      <option name="url" value="https://repo1.maven.org/maven2" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="jboss.community" />
+      <option name="name" value="JBoss Community repository" />
+      <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="BintrayJCenter" />
+      <option name="name" value="BintrayJCenter" />
+      <option name="url" value="https://jcenter.bintray.com/" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="Google" />
+      <option name="name" value="Google" />
+      <option name="url" value="https://dl.google.com/dl/android/maven2/" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="maven" />
+      <option name="name" value="maven" />
+      <option name="url" value="https://jitpack.io" />
+    </remote-repository>
+  </component>
+</project>

+ 56 - 0
.idea/misc.xml

@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="FrameworkDetectionExcludesConfiguration">
+    <file type="web" url="file://$PROJECT_DIR$" />
+  </component>
+  <component name="NullableNotNullManager">
+    <option name="myDefaultNullable" value="org.jetbrains.annotations.Nullable" />
+    <option name="myDefaultNotNull" value="androidx.annotation.RecentlyNonNull" />
+    <option name="myNullables">
+      <value>
+        <list size="14">
+          <item index="0" class="java.lang.String" itemvalue="com.android.annotations.Nullable" />
+          <item index="1" class="java.lang.String" itemvalue="io.reactivex.rxjava3.annotations.Nullable" />
+          <item index="2" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
+          <item index="3" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
+          <item index="4" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
+          <item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
+          <item index="6" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.Nullable" />
+          <item index="7" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
+          <item index="8" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
+          <item index="9" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
+          <item index="10" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
+          <item index="11" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
+          <item index="12" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
+          <item index="13" class="java.lang.String" itemvalue="io.reactivex.annotations.Nullable" />
+        </list>
+      </value>
+    </option>
+    <option name="myNotNulls">
+      <value>
+        <list size="14">
+          <item index="0" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
+          <item index="1" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
+          <item index="2" class="java.lang.String" itemvalue="io.reactivex.annotations.NonNull" />
+          <item index="3" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
+          <item index="4" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
+          <item index="5" class="java.lang.String" itemvalue="lombok.NonNull" />
+          <item index="6" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
+          <item index="7" class="java.lang.String" itemvalue="io.reactivex.rxjava3.annotations.NonNull" />
+          <item index="8" class="java.lang.String" itemvalue="com.android.annotations.NonNull" />
+          <item index="9" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
+          <item index="10" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
+          <item index="11" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
+          <item index="12" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
+          <item index="13" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.NonNull" />
+        </list>
+      </value>
+    </option>
+  </component>
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="jbr-11" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/build/classes" />
+  </component>
+  <component name="ProjectType">
+    <option name="id" value="Android" />
+  </component>
+</project>

+ 124 - 0
.idea/uiDesigner.xml

@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Palette2">
+    <group name="Swing">
+      <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
+      </item>
+      <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
+      </item>
+      <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
+        <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
+        <initial-values>
+          <property name="text" value="Button" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="RadioButton" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="CheckBox" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="Label" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+          <preferred-size width="200" height="200" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+          <preferred-size width="200" height="200" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
+      </item>
+      <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
+          <preferred-size width="-1" height="20" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
+      </item>
+      <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
+      </item>
+    </group>
+  </component>
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>

+ 1 - 0
app/.gitignore

@@ -0,0 +1 @@
+/build

+ 40 - 0
app/build.gradle

@@ -0,0 +1,40 @@
+plugins {
+    id 'com.android.application'
+}
+
+android {
+    compileSdkVersion 34
+    buildToolsVersion "34.0.0"
+
+    defaultConfig {
+        applicationId "hm.wine.seller"
+        minSdkVersion 25
+        targetSdkVersion 34
+        versionCode 23120701
+        versionName "v2023.12.07-01"
+
+        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
+    }
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
+    }
+}
+
+dependencies {
+    implementation "androidx.appcompat:appcompat:1.1.0"
+    implementation "com.google.android.material:material:1.1.0"
+    implementation "com.squareup.okhttp3:okhttp:3.10.0"
+    implementation "com.alibaba:fastjson:1.1.55.android"
+    implementation 'com.github.cl-6666:serialPort:v3.1.7'
+    testImplementation "junit:junit:4.+"
+    androidTestImplementation "androidx.test.ext:junit:1.1.1"
+    androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0"
+}

+ 21 - 0
app/proguard-rules.pro

@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile

+ 28 - 0
app/src/androidTest/java/hm/wine/seller/ExampleInstrumentedTest.java

@@ -0,0 +1,28 @@
+package hm.wine.seller;
+
+import android.content.Context;
+import android.util.Log;
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import hm.wine.seller.bean.HttpResp;
+import hm.wine.seller.bean.HttpRespData;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+
+}

+ 46 - 0
app/src/main/AndroidManifest.xml

@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          package="hm.wine.seller">
+
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.WAKE_LOCK" />
+    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+    <application
+            android:persistent="true"
+            android:allowBackup="true"
+            android:label="@string/app_name"
+            android:usesCleartextTraffic="true"
+            android:icon="@mipmap/app_icon"
+            android:roundIcon="@mipmap/app_icon"
+            android:supportsRtl="true"
+            android:theme="@style/Theme.Wine">
+        <meta-data android:name="android.webkit.WebView.EnableSafeBrowsing"  android:value="false"/>
+
+        <receiver
+                android:name=".AutoStart"
+                android:exported="true">
+            <intent-filter>
+                <action android:name="MY_CUSTOM_ACTION" />
+                <action android:name="android.intent.action.BOOT_COMPLETED" />
+                <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
+                <category android:name="android.intent.category.HOME" />
+            </intent-filter>
+        </receiver>
+        
+        <service android:name=".KeepAlive"
+                 android:enabled="true"
+                 android:exported="false" />
+
+        <activity android:name=".MainActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER"/>
+            </intent-filter>
+        </activity>
+
+    </application>
+
+</manifest>

BIN
app/src/main/app_icon-playstore.png


+ 20 - 0
app/src/main/java/hm/wine/seller/AutoStart.java

@@ -0,0 +1,20 @@
+package hm.wine.seller;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+public class AutoStart extends BroadcastReceiver {
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        String action = intent.getAction();
+        if (action.equals(Intent.ACTION_BOOT_COMPLETED) || action.equals(Intent.ACTION_MY_PACKAGE_REPLACED)) {
+            Intent mainIntent = new Intent(context, MainActivity.class);
+            mainIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+            context.startActivity(mainIntent);
+        }
+        if (action.equals("MY_CUSTOM_ACTION")) {
+            System.out.println("MY_CUSTOM_ACTION");
+        }
+    }
+}

+ 51 - 0
app/src/main/java/hm/wine/seller/KeepAlive.java

@@ -0,0 +1,51 @@
+package hm.wine.seller;
+
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.app.Service;
+import android.content.Intent;
+import android.os.Build;
+import android.os.IBinder;
+import androidx.annotation.Nullable;
+import androidx.core.app.NotificationCompat;
+
+public class KeepAlive extends Service {
+
+    private static final String CHANNEL_ID = "Wine-Channel";
+    private static final int NOTIFICATION_ID = 1;
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        startForeground(NOTIFICATION_ID, buildNotification());
+    }
+
+    private Notification buildNotification() {
+        // 创建通知渠道(仅适用于Android 8.0及以上版本)
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+            NotificationChannel channel = new NotificationChannel(
+                    CHANNEL_ID,
+                    "Wine Notification Name",
+                    NotificationManager.IMPORTANCE_DEFAULT
+            );
+            NotificationManager manager = getSystemService(NotificationManager.class);
+            manager.createNotificationChannel(channel);
+        }
+
+        // 创建通知
+        NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
+                .setSmallIcon(R.mipmap.app_icon) // 设置小图标
+                .setContentTitle("Wine Notification Title") // 设置通知标题
+                .setContentText("Service is running") // 设置通知内容
+                .setPriority(NotificationCompat.PRIORITY_MAX); // 设置通知优先级
+
+        return builder.build();
+    }
+
+    @Nullable
+    @Override
+    public IBinder onBind(Intent intent) {
+        return null;
+    }
+}

+ 171 - 0
app/src/main/java/hm/wine/seller/MainActivity.java

@@ -0,0 +1,171 @@
+package hm.wine.seller;
+
+import android.Manifest;
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.media.AudioManager;
+import android.os.Build;
+import android.os.Bundle;
+import android.webkit.*;
+import androidx.annotation.NonNull;
+import androidx.annotation.RequiresApi;
+import androidx.core.app.ActivityCompat;
+import com.alibaba.fastjson.JSON;
+import hm.wine.seller.lib.*;
+import hm.wine.seller.bean.HttpResp;
+import hm.wine.seller.bean.HttpRespData;
+import okhttp3.*;
+
+public class MainActivity extends Activity {
+    private final String[] Permissions = {
+            Manifest.permission.WRITE_EXTERNAL_STORAGE,
+            Manifest.permission.READ_EXTERNAL_STORAGE
+    };
+    private WebView view = null;
+    private final int PermissionCode = 1000;
+    private final int SoftVer = 23120701;
+    private final String Version = "v2023.12.07-01";
+    private AudioManager audioManager = null;
+    private int maxVolume = 0;
+
+    @RequiresApi(api = Build.VERSION_CODES.O)
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.main_activity);
+
+        WakeLock.acquireWakeLock(this);
+        Alarm.setRepeatingAlarm(this);
+        startService(new Intent(this, KeepAlive.class));
+        requestPermission();
+    }
+
+    @Override
+    protected void onDestroy() {
+        WakeLock.releaseWakeLock();
+        Alarm.cancelRepeatingAlarm(this);
+        stopService(new Intent(this, KeepAlive.class));
+        if (view != null) {
+            view.clearCache(true);
+            view.loadUrl("about:blank");
+            view.stopLoading();
+            view.onPause();
+            view.destroy();
+        }
+        UartUtils.close();
+        super.onDestroy();
+    }
+
+    @Override
+    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+        if (requestCode == PermissionCode) {
+            for (int i = 0; i < permissions.length; i++) {
+                if (grantResults[i] == 0) {
+                    requestPermission();
+                    return;
+                }
+            }
+            start();
+        }
+    }
+
+    private boolean checkPermissions() {
+        for (String permission : Permissions) {
+            if (ActivityCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED)
+                return false;
+        }
+        return true;
+    }
+
+    private void requestPermission() {
+        if (!checkPermissions()) {
+            ActivityCompat.requestPermissions(this, Permissions, PermissionCode);
+        } else start();
+    }
+
+    private void start() {
+        audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
+        maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
+        while (audioManager.getStreamVolume(AudioManager.STREAM_MUSIC) < maxVolume)
+            audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, 0);
+
+        enableGesture();
+        versionCheck();
+        launchWebsite();
+    }
+
+    private void versionCheck() {
+        new Thread(() -> {
+            String url = getResources().getString(R.string.version_url);
+            Request request = new Request.Builder().url(url).build();
+            OkHttpClient client = new OkHttpClient();
+            try {
+                Response response = client.newCall(request).execute();
+                if (response.code() == 200 && response.body() != null) {
+                    String str = response.body().string();
+                    HttpResp httpResp = JSON.parseObject(str, HttpResp.class);
+                    HttpRespData data = httpResp.getData();
+                    if (httpResp.isStatus() && data.getVer() > SoftVer) {
+                        request = new Request.Builder().url(data.getUrl()).build();
+                        client.newCall(request).enqueue(new DownloadCallback(this::reboot));
+                    }
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }).start();
+    }
+
+    private void reboot() {
+        Intent restart = new Intent("wits.action.reboot");
+        sendBroadcast(restart);
+    }
+
+    private void enableGesture() {
+        Intent show = new Intent("show.systemui"), allow = new Intent("com.zc.open_gesture");
+        sendBroadcast(show);
+        sendBroadcast(allow);
+    }
+
+    private void disableGesture() {
+        Intent hide = new Intent("hide.systemui"), forbid = new Intent("com.zc.close_gesture");
+        sendBroadcast(hide);
+        sendBroadcast(forbid);
+    }
+
+    public class AppContext {
+        public void reboot() {
+            MainActivity.this.reboot();
+        }
+
+        public void enableGesture() {
+            MainActivity.this.enableGesture();
+        }
+
+        public void disableGesture() {
+            MainActivity.this.disableGesture();
+        }
+    }
+
+    @SuppressLint("SetJavaScriptEnabled")
+    private void launchWebsite() {
+        String front = getResources().getString(R.string.front_host);
+        view = findViewById(R.id.webview);
+        WebSettings settings = view.getSettings();
+        settings.setJavaScriptEnabled(true);
+        settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
+        settings.setMediaPlaybackRequiresUserGesture(false);
+        settings.setBlockNetworkImage(false);
+        settings.setLoadsImagesAutomatically(true);
+        settings.setDefaultTextEncodingName("utf-8");
+
+        view.addJavascriptInterface(
+                new JsBridge(view, Version, new AppContext(), getApplication(), audioManager, maxVolume),
+                "android"
+        );
+        view.loadUrl(front);
+    }
+}

+ 32 - 0
app/src/main/java/hm/wine/seller/Weight/Publisher.java

@@ -0,0 +1,32 @@
+package hm.wine.seller.Weight;
+
+public class Publisher {
+    private static final int size = 5, hold = 20, range = 20;  // 10 * 0.1 = 1g
+    private static final int[] weight = {-1, -1, -1, -1, -1};
+    private static int curIndex = 0;
+    private static Subscriber subscriber;
+
+    private static void reset() {
+        for (int i = 0; i < size; i++) weight[i] = -1;
+        curIndex = 0;
+        subscriber = null;
+    }
+
+    public static void setSubscriber(Subscriber sub) {
+        Publisher.reset();
+        subscriber = sub;
+    }
+
+    public static void newWeight(int w) {
+        if (w < hold) return;
+        weight[curIndex] = w;
+        curIndex = (curIndex + 1) % size;
+        int sum = weight[0];
+        for (int i = 1; i < size; i++) {
+            if (weight[i] < hold || Math.abs(weight[i] - weight[i - 1]) > range) return;
+            sum += weight[i];
+        }
+        subscriber.onSteadyWeight(sum / size);
+        Publisher.reset();
+    }
+}

+ 5 - 0
app/src/main/java/hm/wine/seller/Weight/Subscriber.java

@@ -0,0 +1,5 @@
+package hm.wine.seller.Weight;
+
+public interface Subscriber {
+    void onSteadyWeight(int weight);
+}

+ 35 - 0
app/src/main/java/hm/wine/seller/bean/HttpResp.java

@@ -0,0 +1,35 @@
+package hm.wine.seller.bean;
+
+
+public class HttpResp {
+    private boolean status;
+    private String msg;
+    private HttpRespData data;
+
+    public HttpResp() {
+    }
+
+    public boolean isStatus() {
+        return status;
+    }
+
+    public void setStatus(boolean status) {
+        this.status = status;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+
+    public HttpRespData getData() {
+        return data;
+    }
+
+    public void setData(HttpRespData data) {
+        this.data = data;
+    }
+}

+ 33 - 0
app/src/main/java/hm/wine/seller/bean/HttpRespData.java

@@ -0,0 +1,33 @@
+package hm.wine.seller.bean;
+
+public class HttpRespData {
+    private String name, url;
+    private int ver;
+
+    public HttpRespData() {
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public int getVer() {
+        return ver;
+    }
+
+    public void setVer(int ver) {
+        this.ver = ver;
+    }
+}

+ 31 - 0
app/src/main/java/hm/wine/seller/lib/Alarm.java

@@ -0,0 +1,31 @@
+package hm.wine.seller.lib;
+import android.app.AlarmManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.os.SystemClock;
+
+public class Alarm {
+    private static final int ALARM_INTERVAL = 10 * 60 * 1000; // 10min
+
+    public static void setRepeatingAlarm(Context context) {
+        Intent intent = new Intent("MY_CUSTOM_ACTION");
+        PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
+
+        AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
+        alarmManager.setRepeating(
+                AlarmManager.ELAPSED_REALTIME_WAKEUP,
+                SystemClock.elapsedRealtime() + ALARM_INTERVAL,
+                ALARM_INTERVAL,
+                pendingIntent
+        );
+    }
+
+    public static void cancelRepeatingAlarm(Context context) {
+        Intent intent = new Intent("MY_CUSTOM_ACTION");
+        PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
+
+        AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
+        alarmManager.cancel(pendingIntent);
+    }
+}

+ 51 - 0
app/src/main/java/hm/wine/seller/lib/DownloadCallback.java

@@ -0,0 +1,51 @@
+package hm.wine.seller.lib;
+
+import android.annotation.SuppressLint;
+import okhttp3.Call;
+import okhttp3.Callback;
+import okhttp3.Response;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class DownloadCallback implements Callback {
+    private final DownloadFinish callback;
+
+    public DownloadCallback(DownloadFinish callback) {
+        this.callback = callback;
+    }
+
+    @Override
+    public void onFailure(Call call, IOException e) {
+        e.printStackTrace();
+    }
+
+    @Override
+    public void onResponse(Call call, Response response) {
+        @SuppressLint("SdCardPath")
+        String filepath = "/sdcard/Download/Wine.apk";
+        InputStream is = null;
+        FileOutputStream fos = null;
+        byte[] buf = new byte[2048];
+        if (response.body() == null) return;
+        try {
+            int len;
+            is = response.body().byteStream();
+            fos = new FileOutputStream(filepath);
+            while ((len = is.read(buf)) != -1) fos.write(buf, 0, len);
+            fos.flush();
+
+            ShellUtils.execAutoRoot("pm install -r " + filepath);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (is != null) is.close();
+                if (fos != null) fos.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+}

+ 5 - 0
app/src/main/java/hm/wine/seller/lib/DownloadFinish.java

@@ -0,0 +1,5 @@
+package hm.wine.seller.lib;
+
+public interface DownloadFinish {
+    void finish();
+}

+ 194 - 0
app/src/main/java/hm/wine/seller/lib/JsBridge.java

@@ -0,0 +1,194 @@
+package hm.wine.seller.lib;
+
+import android.app.Application;
+import android.media.AudioManager;
+import android.os.Build;
+import android.util.Log;
+import android.webkit.JavascriptInterface;
+import android.webkit.WebView;
+import com.kongqw.serialportlibrary.enumerate.SerialPortEnum;
+import com.kongqw.serialportlibrary.enumerate.SerialStatus;
+import com.kongqw.serialportlibrary.listener.SerialPortDirectorListens;
+import hm.wine.seller.MainActivity;
+import hm.wine.seller.Weight.Publisher;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+public class JsBridge {
+    private final WebView webView;
+    private final String version;
+    private final MainActivity.AppContext context;
+    private final AudioManager audioManager;
+    private final int maxVolume;
+
+    public JsBridge(
+            WebView view, String version, MainActivity.AppContext context,
+            Application app, AudioManager audioManager, int maxVolume
+    ) {
+        this.webView = view;
+        this.version = version;
+        this.context = context;
+        this.audioManager = audioManager;
+        this.maxVolume = maxVolume;
+
+        UartUtils.init(app, new SerialPortDirectorListens() {
+            @Override
+            public void onDataReceived(byte[] data, SerialPortEnum serialPortEnum) {
+                if (!UartUtils.isDataCorrect(data)) return;
+                switch (data[2]) {
+                    case 0x11:  // weight
+                        Publisher.newWeight(((data[3] & 0x00FF) << 8) + (data[4] & 0x00FF));
+                        break;
+                    case 0x12:  // door opened
+                        if (data[3] == 0x01) jsCall("frontGateResult(true)");
+                        else if (data[3] == 0x00) jsCall("backGateResult(true)");
+                        else jsCall("__Error_Happened__('unknown open door result from lower machine')");
+                        break;
+                    case 0x13:  // pulse
+                        jsCall(String.format("volumePulse(%d)", ((data[3] & 0x00FF) << 8) + (data[4] & 0x00FF)));
+                        break;
+                    case 0x14:  // wine out finished
+                        jsCall("normalFinish()");
+                        break;
+                    case (byte) 0xFF:  // error
+                        jsCall("__Error_Happened__('error from lower machine: 0xFF')");
+                        jsCall("errorWhileOuting('error from lower machine: 0xFF')");
+                        break;
+                    default:
+                        jsCall("__Error_Happened__('unknown data from lower machine')");
+                        break;
+                }
+            }
+
+            @Override
+            public void onDataSent(byte[] bytes, SerialPortEnum serialPortEnum) {
+                //
+            }
+
+            @Override
+            public void openState(SerialPortEnum serialPortEnum, File device, SerialStatus status) {
+                //
+            }
+        });
+    }
+
+    private void jsCall(String func_with_args) {
+        String script = String.format("javascript:window.%s;", func_with_args);
+        webView.post(() -> webView.evaluateJavascript(script, null));
+    }
+
+    @JavascriptInterface
+    public void pin() {
+        jsCall("pon()");
+    }
+
+    @JavascriptInterface
+    public void onWebMounted() {
+        context.disableGesture();
+        jsCall(String.format("startApp('%s', '%s')", Build.SERIAL, version));
+    }
+
+    @JavascriptInterface
+    public void openFrontGate() {
+        UartUtils.OpenDoor(true);
+    }
+
+    @JavascriptInterface
+    public void openBackGate() {
+        UartUtils.OpenDoor(false);
+    }
+
+    @JavascriptInterface
+    public void lightOn(int index) {
+        UartUtils.SwitchLight(index, true);
+    }
+
+    @JavascriptInterface
+    public void lightOff(int index) {
+        UartUtils.SwitchLight(index, false);
+    }
+
+    @JavascriptInterface
+    public void isCupProperlyPlaced(final int index) {
+        AtomicBoolean read = new AtomicBoolean(true);
+        Publisher.setSubscriber(weight -> {
+            read.set(false);
+            jsCall(String.format("cupProperlyPlaced(%d)", weight));
+        });
+        new Thread(() -> {
+            try {
+                while (true) {
+                    Thread.sleep(300);
+                    if (read.get()) UartUtils.ReadWeight(index);
+                    else break;
+                }
+            } catch (Exception e) {
+                jsCall("__Error_Happened__('application sleep error')");
+            }
+        }).start();
+    }
+
+    @JavascriptInterface
+    public void openGas() {
+        UartUtils.SwitchGas(false);
+    }
+
+    @JavascriptInterface
+    public void closeGas() {
+        UartUtils.SwitchGas(false);
+    }
+
+    @JavascriptInterface
+    public void openValve(int index, int pulse) {
+        UartUtils.OpenValve(index, pulse);
+    }
+
+    @JavascriptInterface
+    public void closeValve(int index) {
+        UartUtils.CloseValve(index);
+    }
+
+    @JavascriptInterface
+    public void readSteadyWeight(final int index) {
+        AtomicBoolean read = new AtomicBoolean(true);
+        Publisher.setSubscriber(weight -> {
+            read.set(false);
+            jsCall(String.format("steadyWeight(%d)", weight));
+        });
+        new Thread(() -> {
+            try {
+                while (true) {
+                    Thread.sleep(300);
+                    if (read.get()) UartUtils.ReadWeight(index);
+                    else break;
+                }
+            } catch (Exception e) {
+                jsCall("__Error_Happened__('application sleep error')");
+            }
+        }).start();
+    }
+
+    @JavascriptInterface
+    public void setVolume(int volume) {
+        volume = Math.min(volume, maxVolume);
+        if (audioManager.getStreamVolume(AudioManager.STREAM_MUSIC) > volume) {
+            while (audioManager.getStreamVolume(AudioManager.STREAM_MUSIC) > volume)
+                audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, 0);
+        } else {
+            while (audioManager.getStreamVolume(AudioManager.STREAM_MUSIC) < volume)
+                audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, 0);
+        }
+    }
+
+    @JavascriptInterface
+    public void show() {
+        context.enableGesture();
+    }
+
+    @JavascriptInterface
+    public void hide() {
+        context.disableGesture();
+    }
+}

+ 237 - 0
app/src/main/java/hm/wine/seller/lib/ShellUtils.java

@@ -0,0 +1,237 @@
+package hm.wine.seller.lib;
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.List;
+
+/**
+ * ShellUtils
+ * <ul>
+ * <strong>Check root</strong>
+ * <li>{@link ShellUtils#checkRootPermission()}</li>
+ * </ul>
+ * <ul>
+ * <strong>Execte command</strong>
+ * <li>{@link ShellUtils#execCommand(String, boolean)}</li>
+ * <li>{@link ShellUtils#execCommand(String, boolean, boolean)}</li>
+ * <li>{@link ShellUtils#execCommand(List, boolean)}</li>
+ * <li>{@link ShellUtils#execCommand(List, boolean, boolean)}</li>
+ * <li>{@link ShellUtils#execCommand(String[], boolean)}</li>
+ * <li>{@link ShellUtils#execCommand(String[], boolean, boolean)}</li>
+ * </ul>
+ *
+ * @author <a href="http://www.trinea.cn" target="_blank">Trinea</a> 2013-5-16
+ */
+public class ShellUtils {
+
+    public static final String COMMAND_SU = "su";
+    public static final String COMMAND_SH = "sh";
+    public static final String COMMAND_EXIT = "exit\n";
+    public static final String COMMAND_LINE_END = "\n";
+
+    //return ShellUtils.execAutoRoot("/system/bin/pm install -r " + apkPath);
+    private ShellUtils() {
+        throw new AssertionError();
+    }
+
+    /**
+     * check whether has root permission
+     *
+     * @return
+     */
+    public static boolean checkRootPermission() {
+        return execCommand("echo root", true, false).result == 0;
+    }
+
+    /**
+     * execute shell command, default return result msg
+     *
+     * @param command command
+     * @param isRoot  whether need to run with root
+     * @return
+     * @see ShellUtils#execCommand(String[], boolean, boolean)
+     */
+    public static CommandResult execCommand(String command, boolean isRoot) {
+        return execCommand(new String[]{command}, isRoot, true);
+    }
+
+    /**
+     * execute shell commands, default return result msg
+     *
+     * @param commands command list
+     * @param isRoot   whether need to run with root
+     * @return
+     * @see ShellUtils#execCommand(String[], boolean, boolean)
+     */
+    public static CommandResult execCommand(List<String> commands, boolean isRoot) {
+        return execCommand(commands == null ? null : commands.toArray(new String[]{}), isRoot, true);
+    }
+
+    /**
+     * execute shell commands, default return result msg
+     *
+     * @param commands command array
+     * @param isRoot   whether need to run with root
+     * @return
+     * @see ShellUtils#execCommand(String[], boolean, boolean)
+     */
+    public static CommandResult execCommand(String[] commands, boolean isRoot) {
+        return execCommand(commands, isRoot, true);
+    }
+
+    /**
+     * execute shell command
+     *
+     * @param command         command
+     * @param isRoot          whether need to run with root
+     * @param isNeedResultMsg whether need result msg
+     * @return
+     * @see ShellUtils#execCommand(String[], boolean, boolean)
+     */
+    public static CommandResult execCommand(String command, boolean isRoot, boolean isNeedResultMsg) {
+        return execCommand(new String[]{command}, isRoot, isNeedResultMsg);
+    }
+
+    /**
+     * execute shell commands
+     *
+     * @param commands        command list
+     * @param isRoot          whether need to run with root
+     * @param isNeedResultMsg whether need result msg
+     * @return
+     * @see ShellUtils#execCommand(String[], boolean, boolean)
+     */
+    public static CommandResult execCommand(List<String> commands, boolean isRoot, boolean isNeedResultMsg) {
+        return execCommand(commands == null ? null : commands.toArray(new String[]{}), isRoot, isNeedResultMsg);
+    }
+
+    /**
+     * execute shell commands
+     *
+     * @param commands        command array
+     * @param isRoot          whether need to run with root
+     * @param isNeedResultMsg whether need result msg
+     * @return <ul>
+     * <li>if isNeedResultMsg is false, {@link CommandResult#successMsg} is null and
+     * {@link CommandResult#errorMsg} is null.</li>
+     * <li>if {@link CommandResult#result} is -1, there maybe some excepiton.</li>
+     * </ul>
+     */
+    public static CommandResult execCommand(String[] commands, boolean isRoot, boolean isNeedResultMsg) {
+        int result = -1;
+        if (commands == null || commands.length == 0) {
+            return new CommandResult(result, null, null);
+        }
+
+        Process process = null;
+        BufferedReader successResult = null;
+        BufferedReader errorResult = null;
+        StringBuilder successMsg = null;
+        StringBuilder errorMsg = null;
+
+        DataOutputStream os = null;
+        try {
+            process = Runtime.getRuntime().exec(isRoot ? COMMAND_SU : COMMAND_SH);
+            os = new DataOutputStream(process.getOutputStream());
+            for (String command : commands) {
+                if (command == null) {
+                    continue;
+                }
+
+                // donnot use os.writeBytes(commmand), avoid chinese charset error
+                os.write(command.getBytes());
+                os.writeBytes(COMMAND_LINE_END);
+                os.flush();
+            }
+            os.writeBytes(COMMAND_EXIT);
+            os.flush();
+
+            result = process.waitFor();
+            // get command result
+            if (isNeedResultMsg) {
+                successMsg = new StringBuilder();
+                errorMsg = new StringBuilder();
+                successResult = new BufferedReader(new InputStreamReader(process.getInputStream()));
+                errorResult = new BufferedReader(new InputStreamReader(process.getErrorStream()));
+                String s;
+                while ((s = successResult.readLine()) != null) {
+                    successMsg.append(s);
+                }
+                while ((s = errorResult.readLine()) != null) {
+                    errorMsg.append(s);
+                }
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (os != null) {
+                    os.close();
+                }
+                if (successResult != null) {
+                    successResult.close();
+                }
+                if (errorResult != null) {
+                    errorResult.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+
+            if (process != null) {
+                process.destroy();
+            }
+        }
+        return new CommandResult(result, successMsg == null ? null : successMsg.toString(), errorMsg == null ? null
+                : errorMsg.toString());
+    }
+
+    public static CommandResult execAutoRoot(String cmd) {
+        CommandResult commandResult = ShellUtils.execCommand(cmd, true);
+        if (commandResult.result != 0) {
+            commandResult = ShellUtils.execCommand(cmd, false);
+        }
+        return commandResult;
+    }
+
+    /**
+     * result of command
+     * <ul>
+     * <li>{@link CommandResult#result} means result of command, 0 means normal, else means error, same to excute in
+     * linux shell</li>
+     * <li>{@link CommandResult#successMsg} means success message of command result</li>
+     * <li>{@link CommandResult#errorMsg} means error message of command result</li>
+     * </ul>
+     *
+     * @author <a href="http://www.trinea.cn" target="_blank">Trinea</a> 2013-5-16
+     */
+    public static class CommandResult {
+
+        /**
+         * result of command
+         **/
+        public int result;
+        /**
+         * success message of command result
+         **/
+        public String successMsg;
+        /**
+         * error message of command result
+         **/
+        public String errorMsg;
+
+        public CommandResult(int result) {
+            this.result = result;
+        }
+
+        public CommandResult(int result, String successMsg, String errorMsg) {
+            this.result = result;
+            this.successMsg = successMsg;
+            this.errorMsg = errorMsg;
+        }
+    }
+}

+ 71 - 0
app/src/main/java/hm/wine/seller/lib/UartUtils.java

@@ -0,0 +1,71 @@
+package hm.wine.seller.lib;
+
+import android.app.Application;
+import com.kongqw.serialportlibrary.Driver;
+import com.kongqw.serialportlibrary.SerialUtils;
+import com.kongqw.serialportlibrary.enumerate.SerialPortEnum;
+import com.kongqw.serialportlibrary.listener.SerialPortDirectorListens;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class UartUtils {
+    private static final byte Start1 = (byte) 0xAA, Start2 = (byte) 0x55;
+
+    private static byte[] getCmd(int op, int pra1, int pra2, int pra3) {
+        return new byte[]{Start1, Start2, (byte) op, (byte) pra1, (byte) pra2, (byte) pra3};
+    }
+
+    public static boolean isDataCorrect(final byte[] data) {
+        return data.length == 5 && data[0] == Start1 && data[1] == Start2;
+    }
+
+    public static void init(Application app, SerialPortDirectorListens listener) {
+        SerialUtils.getInstance().setmSerialPortDirectorListens(listener);
+        SerialUtils.getInstance().init(app, false, "串口", 40);
+        List<Driver> list2 = new ArrayList<>();
+        //串口ttyS1
+        list2.add(new Driver("/dev/ttyS1", "9600"));
+        SerialUtils.getInstance().manyOpenSerialPort(list2);
+    }
+
+    public static void close() {
+        SerialUtils.getInstance().serialPortClose();
+    }
+
+    public static void ReadWeight(int index) {
+        SerialUtils.getInstance().sendData(
+                SerialPortEnum.SERIAL_ONE, getCmd(0x01, index, 0x00, 0x00)
+        );
+    }
+
+    public static void OpenDoor(boolean front) {
+        SerialUtils.getInstance().sendData(
+                SerialPortEnum.SERIAL_ONE, getCmd(0x02, front ? 0x01 : 0x00, 0x00, 0x00)
+        );
+    }
+
+    public static void OpenValve(int index, int pulse) {
+        SerialUtils.getInstance().sendData(
+                SerialPortEnum.SERIAL_ONE, getCmd(0x03, index, (pulse & 0xFF00) >> 8, pulse & 0xFF)
+        );
+    }
+
+    public static void CloseValve(int index) {
+        SerialUtils.getInstance().sendData(
+                SerialPortEnum.SERIAL_ONE, getCmd(0x04, index, 0x00, 0x00)
+        );
+    }
+
+    public static void SwitchLight(int index, boolean on) {
+        SerialUtils.getInstance().sendData(
+                SerialPortEnum.SERIAL_ONE, getCmd(0x05, index, on ? 0x01 : 0x00, 0x00)
+        );
+    }
+
+    public static void SwitchGas(boolean on) {
+        SerialUtils.getInstance().sendData(
+                SerialPortEnum.SERIAL_ONE, getCmd(0x06, on ? 0x01 : 0x00, 0x00, 0x00)
+        );
+    }
+}

+ 23 - 0
app/src/main/java/hm/wine/seller/lib/WakeLock.java

@@ -0,0 +1,23 @@
+package hm.wine.seller.lib;
+
+import android.content.Context;
+import android.os.PowerManager;
+
+public class WakeLock {
+    private static PowerManager.WakeLock wakeLock;
+
+    public static void acquireWakeLock(Context context) {
+        if (wakeLock == null) {
+            PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
+            wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Wine:WakeLock");
+            wakeLock.acquire(10 * 60 * 1000L /*10 minutes*/);
+        }
+    }
+
+    public static void releaseWakeLock() {
+        if (wakeLock != null && wakeLock.isHeld()) {
+            wakeLock.release();
+            wakeLock = null;
+        }
+    }
+}

+ 14 - 0
app/src/main/java/linux-auto.sh

@@ -0,0 +1,14 @@
+#!/system/bin/sh
+
+APP_PACKAGE_NAME="hm.wine.seller"
+
+while true
+do
+    app_running=$(ps | grep $APP_PACKAGE_NAME)
+
+    if [ -z "$app_running" ]; then
+        am start -n "$APP_PACKAGE_NAME/.MainActivity"
+    fi
+
+    sleep 60
+done

+ 74 - 0
app/src/main/res/drawable/app_icon_background.xml

@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector
+    android:height="108dp"
+    android:width="108dp"
+    android:viewportHeight="108"
+    android:viewportWidth="108"
+    xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="#3DDC84"
+          android:pathData="M0,0h108v108h-108z"/>
+    <path android:fillColor="#00000000" android:pathData="M9,0L9,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M19,0L19,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M29,0L29,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M39,0L39,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M49,0L49,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M59,0L59,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M69,0L69,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M79,0L79,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M89,0L89,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M99,0L99,108"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,9L108,9"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,19L108,19"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,29L108,29"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,39L108,39"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,49L108,49"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,59L108,59"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,69L108,69"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,79L108,79"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,89L108,89"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M0,99L108,99"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M19,29L89,29"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M19,39L89,39"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M19,49L89,49"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M19,59L89,59"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M19,69L89,69"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M19,79L89,79"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M29,19L29,89"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M39,19L39,89"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M49,19L49,89"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M59,19L59,89"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M69,19L69,89"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+    <path android:fillColor="#00000000" android:pathData="M79,19L79,89"
+          android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+</vector>

+ 6 - 0
app/src/main/res/drawable/border.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
+    <solid android:color="#ffffff" />
+    <stroke android:width="2dp"
+            android:color="#636363"/>
+</shape>

+ 11 - 0
app/src/main/res/layout/main_activity.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:orientation="vertical"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent">
+    <WebView
+            android:id="@+id/webview"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+    />
+</LinearLayout>

+ 5 - 0
app/src/main/res/mipmap-anydpi-v26/app_icon.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+    <background android:drawable="@drawable/app_icon_background"/>
+    <foreground android:drawable="@mipmap/app_icon_foreground"/>
+</adaptive-icon>

+ 5 - 0
app/src/main/res/mipmap-anydpi-v26/app_icon_round.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+    <background android:drawable="@drawable/app_icon_background"/>
+    <foreground android:drawable="@mipmap/app_icon_foreground"/>
+</adaptive-icon>

BIN
app/src/main/res/mipmap-hdpi/app_icon.png


BIN
app/src/main/res/mipmap-hdpi/app_icon_foreground.png


BIN
app/src/main/res/mipmap-hdpi/app_icon_round.png


BIN
app/src/main/res/mipmap-mdpi/app_icon.png


BIN
app/src/main/res/mipmap-mdpi/app_icon_foreground.png


BIN
app/src/main/res/mipmap-mdpi/app_icon_round.png


BIN
app/src/main/res/mipmap-xhdpi/app_icon.png


BIN
app/src/main/res/mipmap-xhdpi/app_icon_foreground.png


BIN
app/src/main/res/mipmap-xhdpi/app_icon_round.png


BIN
app/src/main/res/mipmap-xxhdpi/app_icon.png


BIN
app/src/main/res/mipmap-xxhdpi/app_icon_foreground.png


BIN
app/src/main/res/mipmap-xxhdpi/app_icon_round.png


BIN
app/src/main/res/mipmap-xxxhdpi/app_icon.png


BIN
app/src/main/res/mipmap-xxxhdpi/app_icon_foreground.png


BIN
app/src/main/res/mipmap-xxxhdpi/app_icon_round.png


+ 17 - 0
app/src/main/res/values-night/themes.xml

@@ -0,0 +1,17 @@
+<resources xmlns:tools="http://schemas.android.com/tools">
+    <!-- Base application theme. -->
+    <style name="Theme.Wine" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
+        <!-- Primary brand color. -->
+        <item name="colorPrimary">@color/purple_200</item>
+        <item name="colorPrimaryVariant">@color/purple_700</item>
+        <item name="colorOnPrimary">@color/black</item>
+        <!-- Secondary brand color. -->
+        <item name="colorSecondary">@color/teal_200</item>
+        <item name="colorSecondaryVariant">@color/teal_200</item>
+        <item name="colorOnSecondary">@color/black</item>
+        <!-- Status bar color. -->
+        <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
+        <!-- Customize your theme here. -->
+        <item name="android:windowFullscreen">true</item>
+    </style>
+</resources>

+ 10 - 0
app/src/main/res/values/colors.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <color name="purple_200">#FFBB86FC</color>
+    <color name="purple_500">#FF6200EE</color>
+    <color name="purple_700">#FF3700B3</color>
+    <color name="teal_200">#FF03DAC5</color>
+    <color name="teal_700">#FF018786</color>
+    <color name="black">#FF000000</color>
+    <color name="white">#FFFFFFFF</color>
+</resources>

+ 5 - 0
app/src/main/res/values/strings.xml

@@ -0,0 +1,5 @@
+<resources>
+    <string name="app_name">四酒源流</string>
+    <string name="front_host">https://wine.ifarmcloud.com/seller/</string>
+    <string name="version_url">https://wine.ifarmcloud.com/api/seller/version</string>
+</resources>

+ 17 - 0
app/src/main/res/values/themes.xml

@@ -0,0 +1,17 @@
+<resources xmlns:tools="http://schemas.android.com/tools">
+    <!-- Base application theme. -->
+    <style name="Theme.Wine" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
+        <!-- Primary brand color. -->
+        <item name="colorPrimary">@color/purple_500</item>
+        <item name="colorPrimaryVariant">@color/purple_700</item>
+        <item name="colorOnPrimary">@color/white</item>
+        <!-- Secondary brand color. -->
+        <item name="colorSecondary">@color/teal_200</item>
+        <item name="colorSecondaryVariant">@color/teal_700</item>
+        <item name="colorOnSecondary">@color/black</item>
+        <!-- Status bar color. -->
+        <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
+        <!-- Customize your theme here. -->
+        <item name="android:windowFullscreen">true</item>
+    </style>
+</resources>

+ 17 - 0
app/src/test/java/hm/wine/seller/ExampleUnitTest.java

@@ -0,0 +1,17 @@
+package hm.wine.seller;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+public class ExampleUnitTest {
+    @Test
+    public void addition_isCorrect() {
+        assertEquals(4, 2 + 2);
+    }
+}

+ 25 - 0
build.gradle

@@ -0,0 +1,25 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+    repositories {
+        google()
+        jcenter()
+    }
+    dependencies {
+        classpath "com.android.tools.build:gradle:4.1.1"
+
+        // NOTE: Do not place your application dependencies here; they belong
+        // in the individual module build.gradle files
+    }
+}
+
+allprojects {
+    repositories {
+        google()
+        jcenter()
+        maven { url "https://jitpack.io" }
+    }
+}
+
+task clean(type: Delete) {
+    delete rootProject.buildDir
+}

+ 19 - 0
gradle.properties

@@ -0,0 +1,19 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+# AndroidX package structure to make it clearer which packages are bundled with the
+# Android operating system, and which are packaged with your app"s APK
+# https://developer.android.com/topic/libraries/support-library/androidx-rn
+android.useAndroidX=true
+# Automatically convert third-party libraries to use AndroidX
+android.enableJetifier=true

BIN
gradle/wrapper/gradle-wrapper.jar


+ 6 - 0
gradle/wrapper/gradle-wrapper.properties

@@ -0,0 +1,6 @@
+#Mon Sep 04 18:31:52 CST 2023
+distributionBase=GRADLE_USER_HOME
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
+distributionPath=wrapper/dists
+zipStorePath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME

+ 172 - 0
gradlew

@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+    echo "$*"
+}
+
+die () {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Escape application args
+save () {
+    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+    echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+  cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"

+ 84 - 0
gradlew.bat

@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

+ 2 - 0
settings.gradle

@@ -0,0 +1,2 @@
+include ':app'
+rootProject.name = "Wine"