<commit_before>package cn.mutils.app;

import java.lang.Thread.UncaughtExceptionHandler;

import com.umeng.analytics.MobclickAgent;
import com.umeng.update.UmengUpdateAgent;
import com.umeng.update.UpdateConfig;
import com.umeng.update.UpdateStatus;

import android.app.Application;
import android.content.Context;
import cn.jpush.android.api.JPushInterface;
import cn.mutils.app.core.log.Logs;
import cn.mutils.app.core.task.RepeatTask;
import cn.mutils.app.core.task.RepeatTask.RepeatTaskListener;
import cn.mutils.app.core.task.RepeatTaskManager;
import cn.mutils.app.os.IContextProvider;
import cn.sharesdk.framework.ShareSDK;

/**
 * Application of framework
 */
public class App extends Application implements IContextProvider {

	/**
	 * Application Edition
	 */
	public static enum Edition {

		/** Debug edition */
		DEBUG,

		/** Beta edition */
		BETA,

		/** Release edition */
		RELEASE

	}

	protected static App sApp;

	protected boolean mUmengEnabled;

	protected boolean mJPushEnabled;

	protected boolean mShareSDKEnabled;

	protected Edition mEdition;

	protected RepeatTaskManager mRepeatTaskManager;

	@Override
	public void onCreate() {

		// Set exception handler to forbid system crash dialog
		Thread.setDefaultUncaughtExceptionHandler(new AppExceptionHandler());

		sApp = this;
		AppLocale.syncLocale(this);
		AppUtil.fixAsyncTask();

		mEdition = detectEdition();
		mUmengEnabled = AppUtil.getAppMetaData(this, "UMENG_APPKEY") != null;
		if (mUmengEnabled) {
			if (mEdition == Edition.DEBUG) {
				MobclickAgent.setDebugMode(true);
				MobclickAgent.setCatchUncaughtExceptions(false);
				UpdateConfig.setDebug(true);
			} else {
				UmengUpdateAgent.setUpdateCheckConfig(false);
			}
			UmengUpdateAgent.setDeltaUpdate(true);
			UmengUpdateAgent.setUpdateOnlyWifi(false);
			UmengUpdateAgent.setUpdateUIStyle(UpdateStatus.STYLE_DIALOG);
			UmengUpdateAgent.setUpdateAutoPopup(false);
		}
		mJPushEnabled = AppUtil.getAppMetaData(this, "JPUSH_APPKEY") != null;
		if (mJPushEnabled) {
			try {
				if (mEdition == Edition.DEBUG) {
					JPushInterface.setDebugMode(true);
				}
				JPushInterface.init(this);
			} catch (Throwable tr) {
				// java.lang.UnsatisfiedLinkError
				Logs.e(AppUtil.TAG_ANDROID_RUNTIME, tr);
			}
		}
		mShareSDKEnabled = AppUtil.isAssetExists(this, "ShareSDK.xml");
		if (mShareSDKEnabled) {
			ShareSDK.initSDK(this);
		}
	}

	/**
	 * Get edition of application<br>
	 * 
	 * @return
	 */<commit_msg>Fix bug for downloading always<commit_after>package cn.mutils.app;

import java.lang.Thread.UncaughtExceptionHandler;

import com.umeng.analytics.MobclickAgent;
import com.umeng.update.UmengUpdateAgent;
import com.umeng.update.UpdateConfig;
import com.umeng.update.UpdateStatus;

import android.app.Application;
import android.content.Context;
import cn.jpush.android.api.JPushInterface;
import cn.mutils.app.core.log.Logs;
import cn.mutils.app.core.task.RepeatTask;
import cn.mutils.app.core.task.RepeatTask.RepeatTaskListener;
import cn.mutils.app.core.task.RepeatTaskManager;
import cn.mutils.app.os.IContextProvider;
import cn.sharesdk.framework.ShareSDK;

/**
 * Application of framework
 */
public class App extends Application implements IContextProvider {

	/**
	 * Application Edition
	 */
	public static enum Edition {

		/** Debug edition */
		DEBUG,

		/** Beta edition */
		BETA,

		/** Release edition */
		RELEASE

	}

	protected static App sApp;

	protected boolean mUmengEnabled;

	protected boolean mJPushEnabled;

	protected boolean mShareSDKEnabled;

	protected Edition mEdition;

	protected RepeatTaskManager mRepeatTaskManager;

	@Override
	public void onCreate() {

		// Set exception handler to forbid system crash dialog
		Thread.setDefaultUncaughtExceptionHandler(new AppExceptionHandler());

		sApp = this;
		AppLocale.syncLocale(this);
		AppUtil.fixAsyncTask();

		mEdition = detectEdition();
		mUmengEnabled = AppUtil.getAppMetaData(this, "UMENG_APPKEY") != null;
		if (mUmengEnabled) {
			if (mEdition == Edition.DEBUG) {
				MobclickAgent.setDebugMode(true);
				MobclickAgent.setCatchUncaughtExceptions(false);
				UpdateConfig.setDebug(true);
			} else {
				UmengUpdateAgent.setUpdateCheckConfig(false);
			}
			// Fix bug for downloading always
			UmengUpdateAgent.setDeltaUpdate(false);
			UmengUpdateAgent.setUpdateOnlyWifi(false);
			UmengUpdateAgent.setUpdateUIStyle(UpdateStatus.STYLE_DIALOG);
			UmengUpdateAgent.setUpdateAutoPopup(false);
		}
		mJPushEnabled = AppUtil.getAppMetaData(this, "JPUSH_APPKEY") != null;
		if (mJPushEnabled) {
			try {
				if (mEdition == Edition.DEBUG) {
					JPushInterface.setDebugMode(true);
				}
				JPushInterface.init(this);
			} catch (Throwable tr) {
				// java.lang.UnsatisfiedLinkError
				Logs.e(AppUtil.TAG_ANDROID_RUNTIME, tr);
			}
		}
		mShareSDKEnabled = AppUtil.isAssetExists(this, "ShareSDK.xml");
		if (mShareSDKEnabled) {
			ShareSDK.initSDK(this);
		}
	}

	/**
	 * Get edition of application<br>
	 * 
	 * @return
	 */
{'fraction_non_alphanumeric': 0.10710690557680692, 'fraction_numerical': 0.0, 'mean_word_length': 4.4593406593406595, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3201495', 'n_tokens_mistral': 1863, 'n_tokens_neox': 1620, 'n_words': 291}