コード例 #1
0
 private void dismissKeyguardOnNextActivity() {
   try {
     WindowManagerGlobal.getWindowManagerService().dismissKeyguard();
   } catch (RemoteException e) {
     Log.w(TAG, "Error dismissing keyguard", e);
   }
 }
コード例 #2
0
 private void showBugreportDialog() {
   final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
   builder.setPositiveButton(
       com.android.internal.R.string.report,
       new OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
           if (which == DialogInterface.BUTTON_POSITIVE) {
             // Add a little delay before executing, to give the
             // dialog a chance to go away before it takes a
             // screenshot.
             mHandler.postDelayed(
                 new Runnable() {
                   @Override
                   public void run() {
                     try {
                       ActivityManagerNative.getDefault().requestBugReport();
                     } catch (RemoteException e) {
                     }
                   }
                 },
                 500);
           }
         }
       });
   builder.setMessage(com.android.internal.R.string.bugreport_message);
   builder.setTitle(com.android.internal.R.string.bugreport_title);
   builder.setCancelable(true);
   final Dialog dialog = builder.create();
   dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
   try {
     WindowManagerGlobal.getWindowManagerService().dismissKeyguard();
   } catch (RemoteException e) {
   }
   dialog.show();
 }
コード例 #3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.prefs_powermenu);
    /*
    mShowPowerSaver = (CheckBoxPreference) findPreference(PREF_POWER_SAVER);
    int powerSaverVal = 0;
    try {
        powerSaverVal = Settings.Secure.getInt(mContentRes,
         Settings.Secure.POWER_SAVER_MODE);
    } catch (SettingNotFoundException e) {
        mShowPowerSaver.setEnabled(false);
        mShowPowerSaver
                .setSummary("You need to enable power saver before you can see it in the power menu.");
    }
    mShowPowerSaver.setChecked(powerSaverVal != 0); */

    mShowTorchToggle = (CheckBoxPreference) findPreference(PREF_TORCH_TOGGLE);
    mShowTorchToggle.setChecked(
        Settings.System.getBoolean(
            mContentRes, Settings.System.POWER_DIALOG_SHOW_TORCH_TOGGLE, false));

    mShowScreenShot = (CheckBoxPreference) findPreference(PREF_SCREENSHOT);
    mShowScreenShot.setChecked(
        Settings.System.getBoolean(
            mContentRes, Settings.System.POWER_DIALOG_SHOW_SCREENSHOT, true));

    mShowAirplaneToggle = (CheckBoxPreference) findPreference(PREF_AIRPLANE_TOGGLE);
    mShowAirplaneToggle.setChecked(
        Settings.System.getBoolean(
            mContentRes, Settings.System.POWER_DIALOG_SHOW_AIRPLANE_TOGGLE, false));

    mShowNavBarHide = (CheckBoxPreference) findPreference(PREF_NAVBAR_HIDE);
    mShowNavBarHide.setChecked(
        Settings.System.getBoolean(
            mContentRes, Settings.System.POWER_DIALOG_SHOW_NAVBAR_HIDE, false));

    mShowVolumeStateToggle = (CheckBoxPreference) findPreference(PREF_VOLUME_STATE_TOGGLE);
    mShowVolumeStateToggle.setChecked(
        Settings.System.getBoolean(
            mContentRes, Settings.System.POWER_DIALOG_SHOW_VOLUME_STATE_TOGGLE, true));

    mShowRebootKeyguard = (CheckBoxPreference) findPreference(PREF_REBOOT_KEYGUARD);
    mShowRebootKeyguard.setChecked(
        Settings.System.getBoolean(
            mContentRes, Settings.System.POWER_DIALOG_SHOW_REBOOT_KEYGUARD, true));

    PreferenceScreen prefSet = getPreferenceScreen();
    mExpandedDesktopPref = (ListPreference) prefSet.findPreference(KEY_EXPANDED_DESKTOP);
    mExpandedDesktopNoNavbarPref =
        (CheckBoxPreference) findPreference(KEY_EXPANDED_DESKTOP_NO_NAVBAR);

    int expandedDesktopValue =
        Settings.System.getInt(getContentResolver(), Settings.System.EXPANDED_DESKTOP_STYLE, 0);

    // Hide no-op "Status bar visible" mode on devices without navbar
    try {
      if (WindowManagerGlobal.getWindowManagerService().hasNavigationBar()) {
        mExpandedDesktopPref.setOnPreferenceChangeListener(this);
        mExpandedDesktopPref.setValue(String.valueOf(expandedDesktopValue));
        updateExpandedDesktop(expandedDesktopValue);

        prefSet.removePreference(mExpandedDesktopNoNavbarPref);
      } else {
        mExpandedDesktopNoNavbarPref.setChecked(expandedDesktopValue > 0);

        prefSet.removePreference(mExpandedDesktopPref);
      }
    } catch (RemoteException e) {
      Log.e(TAG, "Error getting navigation bar status");
    }
  }