Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Segilmez06 authored Nov 3, 2021
1 parent 411bfa6 commit 1efc93d
Show file tree
Hide file tree
Showing 13 changed files with 713 additions and 0 deletions.
37 changes: 37 additions & 0 deletions APK Installer for WSA/APK Installer for WSA.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31702.278
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "APKInstaller", "APKInstaller\APKInstaller.csproj", "{66483CB3-CC46-4E18-A1E9-15F84CB5ADAD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{66483CB3-CC46-4E18-A1E9-15F84CB5ADAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66483CB3-CC46-4E18-A1E9-15F84CB5ADAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66483CB3-CC46-4E18-A1E9-15F84CB5ADAD}.Debug|x64.ActiveCfg = Debug|x64
{66483CB3-CC46-4E18-A1E9-15F84CB5ADAD}.Debug|x64.Build.0 = Debug|x64
{66483CB3-CC46-4E18-A1E9-15F84CB5ADAD}.Debug|x86.ActiveCfg = Debug|x86
{66483CB3-CC46-4E18-A1E9-15F84CB5ADAD}.Debug|x86.Build.0 = Debug|x86
{66483CB3-CC46-4E18-A1E9-15F84CB5ADAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66483CB3-CC46-4E18-A1E9-15F84CB5ADAD}.Release|Any CPU.Build.0 = Release|Any CPU
{66483CB3-CC46-4E18-A1E9-15F84CB5ADAD}.Release|x64.ActiveCfg = Release|x64
{66483CB3-CC46-4E18-A1E9-15F84CB5ADAD}.Release|x64.Build.0 = Release|x64
{66483CB3-CC46-4E18-A1E9-15F84CB5ADAD}.Release|x86.ActiveCfg = Release|x86
{66483CB3-CC46-4E18-A1E9-15F84CB5ADAD}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C9C3CAB0-6050-4D73-9D68-7DAB2DD7EF26}
EndGlobalSection
EndGlobal
147 changes: 147 additions & 0 deletions APK Installer for WSA/APKInstaller/APKInstaller.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{66483CB3-CC46-4E18-A1E9-15F84CB5ADAD}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>APKInstaller</RootNamespace>
<AssemblyName>APKInstaller</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>and_app_ico.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Debug\</OutputPath>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject>APKInstaller.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.IO.Compression.ZipFile, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="and_app_ico.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.6 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
17 changes: 17 additions & 0 deletions APK Installer for WSA/APKInstaller/APKInstaller.csproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<StartArguments>
</StartArguments>
</PropertyGroup>
<PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory>
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>
128 changes: 128 additions & 0 deletions APK Installer for WSA/APKInstaller/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Windows.Forms;
using System.Net;

namespace APKInstaller
{
static class Program
{
static string workpath = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
static string adbpath = Path.Combine(workpath, "platform-tools/adb.exe");
static string zippath = Path.Combine(workpath, "adb.zip");
static string ziplink = "https://dl.google.com/android/repository/platform-tools_r31.0.3-windows.zip";

static string path = "";

static string conaddr = "127.0.0.1:58526";

[STAThread]
static void Main()
{
if (!(File.Exists(adbpath)))
{
getADB();
}

string[] args = Environment.GetCommandLineArgs();
if (args.Length == 2)
{
path = args[1];
if (File.Exists(path) && path.EndsWith(".apk"))
{
installAPK();
}
else
{
MessageBox.Show("File is not available or invalid a Android app package. Please check the file again.", "APKInstaller for WSA");
Environment.Exit(1);
}

}
}
static void getADB()
{
if (File.Exists(zippath))
File.Delete(zippath);

using (var w = new WebClient())
{
w.DownloadFile(ziplink, zippath);
}

ZipFile.ExtractToDirectory(zippath, workpath);
File.Delete(zippath);

}

static void installAPK()
{
Process installproc = new Process();
ProcessStartInfo si = new ProcessStartInfo
{
FileName = adbpath,
Arguments = "install " + path,
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
};

installproc.StartInfo = si;
installproc.Start();
installproc.WaitForExit();

string cmdout = installproc.StandardOutput.ReadToEnd();
if (cmdout.Contains("no devices/emulators found"))
{
connectDev();
}
else if (cmdout.Contains("Success"))
{
MessageBox.Show("Installed app successfully.", "APKInstaller for WSA");
Environment.Exit(0);
}
else
{
MessageBox.Show("An error occured while installing the app.", "APKInstaller for WSA");
Environment.Exit(1);
}
}

static void connectDev()
{
Process installproc = new Process();
ProcessStartInfo si = new ProcessStartInfo
{
FileName = adbpath,
Arguments = conaddr,
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
};

installproc.StartInfo = si;
installproc.Start();
installproc.WaitForExit();

string cmdout = installproc.StandardOutput.ReadToEnd();
if (cmdout.Contains("connected to " + conaddr))
{
installAPK();
}
else if (cmdout.Contains("refused"))
{
MessageBox.Show("Cannot connect to WSA.", "APKInstaller for WSA");
Environment.Exit(1);
}
else
{
MessageBox.Show("An error occured while installing the app.", "APKInstaller for WSA");
Environment.Exit(1);
}
}
}
}
36 changes: 36 additions & 0 deletions APK Installer for WSA/APKInstaller/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("APKInstaller")]
[assembly: AssemblyDescription("An easy way to install APKs to WSA.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Erentronik Corp.")]
[assembly: AssemblyProduct("APKInstaller")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("66483cb3-cc46-4e18-a1e9-15f84cb5adad")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading

0 comments on commit 1efc93d

Please sign in to comment.