Morten Krogh-Jespersen | 7a47b73 | 2021-05-11 17:32:34 +0200 | [diff] [blame] | 1 | // Copyright (c) 2021, the R8 project authors. Please see the AUTHORS file |
| 2 | // for details. All rights reserved. Use of this source code is governed by a |
| 3 | // BSD-style license that can be found in the LICENSE file. |
| 4 | |
Morten Krogh-Jespersen | ba2f61a | 2023-08-15 15:33:38 +0200 | [diff] [blame] | 5 | package softverificationerror; |
Morten Krogh-Jespersen | 7a47b73 | 2021-05-11 17:32:34 +0200 | [diff] [blame] | 6 | |
| 7 | import android.app.NotificationChannel; |
| 8 | import android.app.NotificationManager; |
| 9 | import android.os.Build; |
| 10 | |
| 11 | public class ApiCallerInlined { |
| 12 | |
| 13 | public static void callApi(android.content.Context context) { |
| 14 | // Create the NotificationChannel, but only on API 26+ because |
| 15 | // the NotificationChannel class is new and not in the support library |
| 16 | if (Build.VERSION.SDK_INT >= 26) { |
| 17 | constructUnknownObjectAndCallUnknownMethod(context); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | public static void constructUnknownObject(android.content.Context context) { |
| 22 | NotificationChannel channel = |
| 23 | new NotificationChannel("CHANNEL_ID", "FOO", NotificationManager.IMPORTANCE_DEFAULT); |
| 24 | channel.setDescription("This is a test channel"); |
| 25 | } |
| 26 | |
| 27 | public static void callUnknownMethod(android.content.Context context) { |
| 28 | NotificationManager notificationManager = |
| 29 | (NotificationManager) context.getSystemService(NotificationManager.class); |
| 30 | notificationManager.createNotificationChannel(null); |
| 31 | } |
| 32 | |
| 33 | public static void constructUnknownObjectAndCallUnknownMethod(android.content.Context context) { |
| 34 | NotificationChannel channel = |
| 35 | new NotificationChannel("CHANNEL_ID", "FOO", NotificationManager.IMPORTANCE_DEFAULT); |
| 36 | channel.setDescription("This is a test channel"); |
| 37 | NotificationManager notificationManager = |
| 38 | (NotificationManager) context.getSystemService(NotificationManager.class); |
| 39 | notificationManager.createNotificationChannel(channel); |
| 40 | } |
| 41 | } |