精简应用权限申请,移除不必要的前台服务。
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Mon Mar 16 08:42:47 GMT 2026
|
||||
#Mon Mar 16 18:30:19 GMT 2026
|
||||
stageCount=0
|
||||
libraryProject=
|
||||
baseVersion=15.11
|
||||
publishVersion=15.0.0
|
||||
buildCount=53
|
||||
buildCount=54
|
||||
baseBetaVersion=15.0.1
|
||||
|
||||
@@ -4,10 +4,7 @@
|
||||
package="cc.winboll.studio.autonfc">
|
||||
|
||||
<uses-permission android:name="android.permission.NFC"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.nfc"
|
||||
android:required="true"/>
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package cc.winboll.studio.autonfc.nfc;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -13,12 +9,9 @@ import android.nfc.NfcAdapter;
|
||||
import android.nfc.Tag;
|
||||
import android.nfc.tech.Ndef;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.widget.Toast;
|
||||
|
||||
import cc.winboll.studio.autonfc.MainActivity;
|
||||
import cc.winboll.studio.autonfc.R;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
|
||||
@@ -28,13 +21,11 @@ import java.util.Arrays;
|
||||
public class AutoNFCService extends Service {
|
||||
|
||||
public static final String TAG = "AutoNFCService";
|
||||
private static final int NOTIFICATION_ID = 1001;
|
||||
private static final String CHANNEL_ID = "NFC_SERVICE_CHANNEL";
|
||||
|
||||
// ================= 已修改:更新为 Beta 包名 =================
|
||||
public static final String ACTION_BUILD = "cc.winboll.studio.winboll.termux.NfcTermuxBridgeActivity.ACTION_BUILD";
|
||||
public static final String ACTION_BUILD_VIEW = "cc.winboll.studio.winboll.termux.NfcTermuxBridgeActivity.ACTION_BUILD_VIEW";
|
||||
|
||||
|
||||
private final IBinder mBinder = new LocalBinder();
|
||||
private String mNfcData;
|
||||
private MainActivity mActivity; // 持有 Activity 引用,用于回调
|
||||
@@ -44,7 +35,7 @@ public class AutoNFCService extends Service {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
LogUtils.d(TAG, "onCreate() -> 服务创建");
|
||||
startForeground(NOTIFICATION_ID, buildNotification());
|
||||
// 移除:startForeground(NOTIFICATION_ID, buildNotification());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,7 +55,7 @@ public class AutoNFCService extends Service {
|
||||
@Override
|
||||
public boolean onUnbind(Intent intent) {
|
||||
LogUtils.d(TAG, "onUnbind() -> 服务解绑");
|
||||
stopForeground(true);
|
||||
// 移除:stopForeground(true);
|
||||
stopSelf();
|
||||
return super.onUnbind(intent);
|
||||
}
|
||||
@@ -170,13 +161,6 @@ public class AutoNFCService extends Service {
|
||||
}
|
||||
|
||||
try {
|
||||
// String json = String.format(
|
||||
// "{\"script\":\"%s\",\"args\":[\"%s\"],\"workDir\":null,\"background\":%b,\"resultDir\":null}",
|
||||
// "BuildWinBoLLProject.sh",
|
||||
// nfcData,
|
||||
// action.equals(ACTION_BUILD)
|
||||
// );
|
||||
|
||||
LogUtils.d(TAG, "executeTermuxCommand() -> 发送指令: " + nfcData);
|
||||
|
||||
Intent bridgeIntent = new Intent(action);
|
||||
@@ -208,27 +192,6 @@ public class AutoNFCService extends Service {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private Notification buildNotification() {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, "NFC 后台服务", NotificationManager.IMPORTANCE_LOW);
|
||||
channel.setSound(null, null);
|
||||
channel.setVibrationPattern(null);
|
||||
nm.createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
Intent intent = new Intent(this, MainActivity.class);
|
||||
PendingIntent pi = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
return new Notification.Builder(this)
|
||||
.setChannelId(CHANNEL_ID)
|
||||
.setSmallIcon(R.mipmap.ic_launcher)
|
||||
.setContentTitle("NFC 服务运行中")
|
||||
.setContentText("等待卡片扫描")
|
||||
.setContentIntent(pi)
|
||||
.build();
|
||||
}
|
||||
|
||||
// ========================= Binder =========================
|
||||
public class LocalBinder extends Binder {
|
||||
public AutoNFCService getService() {
|
||||
|
||||
Reference in New Issue
Block a user