1 /* 2 * Copyright (C) 2017 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16 17 package com.google.android.mobly.snippet.bundled; 18 19 import android.widget.Toast; 20 import androidx.test.platform.app.InstrumentationRegistry; 21 import com.google.android.mobly.snippet.Snippet; 22 import com.google.android.mobly.snippet.rpc.Rpc; 23 import com.google.android.mobly.snippet.rpc.RunOnUiThread; 24 25 /** Snippet class exposing Android APIs related to creating notification on screen. */ 26 public class NotificationSnippet implements Snippet { 27 28 @RunOnUiThread 29 @Rpc(description = "Make a toast on screen.") makeToast(String message)30 public void makeToast(String message) { 31 Toast.makeText( 32 InstrumentationRegistry.getInstrumentation().getContext(), 33 message, 34 Toast.LENGTH_LONG) 35 .show(); 36 } 37 38 @Override shutdown()39 public void shutdown() {} 40 } 41