From 7d887f54fa1e0100b2439fd6db76ebb35f0a835d Mon Sep 17 00:00:00 2001 From: Kirill Snezhko <4477094+argrento@users.noreply.github.com> Date: Fri, 1 Apr 2022 17:35:37 +0300 Subject: [PATCH 01/12] Update gradle version in android_rpc app --- apps/android_rpc/app/build.gradle | 22 +++++++++++++------ .../app/src/main/AndroidManifest.xml | 1 + apps/android_rpc/build.gradle | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/apps/android_rpc/app/build.gradle b/apps/android_rpc/app/build.gradle index 747809317cb3..8059c381b0e7 100644 --- a/apps/android_rpc/app/build.gradle +++ b/apps/android_rpc/app/build.gradle @@ -48,16 +48,24 @@ android { jniLibs.srcDirs = ['src/main/libs'] } } + + gradle.taskGraph.whenReady {graph -> + def tasks = graph.getAllTasks() + tasks.each {task -> + def name = task.getName() + if (name.contains("lint")) task.setEnabled(false) + } + } } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + implementation fileTree(dir: 'libs', include: ['*.jar']) + androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) - compile 'com.android.support:appcompat-v7:26.0.1' - compile 'com.android.support.constraint:constraint-layout:1.0.2' - compile 'com.android.support:design:26.0.1' - compile 'org.apache.tvm:tvm4j-core:0.0.1-SNAPSHOT' - testCompile 'junit:junit:4.12' + implementation 'com.android.support:appcompat-v7:26.0.1' + implementation 'com.android.support.constraint:constraint-layout:1.0.2' + implementation 'com.android.support:design:26.0.1' + implementation 'org.apache.tvm:tvm4j-core:0.0.1-SNAPSHOT' + testImplementation 'junit:junit:4.12' } diff --git a/apps/android_rpc/app/src/main/AndroidManifest.xml b/apps/android_rpc/app/src/main/AndroidManifest.xml index d6e1ef8e63ed..4a7ba917dad0 100644 --- a/apps/android_rpc/app/src/main/AndroidManifest.xml +++ b/apps/android_rpc/app/src/main/AndroidManifest.xml @@ -23,6 +23,7 @@ under the License. package="org.apache.tvm.tvmrpc" > + Date: Mon, 4 Apr 2022 16:39:31 +0300 Subject: [PATCH 02/12] Support latest gradle, bump versions, replace ndk build script with gradle tasks --- apps/android_rpc/app/build.gradle | 50 ++++++++++++++----- .../org/apache/tvm/tvmrpc/MainActivity.java | 5 +- .../org/apache/tvm/tvmrpc/RPCActivity.java | 2 +- apps/android_rpc/app/src/main/jni/build.sh | 26 ---------- .../app/src/main/res/layout/activity_main.xml | 10 ++-- .../app/src/main/res/layout/activity_rpc.xml | 10 ++-- apps/android_rpc/build.gradle | 6 +-- apps/android_rpc/gradle.properties | 2 + 8 files changed, 57 insertions(+), 54 deletions(-) delete mode 100755 apps/android_rpc/app/src/main/jni/build.sh create mode 100644 apps/android_rpc/gradle.properties diff --git a/apps/android_rpc/app/build.gradle b/apps/android_rpc/app/build.gradle index 8059c381b0e7..0d5290f110f1 100644 --- a/apps/android_rpc/app/build.gradle +++ b/apps/android_rpc/app/build.gradle @@ -17,8 +17,35 @@ apply plugin: 'com.android.application' +task generateJniHeaders(type: Exec, description: 'Generate JNI Headers') { + def headerPath = "${project.projectDir}/src/main/jni" + def classPath = "${project.projectDir}/../../../jvm/core/target/*" + def filePath = "${project.projectDir}/../../../jvm/core/src/main/java/org/apache/tvm/LibInfo.java" + commandLine "javac", "-h", headerPath, "-classpath", classPath, filePath + doLast { + file("${headerPath}/org_apache_tvm_LibInfo.h").renameTo(file("${headerPath}/org_apache_tvm_native_c_api.h")) + } +} + +task copyFiles(type: Copy, description: 'Copy Sources for ndk-build') { + dependsOn "generateJniHeaders" + def ndkFilesPath = "${project.projectDir}/../../../jvm/native/src/main/native" + def srcPath = "${project.projectDir}/src/main/jni/" + + from "${ndkFilesPath}/org_apache_tvm_native_c_api.cc", "${ndkFilesPath}/jni_helper_func.h" + into srcPath +} + +task deleteLibs(type: Delete, description: "Delete Compiled Libraries") { + dependsOn "copyFiles" + def libsPath = "${project.projectDir}/src/main/libs" + delete libsPath +} + task buildJni(type: Exec, description: 'Build JNI libs') { - commandLine 'sh', 'src/main/jni/build.sh' + dependsOn "deleteLibs" + def buildPath = "${project.projectDir}/src/main/jni" + commandLine "ndk-build", "--directory", buildPath } tasks.withType(JavaCompile) { @@ -26,8 +53,7 @@ tasks.withType(JavaCompile) { } android { - compileSdkVersion 26 - buildToolsVersion "26.0.1" + compileSdkVersion 31 defaultConfig { applicationId "org.apache.tvm.tvmrpc" minSdkVersion 24 @@ -50,22 +76,22 @@ android { } gradle.taskGraph.whenReady {graph -> - def tasks = graph.getAllTasks() - tasks.each {task -> - def name = task.getName() + def tasks = graph.getAllTasks() + tasks.each {task -> + def name = task.getName() if (name.contains("lint")) task.setEnabled(false) - } + } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { + androidTestImplementation('com.android.support.test.espresso:espresso-core:3.4.0', { exclude group: 'com.android.support', module: 'support-annotations' }) - implementation 'com.android.support:appcompat-v7:26.0.1' - implementation 'com.android.support.constraint:constraint-layout:1.0.2' - implementation 'com.android.support:design:26.0.1' + implementation 'androidx.appcompat:appcompat:1.4.1' + implementation 'com.android.support.constraint:constraint-layout:2.1.3' + implementation 'com.android.support:design:28.0.0' implementation 'org.apache.tvm:tvm4j-core:0.0.1-SNAPSHOT' - testImplementation 'junit:junit:4.12' + testImplementation 'junit:junit:4.13.2' } diff --git a/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/MainActivity.java b/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/MainActivity.java index 35105df92b0d..26d553b59fd4 100644 --- a/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/MainActivity.java +++ b/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/MainActivity.java @@ -23,9 +23,10 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; +import android.os.Looper; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; import android.widget.CompoundButton; import android.widget.EditText; import android.widget.Switch; diff --git a/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/RPCActivity.java b/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/RPCActivity.java index 0d7f04782d3a..1481c854f966 100644 --- a/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/RPCActivity.java +++ b/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/RPCActivity.java @@ -18,7 +18,7 @@ package org.apache.tvm.tvmrpc; import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.widget.Button; import android.view.View; diff --git a/apps/android_rpc/app/src/main/jni/build.sh b/apps/android_rpc/app/src/main/jni/build.sh deleted file mode 100755 index 001d206ffd5d..000000000000 --- a/apps/android_rpc/app/src/main/jni/build.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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 -# -# http://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. -PATH="$PATH:/usr/local/bin" -CURR_DIR=$(cd `dirname $0`; pwd) -ROOT_DIR="$CURR_DIR/../../../../../.." -javac -h $CURR_DIR -classpath "$ROOT_DIR/jvm/core/target/*" $ROOT_DIR/jvm/core/src/main/java/org/apache/tvm/LibInfo.java || exit -1 -mv $CURR_DIR/org_apache_tvm_LibInfo.h $CURR_DIR/org_apache_tvm_native_c_api.h -cp -f $ROOT_DIR/jvm/native/src/main/native/org_apache_tvm_native_c_api.cc $CURR_DIR/ || exit -1 -cp -f $ROOT_DIR/jvm/native/src/main/native/jni_helper_func.h $CURR_DIR/ || exit -1 -rm -rf $CURR_DIR/../libs -ndk-build --directory=$CURR_DIR diff --git a/apps/android_rpc/app/src/main/res/layout/activity_main.xml b/apps/android_rpc/app/src/main/res/layout/activity_main.xml index f5cad5443cd1..f317a1cb7988 100644 --- a/apps/android_rpc/app/src/main/res/layout/activity_main.xml +++ b/apps/android_rpc/app/src/main/res/layout/activity_main.xml @@ -19,7 +19,7 @@ specific language governing permissions and limitations under the License. --> - - - - + - + diff --git a/apps/android_rpc/app/src/main/res/layout/activity_rpc.xml b/apps/android_rpc/app/src/main/res/layout/activity_rpc.xml index 7e282b5a02f3..9c586e0cc0c7 100644 --- a/apps/android_rpc/app/src/main/res/layout/activity_rpc.xml +++ b/apps/android_rpc/app/src/main/res/layout/activity_rpc.xml @@ -19,7 +19,7 @@ specific language governing permissions and limitations under the License. --> - - - - + - + diff --git a/apps/android_rpc/build.gradle b/apps/android_rpc/build.gradle index 7cff5de3e4d3..1cd5ac9b656f 100644 --- a/apps/android_rpc/build.gradle +++ b/apps/android_rpc/build.gradle @@ -19,13 +19,13 @@ buildscript { repositories { - jcenter() + gradlePluginPortal() maven { url 'https://maven.google.com' } } dependencies { - classpath 'com.android.tools.build:gradle:4.2.0' + classpath 'com.android.tools.build:gradle:7.1.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -34,7 +34,7 @@ buildscript { allprojects { repositories { - jcenter() + gradlePluginPortal() maven { url 'https://maven.google.com' } diff --git a/apps/android_rpc/gradle.properties b/apps/android_rpc/gradle.properties new file mode 100644 index 000000000000..646c51b977f3 --- /dev/null +++ b/apps/android_rpc/gradle.properties @@ -0,0 +1,2 @@ +android.useAndroidX=true +android.enableJetifier=true From ef748b19690f96870203f081ed2a8490f43fa06a Mon Sep 17 00:00:00 2001 From: Kirill Snezhko <4477094+argrento@users.noreply.github.com> Date: Mon, 4 Apr 2022 17:39:27 +0300 Subject: [PATCH 03/12] [android_rpc] Fix linter errors, disable weird ones --- apps/android_rpc/app/build.gradle | 16 ++++++++----- .../app/src/main/AndroidManifest.xml | 9 ++++---- .../org/apache/tvm/tvmrpc/MainActivity.java | 13 ++++++----- .../app/src/main/res/layout/content_main.xml | 23 +++++++++++-------- .../app/src/main/res/values/strings.xml | 5 ++++ 5 files changed, 40 insertions(+), 26 deletions(-) diff --git a/apps/android_rpc/app/build.gradle b/apps/android_rpc/app/build.gradle index 0d5290f110f1..750660bde1b1 100644 --- a/apps/android_rpc/app/build.gradle +++ b/apps/android_rpc/app/build.gradle @@ -52,6 +52,12 @@ tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn buildJni } +gradle.projectsEvaluated { + tasks.withType(JavaCompile) { + options.compilerArgs << "-Xlint:deprecation" + } +} + android { compileSdkVersion 31 defaultConfig { @@ -75,13 +81,11 @@ android { } } - gradle.taskGraph.whenReady {graph -> - def tasks = graph.getAllTasks() - tasks.each {task -> - def name = task.getName() - if (name.contains("lint")) task.setEnabled(false) + lintOptions { + disable "Instantiatable" // MainActivity and RPCActivity must extend android.app.Activity + disable "MissingClass" // .RPCWatchdogService was not found in the project or the libraries + disable "IconDipSize" // The image ic_launcher.png varies significantly in its density-independent size } - } } dependencies { diff --git a/apps/android_rpc/app/src/main/AndroidManifest.xml b/apps/android_rpc/app/src/main/AndroidManifest.xml index 4a7ba917dad0..217dbb859a76 100644 --- a/apps/android_rpc/app/src/main/AndroidManifest.xml +++ b/apps/android_rpc/app/src/main/AndroidManifest.xml @@ -23,19 +23,18 @@ under the License. package="org.apache.tvm.tvmrpc" > - + android:icon="@mipmap/ic_launcher"> + android:screenOrientation="unspecified" + android:exported="true"> @@ -49,7 +48,7 @@ under the License. android:process=":RPCProcess" android:label="@string/rpc_name" android:theme="@style/AppTheme.NoActionBar" - android:screenOrientation="portrait"> + android:screenOrientation="unspecified"> diff --git a/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/MainActivity.java b/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/MainActivity.java index 26d553b59fd4..f28507b46f8e 100644 --- a/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/MainActivity.java +++ b/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/MainActivity.java @@ -29,7 +29,7 @@ import androidx.appcompat.widget.Toolbar; import android.widget.CompoundButton; import android.widget.EditText; -import android.widget.Switch; +import androidx.appcompat.widget.SwitchCompat; import android.content.Intent; @@ -56,7 +56,7 @@ public Intent updateRPCPrefs() { EditText edProxyAddress = findViewById(R.id.input_address); EditText edProxyPort = findViewById(R.id.input_port); EditText edAppKey = findViewById(R.id.input_key); - Switch inputSwitch = findViewById(R.id.switch_persistent); + SwitchCompat inputSwitch = findViewById(R.id.switch_persistent); final String proxyHost = edProxyAddress.getText().toString(); final int proxyPort = Integer.parseInt(edProxyPort.getText().toString()); @@ -80,7 +80,7 @@ public Intent updateRPCPrefs() { private void setupRelaunch() { final Context context = this; - final Switch switchPersistent = findViewById(R.id.switch_persistent); + final SwitchCompat switchPersistent = findViewById(R.id.switch_persistent); final Runnable rPCStarter = new Runnable() { public void run() { if (switchPersistent.isChecked()) { @@ -90,7 +90,8 @@ public void run() { } } }; - Handler handler = new Handler(); + + Handler handler = new Handler(Looper.getMainLooper()); handler.postDelayed(rPCStarter, HANDLER_RESTART_DELAY); } @@ -102,7 +103,7 @@ protected void onCreate(Bundle savedInstanceState) { setSupportActionBar(toolbar); final Context context = this; - Switch switchPersistent = findViewById(R.id.switch_persistent); + SwitchCompat switchPersistent = findViewById(R.id.switch_persistent); switchPersistent.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { @@ -137,7 +138,7 @@ private void enableInputView(boolean enable) { EditText edProxyAddress = findViewById(R.id.input_address); EditText edProxyPort = findViewById(R.id.input_port); EditText edAppKey = findViewById(R.id.input_key); - Switch input_switch = findViewById(R.id.switch_persistent); + SwitchCompat input_switch = findViewById(R.id.switch_persistent); edProxyAddress.setEnabled(enable); edProxyPort.setEnabled(enable); edAppKey.setEnabled(enable); diff --git a/apps/android_rpc/app/src/main/res/layout/content_main.xml b/apps/android_rpc/app/src/main/res/layout/content_main.xml index d6eff2b06383..483f60a72170 100644 --- a/apps/android_rpc/app/src/main/res/layout/content_main.xml +++ b/apps/android_rpc/app/src/main/res/layout/content_main.xml @@ -38,6 +38,7 @@ under the License. - + diff --git a/apps/android_rpc/app/src/main/res/values/strings.xml b/apps/android_rpc/app/src/main/res/values/strings.xml index 72c19cd4e5b0..960e5a3b92a7 100644 --- a/apps/android_rpc/app/src/main/res/values/strings.xml +++ b/apps/android_rpc/app/src/main/res/values/strings.xml @@ -31,6 +31,11 @@ under the License. Key Enable RPC + 192.168.1.1 + 9190 + android + + Enabled Disabled From 433d65bcb75ba34fc307402cf844bd3765b7ea5d Mon Sep 17 00:00:00 2001 From: Kirill Snezhko <4477094+argrento@users.noreply.github.com> Date: Mon, 4 Apr 2022 18:23:13 +0300 Subject: [PATCH 04/12] [android_deploy] Support latest gradle, bump versions, fix linter errors, disable some of them --- apps/android_deploy/app/build.gradle | 60 ++++++++++++++----- .../android_deploy/app/download-models.gradle | 2 +- .../app/src/main/AndroidManifest.xml | 9 ++- .../apache/tvm/android/demo/MainActivity.java | 10 ++-- apps/android_deploy/app/src/main/jni/build.sh | 26 -------- .../app/src/main/res/layout/activity_main.xml | 37 ++++++------ .../app/src/main/res/layout/content_main.xml | 7 ++- .../app/src/main/res/values/strings.xml | 2 + apps/android_deploy/build.gradle | 8 +-- apps/android_deploy/gradle.properties | 2 + apps/android_rpc/app/build.gradle | 10 ++-- 11 files changed, 92 insertions(+), 81 deletions(-) delete mode 100644 apps/android_deploy/app/src/main/jni/build.sh diff --git a/apps/android_deploy/app/build.gradle b/apps/android_deploy/app/build.gradle index c00528ba49fd..d79d0055b740 100644 --- a/apps/android_deploy/app/build.gradle +++ b/apps/android_deploy/app/build.gradle @@ -26,8 +26,35 @@ apply from: "download-models.gradle" apply plugin: 'com.android.application' +task generateJniHeaders(type: Exec, description: 'Generate JNI Headers') { + def headerPath = "${project.projectDir}/src/main/jni" + def classPath = "${project.projectDir}/../../../jvm/core/target/*" + def filePath = "${project.projectDir}/../../../jvm/core/src/main/java/org/apache/tvm/LibInfo.java" + commandLine "javac", "-h", headerPath, "-classpath", classPath, filePath + doLast { + file("${headerPath}/org_apache_tvm_LibInfo.h").renameTo(file("${headerPath}/org_apache_tvm_native_c_api.h")) + } +} + +task copyFiles(type: Copy, description: 'Copy Sources for ndk-build') { + dependsOn "generateJniHeaders" + def ndkFilesPath = "${project.projectDir}/../../../jvm/native/src/main/native" + def srcPath = "${project.projectDir}/src/main/jni/" + + from "${ndkFilesPath}/org_apache_tvm_native_c_api.cc", "${ndkFilesPath}/jni_helper_func.h" + into srcPath +} + +task deleteLibs(type: Delete, description: "Delete Compiled Libraries") { + dependsOn "copyFiles" + def libsPath = "${project.projectDir}/src/main/libs" + delete libsPath +} + task buildJni(type: Exec, description: 'Build JNI libs') { - commandLine 'sh', 'src/main/jni/build.sh' + dependsOn "deleteLibs" + def buildPath = "${project.projectDir}/src/main/jni" + commandLine "ndk-build", "--directory", buildPath } tasks.withType(JavaCompile) { @@ -35,11 +62,10 @@ tasks.withType(JavaCompile) { } android { - compileSdkVersion 26 - buildToolsVersion "26.0.1" + compileSdkVersion 31 defaultConfig { - applicationId "org.apache.tvm.android.demo" - minSdkVersion 17 + applicationId "org.apache.tvm.tvmrpc" + minSdkVersion 24 targetSdkVersion 26 versionCode 1 versionName "1.0" @@ -55,19 +81,25 @@ android { main { jni.srcDirs = [] jniLibs.srcDirs = ['src/main/libs'] - assets.srcDirs = [project.ext.ASSET_DIR] } } + + lintOptions { + disable "Instantiatable" // MainActivity and RPCActivity must extend android.app.Activity + disable "MissingApplicationIcon" // Should explicitly set android:icon, there is no default + disable "UnsafeNativeCodeLocation" // Shared libraries should not be placed in the res or assets directories. + + } } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + implementation fileTree(dir: 'libs', include: ['*.jar']) + androidTestImplementation('com.android.support.test.espresso:espresso-core:3.4.0', { exclude group: 'com.android.support', module: 'support-annotations' }) - compile 'com.android.support:appcompat-v7:26.0.1' - compile 'com.android.support.constraint:constraint-layout:1.0.2' - compile 'com.android.support:design:26.0.1' - compile 'org.apache.tvm:tvm4j-core:0.0.1-SNAPSHOT' - testCompile 'junit:junit:4.12' -} + implementation 'androidx.appcompat:appcompat:1.4.1' + implementation 'com.android.support.constraint:constraint-layout:2.1.3' + implementation 'com.android.support:design:28.0.0' + implementation 'org.apache.tvm:tvm4j-core:0.0.1-SNAPSHOT' + testImplementation 'junit:junit:4.13.2' +} \ No newline at end of file diff --git a/apps/android_deploy/app/download-models.gradle b/apps/android_deploy/app/download-models.gradle index ed660e0221ee..4d1620bfd953 100644 --- a/apps/android_deploy/app/download-models.gradle +++ b/apps/android_deploy/app/download-models.gradle @@ -34,7 +34,7 @@ buildscript { jcenter() } dependencies { - classpath 'de.undercouch:gradle-download-task:3.2.0' + classpath 'de.undercouch:gradle-download-task:5.0.4' } } diff --git a/apps/android_deploy/app/src/main/AndroidManifest.xml b/apps/android_deploy/app/src/main/AndroidManifest.xml index bf3463f4d9c6..ce1b1fac4552 100644 --- a/apps/android_deploy/app/src/main/AndroidManifest.xml +++ b/apps/android_deploy/app/src/main/AndroidManifest.xml @@ -25,6 +25,7 @@ under the License. + + android:exported="true" + android:screenOrientation="unspecified"> @@ -52,6 +53,4 @@ under the License. - - diff --git a/apps/android_deploy/app/src/main/java/org/apache/tvm/android/demo/MainActivity.java b/apps/android_deploy/app/src/main/java/org/apache/tvm/android/demo/MainActivity.java index 85cc7a277b4d..6320b6aa8afd 100644 --- a/apps/android_deploy/app/src/main/java/org/apache/tvm/android/demo/MainActivity.java +++ b/apps/android_deploy/app/src/main/java/org/apache/tvm/android/demo/MainActivity.java @@ -35,9 +35,9 @@ import android.os.Environment; import android.os.SystemClock; import android.provider.MediaStore; -import android.support.v4.content.FileProvider; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; +import androidx.core.content.FileProvider; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; import android.util.Log; import android.view.View; import android.widget.ImageView; @@ -51,6 +51,7 @@ import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.Locale; import java.util.Vector; import org.apache.tvm.Function; @@ -487,7 +488,7 @@ private final String getTempLibFilePath(String fileName) throws IOException { */ private File createImageFile() { // Create an image file name - String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); + String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date()); String imageFileName = "JPEG_" + timeStamp + "_"; File storageDir = Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES); @@ -527,6 +528,7 @@ public void onClick(DialogInterface dialog, int id) { @Override public void onRequestPermissionsResult (final int requestCode, final String[] permissions, final int[] grantResults){ + super.onRequestPermissionsResult(requestCode, permissions, grantResults); if (requestCode == PERMISSIONS_REQUEST) { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED diff --git a/apps/android_deploy/app/src/main/jni/build.sh b/apps/android_deploy/app/src/main/jni/build.sh deleted file mode 100644 index 001d206ffd5d..000000000000 --- a/apps/android_deploy/app/src/main/jni/build.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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 -# -# http://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. -PATH="$PATH:/usr/local/bin" -CURR_DIR=$(cd `dirname $0`; pwd) -ROOT_DIR="$CURR_DIR/../../../../../.." -javac -h $CURR_DIR -classpath "$ROOT_DIR/jvm/core/target/*" $ROOT_DIR/jvm/core/src/main/java/org/apache/tvm/LibInfo.java || exit -1 -mv $CURR_DIR/org_apache_tvm_LibInfo.h $CURR_DIR/org_apache_tvm_native_c_api.h -cp -f $ROOT_DIR/jvm/native/src/main/native/org_apache_tvm_native_c_api.cc $CURR_DIR/ || exit -1 -cp -f $ROOT_DIR/jvm/native/src/main/native/jni_helper_func.h $CURR_DIR/ || exit -1 -rm -rf $CURR_DIR/../libs -ndk-build --directory=$CURR_DIR diff --git a/apps/android_deploy/app/src/main/res/layout/activity_main.xml b/apps/android_deploy/app/src/main/res/layout/activity_main.xml index 0778374223d8..4b019e1fbdb3 100644 --- a/apps/android_deploy/app/src/main/res/layout/activity_main.xml +++ b/apps/android_deploy/app/src/main/res/layout/activity_main.xml @@ -19,29 +19,28 @@ specific language governing permissions and limitations under the License. --> - - - + android:layout_height="match_parent" + tools:context="org.apache.tvm.tvmrpc.MainActivity"> - + android:theme="@style/AppTheme.AppBarOverlay"> - + - + - + + diff --git a/apps/android_deploy/app/src/main/res/layout/content_main.xml b/apps/android_deploy/app/src/main/res/layout/content_main.xml index aa1b0ea72b3e..6bf3c19f7f81 100644 --- a/apps/android_deploy/app/src/main/res/layout/content_main.xml +++ b/apps/android_deploy/app/src/main/res/layout/content_main.xml @@ -35,10 +35,10 @@ under the License.