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