Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录
切换导航
D
DemoRx356xSystemApp
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
刘建胜
DemoRx356xSystemApp
Commits
e89215ef
提交
e89215ef
authored
9月 26, 2023
作者:
刘建胜
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Feat] 添加检查WIFI休眠策略
上级
efdcc4d1
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
79 行增加
和
3 行删除
+79
-3
build.gradle
app/build.gradle
+1
-1
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+2
-1
MainActivity.java
app/src/main/java/com/ubains/demorx356x/MainActivity.java
+64
-1
activity_main.xml
app/src/main/res/layout/activity_main.xml
+12
-0
没有找到文件。
app/build.gradle
浏览文件 @
e89215ef
...
@@ -8,7 +8,7 @@ android {
...
@@ -8,7 +8,7 @@ android {
defaultConfig
{
defaultConfig
{
applicationId
"com.ubains.demorx356x"
applicationId
"com.ubains.demorx356x"
minSdk
25
minSdk
25
targetSdk
32
targetSdk
28
versionCode
1
versionCode
1
versionName
"1.0"
versionName
"1.0"
...
...
app/src/main/AndroidManifest.xml
浏览文件 @
e89215ef
<?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"
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
package=
"com.ubains.demorx356x"
>
package=
"com.ubains.demorx356x"
android:sharedUserId=
"android.uid.system"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
...
...
app/src/main/java/com/ubains/demorx356x/MainActivity.java
浏览文件 @
e89215ef
...
@@ -2,11 +2,18 @@ package com.ubains.demorx356x;
...
@@ -2,11 +2,18 @@ package com.ubains.demorx356x;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.appcompat.app.AppCompatActivity
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.net.wifi.WifiManager
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.IBinder
;
import
android.os.IBinder
;
import
android.os.RemoteException
;
import
android.os.RemoteException
;
import
android.os.yx.IYxInstallListener
;
import
android.os.yx.IYxInstallListener
;
import
android.os.yx.YxDeviceManager
;
import
android.os.yx.YxDeviceManager
;
import
android.provider.Settings
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.TextView
;
import
android.widget.TextView
;
...
@@ -22,6 +29,7 @@ import java.util.Calendar;
...
@@ -22,6 +29,7 @@ import java.util.Calendar;
import
java.util.Date
;
import
java.util.Date
;
public
class
MainActivity
extends
AppCompatActivity
{
public
class
MainActivity
extends
AppCompatActivity
{
private
static
final
String
TAG
=
"MainActivity"
;
final
YxDeviceManager
yxDeviceManager
=
YxDeviceManager
.
getInstance
(
this
);
final
YxDeviceManager
yxDeviceManager
=
YxDeviceManager
.
getInstance
(
this
);
TextView
tvLog
;
TextView
tvLog
;
...
@@ -63,6 +71,19 @@ public class MainActivity extends AppCompatActivity {
...
@@ -63,6 +71,19 @@ public class MainActivity extends AppCompatActivity {
YxDeviceManager
.
getInstance
(
getApplication
()).
setOemFunc
(
"io50"
);
YxDeviceManager
.
getInstance
(
getApplication
()).
setOemFunc
(
"io50"
);
}
}
});
});
//注册广播监听WIFI状态变化
registerWifiReceiver
();
}
private
void
registerWifiReceiver
()
{
// 创建Wifi状态变化的IntentFilter
IntentFilter
intentFilter
=
new
IntentFilter
();
intentFilter
.
addAction
(
WifiManager
.
WIFI_STATE_CHANGED_ACTION
);
// 注册BroadcastReceiver
registerReceiver
(
wifiStateReceiver
,
intentFilter
);
}
}
/**
/**
...
@@ -91,6 +112,16 @@ public class MainActivity extends AppCompatActivity {
...
@@ -91,6 +112,16 @@ public class MainActivity extends AppCompatActivity {
info
.
append
(
"屏幕方向:"
).
append
(
yxDeviceManager
.
getScreenRotation
()).
append
(
"\n"
);
info
.
append
(
"屏幕方向:"
).
append
(
yxDeviceManager
.
getScreenRotation
()).
append
(
"\n"
);
info
.
append
(
"序列号:"
).
append
(
yxDeviceManager
.
getSerialno
()).
append
(
"\n"
);
info
.
append
(
"序列号:"
).
append
(
yxDeviceManager
.
getSerialno
()).
append
(
"\n"
);
info
.
append
(
"内部存储大小:"
).
append
(
yxDeviceManager
.
getInternalStorageMemory
()).
append
(
"\n"
);
info
.
append
(
"内部存储大小:"
).
append
(
yxDeviceManager
.
getInternalStorageMemory
()).
append
(
"\n"
);
//读取WIFI的默认策略
int
wifiSleepPolicy
=
Settings
.
System
.
getInt
(
getContentResolver
(),
android
.
provider
.
Settings
.
System
.
WIFI_SLEEP_POLICY
,
Settings
.
System
.
WIFI_SLEEP_POLICY_DEFAULT
);
System
.
out
.
println
(
"---> 修改前的Wifi休眠策略值 WIFI_SLEEP_POLICY="
+
wifiSleepPolicy
);
info
.
append
(
"WIFI_SLEEP_POLICY:"
).
append
(
wifiSleepPolicy
).
append
(
"\n"
);
tvLog
.
setText
(
info
.
toString
());
tvLog
.
setText
(
info
.
toString
());
}
}
...
@@ -171,7 +202,7 @@ public class MainActivity extends AppCompatActivity {
...
@@ -171,7 +202,7 @@ public class MainActivity extends AppCompatActivity {
public
void
sliceInstall
(
View
view
)
{
public
void
sliceInstall
(
View
view
)
{
File
apkFile
=
new
File
(
"/sdcard/update.apk"
);
File
apkFile
=
new
File
(
"/sdcard/update.apk"
);
if
(!
apkFile
.
exists
())
{
if
(!
apkFile
.
exists
())
{
tvLog
.
setText
(
"/sdcard/update.apk 文件不存在"
);
tvLog
.
setText
(
"/sdcard/update.apk 文件不存在"
);
return
;
return
;
}
}
...
@@ -181,4 +212,36 @@ public class MainActivity extends AppCompatActivity {
...
@@ -181,4 +212,36 @@ public class MainActivity extends AppCompatActivity {
public
void
sliceUninstall
(
View
view
)
{
public
void
sliceUninstall
(
View
view
)
{
yxDeviceManager
.
unInstallApk
(
"org.videolan.vlc"
);
yxDeviceManager
.
unInstallApk
(
"org.videolan.vlc"
);
}
}
public
void
turnOffScreen
(
View
view
)
{
yxDeviceManager
.
setScreenKeyGuard
(
false
);
}
public
void
setWifiSleepPolicyNever
(
View
view
)
{
Settings
.
System
.
putInt
(
getContentResolver
(),
android
.
provider
.
Settings
.
System
.
WIFI_SLEEP_POLICY
,
Settings
.
System
.
WIFI_SLEEP_POLICY_NEVER
);
tvLog
.
setText
(
"OK!"
);
}
private
final
BroadcastReceiver
wifiStateReceiver
=
new
BroadcastReceiver
()
{
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
int
wifiState
=
intent
.
getIntExtra
(
WifiManager
.
EXTRA_WIFI_STATE
,
WifiManager
.
WIFI_STATE_UNKNOWN
);
switch
(
wifiState
)
{
case
WifiManager
.
WIFI_STATE_ENABLED
:
Log
.
d
(
TAG
,
"onReceive: Wifi已启用"
);
break
;
case
WifiManager
.
WIFI_STATE_DISABLED
:
Log
.
d
(
TAG
,
"onReceive: Wifi已禁用"
);
break
;
case
WifiManager
.
WIFI_STATE_UNKNOWN
:
Log
.
d
(
TAG
,
"onReceive: Wifi状态未知"
);
break
;
}
}
};
}
}
\ No newline at end of file
app/src/main/res/layout/activity_main.xml
浏览文件 @
e89215ef
...
@@ -113,6 +113,18 @@
...
@@ -113,6 +113,18 @@
android:onClick=
"closeStatusBar"
android:onClick=
"closeStatusBar"
android:text=
"隐藏状态栏"
android:text=
"隐藏状态栏"
/>
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:onClick=
"setWifiSleepPolicyNever"
android:text=
"设置WIFI息屏不休眠"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:onClick=
"turnOffScreen"
android:text=
"息屏"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</ScrollView>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论