1 /* 2 * Copyright (C) 2021 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 android.app; 18 19 /** 20 * Interface to control the ANR dialog within the activity manager 21 * {@hide} 22 */ 23 public interface AnrController { 24 /** 25 * Returns the delay in milliseconds for an ANR dialog that is about to be shown for 26 * {@code packageName} with {@code uid}. 27 * 28 * Implementations should only return a positive value if they actually expect the 29 * {@code packageName} to be delayed due to them. 30 31 * If there are multiple controllers registered, the controller with the max delay will 32 * be selected and will receive an {@link #onAnrDelayStarted} callback at the start of the 33 * delay and an {@link #onAnrDelayCompleted} at the end of the delay. 34 */ getAnrDelayMillis(String packageName, int uid)35 long getAnrDelayMillis(String packageName, int uid); 36 37 /** 38 * Notifies the controller at the start of the ANR dialog delay for {@code packageName} with 39 * {@code uid}. The controller can decide to show a progress UI after this notification. 40 */ onAnrDelayStarted(String packageName, int uid)41 void onAnrDelayStarted(String packageName, int uid); 42 43 /** 44 * Notifies the controller at the end of the ANR dialog delay for {@code packageName} with 45 * {@code uid}. 46 * 47 * @return whether the ANR dialog should be shown or cancelled. {@code true} if the 48 * ANR dialog should be shown, {@code false} if it should be cancelled. 49 */ onAnrDelayCompleted(String packageName, int uid)50 boolean onAnrDelayCompleted(String packageName, int uid); 51 } 52