[Security] resolve overlay attack on RequestIgnoreBatteryOptimizations

we should put the addSystemFlags() after onCreate() method rather than the original onStart() method (refer the proposed solution in b/199167909)

Bug: 199167909
Test: make SettingsRoboTests
Change-Id: Ic7361443bfa2e1a6d8d962708c794fa0122a691c
This commit is contained in:
ykhung
2021-09-24 00:33:23 +08:00
committed by YUKAI HUNG
parent 8ab5c92adc
commit a8a2075fd0

View File

@@ -41,6 +41,8 @@ public class RequestIgnoreBatteryOptimizations extends AlertActivity implements
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addSystemFlags(android.view.WindowManager.LayoutParams
.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
mPowerWhitelistManager = getSystemService(PowerWhitelistManager.class);
@@ -94,13 +96,6 @@ public class RequestIgnoreBatteryOptimizations extends AlertActivity implements
setupAlert();
}
@Override
protected void onStart() {
super.onStart();
getWindow().addSystemFlags(android.view.WindowManager.LayoutParams
.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
}
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {