Fix google3 "java code clarity" issue
Bug: 162268101
Bug: 170343703
Test: Manual
Change-Id: Ie0b99c189f8c2b20d084651cdde024ef91e19803
Merged-In: Ie0b99c189f8c2b20d084651cdde024ef91e19803
diff --git a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/Toolbar.java b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/Toolbar.java
index 45e344d..e527a52 100644
--- a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/Toolbar.java
+++ b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/Toolbar.java
@@ -33,6 +33,7 @@
import com.android.car.ui.R;
import com.android.car.ui.imewidescreen.CarUiImeSearchListItem;
+import com.android.car.ui.recyclerview.CarUiListItem;
import java.util.List;
@@ -678,7 +679,7 @@
* <p>Note: Apps can only call this method if the package name is allowed via OEM to render
* their view. To check if the application have the permission to do so or not first call
* {@link #canShowSearchResultsView()}. If the app is not allowed this method will throw an
- * {@link RuntimeException}
+ * {@link IllegalStateException}
*
* @param view to be added in the container.
*/
@@ -688,9 +689,10 @@
}
/**
- * Sets a list of search items to be displayed in the IME window when running as a wide screen
- * mode. This should be called each time the list is updated. For example, when a user is typing
- * in the input field and the list gets filtered this method should be invoked each time.
+ * Sets list of search item {@link CarUiListItem} to be displayed in the IMS
+ * template. This method should be called when system is running in a wide screen mode. Apps
+ * can check that by using {@link #canShowSearchResultItems()}
+ * Else, this method will throw an {@link IllegalStateException}
*/
@Override
public void setSearchResultItems(List<? extends CarUiImeSearchListItem> searchItems) {
diff --git a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarController.java b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarController.java
index 654fe93..6b38718 100644
--- a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarController.java
+++ b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarController.java
@@ -296,7 +296,7 @@
* <p>Note: Apps can only call this method if the package name is allowed via OEM to render
* their view. To check if the application have the permission to do so or not first call
* {@link #canShowSearchResultsView()}. If the app is not allowed this method will throw an
- * {@link RuntimeException}
+ * {@link IllegalStateException}
*
* @param view to be added in the container.
*/
@@ -306,7 +306,7 @@
* Sets list of search item {@link CarUiListItem} to be displayed in the IMS
* template. This method should be called when system is running in a wide screen mode. Apps
* can check that by using {@link #canShowSearchResultItems()}
- * Else, this method will throw an {@link RuntimeException}
+ * Else, this method will throw an {@link IllegalStateException}
*/
void setSearchResultItems(List<? extends CarUiImeSearchListItem> searchItems);
diff --git a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarControllerImpl.java b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarControllerImpl.java
index e1397a4..02b3a1a 100644
--- a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarControllerImpl.java
+++ b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarControllerImpl.java
@@ -866,15 +866,16 @@
* results.
*
* <p>Note: Apps can only call this method if the package name is allowed via OEM to render
- * their view. If the app is not allowed this method will throw an
- * {@link IllegalAccessException}
+ * their view. To check if the application have the permission to do so or not first call
+ * {@link #canShowSearchResultsView()}. If the app is not allowed this method will throw an
+ * {@link IllegalStateException}
*
* @param view to be added in the container.
*/
@Override
public void setSearchResultsView(View view) {
if (!canShowSearchResultsView()) {
- throw new RuntimeException(
+ throw new IllegalStateException(
"not allowed to add view to wide screen IME, package name: "
+ mContext.getPackageName());
}
@@ -890,12 +891,12 @@
* Sets list of search item {@link CarUiListItem} to be displayed in the IMS
* template. This method should be called when system is running in a wide screen mode. Apps
* can check that by using {@link #canShowSearchResultItems()}
- * Else, this method would have no effect.
+ * Else, this method will throw an {@link IllegalStateException}
*/
@Override
public void setSearchResultItems(List<? extends CarUiImeSearchListItem> searchItems) {
if (!canShowSearchResultItems()) {
- throw new RuntimeException(
+ throw new IllegalStateException(
"system not in wide screen mode, not allowed to set search result items ");
}
mSearchItems = searchItems;