android动态修改refresh rate,RefreshRatePolicy.java

/*

* Copyright (C) 2019 The Android Open Source Project

*

* Licensed under the Apache License, Version 2.0 (the "License");

* you may not use this file except in compliance with the License.

* You may obtain a copy of the License at

*

* http://www.apache.org/licenses/LICENSE-2.0

*

* Unless required by applicable law or agreed to in writing, software

* distributed under the License is distributed on an "AS IS" BASIS,

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and

* limitations under the License.

*/

package com.android.server.wm;

import android.util.ArraySet;

import android.view.Display.Mode;

import android.view.DisplayInfo;

/**

* Policy to select a lower refresh rate for the display if applicable.

*/

class RefreshRatePolicy {

private final int mLowRefreshRateId;

private final ArraySetmNonHighRefreshRatePackages = new ArraySet<>();

private final HighRefreshRateBlacklist mHighRefreshRateBlacklist;

private final WindowManagerService mWmService;

RefreshRatePolicy(WindowManagerService wmService, DisplayInfo displayInfo,

HighRefreshRateBlacklist blacklist) {

mLowRefreshRateId = findLowRefreshRateModeId(displayInfo);

mHighRefreshRateBlacklist = blacklist;

mWmService = wmService;

}

/**

* Finds the mode id with the lowest refresh rate which is >= 60hz and same resolution as the

* default mode.

*/

private int findLowRefreshRateModeId(DisplayInfo displayInfo) {

Mode mode = displayInfo.getDefaultMode();

float[] refreshRates = displayInfo.getDefaultRefreshRates();

float bestRefreshRate = mode.getRefreshRate();

for (int i = refreshRates.length - 1; i >= 0; i--) {

if (refreshRates[i] >= 60f && refreshRates[i] < bestRefreshRate) {

bestRefreshRate = refreshRates[i];

}

}

return displayInfo.findDefaultModeByRefreshRate(bestRefreshRate);

}

void addNonHighRefreshRatePackage(String packageName) {

mNonHighRefreshRatePackages.add(packageName);

mWmService.requestTraversal();

}

void removeNonHighRefreshRatePackage(String packageName) {

mNonHighRefreshRatePackages.remove(packageName);

mWmService.requestTraversal();

}

int getPreferredModeId(WindowState w) {

// If app is animating, it's not able to control refresh rate because we want the animation

// to run in default refresh rate.

if (w.isAnimating()) {

return 0;

}

// If app requests a certain refresh rate or mode, don't override it.

if (w.mAttrs.preferredRefreshRate != 0 || w.mAttrs.preferredDisplayModeId != 0) {

return w.mAttrs.preferredDisplayModeId;

}

final String packageName = w.getOwningPackage();

// If app is using Camera, force it to default (lower) refresh rate.

if (mNonHighRefreshRatePackages.contains(packageName)) {

return mLowRefreshRateId;

}

// If app is blacklisted using higher refresh rate, return default (lower) refresh rate

if (mHighRefreshRateBlacklist.isBlacklisted(packageName)) {

return mLowRefreshRateId;

}

return 0;

}

}

Java程序

|

93行

|

3.28 KB

/*

* Copyright (C) 2019 The Android Open Source Project

*

* Licensed under the Apache License, Version 2.0 (the "License");

* you may not use this file except in compliance with the License.

* You may obtain a copy of the License at

*

* http://www.apache.org/licenses/LICENSE-2.0

*

* Unless required by applicable law or agreed to in writing, software

* distributed under the License is distributed on an "AS IS" BASIS,

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and

* limitations under the License.

*/

package com.android.server.wm;

import android.util.ArraySet;

import android.view.Display.Mode;

import android.view.DisplayInfo;

/**

* Policy to select a lower refresh rate for the display if applicable.

*/

class RefreshRatePolicy {

private final int mLowRefreshRateId;

private final ArraySet mNonHighRefreshRatePackages = new ArraySet<>();

private final HighRefreshRateBlacklist mHighRefreshRateBlacklist;

private final WindowManagerService mWmService;

RefreshRatePolicy(WindowManagerService wmService, DisplayInfo displayInfo,

HighRefreshRateBlacklist blacklist) {

mLowRefreshRateId = findLowRefreshRateModeId(displayInfo);

mHighRefreshRateBlacklist = blacklist;

mWmService = wmService;

}

/**

* Finds the mode id with the lowest refresh rate which is >= 60hz and same resolution as the

* default mode.

*/

private int findLowRefreshRateModeId(DisplayInfo displayInfo) {

Mode mode = displayInfo.getDefaultMode();

float[] refreshRates = displayInfo.getDefaultRefreshRates();

float bestRefreshRate = mode.getRefreshRate();

for (int i = refreshRates.length - 1; i >= 0; i--) {

if (refreshRates[i] >= 60f && refreshRates[i] < bestRefreshRate) {

bestRefreshRate = refreshRates[i];

}

}

return displayInfo.findDefaultModeByRefreshRate(bestRefreshRate);

}

void addNonHighRefreshRatePackage(String packageName) {

mNonHighRefreshRatePackages.add(packageName);

mWmService.requestTraversal();

}

void removeNonHighRefreshRatePackage(String packageName) {

mNonHighRefreshRatePackages.remove(packageName);

mWmService.requestTraversal();

}

int getPreferredModeId(WindowState w) {

// If app is animating, it's not able to control refresh rate because we want the animation

// to run in default refresh rate.

if (w.isAnimating()) {

return 0;

}

// If app requests a certain refresh rate or mode, don't override it.

if (w.mAttrs.preferredRefreshRate != 0 || w.mAttrs.preferredDisplayModeId != 0) {

return w.mAttrs.preferredDisplayModeId;

}

final String packageName = w.getOwningPackage();

// If app is using Camera, force it to default (lower) refresh rate.

if (mNonHighRefreshRatePackages.contains(packageName)) {

return mLowRefreshRateId;

}

// If app is blacklisted using higher refresh rate, return default (lower) refresh rate

if (mHighRefreshRateBlacklist.isBlacklisted(packageName)) {

return mLowRefreshRateId;

}

return 0;

}

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'KMSEncryptUtil': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.ideal.upms.common.utils.KMSEncryptUtil] from ClassLoader [sun.misc.Launcher$AppClassLoader@42a57993] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:265) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1253) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1168) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) at com.ideal.order.web.CloudorderWebAPP.main(CloudorderWebAPP.java:27)
06-09

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值