Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 09e6fcab authored by LuK1337's avatar LuK1337
Browse files

Updater: Use PowerManager instead of Intent.ACTION_REBOOT broadcast

* We are getting permission denial when sending Intent.ACTION_REBOOT
  broadcast, using pm.reboot() instead works just fine.

Change-Id: I38d0ad8cc5f4c9362fd5baf7476e14bff56616dd
parent e46f532c
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -15,11 +15,13 @@
 */
package org.lineageos.updater;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.BatteryManager;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AlertDialog;
@@ -382,8 +384,11 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
            case REBOOT: {
                button.setText(R.string.reboot);
                button.setEnabled(enabled);
                clickListener = enabled ?
                        view -> mActivity.sendBroadcast(new Intent(Intent.ACTION_REBOOT)) : null;
                clickListener = enabled ? view -> {
                    PowerManager pm =
                            (PowerManager) mActivity.getSystemService(Context.POWER_SERVICE);
                    pm.reboot(null);
                } : null;
            }
            break;
            default: