List of usage examples for android.content.pm ApplicationInfo FLAG_DEBUGGABLE
int FLAG_DEBUGGABLE
To view the source code for android.content.pm ApplicationInfo FLAG_DEBUGGABLE.
Click Source Link
From source file:org.apache.cordova.AndroidWebView.java
/** * Initialize webview./* w w w . ja v a 2s . c o m*/ */ @SuppressWarnings("deprecation") @SuppressLint("NewApi") private void setup() { this.setInitialScale(0); this.setVerticalScrollBarEnabled(false); if (shouldRequestFocusOnInit()) { this.requestFocusFromTouch(); } // Enable JavaScript WebSettings settings = this.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL); // Set the nav dump for HTC 2.x devices (disabling for ICS, deprecated entirely for Jellybean 4.2) try { Method gingerbread_getMethod = WebSettings.class.getMethod("setNavDump", new Class[] { boolean.class }); String manufacturer = android.os.Build.MANUFACTURER; Log.d(TAG, "CordovaWebView is running on device made by: " + manufacturer); if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB && android.os.Build.MANUFACTURER.contains("HTC")) { gingerbread_getMethod.invoke(settings, true); } } catch (NoSuchMethodException e) { Log.d(TAG, "We are on a modern version of Android, we will deprecate HTC 2.3 devices in 2.8"); } catch (IllegalArgumentException e) { Log.d(TAG, "Doing the NavDump failed with bad arguments"); } catch (IllegalAccessException e) { Log.d(TAG, "This should never happen: IllegalAccessException means this isn't Android anymore"); } catch (InvocationTargetException e) { Log.d(TAG, "This should never happen: InvocationTargetException means this isn't Android anymore."); } //We don't save any form data in the application settings.setSaveFormData(false); settings.setSavePassword(false); // Jellybean rightfully tried to lock this down. Too bad they didn't give us a whitelist // while we do this if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) Level16Apis.enableUniversalAccess(settings); // Enable database // We keep this disabled because we use or shim to get around DOM_EXCEPTION_ERROR_16 String databasePath = this.cordova.getActivity().getApplicationContext() .getDir("database", Context.MODE_PRIVATE).getPath(); settings.setDatabaseEnabled(true); settings.setDatabasePath(databasePath); //Determine whether we're in debug or release mode, and turn on Debugging! try { final String packageName = this.cordova.getActivity().getPackageName(); final PackageManager pm = this.cordova.getActivity().getPackageManager(); ApplicationInfo appInfo; appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0 && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { setWebContentsDebuggingEnabled(true); } } catch (IllegalArgumentException e) { Log.d(TAG, "You have one job! To turn on Remote Web Debugging! YOU HAVE FAILED! "); e.printStackTrace(); } catch (NameNotFoundException e) { Log.d(TAG, "This should never happen: Your application's package can't be found."); e.printStackTrace(); } settings.setGeolocationDatabasePath(databasePath); // Enable DOM storage settings.setDomStorageEnabled(true); // Enable built-in geolocation settings.setGeolocationEnabled(true); // Enable AppCache // Fix for CB-2282 settings.setAppCacheMaxSize(5 * 1048576); String pathToCache = this.cordova.getActivity().getApplicationContext() .getDir("database", Context.MODE_PRIVATE).getPath(); settings.setAppCachePath(pathToCache); settings.setAppCacheEnabled(true); // Fix for CB-1405 // Google issue 4641 this.updateUserAgentString(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); if (this.receiver == null) { this.receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { updateUserAgentString(); } }; this.cordova.getActivity().registerReceiver(this.receiver, intentFilter); } // end CB-1405 pluginManager = new PluginManager(this, this.cordova); jsMessageQueue = new NativeToJsMessageQueue(this, cordova); exposedJsApi = new AndroidExposedJsApi(pluginManager, jsMessageQueue); resourceApi = new CordovaResourceApi(this.getContext(), pluginManager); exposeJsInterface(); }
From source file:org.apache.cordova.AndroidWebViewClient.java
/** * Notify the host application that an SSL error occurred while loading a resource. * The host application must call either handler.cancel() or handler.proceed(). * Note that the decision may be retained for use in response to future SSL errors. * The default behavior is to cancel the load. * * @param view The WebView that is initiating the callback. * @param handler An SslErrorHandler object that will handle the user's response. * @param error The SSL error object. *//*from w w w . j a va 2 s . com*/ @TargetApi(8) @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { final String packageName = this.cordova.getActivity().getPackageName(); final PackageManager pm = this.cordova.getActivity().getPackageManager(); ApplicationInfo appInfo; try { appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { // debug = true handler.proceed(); return; } else { // debug = false super.onReceivedSslError(view, handler, error); } } catch (NameNotFoundException e) { // When it doubt, lock it out! super.onReceivedSslError(view, handler, error); } }
From source file:com.mobicage.rogerthat.MainService.java
@Override public void onCreate() { super.onCreate(); L.d(getPackageName() + "::MainService.OnCreate"); try {/*from w ww. j av a 2 s . com*/ PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0); mIsDebug = (info.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) == ApplicationInfo.FLAG_DEBUGGABLE; } catch (Exception e) { Log.e(L.TAG, "Forcing debug=false"); mIsDebug = false; } T.setUIThread("MainService.onCreate()"); L.setContext(this); patchIPSettingsForDNSSRV(); mIntentStash = new ArrayList<Intent>(); mHighPriorityIntents = new HashSet<String>(); mHighPriorityIntents.add(CLOSE_ACTIVITY_INTENT); mRunnableStash = new ArrayList<SafeRunnable>(); readVersion(); mUIHandler = new Handler(); createIOWorkerThread(); createHttpWorkerThread(); mBinder = new MainBinder(); setupDatabase(); setupConfiguration(); boolean debugLoggingEnabled = isDebugLoggingEnabled(); if (debugLoggingEnabled) { mLOCSDCardLogger = new SDCardLogger(MainService.this, "location_log.txt", "LOC"); } mGeoLocationProvider = new GeoLocationProvider(this, mConfigProvider, mLOCSDCardLogger); setupNetworkConnectivityManager(); setupRPC(); startAwakeLogger(); if (debugLoggingEnabled) { mHTTPSDCardLogger = new SDCardLogger(MainService.this, "httplog.txt", "HTTP"); mXMPPSDCardLogger = new SDCardLogger(MainService.this, "xmpplog.txt", "XMPP"); } final boolean mustInitializeAndStartService = getRegisteredFromConfig(); if (mustInitializeAndStartService) { setupNetworkProtocol(); initializeService(null); startMainService(START_INTENT_FROM_ONCREATE_KEY); } processUncaughtExceptions(mustInitializeAndStartService); IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(INTENT_SHOULD_CLEANUP_CACHED_FILES); registerReceiver(mBroadcastReceiver, filter); final PowerManager pow = (PowerManager) getSystemService(POWER_SERVICE); mScreenIsOn = pow.isScreenOn(); hideLogForwardNotification(); // This should remain the last line of this method. current = this; }
From source file:com.amazonaws.mobile.auth.google.GoogleSignInProvider.java
/** {@inheritDoc} */ @Override/*from w w w . j a va 2s . c om*/ public View.OnClickListener initializeSignInButton(final Activity signInActivity, final View buttonView, final SignInProviderResultHandler providerResultsHandler) { this.resultsHandler = providerResultsHandler; final GoogleApiAvailability api = GoogleApiAvailability.getInstance(); final int code = api.isGooglePlayServicesAvailable(context.getApplicationContext()); if (ConnectionResult.SUCCESS != code) { if (api.isUserResolvableError(code)) { Log.w(LOG_TAG, "Google Play services recoverable error."); api.showErrorDialogFragment(signInActivity, code, REQUEST_GOOGLE_PLAY_SERVICES); } else { final boolean isDebugBuild = (0 != (signInActivity.getApplicationContext() .getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)); if (!isDebugBuild) { buttonView.setVisibility(View.GONE); } else { Log.w(LOG_TAG, "Google Play Services are not available, " + "but we are showing the Google Sign-in Button, anyway, " + "because this is a debug build."); } } return null; } final View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(final View v) { if (!signingIn) { signingIn = true; if (getPermissionsIfNecessary(signInActivity)) { return; } initiateGoogleSignIn(signInActivity); } } }; buttonView.setOnClickListener(listener); return listener; }
From source file:com.breadwallet.presenter.activities.MainActivity.java
private void checkDeviceRooted() { final boolean hasBitcoin = CurrencyManager.getInstance(this).getBALANCE() > 0; boolean isDebuggable = 0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE); if (RootHelper.isDeviceRooted() && !isDebuggable) { new Handler().postDelayed(new Runnable() { @Override//from w w w. j a va 2 s . c o m public void run() { if (app == null) { Log.e(TAG, "WARNING: checkDeviceRooted: app - null"); return; } AlertDialog.Builder builder = new AlertDialog.Builder(app); builder.setTitle(R.string.device_security_compromised) .setMessage(String.format(getString(R.string.rooted_message), hasBitcoin ? getString(R.string.rooted_message_holder1) : "")) .setCancelable(false) .setNegativeButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog alert = builder.create(); if (app != null && !app.isDestroyed()) alert.show(); } }, 10000); } }
From source file:com.pseudosudostudios.jdd.activities.GameActivity.java
public boolean isUserDebuggable() { return (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)); }
From source file:org.readium.sdk.android.biblemesh.WebViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); setContentView(R.layout.activity_web_view); final int abTitleId = getResources().getIdentifier("action_bar_title", "id", "android"); findViewById(abTitleId).setOnClickListener(new View.OnClickListener() { @Override//from w w w .ja v a 2 s. c om public void onClick(View v) { finish(); } }); mWebview = (WebView) findViewById(R.id.webview); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && 0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) { WebView.setWebContentsDebuggingEnabled(true); } mProgress = (ProgressBar) findViewById(R.id.progressBar); initWebView(); final GestureDetector gestureDetector = new GestureDetector(this, new MyGestureListener()); mWebview.setOnTouchListener(new View.OnTouchListener() { private final static long MAX_TOUCH_DURATION = 150; float lastEventX; float m_DownTime; @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: lastEventX = event.getX(); m_DownTime = event.getEventTime(); //init time break; case MotionEvent.ACTION_MOVE: { float distanceX = lastEventX - event.getX(); ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) mWebview .getLayoutParams(); marginLayoutParams.leftMargin = marginLayoutParams.leftMargin - (int) distanceX; marginLayoutParams.rightMargin = -marginLayoutParams.leftMargin;// marginLayoutParams.rightMargin + (int) distanceX; mWebview.requestLayout(); } break; case MotionEvent.ACTION_UP: { ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) mWebview .getLayoutParams(); if (marginLayoutParams.leftMargin < 10 && marginLayoutParams.leftMargin > -10) { Log.i("up", "small margin, open menu?"); if (event.getEventTime() - m_DownTime <= MAX_TOUCH_DURATION) { Log.i("up", "quick"); showActionBar(null); } else { Log.i("up", "too long"); } } } case MotionEvent.ACTION_CANCEL: { ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) mWebview .getLayoutParams(); //Log.i("snap", "snap width: "+mWebview.getWidth()+" left:" + marginLayoutParams.leftMargin + " raw:" + event.getRawX() + " " + event.getX());//+" "+e2.toString()+" "+e1.toString()); //mWebview.getWidth() if (marginLayoutParams.leftMargin < -0.5 * mWebview.getWidth()) { mReadiumJSApi.openPageRight(); mWebview.setAlpha(0.0f); } else if (marginLayoutParams.leftMargin > 0.5 * mWebview.getWidth()) { mReadiumJSApi.openPageLeft(); mWebview.setAlpha(0.0f); } else { snapBack(); //return true; } } break; } ; return gestureDetector.onTouchEvent(event); } }); /*mWebview.setHapticFeedbackEnabled(false);*/ Intent intent = getIntent(); if (intent.getFlags() == Intent.FLAG_ACTIVITY_NEW_TASK) { Bundle extras = intent.getExtras(); if (extras != null) { mContainer = ContainerHolder.getInstance().get(extras.getLong(Constants.CONTAINER_ID)); if (mContainer == null) { finish(); return; } mPackage = mContainer.getDefaultPackage(); String rootUrl = "http://" + EpubServer.HTTP_HOST + ":" + EpubServer.HTTP_PORT + "/"; mPackage.setRootUrls(rootUrl, null); try { mOpenPageRequestData = OpenPageRequest .fromJSON(extras.getString(Constants.OPEN_PAGE_REQUEST_DATA)); } catch (JSONException e) { Log.e(TAG, "Constants.OPEN_PAGE_REQUEST_DATA must be a valid JSON object: " + e.getMessage(), e); } } } // No need, EpubServer already launchers its own thread // new AsyncTask<Void, Void, Void>() { // @Override // protected Void doInBackground(Void... params) { // //xxx // return null; // } // }.execute(); mServer = new EpubServer(EpubServer.HTTP_HOST, EpubServer.HTTP_PORT, mPackage, quiet, dataPreProcessor); mServer.startServer(); // Load the page skeleton mWebview.loadUrl(READER_SKELETON); mViewerSettings = new ViewerSettings(ViewerSettings.SyntheticSpreadMode.SINGLE, ViewerSettings.ScrollMode.AUTO, 100, 20); mReadiumJSApi = new ReadiumJSApi(new ReadiumJSApi.JSLoader() { @Override public void loadJS(String javascript) { mWebview.loadUrl(javascript); } }); /*Button back = (Button)findViewById(R.id.btnBack); back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); if(getActionBar.isShowing()) { hideActionBar(); } else { getActionBar.show(); hideActionBar(); } } });*/ r = new Runnable() { @Override public void run() { getActionBar().hide(); //getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); } }; hide2 = null; hideActionBar(); //ActionBar actionBar = getActionBar(); //actionBar.hide(); //getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); }
From source file:com.amazonaws.mobileconnectors.s3.transferutility.TransferService.java
@Override protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) { // only available when the application is debuggable if ((getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) == 0) { return;// ww w .j av a 2 s .c o m } writer.printf("start id: %d\n", startId); writer.printf("network status: %s\n", networkInfoReceiver.isNetworkConnected()); writer.printf("lastActiveTime: %s, shouldScan: %s\n", new Date(lastActiveTime), shouldScan); final Map<Integer, TransferRecord> transfers = updater.getTransfers(); writer.printf("# of active transfers: %d\n", transfers.size()); for (final TransferRecord transfer : transfers.values()) { writer.printf("bucket: %s, key: %s, status: %s, total size: %d, current: %d\n", transfer.bucketName, transfer.key, transfer.state, transfer.bytesTotal, transfer.bytesCurrent); } writer.flush(); }
From source file:most.voip.example.ws_config.MainActivity.java
private void waitForInitialization() { /* Wait for GDB to init */ Log.d(TAG, "Waiting some second before initializing the lib..."); if ((this.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { this.waitForSeconds(3); }/* w w w . j a v a 2s.c om*/ }
From source file:com.magnet.mmx.client.MMXClient.java
private boolean isApplicationDebuggable(Context context) { return ((context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) > 0); }