OpenDelta: Never crash on a/b perf mode set failure
This can fail for all kinds of reasons, especially for kernel / device side failures or lack of support Let's not crash for it and let the user know via a toast
This commit is contained in:
parent
9f6e0b7df1
commit
a6b0305d09
|
@ -135,6 +135,7 @@
|
|||
<string name="progress_status_9">Disabled.</string>
|
||||
<string name="ab_perf_mode_title">AB performance mode</string>
|
||||
<string name="ab_perf_mode_summary_new">Increase priority of the update process. Might influence normal usage when an update is in progress.</string>
|
||||
<string name="ab_perf_mode_error">Error setting performance mode\nCheck the logs</string>
|
||||
<string name="ab_wake_lock_title">AB wake lock</string>
|
||||
<string name="ab_wake_lock_summary">Keep the CPU awake when installing an update. Makes updating fast even if the screen is off</string>
|
||||
<string name="state_error_flash_file_title">Couldn\'t flash that file</string>
|
||||
|
|
|
@ -15,10 +15,13 @@
|
|||
*/
|
||||
package eu.chainfire.opendelta;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.PowerManager.WakeLock;
|
||||
import android.os.ServiceSpecificException;
|
||||
import android.os.UpdateEngine;
|
||||
import android.os.UpdateEngineCallback;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
@ -242,7 +245,20 @@ class ABUpdate {
|
|||
return ERROR_CORRUPTED;
|
||||
}
|
||||
|
||||
mUpdateEngine.setPerformanceMode(mEnableABPerfMode);
|
||||
try {
|
||||
mUpdateEngine.setPerformanceMode(mEnableABPerfMode);
|
||||
} catch (ServiceSpecificException e) {
|
||||
Log.e(TAG, "Could not set performance mode, Earlier logs should point the reason. Trace:");
|
||||
e.printStackTrace();
|
||||
final Context context = mUpdateService.getApplicationContext();
|
||||
if (context != null) {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.ab_perf_mode_error),
|
||||
Toast.LENGTH_LONG
|
||||
).show();
|
||||
}
|
||||
}
|
||||
if (!bindCallbacks()) return ERROR_NOT_READY;
|
||||
String zipFileUri = "file://" + file.getAbsolutePath();
|
||||
mUpdateEngine.applyPayload(zipFileUri, offset, 0, headerKeyValuePairs);
|
||||
|
|
Loading…
Reference in New Issue