Example usage for android.content.pm ApplicationInfo FLAG_DEBUGGABLE

List of usage examples for android.content.pm ApplicationInfo FLAG_DEBUGGABLE

Introduction

In this page you can find the example usage for android.content.pm ApplicationInfo FLAG_DEBUGGABLE.

Prototype

int FLAG_DEBUGGABLE

To view the source code for android.content.pm ApplicationInfo FLAG_DEBUGGABLE.

Click Source Link

Document

Value for #flags : set to true if this application would like to allow debugging of its code, even when installed on a non-development system.

Usage

From source file:com.landenlabs.all_UiDemo.MainActivity.java

public static boolean isDebug(ApplicationInfo appInfo) {
    return ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0);
}

From source file:io.teak.sdk.Teak.java

/**
 * Initialize Teak and tell it to listen to the lifecycle events of {@link Activity}.
 * <p/>//from   www .ja  va 2s. com
 * <p>Call this function from the {@link Activity#onCreate} function of your <code>Activity</code>
 * <b>before</b> the call to <code>super.onCreate()</code></p>
 *
 * @param activity The main <code>Activity</code> of your app.
 */
public static void onCreate(Activity activity) {
    Log.d(LOG_TAG, "Android SDK Version: " + Teak.SDKVersion);

    if (activity == null) {
        Log.e(LOG_TAG, "null Activity passed to onCreate, Teak is disabled.");
        Teak.setState(State.Disabled);
        return;
    }

    {
        String airSdkVersion = Helpers.getStringResourceByName("io_teak_air_sdk_version",
                activity.getApplicationContext());
        if (airSdkVersion != null) {
            Log.d(LOG_TAG, "Adobe AIR SDK Version: " + airSdkVersion);
        }
    }

    // Set up debug logging ASAP
    try {
        final Context context = activity.getApplicationContext();
        final ApplicationInfo applicationInfo = context.getApplicationInfo();
        Teak.debugConfiguration = new DebugConfiguration(context);
        Teak.isDebug = Teak.forceDebug || Teak.debugConfiguration.forceDebug || (applicationInfo != null
                && (0 != (applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE)));
    } catch (Exception e) {
        Log.e(LOG_TAG, "Error creating DebugConfiguration. " + Log.getStackTraceString(e));
    }

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        Log.e(LOG_TAG, "Teak requires API level 14 to operate. Teak is disabled.");
        Teak.setState(State.Disabled);
    } else {
        try {
            Application application = activity.getApplication();
            synchronized (Teak.stateMutex) {
                if (Teak.state == State.Allocated) {
                    application.registerActivityLifecycleCallbacks(Teak.lifecycleCallbacks);
                }
            }
        } catch (Exception e) {
            Log.e(LOG_TAG, "Failed to register Activity lifecycle callbacks. Teak is disabled. "
                    + Log.getStackTraceString(e));
            Teak.setState(State.Disabled);
        }
    }
}

From source file:co.uk.gauntface.cordova.plugin.nativegplussignin.CordovaGPlusOauthPlugin.java

private String getClienId() {
    boolean isDebuggable = ((this.cordova.getActivity()
            .getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE) != 0);
    return isDebuggable ? C.DEBUG_CLIENT_ID : C.PRODUCTION_CLIENT_ID;
}

From source file:com.yattatech.dbtc.activity.SplashScreen.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (FACADE.isDeviceClockOutOfSync()) {
        Debug.d(mTag, "System clock is not supported");
        showMessage(R.string.system_clock_outof_sync);
        finish();/*w ww. j av a 2  s .c o m*/
        return;
    }
    setContentView(R.layout.layout_splash_screen);
    mView = findViewById(R.id.content);
    mAnim = AnimationUtils.loadAnimation(this, R.anim.activity_open_scale);
    mView.setAnimation(mAnim);
    mAnim.setAnimationListener(mViewAnimationListener);
    Crittercism.initialize(getApplicationContext(), getString(R.string.crittercism_id));
    // make sure set android:debuggable as false, avoiding 
    // execution of bellow code block in release version
    final ApplicationInfo info = getApplicationInfo();
    if ((info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
        Debug.d(mTag, "defining thread policy");
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites()
                .detectNetwork().penaltyLog().build());
        Debug.d(mTag, "defining VM policy");
        StrictMode.setVmPolicy(
                new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects().penaltyLog().build());
    }
    if (Debug.isDebugable()) {
        // Usefull to know current database state using some
        // external sqlite tool to check it out, for copying
        // that file to computer use adb command line
        DbUtil.copyDatabase(Environment.getExternalStorageDirectory().getAbsolutePath());
    }
}

From source file:com.tdispatch.passenger.core.TDApplication.java

@Override
public void onCreate() {

    // Workaround for Android bug #20915
    // http://code.google.com/p/android/issues/detail?id=20915
    try {//w w w  .j  ava2  s  .  c  om
        Class.forName("android.os.AsyncTask");
    } catch (Exception e) {
        e.printStackTrace();
    }

    super.onCreate();

    mAppContext = this;

    mIsDebuggable = ((getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0);

    mPrefs = PreferenceManager.getDefaultSharedPreferences(mAppContext);
    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    mSessionManager = SessionManager.getInstance(mAppContext);
    mBookingManager = BookingManager.getInstance(mAppContext);
    mOfficeManager = OfficeManager.getInstance(mAppContext);

    initPackageInfo();
    initEnvInfo();
    checkGoogleServices();
}

From source file:butter.droid.base.ButterApplication.java

@Override
public void onCreate() {
    super.onCreate();
    sThis = this;

    sDefSystemLanguage = LocaleUtils.getCurrentAsString();

    LeakCanary.install(this);
    Foreground.init(this);

    Constants.DEBUG_ENABLED = false;// w  w w  .  j  ava 2 s.  c o m
    int versionCode = 0;
    try {
        String packageName = getPackageName();
        PackageInfo packageInfo = getPackageManager().getPackageInfo(packageName, 0);
        int flags = packageInfo.applicationInfo.flags;
        versionCode = packageInfo.versionCode;
        Constants.DEBUG_ENABLED = (flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }

    //initialise logging
    if (Constants.DEBUG_ENABLED) {
        Timber.plant(new Timber.DebugTree());
    }

    ButterUpdater.getInstance(this, this).checkUpdates(false);

    if (VersionUtils.isUsingCorrectBuild()) {
        TorrentService.start(this);
    }

    File path = new File(
            PrefUtils.get(this, Prefs.STORAGE_LOCATION, StorageUtils.getIdealCacheDirectory(this).toString()));
    File directory = new File(path, "/torrents/");
    if (PrefUtils.get(this, Prefs.REMOVE_CACHE, true)) {
        FileUtils.recursiveDelete(directory);
        FileUtils.recursiveDelete(new File(path + "/subs"));
    } else {
        File statusFile = new File(directory, "status.json");
        statusFile.delete();
    }

    Timber.d("StorageLocations: " + StorageUtils.getAllStorageLocations());
    Timber.i("Chosen cache location: " + directory);

    Picasso.Builder builder = new Picasso.Builder(getAppContext());
    OkHttpDownloader downloader = new OkHttpDownloader(getHttpClient());
    builder.downloader(downloader);
    Picasso.setSingletonInstance(builder.build());
}

From source file:pct.droid.base.PopcornApplication.java

@Override
public void onCreate() {
    super.onCreate();
    sThis = this;

    if (!BuildConfig.GIT_BRANCH.equals("local"))
        Fabric.with(this, new Crashlytics());

    sDefSystemLanguage = LocaleUtils.getCurrentAsString();

    LeakCanary.install(this);
    Foreground.init(this);

    Constants.DEBUG_ENABLED = false;/* w ww . jav a  2  s  .  c om*/
    int versionCode = 0;
    try {
        String packageName = getPackageName();
        PackageInfo packageInfo = getPackageManager().getPackageInfo(packageName, 0);
        int flags = packageInfo.applicationInfo.flags;
        versionCode = packageInfo.versionCode;
        Constants.DEBUG_ENABLED = (flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }

    //initialise logging
    if (Constants.DEBUG_ENABLED) {
        Timber.plant(new Timber.DebugTree());
    }

    PopcornUpdater.getInstance(this, this).checkUpdates(false);

    if (VersionUtils.isUsingCorrectBuild()) {
        TorrentService.start(this);
    }

    File path = new File(
            PrefUtils.get(this, Prefs.STORAGE_LOCATION, StorageUtils.getIdealCacheDirectory(this).toString()));
    File directory = new File(path, "/torrents/");
    if (PrefUtils.get(this, Prefs.REMOVE_CACHE, true)) {
        FileUtils.recursiveDelete(directory);
        FileUtils.recursiveDelete(new File(path + "/subs"));
    } else {
        File statusFile = new File(directory, "status.json");
        statusFile.delete();
    }

    Timber.d("StorageLocations: " + StorageUtils.getAllStorageLocations());
    Timber.i("Chosen cache location: " + directory);

    if (PrefUtils.get(this, Prefs.INSTALLED_VERSION, 0) < versionCode) {
        PrefUtils.save(this, Prefs.INSTALLED_VERSION, versionCode);
        FileUtils.recursiveDelete(new File(StorageUtils.getIdealCacheDirectory(this) + "/backend"));
    }

    Picasso.Builder builder = new Picasso.Builder(getAppContext());
    OkHttpDownloader downloader = new OkHttpDownloader(getHttpClient());
    builder.downloader(downloader);
    Picasso.setSingletonInstance(builder.build());
}

From source file:io.digibyte.tools.util.Utils.java

public static boolean isEmulatorOrDebug(Context app) {
    String fing = Build.FINGERPRINT;
    boolean isEmulator = false;
    if (fing != null) {
        isEmulator = fing.contains("vbox") || fing.contains("generic");
    }/*  www .  ja  va2 s . c o  m*/
    return isEmulator || (0 != (app.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
}

From source file:at.the.gogo.windig.activities.WindigActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final int applicationFlags = getApplicationInfo().flags;
    if ((applicationFlags & ApplicationInfo.FLAG_DEBUGGABLE) == 0) {
        CrashReportHandler.attach(this);
    }/* ww  w .  ja  va2 s . co m*/
    // now switch debug mode off if
    Util.DEBUGMODE = ((applicationFlags & ApplicationInfo.FLAG_DEBUGGABLE) != 0);

    final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    wantToUseTTS = sharedPreferences.getBoolean("pref_tts_speech", true);

    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(WindigActivity.POSKEY)) {
            currentPage = savedInstanceState.getInt(WindigActivity.POSKEY);
        }
    }

    setContentView(R.layout.windigmain);
    getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    setTitle(R.string.wetterwertetitel);
    getSupportActionBar().setDisplayUseLogoEnabled(false);

    mPagerAdapter = new MyPagerAdapter(getSupportFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.viewflipper);
    mViewPager.setAdapter(mPagerAdapter);

    mIndicator = (LinePageIndicator) findViewById(R.id.indicator);
    mIndicator.setViewPager(mViewPager);
    //      mIndicator.setFooterIndicatorStyle(IndicatorStyle.Underline);

    int lastpageViewed = sharedPreferences.getInt("PageInFlipper", 0);

    if (savedInstanceState != null) {
        lastpageViewed = savedInstanceState.getInt("index", lastpageViewed);
    }
    mViewPager.setCurrentItem(lastpageViewed);

    // Set the indicator as the pageChangeListener
    mViewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageScrolled(final int position, final float positionOffset,
                final int positionOffsetPixels) {
            mIndicator.onPageScrolled(position, positionOffset, positionOffsetPixels);
        }

        @Override
        public void onPageSelected(final int position) {
            mIndicator.onPageSelected(position);
        }

        @Override
        public void onPageScrollStateChanged(final int state) {
            mIndicator.onPageScrollStateChanged(state);
        }
    });

    restoreUIState();
    checkTTS();
}

From source file:com.scm.reader.resultPage.ui.ItemViewFragment.java

@SuppressLint("SetJavaScriptEnabled")
@Override//  ww  w. j a v  a 2s  . co m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View v = inflater.inflate(R.layout.fragment_result, container, false);

    mWebView = (WebView) v.findViewById(R.id.webView);

    // set WebViewClient
    mWebViewClient = createWebViewClient(getActivity());
    mWebView.setWebViewClient(mWebViewClient);

    final ProgressBar progressBar = (ProgressBar) v.findViewById(R.id.progressBar);

    mWebView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int progress) {
            if (progress == 100) {
                progressBar.setVisibility(View.GONE);
            } else {
                progressBar.setVisibility(View.VISIBLE);
                progressBar.setProgress(progress);
            }
        }
    });

    initializeWebView(mWebView);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        if (0 != (getActivity().getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) {
            WebView.setWebContentsDebuggingEnabled(true);
        }
    }

    mWebView.loadUrl(mUrl);

    return v;
}