您好,登錄后才能下訂單哦!
本篇內容介紹了“Android怎么顯示刷新頻率”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
Android 顯示刷新頻率
android11-release
開發者選項->顯示刷新頻率
packages/apps/Settings/src/com/android/settings/development/ShowRefreshRatePreferenceController.java
調用 SurfaceFlinger::onTransact 中 1034 方法
updateShowRefreshRateSetting() 通過 SurfaceFlinger 獲取mRefreshRateOverlay != nullptr
判斷顯示是否打開
writeShowRefreshRateSetting(boolean isEnabled) 設置打開顯示刷新頻率
public class ShowRefreshRatePreferenceController extends DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin { private static final String SHOW_REFRESH_RATE_KEY = "show_refresh_rate"; private static final int SETTING_VALUE_QUERY = 2; private static final int SETTING_VALUE_ON = 1; private static final int SETTING_VALUE_OFF = 0; @VisibleForTesting static final String SURFACE_FLINGER_SERVICE_KEY = "SurfaceFlinger"; @VisibleForTesting static final int SURFACE_FLINGER_CODE = 1034; private static final String SURFACE_COMPOSER_INTERFACE_KEY = "android.ui.ISurfaceComposer"; private final IBinder mSurfaceFlinger; public ShowRefreshRatePreferenceController(Context context) { super(context); mSurfaceFlinger = ServiceManager.getService(SURFACE_FLINGER_SERVICE_KEY); } @Override public String getPreferenceKey() { return SHOW_REFRESH_RATE_KEY; } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { final boolean isEnabled = (Boolean) newValue; writeShowRefreshRateSetting(isEnabled); return true; } @Override public void updateState(Preference preference) { updateShowRefreshRateSetting(); } @Override protected void onDeveloperOptionsSwitchDisabled() { super.onDeveloperOptionsSwitchDisabled(); final SwitchPreference preference = (SwitchPreference) mPreference; if (preference.isChecked()) { // Writing false to the preference when the setting is already off will have a // side effect of turning on the preference that we wish to avoid writeShowRefreshRateSetting(false); preference.setChecked(false); } } @VisibleForTesting void updateShowRefreshRateSetting() { // magic communication with surface flinger. try { if (mSurfaceFlinger != null) { final Parcel data = Parcel.obtain(); final Parcel reply = Parcel.obtain(); data.writeInterfaceToken(SURFACE_COMPOSER_INTERFACE_KEY); data.writeInt(SETTING_VALUE_QUERY); mSurfaceFlinger.transact(SURFACE_FLINGER_CODE, data, reply, 0 /* flags */); final boolean enabled = reply.readBoolean(); ((SwitchPreference) mPreference).setChecked(enabled); reply.recycle(); data.recycle(); } } catch (RemoteException ex) { // intentional no-op } } @VisibleForTesting void writeShowRefreshRateSetting(boolean isEnabled) { try { if (mSurfaceFlinger != null) { final Parcel data = Parcel.obtain(); data.writeInterfaceToken(SURFACE_COMPOSER_INTERFACE_KEY); final int showRefreshRate = isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF; data.writeInt(showRefreshRate); mSurfaceFlinger.transact(SURFACE_FLINGER_CODE, data, null /* reply */, 0 /* flags */); data.recycle(); } } catch (RemoteException ex) { // intentional no-op } updateShowRefreshRateSetting(); } }
RefreshRateOverlay 實際Layer顯示刷新頻率
frameworks\native\services\surfaceflinger\SurfaceFlinger.cpp frameworks\native\services\surfaceflinger\RefreshRateOverlay.cpp
初始化 RefreshRateOverlay,通過 SurfaceFlinger createLayer顯示
“Android怎么顯示刷新頻率”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。