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
This commit is contained in:
@@ -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:
|
||||
|
Reference in New Issue
Block a user