blob: a5d11cf250d80afae0f7bae53ae73f20e4afc41f [file] [log] [blame]
/*
* Copyright (C) 2007 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.internal.telephony;
import com.android.internal.telephony.RILConstants;
import android.util.Log;
/**
* {@hide}
*/
public class CommandException extends RuntimeException {
private Error e;
public enum Error {
INVALID_RESPONSE,
RADIO_NOT_AVAILABLE,
GENERIC_FAILURE,
PASSWORD_INCORRECT,
SIM_PIN2,
SIM_PUK2,
REQUEST_NOT_SUPPORTED,
OP_NOT_ALLOWED_DURING_VOICE_CALL,
OP_NOT_ALLOWED_BEFORE_REG_NW,
SMS_FAIL_RETRY,
}
public CommandException(Error e) {
super(e.toString());
this.e = e;
}
public static CommandException
fromRilErrno(int ril_errno) {
switch(ril_errno) {
case RILConstants.SUCCESS: return null;
case RILConstants.RIL_ERRNO_INVALID_RESPONSE:
return new CommandException(Error.INVALID_RESPONSE);
case RILConstants.RADIO_NOT_AVAILABLE:
return new CommandException(Error.RADIO_NOT_AVAILABLE);
case RILConstants.GENERIC_FAILURE:
return new CommandException(Error.GENERIC_FAILURE);
case RILConstants.PASSWORD_INCORRECT:
return new CommandException(Error.PASSWORD_INCORRECT);
case RILConstants.SIM_PIN2:
return new CommandException(Error.SIM_PIN2);
case RILConstants.SIM_PUK2:
return new CommandException(Error.SIM_PUK2);
case RILConstants.REQUEST_NOT_SUPPORTED:
return new CommandException(Error.REQUEST_NOT_SUPPORTED);
case RILConstants.OP_NOT_ALLOWED_DURING_VOICE_CALL:
return new CommandException(Error.OP_NOT_ALLOWED_DURING_VOICE_CALL);
case RILConstants.OP_NOT_ALLOWED_BEFORE_REG_NW:
return new CommandException(Error.OP_NOT_ALLOWED_BEFORE_REG_NW);
case RILConstants.SMS_SEND_FAIL_RETRY:
return new CommandException(Error.SMS_FAIL_RETRY);
default:
Log.e("GSM", "Unrecognized RIL errno " + ril_errno);
return new CommandException(Error.INVALID_RESPONSE);
}
}
public Error getCommandError() {
return e;
}
}