private static Set<String> generateNewAssetPaths(Application application, String path) {
    Set<String> assetPaths = null;

    if ((path != null) && (assetPathsHistory != null && assetPathsHistory.contains(path))) {
      // already added, just return null
      return null;
    }

    assetPaths = new LinkedHashSet<String>();
    assetPaths.add(application.getApplicationInfo().sourceDir);
    if (ignoreOpt && Build.VERSION.SDK_INT > 20) {
      assetPaths.add(WebViewGoogleAssetPath);
    }

    // get original asset paths on android above 5.0 in case webview not
    // added
    try {
      if (mOriginAssetsPath == null && Build.VERSION.SDK_INT > 20 && !ignoreOpt) {
        mOriginAssetsPath = getOriginAssetsPath(application.getResources().getAssets());
        assetPaths.addAll(mOriginAssetsPath);
      }
    } catch (Throwable e) {
    }

    if (assetPathsHistory != null) assetPaths.addAll(assetPathsHistory);

    if (!TextUtils.isEmpty(path)) assetPaths.add(path);

    return assetPaths;
  }
  public static void modelApplication(android.app.Application app) {
    mApplication = app;

    app.droidsafeOnCreate();
    app.droidsafeOnTerminate();
    app.droidsafeOnEverythingElse();
  }
  @DSVerified
  @DSBan(DSCat.DROIDSAFE_INTERNAL)
  public static void modelBroadCastReceiver(BroadcastReceiver receiver) {
    if (mApplication != null) {
      receiver.setApplication(mApplication);
      // callback receiver
      if (receiver instanceof android.app.admin.DeviceAdminReceiver) {
        DeviceAdminReceiver ar = (DeviceAdminReceiver) receiver;
        Intent appIntent = mApplication.droidsafeGetIntent();
        ar.onDisableRequested(context, appIntent);
        ar.onDisabled(context, appIntent);
        ar.onEnabled(context, appIntent);
        ar.onPasswordChanged(context, appIntent);
        ar.onPasswordExpiring(context, appIntent);
        ar.onPasswordFailed(context, appIntent);
        ar.onPasswordSucceeded(context, appIntent);
      }

      if (receiver instanceof android.appwidget.AppWidgetProvider) {
        AppWidgetProvider aw = (AppWidgetProvider) receiver;
        Intent appIntent = mApplication.droidsafeGetIntent();
        aw.onReceive(context, appIntent);
        aw.onEnabled(context);
        aw.onDisabled(context);
        int[] appWidgetIds = new int[1];
        appWidgetIds[0] = DSUtils.FAKE_INT;
        aw.onUpdate(context, AppWidgetManager.getInstance(context), appWidgetIds);
        aw.onDeleted(context, appWidgetIds);
      }
    }
  }
  @Override
  public void onCreate() {
    super.onCreate();
    ApplicationInfo appliInfo = null;
    super.onCreate();
    try {
      appliInfo =
          this.getPackageManager()
              .getApplicationInfo(this.getPackageName(), PackageManager.GET_META_DATA);
    } catch (PackageManager.NameNotFoundException e) {
      Log.e(TAG, e.getMessage(), e);
    }
    // get info from manifest, which is generated from fetch.json variables
    String clientId = appliInfo.metaData.getString("com.inbeacon.android.CLIENTID");
    String clientSecret = appliInfo.metaData.getString("com.inbeacon.android.SECRET");

    if (clientId == null
        || clientId.equals("your-clientid")
        || clientSecret == null
        || clientSecret.equals("your-secret")) {
      Log.e(
          TAG,
          "Invalid clientId and/or clientSecret !!!!!! YOU NEED TO SET INBEACON CREDENTIALS in your plugin variables (fetch.json)");
      return;
    }
    // initialize the shared instance on application level
    InbeaconManager.initialize(this, clientId, clientSecret);
  }
 @Test
 public void shouldAssignThePackageNameFromTheManifest() throws Exception {
   Application application =
       new ApplicationResolver(newConfig("TestAndroidManifestWithPackageName.xml"))
           .resolveApplication();
   assertEquals("com.wacka.wa", application.getPackageName());
 }
  private static void callPluginApplicationOnCreate(PluginDescriptor pluginDescriptor) {

    Application application = null;

    if (pluginDescriptor.getPluginApplication() == null
        && pluginDescriptor.getPluginClassLoader() != null) {
      try {
        LogUtil.d("创建插件Application", pluginDescriptor.getApplicationName());
        application =
            Instrumentation.newApplication(
                pluginDescriptor
                    .getPluginClassLoader()
                    .loadClass(pluginDescriptor.getApplicationName()),
                pluginDescriptor.getPluginContext());
        pluginDescriptor.setPluginApplication(application);
      } catch (ClassNotFoundException e) {
        e.printStackTrace();
      } catch (InstantiationException e) {
        e.printStackTrace();
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      }
    }

    // 安装ContentProvider
    PluginInjector.installContentProviders(
        sApplication, pluginDescriptor.getProviderInfos().values());

    // 执行onCreate
    if (application != null) {
      application.onCreate();
    }

    changeListener.onPluginStarted(pluginDescriptor.getPackageName());
  }
 @Override
 @SuppressLint("NewApi")
 public void superStartActivity(Intent intent, int requestCode, Bundle options) {
   if (VERSION.SDK_INT >= 16) {
     super.startActivity(intent, options);
   } else {
     super.startActivity(intent);
   }
 }
 @Override
 public void onCreate() {
   if (real_application_not_instantiated) // it is in the bootstrap process with Seppuku.
   return;
   monkeyPatchApplication();
   monkeyPatchExistingResources();
   super.onCreate();
   realApplication.onCreate();
 }
 @Override
 public String getFullVersionName() {
   try {
     final PackageInfo info =
         myApplication.getPackageManager().getPackageInfo(myApplication.getPackageName(), 0);
     return info.versionName + " (" + info.versionCode + ")";
   } catch (Exception e) {
     return "";
   }
 }
 private void createTestUsers() {
   Application application = getActivity().getApplication();
   SharedPreferences.Editor editor =
       application
           .getSharedPreferences(PreferenceAdapter.PREFERENCES_FILE_COMMON, MODE_PRIVATE)
           .edit();
   Set<String> profiles = new LinkedHashSet<String>();
   profiles.add("Default User");
   profiles.add("John Doe");
   profiles.add("Jayne Doe");
   editor.putStringSet(getString(R.string.profile_entries), profiles);
   editor.commit();
 }
Beispiel #11
0
 public static String getAppVersionName(Application application) {
   try {
     PackageManager pm = application.getPackageManager();
     if (pm != null) {
       PackageInfo pi = pm.getPackageInfo(application.getPackageName(), 0);
       String versionName = pi.versionName;
       if (versionName != null && versionName.length() > 0) {
         return versionName;
       }
     }
   } catch (PackageManager.NameNotFoundException e) {
   }
   return "";
 }
  private Payload doInBackgroundSendFeedback(Payload data) {
    Log.i(AnkiDroidApp.TAG, "doInBackgroundSendFeedback");
    String feedbackUrl = (String) data.data[0];
    String errorUrl = (String) data.data[1];
    String feedback = (String) data.data[2];
    ArrayList<HashMap<String, String>> errors = (ArrayList<HashMap<String, String>>) data.data[3];
    String groupId = ((Long) data.data[4]).toString();
    Application app = (Application) data.data[5];
    boolean deleteAfterSending = (Boolean) data.data[6];

    String postType = null;
    if (feedback.length() > 0) {
      if (errors.size() > 0) {
        postType = Feedback.TYPE_ERROR_FEEDBACK;
      } else {
        postType = Feedback.TYPE_FEEDBACK;
      }
      publishProgress(postType, 0, Feedback.STATE_UPLOADING);
      Payload reply = Feedback.postFeedback(feedbackUrl, postType, feedback, groupId, 0, null);
      if (reply.success) {
        publishProgress(postType, 0, Feedback.STATE_SUCCESSFUL, reply.returnType, reply.result);
      } else {
        publishProgress(postType, 0, Feedback.STATE_FAILED, reply.returnType, reply.result);
      }
    }

    for (int i = 0; i < errors.size(); i++) {
      HashMap<String, String> error = errors.get(i);
      if (error.containsKey("state") && error.get("state").equals(Feedback.STATE_WAITING)) {
        postType = Feedback.TYPE_STACKTRACE;
        publishProgress(postType, i, Feedback.STATE_UPLOADING);
        Payload reply =
            Feedback.postFeedback(errorUrl, postType, error.get("filename"), groupId, i, app);
        if (reply.success) {
          publishProgress(postType, i, Feedback.STATE_SUCCESSFUL, reply.returnType, reply.result);
        } else {
          publishProgress(postType, i, Feedback.STATE_FAILED, reply.returnType, reply.result);
        }
        if (deleteAfterSending && (reply.success || reply.returnType == 200)) {
          File file = new File(app.getFilesDir() + "/" + error.get("filename"));
          file.delete();
        }
      }
    }

    app = null;

    return data;
  }
Beispiel #13
0
  @Override
  public void onCreate() {
    super.onCreate();

    // GCM Registration
    PushService.register(this);
  }
Beispiel #14
0
  @Override
  public void onCreate() {
    ACRA.init(this);
    super.onCreate();
    this.prefs = PreferenceManager.getDefaultSharedPreferences(this);
    this.prefs.registerOnSharedPreferenceChangeListener((OnSharedPreferenceChangeListener) this);

    // See if the user has the preference for opening up the last used database. If so, set the path
    // to it.
    if (this.prefs.getBoolean("openLastUsed", false)) {
      // First see if the path still exists if not then the user did something and we need to change
      // the user preference and not
      // try to open any file this time around.
      String path = this.prefs.getString("Full Path", "");
      if (fileExists(path)) setFullPath(path);
      else {
        Editor edit = this.prefs.edit();
        edit.putBoolean("openLastUsed", false);
        edit.putString("Full Path", "");
        edit.apply();
      }
    }

    String value = this.prefs.getString("updateFrequency", "0");
    if (value.equals("-1")) this.setAutoUpdate(true);
    else this.setAutoUpdate(false);
    Splits = new ArrayList<Split>();
    Splits.clear();
  }
Beispiel #15
0
 /**
  * Notify user with a dialog the app has crashed, ask permission to send it. {@link
  * CrashReportDialog} Activity.
  *
  * @param reportFileName Name fo the error report to display in the crash report dialog.
  */
 void notifyDialog(String reportFileName) {
   Log.d(LOG_TAG, "Creating Dialog for " + reportFileName);
   Intent dialogIntent = new Intent(mContext, CrashReportDialog.class);
   dialogIntent.putExtra(ACRAConstants.EXTRA_REPORT_FILE_NAME, reportFileName);
   dialogIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
   mContext.startActivity(dialogIntent);
 }
  public void onCreate() {
    super.onCreate();

    _instance = this;

    Thread.setDefaultUncaughtExceptionHandler(new XbmcExceptionHandler());
  }
 @Override
 public List<String> defaultLanguageCodes() {
   final TreeSet<String> set = new TreeSet<String>();
   set.add(Locale.getDefault().getLanguage());
   final TelephonyManager manager =
       (TelephonyManager) myApplication.getSystemService(Context.TELEPHONY_SERVICE);
   if (manager != null) {
     final String country0 = manager.getSimCountryIso().toLowerCase();
     final String country1 = manager.getNetworkCountryIso().toLowerCase();
     for (Locale locale : Locale.getAvailableLocales()) {
       final String country = locale.getCountry().toLowerCase();
       if (country != null
           && country.length() > 0
           && (country.equals(country0) || country.equals(country1))) {
         set.add(locale.getLanguage());
       }
     }
     if ("ru".equals(country0) || "ru".equals(country1)) {
       set.add("ru");
     } else if ("by".equals(country0) || "by".equals(country1)) {
       set.add("ru");
     } else if ("ua".equals(country0) || "ua".equals(country1)) {
       set.add("ru");
     }
   }
   set.add("multi");
   return new ArrayList<String>(set);
 }
  @Override
  public void onCreate() {
    // VMRuntime.getRuntime().setMinimumHeapSize(4 * 1024 * 1024);
    super.onCreate();

    SettingUtils.loadLauncherSettings(this);

    mContext = getApplicationContext();
    mIconCache = new IconCache(this);
    mModel = new LauncherModel(this, mIconCache);

    // Register intent receivers
    IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    filter.addDataScheme("package");
    registerReceiver(mModel, filter);
    filter = new IntentFilter();
    filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
    filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
    registerReceiver(mModel, filter);

    filter = new IntentFilter();
    filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
    registerReceiver(mModel, filter);

    // Register for changes to the favorites
    ContentResolver resolver = getContentResolver();
    resolver.registerContentObserver(
        LauncherSettings.Favorites.CONTENT_URI, true, mFavoritesObserver);
  }
Beispiel #19
0
 @Override
 public void onTerminate() {
   super.onTerminate();
   if (routingHelper != null) {
     routingHelper.getVoiceRouter().onApplicationTerminate(this);
   }
 }
  @Override
  public void onCreate() {
    super.onCreate();

    // init joda date time
    JodaTimeAndroid.init(this);
  }
  /** the entrance for the application */
  @Override
  public void onCreate() {
    // TODO Auto-generated method stub
    super.onCreate();
    context = this;

    // Baidu Push Service
    FrontiaApplication.initFrontiaApplication(context);

    mBaiduPushServer = new BaiduPush(BaiduPush.HTTP_METHOD_POST, SECRIT_KEY, API_KEY);

    // 不转换没有 @Expose 注解的字段
    mGson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();

    mSpUtil = new SharedPreferencesUtil(this, SP_FILE_NAME);
    mUserDB = new UserDB(this);
    mMsgDB = new MsgDB(this);
    mConvDB = new ConvDB(this);
    mUserList = mUserDB.getAll();
    mMediaPlayer = MediaPlayer.create(this, R.raw.office);
    mNotificationManager =
        (NotificationManager) getSystemService(android.content.Context.NOTIFICATION_SERVICE);

    loadUserBaseData();

    activityManager = ActivityManager.getActivityManager(this); // 实例化活动管理类
    dbOperation = new MailDB(this);
    UID_SET = dbOperation.loadUIDSet("inbox");

    //		// Start Notification Service
    //		startNotificationService();
  }
Beispiel #22
0
 @Override
 public void onCreate() {
   super.onCreate();
   _context = getApplicationContext();
   _resource = _context.getResources();
   init();
 }
Beispiel #23
0
  @SuppressLint("NewApi")
  @Override
  public void onCreate() {
    // TODO Auto-generated method stub
    super.onCreate();
    InputStream is = getResources().openRawResource(R.drawable.ic_launcher);
    Bitmap mBitmap = BitmapFactory.decodeStream(is);

    System.out.println("btm" + mBitmap.getByteCount());
    setBm(mBitmap); // 初始化全局变量

    userId = "";
    UserName = "";
    levelId = "";

    DisplayImageOptions defaultOptions =
        new DisplayImageOptions.Builder() //
            .showImageForEmptyUri(R.drawable.ic_launcher) //
            .showImageOnFail(R.drawable.ic_launcher) //
            .cacheInMemory(true) //
            .cacheOnDisk(true) //
            .build(); //
    ImageLoaderConfiguration config =
        new ImageLoaderConfiguration //
                .Builder(getApplicationContext()) //
            .defaultDisplayImageOptions(defaultOptions) //
            .discCacheSize(50 * 1024 * 1024) //
            .discCacheFileCount(10) // 缓存一百张图片
            .writeDebugLogs() //
            .build(); //
    ImageLoader.getInstance().init(config);
  }
  @Override
  public void onCreate() {
    super.onCreate();

    // Apply the PRNGFixes patch (provided by Google team)
    PRNGFixes.apply();
  }
 @Override
 public void onCreate() {
   super.onCreate();
   mContext = getApplicationContext();
   // Fresco.initialize(mContext);
   initImageLoader(this);
 }
  @Override
  public void onCreate() {
    super.onCreate();

    Thread.setDefaultUncaughtExceptionHandler(
        new MyUncaughtExceptionHandler(Thread.getDefaultUncaughtExceptionHandler()));
  }
Beispiel #27
0
  @Override
  public void onCreate() {
    super.onCreate();
    mInstance = this;

    initImageLoader();
  }
Beispiel #28
0
 @Override
 public void onCreate() {
   super.onCreate();
   if (mInstance == null) {
     mInstance = this;
   }
 }
Beispiel #29
0
 @Override
 public void onCreate() {
   super.onCreate();
   BaiduManager.init(this);
   JPushInterface.setDebugMode(true); // 设置开启日志,发布时请关闭日志
   JPushInterface.init(this); // 初始化 JPush
 }
  @Override
  public void onCreate() {
    super.onCreate();

    // store reference to the application context
    context = getApplicationContext();
  }