content: /*
   * Copyright (C) 2015, 程序亦非猿
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *   http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package me.yifeiyuan.andfixdemo;
  
  import android.app.Application;
  import android.os.Environment;
  import android.util.Log;
  
  import com.alipay.euler.andfix.patch.PatchManager;
  
  import java.io.IOException;
  
  /**
   * Created by 程序亦非猿 on 16/4/21.
   */
  public class App extends Application {
  
      private static final String TAG = "App";
      private PatchManager mPatchManager;
      private static final String APATCH_PATH = "/out.apatch";
  
      @Override
      public void onCreate() {
          super.onCreate();
          // initialize
          mPatchManager = new PatchManager(this);
          mPatchManager.init("1.0");
          Log.d(TAG, "inited.");
  
          // load patch
          mPatchManager.loadPatch();
          Log.d(TAG, "apatch loaded.");
  
          // add patch at runtime
          try {
              // .apatch file path
              String patchFileString = Environment.getExternalStorageDirectory()
                      .getAbsolutePath() + APATCH_PATH;///storage/emulated/0/out.apatch
              mPatchManager.addPatch(patchFileString);
              Log.d(TAG, "apatch:" + patchFileString + " added.");
          } catch (IOException e) {
              Log.e(TAG, "", e);
          }
      }
  }
  