diff options
Diffstat (limited to 'hostsidetests/securitybulletin/test-apps/CVE-2023-20913/src/android/security/cts/CVE_2023_20913/PocService.java')
-rw-r--r-- | hostsidetests/securitybulletin/test-apps/CVE-2023-20913/src/android/security/cts/CVE_2023_20913/PocService.java | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/hostsidetests/securitybulletin/test-apps/CVE-2023-20913/src/android/security/cts/CVE_2023_20913/PocService.java b/hostsidetests/securitybulletin/test-apps/CVE-2023-20913/src/android/security/cts/CVE_2023_20913/PocService.java new file mode 100644 index 00000000000..6ac55d98cff --- /dev/null +++ b/hostsidetests/securitybulletin/test-apps/CVE-2023-20913/src/android/security/cts/CVE_2023_20913/PocService.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2022 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 android.security.cts.CVE_2023_20913; + +import android.app.Service; +import android.content.Intent; +import android.content.res.Resources; +import android.graphics.PixelFormat; +import android.os.IBinder; +import android.util.DisplayMetrics; +import android.view.Gravity; +import android.view.WindowManager; +import android.view.WindowManager.LayoutParams; +import android.widget.Button; + +public class PocService extends Service { + private Button mButton; + private WindowManager mWindowManager; + + @Override + public void onCreate() { + try { + super.onCreate(); + mWindowManager = getSystemService(WindowManager.class); + LayoutParams layoutParams = new LayoutParams(); + layoutParams.type = LayoutParams.TYPE_APPLICATION_OVERLAY; + layoutParams.flags = + LayoutParams.FLAG_NOT_TOUCH_MODAL | LayoutParams.FLAG_NOT_FOCUSABLE; + layoutParams.format = PixelFormat.OPAQUE; + layoutParams.gravity = Gravity.LEFT | Gravity.TOP; + DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics(); + layoutParams.width = displayMetrics.widthPixels; + layoutParams.height = displayMetrics.heightPixels; + layoutParams.x = displayMetrics.widthPixels / 2; + layoutParams.y = displayMetrics.heightPixels / 2; + + // Show the floating window + mButton = new Button(this); + mButton.setText(getString(R.string.textOverlayButton)); + mWindowManager.addView(mButton, layoutParams); + } catch (Exception ignored) { + // In case of occurrence of an exception overlay won't appear on display which results + // in assumption failure in device test. Hence ignoring this exception here. + } + } + + @Override + public IBinder onBind(Intent intent) { + return null; + } + + @Override + public void onDestroy() { + try { + mWindowManager.removeView(mButton); + super.onDestroy(); + } catch (Exception ignored) { + // Ignoring unintended exceptions + } + } +} |