Merge "Show indeterminate progess when installing." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2775c48d14
@@ -65,7 +65,8 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="8dp"
|
android:paddingTop="8dp"
|
||||||
style="?android:attr/progressBarStyleHorizontal" />
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
android:indeterminate="true" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import android.os.Bundle;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ProgressBar;
|
|
||||||
|
|
||||||
import com.android.internal.app.AlertActivity;
|
import com.android.internal.app.AlertActivity;
|
||||||
import com.android.internal.content.PackageHelper;
|
import com.android.internal.content.PackageHelper;
|
||||||
@@ -61,9 +60,6 @@ public class InstallInstalling extends AlertActivity {
|
|||||||
private static final String BROADCAST_ACTION =
|
private static final String BROADCAST_ACTION =
|
||||||
"com.android.packageinstaller.ACTION_INSTALL_COMMIT";
|
"com.android.packageinstaller.ACTION_INSTALL_COMMIT";
|
||||||
|
|
||||||
/** Listens to changed to the session and updates progress bar */
|
|
||||||
private PackageInstaller.SessionCallback mSessionCallback;
|
|
||||||
|
|
||||||
/** Task that sends the package to the package installer */
|
/** Task that sends the package to the package installer */
|
||||||
private InstallingAsyncTask mInstallingTask;
|
private InstallingAsyncTask mInstallingTask;
|
||||||
|
|
||||||
@@ -185,8 +181,6 @@ public class InstallInstalling extends AlertActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mCancelButton = mAlert.getButton(DialogInterface.BUTTON_NEGATIVE);
|
mCancelButton = mAlert.getButton(DialogInterface.BUTTON_NEGATIVE);
|
||||||
|
|
||||||
mSessionCallback = new InstallSessionCallback();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,13 +215,6 @@ public class InstallInstalling extends AlertActivity {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
|
|
||||||
getPackageManager().getPackageInstaller().registerSessionCallback(mSessionCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -263,13 +250,6 @@ public class InstallInstalling extends AlertActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop() {
|
|
||||||
super.onStop();
|
|
||||||
|
|
||||||
getPackageManager().getPackageInstaller().unregisterSessionCallback(mSessionCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
if (mInstallingTask != null) {
|
if (mInstallingTask != null) {
|
||||||
@@ -306,38 +286,6 @@ public class InstallInstalling extends AlertActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class InstallSessionCallback extends PackageInstaller.SessionCallback {
|
|
||||||
@Override
|
|
||||||
public void onCreated(int sessionId) {
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBadgingChanged(int sessionId) {
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActiveChanged(int sessionId, boolean active) {
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProgressChanged(int sessionId, float progress) {
|
|
||||||
if (sessionId == mSessionId) {
|
|
||||||
ProgressBar progressBar = requireViewById(R.id.progress);
|
|
||||||
progressBar.setMax(Integer.MAX_VALUE);
|
|
||||||
progressBar.setProgress((int) (Integer.MAX_VALUE * progress));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFinished(int sessionId, boolean success) {
|
|
||||||
// empty, finish is handled by InstallResultReceiver
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the package to the package installer and then register a event result observer that
|
* Send the package to the package installer and then register a event result observer that
|
||||||
* will call {@link #launchFinishBasedOnResult(int, int, String)}
|
* will call {@link #launchFinishBasedOnResult(int, int, String)}
|
||||||
|
|||||||
Reference in New Issue
Block a user