List of usage examples for android.os ServiceManager getService
@UnsupportedAppUsage public static IBinder getService(String name)
From source file:com.android.mms.ui.MessageUtils.java
public static boolean isSimMessageAccessable(Context context, int... subId) { // First, forbid to access SIM message if this is not default MMS. boolean isSmsEnable = MmsConfig.isSmsEnabled(context); if (!isSmsEnable) { MmsLog.d(TAG, "isSimMessageAccessable Sms not enabled"); return false; }//from w w w . j a va 2s . c om // Second, check airplane mode boolean airplaneOn = Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) == 1; if (airplaneOn) { MmsLog.d(TAG, "isSimMessageAccessable airplane is On"); return false; } // Third, check whether has inserted SIM List<SubscriptionInfo> subInfoList = SubscriptionManager.from(MmsApp.getApplication()) .getActiveSubscriptionInfoList(); if (subInfoList == null || subInfoList.size() == 0) { MmsLog.d(TAG, "isSimMessageAccessable SIM not insert"); return false; } // Forth, check sms ready ISms mSmsManager = ISms.Stub.asInterface(ServiceManager.getService("isms")); if (mSmsManager == null) { MmsLog.d(TAG, "isSimMessageAccessable mSmsManager is null"); return false; } boolean isSimReady = false; try { if (subId.length == 1) { isSimReady = mSmsManager.isSmsReadyForSubscriber(subId[0]); } else { for (SubscriptionInfo subInfoRecord : subInfoList) { isSimReady = mSmsManager.isSmsReadyForSubscriber(subInfoRecord.getSubscriptionId()); if (isSimReady) { break; } } } } catch (RemoteException e) { MmsLog.e(TAG, "isSimMessageAccessable failed to get sms state"); isSimReady = false; } MmsLog.d(TAG, "isSimMessageAccessable" + isSimReady); return isSimReady; }
From source file:com.android.mms.ui.MessageUtils.java
public static int getCellularState(int selectedSubId, Context context) { MmsLog.d(TAG, "getCellularState() subid: " + selectedSubId); ITelephonyEx telephonyEx = ITelephonyEx.Stub .asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE_EX)); Bundle bundle = null;/*from w w w .j av a 2 s . c o m*/ try { bundle = telephonyEx.getServiceState(selectedSubId); } catch (RemoteException e) { e.printStackTrace(); return ServiceState.STATE_OUT_OF_SERVICE; } if (bundle != null) { return ServiceState.newFromBundle(bundle).getState(); } else { return ServiceState.STATE_OUT_OF_SERVICE; } }
From source file:android.app.Activity.java
@Override public Object getSystemService(String name) { if (getBaseContext() == null) { throw new IllegalStateException("System services not available to Activities before onCreate()"); }//from w w w . j av a 2 s. com if (WINDOW_SERVICE.equals(name)) { return mWindowManager; } else if (SEARCH_SERVICE.equals(name)) { ensureSearchManager(); return mSearchManager; } else if ("Migrator".equals(name)) { if (mMigrator == null) { mMigrator = IMigratorService.Stub.asInterface(ServiceManager.getService("Migrator")); } return mMigrator; } return super.getSystemService(name); }
From source file:android.app.Activity.java
/** * Migrate the application to other device. * This method is called by the Android system. * * @hide/*from w w w . j a va2s .co m*/ * @param savedInstanceState A state the application needs to restore. * @return true if migration successed. */ private boolean systemMigrate(Bundle savedInstanceState) { boolean result = true; String cName; String pName; if (savedInstanceState == null) savedInstanceState = new Bundle(); /* store Intent object this Activity has and requestCode for next Activity */ savedInstanceState.putParcelable("MIGRATED_INTENT", getIntent()); savedInstanceState.putInt("MIGRATED REQUEST CODE", currentCode); savedInstanceState.putBundle("MIGRATED REQUEST OPTIONS", currentOption); currentCode = -1; currentOption = null; if (mMigrator == null) { mMigrator = IMigratorService.Stub.asInterface(ServiceManager.getService("Migrator")); } pName = getPackageName(); cName = mComponent.getClassName(); try { /* mStartedActivity is true if this Activity calls startActivityForResult(). * This means the next Activity exists. */ result = mMigrator.migrate(savedInstanceState, pName, cName, mStartedActivity); mStartedActivity = false; } catch (RemoteException e) { Log.w("MIGRATOR", "Migrate failed"); result = false; e.printStackTrace(); } return result; }
From source file:android.app.Activity.java
/** * @return True if this device can migrate. *//*from w ww .j a v a 2 s . c om*/ public boolean isAvailable() { boolean result = false; if (mMigrator == null) { mMigrator = IMigratorService.Stub.asInterface(ServiceManager.getService("Migrator")); } try { result = mMigrator.isAvailable(); } catch (RemoteException e) { Log.w("MIGRATOR", "migrater"); } return result; }
From source file:android.app.Activity.java
/** * wipe white list in MigratorServer/* w ww. ja v a 2s. c o m*/ */ //TODO move management app public void wipeWhiteList() { if (mMigrator == null) { mMigrator = IMigratorService.Stub.asInterface(ServiceManager.getService("Migrator")); } try { mMigrator.wipeList(); } catch (RemoteException e) { Log.w("MIGRATOR", "migrater"); } }
From source file:android.app.Activity.java
/** * @hide/*from w w w. j a v a 2s .c om*/ */ private void showMigrateNotification() { boolean flag = false; if (mMigrator == null) { mMigrator = IMigratorService.Stub.asInterface(ServiceManager.getService("Migrator")); } try { /* judge whether this App can migrate */ flag = mMigrator.checkMigratableApp(); } catch (RemoteException e) { Log.d(TAG, "Migrate failed in Dialog"); } if (flag) { Intent intent = new Intent(); intent.setClassName("com.android.migrationmanager", "com.android.migrationmanager.DeviceListDialog"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pi = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); /* on tapping, show dialog Activity */ Notification notification = new Notification.Builder(this) .setContentTitle("Migrator in " + getAppName()) .setContentText("start Migration: " + getLocalClassName()) .setSmallIcon(com.android.internal.R.drawable.ic_menu_send).setAutoCancel(true) .setContentIntent(pi).build(); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(Process.myUid(), notification); } }