2 * Copyright (C) 2012 Andrew Neal
3 * Copyright (C) 2014 The CyanogenMod Project
4 * Licensed under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with the
6 * License. You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
8 * or agreed to in writing, software distributed under the License is
9 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
10 * KIND, either express or implied. See the License for the specific language
11 * governing permissions and limitations under the License.
14 package org.lineageos.eleven;
16 import android.app.Application;
17 import android.os.StrictMode;
19 import org.lineageos.eleven.cache.ImageCache;
21 import java.util.logging.Level;
22 import java.util.logging.Logger;
25 * Used to turn off logging for jaudiotagger and free up memory when
26 * {@code #onLowMemory()} is called on pre-ICS devices. On post-ICS memory is
27 * released within {@link ImageCache}.
29 * @author Andrew Neal (andrewdneal@gmail.com)
31 public class ElevenApplication extends Application {
32 private static final boolean DEBUG = false;
38 public void onCreate() {
39 // Enable strict mode logging
41 // Turn off logging for jaudiotagger.
42 Logger.getLogger("org.jaudiotagger").setLevel(Level.OFF);
49 public void onLowMemory() {
50 ImageCache.getInstance(this).evictAll();
54 private void enableStrictMode() {
56 final StrictMode.ThreadPolicy.Builder threadPolicyBuilder = new StrictMode.ThreadPolicy.Builder()
57 .detectAll().penaltyLog();
58 final StrictMode.VmPolicy.Builder vmPolicyBuilder = new StrictMode.VmPolicy.Builder()
59 .detectAll().penaltyLog();
61 threadPolicyBuilder.penaltyFlashScreen();
62 StrictMode.setThreadPolicy(threadPolicyBuilder.build());
63 StrictMode.setVmPolicy(vmPolicyBuilder.build());