解決被手機管理工具禁止開機啟動的方法

來源:互聯網
上載者:User

標籤:

目前市面上很多工具有屏蔽其他app開機啟動的功能,比如獵豹清理大師和360安全衛士。本文講解如何避免被獵豹清理大師關閉收不到開機廣播的情況,360安全衛士的屏蔽模式還沒搞清楚,有大牛明白的話請賜教。

獵豹屏蔽的原理是通過改變第三方app接收開機廣播reciver的狀態來達到效果。解決辦法就是在關機廣播裡面把自己改為可用。

具體代碼如下:

接收開機廣播android.intent.action.BOOT_COMPLETED的組建命名為com.android.test.CompletedReciver.java

接收關機廣播android.intent.action.ACTION_SHUTDOWN的組建命名為com.android.test.ShutDownReciver.java

package com.android.test;


import android.content.BroadcastReceiver;

import android.content.ComponentName;

import android.content.Context;

import android.content.Intent;

import android.content.pm.PackageManager;

import android.text.TextUtils;


public class ShutDownReceiverextends BroadcastReceiver {


    private static void setComponentEnableSetting(Context context, String className) {

        PackageManager pm = context.getPackageManager();

        ComponentName componentName = new ComponentName(context, className);

        pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);

    }


    private static int getComponentEnableSetting(Context context, String className) {

        PackageManager pm = context.getPackageManager();

        ComponentName componentName = new ComponentName(context, className);

        return pm.getComponentEnabledSetting(componentName);

    }


    @Override

    public void onReceive(final Context context, Intent intent) {

        String action = intent.getAction();

        if (TextUtils.isEmpty(action)) {

            return;

        }

        if (Intent.ACTION_SHUTDOWN.equals(action)) {

            String ComponentName = "com.android.test.CompletedReciver";

            if (PackageManager.COMPONENT_ENABLED_STATE_DISABLED == getComponentEnableSetting(context.getApplicationContext(), ComponentName)) {

                setComponentEnableSetting(context.getApplicationContext(), ComponentName);

            }

        }

    }

}


關於360安全衛士和MIUI系統內建資訊安全中心的實現方式還沒搞明白。

解決被手機管理工具禁止開機啟動的方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.