2025-06-27 V1.1.0

- *.[新增]支持开启和暂停监控。
- *.[改进]忽略米家app手表连接的消息。
- *.[改进]忽略滴滴出行的天气提醒。
This commit is contained in:
紫林软件 2025-06-27 11:14:58 +08:00
parent 36d068baf1
commit 99ae79d96e
22 changed files with 2087 additions and 222 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="CompilerConfiguration"> <component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" /> <bytecodeTargetLevel target="21" />
</component> </component>
</project> </project>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetSelector">
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
</selectionStates>
</component>
</project>

View File

@ -4,16 +4,16 @@
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<option name="testRunner" value="PLATFORM" /> <option name="testRunner" value="CHOOSE_PER_TEST" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
<option name="modules"> <option name="modules">
<set> <set>
<option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" /> <option value="$PROJECT_DIR$/app" />
</set> </set>
</option> </option>
<option name="resolveModulePerSourceSet" value="false" /> <option name="resolveExternalAnnotations" value="false" />
</GradleProjectSettings> </GradleProjectSettings>
</option> </option>
</component> </component>

View File

@ -21,5 +21,10 @@
<option name="name" value="Google" /> <option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" /> <option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository> </remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
</component> </component>
</project> </project>

10
.idea/migrations.xml Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectMigrations">
<option name="MigrateToGradleLocalJavaHome">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</component>
</project>

View File

@ -1,6 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK"> <component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
<entry key="..\:/My Datas/My Codes/android code/TellMeNotice/app/src/main/res/layout/activity_main.xml" value="0.33" />
<entry key="..\:/My Datas/My Codes/android code/TellMeNotice/app/src/main/res/layout/float_tip.xml" value="0.18489583333333334" />
</map>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
</set>
</option>
</component>
</project>

View File

@ -1,12 +1,27 @@
#### 2025-06-27 V1.1.0
- *.[新增]支持开启和暂停监控。
- *.[改进]忽略米家app手表连接的消息。
- *.[改进]忽略滴滴出行的天气提醒。
#### 2022-11-17 V1.0.4
- *.[改进]优化米家提醒,短时间内的批量提醒不再重复提示音。
- *.[改进]楼下按门铃提醒的弹窗标题和内容进行对调。
- *.[改进]过滤哈啰顺风车某些不重要提醒。
#### 2020-12-21 V1.0.2 #### 2020-12-21 V1.0.2
- *.[新增]新增微信红包提醒 - *.[新增]新增微信红包提醒
- *.[改进]更全面的识别淘口令。 - *.[改进]更全面的识别淘口令。
- *.[改进]更全面的识别快递签收提醒。 - *.[改进]更全面的识别快递签收提醒。
#### 2020-12-18 V1.0.1 #### 2020-12-18 V1.0.1
- *.[新增]支持通过wifi名称来判断是否在上班。 - *.[新增]支持通过wifi名称来判断是否在上班。
- *.[新增]增加游戏模式(尚未完成)。 - *.[新增]增加游戏模式(尚未完成)。
- *.[改进]不连公司wifi的情况下个性化购物和淘口令声音。 - *.[改进]不连公司wifi的情况下个性化购物和淘口令声音。
#### 2020-11-28 V1.0 #### 2020-11-28 V1.0
- 暂无。 - 暂无。

View File

@ -3,15 +3,15 @@ plugins {
} }
android { android {
compileSdkVersion 29 compileSdkVersion 31
buildToolsVersion "30.0.2"
defaultConfig { defaultConfig {
applicationId "com.itrycn.tellmenotice" applicationId "com.itrycn.tellmenotice"
minSdkVersion 23 minSdkVersion 28
targetSdkVersion 29 //noinspection EditedTargetSdkVersion
versionCode 3 targetSdkVersion 28
versionName "1.0.2" versionCode 9
versionName "1.1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
@ -26,16 +26,16 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
namespace 'com.itrycn.tellmenotice'
} }
dependencies { dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1' implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1' implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'com.jakewharton:butterknife:8.8.1' implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.qmuiteam:qmui:2.0.0-alpha10' implementation 'com.qmuiteam:qmui:2.0.1'
def qmui_arch_version = '2.0.0-alpha10' def qmui_arch_version = '2.0.1'
implementation "com.qmuiteam:arch:$qmui_arch_version" implementation "com.qmuiteam:arch:$qmui_arch_version"
testImplementation 'junit:junit:4.+' testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.ext:junit:1.1.2'

View File

@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android">
package="com.itrycn.tellmenotice">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" /> <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
@ -14,6 +15,13 @@
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<!--如果是安卓10.0需要后台获取连接的wifi名称则添加进程获取位置信息权限 --> <!--如果是安卓10.0需要后台获取连接的wifi名称则添加进程获取位置信息权限 -->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<!-- 允许应用程序发现和配对蓝牙设备 -->
<uses-permission android:name="android.permission.BLUETOOTH_ADACCESS_FINE_LOCATIONMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<!-- 允许应用程序连接到已配对的蓝牙设备并进行数据传输 -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<!-- 允许应用发起对蓝牙设备的连接 -->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<application <application
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
@ -23,7 +31,8 @@
android:supportsRtl="true" android:supportsRtl="true"
android:usesCleartextTraffic="true" android:usesCleartextTraffic="true"
android:theme="@style/Theme.TellMeNotice"> android:theme="@style/Theme.TellMeNotice">
<activity android:name=".MainActivity" android:process=":BackgroundService"> <activity android:name=".MainActivity" android:process=":BackgroundService"
android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -35,7 +44,8 @@
android:excludeFromRecents="true" android:excludeFromRecents="true"
android:launchMode="singleTask" android:launchMode="singleTask"
android:process=":BackgroundService" android:process=":BackgroundService"
android:taskAffinity="com.open.helper" /> android:taskAffinity="com.open.helper"
android:exported="true"/>
<receiver android:name=".BootBroadcastReceiver" <receiver android:name=".BootBroadcastReceiver"
android:enabled="true" android:enabled="true"
android:exported="true" android:exported="true"
@ -55,7 +65,8 @@
android:name=".NoticeService" android:name=".NoticeService"
android:priority="1000" android:priority="1000"
android:label="通知监控" android:label="通知监控"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"> android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"
android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.service.notification.NotificationListenerService" /> <action android:name="android.service.notification.NotificationListenerService" />
</intent-filter> </intent-filter>

View File

@ -2,6 +2,8 @@ package com.itrycn.tellmenotice;
import android.app.Notification; import android.app.Notification;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PixelFormat; import android.graphics.PixelFormat;
@ -99,6 +101,15 @@ public class FloatView implements View.OnTouchListener {
TextView idPostTime = view.findViewById(R.id.IdPostTime); TextView idPostTime = view.findViewById(R.id.IdPostTime);
idTitle.setText(Title); idTitle.setText(Title);
idContent.setText(Content); idContent.setText(Content);
idContent.setOnClickListener(v -> {
try {
ClipboardManager clipboard = (ClipboardManager)mContext.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setPrimaryClip(ClipData.newPlainText(null,Content));
} catch (Exception e) {
Toast.makeText(mContext, "复制出错->"+e.getMessage(), Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
});
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");// HH:mm:ss SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");// HH:mm:ss
//获取当前时间 //获取当前时间
Date date = new Date(System.currentTimeMillis()); Date date = new Date(System.currentTimeMillis());

View File

@ -3,18 +3,24 @@ package com.itrycn.tellmenotice;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import android.annotation.SuppressLint;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color; import android.graphics.Color;
import android.media.AudioManager; import android.media.AudioManager;
import android.net.Uri; import android.net.Uri;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.Settings; import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -23,7 +29,6 @@ import com.itrycn.ta.OpenAccessibilitySettingHelper;
import com.qmuiteam.qmui.util.QMUIStatusBarHelper; import com.qmuiteam.qmui.util.QMUIStatusBarHelper;
import com.qmuiteam.qmui.widget.QMUITopBar; import com.qmuiteam.qmui.widget.QMUITopBar;
import com.qmuiteam.qmui.widget.QMUITopBarLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout;
import java.util.Calendar; import java.util.Calendar;
import butterknife.BindView; import butterknife.BindView;
@ -36,9 +41,12 @@ public class MainActivity extends AppCompatActivity {
* *
*/ */
public static Context mContext; public static Context mContext;
private SharedPreferences sharedPreferences;
@SuppressLint("SetTextI18n")
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
// 沉浸式状态栏 // 沉浸式状态栏
//QMUIStatusBarHelper.translucent(this); //QMUIStatusBarHelper.translucent(this);
//初始化状态栏 //初始化状态栏
@ -67,6 +75,27 @@ public class MainActivity extends AppCompatActivity {
"1.帮你监控系统通知,自动筛选重要通知。\n" + "1.帮你监控系统通知,自动筛选重要通知。\n" +
"2.不同通知展现不同的提醒界面和声音。\n" + "2.不同通知展现不同的提醒界面和声音。\n" +
"3.支持免打扰功能,深夜自动免打扰。"); "3.支持免打扰功能,深夜自动免打扰。");
Button btn=findViewById(R.id.BtnStartMon);
btn.setText("开启游戏模式");
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean GameMode=sharedPreferences.getBoolean("GameMode", false);
if(sharedPreferences.getBoolean("GameMode", false))
{
sharedPreferences.edit().putBoolean("GameMode", false).apply();
btn.setText("开启游戏模式");
}
else{
sharedPreferences.edit().putBoolean("GameMode", true).apply();
btn.setText("关闭游戏模式");
}
Intent intent = new Intent("com.itrycn.notice.ACTION_SEND_MESSAGE");
intent.putExtra("mode", "notice");
intent.putExtra("GameMode", !GameMode);
sendBroadcast(intent);
}
});
ScreenListener screenlistener = new ScreenListener(this); ScreenListener screenlistener = new ScreenListener(this);
screenlistener.begin(new ScreenListener.ScreenStateListener() { screenlistener.begin(new ScreenListener.ScreenStateListener() {
@ -89,16 +118,35 @@ public class MainActivity extends AppCompatActivity {
AudioManager audioManager = (AudioManager) MainActivity.this.getSystemService(Context.AUDIO_SERVICE); AudioManager audioManager = (AudioManager) MainActivity.this.getSystemService(Context.AUDIO_SERVICE);
int NoticeVolume= audioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION); int NoticeVolume= audioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION);
int NoticeMaxVolume= audioManager.getStreamMaxVolume(AudioManager.STREAM_NOTIFICATION); int NoticeMaxVolume= audioManager.getStreamMaxVolume(AudioManager.STREAM_NOTIFICATION);
if(NoticeVolume<100) int NoticeMinVolume= audioManager.getStreamMinVolume(AudioManager.STREAM_NOTIFICATION);
if(getWifiName().indexOf("当游")>=0) { //当连接到公司wifi
if(hour==12 || hour==13)
{ {
audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, 100, AudioManager.FLAG_VIBRATE); //audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, NoticeMinVolume, AudioManager.FLAG_PLAY_SOUND);
}
else {
//audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, NoticeMinVolume+(NoticeMaxVolume-NoticeMinVolume)/2, AudioManager.FLAG_PLAY_SOUND);
}
}
else {
if (NoticeVolume < 100) {
//audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, NoticeMinVolume+(NoticeMaxVolume-NoticeMinVolume)*3/4, AudioManager.FLAG_PLAY_SOUND);
}
} }
//endregion //endregion
//Log.e("onScreenOff", "onScreenOff"); //Log.e("onScreenOff", "onScreenOff");
} }
}); });
} }
/**
* 获取wifi名称(必须要有GPS定位权限)
*/
private String getWifiName()
{
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
return wifiInfo.getSSID();
}
private void initTopBar() { private void initTopBar() {
mTopBar.setBackgroundColor(ContextCompat.getColor(this, R.color.app_color_theme_4)); mTopBar.setBackgroundColor(ContextCompat.getColor(this, R.color.app_color_theme_4));
mTopBar.addRightImageButton(R.drawable.menu,R.id.menu).setOnClickListener(new View.OnClickListener() { mTopBar.addRightImageButton(R.drawable.menu,R.id.menu).setOnClickListener(new View.OnClickListener() {
@ -122,7 +170,7 @@ public class MainActivity extends AppCompatActivity {
protected void onStart() { protected void onStart() {
if(!AccessibilityOperator.getInstance().isServiceRunning()) if(!AccessibilityOperator.getInstance().isServiceRunning())
{ {
Toast.makeText(this,"辅助服务没有在运行。", Toast.LENGTH_SHORT).show(); //Toast.makeText(this,"辅助服务没有在运行。", Toast.LENGTH_SHORT).show();
} }
super.onStart(); super.onStart();
} }

View File

@ -1,14 +1,23 @@
package com.itrycn.tellmenotice; package com.itrycn.tellmenotice;
import android.Manifest;
import android.app.Activity; import android.app.Activity;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.Application; import android.app.Application;
import android.app.Notification; import android.app.Notification;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.Service; import android.app.Service;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PixelFormat; import android.graphics.PixelFormat;
import android.graphics.drawable.Icon; import android.graphics.drawable.Icon;
@ -23,6 +32,9 @@ import android.net.wifi.WifiManager;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
import android.os.Messenger;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.provider.Settings; import android.provider.Settings;
import android.service.notification.NotificationListenerService; import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification; import android.service.notification.StatusBarNotification;
@ -40,7 +52,10 @@ import android.widget.RemoteViews;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.core.app.ActivityCompat;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
@ -48,16 +63,31 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
public class NoticeService extends NotificationListenerService { public class NoticeService extends NotificationListenerService {
public static boolean isStarted = false; public static boolean isStarted = false;
public static String CurPackageName = ""; public static String CurPackageName = "";
private WindowManager windowManager; private WindowManager windowManager;
private WindowManager.LayoutParams layoutParams; private WindowManager.LayoutParams layoutParams;
private boolean gameMode=false;
private final BroadcastReceiver messageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if ("com.itrycn.notice.ACTION_SEND_MESSAGE".equals(intent.getAction())) {
gameMode = intent.getBooleanExtra("GameMode",false);
// 处理收到的消息
}
}
};
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
isStarted = true; isStarted = true;
IntentFilter filter = new IntentFilter("com.itrycn.notice.ACTION_SEND_MESSAGE");
registerReceiver(messageReceiver, filter);
//配置声音类型 //配置声音类型
AudioAttributes.Builder builder = new AudioAttributes.Builder(); AudioAttributes.Builder builder = new AudioAttributes.Builder();
builder.setLegacyStreamType(AudioManager.STREAM_NOTIFICATION); builder.setLegacyStreamType(AudioManager.STREAM_NOTIFICATION);
@ -69,14 +99,25 @@ public class NoticeService extends NotificationListenerService {
.setAudioAttributes(builder.build()); .setAudioAttributes(builder.build());
sp = builder2.build(); sp = builder2.build();
MP3_notice = sp.load(this,R.raw.notice,1); MP3_notice = sp.load(this, R.raw.notice, 1);
MP3_mm= sp.load(this,R.raw.chattip,1); MP3_mm = sp.load(this, R.raw.chattip, 1);
MP3_Ring= sp.load(this,R.raw.ring,1); MP3_Ring = sp.load(this, R.raw.ring, 1);
MP3_kuaidi= sp.load(this,R.raw.kuaidi,1); MP3_kuaidi = sp.load(this, R.raw.kuaidi, 1);
MP3_Dingding= sp.load(this,R.raw.dingding,1); MP3_Dingding = sp.load(this, R.raw.dingding, 1);
MP3_TaoCode= sp.load(this,R.raw.taocode,1); MP3_TaoCode = sp.load(this, R.raw.taocode, 1);
MP3_Buy0= sp.load(this,R.raw.buy0,1); MP3_Buy0 = sp.load(this, R.raw.buy0, 1);
MP3_RedPacket= sp.load(this,R.raw.redpacket,1); MP3_RedPacket = sp.load(this, R.raw.redpacket, 1);
sp.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
@Override
public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
// 音频加载完成后的处理
AudioManager audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
//int NoticeVolume= audioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION);
//int NoticeMaxVolume= audioManager.getStreamMaxVolume(AudioManager.STREAM_NOTIFICATION);
//int NoticeMinVolume= audioManager.getStreamMinVolume(AudioManager.STREAM_NOTIFICATION);
audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, NoticeVolume, AudioManager.FLAG_PLAY_SOUND);
}
});
//windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); //windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
//layoutParams = new WindowManager.LayoutParams(); //layoutParams = new WindowManager.LayoutParams();
//if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { //if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
@ -92,6 +133,7 @@ public class NoticeService extends NotificationListenerService {
// layoutParams.x = 300; // layoutParams.x = 300;
// layoutParams.y = 300; // layoutParams.y = 300;
} }
@Override @Override
public void onDestroy() { public void onDestroy() {
sp.unload(MP3_notice); sp.unload(MP3_notice);
@ -102,8 +144,10 @@ public class NoticeService extends NotificationListenerService {
sp.unload(MP3_TaoCode); sp.unload(MP3_TaoCode);
sp.unload(MP3_Buy0); sp.unload(MP3_Buy0);
sp.unload(MP3_RedPacket); sp.unload(MP3_RedPacket);
unregisterReceiver(messageReceiver);
super.onDestroy(); super.onDestroy();
} }
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
Log.i("KEVIN", "Service is started" + "-----"); Log.i("KEVIN", "Service is started" + "-----");
@ -111,6 +155,7 @@ public class NoticeService extends NotificationListenerService {
//data = intent.getStringExtra("data"); //data = intent.getStringExtra("data");
return super.onStartCommand(intent, flags, startId); return super.onStartCommand(intent, flags, startId);
} }
SoundPool sp; SoundPool sp;
int MP3_notice; int MP3_notice;
int MP3_mm; int MP3_mm;
@ -120,10 +165,63 @@ public class NoticeService extends NotificationListenerService {
int MP3_TaoCode; int MP3_TaoCode;
int MP3_Buy0; int MP3_Buy0;
int MP3_RedPacket; int MP3_RedPacket;
String Last_packageName=""; String Last_packageName = "";
String Last_Title=""; String Last_Title = "";
String Last_Content=""; String Last_Content = "";
long Last_UpdateTime=0; long Last_UpdateTime = 0;
/**
* 判断给定的设备名称是否已连接经典蓝牙
*
* @param BlueToothName 蓝牙设备名称
* @return
*/
public boolean isConnectClassicBT(String BlueToothName) {
if (TextUtils.isEmpty(BlueToothName)) {
return false;
}
final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
Class<BluetoothAdapter> bluetoothAdapterClass = BluetoothAdapter.class;//得到BluetoothAdapter的Class对象
try {
//是否存在连接的蓝牙设备
Method method = bluetoothAdapterClass.getDeclaredMethod("getConnectionState", (Class[]) null);
//打开权限
method.setAccessible(true);
int state = (int) method.invoke(bluetoothAdapter, (Object[]) null);
if (state == BluetoothAdapter.STATE_CONNECTED) {
Log.d("test", "BluetoothAdapter.STATE_CONNECTED");
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return false;
}
Set<BluetoothDevice> devices = bluetoothAdapter.getBondedDevices();
Log.d("test", "devices:" + devices.size());
for (BluetoothDevice device : devices) {
Method isConnectedMethod = BluetoothDevice.class.getDeclaredMethod("isConnected", (Class[]) null);
method.setAccessible(true);
boolean isConnected = (boolean) isConnectedMethod.invoke(device, (Object[]) null);
if (isConnected) {
{
return BlueToothName.contains(device.getName());
}
} else {
Log.d("test", device.getName() + " connect false(" + device.getAddress() + ")");
}
}
}
return false;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
/** /**
* 播放声音 * 播放声音
* @param SoundId 声音id * @param SoundId 声音id
@ -132,6 +230,7 @@ public class NoticeService extends NotificationListenerService {
*/ */
private void PlaySound(int SoundId,int loop,boolean DNDPlay) private void PlaySound(int SoundId,int loop,boolean DNDPlay)
{ {
float volume=1f;
if(!DNDPlay) //如果该声音未开启免打扰时允许播放,则检查当前是否属于免打扰 if(!DNDPlay) //如果该声音未开启免打扰时允许播放,则检查当前是否属于免打扰
{ {
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance();
@ -140,17 +239,40 @@ public class NoticeService extends NotificationListenerService {
//int day = c.get(Calendar.DAY_OF_MONTH); // 获取当日 //int day = c.get(Calendar.DAY_OF_MONTH); // 获取当日
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); // 获取当前日期的星期,1 表示星期日 2 表示星期一 int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); // 获取当前日期的星期,1 表示星期日 2 表示星期一
int hour = c.get(Calendar.HOUR_OF_DAY); // int hour = c.get(Calendar.HOUR_OF_DAY); //
//int minute = c.get(Calendar.MINUTE); // int minute = c.get(Calendar.MINUTE); //
if(hour>=23 || hour<7) {return; } //23点到早上7点,免打扰时间段 if(hour>=23 || hour<7) {return; } //23点到早上7点,免打扰时间段
AudioManager audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
NoticeVolume= audioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION);
int NoticeMaxVolume= audioManager.getStreamMaxVolume(AudioManager.STREAM_NOTIFICATION);
int NoticeMinVolume= audioManager.getStreamMinVolume(AudioManager.STREAM_NOTIFICATION);
if(getWifiName().indexOf("当游")>=0) { //当连接到公司wifi
if(hour==12 || (hour==13 && minute<=30))
{
return;//是中午,则不播放声音
}
else {
volume=0.3f;//不是中午,音量降低
}
if(NoticeVolume==NoticeMinVolume) {
audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, NoticeMinVolume + Math.round((NoticeMaxVolume - NoticeMinVolume) * 1/(float)2), AudioManager.FLAG_PLAY_SOUND);
}
}
else {
if(NoticeVolume<(NoticeMinVolume+(NoticeMaxVolume-NoticeMinVolume)/2)) {
audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, NoticeMinVolume + Math.round((NoticeMaxVolume - NoticeMinVolume) * 3/(float)4), AudioManager.FLAG_PLAY_SOUND);
}
}
//if(hour>=23 && hour<7) {return; } //if(hour>=23 && hour<7) {return; }
} }
AudioManager audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE); if(isConnectClassicBT("CARKIT"))
int NoticeVolume= audioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION); {
int NoticeMaxVolume= audioManager.getStreamMaxVolume(AudioManager.STREAM_NOTIFICATION); return;
audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, 100, AudioManager.FLAG_VIBRATE); }
sp.play(SoundId, 1f, 1.0f,1,loop,1); sp.play(SoundId, volume, volume,1,loop,1);
//audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, NoticeVolume, AudioManager.FLAG_PLAY_SOUND);
//audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, NoticeVolume, AudioManager.FLAG_VIBRATE); //audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, NoticeVolume, AudioManager.FLAG_VIBRATE);
} }
private int NoticeVolume=0;
//在进程中去寻找当前APP的信息判断是否在前台运行 //在进程中去寻找当前APP的信息判断是否在前台运行
private boolean isAppOnForeground(String packageName) { private boolean isAppOnForeground(String packageName) {
return NoticeService.CurPackageName.equals(packageName); return NoticeService.CurPackageName.equals(packageName);
@ -161,7 +283,9 @@ public class NoticeService extends NotificationListenerService {
{ {
return true; return true;
} }
return false; return gameMode;
// 读取数据
//return sharedPreferences.getBoolean("GameMode", false);
} }
/** /**
* 获取wifi名称(必须要有GPS定位权限) * 获取wifi名称(必须要有GPS定位权限)
@ -173,6 +297,7 @@ public class NoticeService extends NotificationListenerService {
return wifiInfo.getSSID(); return wifiInfo.getSSID();
} }
private long LastDoorRingTime=0; private long LastDoorRingTime=0;
private long MiHomeTipTime=0;
@Override @Override
public void onNotificationPosted(StatusBarNotification sbn) { public void onNotificationPosted(StatusBarNotification sbn) {
// super.onNotificationPosted(sbn); // super.onNotificationPosted(sbn);
@ -293,22 +418,30 @@ public class NoticeService extends NotificationListenerService {
{ {
//region 米家app处理方式 //region 米家app处理方式
if(Title.equals("GroupSummary") ||Content.equals("GroupSummary")){return;}; if(Title.equals("GroupSummary") ||Content.equals("GroupSummary")){return;};
if(Title.contains("按门铃") || Content.contains("按门铃")) if(Title.contains("你有一条新消息") ||Content.contains("你有一条新消息")){return;};
if(Title.contains("与手表米家连接中") ||Content.contains("与手表米家连接中")){return;};
if(Title.contains("设备状态") || Content.contains("设备状态")){return;};
if(Title.contains("楼下有人按门铃") || Content.contains("楼下有人按门铃"))
{ {
if(LastDoorRingTime+60000>=NowTime){return;} //如果1分钟内有新的门铃提醒,则自动忽略 if(LastDoorRingTime+60000>=NowTime){return;} //如果1分钟内有新的门铃提醒,则自动忽略
LastDoorRingTime=c.getTime().getTime(); LastDoorRingTime=c.getTime().getTime();
if(!IsGameMode()) { if(!IsGameMode()) {
FloatView fv = new FloatView(this); FloatView fv = new FloatView(this);
fv.showFloatingWindow(notice, Content, Title, Color.parseColor("#02BD9D")); fv.showFloatingWindow(notice,Title, Content, Color.parseColor("#02BD9D"));
}
if(MiHomeTipTime+5000<NowTime) {
MiHomeTipTime = c.getTime().getTime();
Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
vibrator.vibrate(new long[]{100,10,100,1000}, -1);
PlaySound(MP3_Ring, 1, false);
} }
PlaySound(MP3_Ring,1,false);
haveTip=true; haveTip=true;
} }
else else
{ {
if(!IsGameMode()) { if(!IsGameMode()) {
FloatView fv = new FloatView(this); FloatView fv = new FloatView(this);
if (Title.equals("自动化通知")) { if (Title.equals("自动化通知") || Title.equals("智能通知")) {
fv.showFloatingWindow(notice, Title, Content, Color.parseColor("#02BD9D")); fv.showFloatingWindow(notice, Title, Content, Color.parseColor("#02BD9D"));
} else { } else {
if (Title.length() >= Content.length()) { if (Title.length() >= Content.length()) {
@ -319,7 +452,12 @@ public class NoticeService extends NotificationListenerService {
} }
} }
haveTip=true; haveTip=true;
PlaySound(MP3_Dingding,0,false); if(MiHomeTipTime+5000<NowTime) {
Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
vibrator.vibrate(new long[]{100,10,100,1000}, -1);
MiHomeTipTime = c.getTime().getTime();
PlaySound(MP3_Dingding, 0, false);
}
} }
//endregion //endregion
} }
@ -341,13 +479,39 @@ public class NoticeService extends NotificationListenerService {
} }
//endregion //endregion
} }
else if(packageName.equals("com.jingyao.easybike") //出行 else if(packageName.equals("com.jingyao.easybike") //出行
|| packageName.equals("com.sdu.didi.psnger") //滴滴出行 || packageName.equals("com.sdu.didi.psnger") //滴滴出行
|| packageName.equals("com.didapinche.booking")) //嘀嗒出行 || packageName.equals("com.didapinche.booking")) //嘀嗒出行
{ {
if(Title.contains("正在运行")){return;} if(Title.contains("正在运行")){return;}
if(Title.contains("哈啰顺风车运行中") || Content.contains("哈啰顺风车运行中")){return;} if(Content.contains("正在运行")){return;}
if(Title.contains("顺风车出行中") || Content.contains("顺风车出行中")){return;} if(Title.contains("哈啰顺风车运行中") || Content.contains("哈啰顺风车运行中")|| Content.contains("哈啰出行使用中")){return;}
if(Content.contains("附近有一笔订单")){return;}
if(Title.contains("顺风车出行中") || Content.contains("顺风车出行中") || Content.contains("行程安全保障") || Content.contains("行程录音中")){return;}
if(Content.contains("您有一条消息")){return;}
if(Content.contains("有一条新消息")){return;}
if(Content.contains("您有新的消息")){return;}
if(Content.contains("使用中")){return;}
if(Content.contains("已隐藏敏感")){return;}
if(Title.contains("天气提醒")){return;}
if(packageName.equals("com.jingyao.easybike"))//哈啰出行
{
if(!Title.contains("顺路"))
{
return;
}
}
if(packageName.equals("com.didapinche.booking"))//嘀嗒出行
{
if(!Content.contains("顺路"))
{
return;
}
if(!Title.contains("新订单"))
{
return;
}
}
if(!IsGameMode()) { if(!IsGameMode()) {
//region 如果是顺风车线路 //region 如果是顺风车线路
FloatView fv = new FloatView(this); FloatView fv = new FloatView(this);
@ -385,6 +549,16 @@ public class NoticeService extends NotificationListenerService {
} }
//endregion //endregion
} }
else if(packageName.equals("com.dreame.smartlife")) //追觅
{
if(!IsGameMode()) {
FloatView fv = new FloatView(this);
fv.showFloatingWindow(notice, Title, Content, Color.parseColor("#020202"));
}
PlaySound(MP3_Dingding,0,false);
haveTip=true;
//endregion
}
//else { //else {
// Toast.makeText(this,packageName+"->"+Title+"-"+Content, Toast.LENGTH_SHORT).show(); // Toast.makeText(this,packageName+"->"+Title+"-"+Content, Toast.LENGTH_SHORT).show();
// sp.play(MP3_notice, 1f, 1.0f, 1, 0, 1); // sp.play(MP3_notice, 1f, 1.0f, 1, 0, 1);

View File

@ -0,0 +1,27 @@
package com.itrycn.tellmenotice;
import android.app.Service;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import androidx.annotation.Nullable;
public class SettingService extends Service {
private final Messenger messenger = new Messenger(new IncomingHandler());
private static class IncomingHandler extends Handler {
@Override
public void handleMessage(Message msg) {
// 处理收到的消息
}
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return messenger.getBinder();
}
}

View File

@ -12,12 +12,39 @@
android:layout_height="88dp" android:layout_height="88dp"
android:background="@color/app_color_theme_4" android:background="@color/app_color_theme_4"
android:fitsSystemWindows="true" /> android:fitsSystemWindows="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView <TextView
android:id="@+id/IdState" android:id="@+id/IdState"
android:layout_width="287dp" android:layout_width="287dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="20dp" android:layout_marginStart="20dp"
android:layout_marginTop="95dp" android:layout_marginTop="95dp"
android:text="@string/app_state" /> android:text="@string/app_state" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/BtnStartMon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="关闭监控"/>
</TableRow>
</TableLayout>
</LinearLayout>
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout> </com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>

View File

@ -5,7 +5,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.2.0-alpha15' classpath 'com.android.tools.build:gradle:8.7.2'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
@ -15,6 +15,9 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
google() google()
//maven { url 'https://jitpack.io' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/central' }
jcenter() jcenter()
} }
} }

View File

@ -17,3 +17,6 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=true android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX # Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true android.enableJetifier=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false

Binary file not shown.

View File

@ -1,6 +1,7 @@
#Sat Oct 03 18:50:49 CST 2020
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionUrl=https://services.gradle.org/distributions/gradle-6.7-bin.zip
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

312
gradlew vendored
View File

@ -1,78 +1,130 @@
#!/usr/bin/env sh #!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# 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.
#
# SPDX-License-Identifier: Apache-2.0
#
############################################################################## ##############################################################################
## #
## Gradle start up script for UN*X # Gradle start up script for POSIX generated by Gradle.
## #
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
############################################################################## ##############################################################################
# Attempt to set APP_HOME # Attempt to set APP_HOME
# Resolve links: $0 may be a link # Resolve links: $0 may be a link
PRG="$0" app_path=$0
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do # Need this for daisy-chained symlinks.
ls=`ls -ld "$PRG"` while
link=`expr "$ls" : '.*-> \(.*\)$'` APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
if expr "$link" : '/.*' > /dev/null; then [ -h "$app_path" ]
PRG="$link" do
else ls=$( ls -ld "$app_path" )
PRG=`dirname "$PRG"`"/$link" link=${ls#*' -> '}
fi case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle" # This is normally unused
APP_BASE_NAME=`basename "$0"` # shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
DEFAULT_JVM_OPTS="" APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD=maximum
warn () { warn () {
echo "$*" echo "$*"
} } >&2
die () { die () {
echo echo
echo "$*" echo "$*"
echo echo
exit 1 exit 1
} } >&2
# OS specific support (must be 'true' or 'false'). # OS specific support (must be 'true' or 'false').
cygwin=false cygwin=false
msys=false msys=false
darwin=false darwin=false
nonstop=false nonstop=false
case "`uname`" in case "$( uname )" in #(
CYGWIN* ) CYGWIN* ) cygwin=true ;; #(
cygwin=true Darwin* ) darwin=true ;; #(
;; MSYS* | MINGW* ) msys=true ;; #(
Darwin* ) NONSTOP* ) nonstop=true ;;
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables # IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java" JAVACMD=$JAVA_HOME/jre/sh/java
else else
JAVACMD="$JAVA_HOME/bin/java" JAVACMD=$JAVA_HOME/bin/java
fi fi
if [ ! -x "$JAVACMD" ] ; then if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@ -81,92 +133,120 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi fi
else else
JAVACMD="java" JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
MAX_FD_LIMIT=`ulimit -H -n` case $MAX_FD in #(
if [ $? -eq 0 ] ; then max*)
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
MAX_FD="$MAX_FD_LIMIT" # shellcheck disable=SC2039,SC3045
fi MAX_FD=$( ulimit -H -n ) ||
ulimit -n $MAX_FD warn "Could not query maximum file descriptor limit"
if [ $? -ne 0 ] ; then esac
warn "Could not set maximum file descriptor limit: $MAX_FD" case $MAX_FD in #(
fi '' | soft) :;; #(
else *)
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
fi # shellcheck disable=SC2039,SC3045
fi ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac esac
fi fi
# Escape application args # Collect all arguments for the java command, stacking in reverse order:
save () { # * args from the command line
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done # * the main class name
echo " " # * -classpath
} # * -D...appname settings
APP_ARGS=$(save "$@") # * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# Collect all arguments for the java command, following the shell quoting and substitution rules # For Cygwin or MSYS, switch paths to Windows format before running java
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong JAVACMD=$( cygpath --unix "$JAVACMD" )
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")" # Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@" exec "$JAVACMD" "$@"

78
gradlew.bat vendored
View File

@ -1,4 +1,22 @@
@if "%DEBUG%" == "" @echo off @rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Gradle startup script for Windows @rem Gradle startup script for Windows
@ -9,25 +27,29 @@
if "%OS%"=="Windows_NT" setlocal if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=. if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS= set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if %ERRORLEVEL% equ 0 goto execute
echo. echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. echo location of your Java installation. 1>&2
goto fail goto fail
@ -35,48 +57,36 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto execute
echo. echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. echo location of your Java installation. 1>&2
goto fail goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute :execute
@rem Setup the command line @rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd if %ERRORLEVEL% equ 0 goto mainEnd
:fail :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code! rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 set EXIT_CODE=%ERRORLEVEL%
exit /b 1 if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd :mainEnd
if "%OS%"=="Windows_NT" endlocal if "%OS%"=="Windows_NT" endlocal

1405
hs_err_pid52728.log Normal file

File diff suppressed because it is too large Load Diff