需求:驱动那边有一款屏幕特殊屏幕,不打开当前选项会闪屏
1.开发者选项的布局在 “apps/Settings/res/xml/development_settings.xml” ,当然也可以通过资源id去检索目录所在;
2.隐藏选项 disable_overlays
base/packages/SettingsLib/res/values-zh-rCN/strings.xml:306:
<string name="disable_overlays_summary" msgid="3578941133710758592">"始终使用 GPU 进行屏幕合成"</string>
<!--
<SwitchPreference
android:key="disable_overlays"
android:title="@string/disable_overlays"
android:summary="@string/disable_overlays_summary" />
-->
3.下面是 patch
Index: android/packages/apps/Settings/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
===================================================================
--- android/packages/apps/Settings/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java (版本 13449)
+++ android/packages/apps/Settings/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java (版本 13450)
@@ -466,7 +466,7 @@
controllers.add(new DebugNonRectClipOperationsPreferenceController(context));
controllers.add(new ForceDarkPreferenceController(context));
controllers.add(new ForceMSAAPreferenceController(context));
- controllers.add(new HardwareOverlaysPreferenceController(context));
+ //controllers.add(new HardwareOverlaysPreferenceController(context));
controllers.add(new SimulateColorSpacePreferenceController(context));
controllers.add(new UsbAudioRoutingPreferenceController(context));
controllers.add(new StrictModePreferenceController(context));
Index: android/packages/apps/Settings/src/com/android/settings/FallbackHome.java
===================================================================
--- android/packages/apps/Settings/src/com/android/settings/FallbackHome.java (版本 13449)
+++ android/packages/apps/Settings/src/com/android/settings/FallbackHome.java (版本 13450)
@@ -41,6 +41,14 @@
import java.util.Objects;
+import android.os.IBinder;
+import android.os.Parcel;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.os.RemoteException;
+
+import androidx.annotation.VisibleForTesting;
+
public class FallbackHome extends Activity {
private static final String TAG = "FallbackHome";
private static final int PROGRESS_TIMEOUT = 2000;
@@ -74,6 +82,17 @@
}
};
+ private static final int SETTING_VALUE_ON = 1;
+ private static final int SETTING_VALUE_OFF = 0;
+ private static final int SURFACE_FLINGER_DISABLE_OVERLAYS_CODE = 1008;
+ private static final String SURFACE_COMPOSER_INTERFACE_KEY = "android.ui.ISurfaceComposer";
+
+ static final int SURFACE_FLINGER_READ_CODE = 1010;
+
+ static final String SURFACE_FLINGER_SERVICE_KEY = "SurfaceFlinger";
+
+ private IBinder mSurfaceFlinger;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -93,6 +112,7 @@
}
mWallManager = getSystemService(WallpaperManager.class);
+ writeHardwareOverlaysSetting();
if (mWallManager == null) {
Log.w(TAG, "Wallpaper manager isn't ready, can't listen to color changes!");
} else {
@@ -104,6 +124,29 @@
maybeFinish();
}
+ void writeHardwareOverlaysSetting() {
+ mSurfaceFlinger = ServiceManager.getService(SURFACE_FLINGER_SERVICE_KEY);
+ try {
+ final Parcel data = Parcel.obtain();
+ /*final Parcel reply = Parcel.obtain();
+ mSurfaceFlinger.transact(SURFACE_FLINGER_READ_CODE, data, reply, 0);
+ @SuppressWarnings("unused") final int showCpu = reply.readInt();
+ @SuppressWarnings("unused") final int enableGL = reply.readInt();
+ @SuppressWarnings("unused") final int showUpdates = reply.readInt();
+ @SuppressWarnings("unused") final int showBackground = reply.readInt();
+ final int disableOverlays = reply.readInt();
+ if (disableOverlays !=SETTING_VALUE_ON) {*/
+ data.writeInterfaceToken(SURFACE_COMPOSER_INTERFACE_KEY);
+ //final int disableOverlays = isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF;
+ data.writeInt(SETTING_VALUE_ON);
+ mSurfaceFlinger.transact(SURFACE_FLINGER_DISABLE_OVERLAYS_CODE, data,null,0);
+ data.recycle();
+ //}
+ } catch (RemoteException ex) {
+ // intentional no-op
+ }
+ }
+
@Override
protected void onResume() {
super.onResume();
Index: android/packages/apps/Settings/res/xml/development_settings.xml
===================================================================
--- android/packages/apps/Settings/res/xml/development_settings.xml (版本 13449)
+++ android/packages/apps/Settings/res/xml/development_settings.xml (版本 13450)
@@ -441,12 +441,12 @@
android:key="force_msaa"
android:title="@string/force_msaa"
android:summary="@string/force_msaa_summary" />
-
+ <!--
<SwitchPreference
android:key="disable_overlays"
android:title="@string/disable_overlays"
android:summary="@string/disable_overlays_summary" />
-
+ -->
<ListPreference
android:entries="@array/simulate_color_space_entries"
android:entryValues="@array/simulate_color_space_values"