package cn.com.xetion;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
import android.database.Cursor;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Handler;
import android.text.TextUtils;
import cn.com.xetion.logic.AccountLogic;
import cn.com.xetion.protobuf.receiver.BNRegistrationReqArgs;
import cn.com.xetion.store.Config;
import cn.com.xetion.store.Config.User;
import cn.com.xetion.store.xetionContract;
import cn.com.xetion.util.AndroidUtil;
import java.net.URLEncoder;
public class Account
{
public static final String ACTION_SET_ACCOUNT_CACHE = "cn.com.xetion.Account.ACTION_SET_ACCOUNT_CACHE";
public static final String EXTRA_CREDENTIAL = "cn.com.xetion.Account.EXTRA_CREDENTIAL";
public static final String EXTRA_DESCRIPTION = "cn.com.xetion.Account.EXTRA_VERSION_DESCRIPTION";
public static final String EXTRA_ENCRYPTED_CREDENTIAL = "cn.com.xetion.Account.EXTRA_ENCRYPTED_CREDENTIAL";
public static final String EXTRA_ENCRYPTED_PASSWORD = "cn.com.xetion.Account.EXTRA_ENCRYPTED_PASSWORD";
public static final String EXTRA_EPID = "cn.com.xetion.Account.EXTRA_EPID";
public static final String EXTRA_INSTALL_URL = "cn.com.xetion.Account.EXTRA_VERSION_INSTALL_URL";
public static final String EXTRA_IS_ONLINE = "cn.com.xetion.Account.EXTRA_IS_ONLINE";
public static final String EXTRA_LOGIN_NAME = "cn.com.xetion.Account.EXTRA_LOGIN_NAME";
public static final String EXTRA_PORTRAIT = "cn.com.xetion.Account.EXTRA_PORTRAIT";
public static final String EXTRA_UPDATE_ALWAYS_SHOW = "cn.com.xetion.Account.EXTRA_UPDATE_ALWAYS_SHOW";
public static final String EXTRA_USER_ID = "cn.com.xetion.Account.EXTRA_USER_ID";
public static final String EXTRA_VERSION_COMPATIBLE = "cn.com.xetion.Account.EXTRA_VERSION_COMPATIBLE";
public static final String EXTRA_VERSION_HIGHEST = "cn.com.xetion.Account.EXTRA_VERSION_HIGHEST";
private static final String TAG = "Account";
private static Context sContext;
private static String sCredential;
private static String sEncryptedPassword;
private static String sEpid;
private static boolean sIsKicked = true;
private static boolean sIsOnline;
private static String sLoginName;
private static int sLoginType;
private static String sMobileNumber;
private static String sName;
private static String sNickName;
private static ContentObserver sObserver;
private static BroadcastReceiver sReceiver;
private static int sSid;
private static String sUri;
private static String sUserCarrier;
private static String sUserCarrierRegion;
private static int sUserCarrierStatus;
private static String urlEncodeCredential;
public static void clearStatus()
{
sIsOnline = false;
sIsKicked = false;
sEpid = null;
sCredential = null;
}
public static void destroy()
{
if (sReceiver != null)
sContext.unregisterReceiver(sReceiver);
if (sObserver != null)
sContext.getContentResolver().unregisterContentObserver(sObserver);
clearStatus();
}
public static String getCaiyunCredential()
{
return Config.User.getString("CAIYUN_CREDENTIAL", "");
}
public static String getCredential()
{
return sCredential;
}
public static String getEncryptCredential()
{
return Config.User.getString("ENCRYPT_CREDENTIAL", "");
}
public static String getEncryptedPassword()
{
return sEncryptedPassword;
}
public static String getEpayCredential()
{
return Config.User.getString("EPAY_CREDENTIAL", "");
}
public static String getEpid()
{
return sEpid;
}
public static String getLoginName()
{
return sLoginName;
}
public static String getMcloudCredential()
{
return Config.User.getString("MCLOUD_CREDENTIAL", "");
}
public static String getMobileNumber()
{
return sMobileNumber;
}
public static String getName()
{
return sName;
}
public static String getNickName()
{
return sNickName;
}
public static String getServices()
{
return Config.User.getString("SERVICES", null);
}
public static int getSid()
{
return sSid;
}
public static String getUri()
{
return sUri;
}
public static String getUrlEncodeCredential()
{
String str;
if (urlEncodeCredential == null)
str = "";
while (true)
{
return str;
str = urlEncodeCredential;
}
}
public static String getUserCarrier()
{
return sUserCarrier;
}
public static String getUserCarrierRegion()
{
return sUserCarrierRegion;
}
public static int getUserCarrierStatus()
{
return sUserCarrierStatus;
}
public static int getUserId()
{
return Config.getUserId();
}
public static int getsLoginType()
{
return sLoginType;
}
public static void init(Context paramContext, boolean paramBoolean)
{
sContext = paramContext.getApplicationContext();
sLoginName = Config.User.getString("USER_LONIN_NAME", null);
sEncryptedPassword = Config.User.getString("USER_ENCRYPTED_PASSWORD", null);
sLoginType = Config.User.getInt("USER_ENCRYPTED_LOGIN_TYPE", 0);
sUserCarrier = Config.User.getString("USER_CARRIER", null);
sUserCarrierRegion = Config.User.getString("CARRIERREGION", null);
if (paramBoolean)
{
IntentFilter localIntentFilter = new IntentFilter();
localIntentFilter.addAction("cn.com.xetion.logic.AccountLogic.ACTION_GET_NAV_INFO");
localIntentFilter.addAction("cn.com.xetion.logic.AccountLogic.ACTION_LOGIN");
localIntentFilter.addAction("cn.com.xetion.logic.AccountLogic.ACTION_LOGIN_FOR_CACHE");
localIntentFilter.addAction("cn.com.xetion.logic.AccountLogic.ACTION_CANCEL_LOGIN");
localIntentFilter.addAction("cn.com.xetion.logic.AccountLogic.ACTION_LOGOUT");
localIntentFilter.addAction("cn.com.xetion.logic.AccountLogic.ACTION_EXIT");
localIntentFilter.addAction("cn.com.xetion.logic.AccountLogic.ACTION_REGISTRATION");
localIntentFilter.addAction("cn.com.xetion.ACTION_KEEP_ALIVE_RESPONSE");
localIntentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
sReceiver = new BroadcastReceiver()
{
public void onReceive(, Intent paramIntent)
{
LogF.d("Account", "onReceive.intent = " + AndroidUtil.toString(paramIntent));
if ("cn.com.xetion.logic.AccountLogic.ACTION_GET_NAV_INFO".equals(paramIntent.getAction()))
{
if (200 == paramIntent.getIntExtra("cn.com.xetion.logic.BaseLogic.EXTRA_STATUE_CODE", -1))
{
int i = paramIntent.getIntExtra("cn.com.xetion.Account.EXTRA_USER_ID", -1);
if (i != -1)
Account.setUserId(i);
}
Account.setLoginName(paramIntent.getStringExtra("cn.com.xetion.Account.EXTRA_LOGIN_NAME"));
}
while (true)
{
label203: NetworkInfo localNetworkInfo;
do
{
label265:
do
while (true)
{
while (true)
{
while (true)
{
while (true)
{
while (true)
{
while (true)
{
return;
if ((!("cn.com.xetion.logic.AccountLogic.ACTION_LOGIN".equals(paramIntent.getAction()))) && (!("cn.com.xetion.logic.AccountLogic.ACTION_LOGIN_FOR_CACHE".equals(paramIntent.getAction()))))
break;
Account.reloadUserInfo();
Account.setEncryptedPassword(paramIntent.getStringExtra("cn.com.xetion.Account.EXTRA_ENCRYPTED_PASSWORD"));
Account.setEpid(paramIntent.getStringExtra("cn.com.xetion.Account.EXTRA_EPID"));
Account.setCredential(paramIntent.getStringExtra("cn.com.xetion.Account.EXTRA_CREDENTIAL"));
}
if ((!("cn.com.xetion.logic.AccountLogic.ACTION_CANCEL_LOGIN".equals(paramIntent.getAction()))) && (!("cn.com.xetion.logic.AccountLogic.ACTION_LOGOUT".equals(paramIntent.getAction()))) && (!("cn.com.xetion.logic.AccountLogic.ACTION_EXIT".equals(paramIntent.getAction()))))
break label203;
if (!("cn.com.xetion.logic.AccountLogic.ACTION_EXIT".equals(paramIntent.getAction())))
break;
Account.destroy();
}
Account.clearStatus();
}
if (!("cn.com.xetion.ACTION_KEEP_ALIVE_RESPONSE".equals(paramIntent.getAction())))
break;
Account.setCredential(paramIntent.getStringExtra("cn.com.xetion.Account.EXTRA_CREDENTIAL"));
}
if (!("cn.com.xetion.logic.AccountLogic.ACTION_REGISTRATION".equals(paramIntent.getAction())))
break label265;
if (!(BNRegistrationReqArgs.isKicked(paramIntent.getStringExtra("cn.com.xetion.logic.AccountLogic.EXTRA_REGISTRATION_EVENT_TYPE"))))
break;
AccountLogic.changeLoginStatus(4);
}
AccountLogic.changeLoginStatus(1);
}
while (!("android.net.conn.CONNECTIVITY_CHANGE".equals(paramIntent.getAction())));
localNetworkInfo = (NetworkInfo)paramIntent.getParcelableExtra("networkInfo");
}
while ((localNetworkInfo == null) || (localNetworkInfo.isConnected()) || (AccountLogic.loadCurrentLoginStatus() == 4));
AccountLogic.changeLoginStatus(1);
}
}
};
sContext.registerReceiver(sReceiver, localIntentFilter);
}
sObserver = new ContentObserver(null)
{
public void onChange()
{
Account.reloadUserInfo();
}
};
sContext.getContentResolver().registerContentObserver(xetionContract.USER_URI, false, sObserver);
}
public static boolean isGDNumber_homenet()
{
int i;
sUserCarrier = Config.User.getString("USER_CARRIER", null);
sUserCarrierRegion = Config.User.getString("CARRIERREGION", null);
if ((!(TextUtils.isEmpty(sUserCarrier))) && (!(TextUtils.isEmpty(sUserCarrierRegion))) && (sUserCarrierRegion.startsWith("CN.gd")))
i = 1;
while (true)
{
return i;
i = 0;
}
}
public static boolean isVIP()
{
return Config.User.getBoolean("VIP", false);
}
public static void reloadUserInfo()
{
Cursor localCursor;
if (sContext != null)
localCursor = null;
try
{
ContentResolver localContentResolver = sContext.getContentResolver();
Uri localUri = xetionContract.USER_URI;
String[] arrayOfString1 = new String[5];
arrayOfString1[0] = "sid";
arrayOfString1[1] = "uri";
arrayOfString1[2] = "name";
arrayOfString1[3] = "mobile_no";
arrayOfString1[4] = "nick_name";
String[] arrayOfString2 = new String[1];
arrayOfString2[0] = String.valueOf(getUserId());
localCursor = localContentResolver.query(localUri, arrayOfString1, "_id = ?", arrayOfString2, null);
if ((localCursor != null) && (localCursor.moveToFirst()))
{
setSid(localCursor.getInt(localCursor.getColumnIndex("sid")));
setUri(localCursor.getString(localCursor.getColumnIndex("uri")));
setName(localCursor.getString(localCursor.getColumnIndex("name")));
setMobileNumber(localCursor.getString(localCursor.getColumnIndex("mobile_no")));
setNickName(localCursor.getString(localCursor.getColumnIndex("nick_name")));
}
return;
}
finally
{
if (localCursor != null)
localCursor.close();
}
}
public static void setCredential(String paramString)
{
sCredential = paramString;
if (paramString != null);
try
{
if (!("".equals(paramString)))
urlEncodeCredential = URLEncoder.encode(paramString);
return;
}
catch (Exception localException)
{
localException.printStackTrace();
}
}
public static void setEncryptedPassword(String paramString)
{
sEncryptedPassword = paramString;
}
public static void setEpid(String paramString)
{
sEpid = paramString;
}
public static void setLoginName(String paramString)
{
sLoginName = paramString;
}
public static void setMobileNumber(String paramString)
{
sMobileNumber = paramString;
}
public static void setName(String paramString)
{
sName = paramString;
}
public static void setNickName(String paramString)
{
sNickName = paramString;
}
public static void setSid(int paramInt)
{
sSid = paramInt;
}
public static void setUri(String paramString)
{
sUri = paramString;
}
public static void setUserCarrier(String paramString)
{
sUserCarrier = paramString;
}
public static void setUserCarrierRegion(String paramString)
{
sUserCarrierRegion = paramString;
}
public static void setUserCarrierStatus(int paramInt)
{
sUserCarrierStatus = paramInt;
}
public static void setUserId(int paramInt)
{
Config.setUserId(paramInt);
}
public static void setsLoginType(int paramInt)
{
sLoginType = paramInt;
}
}
The source code of the Account class of the famous IM app
最新推荐文章于 2024-11-04 11:45:54 发布