List of usage examples for android.content.pm PackageManager COMPONENT_ENABLED_STATE_DISABLED
int COMPONENT_ENABLED_STATE_DISABLED
To view the source code for android.content.pm PackageManager COMPONENT_ENABLED_STATE_DISABLED.
Click Source Link
From source file:com.chummy.jezebel.material.dark.activities.Main.java
public void setLauncherIconEnabled(boolean enabled) { int newState; PackageManager pm = getPackageManager(); if (enabled) { newState = PackageManager.COMPONENT_ENABLED_STATE_ENABLED; } else {/*from w w w . j a va2 s.c o m*/ newState = PackageManager.COMPONENT_ENABLED_STATE_DISABLED; } pm.setComponentEnabledSetting( new ComponentName(this, com.chummy.jezebel.material.dark.LauncherActivity.class), newState, PackageManager.DONT_KILL_APP); }
From source file:com.google.android.marvin.mytalkback.TalkBackService.java
/** * Registers listeners, sets service info, loads preferences. This should be * called from {@link #onServiceConnected} and when TalkBack resumes from a * suspended state.//w w w . j av a 2s .c o m */ private void suspendInfrastructure() { if (!isServiceActive()) { LogUtils.log(this, Log.ERROR, "Attempted to suspend while already suspended"); return; } interruptAllFeedback(); setServiceState(ServiceState.SUSPENDED); setServiceInfo(new AccessibilityServiceInfo()); mPrefs.unregisterOnSharedPreferenceChangeListener(mSharedPreferenceChangeListener); unregisterReceiver(mActiveReceiver); if (mCallStateMonitor != null) { unregisterReceiver(mCallStateMonitor); } if (mRingerModeAndScreenMonitor != null) { unregisterReceiver(mRingerModeAndScreenMonitor); } if (mRadialMenuManager != null) { unregisterReceiver(mRadialMenuManager); mRadialMenuManager.clearCache(); } if (mVolumeMonitor != null) { unregisterReceiver(mVolumeMonitor); mVolumeMonitor.releaseControl(); } if (mShakeDetector != null) { mShakeDetector.setEnabled(false); } if (SUPPORTS_TOUCH_PREF) { final ContentResolver resolver = getContentResolver(); resolver.unregisterContentObserver(mTouchExploreObserver); } // Disable the proxy activity for long-press search. final PackageManager packageManager = getPackageManager(); final ComponentName shortcutProxy = new ComponentName(this, ShortcutProxyActivity.class); packageManager.setComponentEnabledSetting(shortcutProxy, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); // Remove any pending notifications that shouldn't persist. final NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); nm.cancelAll(); if (mTtsOverlay != null) { mTtsOverlay.hide(); } }
From source file:com.google.android.marvin.talkback.TalkBackService.java
/** * Registers listeners, sets service info, loads preferences. This should be * called from {@link #onServiceConnected} and when TalkBack resumes from a * suspended state.//from ww w. j av a 2s . c om */ private void suspendInfrastructure() { if (!isServiceActive()) { LogUtils.log(this, Log.ERROR, "Attempted to suspend while already suspended"); return; } interruptAllFeedback(); setServiceState(ServiceState.SUSPENDED); setServiceInfo(new AccessibilityServiceInfo()); mPrefs.unregisterOnSharedPreferenceChangeListener(mSharedPreferenceChangeListener); unregisterReceiver(mActiveReceiver); if (mCallStateMonitor != null) { unregisterReceiver(mCallStateMonitor); } if (mRingerModeAndScreenMonitor != null) { unregisterReceiver(mRingerModeAndScreenMonitor); } if (mRadialMenuManager != null) { unregisterReceiver(mRadialMenuManager); mRadialMenuManager.clearCache(); } if (mVolumeMonitor != null) { unregisterReceiver(mVolumeMonitor); mVolumeMonitor.releaseControl(); } if (mPackageReceiver != null) { unregisterReceiver(mPackageReceiver); } if (mShakeDetector != null) { mShakeDetector.setEnabled(false); } if (SUPPORTS_TOUCH_PREF) { final ContentResolver resolver = getContentResolver(); resolver.unregisterContentObserver(mTouchExploreObserver); } // Disable the proxy activity for long-press search. final PackageManager packageManager = getPackageManager(); final ComponentName shortcutProxy = new ComponentName(this, ShortcutProxyActivity.class); packageManager.setComponentEnabledSetting(shortcutProxy, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); // Remove any pending notifications that shouldn't persist. final NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); nm.cancelAll(); if (mTtsOverlay != null) { mTtsOverlay.hide(); } }
From source file:com.csipsimple.service.SipService.java
private void applyComponentEnablingState(boolean active) { int enableState = PackageManager.COMPONENT_ENABLED_STATE_DISABLED; if (active && prefsWrapper.getPreferenceBooleanValue(SipConfigManager.INTEGRATE_TEL_PRIVILEGED)) { // Check whether we should register for stock tel: intents // Useful for devices without gsm enableState = PackageManager.COMPONENT_ENABLED_STATE_ENABLED; }/*from ww w . j a v a2s . c o m*/ PackageManager pm = getPackageManager(); ComponentName cmp = new ComponentName(this, "com.csipsimple.ui.PrivilegedOutgoingCallBroadcaster"); try { if (pm.getComponentEnabledSetting(cmp) != enableState) { pm.setComponentEnabledSetting(cmp, enableState, PackageManager.DONT_KILL_APP); } } catch (IllegalArgumentException e) { Log.d(THIS_FILE, "Current manifest has no PrivilegedOutgoingCallBroadcaster -- you can ignore this if voluntary", e); } }
From source file:com.google.android.marvin.screenspeak.ScreenSpeakService.java
/** * Registers listeners, sets service info, loads preferences. This should be called from * {@link #onServiceConnected} and when ScreenSpeak resumes from a suspended state. *//*www. ja va 2 s . c o m*/ private void suspendInfrastructure() { if (!isServiceActive()) { if (LogUtils.LOG_LEVEL <= Log.ERROR) { Log.e(LOGTAG, "Attempted to suspend while already suspended"); } return; } mDimScreenController.makeScreenBright(); interruptAllFeedback(); setServiceState(SERVICE_STATE_SUSPENDED); // Some apps depend on these being set to false when ScreenSpeak is disabled. if (mSupportsTouchScreen) { requestTouchExploration(false); } if (SUPPORTS_WEB_SCRIPT_TOGGLE) { requestWebScripts(false); } mPrefs.unregisterOnSharedPreferenceChangeListener(mSharedPreferenceChangeListener); unregisterReceiver(mActiveReceiver); if (mCallStateMonitor != null) { mCallStateMonitor.stopMonitor(); } if (mRingerModeAndScreenMonitor != null) { unregisterReceiver(mRingerModeAndScreenMonitor); } if (mMenuManager != null) { mMenuManager.clearCache(); } if (mVolumeMonitor != null) { unregisterReceiver(mVolumeMonitor); mVolumeMonitor.releaseControl(); } if (mBatteryMonitor != null) { unregisterReceiver(mBatteryMonitor); } if (mPackageReceiver != null) { unregisterReceiver(mPackageReceiver); } if (mShakeDetector != null) { mShakeDetector.setEnabled(false); } // The tap detector is enabled through reloadPreferences if (mSideTapManager != null) { unregisterReceiver(mSideTapManager); mSideTapManager.onSuspendInfrastructure(); } // Disable the proxy activity for long-press search. final PackageManager packageManager = getPackageManager(); final ComponentName shortcutProxy = new ComponentName(this, ShortcutProxyActivity.class); packageManager.setComponentEnabledSetting(shortcutProxy, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); // Remove any pending notifications that shouldn't persist. final NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); nm.cancelAll(); }
From source file:com.grazerss.EntryManager.java
public void maintainBootReceiverStateAndScheduler() { final ComponentName cName = new ComponentName(ctx, BootReceiver.class); final PackageManager pm = ctx.getPackageManager(); final int newComponentState = isAutoSyncEnabled() ? PackageManager.COMPONENT_ENABLED_STATE_DEFAULT : PackageManager.COMPONENT_ENABLED_STATE_DISABLED; if (pm.getComponentEnabledSetting(cName) != newComponentState) { Log.d(TAG, "Setting new component enabled state on BootReceiver: " + isAutoSyncEnabled()); pm.setComponentEnabledSetting(cName, newComponentState, PackageManager.DONT_KILL_APP); }//from www . j a va 2s . c om PL.log("EntryManager.maintainBootReceiverState(): Component enabled=" + pm.getComponentEnabledSetting(cName), ctx); if (isAutoSyncEnabled()) { scheduler.ensureSchedulingIsEnabled(); } }
From source file:com.grazerss.EntryManager.java
@SuppressWarnings("unchecked") public void maintainPremiumDependencies() { this.proVersion = null; if (false) {//www . j ava 2 s . c om final int desiredComponentState = isProVersion() ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED; final Class[] componentsToDeactivate = { FireReceiver.class, MockEditSettingsActivity.class }; final PackageManager pm = ctx.getPackageManager(); for (final Class cls : componentsToDeactivate) { final ComponentName cName = new ComponentName(ctx, cls); pm.setComponentEnabledSetting(cName, desiredComponentState, PackageManager.DONT_KILL_APP); } } }
From source file:com.newsrob.EntryManager.java
public void maintainBootReceiverState() { final ComponentName cName = new ComponentName(ctx, BootReceiver.class); final PackageManager pm = ctx.getPackageManager(); final int newComponentState = isAutoSyncEnabled() ? PackageManager.COMPONENT_ENABLED_STATE_DEFAULT : PackageManager.COMPONENT_ENABLED_STATE_DISABLED; if (pm.getComponentEnabledSetting(cName) != newComponentState) { Log.d(TAG, "Setting new component enabled state on BootReceiver: " + isAutoSyncEnabled()); pm.setComponentEnabledSetting(cName, newComponentState, PackageManager.DONT_KILL_APP); }/*from w ww . j a va 2 s.c o m*/ PL.log("EntryManager.maintainBootReceiverState(): Component enabled=" + pm.getComponentEnabledSetting(cName), ctx); }
From source file:com.juick.android.MainActivity.java
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) { if (s == null) return;/*from www .ja v a 2s . c om*/ if (s.equals("useHttpsForJuickHttpAPI")) { JuickHttpAPI.setHttpsEnabled(sp.getBoolean("useHttpsForJuickHttpAPI", false)); } if (s.equals("useXMPP")) { toggleXMPP(this); } if (s.equals("juick_gcm")) { toggleJuickGCM(this); } if (s.equals("enableJAMessaging")) { toggleJAMessaging(); } if (s.equals("googlePlusNavigation")) { updateActionBarMode(); } if (s.equals("enableBrowserComponent")) { ComponentName cn = new ComponentName("com.juickadvanced", "com.juick.android.SimpleBrowser"); boolean skipDontKillApp = sp.getBoolean("skip_dont_kill_app", false); getPackageManager().setComponentEnabledSetting(cn, sp.getBoolean(s, false) ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, skipDontKillApp ? 0 : PackageManager.DONT_KILL_APP); } boolean censorLevelChanged = false; if (s.equals("censor")) { censorLevelChanged = true; Censor.setCensorshipLevel(Integer.parseInt(sp.getString("censor", "0"))); } boolean dontWatchPreferences = sp.getBoolean("dontWatchPreferences", false); if (dontWatchPreferences) return; if (s.startsWith("msrc")) { final DragSortListView navigationList = (DragSortListView) findViewById(R.id.navigation_list); if (navigationList.isDragEnabled()) return; // editing is being done final int REFRESHNAV = 0xFE0D; if (!handler.hasMessages(REFRESHNAV)) { Message msg = Message.obtain(handler, new Runnable() { @Override public void run() { updateNavigation(); } }); msg.what = REFRESHNAV; handler.sendMessageDelayed(msg, 100); } } boolean invalidateRendering = false; if (censorLevelChanged) { invalidateRendering = true; } if (s.startsWith("Colors.")) { invalidateRendering = true; } String[] refreshCauses = new String[] { "messagesFontScale", "showNumbers", "wrapUserpics", "showUserpics", }; for (String refreshCause : refreshCauses) { if (refreshCause.equals(s)) { if (s.equals("messagesFontScale") && sp.getBoolean("enableScaleByGesture", true)) continue; // should have been pinch zoom invalidateRendering = true; break; } } if (invalidateRendering) { if (mf != null && mf.listAdapter != null) mf.listAdapter.notifyDataSetInvalidated(); } if (s.equals("enableLoginNameWithCrashReport")) { if (sp.getBoolean("enableLoginNameWithCrashReport", false)) { String juickAccountName = JuickAPIAuthorizer.getJuickAccountName(this); if (juickAccountName != null) Crashlytics.setString("juick_user", juickAccountName); } else { Crashlytics.setString("juick_user", ""); } } }
From source file:android.content.pm.PackageParser.java
private static void updateApplicationInfo(ApplicationInfo ai, int flags, PackageUserState state) { // CompatibilityMode is global state. if (!sCompatibilityModeEnabled) { ai.disableCompatibilityMode();/* ww w . j av a2 s . co m*/ } if (state.installed) { ai.flags |= ApplicationInfo.FLAG_INSTALLED; } else { ai.flags &= ~ApplicationInfo.FLAG_INSTALLED; } if (state.hidden) { ai.privateFlags |= ApplicationInfo.PRIVATE_FLAG_HIDDEN; } else { ai.privateFlags &= ~ApplicationInfo.PRIVATE_FLAG_HIDDEN; } if (state.enabled == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) { ai.enabled = true; } else if (state.enabled == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED) { ai.enabled = (flags & PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS) != 0; } else if (state.enabled == PackageManager.COMPONENT_ENABLED_STATE_DISABLED || state.enabled == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER) { ai.enabled = false; } ai.enabledSetting = state.enabled; }