List of usage examples for android.os ServiceManager getService
@UnsupportedAppUsage public static IBinder getService(String name)
From source file:com.android.settings.applications.ClearDefaultsPreference.java
public ClearDefaultsPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); setLayoutResource(R.layout.app_preferred_settings); mAppWidgetManager = AppWidgetManager.getInstance(context); mPm = context.getPackageManager();/*from www .j a v a 2 s . co m*/ IBinder b = ServiceManager.getService(Context.USB_SERVICE); mUsbManager = IUsbManager.Stub.asInterface(b); }
From source file:com.android.antitheft.activities.ParseSettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.parse_settings_activity); final EditText parseAppId = (EditText) findViewById(R.id.parse_app_id); final EditText parseClientKey = (EditText) findViewById(R.id.parse_client_key); Button btnUpdateParse = (Button) findViewById(R.id.btn_update_parse_setup); btnUpdateParse.setOnClickListener(new OnClickListener() { @Override//from ww w.j a v a 2s . co m public void onClick(View v) { String savedClientKey = PrefUtils.getInstance().getStringPreference(PrefUtils.PARSE_CLIENT_KEY, ""); String savedAppId = PrefUtils.getInstance().getStringPreference(PrefUtils.PARSE_APP_ID, ""); String newClientKey = parseClientKey.getText().toString(); String newAppId = parseAppId.getText().toString(); if (!newAppId.equals(savedAppId) && !newClientKey.equals(savedClientKey)) { PrefUtils.getInstance().setStringPreference(PrefUtils.PARSE_APP_ID, newAppId); PrefUtils.getInstance().setStringPreference(PrefUtils.PARSE_CLIENT_KEY, newClientKey); Toast.makeText(ParseSettingsActivity.this, "Your device will now reboot!", Toast.LENGTH_LONG) .show(); //PrefUtils.getInstance().setBoolPreference(PrefUtils.PARSE_CONFIG_CHANGED, true); try { IPowerManager pm = IPowerManager.Stub .asInterface(ServiceManager.getService(Context.POWER_SERVICE)); pm.reboot(false, null, false); } catch (RemoteException e) { Log.e(TAG, "PowerManager service died!", e); return; } } } }); }
From source file:com.android.settings.applications.CanBeOnSdCardChecker.java
CanBeOnSdCardChecker() {
mPm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
}
From source file:com.android.managedprovisioning.ProfileOwnerProvisioningService.java
@Override public void onCreate() { super.onCreate(); mIpm = IPackageManager.Stub.asInterface(ServiceManager.getService("package")); mAccountManager = (AccountManager) getSystemService(Context.ACCOUNT_SERVICE); mUserManager = (UserManager) getSystemService(Context.USER_SERVICE); runnerTask = new RunnerTask(); }
From source file:com.android.systemui.statusbar.phone.NavigationBarView.java
public NavigationBarView(Context context, AttributeSet attrs) { super(context, attrs); mContext = context;//from w ww.ja va 2 s. c om mHidden = false; mDisplay = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); mBarService = IStatusBarService.Stub.asInterface(ServiceManager.getService(Context.STATUS_BAR_SERVICE)); final Resources res = mContext.getResources(); mBarSize = res.getDimensionPixelSize(R.dimen.navigation_bar_size); mVertical = false; mShowMenu = false; mDelegateHelper = new DelegateViewHelper(this); mBackIcon = res.getDrawable(R.drawable.ic_sysbar_back); mBackLandIcon = res.getDrawable(R.drawable.ic_sysbar_back_land); mBackAltIcon = res.getDrawable(R.drawable.ic_sysbar_back_ime); mBackAltLandIcon = res.getDrawable(R.drawable.ic_sysbar_back_ime); mContext.getContentResolver().registerContentObserver( Settings.System.getUriFor(Settings.System.NAV_BAR_COLOR), false, new ContentObserver(new Handler()) { @Override public void onChange(boolean selfChange) { updateColor(false); } }); }
From source file:com.android.development.Connectivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.connectivity); mWm = (WifiManager) getSystemService(Context.WIFI_SERVICE); mPm = (PowerManager) getSystemService(Context.POWER_SERVICE); mCm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE); mNetd = INetworkManagementService.Stub.asInterface(b); findViewById(R.id.enableWifi).setOnClickListener(mClickListener); findViewById(R.id.disableWifi).setOnClickListener(mClickListener); findViewById(R.id.startDelayedCycle).setOnClickListener(mClickListener); findViewById(R.id.stopDelayedCycle).setOnClickListener(mClickListener); mDCOnDurationEdit = (EditText) findViewById(R.id.dc_wifi_on_duration); mDCOnDurationEdit.setText(Long.toString(mDCOnDuration)); mDCOffDurationEdit = (EditText) findViewById(R.id.dc_wifi_off_duration); mDCOffDurationEdit.setText(Long.toString(mDCOffDuration)); mDCCycleCountView = (TextView) findViewById(R.id.dc_wifi_cycles_done); mDCCycleCountView.setText(Integer.toString(mDCCycleCount)); findViewById(R.id.startScreenCycle).setOnClickListener(mClickListener); findViewById(R.id.stopScreenCycle).setOnClickListener(mClickListener); mSCOnDurationEdit = (EditText) findViewById(R.id.sc_wifi_on_duration); mSCOnDurationEdit.setText(Long.toString(mSCOnDuration)); mSCOffDurationEdit = (EditText) findViewById(R.id.sc_wifi_off_duration); mSCOffDurationEdit.setText(Long.toString(mSCOffDuration)); mSCCycleCountView = (TextView) findViewById(R.id.sc_wifi_cycles_done); mSCCycleCountView.setText(Integer.toString(mSCCycleCount)); mScanButton = (Button) findViewById(R.id.startScan); mScanButton.setOnClickListener(mClickListener); mScanCyclesEdit = (EditText) findViewById(R.id.sc_scan_cycles); mScanCyclesEdit.setText(Long.toString(mScanCycles)); mScanDisconnect = (CheckBox) findViewById(R.id.scanDisconnect); mScanDisconnect.setChecked(true);//from w w w .j a va2 s .c om mScanResults = (TextView) findViewById(R.id.sc_scan_results); mScanResults.setVisibility(View.INVISIBLE); mScanRecv = new WifiScanReceiver(); mIntentFilter = new IntentFilter(); mIntentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); findViewById(R.id.startTdls).setOnClickListener(mClickListener); findViewById(R.id.stopTdls).setOnClickListener(mClickListener); findViewById(R.id.start_mms).setOnClickListener(mClickListener); findViewById(R.id.stop_mms).setOnClickListener(mClickListener); findViewById(R.id.start_hipri).setOnClickListener(mClickListener); findViewById(R.id.stop_hipri).setOnClickListener(mClickListener); findViewById(R.id.crash).setOnClickListener(mClickListener); findViewById(R.id.add_default_route).setOnClickListener(mClickListener); findViewById(R.id.remove_default_route).setOnClickListener(mClickListener); findViewById(R.id.bound_http_request).setOnClickListener(mClickListener); findViewById(R.id.bound_socket_request).setOnClickListener(mClickListener); findViewById(R.id.routed_http_request).setOnClickListener(mClickListener); findViewById(R.id.routed_socket_request).setOnClickListener(mClickListener); findViewById(R.id.default_request).setOnClickListener(mClickListener); findViewById(R.id.default_socket).setOnClickListener(mClickListener); registerReceiver(mReceiver, new IntentFilter(CONNECTIVITY_TEST_ALARM)); }
From source file:com.android.settings.Settings.java
private void updateHeaderList(List<Header> target) { final boolean showDev = mDevelopmentPreferences.getBoolean(DevelopmentSettings.PREF_SHOW, android.os.Build.TYPE.equals("eng")); int i = 0;//from ww w . j a v a2s . c o m boolean IsSupVoice = Settings.this.getResources() .getBoolean(com.android.internal.R.bool.config_voice_capable); final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE); mHeaderIndexMap.clear(); while (i < target.size()) { Header header = target.get(i); // Ids are integers, so downcasting int id = (int) header.id; if (id == R.id.operator_settings || id == R.id.manufacturer_settings) { Utils.updateHeaderToSpecificActivityFromMetaDataOrRemove(this, target, header); } else if (id == R.id.wifi_settings) { // Remove WiFi Settings if WiFi service is not available. if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) { target.remove(i); } } else if (id == R.id.bluetooth_settings) { // Remove Bluetooth Settings if Bluetooth service is not available. if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) { target.remove(i); } } else if (id == R.id.data_usage_settings) { // Remove data usage when kernel module not enabled final INetworkManagementService netManager = INetworkManagementService.Stub .asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE)); try { /* SPRDADD to delete the data usage item of settings @{ */ boolean support_cmcc = SystemProperties.get("ro.operator").equals("cmcc"); if (!netManager.isBandwidthControlEnabled() || support_cmcc) { target.remove(i); } } catch (RemoteException e) { // ignored } } else if (id == R.id.battery_settings) { // Remove battery settings when battery is not available. (e.g. TV) if (!mBatteryPresent) { target.remove(i); } /* @} */ } else if (id == R.id.account_settings) { int headerIndex = i + 1; i = insertAccountsHeaders(target, headerIndex); // SPRD: clear viewCache ListAdapter listAdapter = getListAdapter(); if (listAdapter instanceof HeaderAdapter) { // add for tab style ((HeaderAdapter) listAdapter).flushViewCache(); } } else if (id == R.id.home_settings) { if (!updateHomeSettingHeaders(header)) { target.remove(i); } } else if (id == R.id.user_settings) { if (!UserHandle.MU_ENABLED || !UserManager.supportsMultipleUsers() || Utils.isMonkeyRunning()) { target.remove(i); } } else if (id == R.id.nfc_payment_settings) { if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) { target.remove(i); } else { // Only show if NFC is on and we have the HCE feature NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this); if (!adapter.isEnabled() || !getPackageManager() .hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) { target.remove(i); } } } else if (id == R.id.development_settings) { if (!showDev) { target.remove(i); } } else if (id == R.id.account_add) { if (um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) { target.remove(i); } } /* SPRD: modified for cucc feature @{ */ else if (id == R.id.network_preference_settings) { //if (!("cucc".equals(WifiManager.SUPPORT_VERSION))) { if (!CU_SUPPORT) { //modify for CUCC support 2013-11-22 target.remove(header); } } /* @} */ /* SPRD: add AudioProfile @{ */ else if (id == R.id.sound_settings && IsSupVoice) { target.remove(header); } else if (id == R.id.audio_profiles && !IsSupVoice) { target.remove(header); } /* @} */ /* SPRD: for multi-sim @{ */ else if (id == R.id.dual_sim_settings) { if (!TelephonyManager.isMultiSim() || (!mVoiceCapable)) { target.remove(header); } } /* @} */ /* SPRD: add for uui style 335009 @{ */ else if (id == R.id.uninstall_settings) { if (!UNIVERSEUI_SUPPORT) { target.remove(header); } } /* @} */ /* smart_wake {@*/ else if (id == R.id.smart_wake) { if (!SMART_WAKE) { target.remove(header); } } /* @} */ /*lyx 20150320 power_saving */ else if (id == R.id.power_saving) { if (!FeatureOption.PRJ_FEATURE_POWER_SAVING) { target.remove(header); } } /* @} */ if (i < target.size() && target.get(i) == header && UserHandle.MU_ENABLED && UserHandle.myUserId() != 0 && !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, id)) { target.remove(i); } // Increment if the current one wasn't removed by the Utils code. if (i < target.size() && target.get(i) == header) { // Hold on to the first header, when we need to reset to the top-level if (mFirstHeader == null && HeaderAdapter.getHeaderType(header) != HeaderAdapter.HEADER_TYPE_CATEGORY) { mFirstHeader = header; } mHeaderIndexMap.put(id, i); i++; } } }
From source file:com.android.settings.HWSettings.java
public void updateHeaderList(List<Header> target) { final boolean showDev = mDevelopmentPreferences.getBoolean(DevelopmentSettings.PREF_SHOW, android.os.Build.TYPE.equals("eng")); int i = 0;/* w w w .j a v a 2 s.c o m*/ boolean IsSupVoice = this.getResources().getBoolean(com.android.internal.R.bool.config_voice_capable); final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE); mHeaderIndexMap.clear(); while (i < target.size()) { Header header = target.get(i); // Ids are integers, so downcasting int id = (int) header.id; if (id == R.id.operator_settings || id == R.id.manufacturer_settings) { Utils.updateHeaderToSpecificActivityFromMetaDataOrRemove(this, target, header); } else if (id == R.id.wifi_settings) { // Remove WiFi Settings if WiFi service is not available. if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) { target.remove(i); } } else if (id == R.id.bluetooth_settings) { // Remove Bluetooth Settings if Bluetooth service is not available. if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) { target.remove(i); } } else if (id == R.id.data_usage_settings) { // Remove data usage when kernel module not enabled final INetworkManagementService netManager = INetworkManagementService.Stub .asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE)); try { /* SPRDADD to delete the data usage item of settings @{ */ boolean support_cmcc = SystemProperties.get("ro.operator").equals("cmcc"); if (!netManager.isBandwidthControlEnabled() || support_cmcc) { target.remove(i); } } catch (RemoteException e) { // ignored } } else if (id == R.id.battery_settings) { // Remove battery settings when battery is not available. (e.g. TV) if (!mBatteryPresent) { target.remove(i); } /* @} */ } else if (id == R.id.account_settings) { int headerIndex = i + 1; i = insertAccountsHeaders(target, headerIndex); // SPRD: clear viewCache ListAdapter listAdapter = getListAdapter(); if (listAdapter instanceof HeaderAdapter) { // add for tab style ((HeaderAdapter) listAdapter).flushViewCache(); } } else if (id == R.id.home_settings) { if (!updateHomeSettingHeaders(header)) { target.remove(i); } } else if (id == R.id.user_settings) { if (!UserHandle.MU_ENABLED || !UserManager.supportsMultipleUsers() || Utils.isMonkeyRunning()) { target.remove(i); } } else if (id == R.id.nfc_payment_settings) { if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) { target.remove(i); } else { // Only show if NFC is on and we have the HCE feature NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this); if (!adapter.isEnabled() || !getPackageManager() .hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) { target.remove(i); } } } else if (id == R.id.development_settings) { if (!showDev) { target.remove(i); } } else if (id == R.id.account_add) { if (um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) { target.remove(i); } } /* SPRD: modified for cucc feature @{ */ else if (id == R.id.network_preference_settings) { //if (!("cucc".equals(WifiManager.SUPPORT_VERSION))) { if (!CU_SUPPORT) { //modify for CUCC support 2013-11-22 target.remove(header); } } /* @} */ /* SPRD: add AudioProfile @{ */ else if (id == R.id.sound_settings && IsSupVoice) { target.remove(header); } else if (id == R.id.audio_profiles && !IsSupVoice) { target.remove(header); } /* @} */ /* SPRD: for multi-sim @{ */ else if (id == R.id.dual_sim_settings) { if (!TelephonyManager.isMultiSim() || (!mVoiceCapable)) { target.remove(header); } } /* @} */ /* SPRD: add for uui style 335009 @{ */ else if (id == R.id.uninstall_settings) { target.remove(header); } /* @} */ /* else if (id == R.id.mobile_network_settings_hw){ header.intent.putExtra(MobileSimChoose.PACKAGE_NAME, "com.android.phone"); header.intent.putExtra(MobileSimChoose.CLASS_NAME, "com.android.phone.MobileNetworkSettings"); } */ if (i < target.size() && target.get(i) == header && UserHandle.MU_ENABLED && UserHandle.myUserId() != 0 && !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, id)) { target.remove(i); } // Increment if the current one wasn't removed by the Utils code. if (i < target.size() && target.get(i) == header) { // Hold on to the first header, when we need to reset to the top-level if (mFirstHeader == null && HeaderAdapter.getHeaderType(header) != HeaderAdapter.HEADER_TYPE_CATEGORY) { mFirstHeader = header; } mHeaderIndexMap.put(id, i); i++; } } }
From source file:com.android.settings.applications.CanBeOnSdCardChecker.java
@Override public void onClick(DialogInterface dialog, int which) { if (mResetDialog == dialog) { final PackageManager pm = getActivity().getPackageManager(); final IPackageManager mIPm = IPackageManager.Stub.asInterface(ServiceManager.getService("package")); final INotificationManager nm = INotificationManager.Stub .asInterface(ServiceManager.getService(Context.NOTIFICATION_SERVICE)); final NetworkPolicyManager npm = NetworkPolicyManager.from(getActivity()); final AppOpsManager aom = (AppOpsManager) getActivity().getSystemService(Context.APP_OPS_SERVICE); final Handler handler = new Handler(getActivity().getMainLooper()); (new AsyncTask<Void, Void, Void>() { @Override/*from ww w .j av a 2 s. co m*/ protected Void doInBackground(Void... params) { List<ApplicationInfo> apps = pm .getInstalledApplications(PackageManager.GET_DISABLED_COMPONENTS); for (int i = 0; i < apps.size(); i++) { ApplicationInfo app = apps.get(i); try { if (DEBUG) Log.v(TAG, "Enabling notifications: " + app.packageName); nm.setNotificationsEnabledForPackage(app.packageName, app.uid, true); } catch (android.os.RemoteException ex) { } if (!app.enabled) { if (DEBUG) Log.v(TAG, "Enabling app: " + app.packageName); if (pm.getApplicationEnabledSetting( app.packageName) == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER) { pm.setApplicationEnabledSetting(app.packageName, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, PackageManager.DONT_KILL_APP); } } } try { mIPm.resetPreferredActivities(UserHandle.myUserId()); } catch (RemoteException e) { } aom.resetAllModes(); final int[] restrictedUids = npm.getUidsWithPolicy(POLICY_REJECT_METERED_BACKGROUND); final int currentUserId = ActivityManager.getCurrentUser(); for (int uid : restrictedUids) { // Only reset for current user if (UserHandle.getUserId(uid) == currentUserId) { if (DEBUG) Log.v(TAG, "Clearing data policy: " + uid); npm.setUidPolicy(uid, POLICY_NONE); } } handler.post(new Runnable() { @Override public void run() { if (DEBUG) Log.v(TAG, "Done clearing"); if (getActivity() != null && mActivityResumed) { if (DEBUG) Log.v(TAG, "Updating UI!"); for (int i = 0; i < mTabs.size(); i++) { TabInfo tab = mTabs.get(i); if (tab.mApplications != null) { tab.mApplications.pause(); } } if (mCurTab != null) { mCurTab.resume(mSortOrder); } } } }); return null; } }).execute(); } }
From source file:com.android.server.MountService.java
/** * Constructs a new MountService instance * * @param context Binder context for this service *//*from w w w .ja v a2s. co m*/ public MountService(Context context) { sSelf = this; mContext = context; synchronized (mVolumesLock) { readStorageListLocked(); } // XXX: This will go away soon in favor of IMountServiceObserver mPms = (PackageManagerService) ServiceManager.getService("package"); HandlerThread hthread = new HandlerThread(TAG); hthread.start(); mHandler = new MountServiceHandler(hthread.getLooper()); // Watch for user changes final IntentFilter userFilter = new IntentFilter(); userFilter.addAction(Intent.ACTION_USER_ADDED); userFilter.addAction(Intent.ACTION_USER_REMOVED); mContext.registerReceiver(mUserReceiver, userFilter, null, mHandler); // Watch for USB changes on primary volume final StorageVolume primary = getPrimaryPhysicalVolume(); if (primary != null && primary.allowMassStorage()) { mContext.registerReceiver(mUsbReceiver, new IntentFilter(UsbManager.ACTION_USB_STATE), null, mHandler); } // Add OBB Action Handler to MountService thread. mObbActionHandler = new ObbActionHandler(IoThread.get().getLooper()); // Initialize the last-fstrim tracking if necessary File dataDir = Environment.getDataDirectory(); File systemDir = new File(dataDir, "system"); mLastMaintenanceFile = new File(systemDir, LAST_FSTRIM_FILE); if (!mLastMaintenanceFile.exists()) { // Not setting mLastMaintenance here means that we will force an // fstrim during reboot following the OTA that installs this code. try { (new FileOutputStream(mLastMaintenanceFile)).close(); } catch (IOException e) { Slog.e(TAG, "Unable to create fstrim record " + mLastMaintenanceFile.getPath()); } } else { mLastMaintenance = mLastMaintenanceFile.lastModified(); } /* * Create the connection to vold with a maximum queue of twice the * amount of containers we'd ever expect to have. This keeps an * "asec list" from blocking a thread repeatedly. */ mConnector = new NativeDaemonConnector(this, "vold", MAX_CONTAINERS * 2, VOLD_TAG, 25, null); Thread thread = new Thread(mConnector, VOLD_TAG); thread.start(); // Add ourself to the Watchdog monitors if enabled. if (WATCHDOG_ENABLE) { Watchdog.getInstance().addMonitor(this); } }