Beispiel #1
0
  @Override
  protected void before(XParam param) throws Throwable {
    if (mMethod == Methods.isApiSupported
        || mMethod == Methods.isSipWifiOnly
        || mMethod == Methods.isVoipSupported) {
      if (isRestricted(param)) param.setResult(false);

    } else if (mMethod == Methods.newInstance) {
      if (isRestricted(param)) param.setResult(null);

    } else Util.log(this, Log.WARN, "Unknown method=" + param.method.getName());
  }
  @Override
  protected void before(XParam param) throws Throwable {
    switch (mMethod) {
      case enableMyLocation:
        if (isRestricted(param)) param.setResult(false);
        break;

      case disableMyLocation:
        if (isRestricted(param, PrivacyManager.cLocation, "MapV1.enableMyLocation"))
          param.setResult(null);
        break;
    }
  }
Beispiel #3
0
  @Override
  protected void after(XParam param) throws Throwable {
    switch (mMethod) {
      case getExternalStorageState:
        if (param.getResult() != null) {
          String extra = null;
          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
            if (param.args.length > 0 && param.args[0] instanceof File)
              extra = ((File) param.args[0]).getAbsolutePath();

          if (isRestrictedExtra(param, extra)) param.setResult(Environment.MEDIA_UNMOUNTED);
        }
        break;
    }
  }
Beispiel #4
0
  @Override
  @SuppressWarnings("unchecked")
  protected void after(XParam param) throws Throwable {
    if (mMethod != Methods.addOnAccountsUpdatedListener
        && mMethod != Methods.removeOnAccountsUpdatedListener) {
      int uid = Binder.getCallingUid();
      if (mMethod == Methods.blockingGetAuthToken) {
        if (param.args.length > 0 && param.args[0] != null) {
          Account account = (Account) param.args[0];
          if (param.getResult() != null
              && isRestrictedExtra(param, account == null ? null : account.name))
            if (!isAccountAllowed(account, uid)) param.setResult(null);
        }

      } else if (mMethod == Methods.getAccounts) {
        if (param.getResult() != null && isRestricted(param)) {
          Account[] accounts = (Account[]) param.getResult();
          param.setResult(filterAccounts(accounts, uid));
        }

      } else if (mMethod == Methods.getAccountsByType
          || mMethod == Methods.getAccountsByTypeForPackage) {
        if (param.args.length > 0)
          if (param.getResult() != null && isRestrictedExtra(param, (String) param.args[0])) {
            Account[] accounts = (Account[]) param.getResult();
            param.setResult(filterAccounts(accounts, uid));
          }

      } else if (mMethod == Methods.getAccountsByTypeAndFeatures) {
        if (param.args.length > 0)
          if (param.getResult() != null && isRestrictedExtra(param, (String) param.args[0])) {
            AccountManagerFuture<Account[]> future =
                (AccountManagerFuture<Account[]>) param.getResult();
            param.setResult(new XFutureAccount(future, uid));
          }

      } else if (mMethod == Methods.getAuthenticatorTypes) {
        if (param.getResult() != null && isRestricted(param))
          param.setResult(new AuthenticatorDescription[0]);

      } else if (mMethod == Methods.getAuthToken) {
        if (param.args.length > 0) {
          Account account = (Account) param.args[0];
          if (param.getResult() != null
              && isRestrictedExtra(param, account == null ? null : account.name)) {
            AccountManagerFuture<Bundle> future = (AccountManagerFuture<Bundle>) param.getResult();
            param.setResult(new XFutureBundle(future, uid));
          }
        }

      } else if (mMethod == Methods.getAuthTokenByFeatures) {
        if (param.getResult() != null && isRestricted(param, (String) param.args[0])) {
          AccountManagerFuture<Bundle> future = (AccountManagerFuture<Bundle>) param.getResult();
          param.setResult(new XFutureBundle(future, uid));
        }

      } else if (mMethod == Methods.hasFeatures) {
        if (param.args.length > 0 && param.args[0] != null) {
          Account account = (Account) param.args[0];
          if (param.getResult() != null
              && isRestrictedExtra(param, account == null ? null : account.name))
            if (!isAccountAllowed(account, uid)) param.setResult(new XFutureBoolean());
        }

      } else Util.log(this, Log.WARN, "Unknown method=" + param.method.getName());
    }
  }
 @Override
 protected void before(XParam param) throws Throwable {
   Util.log(this, Log.INFO, param.method.getName() + "=true");
   param.setResult(true);
 }