我是靠谱客的博主 丰富皮卡丘,最近开发中收集的这篇文章主要介绍Android app黑白名单Android app黑白名单,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

转载自:https://www.2cto.com/kf/201505/400664.html


Android app黑白名单

Android设备系统正常工作时,很多Service运行在后台,只用在系统内存不够使用时候,才会自动kill掉后台Service
Android OTT盒子项目开发中,网络机顶盒运行内存512M/1G 内存不够使用,为了提高系统的流畅性,编译固件时加入app黑白名单功能。

Android系统开机后会发出BroadcastReceiver开机广播,
在设置app 添加BootCompletedReceiverAML.java

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<code class = "language-java hljs " > public class BootCompletedReceiverAML extends BroadcastReceiver {
     public static final String TAG = "BootCompletedReceiverAML" ;
     public void onReceive(Context context, Intent intent) {
 
     initScreenSaver();
     initEnableRunningBackgroudComponents();
     initEnableAutoRunningComponents(); 
     initLauncherComponents();
     }
 
     //设置进入屏保黑白名单
     private void initScreenSaver() {
         Settings.System.putInt(mContext.getContentResolver(),
         Settings.System.BOOT_GUIDE_COMPLETED, 1 );
         IDreamManager mDreamManager = IDreamManager.Stub.asInterface(ServiceManager.getService(DreamService.DREAM_SERVICE));
         ComponentName dream = newComponentName( "com.mipt.screensaver" ,
                 "com.mipt.screensaver.ScreenSaverService" );
         try {
             ComponentName[] dreams = { dream };
             mDreamManager.setDreamComponents(dream == null ? null : dreams);
         }
         catch (RemoteException e) {
         }
 
         String dreamEnableComponentNames = "com.skyworthdigital.filexplorer/com.skyworthdigital.weather.main/com.skyworthdigital.ihome.settings/com.study.pumpkinstudy/com.android.dreams.phototable" ;
         Settings.System.putString(mContext.getContentResolver(),
         Settings.System.DREAM_ENABLE_COMPONENT,dreamEnableComponentNames);
 
         try {
             long currentTimeout = Settings.System.getLong(
                     mContext.getContentResolver(), SCREEN_OFF_TIMEOUT);
             if (currentTimeout < 0 ) {
                 Settings.System.putInt(mContext.getContentResolver(),
                         SCREEN_OFF_TIMEOUT, 2147483646 );
             }
             currentTimeout = Settings.System.getLong(
                     mContext.getContentResolver(), SCREEN_DREAM_TIMEOUT, - 1 );
             if (currentTimeout < 0 ) {
                 Settings.System.putInt(mContext.getContentResolver(),
                         SCREEN_DREAM_TIMEOUT, 240000 );
             }
 
         } catch (SettingNotFoundException e) {
             e.printStackTrace();
         }
     }
 
     // 使能自动运行在后台service
     private void initEnableRunningBackgroudComponents() {
         Settings.Secure.putString(mContext.getContentResolver(),
         Settings.Secure.ENABLE_RUNNING_BACKGROUD_COMPONENTS,
         "android/system/com.android/com.mipt/com.skyworth/com.google.android/com.skydigital/com.sky/com.starcor.hunan/com.explorer/com.slanissue.tv.erge/eu.chainfire.perfmon" );
     }
 
     //开机自动运行
     private void initEnableAutoRunningComponents() {
         Settings.Secure.putString(mContext.getContentResolver(),
         Settings.Secure.ENABLE_AUTO_LAUNCH_COMPONENTS,
         "com.android/android/system/com.mipt/com.skyworth/com.mipt.metro.launcher/com.skydigital/com.sky/com.starcor.hunan" );
     }
     //开机Launcher
     private void initLauncherComponents() {
         Settings.Secure.putString(mContext.getContentResolver(),
         Settings.Secure.ENABLE_LAUNCHER_COMPONENTS,
         "com.mipt.metro.launcher" );
     }
}   </code>

最后

以上就是丰富皮卡丘为你收集整理的Android app黑白名单Android app黑白名单的全部内容,希望文章能够帮你解决Android app黑白名单Android app黑白名单所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(38)

评论列表共有 0 条评论

立即
投稿
返回
顶部