コード例 #1
0
 public SQLiteDatabase getSQLiteDatabase() {
   if (mDatabase != null) return mDatabase;
   StrictModeUtils.checkDiskIO();
   return mDatabase = getSQLiteOpenHelper().getWritableDatabase();
 }
コード例 #2
0
  @Override
  public void onCreate() {
    if (BuildConfig.DEBUG) {
      StrictModeUtils.detectAllVmPolicy();
    }
    super.onCreate();
    initDebugMode();
    initBugReport();
    mHandler = new Handler();
    initializeAsyncTask();
    initAccountColor(this);

    final PackageManager pm = getPackageManager();
    final ComponentName main = new ComponentName(this, MainActivity.class);
    final ComponentName main2 = new ComponentName(this, MainHondaJOJOActivity.class);
    final boolean mainDisabled =
        pm.getComponentEnabledSetting(main) != PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
    final boolean main2Disabled =
        pm.getComponentEnabledSetting(main2) != PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
    final boolean noEntry = mainDisabled && main2Disabled;
    if (noEntry) {
      pm.setComponentEnabledSetting(
          main, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
    } else if (!mainDisabled) {
      pm.setComponentEnabledSetting(
          main2, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
    }
    if (!Utils.isComposeNowSupported(this)) {
      final ComponentName assist = new ComponentName(this, AssistLauncherActivity.class);
      pm.setComponentEnabledSetting(
          assist, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
    }

    migrateUsageStatisticsPreferences();
    startRefreshServiceIfNeeded(this);

    reloadConnectivitySettings();

    DependencyHolder holder = DependencyHolder.get(this);
    registerActivityLifecycleCallbacks(holder.getActivityTracker());

    final IntentFilter packageFilter = new IntentFilter();
    packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
    registerReceiver(
        new BroadcastReceiver() {
          @Override
          public void onReceive(Context context, Intent intent) {
            final int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
            final String[] packages = getPackageManager().getPackagesForUid(uid);
            DependencyHolder holder = DependencyHolder.get(context);
            final ExternalThemeManager manager = holder.getExternalThemeManager();
            if (ArrayUtils.contains(packages, manager.getEmojiPackageName())) {
              manager.reloadEmojiPreferences();
            }
          }
        },
        packageFilter);
  }