Skip to content

Commit 9553fea

Browse files
author
Stewart Miles
committed
Removed Android Resolver logging dependency upon JarResolverLib.
All Android Resolver logging has been moved to depend upon Logger (in VersionHandlerImpl) rather than using the Log() methods in going JarResolverLib. Change-Id: I2a03e0a8553dec2019bebacd1b8c36922c66c5c8
1 parent f9d587b commit 9553fea

File tree

7 files changed

+126
-102
lines changed

7 files changed

+126
-102
lines changed

source/PlayServicesResolver/src/AndroidSdkManager.cs

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// </copyright>
1616

1717
namespace GooglePlayServices {
18+
using Google;
1819
using Google.JarResolver;
1920
using System;
2021
using System.Diagnostics;
@@ -182,10 +183,10 @@ public static long ConvertVersionStringToInteger(string versionString,
182183
try {
183184
componentInteger = Convert.ToInt64(component);
184185
} catch (FormatException) {
185-
PlayServicesSupport.Log(
186+
PlayServicesResolver.Log(
186187
String.Format("Unable to convert version string {0} to " +
187188
"integer value", versionString),
188-
level: PlayServicesSupport.LogLevel.Warning);
189+
level: LogLevel.Warning);
189190
return 0;
190191
}
191192
versionInteger += (componentInteger * currentMultiplier);
@@ -241,9 +242,9 @@ public static AndroidSdkPackage ReadFromSourceProperties(string sdkDirectory,
241242
try {
242243
propertiesText = File.ReadAllText(propertiesPath);
243244
} catch (Exception e) {
244-
PlayServicesSupport.Log(String.Format("Unable to read {0}\n{1}\n",
245+
PlayServicesResolver.Log(String.Format("Unable to read {0}\n{1}\n",
245246
propertiesPath, e.ToString()),
246-
verbose: true);
247+
level: LogLevel.Verbose);
247248
return null;
248249
}
249250
// Unfortunately the package name is simply based upon the path within the SDK.
@@ -405,10 +406,11 @@ public static void QueryPackages(string toolPath, string toolArguments,
405406
Action<CommandLine.Result> complete) {
406407
var window = CommandLineDialog.CreateCommandLineDialog(
407408
"Querying Android SDK packages");
408-
PlayServicesSupport.Log(String.Format("Query Android SDK packages\n" +
409-
"\n" +
410-
"{0} {1}\n",
411-
toolPath, toolArguments), verbose: true);
409+
PlayServicesResolver.Log(String.Format("Query Android SDK packages\n" +
410+
"\n" +
411+
"{0} {1}\n",
412+
toolPath, toolArguments),
413+
level: LogLevel.Verbose);
412414
window.summaryText = "Getting Installed Android SDK packages.";
413415
window.modal = false;
414416
window.progressTitle = window.summaryText;
@@ -418,7 +420,7 @@ public static void QueryPackages(string toolPath, string toolArguments,
418420
(CommandLine.Result result) => {
419421
window.Close();
420422
if (result.exitCode != 0) {
421-
PlayServicesSupport.Log(String.Format(PACKAGES_MISSING, result.message));
423+
PlayServicesResolver.Log(String.Format(PACKAGES_MISSING, result.message));
422424
}
423425
complete(result);
424426
},
@@ -443,10 +445,11 @@ public static void InstallPackages(
443445
HashSet<AndroidSdkPackageNameVersion> packages,
444446
string licenseQuestion, string licenseAgree, string licenseDecline,
445447
Regex licenseTextHeader, Action<bool> complete) {
446-
PlayServicesSupport.Log(String.Format("Install Android SDK packages\n" +
447-
"\n" +
448-
"{0} {1}\n",
449-
toolPath, toolArguments), verbose: true);
448+
PlayServicesResolver.Log(String.Format("Install Android SDK packages\n" +
449+
"\n" +
450+
"{0} {1}\n",
451+
toolPath, toolArguments),
452+
level: LogLevel.Verbose);
450453
// Display the license retrieval dialog.
451454
DisplayInstallLicenseDialog(
452455
toolPath, toolArguments, true,
@@ -507,16 +510,15 @@ private static void LogInstallLicenseResult(
507510
"Aborted installation of the following packages:\n" :
508511
"Android package installation failed.\n\n" +
509512
"Failed when installing the following packages:\n";
510-
PlayServicesSupport.Log(
513+
PlayServicesResolver.Log(
511514
String.Format(
512515
"{0}\n" +
513516
"{1}\n\n" +
514517
"{2}\n",
515518
succeeded ? "Successfully installed Android packages.\n\n" : failedMessage,
516519
AndroidSdkPackageNameVersion.ListToString(packages),
517520
toolResult.message),
518-
level: succeeded ? PlayServicesSupport.LogLevel.Info :
519-
PlayServicesSupport.LogLevel.Warning);
521+
level: succeeded ? LogLevel.Info : LogLevel.Warning);
520522
}
521523
}
522524

@@ -544,8 +546,8 @@ private static void DisplayInstallLicenseDialog(
544546
window.autoScrollToBottom = true;
545547
CommandLine.IOHandler ioHandler = null;
546548
if (licenseResponder != null) ioHandler = licenseResponder.AggregateLine;
547-
PlayServicesSupport.Log(String.Format("{0} {1}", toolPath, toolArguments),
548-
verbose: true);
549+
PlayServicesResolver.Log(String.Format("{0} {1}", toolPath, toolArguments),
550+
level: LogLevel.Verbose);
549551
window.RunAsync(
550552
toolPath, toolArguments,
551553
(CommandLine.Result result) => {
@@ -919,8 +921,9 @@ public void InstallPackages(HashSet<AndroidSdkPackageNameVersion> packages,
919921
packagesString),
920922
"Yes", cancel: "No");
921923
if (!installPackage) {
922-
PlayServicesSupport.Log("User cancelled installation of Android SDK tools package.",
923-
level: PlayServicesSupport.LogLevel.Warning);
924+
PlayServicesResolver.Log(
925+
"User cancelled installation of Android SDK tools package.",
926+
level: LogLevel.Warning);
924927
complete(false);
925928
return;
926929
}
@@ -945,7 +948,7 @@ internal class AndroidSdkManager {
945948
/// <returns>String with the path to the tool if found, null otherwise.</returns>
946949
private static string FindAndroidSdkTool(string toolName, string sdkPath = null) {
947950
if (String.IsNullOrEmpty(sdkPath)) {
948-
PlayServicesSupport.Log(String.Format(
951+
PlayServicesResolver.Log(String.Format(
949952
"{0}\n" +
950953
"Falling back to searching for the Android SDK tool {1} in the system path.",
951954
PlayServicesSupport.AndroidSdkConfigurationError, toolName));
@@ -974,7 +977,7 @@ private static string FindAndroidSdkTool(string toolName, string sdkPath = null)
974977
/// </summary>
975978
/// <param name="complete">Action called with null.</param>
976979
private static void CreateFailed(Action<IAndroidSdkManager> complete) {
977-
PlayServicesSupport.Log(String.Format(
980+
PlayServicesResolver.Log(String.Format(
978981
"Unable to find either the {0} or {1} command line tool.\n\n" +
979982
"It is not possible to query or install Android SDK packages.\n" +
980983
"To resolve this issue, open the Android Package Manager" +

source/PlayServicesResolver/src/CommandLineDialog.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ namespace GooglePlayServices
2424
using UnityEditor;
2525
using UnityEngine;
2626

27+
using Google;
28+
2729
public class CommandLineDialog : TextAreaDialog
2830
{
2931
/// <summary>
@@ -90,8 +92,9 @@ private void CommandLineIOHandler(Process process, StreamWriter stdin,
9092
/// </summary>
9193
public void CommandLineToolCompletion(CommandLine.Result result)
9294
{
93-
Google.JarResolver.PlayServicesSupport.Log(
94-
String.Format("Command completed: {0}", result.message), verbose: true);
95+
PlayServicesResolver.Log(
96+
String.Format("Command completed: {0}", result.message),
97+
level: LogLevel.Verbose);
9598
this.result = result;
9699
}
97100

@@ -218,8 +221,8 @@ public void RunAsync(
218221
CommandLine.CompletionHandler reporterUpdateDisable =
219222
(CommandLine.Result unusedResult) => { this.UpdateEvent -= reporter.Update; };
220223
reporter.Complete += reporterUpdateDisable;
221-
Google.JarResolver.PlayServicesSupport.Log(String.Format(
222-
"Executing command: {0} {1}", toolPath, arguments), verbose: true);
224+
PlayServicesResolver.Log(String.Format(
225+
"Executing command: {0} {1}", toolPath, arguments), level: LogLevel.Verbose);
223226
CommandLine.RunAsync(toolPath, arguments, reporter.CommandLineToolCompletion,
224227
workingDirectory: workingDirectory, envVars: envVars,
225228
ioHandler: reporter.AggregateLine);

source/PlayServicesResolver/src/DefaultResolver.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,9 @@ internal HashSet<string> GetSelectedABIDirs(string currentAbi) {
349349
/// <returns>true if successful, false otherwise.</returns>
350350
internal virtual bool ProcessAar(string dir, string aarFile, bool antProject,
351351
out string abi) {
352-
PlayServicesSupport.Log(String.Format("ProcessAar {0} {1} antProject={2}",
353-
dir, aarFile, antProject), verbose: true);
352+
PlayServicesResolver.Log(String.Format("ProcessAar {0} {1} antProject={2}",
353+
dir, aarFile, antProject),
354+
level: LogLevel.Verbose);
354355
abi = null;
355356
string workingDir = Path.Combine(dir, Path.GetFileNameWithoutExtension(aarFile));
356357
FileUtils.DeleteExistingFileOrDirectory(workingDir);

source/PlayServicesResolver/src/GradlePreBuildResolver.cs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@ private void GradleResolve(AndroidSdkPackageCollection packages,
248248
// A value of -1 means the targetSDK Version enum returned "Auto"
249249
// instead of an actual version, so it's up to us to actually figure it out.
250250
targetSdkVersion = GetLatestInstalledAndroidPlatformVersion(packages);
251-
PlayServicesSupport.Log(
252-
String.Format("TargetSDK is set to Auto-detect, and the latest Platform has been " +
253-
"detected as: android-{0}", targetSdkVersion),
254-
level: PlayServicesSupport.LogLevel.Info, verbose: true);
251+
PlayServicesResolver.Log(
252+
String.Format("TargetSDK is set to Auto-detect, and the latest Platform has " +
253+
"been detected as: android-{0}", targetSdkVersion),
254+
level: LogLevel.Verbose);
255255

256256
errorIntro = String.Format("The Target SDK is set to automatically pick the highest " +
257257
"installed platform in the Android Player Settings, which appears to be " +
@@ -274,16 +274,18 @@ private void GradleResolve(AndroidSdkPackageCollection packages,
274274
buildToolsVersion = GetLatestMinorBuildToolsVersion(packages, targetSdkVersion);
275275

276276
if (buildToolsVersion == null) {
277-
PlayServicesSupport.Log(errorIntro + String.Format("no build-tools are available " +
277+
PlayServicesResolver.Log(
278+
errorIntro + String.Format("no build-tools are available " +
278279
"at this level in the sdk manager. This plugin has been tested with " +
279280
"platforms up to android-{0} using build-tools {0}.{1}.{2}. You can try " +
280281
"selecting a lower targetSdkVersion in the Android Player Settings. Please ",
281282
TESTED_BUILD_TOOLS_VERSION_MAJOR, TESTED_BUILD_TOOLS_VERSION_MINOR,
282283
TESTED_BUILD_TOOLS_VERSION_REV) + errorOutro,
283-
level: PlayServicesSupport.LogLevel.Error);
284+
level: LogLevel.Error);
284285
return;
285286
} else {
286-
PlayServicesSupport.Log(errorIntro + String.Format("this plugin has only been " +
287+
PlayServicesResolver.Log(
288+
errorIntro + String.Format("this plugin has only been " +
287289
"tested with build-tools up to version {0}.{1}.{2}. Corresponding " +
288290
"build-tools version {3} will be used, however this is untested with this " +
289291
"plugin and MAY NOT WORK! If you have trouble, please select a target SDK " +
@@ -292,7 +294,7 @@ private void GradleResolve(AndroidSdkPackageCollection packages,
292294
TESTED_BUILD_TOOLS_VERSION_MAJOR,
293295
TESTED_BUILD_TOOLS_VERSION_MINOR,
294296
TESTED_BUILD_TOOLS_VERSION_REV,
295-
buildToolsVersion) + errorOutro, level: PlayServicesSupport.LogLevel.Warning);
297+
buildToolsVersion) + errorOutro, level: LogLevel.Warning);
296298
}
297299
}
298300

@@ -404,19 +406,19 @@ public override void DoResolution(PlayServicesSupport svcSupport, string destina
404406
sdkPath,
405407
(IAndroidSdkManager sdkManager) => {
406408
if (sdkManager == null) {
407-
PlayServicesSupport.Log(
409+
PlayServicesResolver.Log(
408410
String.Format("Unable to find the Android SDK manager tool."),
409-
level: PlayServicesSupport.LogLevel.Error);
411+
level: LogLevel.Error);
410412
return;
411413
}
412414

413415
// Get the set of available and installed packages.
414416
sdkManager.QueryPackages(
415417
(AndroidSdkPackageCollection packages) => {
416418
if (packages == null) {
417-
PlayServicesSupport.Log(
418-
String.Format("No packages returned from the Android SDK Manager."),
419-
level: PlayServicesSupport.LogLevel.Error);
419+
PlayServicesResolver.Log(
420+
String.Format("No packages returned from the Android SDK " +
421+
"Manager."), level: LogLevel.Error);
420422
return;
421423
}
422424

source/PlayServicesResolver/src/JavaUtilities.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace GooglePlayServices {
2121
using System.IO;
2222
using UnityEditor;
2323

24+
using Google;
2425
using Google.JarResolver;
2526

2627
/// <summary>
@@ -152,13 +153,13 @@ private static string FindJavaTool(string javaTool)
152153
/// <param name="javaPath">Path to the java tool.</param>
153154
/// <param name="commandLineSummary">Summary of the executed command line.</param>
154155
private static void LogJdkVersionFailedWarning(string javaPath, string commandLineSummary) {
155-
PlayServicesSupport.Log(
156+
PlayServicesResolver.Log(
156157
String.Format(
157158
"Failed to get Java version when running {0}\n" +
158159
"It is not be possible to verify your Java installation is new enough to " +
159160
"compile with the latest Android SDK\n\n" +
160161
"{1}", javaPath, commandLineSummary),
161-
level: PlayServicesSupport.LogLevel.Warning);
162+
level: LogLevel.Warning);
162163
}
163164

164165
/// <summary>
@@ -204,14 +205,14 @@ internal static void CheckJdkForApiLevel() {
204205
}
205206
// If the user's installed JDK is too old, report an error.
206207
if (majorMinorVersion < MINIMUM_JDK_VERSION_MAJOR_MINOR) {
207-
PlayServicesSupport.Log(
208+
PlayServicesResolver.Log(
208209
String.Format("The configured JDK {0} is too old to build Android " +
209210
"applications with recent libraries.\n" +
210211
"Please install JDK version {1} or newer and configure Unity " +
211212
"to use the new JDK installation in the " +
212213
"'Unity Preferences > External Tools' menu.\n",
213214
majorMinorVersion, MINIMUM_JDK_VERSION_MAJOR_MINOR),
214-
level: PlayServicesSupport.LogLevel.Error);
215+
level: LogLevel.Error);
215216
}
216217
}
217218
}

0 commit comments

Comments
 (0)