Loading packages/DynamicAndroidInstallationService/src/com/android/dynandroid/DynamicAndroidInstallationService.java +7 −4 Original line number Diff line number Diff line Loading @@ -114,6 +114,7 @@ public class DynamicAndroidInstallationService extends Service private NotificationManager mNM; private long mSystemSize; private long mUserdataSize; private long mInstalledSize; private boolean mJustCancelledByUser; Loading Loading @@ -220,9 +221,11 @@ public class DynamicAndroidInstallationService extends Service String url = intent.getStringExtra(DynamicAndroidClient.KEY_SYSTEM_URL); mSystemSize = intent.getLongExtra(DynamicAndroidClient.KEY_SYSTEM_SIZE, 0); long userdata = intent.getLongExtra(DynamicAndroidClient.KEY_USERDATA_SIZE, 0); mUserdataSize = intent.getLongExtra(DynamicAndroidClient.KEY_USERDATA_SIZE, 0); mInstallTask = new InstallationAsyncTask( url, mSystemSize, mUserdataSize, mDynAndroid, this); mInstallTask = new InstallationAsyncTask(url, mSystemSize, userdata, mDynAndroid, this); mInstallTask.execute(); // start fore ground Loading Loading @@ -332,8 +335,8 @@ public class DynamicAndroidInstallationService extends Service case STATUS_IN_PROGRESS: builder.setContentText(getString(R.string.notification_install_inprogress)); int max = (int) Math.max(mSystemSize >> 20, 1); int progress = (int) mInstalledSize >> 20; int max = (int) Math.max((mSystemSize + mUserdataSize) >> 20, 1); int progress = (int) (mInstalledSize >> 20); builder.setProgress(max, progress, false); Loading packages/DynamicAndroidInstallationService/src/com/android/dynandroid/InstallationAsyncTask.java +40 −10 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.dynandroid; import android.gsi.GsiProgress; import android.os.AsyncTask; import android.os.DynamicAndroidManager; import android.util.Log; Loading Loading @@ -63,8 +64,6 @@ class InstallationAsyncTask extends AsyncTask<String, Long, Integer> { private final InstallStatusListener mListener; private DynamicAndroidManager.Session mInstallationSession; private long mInstalledSize; private long mReportedInstalledSize; private int mResult = NO_RESULT; private InputStream mStream; Loading @@ -89,8 +88,40 @@ class InstallationAsyncTask extends AsyncTask<String, Long, Integer> { Log.d(TAG, "Start doInBackground(), URL: " + mUrl); try { // call start in background mInstallationSession = mDynamicAndroid.startInstallation(mSystemSize, mUserdataSize); long installedSize = 0; long reportedInstalledSize = 0; long minStepToReport = (mSystemSize + mUserdataSize) / 100; // init input stream before calling startInstallation(), which takes 90 seconds. initInputStream(); Thread thread = new Thread(() -> { mInstallationSession = mDynamicAndroid.startInstallation(mSystemSize, mUserdataSize); }); thread.start(); while (thread.isAlive()) { if (isCancelled()) { boolean aborted = mDynamicAndroid.abort(); Log.d(TAG, "Called DynamicAndroidManager.abort(), result = " + aborted); return RESULT_OK; } GsiProgress progress = mDynamicAndroid.getInstallationProgress(); installedSize = progress.bytes_processed; if (installedSize > reportedInstalledSize + minStepToReport) { publishProgress(installedSize); reportedInstalledSize = installedSize; } Thread.sleep(10); } if (mInstallationSession == null) { Log.e(TAG, "Failed to start installation with requested size: " Loading @@ -99,12 +130,11 @@ class InstallationAsyncTask extends AsyncTask<String, Long, Integer> { return RESULT_ERROR_IO; } initInputStream(); installedSize = mUserdataSize; byte[] bytes = new byte[READ_BUFFER_SIZE]; int numBytesRead; long minStepToReport = mSystemSize / 100; Log.d(TAG, "Start installation loop"); while ((numBytesRead = mStream.read(bytes, 0, READ_BUFFER_SIZE)) != -1) { Loading @@ -119,11 +149,11 @@ class InstallationAsyncTask extends AsyncTask<String, Long, Integer> { throw new IOException("Failed write() to DynamicAndroid"); } mInstalledSize += numBytesRead; installedSize += numBytesRead; if (mInstalledSize > mReportedInstalledSize + minStepToReport) { publishProgress(mInstalledSize); mReportedInstalledSize = mInstalledSize; if (installedSize > reportedInstalledSize + minStepToReport) { publishProgress(installedSize); reportedInstalledSize = installedSize; } } Loading Loading
packages/DynamicAndroidInstallationService/src/com/android/dynandroid/DynamicAndroidInstallationService.java +7 −4 Original line number Diff line number Diff line Loading @@ -114,6 +114,7 @@ public class DynamicAndroidInstallationService extends Service private NotificationManager mNM; private long mSystemSize; private long mUserdataSize; private long mInstalledSize; private boolean mJustCancelledByUser; Loading Loading @@ -220,9 +221,11 @@ public class DynamicAndroidInstallationService extends Service String url = intent.getStringExtra(DynamicAndroidClient.KEY_SYSTEM_URL); mSystemSize = intent.getLongExtra(DynamicAndroidClient.KEY_SYSTEM_SIZE, 0); long userdata = intent.getLongExtra(DynamicAndroidClient.KEY_USERDATA_SIZE, 0); mUserdataSize = intent.getLongExtra(DynamicAndroidClient.KEY_USERDATA_SIZE, 0); mInstallTask = new InstallationAsyncTask( url, mSystemSize, mUserdataSize, mDynAndroid, this); mInstallTask = new InstallationAsyncTask(url, mSystemSize, userdata, mDynAndroid, this); mInstallTask.execute(); // start fore ground Loading Loading @@ -332,8 +335,8 @@ public class DynamicAndroidInstallationService extends Service case STATUS_IN_PROGRESS: builder.setContentText(getString(R.string.notification_install_inprogress)); int max = (int) Math.max(mSystemSize >> 20, 1); int progress = (int) mInstalledSize >> 20; int max = (int) Math.max((mSystemSize + mUserdataSize) >> 20, 1); int progress = (int) (mInstalledSize >> 20); builder.setProgress(max, progress, false); Loading
packages/DynamicAndroidInstallationService/src/com/android/dynandroid/InstallationAsyncTask.java +40 −10 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.dynandroid; import android.gsi.GsiProgress; import android.os.AsyncTask; import android.os.DynamicAndroidManager; import android.util.Log; Loading Loading @@ -63,8 +64,6 @@ class InstallationAsyncTask extends AsyncTask<String, Long, Integer> { private final InstallStatusListener mListener; private DynamicAndroidManager.Session mInstallationSession; private long mInstalledSize; private long mReportedInstalledSize; private int mResult = NO_RESULT; private InputStream mStream; Loading @@ -89,8 +88,40 @@ class InstallationAsyncTask extends AsyncTask<String, Long, Integer> { Log.d(TAG, "Start doInBackground(), URL: " + mUrl); try { // call start in background mInstallationSession = mDynamicAndroid.startInstallation(mSystemSize, mUserdataSize); long installedSize = 0; long reportedInstalledSize = 0; long minStepToReport = (mSystemSize + mUserdataSize) / 100; // init input stream before calling startInstallation(), which takes 90 seconds. initInputStream(); Thread thread = new Thread(() -> { mInstallationSession = mDynamicAndroid.startInstallation(mSystemSize, mUserdataSize); }); thread.start(); while (thread.isAlive()) { if (isCancelled()) { boolean aborted = mDynamicAndroid.abort(); Log.d(TAG, "Called DynamicAndroidManager.abort(), result = " + aborted); return RESULT_OK; } GsiProgress progress = mDynamicAndroid.getInstallationProgress(); installedSize = progress.bytes_processed; if (installedSize > reportedInstalledSize + minStepToReport) { publishProgress(installedSize); reportedInstalledSize = installedSize; } Thread.sleep(10); } if (mInstallationSession == null) { Log.e(TAG, "Failed to start installation with requested size: " Loading @@ -99,12 +130,11 @@ class InstallationAsyncTask extends AsyncTask<String, Long, Integer> { return RESULT_ERROR_IO; } initInputStream(); installedSize = mUserdataSize; byte[] bytes = new byte[READ_BUFFER_SIZE]; int numBytesRead; long minStepToReport = mSystemSize / 100; Log.d(TAG, "Start installation loop"); while ((numBytesRead = mStream.read(bytes, 0, READ_BUFFER_SIZE)) != -1) { Loading @@ -119,11 +149,11 @@ class InstallationAsyncTask extends AsyncTask<String, Long, Integer> { throw new IOException("Failed write() to DynamicAndroid"); } mInstalledSize += numBytesRead; installedSize += numBytesRead; if (mInstalledSize > mReportedInstalledSize + minStepToReport) { publishProgress(mInstalledSize); mReportedInstalledSize = mInstalledSize; if (installedSize > reportedInstalledSize + minStepToReport) { publishProgress(installedSize); reportedInstalledSize = installedSize; } } Loading