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.engine.crosswalk.XWalkCordovaWebView.java
@SuppressLint("SetJavaScriptEnabled") private void initWebViewSettings() { webview.setVerticalScrollBarEnabled(false); // TODO: The Activity is the one that should call requestFocus(). if (shouldRequestFocusOnInit()) { this.webview.requestFocusFromTouch(); }/* ww w .j av a 2s .c om*/ //Determine whether we're in debug or release mode, and turn on Debugging! ApplicationInfo appInfo = webview.getContext().getApplicationContext().getApplicationInfo(); if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true); } }
From source file:com.gcm.client.GcmHelper.java
/** * Initialize the GcmHelper class. To be called from the application class onCreate or from the * onCreate of the main activity//from ww w .j a va 2 s .c o m * * @param context An instance of the Application Context */ public synchronized void init(@NonNull Context context) { if (!isGooglePlayservicesAvailable(context)) { throw new IllegalArgumentException("Not using the recommended Play Services version"); } //get the GCM sender id from strings.xml if (TextUtils.isEmpty(senderID)) { int id = context.getResources().getIdentifier("gcm_authorized_entity", "string", context.getPackageName()); senderID = context.getResources().getString(id); } if (TextUtils.isEmpty(senderID)) { throw new IllegalArgumentException("No SenderId provided!! Cannot instantiate"); } SharedPreferences localPref = getSharedPreference(context); //get topics array if (localPref.contains(PREF_KEY_SUBSCRIPTION)) { String subscription = localPref.getString(PREF_KEY_SUBSCRIPTION, null); if (!TextUtils.isEmpty(subscription)) { try { JSONArray array = new JSONArray(subscription); int length = array.length(); topics = new ArrayList<>(); for (int i = 0; i < length; i++) { topics.add(array.getString(i)); } } catch (JSONException ignored) { if (DEBUG_ENABLED) Log.e(TAG, "init: while processing subscription list", ignored); } } } boolean registrationReq = true; if (localPref.contains(PREF_KEY_TOKEN)) { pushToken = localPref.getString(PREF_KEY_TOKEN, null); if (!TextUtils.isEmpty(pushToken)) { registrationReq = false; //don't pass token if already present } } if (registrationReq) { //register for push token Intent registration = new Intent(context, RegistrationIntentService.class); registration.setAction(RegistrationIntentService.ACTION_REGISTER); context.startService(registration); } //check if debug build and enable DEBUG MODE DEBUG_ENABLED = (0 != (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)); initialized = true; }
From source file:com.platform.APIClient.java
private APIClient(Activity context) { ctx = context;/*from www . j av a 2 s . co m*/ if (0 != (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)) { BREAD_BUY = "bread-buy-staging"; } }
From source file:com.wipro.sa349342.wmar.AbstractArchitectCamActivity.java
/** Called when the activity is first created. */ @SuppressLint("NewApi") @Override//w w w. j a v a 2 s . c o m public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* pressing volume up/down should cause music volume changes */ this.setVolumeControlStream(AudioManager.STREAM_MUSIC); /* set samples content view */ this.setContentView(this.getContentViewId()); this.setTitle(this.getActivityTitle()); View mapFrag = findViewById(R.id.map); if (this.isMapPanelRequired()) { mapFrag.setVisibility(View.VISIBLE); // Obtain the SupportMapFragment and get notified when the map is ready to be used. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(map); mapFragment.getMapAsync(AbstractArchitectCamActivity.this); } else { mapFrag.setVisibility(View.GONE); } /* * this enables remote debugging of a WebView on Android 4.4+ when debugging = true in AndroidManifest.xml * If you get a compile time error here, ensure to have SDK 19+ used in your ADT/Eclipse. * You may even delete this block in case you don't need remote debugging or don't have an Android 4.4+ device in place. * Details: https://developers.google.com/chrome-developer-tools/docs/remote-debugging */ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) { WebView.setWebContentsDebuggingEnabled(true); } } /* set AR-view for life-cycle notifications etc. */ this.architectView = (ArchitectView) this.findViewById(this.getArchitectViewId()); /* pass SDK key if you have one, this one is only valid for this package identifier and must not be used somewhere else */ final StartupConfiguration config = new StartupConfiguration(this.getWikitudeSDKLicenseKey(), this.getFeatures(), this.getCameraPosition()); try { /* first mandatory life-cycle notification */ this.architectView.onCreate(config); } catch (RuntimeException rex) { this.architectView = null; Toast.makeText(getApplicationContext(), "can't create Architect View", Toast.LENGTH_SHORT).show(); Log.e(this.getClass().getName(), "Exception in ArchitectView.onCreate()", rex); } // set accuracy listener if implemented, you may e.g. show calibration prompt for compass using this listener this.sensorAccuracyListener = this.getSensorAccuracyListener(); // set urlListener, any calls made in JS like "document.location = 'architectsdk://foo?bar=123'" is forwarded to this listener, use this to interact between JS and native Android activity/fragment this.urlListener = this.getUrlListener(); // register valid urlListener in architectView, ensure this is set before content is loaded to not miss any event if (this.urlListener != null && this.architectView != null) { this.architectView.registerUrlListener(this.getUrlListener()); } if (hasGeo()) { // listener passed over to locationProvider, any location update is handled here this.locationListener = new LocationListener() { @Override public void onStatusChanged(String provider, int status, Bundle extras) { } @Override public void onProviderEnabled(String provider) { } @Override public void onProviderDisabled(String provider) { } @Override public void onLocationChanged(final Location location) { // forward location updates fired by LocationProvider to architectView, you can set lat/lon from any location-strategy if (location != null) { // sore last location as member, in case it is needed somewhere (in e.g. your adjusted project) AbstractArchitectCamActivity.this.lastKnownLocaton = location; if (AbstractArchitectCamActivity.this.architectView != null) { // check if location has altitude at certain accuracy level & call right architect method (the one with altitude information) if (location.hasAltitude() && location.hasAccuracy() && location.getAccuracy() < 7) { AbstractArchitectCamActivity.this.architectView.setLocation(location.getLatitude(), location.getLongitude(), location.getAltitude(), location.getAccuracy()); } else { AbstractArchitectCamActivity.this.architectView.setLocation(location.getLatitude(), location.getLongitude(), location.hasAccuracy() ? location.getAccuracy() : 1000); } } // currentLocationMarker(location); } } }; // locationProvider used to fetch user position this.locationProvider = getLocationProvider(this.locationListener); } else { this.locationProvider = null; this.locationListener = null; } }
From source file:plugin.google.maps.GoogleMaps.java
@SuppressLint("NewApi") @Override/*from w ww . ja v a 2 s .c o m*/ public void initialize(final CordovaInterface cordova, final CordovaWebView webView) { super.initialize(cordova, webView); activity = cordova.getActivity(); density = Resources.getSystem().getDisplayMetrics().density; root = (ViewGroup) webView.getParent(); // Is this app in debug mode? try { PackageManager manager = activity.getPackageManager(); ApplicationInfo appInfo = manager.getApplicationInfo(activity.getPackageName(), 0); isDebug = (appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) == ApplicationInfo.FLAG_DEBUGGABLE; } catch (Exception e) { } Log.i("CordovaLog", "This app uses phonegap-googlemaps-plugin version " + PLUGIN_VERSION); if (isDebug) { cordova.getThreadPool().execute(new Runnable() { @Override public void run() { try { JSONArray params = new JSONArray(); params.put("get"); params.put("http://plugins.cordova.io/api/plugin.google.maps"); HttpRequest httpReq = new HttpRequest(); httpReq.initialize(cordova, null); httpReq.execute("execute", params, new CallbackContext("version_check", webView) { @Override public void sendPluginResult(PluginResult pluginResult) { if (pluginResult.getStatus() == PluginResult.Status.OK.ordinal()) { try { JSONObject result = new JSONObject(pluginResult.getStrMessage()); JSONObject distTags = result.getJSONObject("dist-tags"); String latestVersion = distTags.getString("latest"); if (latestVersion.equals(PLUGIN_VERSION) == false) { Log.i("CordovaLog", "phonegap-googlemaps-plugin version " + latestVersion + " is available."); } } catch (JSONException e) { } } } }); } catch (Exception e) { } } }); } cordova.getActivity().runOnUiThread(new Runnable() { @SuppressLint("NewApi") public void run() { /* try { Method method = webView.getClass().getMethod("getSettings"); WebSettings settings = (WebSettings)method.invoke(null); settings.setRenderPriority(RenderPriority.HIGH); settings.setCacheMode(WebSettings.LOAD_NO_CACHE); } catch (Exception e) { e.printStackTrace(); } */ if (Build.VERSION.SDK_INT >= 11) { webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } root.setBackgroundColor(Color.WHITE); if (VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) { activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); } if (VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { Log.d(TAG, "Google Maps Plugin reloads the browser to change the background color as transparent."); webView.setBackgroundColor(0); try { Method method = webView.getClass().getMethod("reload"); method.invoke(webView); } catch (Exception e) { e.printStackTrace(); } } } }); }
From source file:com.southernstorm.tvguide.TvChannelCache.java
@Override public void addContext(Context context) { super.addContext(context); if (region == null) { // Load the region from the settings for the first time. SharedPreferences prefs = context.getSharedPreferences("TVGuideActivity", 0); region = prefs.getString("region", ""); if (region != null && region.equals("")) region = null;//from w w w .j a va 2 s . c o m } // Determine if the application was built as debug or release to set the debug flag. if (!debugLoaded) { debugLoaded = true; debug = false; PackageManager manager = context.getPackageManager(); try { PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0); if ((info.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) debug = true; } catch (NameNotFoundException e) { } } // Load the channels. if (channels.size() == 0 && region != null) loadChannels(); }
From source file:com.att.arocollector.AROCollectorActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.i(TAG, "onCreate(...)"); // Setup handler for uncaught exceptions. Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override/*from w ww . j av a 2 s . co m*/ public void uncaughtException(Thread thread, Throwable e) { handleUncaughtException(thread, e); } }); super.onCreate(savedInstanceState); setContentView(R.layout.splash); final TextView splashText = (TextView) findViewById(R.id.splash_message); splashText.setText(String.format(getString(R.string.splashmessageopensource), getString(R.string.app_brand_name), getString(R.string.app_url_name))); AttenuatorManager.getInstance().init(); Intent intent = getIntent(); //delay int delayDl = intent.getIntExtra(BundleKeyUtil.DL_DELAY, 0); int delayUl = intent.getIntExtra(BundleKeyUtil.UL_DELAY, 0); if (delayDl >= 0) { AttenuatorManager.getInstance().setDelayDl(delayDl); } else { Log.i(TAG, "Invalid attenuation delay value" + delayDl + "ms"); } if (delayUl >= 0) { AttenuatorManager.getInstance().setDelayUl(delayUl); } else { Log.i(TAG, "Invalid attenuation delay value" + delayUl + "ms"); } //throttle int throttleDl = intent.getIntExtra(BundleKeyUtil.DL_THROTTLE, AttenuatorUtil.DEFAULT_THROTTLE_SPEED); int throttleUl = intent.getIntExtra(BundleKeyUtil.UL_THROTTLE, AttenuatorUtil.DEFAULT_THROTTLE_SPEED); AttenuatorManager.getInstance().setThrottleDL(throttleDl); Log.d(TAG, "Download speed throttle value: " + throttleDl + " kbps"); AttenuatorManager.getInstance().setThrottleUL(throttleUl); Log.d(TAG, "Upload speed throttle value: " + throttleUl + " kbps"); printLog = intent.getBooleanExtra(BundleKeyUtil.PRINT_LOG, false); setVideoOption(intent); bitRate = intent.getIntExtra(BundleKeyUtil.BIT_RATE, 0); String screenSizeTmp = intent.getStringExtra(BundleKeyUtil.SCREEN_SIZE); screenSize = screenSizeTmp == null ? screenSize : screenSizeTmp; setVideoOrient(intent); Log.i(TAG, "get from intent delayTime: " + AttenuatorManager.getInstance().getDelayDl() + "get from intent delayTimeUL: " + AttenuatorManager.getInstance().getDelayUl() + "get from intent throttleDL: " + AttenuatorManager.getInstance().getThrottleDL() + "get from intnetn throttleUL: " + AttenuatorManager.getInstance().getThrottleUL() + " video: " + videoOption + " bitRate: " + bitRate + " screenSize: " + screenSize + " orientation: " + videoOrient); context = getApplicationContext(); launchAROCpuTraceService(); launchAROCpuTempService(); if (networkAndAirplaneModeCheck()) { // register to listen for close down message registerAnalyzerCloseCmdReceiver(); Log.d(TAG, "register the attenuator delay signal"); startVPN(); } { // test code PackageInfo packageInfo = null; try { packageInfo = this.getPackageManager().getPackageInfo(this.getPackageName(), 0); } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } boolean valu = (packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; // build datetime Date buildDate = new Date(BuildConfig.TIMESTAMP); String appBuildDate = ""; if (buildDate != null) { appBuildDate = buildDate.toString(); } String display = "App Build Date: " + appBuildDate + "\n" // +" DownStream Delay Time: " + AttenuatorManager.getInstance().getDelayDl() + " ms\n" // +" UpStream Delay Time: " + AttenuatorManager.getInstance().getDelayUl() + " ms\n" // +" DownStream Throttle: " + AttenuatorManager.getInstance().getThrottleDL() + " kbps\n" // +" Upstream Throttle: " + AttenuatorManager.getInstance().getThrottleUL() + " kbps\n" + AttenuatorUtil.getInstance().notificationMessage() + "\n" + " Version: " + packageInfo.versionName + " (" + (valu ? "Debug" : "Production") + ")"; ((TextView) findViewById(R.id.version)).setText(display); } }
From source file:com.raspberry.library.util.AppUtils.java
/** * ??debug?//from w w w .j av a2s .com * * @param context * @return */ public static boolean isApkInDebug(Context context) { try { ApplicationInfo info = context.getApplicationInfo(); return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; } catch (Exception e) { return false; } }
From source file:com.github.javiersantos.piracychecker.LibraryUtils.java
static boolean isDebug(Context context) { return ((context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0); }
From source file:org.readium.sdk.android.launcher.WebViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_web_view); mWebview = (WebView) findViewById(R.id.webview); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && 0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) { WebView.setWebContentsDebuggingEnabled(true); }//w w w. ja va 2 s . co m mPageInfo = (TextView) findViewById(R.id.page_info); initWebView(); 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.AUTO, ViewerSettings.ScrollMode.AUTO, 100, 20); mReadiumJSApi = new ReadiumJSApi(new ReadiumJSApi.JSLoader() { @Override public void loadJS(String javascript) { mWebview.loadUrl(javascript); } }); }