2021.04.08

This commit is contained in:
FHT
2021-04-08 11:22:29 +08:00
parent bea9f1c45c
commit a76ee8f972
11 changed files with 248 additions and 88 deletions

View File

@@ -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'

View File

@@ -8,16 +8,10 @@
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<!-- Required -->
<permission
android:name="${applicationId}.permission.JPUSH_MESSAGE"
android:protectionLevel="signature" />
<!-- Required 一些系统要求的权限,如访问网络等-->
android:protectionLevel="signature" /> <!-- Required 一些系统要求的权限,如访问网络等 -->
<uses-permission android:name="${applicationId}.permission.JPUSH_MESSAGE" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.INTERNET" />
@@ -26,26 +20,18 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!--华为角标-->
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE" />
<!-- Optional for location -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 华为角标 -->
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE" /> <!-- Optional for location -->
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<!-- 用于开启 debug 版本的应用在6.0 系统上 层叠窗口权限 -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <!-- 用于开启 debug 版本的应用在6.0 系统上 层叠窗口权限 -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<!-- Android Q后台定位权限-->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> <!-- Android Q后台定位权限 -->
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<application
android:name="com.tt.base.MyApplication"
android:allowBackup="true"
@@ -54,22 +40,65 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.tt.activity.PackageActivity"></activity>
<receiver
android:name="com.tt.receiver.PackageReceiver"
android:enabled="true"
android:exported="true">
<intent-filter android:priority="1000">
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
<receiver
android:name="com.tt.receiver.BootReceiver"
android:enabled="true"
android:exported="true">
<intent-filter android:priority="1000">
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.BATTERY_CHANGED" />
<action android:name="android.intent.action.BATTERY_LOW" />
<action android:name="android.intent.action.BATTERY_OKAY" />
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
<action android:name="android.intent.action.DATE_CHANGED" />
<action android:name="android.intent.action.ACTION_TIMEZONE_CHANGED" />
<action android:name="android.intent.action.USER_PRESENT" />
<action android:name="android.intent.action.SCREEN_ON" />
<action android:name="android.intent.action.SCREEN_OFF" />
<!-- 测试 -->
<!-- <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" /> -->
<!-- <action android:name="android.hardware.usb.action.USB_ACCESSORY_DETACHED" /> -->
<!-- <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /> -->
<!-- <action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" /> -->
<!-- <action android:name="android.intent.action.MEDIA_MOUNTED" /> -->
<!-- <action android:name="android.intent.action.MEDIA_CHECKING" /> -->
<!-- <action android:name="android.intent.action.MEDIA_UNMOUNTED" /> -->
<!-- <action android:name="android.intent.action.MEDIA_EJECT" /> -->
<!-- <action android:name="android.intent.action.MEDIA_UNMOUNTABLE" /> -->
<!-- <action android:name="android.intent.action.MEDIA_REMOVED" /> -->
<!-- <action android:name="android.intent.action.MEDIA_BAD_REMOVAL" /> -->
<!-- 自定义广播 -->
<action android:name="com.jiaoguanyi.appstore.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity android:name="com.tt.activity.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!---->
<!-- Rich push 核心功能 since 2.0.6-->
</activity> <!-- -->
<!-- Rich push 核心功能 since 2.0.6 -->
<activity
android:name="cn.jpush.android.ui.PopWinActivity"
android:exported="false"
android:theme="@style/MyDialogStyle"
tools:replace="android:exported"></activity>
<!-- Required SDK核心功能-->
tools:replace="android:exported" /> <!-- Required SDK核心功能 -->
<activity
android:name="cn.jpush.android.ui.PushActivity"
android:configChanges="orientation|keyboardHidden"
@@ -82,9 +111,7 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="${applicationId}" />
</intent-filter>
</activity>
<!-- Required SDK 核心功能-->
</activity> <!-- Required SDK 核心功能 -->
<!-- 可配置android:process参数将PushService放在其他进程中 -->
<service
android:name="cn.jpush.android.service.PushService"
@@ -95,16 +122,12 @@
<action android:name="cn.jpush.android.intent.PushService" />
<action android:name="cn.jpush.android.intent.PUSH_TIME" />
</intent-filter>
</service>
<!-- since 3.0.9 Required SDK 核心功能-->
</service> <!-- since 3.0.9 Required SDK 核心功能 -->
<provider
android:name="cn.jpush.android.service.DataProvider"
android:authorities="${applicationId}.DataProvider"
android:exported="false"
android:process=":pushcore" />
<!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 -->
android:process=":pushcore" /> <!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 -->
<!-- 若不启用该功能可删除该组件,或把 enabled 设置成 false App 不会被其他 App 拉起,但会拉起其他的 App。 -->
<service
android:name="cn.jpush.android.service.DaemonService"
@@ -112,12 +135,10 @@
android:exported="true">
<intent-filter>
<action android:name="cn.jpush.android.intent.DaemonService" />
<category android:name="${applicationId}" />
</intent-filter>
</service>
<!-- 可选如果使用静态Activity方式拉起该组件必须声明 -->
</service> <!-- 可选如果使用静态Activity方式拉起该组件必须声明 -->
<activity
android:name="cn.jpush.android.service.DActivity"
android:enabled="true"
@@ -126,22 +147,19 @@
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="cn.jpush.android.intent.DActivity" />
<category android:name="${applicationId}" />
</intent-filter>
</activity>
<!-- since 3.1.0 Required SDK 核心功能-->
</activity> <!-- since 3.1.0 Required SDK 核心功能 -->
<provider
android:name="cn.jpush.android.service.DownloadProvider"
android:authorities="${applicationId}.DownloadProvider"
android:exported="true" />
<!-- Required SDK核心功能-->
android:exported="true" /> <!-- Required SDK核心功能 -->
<receiver
android:name="cn.jpush.android.service.PushReceiver"
android:enabled="true">
<intent-filter android:priority="1000">
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" /> <!--Required 显示通知栏 -->
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" /> <!-- Required 显示通知栏 -->
<category android:name="${applicationId}" />
</intent-filter>
<intent-filter>
@@ -155,46 +173,34 @@
<data android:scheme="package" />
</intent-filter>
</receiver>
<!-- Required SDK核心功能-->
</receiver> <!-- Required SDK核心功能 -->
<receiver
android:name="cn.jpush.android.service.AlarmReceiver"
android:exported="false" />
<!-- 3.5.0新增,用于定时展示功能 -->
android:exported="false" /> <!-- 3.5.0新增,用于定时展示功能 -->
<receiver
android:name="cn.jpush.android.service.SchedulerReceiver"
android:exported="false" />
<!-- 3.6.7 新增,用于负反馈组件 -->
<service android:name="cn.jpush.android.service.MessagingIntentService" />
<!-- User defined. For test only 用户自定义的广播接收器-->
android:exported="false" /> <!-- 3.6.7 新增,用于负反馈组件 -->
<service android:name="cn.jpush.android.service.MessagingIntentService" /> <!-- User defined. For test only 用户自定义的广播接收器 -->
<receiver
android:name="com.tt.sdk.jpush.jpushdemo.MyReceiver"
android:enabled="true">
<intent-filter>
<action android:name="cn.jpush.android.intent.REGISTRATION" /> <!--Required 用户注册SDK的intent-->
<action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /> <!--Required 用户接收SDK消息的intent-->
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> <!--Required 用户接收SDK通知栏信息的intent-->
<action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /> <!--Required 用户打开自定义通知栏的intent-->
<action android:name="cn.jpush.android.intent.CONNECTION" /><!-- 接收网络变化 连接/断开 since 1.6.3 -->
<action android:name="cn.jpush.android.intent.REGISTRATION" /> <!-- Required 用户注册SDK的intent -->
<action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /> <!-- Required 用户接收SDK消息的intent -->
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> <!-- Required 用户接收SDK通知栏信息的intent -->
<action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /> <!-- Required 用户打开自定义通知栏的intent -->
<action android:name="cn.jpush.android.intent.CONNECTION" /> <!-- 接收网络变化 连接/断开 since 1.6.3 -->
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
<!-- User defined. For test only 用户自定义接收消息器,3.0.7开始支持,目前新tag/alias接口设置结果会在该广播接收器对应的方法中回调-->
<!--since 3.3.0 接收JPush相关事件-->
</receiver> <!-- User defined. For test only 用户自定义接收消息器,3.0.7开始支持,目前新tag/alias接口设置结果会在该广播接收器对应的方法中回调 -->
<!-- since 3.3.0 接收JPush相关事件 -->
<receiver android:name="com.tt.sdk.jpush.jpushdemo.PushMessageReceiver">
<intent-filter>
<action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
<category android:name="${applicationId}"></category>
</intent-filter>
</receiver>
<!--since 3.3.0 Required SDK核心功能-->
<category android:name="${applicationId}" />
</intent-filter>
</receiver> <!-- since 3.3.0 Required SDK核心功能 -->
<activity
android:name="cn.jpush.android.service.JNotifyActivity"
android:exported="false"
@@ -203,32 +209,26 @@
tools:replace="android:exported">
<intent-filter>
<action android:name="cn.jpush.android.intent.JNotifyActivity" />
<category android:name="${applicationId}" />
</intent-filter>
</activity>
<!-- since 3.3.0 Required SDK 核心功能-->
</activity> <!-- since 3.3.0 Required SDK 核心功能 -->
<!-- 可配置android:process参数将PushService放在其他进程中 -->
<!--User defined. For test only 继承自cn.jpush.android.service.JCommonService-->
<!-- User defined. For test only 继承自cn.jpush.android.service.JCommonService -->
<service
android:name="com.tt.sdk.jpush.jpushdemo.PushService"
android:process=":pushcore">
<intent-filter>
<action android:name="cn.jiguang.user.service.action" />
</intent-filter>
</service>
<!-- since 3.5.6 新增华硕通道 -->
<receiver android:name="cn.jpush.android.asus.AsusPushMessageReceiver">
</receiver>
<!-- Required . Enable it you can get statistics data with channel -->
</service> <!-- since 3.5.6 新增华硕通道 -->
<receiver android:name="cn.jpush.android.asus.AsusPushMessageReceiver" /> <!-- Required . Enable it you can get statistics data with channel -->
<meta-data
android:name="JPUSH_CHANNEL"
android:value="${JPUSH_CHANNEL}" />
<meta-data
android:name="JPUSH_APPKEY"
android:value="${JPUSH_APPKEY}" />
<!-- </>值来自开发者平台取得的AppKey-->
android:value="${JPUSH_APPKEY}" /> <!-- </>值来自开发者平台取得的AppKey -->
<meta-data
android:name="design_width_in_dp"
android:value="640" />

View File

@@ -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())
}

View File

@@ -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);
}
}

View File

@@ -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)) {
//解锁
}
}
}

View File

@@ -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)) {
}
}
}

View File

@@ -0,0 +1,10 @@
package com.tt.ttutils.jni;
public class NDKTools {
static {
System.loadLibrary("myMeetJni");
}
public static native String getStringFromNDK();
}

View File

@@ -0,0 +1,21 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* 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

21
app/src/main/jni/main.c Normal file
View File

@@ -0,0 +1,21 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* 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

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.tt.activity.PackageActivity">
</androidx.constraintlayout.widget.ConstraintLayout>