电池模块默认不能优化省点,否则会出现异常

电池模块默认不能点击省点模式,是由于短信和电话限制设置,如果点击省电模式会影响电话功能,具体代码修改如下:

frameworks/base/packages/SettingsLib/src/com/android/settingslib/fuelgauge/PowerWhitelistBackend.java

 public boolean isWhitelisted(String pkg) {
        if (mWhitelistedApps.contains(pkg)) {
            return true;
        }

        // Additionally, check if pkg is default dialer/sms. They are considered essential apps and
        // should be automatically whitelisted (otherwise user may be able to set restriction on
        // them, leading to bad device behavior.)
        if (!mAppContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
            return false;
        }
        final ComponentName defaultSms = SmsApplication.getDefaultSmsApplication(mAppContext,
                true /* updateIfNeeded */);
        if (defaultSms != null && TextUtils.equals(pkg, defaultSms.getPackageName())) {
            return true;
        }

        final String defaultDialer = DefaultDialerManager.getDefaultDialerApplication(mAppContext);
        if (TextUtils.equals(pkg, defaultDialer)) {
            return true;
        }

        final DevicePolicyManager devicePolicyManager = mAppContext.getSystemService(
                DevicePolicyManager.class);
        if (devicePolicyManager.packageHasActiveAdmins(pkg)) {
            return true;
        }

        return false;
    }

猜你喜欢

转载自blog.csdn.net/liuminx/article/details/106466254