Android app blacklist and whitelist
Android app blacklist and whitelist
When the Android device system works normally, many services run in the background. The background Service is automatically killed only when the system memory is insufficient.
During the development of the Android OTT box project, the network set-top box running memory of 512 MB/1 GB is insufficient. To improve the smoothness of the system, the app blacklist and whitelist function is added during firmware compilation.
After the Android system is turned on, A BroadcastReceiver boot broadcast is sent,
Add BootCompletedReceiverAML. java in the app
Public class BootCompletedReceiverAML extends BroadcastReceiver {public static final String TAG = "BootCompletedReceiverAML"; public void onReceive (Context context, Intent intent) {initScreenSaver (); resume (); initLauncherComponents ();} // enter the screen saver black/white list 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 () ;}}// Enable Automatic Running of 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 ");} // automatically run private void initEnableAutoRunningComponents () {Settings. secure. putString (mContext. getContentResolver (), Settings. secure. ENABLE_AUTO_LAUNCH_COMPONENTS, "com. android/system/com. mipt/com. skyworth/com. mipt. metro. launcher/com. skydigital/com. sky/com. starcor. hunan ");} // boot Launcher private void initLauncherComponents () {Settings. secure. putString (mContext. getContentResolver (), Settings. secure. ENABLE_LAUNCHER_COMPONENTS, "com. mipt. metro. launcher ");}}