public void onPasswordFailed(@Nullable final Context context, @Nullable final Intent intent) {
if(context==null)
return;
- final DevicePolicyManager dpm=(DevicePolicyManager) FonBotApplication.instance.getSystemService(Context.DEVICE_POLICY_SERVICE);
+ 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())));
}
* iEval GCM sender id
*/
public static final String GCM_SENDER_ID = "379674287523";
- /**
- * The one instance of FonBotApplication
- */
- public static FonBotApplication instance=null;
- /**
- * The GCM registration ID
- */
- public String regID=null;
@Override
public void onCreate() {
super.onCreate();
//GCMRegistrar.checkDevice(this);
- regID=GCMRegistrar.getRegistrationId(this);
+ final String regID=GCMRegistrar.getRegistrationId(this);
if("".equals(regID))
GCMRegistrar.register(this, GCM_SENDER_ID);
final TelephonyManager tman=(TelephonyManager) getSystemService(TELEPHONY_SERVICE);
tman.listen(new FonBotPhoneStateListener(this), PhoneStateListener.LISTEN_CALL_STATE);
- instance=this;
new PollServerAsyncTask(this).execute();
@Override
protected void onRegistered(@Nullable final Context context, @Nullable final String regID) {
- FonBotApplication.instance.regID=regID;
+ //do nothing
}
@Override
import android.util.Base64;
import android.util.Log;
+import com.google.android.gcm.GCMRegistrar;
+
/*
* Copyright © 2013 Marius Gavrilescu
*
try {
final URL url=Utils.getServerURL(toNonNull(context),"/get");
final HttpURLConnection conn=(HttpURLConnection) url.openConnection();
- conn.setRequestProperty("X-ID", FonBotApplication.instance.regID);
+ conn.setRequestProperty("X-ID", GCMRegistrar.getRegistrationId(context));
final String user=PreferenceManager.getDefaultSharedPreferences(context).getString("username", null);
final String password=PreferenceManager.getDefaultSharedPreferences(context).getString("password", null);
if(user == null || password == null)
Log.d(getClass().getName(), "Poll got command "+command.command+" with "+((command.args.length==0)?"no args":"args "+Utils.join(
" ",toNonNull(command.args))));
Utils.processCommand(
- toNonNull(FonBotApplication.instance),
+ toNonNull(context),
toNonNull(command.command),
toNonNull(command.args),
new Address(toNonNull(Protocol.HTTP), command.replyto));//NOPMD address depends on command
import android.util.Base64;
import android.util.Log;
+import com.google.android.gcm.GCMRegistrar;
+
/*
* Copyright © 2013 Marius Gavrilescu
*
conn.setDoOutput(true);
conn.setFixedLengthStreamingMode(msg.length);
}
- conn.setRequestProperty("X-ID", FonBotApplication.instance.regID);
+ conn.setRequestProperty("X-ID", GCMRegistrar.getRegistrationId(context));
final String user=PreferenceManager.getDefaultSharedPreferences(context).getString("username", null);
final String password=PreferenceManager.getDefaultSharedPreferences(context).getString("password", null);
if(user == null || password == null)