From fd6ca6c8d4043855c6b066fea792c289c459971e Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Tue, 23 Jun 2015 13:35:28 -0700 Subject: [PATCH] Handle volume benchmark timeout If a volume benchmark operation times out, we don't want to show a cryptic toast message. Instead, we return a very large integer [eg Long.MAX_INT]. The storage wizard can then use this value to show an appropriate dialog if it chooses. Bug: 21376364 Change-Id: I3d97336e19c93511cfff2cbdb2f07ab033a1143d --- .../android/server/NativeDaemonConnector.java | 2 +- .../server/NativeDaemonTimeoutException.java | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 services/core/java/com/android/server/NativeDaemonTimeoutException.java diff --git a/services/core/java/com/android/server/NativeDaemonConnector.java b/services/core/java/com/android/server/NativeDaemonConnector.java index 78c7f385a1..e7979e4310 100644 --- a/services/core/java/com/android/server/NativeDaemonConnector.java +++ b/services/core/java/com/android/server/NativeDaemonConnector.java @@ -421,7 +421,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo event = mResponseQueue.remove(sequenceNumber, timeout, logCmd); if (event == null) { loge("timed-out waiting for response to " + logCmd); - throw new NativeDaemonFailureException(logCmd, event); + throw new NativeDaemonTimeoutException(logCmd, event); } if (VDBG) log("RMV <- {" + event + "}"); events.add(event); diff --git a/services/core/java/com/android/server/NativeDaemonTimeoutException.java b/services/core/java/com/android/server/NativeDaemonTimeoutException.java new file mode 100644 index 0000000000..658f7d6264 --- /dev/null +++ b/services/core/java/com/android/server/NativeDaemonTimeoutException.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server; + +/** + * An exception that indicates there was a timeout with a + * {@link NativeDaemonConnector} operation. + */ +public class NativeDaemonTimeoutException extends NativeDaemonConnectorException { + public NativeDaemonTimeoutException(String command, NativeDaemonEvent event) { + super(command, event); + } +} +