Skip to content

Commit f0195fc

Browse files
committed
修改编译和目标版本为31 适配安卓12
1 parent 6ecd99e commit f0195fc

File tree

10 files changed

+92
-68
lines changed

10 files changed

+92
-68
lines changed

app/build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ android {
9696
reset()
9797

9898
// Specifies a list of ABIs that Gradle should create APKs for.
99-
include "armeabi-v7a", "arm64-v8a"
99+
include "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
100100
// include "x86", "armeabi-v7a"
101101

102102
// Specifies that we do not want to also generate a universal APK that includes all ABIs.
@@ -141,7 +141,7 @@ dependencies {
141141
})
142142
kapt 'com.jakewharton:butterknife-compiler:10.2.3'
143143
// Android supports
144-
implementation 'androidx.appcompat:appcompat:1.2.0'
144+
implementation 'androidx.appcompat:appcompat:1.4.0'
145145
implementation 'androidx.cardview:cardview:1.0.0'
146146
implementation 'com.google.android.material:material:1.4.0'
147147
implementation 'androidx.multidex:multidex:2.0.1'
@@ -201,10 +201,10 @@ dependencies {
201201
exclude group: 'com.android.support'
202202
})
203203
// WorkManager
204-
implementation 'androidx.work:work-runtime:2.5.0'
204+
implementation 'androidx.work:work-runtime:2.7.1'
205205
// Android job
206206
implementation 'com.evernote:android-job:1.4.2'
207-
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
207+
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1'
208208
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
209209
// Optional, if you use support library fragments:
210210
debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.3'

app/src/main/AndroidManifest.xml

+57-38
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
package="org.autojs.autojs">
55

66
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
7-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
7+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
8+
tools:ignore="ScopedStorage" />
89
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
910
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
1011
<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT"/>
1112
<uses-permission android:name="android.permission.INTERNET"/>
1213
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
13-
<uses-permission android:name="android.permission.READ_LOGS"/>
14+
<uses-permission android:name="android.permission.READ_LOGS"
15+
tools:ignore="ProtectedPermissions" />
1416
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
1517
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
1618
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
@@ -19,14 +21,14 @@
1921

2022
<!-- 非Auto.js运行必需,不会主动申请,某些脚本可以自行申请-->
2123
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
24+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
2225
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
2326

2427
<!-- Ad SDK Permissions -->
2528
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
2629

2730

2831
<application
29-
xmlns:tools="http://schemas.android.com/tools"
3032
android:name="org.autojs.autojs.App"
3133
android:allowBackup="false"
3234
android:icon="@drawable/autojs_material"
@@ -35,7 +37,8 @@
3537
android:supportsRtl="true"
3638
android:theme="@style/AppTheme"
3739
android:usesCleartextTraffic="true"
38-
tools:replace="android:label, android:icon, android:allowBackup">
40+
tools:replace="android:label, android:icon, android:allowBackup"
41+
tools:targetApi="m">
3942

4043
<meta-data
4144
android:name="android.max_aspect"
@@ -45,7 +48,8 @@
4548
android:name="org.autojs.autojs.ui.splash.SplashActivity"
4649
android:hardwareAccelerated="true"
4750
android:label="@string/app_name"
48-
android:theme="@style/AppTheme.Splash">
51+
android:theme="@style/AppTheme.Splash"
52+
android:exported="true">
4953
<intent-filter>
5054
<category android:name="android.intent.category.LAUNCHER"/>
5155

@@ -57,12 +61,14 @@
5761
android:hardwareAccelerated="true"
5862
android:label="@string/app_name"
5963
android:launchMode="singleTask"
60-
android:theme="@style/AppTheme.FullScreen">
64+
android:theme="@style/AppTheme.FullScreen"
65+
android:exported="true">
6166
</activity>
6267
<activity
6368
android:name="org.autojs.autojs.external.shortcut.ShortcutActivity"
6469
android:taskAffinity="org.autojs.autojs.external.shortcut.ShortcutActivity"
65-
android:theme="@android:style/Theme.NoDisplay">
70+
android:theme="@android:style/Theme.NoDisplay"
71+
android:exported="true">
6672
<intent-filter>
6773
<action android:name="android.intent.action.MAIN"/>
6874

@@ -86,37 +92,39 @@
8692
android:launchMode="standard"
8793
android:multiprocess="true"
8894
android:taskAffinity="org.autojs.autojs.edit"
95+
android:exported="false"
8996
android:theme="@style/EditorTheme">
9097
</activity>
91-
<activity android:name=".ui.settings.AboutActivity_"/>
98+
<activity android:name=".ui.settings.AboutActivity_" android:exported="false"/>
9299
<activity
93-
android:name=".ui.settings.SettingsActivity_"
100+
android:name=".ui.settings.SettingsActivity_" android:exported="false"
94101
android:theme="@style/AppTheme.Settings"/>
95-
<activity android:name="org.autojs.autojs.ui.error.ErrorReportActivity"/>
102+
<activity android:name="org.autojs.autojs.ui.error.ErrorReportActivity" android:exported="false"/>
96103
<activity
97104
android:name=".external.tasker.TaskerScriptEditActivity_"
98-
android:configChanges="orientation|screenSize"
105+
android:configChanges="orientation|screenSize" android:exported="false"
99106
/>
100-
<activity android:name="org.autojs.autojs.ui.edit.ViewSampleActivity"/>
107+
<activity android:name="org.autojs.autojs.ui.edit.ViewSampleActivity" android:exported="false"/>
101108
<activity
102-
android:name=".ui.user.LoginActivity_"
109+
android:name=".ui.user.LoginActivity_" android:exported="false"
103110
android:windowSoftInputMode="adjustResize"/>
104111
<activity
105-
android:name=".ui.user.RegisterActivity_"
112+
android:name=".ui.user.RegisterActivity_" android:exported="false"
106113
android:windowSoftInputMode="adjustResize"/>
107-
<activity android:name=".ui.user.WebActivity_"/>
114+
<activity android:name=".ui.user.WebActivity_" android:exported="false"/>
108115
<activity
109116
android:name=".ui.project.BuildActivity_"
110-
android:configChanges="orientation|screenSize"/>
111-
<activity android:name=".ui.project.ProjectConfigActivity_"/>
112-
<activity android:name=".ui.log.LogActivity_"/>
113-
<activity android:name=".ui.doc.DocumentationActivity_"/>
114-
<activity android:name=".ui.shortcut.ShortcutIconSelectActivity_"/>
115-
<activity android:name=".ui.timing.TimedTaskSettingActivity_"/>
117+
android:configChanges="orientation|screenSize" android:exported="false"/>
118+
<activity android:name=".ui.project.ProjectConfigActivity_" android:exported="false"/>
119+
<activity android:name=".ui.log.LogActivity_" android:exported="false"/>
120+
<activity android:name=".ui.doc.DocumentationActivity_" android:exported="false"/>
121+
<activity android:name=".ui.shortcut.ShortcutIconSelectActivity_" android:exported="false"/>
122+
<activity android:name=".ui.timing.TimedTaskSettingActivity_" android:exported="false"/>
116123
<activity
117124
android:name="org.autojs.autojs.ui.shortcut.ShortcutCreateActivity"
118-
android:theme="@style/AppTheme.Transparent"/>
119-
<activity android:name=".external.widget.ScriptWidgetSettingsActivity_">
125+
android:theme="@style/AppTheme.Transparent" android:exported="false"/>
126+
<activity android:name=".external.widget.ScriptWidgetSettingsActivity_"
127+
android:exported="false">
120128
<intent-filter>
121129
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
122130
</intent-filter>
@@ -127,20 +135,21 @@
127135
</activity>
128136

129137
<activity
130-
android:name="org.autojs.autojs.ui.error.IssueReporterActivity"
138+
android:name="org.autojs.autojs.ui.error.IssueReporterActivity" android:exported="false"
131139
android:theme="@style/IssueReporterTheme"/>
132140

133141

134-
<service android:name="org.autojs.autojs.external.foreground.ForegroundService"/>
135-
<service android:name="org.autojs.autojs.external.ScriptExecutionIntentService"/>
142+
<service android:name="org.autojs.autojs.external.foreground.ForegroundService" android:exported="false"/>
143+
<service android:name="org.autojs.autojs.external.ScriptExecutionIntentService" android:exported="false"/>
136144

137-
<activity android:name=".external.tasker.TaskPrefEditActivity_"/>
145+
<activity android:name=".external.tasker.TaskPrefEditActivity_" android:exported="false"/>
138146

139147
<service
140148
android:name="org.autojs.autojs.external.tile.LayoutBoundsTile"
141149
android:icon="@drawable/ic_circular_menu_bounds"
142150
android:label="@string/text_inspect_layout_bounds"
143-
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
151+
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
152+
android:exported="true">
144153
<meta-data
145154
android:name="android.service.quicksettings.ACTIVE_TILE"
146155
android:value="false"/>
@@ -153,7 +162,8 @@
153162
android:name="org.autojs.autojs.external.tile.LayoutHierarchyTile"
154163
android:icon="@drawable/ic_circular_menu_hierarchy"
155164
android:label="@string/text_inspect_layout_hierarchy"
156-
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
165+
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
166+
android:exported="true">
157167

158168
<meta-data
159169
android:name="android.service.quicksettings.ACTIVE_TILE"
@@ -175,7 +185,8 @@
175185
</intent-filter>
176186
</activity-alias>
177187

178-
<receiver android:name="org.autojs.autojs.external.receiver.StaticBroadcastReceiver">
188+
<receiver android:name="org.autojs.autojs.external.receiver.StaticBroadcastReceiver"
189+
android:exported="false">
179190
<intent-filter>
180191
<action android:name="android.intent.action.BOOT_COMPLETED"/>
181192
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
@@ -199,7 +210,8 @@
199210
<action android:name="android.intent.action.WALLPAPER_CHANGED"/>
200211
<action android:name="android.intent.action.USER_UNLOCKED"/>
201212
<action android:name="android.intent.action.USER_PRESENT"/>
202-
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
213+
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"
214+
tools:ignore="BatteryLife" />
203215
</intent-filter>
204216
<intent-filter>
205217
<action android:name="android.intent.action.PACKAGE_ADDED"/>
@@ -227,7 +239,8 @@
227239
<activity
228240
android:name="org.autojs.autojs.external.open.EditIntentActivity"
229241
android:icon="@drawable/autojs_material"
230-
android:label="@string/text_edit_script">
242+
android:label="@string/text_edit_script"
243+
android:exported="true">
231244
<intent-filter>
232245
<action android:name="android.intent.action.VIEW"/>
233246
<action android:name="android.intent.action.EDIT"/>
@@ -246,7 +259,8 @@
246259
android:icon="@drawable/autojs_material"
247260
android:label="@string/text_run_script"
248261
android:taskAffinity="org.autojs.autojs.external.open.RunIntentActivity"
249-
android:theme="@android:style/Theme.NoDisplay">
262+
android:theme="@android:style/Theme.NoDisplay"
263+
android:exported="true">
250264
<intent-filter>
251265
<action android:name="android.intent.action.VIEW"/>
252266
<action android:name="android.intent.action.EDIT"/>
@@ -264,7 +278,8 @@
264278
android:name="org.autojs.autojs.external.open.ImportIntentActivity"
265279
android:icon="@drawable/autojs_material"
266280
android:label="@string/text_import_script"
267-
android:theme="@style/AppTheme.Transparent">
281+
android:theme="@style/AppTheme.Transparent"
282+
android:exported="true">
268283
<intent-filter>
269284
<action android:name="android.intent.action.VIEW"/>
270285
<action android:name="android.intent.action.EDIT"/>
@@ -282,13 +297,15 @@
282297
<service
283298
android:name="com.stardust.notification.NotificationListenerService"
284299
android:label="@string/app_name"
285-
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
300+
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"
301+
android:exported="false">
286302
<intent-filter>
287303
<action android:name="android.service.notification.NotificationListenerService"/>
288304
</intent-filter>
289305
</service>
290306

291-
<receiver android:name="org.autojs.autojs.external.widget.ScriptWidget">
307+
<receiver android:name="org.autojs.autojs.external.widget.ScriptWidget"
308+
android:exported="false">
292309
<intent-filter>
293310
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
294311
</intent-filter>
@@ -298,13 +315,15 @@
298315
android:resource="@xml/script_widget_config"/>
299316
</receiver>
300317

301-
<receiver android:name="org.autojs.autojs.timing.TaskReceiver">
318+
<receiver android:name="org.autojs.autojs.timing.TaskReceiver"
319+
android:exported="false">
302320
<intent-filter>
303321
<action android:name="com.stardust.autojs.action.task"/>
304322
</intent-filter>
305323
</receiver>
306324

307-
<receiver android:name=".timing.work.AlarmManagerProvider">
325+
<receiver android:name=".timing.work.AlarmManagerProvider"
326+
android:exported="false">
308327
<intent-filter>
309328
<action android:name="com.stardust.autojs.action.check_task"/>
310329
<action android:name="com.android.deskclock.ALARM_ALERT"/>

app/src/main/java/org/autojs/autojs/App.kt

-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import com.bumptech.glide.Glide
1313
import com.bumptech.glide.request.target.SimpleTarget
1414
import com.bumptech.glide.request.transition.Transition
1515
import com.flurry.android.FlurryAgent
16-
import com.squareup.leakcanary.LeakCanary
1716
import com.stardust.app.GlobalAppContext
1817
import com.stardust.autojs.core.ui.inflater.ImageLoader
1918
import com.stardust.autojs.core.ui.inflater.util.Drawables
@@ -67,12 +66,6 @@ class App : MultiDexApplication() {
6766

6867
crashHandler.setBuglyHandler(Thread.getDefaultUncaughtExceptionHandler())
6968
Thread.setDefaultUncaughtExceptionHandler(crashHandler)
70-
if (LeakCanary.isInAnalyzerProcess(this)) {
71-
// This process is dedicated to LeakCanary for heap analysis.
72-
// You should not init your app in this process.
73-
return
74-
}
75-
//LeakCanary.install(this);
7669

7770
}
7871

autojs/src/main/AndroidManifest.xml

+13-6
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,44 @@
33
xmlns:tools="http://schemas.android.com/tools"
44
package="com.stardust.autojs">
55

6+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
7+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
68
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
9+
<uses-permission android:name="android.permission.LOCAL_MAC_ADDRESS"
10+
tools:ignore="ProtectedPermissions" />
711
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
812
<uses-permission android:name="android.permission.VIBRATE"/>
913
<uses-permission android:name="android.permission.WAKE_LOCK"/>
1014
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
11-
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
12-
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
15+
<uses-permission android:name="android.permission.WRITE_SETTINGS"
16+
tools:ignore="ProtectedPermissions" />
17+
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"
18+
tools:ignore="ProtectedPermissions" />
1319

1420
<application
1521
>
1622
<activity
17-
android:name=".execution.ScriptExecuteActivity"
23+
android:name=".execution.ScriptExecuteActivity" android:exported="false"
1824
android:configChanges="keyboardHidden|orientation|screenSize"
1925
android:theme="@style/ScriptTheme"/>
2026

2127

2228
<activity
2329
android:name="com.stardust.autojs.core.permission.PermissionRequestActivity"
24-
android:excludeFromRecents="true"
30+
android:excludeFromRecents="true" android:exported="false"
2531
android:taskAffinity="com.stardust.autojs.runtime.api.image.ScreenCaptureRequestActivity"
2632
android:theme="@style/ScriptTheme.Transparent"/>
2733

2834
<activity
2935
android:name="com.stardust.autojs.core.image.capture.ScreenCaptureRequestActivity"
30-
android:excludeFromRecents="true"
36+
android:excludeFromRecents="true" android:exported="false"
3137
android:taskAffinity="com.stardust.autojs.runtime.api.image.ScreenCaptureRequestActivity"
3238
android:theme="@style/ScriptTheme.Transparent"/>
3339

3440
<service
3541
android:name="com.stardust.autojs.core.accessibility.AccessibilityService"
36-
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
42+
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
43+
android:exported="false">
3744
<intent-filter>
3845
<action android:name="android.accessibilityservice.AccessibilityService"/>
3946
</intent-filter>

autojs/src/main/java/com/stardust/autojs/core/accessibility/SimpleActionAutomator.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class SimpleActionAutomator(
206206
ScriptRuntime.requiresApi(24)
207207
if (!::mGlobalActionAutomator.isInitialized) {
208208
mGlobalActionAutomator =
209-
GlobalActionAutomator(Handler(mScriptRuntime.get()?.loopers?.servantLooper)) {
209+
GlobalActionAutomator(mScriptRuntime.get()?.loopers?.servantLooper?.let { Handler(it) }) {
210210
ensureAccessibilityServiceEnabled()
211211
return@GlobalActionAutomator mAccessibilityBridge.service!!
212212
}

autojs/src/main/java/com/stardust/autojs/core/graphics/ScriptCanvasView.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ class ScriptCanvasView(context: Context, scriptRuntime: ScriptRuntime) : Texture
6363
canvas = lockCanvas()
6464
scriptCanvas.setCanvas(canvas)
6565
emit("draw", scriptCanvas, this@ScriptCanvasView)
66-
unlockCanvasAndPost(canvas)
66+
if (canvas != null) {
67+
unlockCanvasAndPost(canvas)
68+
}
6769
canvas = null
6870
val dt = mTimePerDraw - (SystemClock.uptimeMillis() - time)
6971
if (dt > 0) {

automator/src/main/java/com/stardust/automator/GlobalActionAutomator.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class GlobalActionAutomator(private val mHandler: Handler?, private val serviceP
117117
private fun gesturesWithoutHandler(description: GestureDescription): Boolean {
118118
prepareLooperIfNeeded()
119119
val result = VolatileBox(false)
120-
val handler = Handler(Looper.myLooper())
120+
val handler = Looper.myLooper()?.let { Handler(it) }
121121
service.dispatchGesture(description, object : AccessibilityService.GestureResultCallback() {
122122
override fun onCompleted(gestureDescription: GestureDescription) {
123123
result.set(true)

automator/src/main/java/com/stardust/view/accessibility/AccessibilityNodeInfoAllocator.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ open class AccessibilityNodeInfoAllocator {
8484
key.recycle()
8585
notRecycledCount++
8686
if (DEBUG)
87-
Log.w(TAG, value)
87+
value?.let { Log.w(TAG, it) }
8888
} catch (ignored: IllegalStateException) {
8989
}
9090

0 commit comments

Comments
 (0)