コード例 #1
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
  /**
   * Configure device WIFI profile.
   *
   * @param code - Operation code.
   * @param data - Data required(SSID, Password).
   * @param requestMode - Request mode(Normal mode or policy bundle mode).
   */
  public void configureWifi(String code, String data) {
    boolean wifistatus = false;
    String ssid = null;
    String password = null;

    try {
      JSONObject wifiData = new JSONObject(data);
      if (!wifiData.isNull(resources.getString(R.string.intent_extra_ssid))) {
        ssid = (String) wifiData.get(resources.getString(R.string.intent_extra_ssid));
      }
      if (!wifiData.isNull(resources.getString(R.string.intent_extra_password))) {
        password = (String) wifiData.get(resources.getString(R.string.intent_extra_password));
      }
    } catch (JSONException e) {
      Log.e(TAG, "Invalid JSON format " + e.toString());
    }

    WiFiConfig config = new WiFiConfig(context.getApplicationContext());

    wifistatus = config.saveWEPConfig(ssid, password);

    String status = null;
    if (wifistatus) {
      status = resources.getString(R.string.shared_pref_default_status);
    } else {
      status = resources.getString(R.string.shared_pref_false_status);
    }

    resultBuilder.build(code, status);
  }
コード例 #2
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
  /**
   * Wipe the device.
   *
   * @param code - Operation code.
   * @param data - Data required by the operation(PIN).
   */
  public void wipeDevice(String code, String data) {
    String inputPin;
    String savedPin = Preference.getString(context, resources.getString(R.string.shared_pref_pin));

    try {
      JSONObject wipeKey = new JSONObject(data);
      inputPin = (String) wipeKey.get(resources.getString(R.string.shared_pref_pin));
      String status;
      if (inputPin.trim().equals(savedPin.trim())) {
        status = resources.getString(R.string.shared_pref_default_status);
      } else {
        status = resources.getString(R.string.shared_pref_false_status);
      }

      resultBuilder.build(code, status);

      if (inputPin.trim().equals(savedPin.trim())) {
        Toast.makeText(context, resources.getString(R.string.toast_message_wipe), Toast.LENGTH_LONG)
            .show();
        try {
          Thread.sleep(PRE_WIPE_WAIT_TIME);
        } catch (InterruptedException e) {
          Log.e(TAG, "Wipe pause interrupted :" + e.toString());
        }
        devicePolicyManager.wipeData(ACTIVATION_REQUEST);
      } else {
        Toast.makeText(
                context, resources.getString(R.string.toast_message_wipe_failed), Toast.LENGTH_LONG)
            .show();
      }
    } catch (JSONException e) {
      Log.e(TAG, "Invalid JSON format." + e);
    }
  }
コード例 #3
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
  /**
   * Display notification.
   *
   * @param code - Operation code.
   */
  public void displayNotification(String code) {
    String notification = null;

    try {
      JSONObject inputData = new JSONObject(code);
      if (inputData.get(resources.getString(R.string.intent_extra_notification)).toString() != null
          && !inputData
              .get(resources.getString(R.string.intent_extra_notification))
              .toString()
              .isEmpty()) {
        notification =
            inputData.get(resources.getString(R.string.intent_extra_notification)).toString();
      }

      resultBuilder.build(code);

      if (notification != null) {
        Intent intent = new Intent(context, AlertActivity.class);
        intent.putExtra(resources.getString(R.string.intent_extra_message), notification);
        intent.setFlags(
            Intent.FLAG_ACTIVITY_CLEAR_TASK
                | Intent.FLAG_ACTIVITY_CLEAR_TOP
                | Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
      }
    } catch (JSONException e) {
      Log.e(TAG, "Invalid JSON format." + e);
    }
  }
コード例 #4
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
 /**
  * Set policy bundle.
  *
  * @param code - Operation code.
  */
 public void setPolicyBundle(String code) {
   try {
     resultBuilder.build(code, new JSONObject(bundleParams.toString()));
   } catch (JSONException e) {
     Log.e(TAG, "Invalid JSON format." + e);
   }
 }
コード例 #5
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
  /**
   * Disable/Enable device camera.
   *
   * @param code - Operation code.
   * @param data - Data required(Camera enable/disable switch).
   * @param requestMode - Request mode(Normal mode or policy bundle mode).
   */
  public void disableCamera(String code, String data) {
    boolean camFunc = false;
    try {
      JSONObject inputData = new JSONObject(data);
      if (!inputData.isNull(resources.getString(R.string.intent_extra_function))
          && inputData
              .get(resources.getString(R.string.intent_extra_function))
              .toString()
              .equalsIgnoreCase(resources.getString(R.string.intent_extra_enable))) {
        camFunc = false;
      } else if (!inputData.isNull(resources.getString(R.string.intent_extra_function))
          && inputData
              .get(resources.getString(R.string.intent_extra_function))
              .toString()
              .equalsIgnoreCase(resources.getString(R.string.intent_extra_disable))) {
        camFunc = true;
      } else if (!inputData.isNull(resources.getString(R.string.intent_extra_function))) {
        camFunc =
            Boolean.parseBoolean(
                inputData.get(resources.getString(R.string.intent_extra_function)).toString());
      }

      ComponentName cameraAdmin = new ComponentName(context, AgentDeviceAdminReceiver.class);

      resultBuilder.build(code);

      devicePolicyManager.setCameraDisabled(cameraAdmin, camFunc);
    } catch (JSONException e) {
      Log.e(TAG, "Invalid JSON format." + e);
    }
  }
コード例 #6
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
  /**
   * Blacklisting apps.
   *
   * @param code - Operation code.
   * @param data - Data required(Application data).
   */
  public void blacklistApps(String code, String data) {
    ArrayList<DeviceAppInfo> apps = appList.getInstalledApps();
    JSONArray appList = new JSONArray();
    String identity = null;
    try {
      JSONObject resultApp = new JSONObject(data);
      if (!resultApp.isNull(resources.getString(R.string.intent_extra_data))) {
        resultApp = (JSONObject) resultApp.get(resources.getString(R.string.intent_extra_data));
      }

      identity = (String) resultApp.get(resources.getString(R.string.intent_extra_identity));
    } catch (JSONException e) {
      Log.e(TAG, "Invalid JSON format." + e);
    }

    for (DeviceAppInfo app : apps) {
      JSONObject result = new JSONObject();
      try {
        result.put(resources.getString(R.string.intent_extra_name), app.getAppname());
        result.put(resources.getString(R.string.intent_extra_package), app.getPackagename());
        if (identity.trim().equals(app.getPackagename())) {
          result.put(resources.getString(R.string.intent_extra_not_violated), false);
          result.put(resources.getString(R.string.intent_extra_package), app.getPackagename());
        } else {
          result.put(resources.getString(R.string.intent_extra_not_violated), true);
        }

      } catch (JSONException e) {
        Log.e(TAG, "Invalid JSON format." + e);
      }
      appList.put(result);
    }

    resultBuilder.build(code, appList);
  }
コード例 #7
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
  /**
   * Encrypt/Decrypt device storage.
   *
   * @param code - Operation code.
   * @param data - Data required(Encryption enable/disable switch).
   * @param requestMode - Request mode(Normal mode or policy bundle mode).
   */
  public void encryptStorage(String code, String data) {
    boolean doEncrypt = true;
    try {
      JSONObject encryptData = new JSONObject(data);
      if (!encryptData.isNull(resources.getString(R.string.intent_extra_function))
          && encryptData
              .get(resources.getString(R.string.intent_extra_function))
              .toString()
              .equalsIgnoreCase(resources.getString(R.string.intent_extra_encrypt))) {
        doEncrypt = true;
      } else if (!encryptData.isNull(resources.getString(R.string.intent_extra_function))
          && encryptData
              .get(resources.getString(R.string.intent_extra_function))
              .toString()
              .equalsIgnoreCase(resources.getString(R.string.intent_extra_decrypt))) {
        doEncrypt = false;
      } else if (!encryptData.isNull(resources.getString(R.string.intent_extra_function))) {
        doEncrypt =
            Boolean.parseBoolean(
                encryptData.get(resources.getString(R.string.intent_extra_function)).toString());
      }
    } catch (JSONException e) {
      Log.e(TAG, "Invalid JSON format." + e);
    }

    ComponentName admin = new ComponentName(context, AgentDeviceAdminReceiver.class);

    if (doEncrypt
        && devicePolicyManager.getStorageEncryptionStatus()
            != DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED
        && (devicePolicyManager.getStorageEncryptionStatus()
            == DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE)) {

      devicePolicyManager.setStorageEncryption(admin, doEncrypt);
      Intent intent = new Intent(DevicePolicyManager.ACTION_START_ENCRYPTION);
      intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      context.startActivity(intent);

    } else if (!doEncrypt
        && devicePolicyManager.getStorageEncryptionStatus()
            != DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED
        && (devicePolicyManager.getStorageEncryptionStatus()
                == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE
            || devicePolicyManager.getStorageEncryptionStatus()
                == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVATING)) {

      devicePolicyManager.setStorageEncryption(admin, doEncrypt);
    }

    String status;
    if (devicePolicyManager.getStorageEncryptionStatus()
        != DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED) {
      status = resources.getString(R.string.shared_pref_default_status);
    } else {
      status = resources.getString(R.string.shared_pref_false_status);
    }

    resultBuilder.build(code, status);
  }
コード例 #8
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
  /**
   * Enterprise wipe the device.
   *
   * @param code - Operation code.
   */
  public void enterpriseWipe(String code) {
    resultBuilder.build(code);

    CommonUtils.clearAppData(context);
    Intent intent = new Intent(context, ServerDetails.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
  }
コード例 #9
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
  /**
   * Uninstall application.
   *
   * @param code - Operation code.
   * @param data - Data required(App package).
   */
  public void uninstallApplication(String code, String data) {
    String packageName;
    try {
      JSONObject appData = new JSONObject(data);
      packageName = (String) appData.get(resources.getString(R.string.intent_extra_identity));

      resultBuilder.build(code);

      appList.uninstallApplication(packageName);
    } catch (JSONException e) {
      Log.e(TAG, "Invalid JSON format." + e);
    }
  }
コード例 #10
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
  /**
   * Install google play applications.
   *
   * @param code - Operation code.
   * @param data - Data required(App data).
   */
  public void installGooglePlayApp(String code, String data) {
    String packageName = null;
    try {
      JSONObject appData = new JSONObject(data);
      packageName = (String) appData.get(resources.getString(R.string.intent_extra_package));

    } catch (JSONException e) {
      Log.e(TAG, "Invalid JSON format." + e);
    }

    resultBuilder.build(code);
    triggerGooglePlayApp(packageName);
  }
コード例 #11
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
  /**
   * Clear device password.
   *
   * @param code - Operation code.
   * @param requestMode - Request mode(Normal mode or policy bundle mode).
   */
  public void clearPassword(String code) {
    ComponentName demoDeviceAdmin = new ComponentName(context, AgentDeviceAdminReceiver.class);
    resultBuilder.build(code);

    devicePolicyManager.setPasswordQuality(
        demoDeviceAdmin, DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
    devicePolicyManager.setPasswordMinimumLength(demoDeviceAdmin, DEFAULT_PASSWORD_LENGTH);
    devicePolicyManager.resetPassword(
        resources.getString(R.string.shared_pref_default_string),
        DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY);
    devicePolicyManager.lockNow();
    devicePolicyManager.setPasswordQuality(
        demoDeviceAdmin, DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
  }
コード例 #12
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
  /**
   * Retrieve device information.
   *
   * @param code - Operation code.
   */
  public void getLocationInfo(String code) {
    double latitude;
    double longitude;
    JSONObject result = new JSONObject();
    GPSTracker gps = new GPSTracker(context);

    try {
      latitude = gps.getLatitude();
      longitude = gps.getLongitude();
      result.put(LOCATION_INFO_TAG_LATITUDE, latitude);
      result.put(LOCATION_INFO_TAG_LONGITUDE, longitude);
      resultBuilder.build(code, result);
    } catch (JSONException e) {
      Log.e(TAG, "Invalid JSON format." + e);
    }
  }
コード例 #13
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
  /**
   * Create web clip (Web app shortcut on device home screen).
   *
   * @param code - Operation code.
   * @param data - Data required(Web app data).
   */
  public void createWebClip(String code, String data) {
    String appUrl = null;
    String title = null;

    try {
      JSONObject webClipData = new JSONObject(code);
      appUrl = (String) webClipData.get(resources.getString(R.string.intent_extra_identity));
      title = (String) webClipData.get(resources.getString(R.string.intent_extra_title));
    } catch (JSONException e) {
      Log.e(TAG, "Invalid JSON format. " + e);
    }

    resultBuilder.build(data);

    if (appUrl != null && title != null) {
      appList.createWebAppBookmark(appUrl, title);
    }
  }
コード例 #14
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
  /**
   * Retrieve device information.
   *
   * @param code - Operation code.
   */
  public void getDeviceInfo(String code) {
    DeviceInfo deviceInfo = new DeviceInfo(context.getApplicationContext());
    DeviceState phoneState =
        DeviceStateFactory.getDeviceState(
            context.getApplicationContext(), deviceInfo.getSdkVersion());
    GPSTracker gps = new GPSTracker(context.getApplicationContext());
    JSONObject result = new JSONObject();
    JSONObject batteryInfo = new JSONObject();
    JSONObject internalMemoryInfo = new JSONObject();
    JSONObject externalMemoryInfo = new JSONObject();
    JSONObject locationInfo = new JSONObject();
    double latitude;
    double longitude;

    try {
      latitude = gps.getLatitude();
      longitude = gps.getLongitude();
      int batteryLevel = (int) Math.floor(phoneState.getBatteryLevel());
      batteryInfo.put(BATTERY_INFO_TAG_LEVEL, batteryLevel);

      internalMemoryInfo.put(MEMORY_INFO_TAG_TOTAL, phoneState.getTotalInternalMemorySize());
      internalMemoryInfo.put(
          MEMORY_INFO_TAG_AVAILABLE, phoneState.getAvailableInternalMemorySize());
      externalMemoryInfo.put(MEMORY_INFO_TAG_TOTAL, phoneState.getTotalExternalMemorySize());
      externalMemoryInfo.put(
          MEMORY_INFO_TAG_AVAILABLE, phoneState.getAvailableExternalMemorySize());
      locationInfo.put(LOCATION_INFO_TAG_LATITUDE, latitude);
      locationInfo.put(LOCATION_INFO_TAG_LONGITUDE, longitude);

      result.put(BATTERY_INFO_TAG, batteryInfo);
      result.put(MEMORY_INFO_TAG_INTERNAL, internalMemoryInfo);
      result.put(MEMORY_INFO_TAG_EXTERNAL, externalMemoryInfo);
      if (latitude != 0 && longitude != 0) {
        result.put(LOCATION_INFO_TAG, locationInfo);
      }
      result.put(NETWORK_OPERATOR_TAG, deviceInfo.getNetworkOperatorName());

      resultBuilder.build(code, result);

    } catch (JSONException e) {
      Log.e(TAG, "Invalid JSON format." + e);
    }
  }
コード例 #15
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
  /**
   * Retrieve device application information.
   *
   * @param code - Operation code.
   */
  public void getApplicationList(String code) {
    ArrayList<DeviceAppInfo> apps = appList.getInstalledApps();

    JSONArray result = new JSONArray();
    int size = apps.size();

    for (int i = 0; i < size; i++) {
      JSONObject app = new JSONObject();
      try {
        app.put(APP_INFO_TAG_NAME, Uri.encode(apps.get(i).getAppname()));
        app.put(APP_INFO_TAG_PACKAGE, apps.get(i).getPackagename());
        app.put(APP_INFO_TAG_ICON, apps.get(i).getIcon());
        result.put(app);
      } catch (JSONException e) {
        Log.e(TAG, "Invalid JSON format." + e);
      }
    }

    resultBuilder.build(code, result);
  }
コード例 #16
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
  /**
   * Install application/bundle.
   *
   * @param code - Operation code.
   * @param data - Data required(App data).
   */
  public void installAppBundle(String code, String data) {
    try {
      resultBuilder.build(code);

      if (code.equals(Constants.OPERATION_INSTALL_APPLICATION)) {
        JSONObject appData = new JSONObject(data);
        installApplication(appData, code);
      } else if (code.equals(Constants.OPERATION_INSTALL_APPLICATION_BUNDLE)) {
        JSONArray jArray = null;
        jArray = new JSONArray(data);
        for (int i = 0; i < jArray.length(); i++) {
          JSONObject appObj = (JSONObject) jArray.getJSONObject(i);
          installApplication(appObj, code);
        }
      }

    } catch (JSONException e) {
      Log.e(TAG, "Invalid JSON format." + e);
    }
  }
コード例 #17
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
  /**
   * Change device lock code.
   *
   * @param code - Operation code.
   * @param data - Data required(Lock code).
   */
  public void changeLockCode(String code, String data) {
    ComponentName demoDeviceAdmin = new ComponentName(context, AgentDeviceAdminReceiver.class);
    devicePolicyManager.setPasswordMinimumLength(demoDeviceAdmin, DEFAULT_PASSWORD_MIN_LENGTH);
    String password = null;

    try {
      JSONObject lockData = new JSONObject(data);
      if (!lockData.isNull(resources.getString(R.string.intent_extra_password))) {
        password = (String) lockData.get(resources.getString(R.string.intent_extra_password));
      }

      resultBuilder.build(code);

      if (password != null && !password.isEmpty()) {
        devicePolicyManager.resetPassword(
            password, DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY);
        devicePolicyManager.lockNow();
      }
    } catch (JSONException e) {
      Log.e(TAG, "Invalid JSON format." + e);
    }
  }
コード例 #18
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
 /**
  * Ring the device.
  *
  * @param code - Operation code.
  */
 public void ringDevice(String code) {
   resultBuilder.build(code);
   devicePolicyManager.lockNow();
 }
コード例 #19
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
  /**
   * Set device password policy.
   *
   * @param code - Operation code.
   * @param data - Data required (Password policy parameters).
   * @param requestMode - Request mode(Normal mode or policy bundle mode).
   */
  public void setPasswordPolicy(String code, String data) {
    ComponentName demoDeviceAdmin = new ComponentName(context, AgentDeviceAdminReceiver.class);

    int attempts, length, history, specialChars;
    String alphanumeric, complex;
    boolean isAlphanumeric, isComplex;
    long timout;

    resultBuilder.build(code);

    try {
      JSONObject policyData = new JSONObject(data);
      if (!policyData.isNull(resources.getString(R.string.policy_password_max_failed_attempts))
          && policyData.get(resources.getString(R.string.policy_password_max_failed_attempts))
              != null) {
        attempts =
            Integer.parseInt(
                (String)
                    policyData.get(
                        resources.getString(R.string.policy_password_max_failed_attempts)));
        devicePolicyManager.setMaximumFailedPasswordsForWipe(demoDeviceAdmin, attempts);
      }

      if (!policyData.isNull(resources.getString(R.string.policy_password_min_length))
          && policyData.get(resources.getString(R.string.policy_password_min_length)) != null) {
        length =
            Integer.parseInt(
                (String) policyData.get(resources.getString(R.string.policy_password_min_length)));
        devicePolicyManager.setPasswordMinimumLength(demoDeviceAdmin, length);
      }

      if (!policyData.isNull(resources.getString(R.string.policy_password_pin_history))
          && policyData.get(resources.getString(R.string.policy_password_pin_history)) != null) {
        history =
            Integer.parseInt(
                (String) policyData.get(resources.getString(R.string.policy_password_pin_history)));
        devicePolicyManager.setPasswordHistoryLength(demoDeviceAdmin, history);
      }

      if (!policyData.isNull(resources.getString(R.string.policy_password_min_complex_chars))
          && policyData.get(resources.getString(R.string.policy_password_min_complex_chars))
              != null) {
        specialChars =
            Integer.parseInt(
                (String)
                    policyData.get(
                        resources.getString(R.string.policy_password_min_complex_chars)));
        devicePolicyManager.setPasswordMinimumSymbols(demoDeviceAdmin, specialChars);
      }

      if (!policyData.isNull(resources.getString(R.string.policy_password_require_alphanumeric))
          && policyData.get(resources.getString(R.string.policy_password_require_alphanumeric))
              != null) {
        if (policyData.get(resources.getString(R.string.policy_password_require_alphanumeric))
            instanceof String) {
          alphanumeric =
              (String)
                  policyData.get(
                      resources.getString(R.string.policy_password_require_alphanumeric));
          if (alphanumeric.equals(resources.getString(R.string.shared_pref_default_status))) {
            devicePolicyManager.setPasswordQuality(
                demoDeviceAdmin, DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC);
          }
        } else if (policyData.get(
                resources.getString(R.string.policy_password_require_alphanumeric))
            instanceof Boolean) {
          isAlphanumeric =
              policyData.getBoolean(
                  resources.getString(R.string.policy_password_require_alphanumeric));
          if (isAlphanumeric) {
            devicePolicyManager.setPasswordQuality(
                demoDeviceAdmin, DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC);
          }
        }
      }

      if (!policyData.isNull(resources.getString(R.string.policy_password_allow_simple))
          && policyData.get(resources.getString(R.string.policy_password_allow_simple)) != null) {
        if (policyData.get(resources.getString(R.string.policy_password_allow_simple))
            instanceof String) {
          complex =
              (String) policyData.get(resources.getString(R.string.policy_password_allow_simple));
          if (!complex.equals(resources.getString(R.string.shared_pref_default_status))) {
            devicePolicyManager.setPasswordQuality(
                demoDeviceAdmin, DevicePolicyManager.PASSWORD_QUALITY_COMPLEX);
          }
        } else if (policyData.get(resources.getString(R.string.policy_password_allow_simple))
            instanceof Boolean) {
          isComplex =
              policyData.getBoolean(resources.getString(R.string.policy_password_allow_simple));
          if (!isComplex) {
            devicePolicyManager.setPasswordQuality(
                demoDeviceAdmin, DevicePolicyManager.PASSWORD_QUALITY_COMPLEX);
          }
        }
      }

      if (!policyData.isNull(resources.getString(R.string.policy_password_pin_age_in_days))
          && policyData.get(resources.getString(R.string.policy_password_pin_age_in_days))
              != null) {
        int daysOfExp =
            Integer.parseInt(
                (String)
                    policyData.get(resources.getString(R.string.policy_password_pin_age_in_days)));
        timout = (long) (daysOfExp * DAY_MILLISECONDS_MULTIPLIER);
        devicePolicyManager.setPasswordExpirationTimeout(demoDeviceAdmin, timout);
      }

    } catch (JSONException e) {
      Log.e(TAG, "Invalid JSON format." + e);
    }
  }
コード例 #20
0
ファイル: Operation.java プロジェクト: GaniduAsh/product-emm
  /**
   * Mute the device.
   *
   * @param code - Operation code.
   * @param requestMode - Request mode(Normal mode or policy bundle mode).
   */
  private void muteDevice(String code) {
    resultBuilder.build(code);

    AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    audioManager.setStreamVolume(AudioManager.STREAM_RING, DEFAULT_VOLUME, DEFAULT_FLAG);
  }