Merge "Small build and lint-required fixes"
diff --git a/GameActivity/src/main/java/com/google/androidgamesdk/GameActivity.java b/GameActivity/src/main/java/com/google/androidgamesdk/GameActivity.java
index 670c33e..b02a246 100644
--- a/GameActivity/src/main/java/com/google/androidgamesdk/GameActivity.java
+++ b/GameActivity/src/main/java/com/google/androidgamesdk/GameActivity.java
@@ -391,8 +391,10 @@
@Override
public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
onWindowInsetsChangedNative(mNativeHandle);
- // Pass through to the view - we don't want to handle the insets, just observe them.
- v.onApplyWindowInsets(insets.toWindowInsets());
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
+ // Pass through to the view - we don't want to handle the insets, just observe them.
+ v.onApplyWindowInsets(insets.toWindowInsets());
+ }
return insets;
}
diff --git a/GameController/src/main/java/com/google/android/games/paddleboat/GameControllerManager.java b/GameController/src/main/java/com/google/android/games/paddleboat/GameControllerManager.java
index 42ec9f2..691075d 100644
--- a/GameController/src/main/java/com/google/android/games/paddleboat/GameControllerManager.java
+++ b/GameController/src/main/java/com/google/android/games/paddleboat/GameControllerManager.java
@@ -779,7 +779,9 @@
float axisMax = motionRange.getMax();
float axisMin = motionRange.getMin();
float axisRange = motionRange.getRange();
- float axisResolution = motionRange.getResolution();
+ float axisResolution = -1;
+ if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.JELLY_BEAN_MR2)
+ axisResolution = motionRange.getResolution();
Log.d(TAG, "MotionRange:" +
"\n" + axisString +
@@ -794,12 +796,18 @@
private void logControllerInfo(int deviceId) {
InputDevice inputDevice = InputDevice.getDevice(deviceId);
- int controllerNumber = inputDevice.getControllerNumber();
+ int controllerNumber = -1;
+ if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.KITKAT)
+ controllerNumber = inputDevice.getControllerNumber();
String deviceDescriptor = inputDevice.getDescriptor();
String deviceName = inputDevice.getName();
- int deviceProductId = inputDevice.getProductId();
+ int deviceProductId = -1;
+ if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.KITKAT)
+ deviceProductId = inputDevice.getProductId();
int deviceSources = inputDevice.getSources();
- int deviceVendorId = inputDevice.getVendorId();
+ int deviceVendorId = -1;
+ if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.KITKAT)
+ deviceVendorId = inputDevice.getVendorId();
boolean hasVibrator = inputDevice.getVibrator().hasVibrator();
boolean isVirtual = inputDevice.isVirtual();
@@ -834,4 +842,4 @@
public native void onMouseConnected(int deviceId);
public native void onMouseDisconnected(int deviceId);
-}
\ No newline at end of file
+}
diff --git a/GameController/src/test/java/com/google/android/games/paddleboat/ExampleUnitTest.java b/GameController/src/test/java/com/google/android/games/paddleboat/ExampleUnitTest.java
deleted file mode 100644
index 17be7b4..0000000
--- a/GameController/src/test/java/com/google/android/games/paddleboat/ExampleUnitTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (C) 2021 The Android Open Source Project
-//
-// 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.
-package com.google.android.games.paddleboat;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/GameTextInput/src/main/java/com/google/androidgamesdk/gametextinput/InputConnection.java b/GameTextInput/src/main/java/com/google/androidgamesdk/gametextinput/InputConnection.java
index 50c6ae7..71d3099 100644
--- a/GameTextInput/src/main/java/com/google/androidgamesdk/gametextinput/InputConnection.java
+++ b/GameTextInput/src/main/java/com/google/androidgamesdk/gametextinput/InputConnection.java
@@ -37,7 +37,7 @@
public class InputConnection
extends BaseInputConnection
implements View.OnKeyListener, OnApplyWindowInsetsListener {
- private static final String TAG = "gametextinput.InputConnection";
+ private static final String TAG = "gti.InputConnection";
// TODO: (b/183179971) We should react to most of these events rather than ignoring them? Plus
// there are others that should be ignored.
private static final int[] notInsertedKeyCodes = {KeyEvent.KEYCODE_DEL,
@@ -67,7 +67,7 @@
super(targetView, settings.mEditorInfo.inputType != 0);
this.targetView = targetView;
this.settings = settings;
- Object imm = ctx.getSystemService("input_method");
+ Object imm = ctx.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm == null) {
throw new java.lang.RuntimeException("Can't get IMM");
} else {
diff --git a/build.gradle b/build.gradle
index 2e1f7db..338199d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -767,7 +767,16 @@
class BuildTask extends DefaultTask {
}
-task build(type: BuildTask) {
+task build(type: DefaultTask) {
+ doFirst {
+ throw new GradleException("""
+Do not use the default build task for building the AGDK.
+Use buildLocal, buildSpecific or one of the packaging tasks.
+""")
+ }
+}
+
+task buildAll(type: BuildTask) {
ext.flattenLibs = false
ext.withSharedLibs = true
ext.withStaticLibs = true
@@ -811,7 +820,6 @@
tasks.withType(BuildTask) {
def nativeLibraries = filterNativeLibraries(allLibraries)
def androidArchiveLibraries = filterAndroidArchiveLibraries(allLibraries)
-
dependsOn ':extras:assembleRelease'
nativeLibraries.each { nativeLibrary ->
if (nativeLibrary.isThirdParty()) dependsOn prepare_third_party_libraries
@@ -1117,7 +1125,7 @@
}
addZipTask("packageUnityZip", buildUnity, "builds.zip")
-addZipTask("packageZip", build, getAGDKZipName())
+addZipTask("packageZip", buildAll, getAGDKZipName())
addZipTask("packageLocalZip", buildLocal, "gamesdk.zip")
addZipTask("packageSpecificZip", buildSpecific, "gamesdk.zip")
addZipTask("packageAar", buildAarStructure, "gamesdk.aar")
diff --git a/samples/bouncyball/app/CMakeLists.txt b/samples/bouncyball/app/CMakeLists.txt
index 05092dc..08b5d2b 100644
--- a/samples/bouncyball/app/CMakeLists.txt
+++ b/samples/bouncyball/app/CMakeLists.txt
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.4.1)
+project(bouncyball)
+
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Werror -Wthread-safety -D _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS" )
# ============== Games SDK
diff --git a/samples/bouncyball/gradle.properties b/samples/bouncyball/gradle.properties
index aac7c9b..01236ed 100644
--- a/samples/bouncyball/gradle.properties
+++ b/samples/bouncyball/gradle.properties
@@ -15,3 +15,5 @@
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
+
+android.useAndroidX=true
diff --git a/samples/gamesdk.cmake b/samples/gamesdk.cmake
index d748edd..6e99cb5 100644
--- a/samples/gamesdk.cmake
+++ b/samples/gamesdk.cmake
@@ -135,5 +135,5 @@
# sources to your project - allowing the IDE to provide autocompletions and
# debugging.
function(add_gamesdk_sources)
- add_subdirectory("${_MY_DIR}/../src")
+ add_subdirectory("${_MY_DIR}/../src" "${_MY_DIR}/../src")
endfunction()