Java Code Examples for android.content.pm.ApplicationInfo#FLAG_DEBUGGABLE
The following examples show how to use
android.content.pm.ApplicationInfo#FLAG_DEBUGGABLE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SystemWebViewClient.java From BigDataPlatform with GNU General Public License v3.0 | 6 votes |
/** * 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. */ @TargetApi(8) @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { final String packageName = parentEngine.cordova.getActivity().getPackageName(); final PackageManager pm = parentEngine.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); } }
Example 2
Source File: CordovaWebViewClient.java From IoTgo_Android_App with MIT License | 6 votes |
/** * 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. */ @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); } }
Example 3
Source File: ViewServer.java From NineGridImageView with Apache License 2.0 | 6 votes |
/** * Returns a unique instance of the ViewServer. This method should only be * called from the main thread of your application. The server will have * the same lifetime as your process. * * If your application does not have the <code>android:debuggable</code> * flag set in its manifest, the server returned by this method will * be a dummy object that does not do anything. This allows you to use * the same code in debug and release versions of your application. * * @param context A Context used to check whether the application is * debuggable, this can be the application context */ public static ViewServer get(Context context) { ApplicationInfo info = context.getApplicationInfo(); if (BUILD_TYPE_USER.equals(Build.TYPE) && (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { if (sServer == null) { sServer = new ViewServer(ViewServer.VIEW_SERVER_DEFAULT_PORT); } if (!sServer.isRunning()) { try { sServer.start(); } catch (IOException e) { Log.d(LOG_TAG, "Error:", e); } } } else { sServer = new NoopViewServer(); } return sServer; }
Example 4
Source File: ViewServer.java From Android_Blog_Demos with Apache License 2.0 | 6 votes |
/** * Returns a unique instance of the ViewServer. This method should only be * called from the main thread of your application. The server will have * the same lifetime as your process. * * If your application does not have the <code>android:debuggable</code> * flag set in its manifest, the server returned by this method will * be a dummy object that does not do anything. This allows you to use * the same code in debug and release versions of your application. * * @param context A Context used to check whether the application is * debuggable, this can be the application context */ public static ViewServer get(Context context) { ApplicationInfo info = context.getApplicationInfo(); if (BUILD_TYPE_USER.equals(Build.TYPE) && (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { if (sServer == null) { sServer = new ViewServer(ViewServer.VIEW_SERVER_DEFAULT_PORT); } if (!sServer.isRunning()) { try { sServer.start(); } catch (IOException e) { Log.d(LOG_TAG, "Error:", e); } } } else { sServer = new NoopViewServer(); } return sServer; }
Example 5
Source File: SystemWebViewClient.java From pychat with MIT License | 6 votes |
/** * 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. */ @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { final String packageName = parentEngine.cordova.getActivity().getPackageName(); final PackageManager pm = parentEngine.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); } }
Example 6
Source File: MainActivity.java From CrossMobile with GNU Lesser General Public License v3.0 | 6 votes |
@Override @SuppressWarnings({"UseSpecificCatch"}) protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); launchDebug = (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; instanceState = savedInstanceState; MainActivity.current = this; setContentView(AndroidFileBridge.getResourceID("layout", "crossmobile_core")); MainView.current = findViewById(AndroidFileBridge.getResourceID("id", "mainview")); Native.destroy(); // Needs a fresh start Native.lifecycle().loadSystemProperties(); // Make sure they are loaded before initialization. Native.lifecycle().init(args); AndroidUIGuidelinesBridge.setTranslucentStatusBar(); SystemUtilities.launchClass(System.getProperty("cm.main.class"), MainActivity.args); OrientationManager.register(this); Native.graphics().setOrientation(DefaultInitialOrientation); updateOrientation(); statusBarListener = StatusBarListener.init(this); if (launchDebug) Native.system().debug("Activity created", null); if (stateListener != null) stateListener.onCreate(savedInstanceState); }
Example 7
Source File: KernalBundle.java From atlas with Apache License 2.0 | 6 votes |
public boolean isDeubgMode() { try { /** * enable patch debug if in debug mode */ final ApplicationInfo app_info = KernalConstants.baseContext.getApplicationInfo(); boolean DEBUG = (app_info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; if (DEBUG) { return true; } SharedPreferences sharedPreferences = KernalConstants.baseContext.getSharedPreferences("dynamic_test", Context.MODE_PRIVATE); boolean dynamic_test_flag = sharedPreferences.getBoolean("dynamic_test_key", false); if (dynamic_test_flag) { return true; } } catch (final Exception e) { return false; } return false; }
Example 8
Source File: CordovaWebViewClient.java From bluemix-parking-meter with MIT License | 6 votes |
/** * 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. */ @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); } }
Example 9
Source File: DebuggedCheck.java From jail-monkey with MIT License | 5 votes |
/** * Checks if the device is in debug mode. * * @return <code>true</code> if the device is debug mode, <code>false</code> otherwise. */ public static boolean isDebugged(Context context) { if (Debug.isDebuggerConnected()) { return true; } return (context.getApplicationContext().getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; }
Example 10
Source File: AppUtils.java From freeline with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static boolean isApkDebugable(Context context) { try { ApplicationInfo info = context.getApplicationInfo(); return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; } catch (Exception e) { } return false; }
Example 11
Source File: AppModel.java From Xndroid with GNU General Public License v3.0 | 5 votes |
private static boolean isApkInDebug(Context context) { try { ApplicationInfo info = context.getApplicationInfo(); return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; } catch (Exception e) { e.printStackTrace(); return false; } }
Example 12
Source File: Util.java From AutoInteraction-Library with Apache License 2.0 | 5 votes |
/** * @return true: debug false:release * @description 判断当前程序是否出于DEBUG模式 */ public static boolean isDebug(Context context) { // 如果是开发使用则直接开启日志,否则根据当前状态判断 try { ApplicationInfo info = context.getPackageManager().getApplicationInfo(context.getPackageName(), 0); return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) == ApplicationInfo.FLAG_DEBUGGABLE; } catch (PackageManager.NameNotFoundException e) { } return false; }
Example 13
Source File: DUtils.java From UTubeTV with The Unlicense | 5 votes |
public static boolean isDebuggable(Context context) { PackageManager pm = context.getPackageManager(); try { ApplicationInfo info = pm.getApplicationInfo(context.getPackageName(), 0); return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; } catch (PackageManager.NameNotFoundException e) { } return true; }
Example 14
Source File: AppProtocol.java From rides-android-sdk with MIT License | 5 votes |
private boolean isDebug(@NonNull Context context) { String brand = Build.BRAND; int applicationFlags = context.getApplicationInfo().flags; // We are debugging on an emulator, don't validate package signature. return (brand.startsWith("Android") || brand.startsWith("generic")) && (applicationFlags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; }
Example 15
Source File: LegacyUriRedirectHandlerTest.java From rides-android-sdk with MIT License | 5 votes |
@Before public void setup() { MockitoAnnotations.initMocks(this); applicationInfo = new ApplicationInfo(); applicationInfo.flags = ApplicationInfo.FLAG_DEBUGGABLE; activity = spy(Robolectric.setupActivity(Activity.class)); //applicationInfo.flags = 0; when(sessionConfiguration.getRedirectUri()).thenReturn("com.example.uberauth://redirect"); when(loginManager.getSessionConfiguration()).thenReturn(sessionConfiguration); when(activity.getApplicationInfo()).thenReturn(applicationInfo); when(activity.getPackageManager()).thenReturn(packageManager); when(activity.getPackageName()).thenReturn("com.example"); legacyUriRedirectHandler = new LegacyUriRedirectHandler(); misconfiguredAuthCode = RuntimeEnvironment.application.getString( R.string.ub__misconfigured_auth_code_flow_log); missingRedirectUri = RuntimeEnvironment.application.getString( R.string.ub__missing_redirect_uri_log); mismatchingRedirectUri = RuntimeEnvironment.application.getString( R.string.ub__mismatching_redirect_uri_log); alertTitle = RuntimeEnvironment.application.getString( R.string.ub__misconfigured_redirect_uri_title); alertMessage = RuntimeEnvironment.application.getString( R.string.ub__misconfigured_redirect_uri_message); }
Example 16
Source File: BaseApplication.java From POCenter with MIT License | 5 votes |
/** * init logger */ private void initLogger() { if ((0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE))) Logger.init(); // for debug, print all log else Logger.init().logLevel(LogLevel.NONE); // for release, remove all log // Logger.init(); // for release, remove all log }
Example 17
Source File: MobileMessagingLogger.java From mobile-messaging-sdk-android with Apache License 2.0 | 4 votes |
public static boolean loggingEnabled() { boolean isDebuggable = (context != null && 0 != (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)); return isDebuggable || isEnforced; }
Example 18
Source File: ReflectTool.java From Android-Router with Apache License 2.0 | 4 votes |
public static boolean debugable() { Context context = getApplication(); return context != null && (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; }
Example 19
Source File: Logf.java From sana.mobile with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Checks whether the application is running in debug mode. * * @return <code>true</code> if the application is run in debug mode. */ public static final boolean isDebuggable(Context c) { String packageName = c.getPackageName(); int flags = c.getPackageManager().getLaunchIntentForPackage(packageName).getFlags(); return ((flags & ApplicationInfo.FLAG_DEBUGGABLE) > 0) ? true : false; }
Example 20
Source File: RouterServiceValidator.java From sdl_java_suite with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * This method will check to see if this app is a debug build. If it is, we will attempt to connect to any router service. * If false, it will only connect to approved apps with router services. * @return */ public boolean inDebugMode(){ return (0 != (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)); }