1 /* 2 * Copyright (C) 2019 The Android Open Source Project. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of 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, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.car.frameworkpackagestubs; 18 19 import android.app.Activity; 20 import android.os.Bundle; 21 import android.widget.Toast; 22 23 /** 24 * Contains different stub classes. 25 * 26 * <p>These are broken out so that the intent filters are easier to track and so that 27 * individual ones can create more specific messages if desired. 28 */ 29 public final class Stubs { 30 31 /** 32 * Base class for stubs. 33 * 34 * <p>Shows a toast and finishes. 35 * 36 * <p>Subclasses can override {@link #getMessage()} to customize the message. 37 */ 38 private static class BaseActivity extends Activity { 39 40 private Toast mToast; 41 42 @Override onCreate(Bundle savedInstanceState)43 protected void onCreate(Bundle savedInstanceState) { 44 super.onCreate(savedInstanceState); 45 showToast(); 46 finish(); 47 } 48 getMessage()49 protected CharSequence getMessage() { 50 return getResources().getString(R.string.message_not_supported); 51 } 52 showToast()53 private void showToast() { 54 cancelToast(); 55 mToast = Toast.makeText(this, getMessage(), Toast.LENGTH_LONG); 56 mToast.show(); 57 } 58 cancelToast()59 private void cancelToast() { 60 if (mToast != null) { 61 mToast.cancel(); 62 } 63 } 64 } 65 66 /** 67 * Stub activity for Browser events. 68 */ 69 public static class BrowserStub extends BaseActivity { } 70 71 /** 72 * Stub activity for Calendar events. 73 */ 74 public static class CalendarStub extends BaseActivity { } 75 76 /** 77 * Stub activity for Desk Clock events. 78 */ 79 public static class DeskClockStub extends BaseActivity { } 80 81 /** 82 * Stub activity for Dialer events. 83 */ 84 public static class DialerStub extends BaseActivity { } 85 86 /** 87 * Stub activity for media events. 88 */ 89 public static class MediaStub extends BaseActivity { } 90 91 /** 92 * Stub activity for setting events. 93 */ 94 public static class SettingsStub extends BaseActivity { } 95 96 /** 97 * Stub activity for ignore background data restriction setting. 98 */ 99 public static class IgnoreBackgroundDataRestrictionsSettingsStub extends BaseActivity { } 100 101 /** 102 * Stub activity for ignore battery optimization setting. 103 */ 104 public static class IgnoreBatteryOptimizationSettingsStub extends BaseActivity { } 105 106 /** 107 * Stub activity for request battery optimization. 108 */ 109 public static class RequestIgnoreBatteryOptimizationsStub extends BaseActivity { } 110 111 /** 112 * Stub activity for webview setting. 113 */ 114 public static class WebViewSettingsStub extends BaseActivity { } 115 } 116