コード例 #1
0
 /* Helper method, on API 17+ this method uses sendBroadcastAsUser to prevent
  * system warnings in logcat.
  */
 public static void sendBroadcast(Context context, Intent intent) {
   int currentapiVersion = android.os.Build.VERSION.SDK_INT;
   if (currentapiVersion >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
     context.sendBroadcastAsUser(
         intent, (UserHandle) XposedHelpers.getStaticObjectField(UserHandle.class, "CURRENT"));
   } else {
     context.sendBroadcast(intent);
   }
 }
コード例 #2
0
 private void sendBroadcast(String code, String status, String payload) {
   Intent broadcastIntent = new Intent();
   broadcastIntent.setAction(Constants.SYSTEM_APP_ACTION_RESPONSE);
   broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
   broadcastIntent.putExtra(Constants.CODE, code);
   broadcastIntent.putExtra(Constants.STATUS, status);
   broadcastIntent.putExtra(Constants.PAYLOAD, payload);
   context.sendBroadcastAsUser(broadcastIntent, android.os.Process.myUserHandle());
 }
コード例 #3
0
  /** Cancels low storage notification and sends OK intent. */
  private final void cancelNotification() {
    if (localLOGV) Slog.i(TAG, "Canceling low memory notification");
    NotificationManager mNotificationMgr =
        (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    // cancel notification since memory has been freed
    mNotificationMgr.cancelAsUser(null, LOW_MEMORY_NOTIFICATION_ID, UserHandle.ALL);

    mContext.removeStickyBroadcastAsUser(mStorageLowIntent, UserHandle.ALL);
    mContext.sendBroadcastAsUser(mStorageOkIntent, UserHandle.ALL);
  }
コード例 #4
0
 /** Notifies the status bar to trigger screen pinning. */
 @ProxyFromAnyToPrimaryUser
 public static void startScreenPinning(Context context, SystemServicesProxy ssp) {
   if (ssp.isForegroundUserOwner()) {
     onStartScreenPinning(context);
   } else {
     Intent intent =
         createLocalBroadcastIntent(context, ACTION_PROXY_SCREEN_PINNING_REQUEST_TO_OWNER);
     context.sendBroadcastAsUser(intent, UserHandle.OWNER);
   }
 }
コード例 #5
0
 /** Notifies the callbacks that the visibility of Recents has changed. */
 @ProxyFromAnyToPrimaryUser
 public static void notifyVisibilityChanged(
     Context context, SystemServicesProxy ssp, boolean visible) {
   if (ssp.isForegroundUserOwner()) {
     visibilityChanged(visible);
   } else {
     Intent intent =
         createLocalBroadcastIntent(context, ACTION_PROXY_NOTIFY_RECENTS_VISIBLITY_TO_OWNER);
     intent.putExtra(EXTRA_RECENTS_VISIBILITY, visible);
     context.sendBroadcastAsUser(intent, UserHandle.OWNER);
   }
 }
コード例 #6
0
  @Override
  public UserInfo createUser(String name, int flags) {
    checkManageUsersPermission("Only the system can create users");

    final long ident = Binder.clearCallingIdentity();
    final UserInfo userInfo;
    try {
      synchronized (mInstallLock) {
        synchronized (mPackagesLock) {
          if (isUserLimitReachedLocked()) return null;
          int userId = getNextAvailableIdLocked();
          userInfo = new UserInfo(userId, name, null, flags);
          File userPath = new File(mBaseUserPath, Integer.toString(userId));
          userInfo.serialNumber = mNextSerialNumber++;
          long now = System.currentTimeMillis();
          userInfo.creationTime = (now > EPOCH_PLUS_30_YEARS) ? now : 0;
          userInfo.partial = true;
          Environment.getUserSystemDirectory(userInfo.id).mkdirs();
          mUsers.put(userId, userInfo);
          writeUserListLocked();
          writeUserLocked(userInfo);
          mPm.createNewUserLILPw(userId, userPath);
          userInfo.partial = false;
          writeUserLocked(userInfo);
          updateUserIdsLocked();
        }
      }
      if (userInfo != null) {
        Intent addedIntent = new Intent(Intent.ACTION_USER_ADDED);
        addedIntent.putExtra(Intent.EXTRA_USER_HANDLE, userInfo.id);
        mContext.sendBroadcastAsUser(
            addedIntent, UserHandle.ALL, android.Manifest.permission.MANAGE_USERS);
      }
    } finally {
      Binder.restoreCallingIdentity(ident);
    }
    return userInfo;
  }
コード例 #7
0
 /** Cancels memory full notification and sends "not full" intent. */
 private final void cancelFullNotification() {
   if (localLOGV) Slog.i(TAG, "Canceling memory full notification");
   mContext.removeStickyBroadcastAsUser(mStorageFullIntent, UserHandle.ALL);
   mContext.sendBroadcastAsUser(mStorageNotFullIntent, UserHandle.ALL);
 }
コード例 #8
0
 private void sendUserInfoChangedBroadcast(int userId) {
   Intent changedIntent = new Intent(Intent.ACTION_USER_INFO_CHANGED);
   changedIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId);
   changedIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
   mContext.sendBroadcastAsUser(changedIntent, new UserHandle(userId));
 }