From a76ee8f972547363a489c3101bc7247bdfd98edc Mon Sep 17 00:00:00 2001 From: FHT <981964879@qq.com> Date: Thu, 8 Apr 2021 11:22:29 +0800 Subject: [PATCH] 2021.04.08 --- app/build.gradle | 19 +- app/src/main/AndroidManifest.xml | 166 +++++++++--------- .../main/java/com/tt/activity/MainActivity.kt | 3 +- .../java/com/tt/activity/PackageActivity.java | 42 +++++ .../java/com/tt/receiver/BootReceiver.java | 21 +++ .../java/com/tt/receiver/PackageReceiver.java | 21 +++ .../java/com/tt/ttutils/jni/NDKTools.java | 10 ++ .../main/java/com_tt_ttutils_jni_NDKTools.h | 21 +++ app/src/main/jni/main.c | 21 +++ app/src/main/res/layout/activity_package.xml | 9 + gradle.properties | 3 +- 11 files changed, 248 insertions(+), 88 deletions(-) create mode 100644 app/src/main/java/com/tt/activity/PackageActivity.java create mode 100644 app/src/main/java/com/tt/receiver/BootReceiver.java create mode 100644 app/src/main/java/com/tt/receiver/PackageReceiver.java create mode 100644 app/src/main/java/com/tt/ttutils/jni/NDKTools.java create mode 100644 app/src/main/java/com_tt_ttutils_jni_NDKTools.h create mode 100644 app/src/main/jni/main.c create mode 100644 app/src/main/res/layout/activity_package.xml diff --git a/app/build.gradle b/app/build.gradle index fd9af64..f9c0562 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,13 +11,13 @@ def releaseTime() { } android { - compileSdkVersion 29 + compileSdkVersion 30 buildToolsVersion "30.0.1" defaultConfig { applicationId "com.tt.ttutils" - minSdkVersion 14 - targetSdkVersion 29 + minSdkVersion 16 + targetSdkVersion 30 // versionCode 1 // versionName "1.0" multiDexEnabled true @@ -35,6 +35,18 @@ android { JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可. ] } + packagingOptions { + exclude 'META-INF/DEPENDENCIES' + exclude 'META-INF/LICENSE' + exclude 'META-INF/LICENSE.txt' + exclude 'META-INF/license.txt' + exclude 'META-INF/NOTICE' + exclude 'META-INF/NOTICE.txt' + exclude 'META-INF/notice.txt' + exclude 'META-INF/ASL2.0' + //添加 + exclude 'META-INF/rxjava.properties' + } lintOptions { checkReleaseBuilds false @@ -131,6 +143,7 @@ android { dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation 'androidx.core:core-ktx:1.1.0' implementation 'androidx.appcompat:appcompat:1.1.0' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 97f5b0f..c2da994 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,16 +8,10 @@ - - - - - - + android:protectionLevel="signature" /> @@ -26,26 +20,18 @@ - - - - - - - + + - - + - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + - - + tools:replace="android:exported" /> - - - + - - - + - - + android:process=":pushcore" /> + - - - - + + - - - + - - + android:exported="true" /> - + @@ -155,46 +173,34 @@ - - - + - - + android:exported="false" /> - - - - - + android:exported="false" /> + - - - - - + + + + + - - - - - + + - - - - + + + + - - - + - + - - - - - - + + - + android:value="${JPUSH_APPKEY}" /> diff --git a/app/src/main/java/com/tt/activity/MainActivity.kt b/app/src/main/java/com/tt/activity/MainActivity.kt index 3ea535d..5706003 100644 --- a/app/src/main/java/com/tt/activity/MainActivity.kt +++ b/app/src/main/java/com/tt/activity/MainActivity.kt @@ -14,8 +14,9 @@ class MainActivity : AppCompatActivity(), CancelAdapt { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) //截图 - CmdUtil.execute(" screencap -p /sdcard/" + "screen" + System.currentTimeMillis() + ".png") +// CmdUtil.execute(" screencap -p /sdcard/" + "screen" + System.currentTimeMillis() + ".png") textView.setText(DevicesUtils.getSerial()) + } diff --git a/app/src/main/java/com/tt/activity/PackageActivity.java b/app/src/main/java/com/tt/activity/PackageActivity.java new file mode 100644 index 0000000..b0ed77f --- /dev/null +++ b/app/src/main/java/com/tt/activity/PackageActivity.java @@ -0,0 +1,42 @@ +package com.tt.activity; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.content.IntentFilter; +import android.os.Bundle; + +import com.tt.receiver.PackageReceiver; +import com.tt.ttutils.R; + +public class PackageActivity extends AppCompatActivity { + private PackageReceiver packageReceiver; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_package); + register(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + if (null != packageReceiver) { + unregisterReceiver(packageReceiver); + } + } + + private void register() { + if (null == packageReceiver) { + packageReceiver = new PackageReceiver(); + } + IntentFilter filter = new IntentFilter(); + filter.addAction(Intent.ACTION_PACKAGE_ADDED); + filter.addAction(Intent.ACTION_PACKAGE_REPLACED); + filter.addAction(Intent.ACTION_PACKAGE_REMOVED); + filter.addDataScheme("package"); + filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY); + registerReceiver(packageReceiver, filter); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/tt/receiver/BootReceiver.java b/app/src/main/java/com/tt/receiver/BootReceiver.java new file mode 100644 index 0000000..38f7b42 --- /dev/null +++ b/app/src/main/java/com/tt/receiver/BootReceiver.java @@ -0,0 +1,21 @@ +package com.tt.receiver; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +public class BootReceiver extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + // TODO: This method is called when the BroadcastReceiver is receiving + // an Intent broadcast. + //throw new UnsupportedOperationException("Not yet implemented"); + String action = intent.getAction(); + if (action.equals(Intent.ACTION_BOOT_COMPLETED)) { + //自启 + } else if (action.equals(Intent.ACTION_USER_PRESENT)) { + //解锁 + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/tt/receiver/PackageReceiver.java b/app/src/main/java/com/tt/receiver/PackageReceiver.java new file mode 100644 index 0000000..b3d744a --- /dev/null +++ b/app/src/main/java/com/tt/receiver/PackageReceiver.java @@ -0,0 +1,21 @@ +package com.tt.receiver; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +public class PackageReceiver extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + // TODO: This method is called when the BroadcastReceiver is receiving + // an Intent broadcast. + //throw new UnsupportedOperationException("Not yet implemented"); + String action = intent.getAction(); + if (action.equals(Intent.ACTION_PACKAGE_ADDED) + || action.equals(Intent.ACTION_PACKAGE_REPLACED) + || action.equals(Intent.ACTION_PACKAGE_REMOVED)) { + + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/tt/ttutils/jni/NDKTools.java b/app/src/main/java/com/tt/ttutils/jni/NDKTools.java new file mode 100644 index 0000000..1b111e2 --- /dev/null +++ b/app/src/main/java/com/tt/ttutils/jni/NDKTools.java @@ -0,0 +1,10 @@ +package com.tt.ttutils.jni; + +public class NDKTools { + static { + System.loadLibrary("myMeetJni"); + } + + public static native String getStringFromNDK(); + +} diff --git a/app/src/main/java/com_tt_ttutils_jni_NDKTools.h b/app/src/main/java/com_tt_ttutils_jni_NDKTools.h new file mode 100644 index 0000000..babe232 --- /dev/null +++ b/app/src/main/java/com_tt_ttutils_jni_NDKTools.h @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class com_tt_ttutils_jni_NDKTools */ + +#ifndef _Included_com_tt_ttutils_jni_NDKTools +#define _Included_com_tt_ttutils_jni_NDKTools +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: com_tt_ttutils_jni_NDKTools + * Method: getStringFromNDK + * Signature: ()Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_com_tt_ttutils_jni_NDKTools_getStringFromNDK + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/app/src/main/jni/main.c b/app/src/main/jni/main.c new file mode 100644 index 0000000..babe232 --- /dev/null +++ b/app/src/main/jni/main.c @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class com_tt_ttutils_jni_NDKTools */ + +#ifndef _Included_com_tt_ttutils_jni_NDKTools +#define _Included_com_tt_ttutils_jni_NDKTools +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: com_tt_ttutils_jni_NDKTools + * Method: getStringFromNDK + * Signature: ()Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_com_tt_ttutils_jni_NDKTools_getStringFromNDK + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/app/src/main/res/layout/activity_package.xml b/app/src/main/res/layout/activity_package.xml new file mode 100644 index 0000000..97a198f --- /dev/null +++ b/app/src/main/res/layout/activity_package.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 4d15d01..c39c4c4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,4 +18,5 @@ android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official \ No newline at end of file +kotlin.code.style=official +android.useDeprecatedNdk=true \ No newline at end of file