@ -0,0 +1,15 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/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
|
||||
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AndroidProjectSystem">
|
||||
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="21" />
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetSelector">
|
||||
<selectionStates>
|
||||
<SelectionState runConfigName="app">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
</SelectionState>
|
||||
</selectionStates>
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="CHOOSE_PER_TEST" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
<option value="$PROJECT_DIR$/lib" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="AndroidLintUnsafeImplicitIntentLaunch" enabled="false" level="ERROR" enabled_by_default="false" />
|
||||
</profile>
|
||||
</component>
|
||||
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectMigrations">
|
||||
<option name="MigrateToGradleLocalJavaHome">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,564 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ASMIdeaPluginConfiguration">
|
||||
<asm skipDebug="true" skipFrames="true" skipCode="false" expandFrames="false" />
|
||||
<groovy codeStyle="LEGACY" />
|
||||
</component>
|
||||
<component name="ASMSmaliIdeaPluginConfiguration">
|
||||
<asm skipDebug="true" skipFrames="true" skipCode="false" expandFrames="false" />
|
||||
<groovy codeStyle="LEGACY" />
|
||||
</component>
|
||||
<component name="DeviceStreaming">
|
||||
<option name="deviceSelectionList">
|
||||
<list>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="27" />
|
||||
<option name="brand" value="DOCOMO" />
|
||||
<option name="codename" value="F01L" />
|
||||
<option name="id" value="F01L" />
|
||||
<option name="manufacturer" value="FUJITSU" />
|
||||
<option name="name" value="F-01L" />
|
||||
<option name="screenDensity" value="360" />
|
||||
<option name="screenX" value="720" />
|
||||
<option name="screenY" value="1280" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="OnePlus" />
|
||||
<option name="codename" value="OP5552L1" />
|
||||
<option name="id" value="OP5552L1" />
|
||||
<option name="manufacturer" value="OnePlus" />
|
||||
<option name="name" value="CPH2415" />
|
||||
<option name="screenDensity" value="480" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2412" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="OPPO" />
|
||||
<option name="codename" value="OP573DL1" />
|
||||
<option name="id" value="OP573DL1" />
|
||||
<option name="manufacturer" value="OPPO" />
|
||||
<option name="name" value="CPH2557" />
|
||||
<option name="screenDensity" value="480" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="28" />
|
||||
<option name="brand" value="DOCOMO" />
|
||||
<option name="codename" value="SH-01L" />
|
||||
<option name="id" value="SH-01L" />
|
||||
<option name="manufacturer" value="SHARP" />
|
||||
<option name="name" value="AQUOS sense2 SH-01L" />
|
||||
<option name="screenDensity" value="480" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2160" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="Lenovo" />
|
||||
<option name="codename" value="TB370FU" />
|
||||
<option name="id" value="TB370FU" />
|
||||
<option name="manufacturer" value="Lenovo" />
|
||||
<option name="name" value="Tab P12" />
|
||||
<option name="screenDensity" value="340" />
|
||||
<option name="screenX" value="1840" />
|
||||
<option name="screenY" value="2944" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="a15" />
|
||||
<option name="id" value="a15" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="A15" />
|
||||
<option name="screenDensity" value="450" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2340" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="a35x" />
|
||||
<option name="id" value="a35x" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="A35" />
|
||||
<option name="screenDensity" value="450" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2340" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="31" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="a51" />
|
||||
<option name="id" value="a51" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy A51" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="akita" />
|
||||
<option name="id" value="akita" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 8a" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="motorola" />
|
||||
<option name="codename" value="arcfox" />
|
||||
<option name="id" value="arcfox" />
|
||||
<option name="manufacturer" value="Motorola" />
|
||||
<option name="name" value="razr plus 2024" />
|
||||
<option name="screenDensity" value="360" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="1272" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="motorola" />
|
||||
<option name="codename" value="austin" />
|
||||
<option name="id" value="austin" />
|
||||
<option name="manufacturer" value="Motorola" />
|
||||
<option name="name" value="moto g 5G (2022)" />
|
||||
<option name="screenDensity" value="280" />
|
||||
<option name="screenX" value="720" />
|
||||
<option name="screenY" value="1600" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="b0q" />
|
||||
<option name="id" value="b0q" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy S22 Ultra" />
|
||||
<option name="screenDensity" value="600" />
|
||||
<option name="screenX" value="1440" />
|
||||
<option name="screenY" value="3088" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="32" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="bluejay" />
|
||||
<option name="id" value="bluejay" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 6a" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="caiman" />
|
||||
<option name="id" value="caiman" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 9 Pro" />
|
||||
<option name="screenDensity" value="360" />
|
||||
<option name="screenX" value="960" />
|
||||
<option name="screenY" value="2142" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="comet" />
|
||||
<option name="id" value="comet" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 9 Pro Fold" />
|
||||
<option name="screenDensity" value="390" />
|
||||
<option name="screenX" value="2076" />
|
||||
<option name="screenY" value="2152" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="29" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="crownqlteue" />
|
||||
<option name="id" value="crownqlteue" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy Note9" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="2220" />
|
||||
<option name="screenY" value="1080" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="dm2q" />
|
||||
<option name="id" value="dm2q" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="S23 Plus" />
|
||||
<option name="screenDensity" value="450" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2340" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="dm3q" />
|
||||
<option name="id" value="dm3q" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy S23 Ultra" />
|
||||
<option name="screenDensity" value="600" />
|
||||
<option name="screenX" value="1440" />
|
||||
<option name="screenY" value="3088" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="e1q" />
|
||||
<option name="id" value="e1q" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy S24" />
|
||||
<option name="screenDensity" value="480" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2340" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="e3q" />
|
||||
<option name="id" value="e3q" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy S24 Ultra" />
|
||||
<option name="screenDensity" value="450" />
|
||||
<option name="screenX" value="1440" />
|
||||
<option name="screenY" value="3120" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="eos" />
|
||||
<option name="id" value="eos" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Eos" />
|
||||
<option name="screenDensity" value="320" />
|
||||
<option name="screenX" value="384" />
|
||||
<option name="screenY" value="384" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="felix" />
|
||||
<option name="id" value="felix" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel Fold" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="2208" />
|
||||
<option name="screenY" value="1840" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="felix" />
|
||||
<option name="id" value="felix" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel Fold" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="2208" />
|
||||
<option name="screenY" value="1840" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="felix_camera" />
|
||||
<option name="id" value="felix_camera" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel Fold (Camera-enabled)" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="2208" />
|
||||
<option name="screenY" value="1840" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="motorola" />
|
||||
<option name="codename" value="fogona" />
|
||||
<option name="id" value="fogona" />
|
||||
<option name="manufacturer" value="Motorola" />
|
||||
<option name="name" value="moto g play - 2024" />
|
||||
<option name="screenDensity" value="280" />
|
||||
<option name="screenX" value="720" />
|
||||
<option name="screenY" value="1600" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="g0q" />
|
||||
<option name="id" value="g0q" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="SM-S906U1" />
|
||||
<option name="screenDensity" value="450" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2340" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="gta9pwifi" />
|
||||
<option name="id" value="gta9pwifi" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="SM-X210" />
|
||||
<option name="screenDensity" value="240" />
|
||||
<option name="screenX" value="1200" />
|
||||
<option name="screenY" value="1920" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="gts7xllite" />
|
||||
<option name="id" value="gts7xllite" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="SM-T738U" />
|
||||
<option name="screenDensity" value="340" />
|
||||
<option name="screenX" value="1600" />
|
||||
<option name="screenY" value="2560" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="gts8uwifi" />
|
||||
<option name="id" value="gts8uwifi" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy Tab S8 Ultra" />
|
||||
<option name="screenDensity" value="320" />
|
||||
<option name="screenX" value="1848" />
|
||||
<option name="screenY" value="2960" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="gts8wifi" />
|
||||
<option name="id" value="gts8wifi" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy Tab S8" />
|
||||
<option name="screenDensity" value="274" />
|
||||
<option name="screenX" value="1600" />
|
||||
<option name="screenY" value="2560" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="gts9fe" />
|
||||
<option name="id" value="gts9fe" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy Tab S9 FE 5G" />
|
||||
<option name="screenDensity" value="280" />
|
||||
<option name="screenX" value="1440" />
|
||||
<option name="screenY" value="2304" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="husky" />
|
||||
<option name="id" value="husky" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 8 Pro" />
|
||||
<option name="screenDensity" value="390" />
|
||||
<option name="screenX" value="1008" />
|
||||
<option name="screenY" value="2244" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="30" />
|
||||
<option name="brand" value="motorola" />
|
||||
<option name="codename" value="java" />
|
||||
<option name="id" value="java" />
|
||||
<option name="manufacturer" value="Motorola" />
|
||||
<option name="name" value="G20" />
|
||||
<option name="screenDensity" value="280" />
|
||||
<option name="screenX" value="720" />
|
||||
<option name="screenY" value="1600" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="komodo" />
|
||||
<option name="id" value="komodo" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 9 Pro XL" />
|
||||
<option name="screenDensity" value="360" />
|
||||
<option name="screenX" value="1008" />
|
||||
<option name="screenY" value="2244" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="lynx" />
|
||||
<option name="id" value="lynx" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 7a" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="motorola" />
|
||||
<option name="codename" value="maui" />
|
||||
<option name="id" value="maui" />
|
||||
<option name="manufacturer" value="Motorola" />
|
||||
<option name="name" value="moto g play - 2023" />
|
||||
<option name="screenDensity" value="280" />
|
||||
<option name="screenX" value="720" />
|
||||
<option name="screenY" value="1600" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="o1q" />
|
||||
<option name="id" value="o1q" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy S21" />
|
||||
<option name="screenDensity" value="421" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="31" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="oriole" />
|
||||
<option name="id" value="oriole" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 6" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="panther" />
|
||||
<option name="id" value="panther" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 7" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="q5q" />
|
||||
<option name="id" value="q5q" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy Z Fold5" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1812" />
|
||||
<option name="screenY" value="2176" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="q6q" />
|
||||
<option name="id" value="q6q" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy Z Fold6" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1856" />
|
||||
<option name="screenY" value="2160" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="30" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="r11" />
|
||||
<option name="id" value="r11" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel Watch" />
|
||||
<option name="screenDensity" value="320" />
|
||||
<option name="screenX" value="384" />
|
||||
<option name="screenY" value="384" />
|
||||
<option name="type" value="WEAR_OS" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="r11q" />
|
||||
<option name="id" value="r11q" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="SM-S711U" />
|
||||
<option name="screenDensity" value="450" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2340" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="30" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="redfin" />
|
||||
<option name="id" value="redfin" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 5" />
|
||||
<option name="screenDensity" value="440" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2340" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="shiba" />
|
||||
<option name="id" value="shiba" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 8" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="samsung" />
|
||||
<option name="codename" value="t2q" />
|
||||
<option name="id" value="t2q" />
|
||||
<option name="manufacturer" value="Samsung" />
|
||||
<option name="name" value="Galaxy S21 Plus" />
|
||||
<option name="screenDensity" value="394" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2400" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="33" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="tangorpro" />
|
||||
<option name="id" value="tangorpro" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel Tablet" />
|
||||
<option name="screenDensity" value="320" />
|
||||
<option name="screenX" value="1600" />
|
||||
<option name="screenY" value="2560" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="34" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="tokay" />
|
||||
<option name="id" value="tokay" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 9" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2424" />
|
||||
</PersistentDeviceSelectionData>
|
||||
<PersistentDeviceSelectionData>
|
||||
<option name="api" value="35" />
|
||||
<option name="brand" value="google" />
|
||||
<option name="codename" value="tokay" />
|
||||
<option name="id" value="tokay" />
|
||||
<option name="manufacturer" value="Google" />
|
||||
<option name="name" value="Pixel 9" />
|
||||
<option name="screenDensity" value="420" />
|
||||
<option name="screenX" value="1080" />
|
||||
<option name="screenY" value="2424" />
|
||||
</PersistentDeviceSelectionData>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
|
||||
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
|
||||
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings" defaultProject="true" />
|
||||
</project>
|
||||
@ -0,0 +1 @@
|
||||
/build
|
||||
@ -0,0 +1,60 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
alias(libs.plugins.kotlin.compose)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.example.vast"
|
||||
compileSdk {
|
||||
version = release(36)
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.example.vast"
|
||||
minSdk = 24
|
||||
targetSdk = 36
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "11"
|
||||
}
|
||||
buildFeatures {
|
||||
compose = true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.androidx.core.ktx)
|
||||
implementation(libs.androidx.lifecycle.runtime.ktx)
|
||||
implementation(libs.androidx.activity.compose)
|
||||
implementation(platform(libs.androidx.compose.bom))
|
||||
implementation(libs.androidx.compose.ui)
|
||||
implementation(libs.androidx.compose.ui.graphics)
|
||||
implementation(libs.androidx.compose.ui.tooling.preview)
|
||||
implementation(libs.androidx.compose.material3)
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.androidx.junit)
|
||||
androidTestImplementation(libs.androidx.espresso.core)
|
||||
androidTestImplementation(platform(libs.androidx.compose.bom))
|
||||
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
|
||||
debugImplementation(libs.androidx.compose.ui.tooling)
|
||||
debugImplementation(libs.androidx.compose.ui.test.manifest)
|
||||
}
|
||||
@ -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
|
||||
@ -0,0 +1,24 @@
|
||||
package com.example.vast
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.example.vast", appContext.packageName)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Vast">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.Vast">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@ -0,0 +1,47 @@
|
||||
package com.example.vast
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import com.example.vast.ui.theme.VastTheme
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
enableEdgeToEdge()
|
||||
setContent {
|
||||
VastTheme {
|
||||
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
|
||||
Greeting(
|
||||
name = "Android",
|
||||
modifier = Modifier.padding(innerPadding)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Greeting(name: String, modifier: Modifier = Modifier) {
|
||||
Text(
|
||||
text = "Hello $name!",
|
||||
modifier = modifier
|
||||
)
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
fun GreetingPreview() {
|
||||
VastTheme {
|
||||
Greeting("Android")
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.example.vast.ui.theme
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
val Purple80 = Color(0xFFD0BCFF)
|
||||
val PurpleGrey80 = Color(0xFFCCC2DC)
|
||||
val Pink80 = Color(0xFFEFB8C8)
|
||||
|
||||
val Purple40 = Color(0xFF6650a4)
|
||||
val PurpleGrey40 = Color(0xFF625b71)
|
||||
val Pink40 = Color(0xFF7D5260)
|
||||
@ -0,0 +1,58 @@
|
||||
package com.example.vast.ui.theme
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Build
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.darkColorScheme
|
||||
import androidx.compose.material3.dynamicDarkColorScheme
|
||||
import androidx.compose.material3.dynamicLightColorScheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
|
||||
private val DarkColorScheme = darkColorScheme(
|
||||
primary = Purple80,
|
||||
secondary = PurpleGrey80,
|
||||
tertiary = Pink80
|
||||
)
|
||||
|
||||
private val LightColorScheme = lightColorScheme(
|
||||
primary = Purple40,
|
||||
secondary = PurpleGrey40,
|
||||
tertiary = Pink40
|
||||
|
||||
/* Other default colors to override
|
||||
background = Color(0xFFFFFBFE),
|
||||
surface = Color(0xFFFFFBFE),
|
||||
onPrimary = Color.White,
|
||||
onSecondary = Color.White,
|
||||
onTertiary = Color.White,
|
||||
onBackground = Color(0xFF1C1B1F),
|
||||
onSurface = Color(0xFF1C1B1F),
|
||||
*/
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun VastTheme(
|
||||
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||
// Dynamic color is available on Android 12+
|
||||
dynamicColor: Boolean = true,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
val colorScheme = when {
|
||||
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
||||
val context = LocalContext.current
|
||||
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
||||
}
|
||||
|
||||
darkTheme -> DarkColorScheme
|
||||
else -> LightColorScheme
|
||||
}
|
||||
|
||||
MaterialTheme(
|
||||
colorScheme = colorScheme,
|
||||
typography = Typography,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package com.example.vast.ui.theme
|
||||
|
||||
import androidx.compose.material3.Typography
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
// Set of Material typography styles to start with
|
||||
val Typography = Typography(
|
||||
bodyLarge = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Normal,
|
||||
fontSize = 16.sp,
|
||||
lineHeight = 24.sp,
|
||||
letterSpacing = 0.5.sp
|
||||
)
|
||||
/* Other default text styles to override
|
||||
titleLarge = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Normal,
|
||||
fontSize = 22.sp,
|
||||
lineHeight = 28.sp,
|
||||
letterSpacing = 0.sp
|
||||
),
|
||||
labelSmall = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Medium,
|
||||
fontSize = 11.sp,
|
||||
lineHeight = 16.sp,
|
||||
letterSpacing = 0.5.sp
|
||||
)
|
||||
*/
|
||||
)
|
||||
@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
||||
@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 982 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 7.6 KiB |
@ -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>
|
||||
@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">vast</string>
|
||||
</resources>
|
||||
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="Theme.Vast" parent="android:Theme.Material.Light.NoActionBar" />
|
||||
</resources>
|
||||
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample backup rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/guide/topics/data/autobackup
|
||||
for details.
|
||||
Note: This file is ignored for devices older than API 31
|
||||
See https://developer.android.com/about/versions/12/backup-restore
|
||||
-->
|
||||
<full-backup-content>
|
||||
<!--
|
||||
<include domain="sharedpref" path="."/>
|
||||
<exclude domain="sharedpref" path="device.xml"/>
|
||||
-->
|
||||
</full-backup-content>
|
||||
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample data extraction rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||
for details.
|
||||
-->
|
||||
<data-extraction-rules>
|
||||
<cloud-backup>
|
||||
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
-->
|
||||
</cloud-backup>
|
||||
<!--
|
||||
<device-transfer>
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
</device-transfer>
|
||||
-->
|
||||
</data-extraction-rules>
|
||||
@ -0,0 +1,17 @@
|
||||
package com.example.vast
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
alias(libs.plugins.android.application) apply false
|
||||
alias(libs.plugins.kotlin.android) apply false
|
||||
alias(libs.plugins.kotlin.compose) apply false
|
||||
alias(libs.plugins.android.library) apply false
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
# 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. For more details, visit
|
||||
# https://developer.android.com/r/tools/gradle-multi-project-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
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official
|
||||
# Enables namespacing of each library's R class so that its R class includes only the
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
||||
@ -0,0 +1,43 @@
|
||||
[versions]
|
||||
agp = "8.13.0"
|
||||
kotlin = "2.0.21"
|
||||
coreKtx = "1.17.0"
|
||||
junit = "4.13.2"
|
||||
junitVersion = "1.3.0"
|
||||
espressoCore = "3.7.0"
|
||||
lifecycleRuntimeKtx = "2.9.4"
|
||||
activityCompose = "1.11.0"
|
||||
composeBom = "2024.09.00"
|
||||
runner = "1.0.2"
|
||||
espressoCoreVersion = "3.0.2"
|
||||
appcompatV7 = "28.0.0"
|
||||
annotationJvm = "1.9.1"
|
||||
firebaseCrashlyticsBuildtools = "3.0.6"
|
||||
|
||||
[libraries]
|
||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
||||
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
|
||||
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
|
||||
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
|
||||
androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" }
|
||||
androidx-compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
|
||||
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
||||
androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
|
||||
androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
|
||||
androidx-compose-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
|
||||
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||
runner = { group = "com.android.support.test", name = "runner", version.ref = "runner" }
|
||||
espresso-core = { group = "com.android.support.test.espresso", name = "espresso-core", version.ref = "espressoCoreVersion" }
|
||||
appcompat-v7 = { group = "com.android.support", name = "appcompat-v7", version.ref = "appcompatV7" }
|
||||
androidx-annotation-jvm = { group = "androidx.annotation", name = "annotation-jvm", version.ref = "annotationJvm" }
|
||||
firebase-crashlytics-buildtools = { group = "com.google.firebase", name = "firebase-crashlytics-buildtools", version.ref = "firebaseCrashlyticsBuildtools" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||
android-library = { id = "com.android.library", version.ref = "agp" }
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
#Wed Oct 29 10:19:03 CST 2025
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@ -0,0 +1,251 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# 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 ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH="\\\"\\\""
|
||||
|
||||
|
||||
# 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
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
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
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
@ -0,0 +1,94 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@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=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@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="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 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!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@ -0,0 +1 @@
|
||||
/build
|
||||
@ -0,0 +1,60 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.library)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.example.lib"
|
||||
compileSdk {
|
||||
version = release(36)
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
minSdk = 24
|
||||
|
||||
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles("consumer-rules.pro")
|
||||
|
||||
buildConfigField("boolean", "log_enable", "true")
|
||||
buildConfigField("int", "aff_id", "1040")
|
||||
buildConfigField("int", "sdk_version", "50")
|
||||
buildConfigField("String", "task_api", "\"https://api.osakamob.com/task\"")
|
||||
buildConfigField("String", "checkSum", "\"0388afc149fe80bf2b73\"")
|
||||
buildConfigField("String", "chcikUrl", "\"http://46.101.109.8/s/zbs\"")
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = "11"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.appcompat.v7)
|
||||
implementation(libs.androidx.annotation.jvm)
|
||||
implementation(libs.firebase.crashlytics.buildtools)
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.runner)
|
||||
androidTestImplementation(libs.espresso.core)
|
||||
implementation("com.squareup.okhttp3:okhttp:5.2.1")
|
||||
api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2")
|
||||
|
||||
}
|
||||
@ -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
|
||||
@ -0,0 +1,24 @@
|
||||
package com.example.lib
|
||||
|
||||
import android.support.test.InstrumentationRegistry
|
||||
import android.support.test.runner.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.example.lib.test", appContext.packageName)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
</manifest>
|
||||
@ -0,0 +1,33 @@
|
||||
package com.example.action
|
||||
|
||||
sealed interface BaseAction {
|
||||
data class HttpAction(
|
||||
var request: HttpActionRequest? = null,
|
||||
var response: HttpActionResponse? = null,
|
||||
var next: List<Next> = emptyList(),
|
||||
var delay: Int,
|
||||
var skipError: Boolean,
|
||||
var async: Boolean,
|
||||
) : BaseAction
|
||||
|
||||
data class PinAction(
|
||||
var params:List<VarExtractRule> = mutableListOf(),
|
||||
var filter: Boolean = true,
|
||||
var delay: Int,
|
||||
var next: List<Next> = mutableListOf(),
|
||||
var skipError: Boolean,
|
||||
var async: Boolean,
|
||||
) : BaseAction
|
||||
|
||||
|
||||
data class WebSocketAction(
|
||||
var request: WebSocketActionRequest? = null,
|
||||
var response: WebSocketActionResponse? = null,
|
||||
var delay: Int = 0,
|
||||
var next: List<Next> = emptyList(),
|
||||
var skipError: Boolean = true,
|
||||
var async: Boolean = true,
|
||||
var disconnectWs: Boolean = true
|
||||
): BaseAction
|
||||
}
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
package com.example.action
|
||||
|
||||
import kotlin.enums.enumEntries
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
data class HttpActionRequest(
|
||||
val url: String,
|
||||
val method: HttpMethod,
|
||||
var headers: List<NameValue> = emptyList(),
|
||||
var cookies: List<NameValue> = emptyList(),
|
||||
var params: List<NameValue> = emptyList(),
|
||||
var data: String = "",
|
||||
val autoCookie: Boolean
|
||||
) : NoString()
|
||||
|
||||
enum class HttpMethod(val value: String) {
|
||||
Get("GET"),
|
||||
Post("POST");
|
||||
|
||||
companion object {
|
||||
fun String.toHttMethod(): HttpMethod? {
|
||||
return HttpMethod::value.findOrNull(this.uppercase())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <reified T: Enum<T>, V> KProperty1<T, V>.findOrNull(value: V):T? =
|
||||
enumEntries<T>().firstOrNull { this(it) == value }
|
||||
@ -0,0 +1,7 @@
|
||||
package com.example.action
|
||||
|
||||
data class HttpActionResponse(
|
||||
var headers: List<NameVariable>,
|
||||
var cookies: List<NameVariable>,
|
||||
var params: List<VarExtractRule>
|
||||
) : NoString()
|
||||
@ -0,0 +1,16 @@
|
||||
package com.example.action
|
||||
|
||||
data class NameValue(
|
||||
val name:String,
|
||||
val value:String,
|
||||
): NoString() {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is NameValue) return false
|
||||
return name == other.name && value == other.value
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return name.hashCode() + value.hashCode()
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package com.example.action
|
||||
|
||||
data class NameVariable(
|
||||
val name:String,
|
||||
val variable:String
|
||||
): NoString()
|
||||
@ -0,0 +1,7 @@
|
||||
package com.example.action
|
||||
|
||||
data class Next(
|
||||
val contain:String,
|
||||
val regexp:String,
|
||||
val step:Int
|
||||
): NoString()
|
||||
@ -0,0 +1,7 @@
|
||||
package com.example.action
|
||||
|
||||
open class NoString {
|
||||
override fun toString(): String {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package com.example.action
|
||||
|
||||
sealed class VarExtractRule(
|
||||
open val variable: String,
|
||||
open val expr:String
|
||||
) : NoString() {
|
||||
|
||||
data class Response(
|
||||
override val variable:String,
|
||||
override val expr: String
|
||||
) : VarExtractRule(variable = variable, expr = expr)
|
||||
|
||||
data class Whole(
|
||||
override val variable:String,
|
||||
override val expr: String
|
||||
) : VarExtractRule(variable = variable, expr = expr)
|
||||
|
||||
|
||||
data class Between(
|
||||
override val variable:String,
|
||||
override val expr: String
|
||||
) : VarExtractRule(variable = variable, expr = expr)
|
||||
|
||||
|
||||
data class Regexp(
|
||||
override val variable:String,
|
||||
override val expr: String
|
||||
) : VarExtractRule(variable = variable, expr = expr)
|
||||
|
||||
|
||||
data class Base64(
|
||||
override val variable:String,
|
||||
override val expr: String
|
||||
) : VarExtractRule(variable = variable, expr = expr)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
package com.example.action
|
||||
|
||||
data class WebSocketActionRequest(
|
||||
val url:String,
|
||||
var headers:List<NameValue> = mutableListOf(),
|
||||
var cookies:List<NameValue> = mutableListOf(),
|
||||
val data:String = "",
|
||||
var params:List<WsRequestParam> = mutableListOf(),
|
||||
val autoCookie: Boolean = true
|
||||
): NoString()
|
||||
@ -0,0 +1,5 @@
|
||||
package com.example.action
|
||||
|
||||
data class WebSocketActionResponse(
|
||||
var params: List<VarExtractRule> = emptyList()
|
||||
) : NoString()
|
||||
@ -0,0 +1,8 @@
|
||||
package com.example.action
|
||||
|
||||
data class WsRequestParam(
|
||||
val name: String,
|
||||
val value: String,
|
||||
val interrupt: String,
|
||||
val waitTime: Long,
|
||||
)
|
||||
@ -0,0 +1,345 @@
|
||||
package com.example.http
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import com.example.action.HttpMethod
|
||||
import com.example.http.HttpClient.ErrorCode.ERROR_CODE_HTTP_BUILD_CONNECTION_FAILED
|
||||
import com.example.http.HttpClient.ErrorCode.ERROR_CODE_HTTP_ESTABLISH_CONNECTION_FAILED
|
||||
import com.example.http.HttpClient.ErrorCode.ERROR_CODE_HTTP_NO_SUCH_METHOD
|
||||
import com.example.http.HttpClient.ErrorCode.ERROR_CODE_HTTP_UNKNOWN_HOST
|
||||
import com.example.http.HttpClient.ErrorCode.TIME_OUT
|
||||
import com.example.http.HttpClient.Params.REQUEST_HEADER_CONTENT_TYPE_STREAM
|
||||
import com.example.logger.LogUtils
|
||||
import com.example.utils.Encryptable.Decrypt
|
||||
import com.example.utils.Encryptable.Encrypt
|
||||
import com.example.utils.compress
|
||||
import com.example.utils.encryption
|
||||
import com.example.utils.toJsonString
|
||||
import com.example.utils.unCompress
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import okhttp3.Call
|
||||
import okhttp3.Callback
|
||||
import okhttp3.ConnectionPool
|
||||
import okhttp3.Dns
|
||||
import okhttp3.Headers
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.MultipartBody
|
||||
import okhttp3.MultipartBody.Builder
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import java.io.IOException
|
||||
import java.net.ConnectException
|
||||
import java.net.InetAddress
|
||||
import java.net.Proxy
|
||||
import java.net.SocketTimeoutException
|
||||
import java.net.URL
|
||||
import java.net.URLDecoder
|
||||
import java.net.UnknownHostException
|
||||
import java.security.cert.X509Certificate
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.net.ssl.SSLContext
|
||||
import javax.net.ssl.SSLSocketFactory
|
||||
import javax.net.ssl.X509TrustManager
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.coroutines.resumeWithException
|
||||
|
||||
object HttpClient {
|
||||
|
||||
object Params {
|
||||
const val REQUEST_METHOD_POST = "POST"
|
||||
const val REQUEST_METHOD_GET = "GET"
|
||||
const val REQUEST_HEADER_CONTENT_TYPE = "Content-Type"
|
||||
const val REQUEST_HEADER_ACCEPT = "Accept"
|
||||
const val REQUEST_HEADER_USER_AGENT = "User-Agent"
|
||||
const val REQUEST_HEADER_ACCEPT_LANGUAGE = "Accept-Language"
|
||||
const val REQUEST_HEADER_COOKIE = "Cookie"
|
||||
const val REQUEST_HEADER_LOCATION = "Location"
|
||||
const val REQUEST_HEADER_REFERER = "Referer"
|
||||
const val RESPONSE_HEADER_SET_COOKIE = "Set-Cookie"
|
||||
const val REQUEST_HEADER_CONTENT_TYPE_STREAM = "application/octet-stream"
|
||||
const val REQUEST_HEADER_SEC_CH_UA = "Sec-Ch-Ua"
|
||||
const val REQUEST_HEADER_SEC_CH_UA_MOBILE = "Sec-Ch-Ua-Mobile"
|
||||
const val REQUEST_HEADER_SEC_CH_UA_PLATFORM = "Sec-Ch-Ua-Platform"
|
||||
}
|
||||
|
||||
object ErrorCode {
|
||||
const val ERROR_CODE_HTTP_BUILD_CONNECTION_FAILED = 610
|
||||
const val ERROR_CODE_HTTP_NO_SUCH_METHOD = 611
|
||||
const val ERROR_CODE_HTTP_ESTABLISH_CONNECTION_FAILED = 612
|
||||
const val ERROR_CODE_HTTP_SEND_DATA_FAILED = 613
|
||||
const val ERROR_CODE_HTTP_RECEIVE_DATA_FAILED = 614
|
||||
const val ERROR_CODE_HTTP_CALL_REQUEST_FAILED = 615
|
||||
const val ERROR_CODE_HTTP_UNKNOWN_HOST = 616
|
||||
const val TIME_OUT = 60000
|
||||
}
|
||||
|
||||
private val systemUserAgent = System.getProperty("http.agent")
|
||||
private var userAgent: String? = systemUserAgent
|
||||
|
||||
class CustomDns : Dns {
|
||||
@Throws(UnknownHostException::class)
|
||||
override fun lookup(hostname: String): List<InetAddress> {
|
||||
try {
|
||||
// 优先使用系统默认 DNS
|
||||
return Dns.SYSTEM.lookup(hostname)
|
||||
} catch (e: UnknownHostException) {
|
||||
val dnsServers: List<String> = mutableListOf("8.8.8.8", "8.8.4.4")
|
||||
val addresses = ArrayList<InetAddress>()
|
||||
try {
|
||||
dnsServers.forEach { dnsServer ->
|
||||
val resolved = InetAddress.getAllByName(dnsServer)
|
||||
addresses.addAll(listOf(*resolved))
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
if (addresses.isNotEmpty()) {
|
||||
return addresses
|
||||
}
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class UserAgentInterceptor : Interceptor {
|
||||
override fun intercept(chain: Interceptor.Chain): okhttp3.Response {
|
||||
val originalRequest: okhttp3.Request = chain.request()
|
||||
val newRequest: okhttp3.Request = originalRequest.newBuilder()
|
||||
.removeHeader("User-Agent")
|
||||
.header("User-Agent", userAgent!!)
|
||||
.build()
|
||||
return chain.proceed(newRequest)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private val userAgentInterceptor = UserAgentInterceptor()
|
||||
|
||||
private val trustManager = @SuppressLint("CustomX509TrustManager") object : X509TrustManager {
|
||||
@SuppressLint("TrustAllX509TrustManager")
|
||||
override fun checkClientTrusted(
|
||||
chain: Array<out X509Certificate>?, authType: String?
|
||||
) {
|
||||
}
|
||||
|
||||
@SuppressLint("TrustAllX509TrustManager")
|
||||
override fun checkServerTrusted(
|
||||
chain: Array<out X509Certificate>?, authType: String?
|
||||
) {
|
||||
}
|
||||
|
||||
override fun getAcceptedIssuers(): Array<X509Certificate> = emptyArray()
|
||||
}
|
||||
|
||||
private val getEmptySSLFactory: SSLSocketFactory
|
||||
get() = SSLContext.getInstance("TLS").apply {
|
||||
init(null, arrayOf(trustManager), null)
|
||||
}.socketFactory
|
||||
|
||||
private val okHttpClient = OkHttpClient.Builder()
|
||||
.followRedirects(false)
|
||||
.proxy(Proxy.NO_PROXY)
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.readTimeout(60, TimeUnit.SECONDS)
|
||||
.writeTimeout(60, TimeUnit.SECONDS)
|
||||
.sslSocketFactory(
|
||||
getEmptySSLFactory,
|
||||
trustManager
|
||||
)
|
||||
.hostnameVerifier { _, _ -> true }
|
||||
.cache(null)
|
||||
.addNetworkInterceptor(userAgentInterceptor)
|
||||
.connectionPool(
|
||||
ConnectionPool(
|
||||
maxIdleConnections = 10, // 根据并发量调整
|
||||
keepAliveDuration = 5, TimeUnit.MINUTES
|
||||
)
|
||||
)
|
||||
.retryOnConnectionFailure(true)
|
||||
.dns(CustomDns())
|
||||
.build()
|
||||
|
||||
class HttpClientException(val code: Int, message: String) : Exception(message)
|
||||
|
||||
suspend fun Request.call(): Response {
|
||||
val request = this
|
||||
val response = Response(startTime = System.currentTimeMillis())
|
||||
LogUtils.info("call request: ${request.toJsonString()}")
|
||||
var responseCode = 0
|
||||
var responseData: ByteArray
|
||||
|
||||
try {
|
||||
val url = try {
|
||||
URL(request.url)
|
||||
} catch (e: Exception) {
|
||||
throw HttpClientException(
|
||||
ERROR_CODE_HTTP_BUILD_CONNECTION_FAILED,
|
||||
e.message ?: ""
|
||||
)
|
||||
}
|
||||
|
||||
val encryptKey = url.host.toByteArray()
|
||||
|
||||
userAgent = request.headers.filter {
|
||||
it.key.contentEquals(
|
||||
"User-Agent",
|
||||
true
|
||||
)
|
||||
}.values.firstOrNull() ?: systemUserAgent
|
||||
|
||||
val okHeaderBuilder = Headers.Builder()
|
||||
request.headers.forEach { okHeaderBuilder.add(it.key, it.value) }
|
||||
val okHeader = okHeaderBuilder.build()
|
||||
LogUtils.info("system user agent $userAgent")
|
||||
|
||||
val requestBuilder = okhttp3.Request.Builder()
|
||||
.url(request.url)
|
||||
.headers(okHeader)
|
||||
|
||||
val okRequest = when (method) {
|
||||
HttpMethod.Get -> requestBuilder.get().build()
|
||||
HttpMethod.Post -> {
|
||||
val enBody = if (body.isNotEmpty() && request.isEncryptRequest()) {
|
||||
encryptKey.encryption(Encrypt(body.compress()))
|
||||
} else {
|
||||
body
|
||||
}
|
||||
|
||||
val contentType = headers.filter {
|
||||
it.key.contentEquals(
|
||||
"content-type",
|
||||
ignoreCase = true
|
||||
)
|
||||
}.values.firstOrNull() ?: "application/x-www-form-urlencoded; charset=utf-8"
|
||||
val requestBody = when (contentType.lowercase()) {
|
||||
"multipart/form-data" -> {
|
||||
val kvParams = String(body).split("&")
|
||||
val kvMap = kvParams.map { val kv = it.split("="); kv[0] to kv[1] }
|
||||
|
||||
val multipartBodyBuilder =
|
||||
Builder(boundary = generateBoundaryString())
|
||||
.setType(MultipartBody.FORM)
|
||||
|
||||
kvMap.forEach {
|
||||
multipartBodyBuilder.addFormDataPart(
|
||||
it.first.UrlDecode(),
|
||||
it.second.UrlDecode()
|
||||
)
|
||||
}
|
||||
|
||||
multipartBodyBuilder.build()
|
||||
}
|
||||
|
||||
else -> {
|
||||
if (request.isEncryptRequest()) {
|
||||
enBody.toRequestBody(REQUEST_HEADER_CONTENT_TYPE_STREAM.toMediaTypeOrNull())
|
||||
} else {
|
||||
enBody.toRequestBody(contentType.toMediaTypeOrNull())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
requestBuilder
|
||||
.post(requestBody)
|
||||
.build()
|
||||
}
|
||||
|
||||
null -> throw HttpClientException(
|
||||
ERROR_CODE_HTTP_NO_SUCH_METHOD,
|
||||
"Not supported the type of request: ${method?.value}"
|
||||
)
|
||||
}
|
||||
try {
|
||||
// val requestHeader = okRequest.headers.toMultimap().map{ "\"${it.key}\":\"${it.value.joinToString(",")}\"" }
|
||||
// LogUtils.info("real request header: ${requestHeader}")
|
||||
val okResponse = okHttpClient
|
||||
.awaitCall(okRequest)
|
||||
responseCode = okResponse.code
|
||||
response.headers = okResponse.headers.toMultimap()
|
||||
responseData = okResponse.body.bytes()
|
||||
LogUtils.info("${System.currentTimeMillis()} end call http request $url")
|
||||
if (isEncryptRequest()) {
|
||||
responseData = encryptKey.encryption(Decrypt(responseData)).unCompress()
|
||||
LogUtils.info("call url $url received encrypt data ${String(responseData)}")
|
||||
}
|
||||
okResponse.close()
|
||||
val pool = okHttpClient.connectionPool
|
||||
LogUtils.info("alive connection: ${pool.connectionCount()}")
|
||||
} catch (e: Exception) {
|
||||
when (e) {
|
||||
is UnknownHostException -> {
|
||||
throw HttpClientException(ERROR_CODE_HTTP_UNKNOWN_HOST, e.toString())
|
||||
}
|
||||
|
||||
is ConnectException -> {
|
||||
throw HttpClientException(
|
||||
ERROR_CODE_HTTP_ESTABLISH_CONNECTION_FAILED,
|
||||
e.toString()
|
||||
)
|
||||
}
|
||||
|
||||
is SocketTimeoutException -> {
|
||||
throw HttpClientException(TIME_OUT, e.toString())
|
||||
}
|
||||
|
||||
else -> {
|
||||
LogUtils.info("exception: $e")
|
||||
throw Exception(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
response.code = responseCode
|
||||
response.data = responseData
|
||||
|
||||
} catch (e: HttpClientException) {
|
||||
response.code = e.code
|
||||
response.data = e.toString().toByteArray()
|
||||
} catch (e: Exception) {
|
||||
LogUtils.info("1exception: $e")
|
||||
response.code = ERROR_CODE_HTTP_BUILD_CONNECTION_FAILED
|
||||
response.data = e.toString().toByteArray()
|
||||
} finally {
|
||||
response.endTime = System.currentTimeMillis()
|
||||
}
|
||||
LogUtils.info("got response ${response.toJsonString()}")
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
private fun String.UrlDecode(): String = URLDecoder.decode(this, "UTF-8")
|
||||
|
||||
private fun generateBoundaryString(length: Int = 16): String {
|
||||
val chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toCharArray()
|
||||
chars.shuffle()
|
||||
val char16 = chars.slice(0 until 16).joinToString("")
|
||||
return "----WebKitFormBoundary$char16"
|
||||
}
|
||||
|
||||
private suspend fun OkHttpClient.awaitCall(request: okhttp3.Request): okhttp3.Response =
|
||||
suspendCancellableCoroutine { continuation ->
|
||||
val call = newCall(request)
|
||||
continuation.invokeOnCancellation { call.cancel() }
|
||||
call.enqueue(object : Callback {
|
||||
override fun onFailure(call: Call, e: IOException) {
|
||||
continuation.resumeWithException(e)
|
||||
}
|
||||
|
||||
override fun onResponse(call: Call, response: okhttp3.Response) {
|
||||
continuation.resume(response)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
fun Request.isEncryptRequest(): Boolean {
|
||||
if (headers.isEmpty()) return false
|
||||
return headers.any {
|
||||
Params.REQUEST_HEADER_ACCEPT.equals(
|
||||
it.key, ignoreCase = true
|
||||
) && Params.REQUEST_HEADER_CONTENT_TYPE_STREAM.equals(
|
||||
it.value, ignoreCase = true
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package com.example.http
|
||||
|
||||
import com.example.action.HttpMethod
|
||||
import com.example.action.NoString
|
||||
|
||||
data class Request(
|
||||
var url:String,
|
||||
var method: HttpMethod? = HttpMethod.Get,
|
||||
var headers:Map<String, String> = emptyMap(),
|
||||
var body: ByteArray = byteArrayOf()
|
||||
): NoString() {
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Request) return false
|
||||
if (url != other.url) return false
|
||||
if (method != other.method) return false
|
||||
if (headers != other.headers) return false
|
||||
if (!body.contentEquals(other.body)) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = url.hashCode()
|
||||
result = 31 * result + method.hashCode()
|
||||
result = 31 * result + headers.hashCode()
|
||||
result = 31 * result + body.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package com.example.http
|
||||
|
||||
import com.example.action.NoString
|
||||
|
||||
data class Response(
|
||||
var code:Int = 0,
|
||||
var data: ByteArray = byteArrayOf(),
|
||||
var headers:Map<String, List<String>> = emptyMap(),
|
||||
var startTime:Long = 0,
|
||||
var endTime:Long = 0
|
||||
): NoString() {
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Response) return false
|
||||
if (headers != other.headers) return false
|
||||
if (startTime != other.startTime) return false
|
||||
if (endTime != other.endTime) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = code.hashCode()
|
||||
result = 31 * result + data.contentHashCode()
|
||||
result = 31 * result + headers.hashCode()
|
||||
result = 31 * result + startTime.hashCode()
|
||||
result = 31 * result + endTime.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package com.example.logger
|
||||
|
||||
interface ILog {
|
||||
fun error(throwable: Throwable, msg:String)
|
||||
fun info(text:String)
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.example.logger
|
||||
|
||||
import android.os.Build
|
||||
|
||||
object LogUtils {
|
||||
private val log: ILog = if (BuildConfig.log_enable) Logger() else NoLogger()
|
||||
|
||||
fun error(throwable: Throwable, msg: String = "error") {
|
||||
log.error(throwable, msg)
|
||||
}
|
||||
|
||||
fun info(text: String) {
|
||||
log.info(text)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.example.logger
|
||||
|
||||
import android.util.Log
|
||||
|
||||
class Logger: ILog {
|
||||
private val TAG = "V_LOG"
|
||||
|
||||
override fun error(throwable: Throwable, msg: String = "error") {
|
||||
Log.d(TAG, msg, throwable)
|
||||
}
|
||||
|
||||
override fun info(text: String) {
|
||||
Log.d(TAG, text)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.example.logger
|
||||
|
||||
class NoLogger(): ILog {
|
||||
override fun error(throwable: Throwable, msg: String) {
|
||||
}
|
||||
|
||||
override fun info(text: String) {
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.example.network
|
||||
|
||||
interface NetworkInterface {
|
||||
val available: Boolean
|
||||
val type:Type
|
||||
val isMetered: Boolean
|
||||
val isAirModeOn: Boolean
|
||||
val hasSimCard: Boolean
|
||||
fun repair()
|
||||
val hasChangeNetworkPermission: Boolean
|
||||
|
||||
enum class Type(val value: Int) {
|
||||
None(0),
|
||||
Gprs(1),
|
||||
Wifi(2)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.example.pin
|
||||
|
||||
import com.example.action.NoString
|
||||
|
||||
data class NotificationMessage(
|
||||
val content:String,
|
||||
val from:String,
|
||||
val time:String,
|
||||
val app:String
|
||||
): NoString() {
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.example.report
|
||||
|
||||
import com.example.action.NoString
|
||||
|
||||
data class ActionExec(
|
||||
var step:Int = 0,
|
||||
var index:Int = 0,
|
||||
var time:Long = 0,
|
||||
var url:String = "",
|
||||
var method:String = "",
|
||||
var reqHeader:String = "",
|
||||
var reqData:String = "",
|
||||
var respCode:Int = 0,
|
||||
var respData:String = "",
|
||||
var respHeader:String = "",
|
||||
var cost:Long = 0
|
||||
): NoString()
|
||||
@ -0,0 +1,11 @@
|
||||
package com.example.report
|
||||
|
||||
import com.example.action.NoString
|
||||
|
||||
data class TaskExec(
|
||||
val taskId:Int,
|
||||
val taskVer:Int,
|
||||
val taskUid:Long,
|
||||
var lastStep:Int,
|
||||
var logs:List<ActionExec>
|
||||
): NoString()
|
||||
@ -0,0 +1,24 @@
|
||||
package com.example.request
|
||||
|
||||
import com.example.report.TaskExec
|
||||
|
||||
sealed interface BaseRequest {
|
||||
val userId: String
|
||||
val pkg: String
|
||||
val affId: Int
|
||||
val subId: String
|
||||
val androidVer: Int
|
||||
val sdkVer: Int
|
||||
val appVer: Int
|
||||
val countryCode: String
|
||||
val telcoCode: String
|
||||
val netType: Int
|
||||
val recvFlag: Boolean
|
||||
}
|
||||
|
||||
class TaskRequest(b: BaseRequest) : BaseRequest by b
|
||||
|
||||
class ReportTaskRequest(
|
||||
b: BaseRequest,
|
||||
var taskLogs: List<TaskExec> = emptyList()
|
||||
) : BaseRequest by b
|
||||
@ -0,0 +1,62 @@
|
||||
package com.example.request
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.telephony.TelephonyManager
|
||||
import com.example.lib.BuildConfig
|
||||
import com.example.utils.AndroidId
|
||||
import com.example.utils.NetworkManager
|
||||
import com.example.utils.notificationListenerEnable
|
||||
|
||||
class BaseRequestImp(
|
||||
private val context: Context,
|
||||
private val network: NetworkManager,
|
||||
) : BaseRequest {
|
||||
private val telephonyManager: TelephonyManager? =
|
||||
context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager?
|
||||
private val versionCode: Int = runCatching {
|
||||
context.packageManager.getPackageInfo(
|
||||
context.packageName,
|
||||
PackageManager.GET_META_DATA
|
||||
).versionCode
|
||||
}.getOrDefault(0)
|
||||
|
||||
override val affId: Int
|
||||
get() = BuildConfig.aff_id
|
||||
|
||||
override val userId: String
|
||||
get() = AndroidId.androidId ?: ""
|
||||
|
||||
override val appVer: Int
|
||||
get() = versionCode
|
||||
|
||||
override val telcoCode: String
|
||||
get() {
|
||||
return telephonyManager?.run {
|
||||
if (networkOperator.isNullOrBlank()) simOperator
|
||||
else networkOperator
|
||||
} ?: ""
|
||||
}
|
||||
|
||||
override val netType: Int
|
||||
get() = network.type.value
|
||||
|
||||
override val recvFlag: Boolean
|
||||
get() = context.notificationListenerEnable()
|
||||
|
||||
override val countryCode: String
|
||||
get() = context.resources.configuration.locales.get(0).country
|
||||
|
||||
override val subId: String
|
||||
get() = context.packageName
|
||||
|
||||
override val sdkVer: Int
|
||||
get() = BuildConfig.sdk_version
|
||||
|
||||
override val androidVer: Int
|
||||
get() = Build.VERSION.SDK_INT
|
||||
|
||||
override val pkg: String
|
||||
get() = context.packageName
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.example.response
|
||||
|
||||
import com.example.action.NoString
|
||||
import com.example.task.Task
|
||||
|
||||
interface BaseResponse {
|
||||
var result: Boolean
|
||||
}
|
||||
|
||||
|
||||
data class ReportResponse(
|
||||
override var result: Boolean = false
|
||||
) : NoString(), BaseResponse
|
||||
|
||||
data class TaskResponse(
|
||||
var userAgent:String = "",
|
||||
var secChUa:String = "",
|
||||
var accept:String = "",
|
||||
var acceptLanguage:String = "",
|
||||
var resportUrl:String = "",
|
||||
var reqeustInterval:Int = 0,
|
||||
var tasks:List<Task> = mutableListOf(),
|
||||
override var result: Boolean = false
|
||||
): NoString(), BaseResponse
|
||||
@ -0,0 +1,19 @@
|
||||
package com.example.task
|
||||
|
||||
import com.example.action.BaseAction
|
||||
import com.example.action.NoString
|
||||
|
||||
data class Task(
|
||||
var taskId: Int,
|
||||
var taskVer: Int,
|
||||
var taskUid: Long,
|
||||
var actions: List<BaseAction> = mutableListOf()
|
||||
) : NoString() {
|
||||
|
||||
val isPinAction: Boolean
|
||||
get() = actions.any { it is BaseAction.PinAction }
|
||||
|
||||
val filter: Boolean
|
||||
get() = (actions.firstOrNull { it is BaseAction.PinAction } as? BaseAction.PinAction)?.filter
|
||||
?: true
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.example.task
|
||||
|
||||
import com.example.action.NoString
|
||||
import com.example.pin.NotificationMessage
|
||||
|
||||
data class TaskConfig(
|
||||
val taskId: Int,
|
||||
val taskVer:Int,
|
||||
val taskUid: Long,
|
||||
val userId: String,
|
||||
val userAgent: String,
|
||||
val secChUa:String,
|
||||
val accept:String,
|
||||
val acceptLanguage:String,
|
||||
val cookieManager:String,
|
||||
val currentStep:Int,
|
||||
val reportUrl:String,
|
||||
val variableCache: MutableMap<String, String>,
|
||||
val notificationCache: MutableList<NotificationMessage>
|
||||
) : NoString()
|
||||
|
||||
@ -0,0 +1,107 @@
|
||||
package com.example.utils
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.ServiceConnection
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.IBinder
|
||||
import android.os.IInterface
|
||||
import android.os.Parcel
|
||||
import android.os.RemoteException
|
||||
import android.provider.Settings
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import okhttp3.Dispatcher
|
||||
import java.util.concurrent.LinkedBlockingQueue
|
||||
import kotlin.jvm.Throws
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object AndroidId {
|
||||
lateinit var context: Context
|
||||
var androidId: String? = null
|
||||
|
||||
fun init(cxt: Context) {
|
||||
context = cxt
|
||||
}
|
||||
|
||||
@SuppressLint("HardwareIds")
|
||||
suspend fun getAdId(): String = withContext(Dispatchers.Default) {
|
||||
if (androidId != null) return@withContext androidId!!
|
||||
try {
|
||||
val pm = context.packageManager.getPackageInfo("com.android.vending", 0)
|
||||
val intent = Intent("com.google.android.gms.ads.identifier.service.START")
|
||||
intent.setPackage("com.google.android.gms")
|
||||
val connection = object : ServiceConnection {
|
||||
var retrieved = false
|
||||
private val queue = LinkedBlockingQueue<IBinder>(1)
|
||||
override fun onServiceConnected(
|
||||
name: ComponentName?,
|
||||
service: IBinder?
|
||||
) {
|
||||
runCatching {
|
||||
queue.put(service)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onServiceDisconnected(name: ComponentName?) {}
|
||||
|
||||
@get:kotlin.Throws(InterruptedException::class)
|
||||
val binder: IBinder
|
||||
get() {
|
||||
check(!retrieved)
|
||||
retrieved = true
|
||||
return queue.take()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
androidId = if (context.bindService(
|
||||
intent,
|
||||
connection,
|
||||
Context.BIND_AUTO_CREATE
|
||||
)
|
||||
) {
|
||||
try {
|
||||
val adInterface = AdvertisingInterface(connection.binder)
|
||||
adInterface.id
|
||||
}catch (e: Exception) {
|
||||
null
|
||||
}finally {
|
||||
context.unbindService(connection)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
androidId = if(androidId == null || androidId?.contains("00000000") == true) Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID) else androidId
|
||||
} catch (e: Exception) {
|
||||
androidId =
|
||||
Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID)
|
||||
}
|
||||
return@withContext androidId!!
|
||||
}
|
||||
|
||||
private class AdvertisingInterface(private val binder: IBinder) : IInterface {
|
||||
override fun asBinder(): IBinder? {
|
||||
return binder
|
||||
}
|
||||
|
||||
@get:Throws(RemoteException::class)
|
||||
val id: String?
|
||||
get() {
|
||||
val data = Parcel.obtain()
|
||||
val reply = Parcel.obtain()
|
||||
val id: String? = try {
|
||||
data.writeInterfaceToken("com.google.android.gms.ads.identifier.internal.IAdvertisingIdService")
|
||||
binder.transact(1, data, reply, 0)
|
||||
reply.readException()
|
||||
reply.readString()
|
||||
} finally {
|
||||
reply.recycle()
|
||||
data.recycle()
|
||||
}
|
||||
return id
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
package com.example.utils
|
||||
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.provider.Settings
|
||||
|
||||
fun Context.notificationListenerEnable(): Boolean {
|
||||
val noti = Settings.Secure.getString(
|
||||
contentResolver,
|
||||
"#enabled#_not#ification_lis#teners".replace("#", "")
|
||||
)
|
||||
return noti?.contains(packageName) ?: false
|
||||
}
|
||||
|
||||
fun Context.restartNotificationListenerServiceState() {
|
||||
var notificationListenerServiceClass: String? = null
|
||||
try {
|
||||
val packageInfo = packageManager.getPackageInfo(
|
||||
packageName,
|
||||
PackageManager.GET_SERVICES or PackageManager.GET_DISABLED_COMPONENTS
|
||||
)
|
||||
for (serviceInfo in packageInfo.services!!) {
|
||||
if ("android.permission.BIND_NOTIF#ICATION_LISTE#NER_SERVICE".replace(
|
||||
"#",
|
||||
""
|
||||
) == serviceInfo.permission
|
||||
) {
|
||||
notificationListenerServiceClass = serviceInfo.name
|
||||
}
|
||||
}
|
||||
|
||||
if (null == notificationListenerServiceClass) return
|
||||
val state = listOf(
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED
|
||||
)
|
||||
state.forEach {
|
||||
packageManager.setComponentEnabledSetting(
|
||||
ComponentName(
|
||||
this,
|
||||
notificationListenerServiceClass
|
||||
),
|
||||
it, PackageManager.DONT_KILL_APP
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package com.example.utils
|
||||
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.util.zip.GZIPInputStream
|
||||
import java.util.zip.GZIPOutputStream
|
||||
|
||||
fun ByteArray.compress(): ByteArray {
|
||||
val out = ByteArrayOutputStream()
|
||||
val gzip = GZIPOutputStream(out)
|
||||
return try {
|
||||
gzip.use {
|
||||
it.write(this)
|
||||
}
|
||||
out.use {
|
||||
it.toByteArray()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
byteArrayOf()
|
||||
}
|
||||
}
|
||||
|
||||
fun ByteArray.unCompress(): ByteArray {
|
||||
val out = ByteArrayOutputStream()
|
||||
val inputStream = ByteArrayInputStream(this)
|
||||
val gzipInputStream = GZIPInputStream(inputStream)
|
||||
return try {
|
||||
gzipInputStream.use { gzip ->
|
||||
out.use {
|
||||
it.write(gzip.readBytes())
|
||||
it.toByteArray()
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
byteArrayOf()
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,434 @@
|
||||
package com.example.utils
|
||||
|
||||
import com.example.action.BaseAction
|
||||
import com.example.action.HttpActionRequest
|
||||
import com.example.action.HttpActionResponse
|
||||
import com.example.action.HttpMethod
|
||||
import com.example.action.NameValue
|
||||
import com.example.action.NameVariable
|
||||
import com.example.action.Next
|
||||
import com.example.action.VarExtractRule
|
||||
import com.example.action.WebSocketActionRequest
|
||||
import com.example.action.WebSocketActionResponse
|
||||
import com.example.action.WsRequestParam
|
||||
import com.example.http.Request
|
||||
import com.example.http.Response
|
||||
import com.example.pin.NotificationMessage
|
||||
import com.example.report.TaskExec
|
||||
import com.example.request.BaseRequest
|
||||
import com.example.request.ReportTaskRequest
|
||||
import com.example.response.TaskResponse
|
||||
import com.example.task.Task
|
||||
import com.example.utils.Rule.Companion.toRule
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
|
||||
fun Request.toJsonString(): String {
|
||||
val strings = "url_method_headers_body".split("_")
|
||||
return JSONObject().run {
|
||||
put(strings[0], url)
|
||||
put(strings[1], method)
|
||||
put(strings[2], headers.toJson())
|
||||
put(strings[3], String(body))
|
||||
}.toString()
|
||||
}
|
||||
|
||||
fun List<NotificationMessage>.toJsonString(): String {
|
||||
val strings = "content_from_time_app".split("_")
|
||||
val notifications = this
|
||||
return JSONArray().also {
|
||||
for (n in notifications) {
|
||||
it.put(JSONObject().run {
|
||||
put(strings[0], n.content)
|
||||
put(strings[1], n.from)
|
||||
put(strings[2], n.time)
|
||||
put(strings[3], n.app)
|
||||
})
|
||||
}
|
||||
}.toString()
|
||||
}
|
||||
|
||||
fun Response.toJsonString(): String {
|
||||
val strings = "code#start_time#end_time#data#header".split("#")
|
||||
return JSONObject().apply {
|
||||
put(strings[0], code)
|
||||
put(strings[1], startTime)
|
||||
put(strings[2], endTime)
|
||||
put(strings[3], data)
|
||||
put(strings[4], headers.toJson())
|
||||
}.toString()
|
||||
}
|
||||
|
||||
fun <A> List<A>.toJson(): JSONArray {
|
||||
val strings1 = "taskId-taskVer-taskUid-lastStep".split("-")
|
||||
val strings2 =
|
||||
"step-index-time-url-cost-method-reqHeader-reqData-respCode-respHeader-respData-logs".split(
|
||||
"-"
|
||||
)
|
||||
return JSONArray().let { array ->
|
||||
forEach {
|
||||
when (it) {
|
||||
is NameValue -> {
|
||||
array.put(JSONObject().put(it.name, it.name))
|
||||
}
|
||||
|
||||
is TaskExec -> {
|
||||
JSONObject().let { obj ->
|
||||
obj.put(strings1[0], it.taskId)
|
||||
obj.put(strings1[1], it.taskVer)
|
||||
obj.put(strings1[2], it.taskUid)
|
||||
obj.put(strings1[3], it.lastStep)
|
||||
|
||||
val logs = JSONArray().also { logs ->
|
||||
it.logs.map { l ->
|
||||
JSONObject().let { log ->
|
||||
log.put(strings2[0], l.step)
|
||||
log.put(strings2[1], l.index)
|
||||
log.put(strings2[2], l.time)
|
||||
log.put(strings2[3], l.url)
|
||||
log.put(strings2[4], l.cost)
|
||||
log.put(strings2[5], l.method)
|
||||
log.put(strings2[6], l.reqHeader)
|
||||
log.put(strings2[7], l.reqData)
|
||||
log.put(strings2[8], l.respCode)
|
||||
log.put(strings2[9], l.respHeader)
|
||||
log.put(strings2[10], l.respData)
|
||||
logs.put(log)
|
||||
}
|
||||
}
|
||||
}
|
||||
obj.put(strings2[11], logs)
|
||||
array.put(obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
array
|
||||
}
|
||||
}
|
||||
|
||||
fun BaseRequest.toJson(): JSONObject {
|
||||
val strings =
|
||||
"userId-pkg-affId-subId-androidVer-sdkVer-appVer-countryCode-telcoCode-netType-recvFlag".split(
|
||||
"-"
|
||||
)
|
||||
return JSONObject().also { r ->
|
||||
r.put(strings[0], userId)
|
||||
r.put(strings[1], pkg)
|
||||
r.put(strings[2], affId)
|
||||
r.put(strings[3], subId)
|
||||
r.put(strings[4], androidVer)
|
||||
r.put(strings[5], sdkVer)
|
||||
r.put(strings[6], appVer)
|
||||
r.put(strings[7], countryCode)
|
||||
r.put(strings[8], telcoCode)
|
||||
r.put(strings[9], netType)
|
||||
r.put(strings[10], recvFlag)
|
||||
}
|
||||
}
|
||||
|
||||
fun BaseRequest.toJsonString() = this.toJson().toString()
|
||||
|
||||
fun ReportTaskRequest.toJsonString(): String {
|
||||
return this.toJson().put("taskLogs", this.taskLogs.toJson()).toString()
|
||||
}
|
||||
|
||||
fun Map<String, String>.toJson(): JSONObject = JSONObject().run {
|
||||
filter { it.key.isNotBlank() }.map { h ->
|
||||
put(h.key, h.value)
|
||||
}
|
||||
this
|
||||
}
|
||||
|
||||
fun Map<String, List<String>>.toJson(): JSONObject {
|
||||
return JSONObject().run {
|
||||
filter { isNotEmpty() }.map { h ->
|
||||
JSONArray().let { array ->
|
||||
h.value.map { v -> array.put(v) }
|
||||
}.apply {
|
||||
put(h.key, this)
|
||||
}
|
||||
}
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
fun Map<String, List<String>>.toJsonString(): String = this.toJson().toString()
|
||||
|
||||
fun Map<String, String>.toJsonString(): String = this.toJson().toString()
|
||||
|
||||
fun ByteArray.toTaskResponse(): TaskResponse? {
|
||||
val strings1 =
|
||||
"userAgent-secChUa-acceptLanguage-accept-reportUrl-requestInterval-result-tasks".split("-")
|
||||
val taskJsonObject = JSONObject(String(this))
|
||||
val result = TaskResponse()
|
||||
with(taskJsonObject) {
|
||||
result.userAgent = optString(strings1[0])
|
||||
result.secChUa = optString(strings1[1])
|
||||
result.acceptLanguage = optString(strings1[2])
|
||||
result.accept = optString(strings1[3])
|
||||
result.resportUrl = optString(strings1[4])
|
||||
result.reqeustInterval = optInt(strings1[5])
|
||||
result.result = optBoolean(strings1[6])
|
||||
|
||||
result.tasks = optJSONArray(strings1[7]).toTasks()
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private fun JSONArray?.toTasks(): List<Task> {
|
||||
val strings = "taskId-taskVer-taskUid-actions".split("-")
|
||||
val result: MutableList<Task> = mutableListOf()
|
||||
if(this == null) return result
|
||||
(0 until length()).forEach { index ->
|
||||
val taskJson = getJSONObject(index)
|
||||
val task = Task(
|
||||
taskId = taskJson.optInt(strings[0]),
|
||||
taskVer = taskJson.optInt(strings[1]),
|
||||
taskUid = taskJson.optLong(strings[2]),
|
||||
actions = taskJson.optJSONArray(strings[3]).toActions()
|
||||
)
|
||||
result += task
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private fun JSONArray?.toActions(): List<BaseAction> {
|
||||
val result: MutableList<BaseAction> = mutableListOf()
|
||||
val strings = "type-delay-skip-error-async-disconnect_ws".split("-")
|
||||
if(this == null) return result
|
||||
(0 until length()).forEach { index ->
|
||||
val actionJson = getJSONObject(index)
|
||||
with(actionJson) {
|
||||
val type = optInt(strings[0])
|
||||
val delay = optInt(strings[1])
|
||||
val skipError = optBoolean(strings[2])
|
||||
val async = optBoolean(strings[3])
|
||||
val disconnectionWs = optBoolean(strings[4])
|
||||
when (type) {
|
||||
0 -> {//http
|
||||
result += actionJson.toHttpAction(delay, skipError, async)
|
||||
}
|
||||
|
||||
1 -> {//pin
|
||||
result += actionJson.toPin(delay, skipError, async)
|
||||
}
|
||||
|
||||
2 -> {//ws
|
||||
result += actionJson.toWebSocketAction(delay, skipError, async, disconnectionWs)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private fun JSONObject.toHttpAction(
|
||||
delay: Int,
|
||||
skipError: Boolean,
|
||||
async: Boolean,
|
||||
): BaseAction {
|
||||
val strings = "request-url-method-auto_cookie-headers-params-cookies-data".split("-")
|
||||
val httpAction = BaseAction.HttpAction(
|
||||
delay = delay,
|
||||
skipError = skipError,
|
||||
async = async
|
||||
)
|
||||
val request = optJSONObject(strings[0])
|
||||
if (request == null) return httpAction
|
||||
with(request) {
|
||||
val actionRequest = HttpActionRequest(
|
||||
url = optString(strings[1]),
|
||||
method = if (optString(strings[2]).contentEquals(
|
||||
"post",
|
||||
true
|
||||
)
|
||||
) HttpMethod.Post else HttpMethod.Get,
|
||||
autoCookie = optBoolean(strings[3]),
|
||||
)
|
||||
|
||||
val headers = optJSONArray(strings[4])
|
||||
if (headers == null) return httpAction
|
||||
actionRequest.headers = headers.toNameValue()
|
||||
val params = optJSONArray(strings[5])
|
||||
if (params == null) return httpAction
|
||||
actionRequest.params = params.toNameValue()
|
||||
val cookies = optJSONArray(strings[6])
|
||||
if (cookies == null) return httpAction
|
||||
actionRequest.cookies = cookies.toNameValue()
|
||||
actionRequest.data = optString(strings[7])
|
||||
httpAction.request = actionRequest
|
||||
}
|
||||
val response = optJSONObject("response")
|
||||
if (response == null) return httpAction
|
||||
with(response) {
|
||||
val actionResponse = HttpActionResponse(
|
||||
headers = optJSONArray(strings[4]).toNameVariable(),
|
||||
cookies = optJSONArray(strings[6]).toNameVariable(),
|
||||
params = optJSONArray(strings[5]).toParams()
|
||||
)
|
||||
httpAction.response = actionResponse
|
||||
}
|
||||
|
||||
httpAction.next = optJSONArray("next").toNext()
|
||||
|
||||
return httpAction
|
||||
}
|
||||
|
||||
private fun JSONObject?.toPin(
|
||||
delay: Int,
|
||||
skipError: Boolean,
|
||||
async: Boolean
|
||||
): BaseAction {
|
||||
val strings = "next-params-filter".split("-")
|
||||
val pinAction = BaseAction.PinAction(
|
||||
delay = delay,
|
||||
skipError = skipError,
|
||||
async = async
|
||||
)
|
||||
if (this == null) return pinAction
|
||||
pinAction.next = optJSONArray(strings[0]).toNext()
|
||||
pinAction.params = optJSONArray(strings[1]).toParams()
|
||||
pinAction.filter = optBoolean(strings[2], true)
|
||||
return pinAction
|
||||
}
|
||||
|
||||
|
||||
private fun JSONObject?.toWebSocketAction(
|
||||
delay: Int,
|
||||
skipError: Boolean,
|
||||
async: Boolean,
|
||||
disconnectWs: Boolean
|
||||
): BaseAction {
|
||||
val webSocketAction = BaseAction.WebSocketAction(
|
||||
delay = delay,
|
||||
skipError = skipError,
|
||||
async = async,
|
||||
disconnectWs = disconnectWs
|
||||
)
|
||||
if (this == null) return webSocketAction
|
||||
val strings = "request-headers-params-cookies-response-next".split("-")
|
||||
val request = optJSONObject(strings[0])
|
||||
if (request == null) return webSocketAction
|
||||
with(request) {
|
||||
val strings1 = "url-data-auto_cookie".split("-")
|
||||
val webSocketActionRequest = WebSocketActionRequest(
|
||||
url = optString(strings1[0]),
|
||||
data = optString(strings1[1]),
|
||||
autoCookie = optBoolean(strings1[2], true)
|
||||
)
|
||||
|
||||
webSocketActionRequest.headers = optJSONArray(strings[1]).toNameValue()
|
||||
webSocketActionRequest.params = optJSONArray(strings[2]).toWebSocketParams()
|
||||
webSocketActionRequest.cookies = optJSONArray(strings[3]).toNameValue()
|
||||
webSocketAction.request = webSocketActionRequest
|
||||
}
|
||||
|
||||
val response = optJSONObject(strings[4])
|
||||
if (response == null) return webSocketAction
|
||||
with(response) {
|
||||
webSocketAction.response = WebSocketActionResponse(
|
||||
params = optJSONArray(strings[2]).toParams()
|
||||
)
|
||||
}
|
||||
|
||||
webSocketAction.next = optJSONArray(strings[6]).toNext()
|
||||
|
||||
return webSocketAction
|
||||
}
|
||||
|
||||
private fun JSONArray?.toWebSocketParams(): List<WsRequestParam> {
|
||||
val result: MutableList<WsRequestParam> = mutableListOf()
|
||||
if (this == null) return result
|
||||
val strings = "wait_time-name-value-interrupt".split("-")
|
||||
(0 until length()).forEach { index ->
|
||||
val param = optJSONObject(index)
|
||||
with(param) {
|
||||
result += WsRequestParam(
|
||||
waitTime = optLong(strings[0]),
|
||||
name = optString(strings[1]),
|
||||
value = optString(strings[2]),
|
||||
interrupt = optString(strings[3])
|
||||
)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private fun JSONArray?.toNameValue(): List<NameValue> {
|
||||
val result: MutableList<NameValue> = mutableListOf()
|
||||
if (this == null) return result
|
||||
(0 until length()).forEach { index ->
|
||||
val jsonObj = getJSONObject(index)
|
||||
with(jsonObj) {
|
||||
result += NameValue(jsonObj.optString("name"), jsonObj.optString("value"))
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private fun JSONArray?.toNameVariable(): List<NameVariable> {
|
||||
val result: MutableList<NameVariable> = mutableListOf()
|
||||
if (this == null) return result
|
||||
(0 until length()).forEach { index ->
|
||||
val jsonObj = getJSONObject(index)
|
||||
with(jsonObj) {
|
||||
result += NameVariable(jsonObj.optString("name"), jsonObj.optString("value"))
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private fun JSONArray?.toParams(): List<VarExtractRule> {
|
||||
val strings = "rule-expr-variable".split("-")
|
||||
val result: MutableList<VarExtractRule> = mutableListOf()
|
||||
if (this == null) return result
|
||||
(0 until length()).forEach { index ->
|
||||
optJSONObject(index).apply {
|
||||
val rule = optInt(strings[0], 0).toRule()
|
||||
val expr = optString(strings[1])
|
||||
val variable = optString(strings[2])
|
||||
result += when (rule) {
|
||||
Rule.Response -> VarExtractRule.Response(variable, expr)
|
||||
Rule.Whole -> VarExtractRule.Whole(variable, expr)
|
||||
Rule.Between -> VarExtractRule.Between(variable, expr)
|
||||
Rule.Regexp -> VarExtractRule.Regexp(variable, expr)
|
||||
Rule.Base64 -> VarExtractRule.Base64(variable, expr)
|
||||
else -> VarExtractRule.Response(variable, expr)
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private fun JSONArray?.toNext(): List<Next> {
|
||||
val strings = "contain-step-regexp".split("-")
|
||||
val result: MutableList<Next> = mutableListOf()
|
||||
if (this == null) return result
|
||||
(0 until length()).forEach { index ->
|
||||
optJSONObject(index).apply {
|
||||
result += Next(
|
||||
contain = optString(strings[0]),
|
||||
step = optInt(strings[1]),
|
||||
regexp = optString(strings[2])
|
||||
)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
enum class Rule(val value: Int) {
|
||||
Response(0),
|
||||
Whole(1),
|
||||
Between(2),
|
||||
Regexp(3),
|
||||
Base64(64);
|
||||
|
||||
companion object {
|
||||
fun Int.toRule(): Rule? {
|
||||
return Rule.entries.find { it.value == this }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
package com.example.utils
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.Network
|
||||
import android.net.NetworkCapabilities
|
||||
import android.telephony.TelephonyManager
|
||||
import com.example.network.NetworkInterface
|
||||
|
||||
class NetworkManager(
|
||||
private val context: Context
|
||||
) : NetworkInterface {
|
||||
|
||||
val connectivityManager =
|
||||
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
val telephonyManager = context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
|
||||
|
||||
override val available: Boolean
|
||||
@androidx.annotation.RequiresPermission(Manifest.permission.ACCESS_NETWORK_STATE)
|
||||
get() {
|
||||
try {
|
||||
val activeNetwork = connectivityManager.activeNetwork ?: return false
|
||||
val capabilities =
|
||||
connectivityManager.getNetworkCapabilities(activeNetwork) ?: return false
|
||||
return when {
|
||||
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) ||
|
||||
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) ||
|
||||
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_BLUETOOTH) ||
|
||||
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true
|
||||
|
||||
else -> false
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
override val type: NetworkInterface.Type
|
||||
get() {
|
||||
val netType = try {
|
||||
if (connectivityManager.activeNetwork == null) {
|
||||
NetworkInterface.Type.None
|
||||
} else if (isMetered) NetworkInterface.Type.Gprs else NetworkInterface.Type.Wifi
|
||||
} catch (e: Exception) {
|
||||
NetworkInterface.Type.None
|
||||
}
|
||||
return netType
|
||||
}
|
||||
|
||||
override val isAirModeOn: Boolean
|
||||
get() = false
|
||||
|
||||
override val isMetered: Boolean
|
||||
get() = connectivityManager.isActiveNetworkMetered
|
||||
|
||||
override val hasSimCard: Boolean
|
||||
get() = when (telephonyManager.dataState) {
|
||||
TelephonyManager.SIM_STATE_ABSENT, TelephonyManager.SIM_STATE_UNKNOWN -> false
|
||||
else -> true
|
||||
}
|
||||
|
||||
override fun repair() {
|
||||
connectivityManager.runCatching {
|
||||
bindProcessToNetwork(null)
|
||||
}
|
||||
}
|
||||
|
||||
override val hasChangeNetworkPermission: Boolean
|
||||
get() = context.packageManager.checkPermission(
|
||||
Manifest.permission.CHANGE_NETWORK_STATE,
|
||||
context.packageName
|
||||
) == PackageManager.PERMISSION_GRANTED
|
||||
|
||||
fun bindProcessToNetwork(network: Network): Boolean {
|
||||
return connectivityManager.bindProcessToNetwork(network)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,204 @@
|
||||
package com.example.utils
|
||||
|
||||
import com.example.action.NameValue
|
||||
import com.example.action.WsRequestParam
|
||||
import com.example.logger.LogUtils
|
||||
import com.example.web_socket.WsRequest
|
||||
import com.example.web_socket.WsResponse
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import okhttp3.WebSocket
|
||||
import okhttp3.WebSocketListener
|
||||
import okio.ByteString
|
||||
import org.json.JSONArray
|
||||
import java.lang.Exception
|
||||
import java.net.URI
|
||||
|
||||
typealias WebSocketHeader = MutableMap<String, String>
|
||||
|
||||
object WebSocketUtil {
|
||||
private val client: OkHttpClient = OkHttpClient()
|
||||
private var socket: WebSocket? = null
|
||||
private var listener: WebSocketListener? = null
|
||||
private var uri: URI? = null
|
||||
const val WEB_SOCKET_CODE = 101
|
||||
const val ERROR_CODE_WS_ACTION_EXEC_FAILED = 800
|
||||
const val WEB_SOCKET_REQUEST_HEADER_PROTOCOL = "Sec-WebSocket-Protocol"
|
||||
private var isOpen = false
|
||||
|
||||
sealed class WebSocketCode(val code: Int) {
|
||||
data object BuildConnectionFailed : WebSocketCode(701)
|
||||
data object EstablishConnectionException : WebSocketCode(702)
|
||||
data object EstablishConnectionFailed : WebSocketCode(703)
|
||||
data object SendMessageFailed : WebSocketCode(704)
|
||||
data object CallFailed : WebSocketCode(705)
|
||||
}
|
||||
|
||||
sealed class WebSocketEvent(val code: Int) {
|
||||
data object BuildConnectionSuccess : WebSocketEvent(110)
|
||||
data object ConnectSuccess : WebSocketCode(11)
|
||||
data object AllMessageSent : WebSocketEvent(112)
|
||||
}
|
||||
|
||||
private var interrupt: String = ""
|
||||
|
||||
data class Result(var code: Int, var message: String)
|
||||
|
||||
fun callRequest(request: WsRequest): WsResponse {
|
||||
val wsResponse = WsResponse(startTime = System.currentTimeMillis())
|
||||
val responseHeader: WebSocketHeader = mutableMapOf()
|
||||
val responseData = JSONArray()
|
||||
|
||||
val webSockResponse = Result(WEB_SOCKET_CODE, "")
|
||||
|
||||
try {
|
||||
|
||||
if (socket == null || !isOpen || uri?.toString() != request.url) {
|
||||
if (socket != null) {
|
||||
disconnect()
|
||||
}
|
||||
uri = URI(request.url)
|
||||
val subProtocol =
|
||||
request.headers.filter {
|
||||
it.key.equals(
|
||||
WEB_SOCKET_REQUEST_HEADER_PROTOCOL,
|
||||
true
|
||||
)
|
||||
}
|
||||
.map { NameValue(it.key, it.value) }.firstOrNull()
|
||||
connect(url = request.url, subProtocol) {
|
||||
responseData.put(it)
|
||||
}
|
||||
responseHeader.put(
|
||||
"${System.currentTimeMillis()}",
|
||||
"${WebSocketEvent.BuildConnectionSuccess}"
|
||||
)
|
||||
|
||||
try {
|
||||
var waitCount = 0
|
||||
while (!isOpen && waitCount < 10) {
|
||||
LogUtils.info("Connecting...")
|
||||
Thread.sleep(1000)
|
||||
waitCount++
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
LogUtils.error(e)
|
||||
webSockResponse.code = WebSocketCode.EstablishConnectionException.code
|
||||
webSockResponse.message = "${e.message}"
|
||||
return wsResponse
|
||||
}
|
||||
|
||||
if (isOpen) {
|
||||
responseHeader["${System.currentTimeMillis()}"] =
|
||||
"${WebSocketEvent.ConnectSuccess.code}"
|
||||
}
|
||||
} else {
|
||||
LogUtils.info("use last time web socket connection")
|
||||
}
|
||||
val messages: List<WsRequestParam> = request.message
|
||||
if (messages.isNotEmpty() && socket != null && isOpen) {
|
||||
try {
|
||||
for (message in messages) {
|
||||
//当前消息需要判断响应是否包含中断当前连接的关键字
|
||||
interrupt = message.interrupt.ifBlank {
|
||||
""
|
||||
}
|
||||
|
||||
if (isOpen) {
|
||||
send(message.value)
|
||||
responseHeader.put("${System.currentTimeMillis()}", message.value)
|
||||
LogUtils.info("${System.currentTimeMillis()} send message ${message.value}")
|
||||
//当前消息发送完需要等待
|
||||
if (message.waitTime > 0) {
|
||||
Thread.sleep(message.waitTime)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
LogUtils.error(e)
|
||||
webSockResponse.code = WebSocketCode.SendMessageFailed.code
|
||||
webSockResponse.message = "${e.message}"
|
||||
return wsResponse
|
||||
}
|
||||
responseHeader.put(
|
||||
"${System.currentTimeMillis()}",
|
||||
"${WebSocketEvent.AllMessageSent.code}"
|
||||
)
|
||||
if (request.delay > 0) {
|
||||
Thread.sleep(request.delay * 1000L)
|
||||
}
|
||||
} else {
|
||||
webSockResponse.code = WebSocketCode.EstablishConnectionFailed.code
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
webSockResponse.code = WebSocketCode.BuildConnectionFailed.code
|
||||
webSockResponse.message = "${e.message}"
|
||||
LogUtils.error(throwable = e)
|
||||
return wsResponse
|
||||
} finally {
|
||||
if (responseData.length() < 1 && webSockResponse.message.isNotBlank()) {
|
||||
responseData.put(webSockResponse.message)
|
||||
}
|
||||
|
||||
wsResponse.data = responseData
|
||||
wsResponse.headers = responseHeader
|
||||
wsResponse.endTime = System.currentTimeMillis()
|
||||
wsResponse.code = webSockResponse.code
|
||||
}
|
||||
|
||||
LogUtils.info("${System.currentTimeMillis()} start connect web socket ${uri.toString()}")
|
||||
|
||||
return wsResponse
|
||||
}
|
||||
|
||||
fun connect(url: String, head: NameValue? = null, callBack: (String) -> Unit) {
|
||||
val request = Request.Builder()
|
||||
.url(url)
|
||||
.apply {
|
||||
if (head != null) {
|
||||
addHeader(name = head.name, value = head.name)
|
||||
}
|
||||
}
|
||||
.build()
|
||||
listener = object : WebSocketListener() {
|
||||
override fun onOpen(webSocket: WebSocket, response: Response) {
|
||||
super.onOpen(webSocket, response)
|
||||
isOpen = true
|
||||
LogUtils.info("${System.currentTimeMillis()} connection opened")
|
||||
}
|
||||
|
||||
override fun onMessage(webSocket: WebSocket, text: String) {
|
||||
super.onMessage(webSocket, text)
|
||||
LogUtils.info("${System.currentTimeMillis()} receive message $text")
|
||||
if ((interrupt.isNotBlank() && "*" == interrupt) || interrupt == text) {
|
||||
disconnect()
|
||||
}
|
||||
callBack.invoke(text)
|
||||
}
|
||||
|
||||
override fun onClosed(webSocket: WebSocket, code: Int, reason: String) {
|
||||
super.onClosed(webSocket, code, reason)
|
||||
isOpen = false
|
||||
LogUtils.info("${System.currentTimeMillis()} current web socket connection disconnected")
|
||||
}
|
||||
|
||||
override fun onFailure(webSocket: WebSocket, t: Throwable, response: Response?) {
|
||||
super.onFailure(webSocket, t, response)
|
||||
LogUtils.info("${System.currentTimeMillis()} current web socket connection error")
|
||||
}
|
||||
}
|
||||
socket = client.newWebSocket(request, listener!!)
|
||||
}
|
||||
|
||||
fun send(message: String) {
|
||||
socket?.send(message)
|
||||
}
|
||||
|
||||
fun disconnect() {
|
||||
socket?.close(1000, "")
|
||||
client.dispatcher.executorService.shutdown()
|
||||
socket = null
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package com.example.web_socket
|
||||
|
||||
import com.example.action.HttpMethod
|
||||
import com.example.action.NoString
|
||||
import com.example.action.WsRequestParam
|
||||
|
||||
data class WsRequest(
|
||||
val url: String,
|
||||
val method: HttpMethod = HttpMethod.Get,
|
||||
val headers: MutableMap<String, String> = mutableMapOf(),
|
||||
val message: List<WsRequestParam> = mutableListOf(),
|
||||
val delay: Int = 0
|
||||
) : NoString()
|
||||
@ -0,0 +1,12 @@
|
||||
package com.example.web_socket
|
||||
|
||||
import com.example.action.NoString
|
||||
import org.json.JSONArray
|
||||
|
||||
data class WsResponse(
|
||||
var code:Int = 0,
|
||||
var data: JSONArray? = null,
|
||||
var headers:Map<String, String> = mutableMapOf(),
|
||||
var startTime:Long = 0,
|
||||
var endTime:Long = 0
|
||||
): NoString()
|
||||
@ -0,0 +1,17 @@
|
||||
package com.example.lib
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
google {
|
||||
content {
|
||||
includeGroupByRegex("com\\.android.*")
|
||||
includeGroupByRegex("com\\.google.*")
|
||||
includeGroupByRegex("androidx.*")
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "vast"
|
||||
include(":app")
|
||||
include(":lib")
|
||||