<string name="user_tapped_fmt">User tapped \'%s\'</string>
<string name="user_navigated_away_from_dialog">User navigated away from dialog</string>
<string name="user_canceled_dialog">User canceled dialog</string>
+ <string name="admin_disabled">Admin disabled</string>
<string name="admin_disable_requested">Admin disable requested</string>
<string name="admin_enabled">Admin enabled</string>
<string name="device_password_changed">Device password changed</string>
<string name="device_login_succeeded">Device login succeeded</string>
<string name="logging_in">Logging in…</string>
<string name="phone_status_idle">Phone is now idle</string>
- <string name="phone_status_ringing">"Phone is ringing. Incoming number: "</string>
+ <string name="phone_status_ringing">"Phone is ringing. Incoming number: %s"</string>
<string name="phone_status_offhook">Phone is offhook</string>
<string name="location">Location</string>
<string name="latitude">Latitude</string>
Example: rootsh stop;sleep 3;start
</string>
<string name="command_not_documented">This command is not documented (yet).</string>
+ <string name="sms_sent">SMS sent (%s)</string>
+ <string name="sms_not_sent_generic_failure">SMS not sent: Generic failure (%s)</string>
+ <string name="sms_not_sent_no_service">SMS not sent: No service (%s)</string>
+ <string name="sms_not_sent_null_pdu">SMS not sent: Null PDU (%s)</string>
+ <string name="sms_not_sent_radio_off">SMS not sent: Radio off (%s)</string>
+ <string name="sms_delivered">SMS delivered (%s)</string>
+ <string name="sms_not_delivered">SMS not delivered (%s)</string>
</resources>
return;
Utils.sendMessage(DialogActivity.this, toNonNull(address),
- toNonNull(getString(user_tapped_fmt, ((Button)v).getText())));
+ user_tapped_fmt, ((Button)v).getText());
gotAnswer=true;
finish();
}
super.onStop();
if(!gotAnswer){
Utils.sendMessage(this, toNonNull(address),
- toNonNull(getString(user_navigated_away_from_dialog)));
+ user_navigated_away_from_dialog);
gotAnswer=true;
}
finish();
public void onBackPressed() {
if(!gotAnswer){
Utils.sendMessage(this, toNonNull(address),
- toNonNull(getString(user_canceled_dialog)));
+ user_canceled_dialog);
gotAnswer=true;
}
finish();
public void onDisabled(@Nullable final Context context, @Nullable final Intent intent) {
if(context==null)
return;
- Utils.sendMessage(context, toNonNull(MessageType.ADMIN), "Admin disabled");
+ Utils.sendMessage(context, toNonNull(MessageType.ADMIN), admin_disabled);
}
@Override
Log.wtf(getClass().getName(), "context is null in onDisableRequested");
throw new AssertionError("Log.wtf did not terminate the process");
}
- Utils.sendMessage(context, toNonNull(MessageType.ADMIN),
- toNonNull(context.getString(admin_disable_requested)));
+ Utils.sendMessage(context, toNonNull(MessageType.ADMIN), admin_disable_requested);
return null;//TODO: write this
}
public void onEnabled(@Nullable final Context context, @Nullable final Intent intent) {
if(context==null)
return;
- Utils.sendMessage(context, toNonNull(MessageType.ADMIN),
- toNonNull(context.getString(admin_enabled)));
+ Utils.sendMessage(context, toNonNull(MessageType.ADMIN), admin_enabled);
}
@Override
public void onPasswordChanged(@Nullable final Context context, @Nullable final Intent intent) {
if(context==null)
return;
- Utils.sendMessage(context, toNonNull(MessageType.ADMIN),
- toNonNull(context.getString(device_password_changed)));
+ Utils.sendMessage(context, toNonNull(MessageType.ADMIN), device_password_changed);
}
@SuppressWarnings("boxing")
if(context==null)
return;
final DevicePolicyManager dpm=(DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
- Utils.sendMessage(context, toNonNull(MessageType.WATCH_LOGIN),
- toNonNull(context.getString(device_login_failed_fmt, dpm.getCurrentFailedPasswordAttempts())));
+ Utils.sendMessage(context, toNonNull(MessageType.WATCH_LOGIN), device_login_failed_fmt, dpm.getCurrentFailedPasswordAttempts());
}
@Override
public void onPasswordSucceeded(@Nullable final Context context, @Nullable final Intent intent) {
if(context==null)
return;
- Utils.sendMessage(context, toNonNull(MessageType.WATCH_LOGIN), toNonNull(context.getString(device_login_succeeded)));
+ Utils.sendMessage(context, toNonNull(MessageType.WATCH_LOGIN), device_login_succeeded);
}
}
switch(state){
case TelephonyManager.CALL_STATE_IDLE:
- Utils.sendMessage(context, toNonNull(MessageType.PHONE_STATE),
- toNonNull(context.getString(phone_status_idle)));
+ Utils.sendMessage(context, toNonNull(MessageType.PHONE_STATE), phone_status_idle);
break;
case TelephonyManager.CALL_STATE_RINGING:
if(incomingNumber==null)
return;
final String name=Utils.callerId(context, incomingNumber);
if(name==null)
- Utils.sendMessage(context, toNonNull(MessageType.PHONE_STATE),
- context.getString(phone_status_ringing)+incomingNumber);
+ Utils.sendMessage(context, toNonNull(MessageType.PHONE_STATE), phone_status_ringing, incomingNumber);
else
Utils.sendMessage(context, toNonNull(MessageType.PHONE_STATE),
- context.getString(phone_status_ringing)+incomingNumber+" ("+name+")");
+ phone_status_ringing, incomingNumber + " ("+name+")");
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
- Utils.sendMessage(context, toNonNull(MessageType.PHONE_STATE),
- toNonNull(context.getString(phone_status_offhook)));
+ Utils.sendMessage(context, toNonNull(MessageType.PHONE_STATE), phone_status_offhook);
break;
}
}
try{
sock = SocketChannel.open(new InetSocketAddress(hostname, port));
} catch (final IOException e){
- Utils.sendMessage(context, replyTo, toNonNull(context.getString(cannot_connect_to_host_on_port, hostname, Integer.valueOf(port))));
+ Utils.sendMessage(context, replyTo, cannot_connect_to_host_on_port, hostname, Integer.valueOf(port));
try {
in.close();
} catch (IOException ex) {
try{
in.transferTo(0, in.size(), sock);
} catch (final IOException e){
- Utils.sendMessage(context, replyTo, toNonNull(context.getString(io_error, e.getMessage())));
+ Utils.sendMessage(context, replyTo, io_error, e.getMessage());
} finally {
try{
in.close();
sock = new Socket(hostname, port);
in = sock.getInputStream();
} catch (final IOException e){
- Utils.sendMessage(context, replyTo, toNonNull(context.getString(cannot_connect_to_host_on_port, hostname, Integer.valueOf(port))));
+ Utils.sendMessage(context, replyTo, cannot_connect_to_host_on_port, hostname, Integer.valueOf(port));
try {
out.close();
} catch (IOException ex) {
while((nread = in.read(buffer)) > 0)
out.write(buffer, 0, nread);
} catch (final IOException e){
- Utils.sendMessage(context, replyTo, toNonNull(context.getString(io_error, e.getMessage())));
+ Utils.sendMessage(context, replyTo, io_error, e.getMessage());
} finally {
try{
out.close();
CommonDataKinds.Phone.LABEL);
while(inCursor.moveToNext())
- Utils.sendMessage(context, replyTo, toNonNull(context.getString(contact_info,
+ Utils.sendMessage(context, replyTo, contact_info,
cursor.getString(0),
inCursor.getString(0),
- phoneNumberType(context, inCursor.getInt(1), inCursor.getString(2)))));
+ phoneNumberType(context, inCursor.getInt(1), inCursor.getString(2)));
inCursor.close();
}
final String action=intent.getAction();
if(action.equals(Intent.ACTION_BATTERY_LOW)){
- Utils.sendMessage(context, toNonNull(MessageType.BATTERY),
- toNonNull(context.getString(battery_low)));
+ Utils.sendMessage(context, toNonNull(MessageType.BATTERY), battery_low);
Heavy.describeBatteryLevel(context, null, toNonNull(MessageType.BATTERY));
} else if(action.equals(Intent.ACTION_BATTERY_OKAY)){
- Utils.sendMessage(context, toNonNull(MessageType.BATTERY),
- toNonNull(context.getString(battery_okay)));
+ Utils.sendMessage(context, toNonNull(MessageType.BATTERY),battery_okay);
Heavy.describeBatteryLevel(context, null, toNonNull(MessageType.BATTERY));
} else if(action.equals(Intent.ACTION_BOOT_COMPLETED)){
- Utils.sendMessage(context, toNonNull(MessageType.BOOT),
- toNonNull(context.getString(device_booted)));
+ Utils.sendMessage(context, toNonNull(MessageType.BOOT), device_booted);
} else if(action.equals(ConnectivityManager.CONNECTIVITY_ACTION))
context.startService(new Intent(context, FonBotMainService.class));
}
package ro.ieval.fonbot;
+import static ro.ieval.fonbot.R.string.*;
import org.eclipse.jdt.annotation.Nullable;
import android.app.Activity;
* @return the string representation of the SMS
*/
private static String describeSMS(final Intent intent){
- return " ("+"To: "+intent.getStringExtra(EXTRA_DESTINATION)+
- ", Part: "+intent.getIntExtra(EXTRA_PART, 1)+" of "+intent.getIntExtra(EXTRA_TOTAL, 1)+")";
+ return "To: "+intent.getStringExtra(EXTRA_DESTINATION)+
+ ", Part: "+intent.getIntExtra(EXTRA_PART, 1)+" of "+intent.getIntExtra(EXTRA_TOTAL, 1);
}
/**
if(intent.getAction().startsWith(SENT_ACTION))
switch(getResultCode()){
case Activity.RESULT_OK:
- Utils.sendMessage(context, replyTo, "SMS sent"+describeSMS(intent));
+ Utils.sendMessage(context, replyTo, sms_sent, describeSMS(intent));
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
- Utils.sendMessage(context, replyTo, "SMS not sent: Generic failure"+describeSMS(intent));
+ Utils.sendMessage(context, replyTo, sms_not_sent_generic_failure, describeSMS(intent));
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
- Utils.sendMessage(context, replyTo, "SMS not sent: No service"+describeSMS(intent));
+ Utils.sendMessage(context, replyTo, sms_not_sent_no_service, describeSMS(intent));
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
- Utils.sendMessage(context, replyTo, "SMS not sent: Null PDU"+describeSMS(intent));
+ Utils.sendMessage(context, replyTo, sms_not_sent_null_pdu, describeSMS(intent));
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
- Utils.sendMessage(context, replyTo, "SMS not sent: Radio off"+describeSMS(intent));
+ Utils.sendMessage(context, replyTo, sms_not_sent_radio_off, describeSMS(intent));
break;
}
else if(intent.getAction().startsWith(DELIVERED_ACTION))
switch(getResultCode()){
case Activity.RESULT_OK:
- Utils.sendMessage(context, replyTo, "SMS delivered"+describeSMS(intent));
+ Utils.sendMessage(context, replyTo, sms_delivered, describeSMS(intent));
break;
case Activity.RESULT_CANCELED:
- Utils.sendMessage(context, replyTo, "SMS not delivered"+describeSMS(intent));
+ Utils.sendMessage(context, replyTo, sms_not_delivered, describeSMS(intent));
break;
}
}