Commit 09e6fcab authored by LuK1337's avatar LuK1337

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
......@@ -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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment