Skip to content

Commit 59350ea

Browse files
amartinzGerrit Code Review
authored andcommitted
[2/2] base: cm custom boot dexopt UI
* Pass app info and number of installed packages to boot message UI * Ui by Asher and Joey, based on Alexander's previous work Change-Id: I9ec9d0cb0e20a9bac73e126f6b6f3965400f05e7
1 parent 32265ae commit 59350ea

8 files changed

Lines changed: 60 additions & 88 deletions

File tree

core/java/android/app/ActivityManagerNative.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,11 +2097,14 @@ public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
20972097
return true;
20982098
}
20992099

2100-
case SHOW_BOOT_MESSAGE_TRANSACTION: {
2100+
case UPDATE_BOOT_PROGRESS_TRANSACTION: {
21012101
data.enforceInterface(IActivityManager.descriptor);
2102-
CharSequence msg = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
2102+
int stage = data.readInt();
2103+
ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data);
2104+
int current = data.readInt();
2105+
int total = data.readInt();
21032106
boolean always = data.readInt() != 0;
2104-
showBootMessage(msg, always);
2107+
updateBootProgress(stage, info, current, total, always);
21052108
reply.writeNoException();
21062109
return true;
21072110
}
@@ -5285,13 +5288,17 @@ public long[] getProcessPss(int[] pids) throws RemoteException {
52855288
return res;
52865289
}
52875290

5288-
public void showBootMessage(CharSequence msg, boolean always) throws RemoteException {
5291+
public void updateBootProgress(int stage, ApplicationInfo optimizedApp,
5292+
int currentAppPos, int totalAppCount, boolean always) throws RemoteException {
52895293
Parcel data = Parcel.obtain();
52905294
Parcel reply = Parcel.obtain();
52915295
data.writeInterfaceToken(IActivityManager.descriptor);
5292-
TextUtils.writeToParcel(msg, data, 0);
5296+
data.writeInt(stage);
5297+
optimizedApp.writeToParcel(data, 0);
5298+
data.writeInt(currentAppPos);
5299+
data.writeInt(totalAppCount);
52935300
data.writeInt(always ? 1 : 0);
5294-
mRemote.transact(SHOW_BOOT_MESSAGE_TRANSACTION, data, reply, 0);
5301+
mRemote.transact(UPDATE_BOOT_PROGRESS_TRANSACTION, data, reply, 0);
52955302
reply.readException();
52965303
data.recycle();
52975304
reply.recycle();

core/java/android/app/IActivityManager.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,8 @@ public void setPackageAskScreenCompat(String packageName, boolean ask)
408408

409409
public long[] getProcessPss(int[] pids) throws RemoteException;
410410

411-
public void showBootMessage(CharSequence msg, boolean always) throws RemoteException;
411+
public void updateBootProgress(int stage, ApplicationInfo optimizedApp,
412+
int currentAppPos, int totalAppCount, boolean always) throws RemoteException;
412413

413414
public void keyguardWaitingForActivityDrawn() throws RemoteException;
414415

@@ -622,6 +623,11 @@ private WaitResult(Parcel source) {
622623
}
623624
}
624625

626+
public static final int BOOT_STAGE_STARTING_APPS = 1;
627+
public static final int BOOT_STAGE_FSTRIM = 2;
628+
public static final int BOOT_STAGE_PREPARING_APPS = 3;
629+
public static final int BOOT_STAGE_COMPLETE = 4;
630+
625631
String descriptor = "android.app.IActivityManager";
626632

627633
// Please keep these transaction codes the same -- they are also
@@ -757,7 +763,7 @@ private WaitResult(Parcel source) {
757763
int IS_INTENT_SENDER_TARGETED_TO_PACKAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+134;
758764
int UPDATE_PERSISTENT_CONFIGURATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+135;
759765
int GET_PROCESS_PSS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+136;
760-
int SHOW_BOOT_MESSAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+137;
766+
int UPDATE_BOOT_PROGRESS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+137;
761767
int KILL_ALL_BACKGROUND_PROCESSES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+139;
762768
int GET_CONTENT_PROVIDER_EXTERNAL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+140;
763769
int REMOVE_CONTENT_PROVIDER_EXTERNAL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+141;

core/java/android/view/WindowManagerPolicy.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import android.annotation.SystemApi;
2121
import android.content.Context;
2222
import android.content.pm.ActivityInfo;
23+
import android.content.pm.ApplicationInfo;
2324
import android.content.res.CompatibilityInfo;
2425
import android.content.res.Configuration;
2526
import android.graphics.Rect;
@@ -1171,9 +1172,10 @@ public boolean rotationHasCompatibleMetricsLw(@ActivityInfo.ScreenOrientation in
11711172
public void systemBooted();
11721173

11731174
/**
1174-
* Show boot time message to the user.
1175+
* Update UI for boot-up progress.
11751176
*/
1176-
public void showBootMessage(final CharSequence msg, final boolean always);
1177+
public void updateBootProgress(final int stage, final ApplicationInfo optimizedApp,
1178+
final int currentAppPos, final int totalAppCount);
11771179

11781180
/**
11791181
* Hide the UI for showing boot messages, never to be displayed again.

services/core/java/com/android/server/am/ActivityManagerService.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import android.app.BroadcastOptions;
4545
import android.app.IActivityContainer;
4646
import android.app.IActivityContainerCallback;
47+
import android.app.IActivityManager;
4748
import android.app.IAppTask;
4849
import android.app.ITaskStackListener;
4950
import android.app.ProfilerInfo;
@@ -6558,12 +6559,14 @@ void enableScreenAfterBoot() {
65586559
}
65596560

65606561
@Override
6561-
public void showBootMessage(final CharSequence msg, final boolean always) {
6562+
public void updateBootProgress(final int stage, final ApplicationInfo optimizedApp,
6563+
final int currentAppPos, final int totalAppCount, final boolean always) {
65626564
if (Binder.getCallingUid() != Process.myUid()) {
65636565
// These days only the core system can call this, so apps can't get in
65646566
// the way of what we show about running them.
65656567
}
6566-
mWindowManager.showBootMessage(msg, always);
6568+
mWindowManager.updateBootProgress(stage, optimizedApp,
6569+
currentAppPos, totalAppCount, always);
65676570
}
65686571

65696572
@Override
@@ -11985,8 +11988,8 @@ void go() {
1198511988
intent.setComponent(comp);
1198611989
doneReceivers.add(comp);
1198711990
lastRi = curRi;
11988-
CharSequence label = ai.loadLabel(mContext.getPackageManager());
11989-
showBootMessage(mContext.getString(R.string.android_preparing_apk, label), false);
11991+
updateBootProgress(IActivityManager.BOOT_STAGE_PREPARING_APPS,
11992+
ai.applicationInfo, 0, 0, false);
1199011993
}
1199111994
Slog.i(TAG, "Pre-boot of " + intent.getComponent().toShortString()
1199211995
+ " for user " + users[curUser]);
@@ -12109,9 +12112,8 @@ public void run() {
1210912112
synchronized (ActivityManagerService.this) {
1211012113
mDidUpdate = true;
1211112114
}
12112-
showBootMessage(mContext.getText(
12113-
R.string.android_upgrading_complete),
12114-
false);
12115+
updateBootProgress(IActivityManager.BOOT_STAGE_COMPLETE,
12116+
null, 0, 0, false);
1211512117
writeLastDonePreBootReceivers(doneReceivers);
1211612118
systemReady(goingCallback);
1211712119
}

services/core/java/com/android/server/pm/PackageManagerService.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6364,9 +6364,8 @@ public void performBootDexOpt() {
63646364
if (doTrim) {
63656365
if (!isFirstBoot()) {
63666366
try {
6367-
ActivityManagerNative.getDefault().showBootMessage(
6368-
mContext.getResources().getString(
6369-
R.string.android_upgrading_fstrim), true);
6367+
ActivityManagerNative.getDefault().updateBootProgress(
6368+
IActivityManager.BOOT_STAGE_FSTRIM, null, 0, 0, true);
63706369
} catch (RemoteException e) {
63716370
}
63726371
}
@@ -6493,9 +6492,9 @@ private void performBootDexOpt(PackageParser.Package pkg, int curr, int total) {
64936492
Log.i(TAG, "Optimizing app " + curr + " of " + total + ": " + pkg.packageName);
64946493
}
64956494
try {
6496-
ActivityManagerNative.getDefault().showBootMessage(
6497-
mContext.getResources().getString(R.string.android_upgrading_apk,
6498-
curr, total), true);
6495+
ActivityManagerNative.getDefault().updateBootProgress(
6496+
IActivityManager.BOOT_STAGE_PREPARING_APPS,
6497+
pkg.applicationInfo, curr, total, true);
64996498
} catch (RemoteException e) {
65006499
}
65016500
PackageParser.Package p = pkg;

services/core/java/com/android/server/policy/PhoneWindowManager.java

Lines changed: 9 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import android.app.ActivityManagerNative;
2323
import android.app.AppOpsManager;
2424
import android.app.IUiModeManager;
25-
import android.app.KeyguardManager;
26-
import android.app.ProgressDialog;
2725
import android.app.SearchManager;
2826
import android.app.StatusBarManager;
2927
import android.app.UiModeManager;
@@ -37,6 +35,7 @@
3735
import android.content.IntentFilter;
3836
import android.content.ServiceConnection;
3937
import android.content.pm.ActivityInfo;
38+
import android.content.pm.ApplicationInfo;
4039
import android.content.pm.PackageManager;
4140
import android.content.pm.ResolveInfo;
4241
import android.content.res.CompatibilityInfo;
@@ -138,6 +137,8 @@
138137
import com.android.server.policy.keyguard.KeyguardServiceDelegate;
139138
import com.android.server.policy.keyguard.KeyguardServiceDelegate.DrawnListener;
140139

140+
import org.cyanogenmod.internal.BootDexoptDialog;
141+
141142
import java.io.File;
142143
import java.io.FileReader;
143144
import java.io.IOException;
@@ -7014,68 +7015,18 @@ public void systemBooted() {
70147015
screenTurnedOn();
70157016
}
70167017

7017-
ProgressDialog mBootMsgDialog = null;
7018+
BootDexoptDialog mBootMsgDialog = null;
70187019

70197020
/** {@inheritDoc} */
70207021
@Override
7021-
public void showBootMessage(final CharSequence msg, final boolean always) {
7022+
public void updateBootProgress(final int stage, final ApplicationInfo optimizedApp,
7023+
final int currentAppPos, final int totalAppCount) {
70227024
mHandler.post(new Runnable() {
70237025
@Override public void run() {
70247026
if (mBootMsgDialog == null) {
7025-
int theme;
7026-
if (mContext.getPackageManager().hasSystemFeature(
7027-
PackageManager.FEATURE_WATCH)) {
7028-
theme = com.android.internal.R.style.Theme_Micro_Dialog_Alert;
7029-
} else if (mContext.getPackageManager().hasSystemFeature(
7030-
PackageManager.FEATURE_TELEVISION)) {
7031-
theme = com.android.internal.R.style.Theme_Leanback_Dialog_Alert;
7032-
} else {
7033-
theme = 0;
7034-
}
7035-
7036-
mBootMsgDialog = new ProgressDialog(mContext, theme) {
7037-
// This dialog will consume all events coming in to
7038-
// it, to avoid it trying to do things too early in boot.
7039-
@Override public boolean dispatchKeyEvent(KeyEvent event) {
7040-
return true;
7041-
}
7042-
@Override public boolean dispatchKeyShortcutEvent(KeyEvent event) {
7043-
return true;
7044-
}
7045-
@Override public boolean dispatchTouchEvent(MotionEvent ev) {
7046-
return true;
7047-
}
7048-
@Override public boolean dispatchTrackballEvent(MotionEvent ev) {
7049-
return true;
7050-
}
7051-
@Override public boolean dispatchGenericMotionEvent(MotionEvent ev) {
7052-
return true;
7053-
}
7054-
@Override public boolean dispatchPopulateAccessibilityEvent(
7055-
AccessibilityEvent event) {
7056-
return true;
7057-
}
7058-
};
7059-
if (mContext.getPackageManager().isUpgrade()) {
7060-
mBootMsgDialog.setTitle(R.string.android_upgrading_title);
7061-
} else {
7062-
mBootMsgDialog.setTitle(R.string.android_start_title);
7063-
}
7064-
mBootMsgDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
7065-
mBootMsgDialog.setIndeterminate(true);
7066-
mBootMsgDialog.getWindow().setType(
7067-
WindowManager.LayoutParams.TYPE_BOOT_PROGRESS);
7068-
mBootMsgDialog.getWindow().addFlags(
7069-
WindowManager.LayoutParams.FLAG_DIM_BEHIND
7070-
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
7071-
mBootMsgDialog.getWindow().setDimAmount(1);
7072-
WindowManager.LayoutParams lp = mBootMsgDialog.getWindow().getAttributes();
7073-
lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
7074-
mBootMsgDialog.getWindow().setAttributes(lp);
7075-
mBootMsgDialog.setCancelable(false);
7076-
mBootMsgDialog.show();
7077-
}
7078-
mBootMsgDialog.setMessage(msg);
7027+
mBootMsgDialog = BootDexoptDialog.create(mContext);
7028+
}
7029+
mBootMsgDialog.setProgress(stage, optimizedApp, currentAppPos, totalAppCount);
70797030
}
70807031
});
70817032
}

services/core/java/com/android/server/wm/WindowManagerService.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import android.content.Intent;
3030
import android.content.IntentFilter;
3131
import android.content.pm.ActivityInfo;
32+
import android.content.pm.ApplicationInfo;
3233
import android.content.pm.PackageManager;
3334
import android.content.res.CompatibilityInfo;
3435
import android.content.res.Configuration;
@@ -5959,13 +5960,18 @@ private boolean checkBootAnimationCompleteLocked() {
59595960
return true;
59605961
}
59615962

5962-
public void showBootMessage(final CharSequence msg, final boolean always) {
5963+
public void updateBootProgress(final int stage, final ApplicationInfo optimizedApp,
5964+
final int currentAppPos, final int totalAppCount, final boolean always) {
59635965
boolean first = false;
59645966
synchronized(mWindowMap) {
59655967
if (DEBUG_BOOT) {
59665968
RuntimeException here = new RuntimeException("here");
59675969
here.fillInStackTrace();
5968-
Slog.i(TAG, "showBootMessage: msg=" + msg + " always=" + always
5970+
Slog.i(TAG, "updateBootProgress: stage=" + stage
5971+
+ " optimizedApp=" + optimizedApp
5972+
+ " currentAppPos=" + currentAppPos
5973+
+ " totalAppCount=" + totalAppCount
5974+
+ " always=" + always
59695975
+ " mAllowBootMessages=" + mAllowBootMessages
59705976
+ " mShowingBootMessages=" + mShowingBootMessages
59715977
+ " mSystemBooted=" + mSystemBooted, here);
@@ -5983,7 +5989,7 @@ public void showBootMessage(final CharSequence msg, final boolean always) {
59835989
return;
59845990
}
59855991
mShowingBootMessages = true;
5986-
mPolicy.showBootMessage(msg, always);
5992+
mPolicy.updateBootProgress(stage, optimizedApp, currentAppPos, totalAppCount);
59875993
}
59885994
if (first) {
59895995
performEnableScreen();

services/java/com/android/server/SystemServer.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import android.app.ActivityManagerNative;
2020
import android.app.ActivityThread;
21+
import android.app.IActivityManager;
2122
import android.app.IAlarmManager;
2223
import android.app.INotificationManager;
2324
import android.app.usage.UsageStatsManagerInternal;
@@ -620,10 +621,8 @@ private void startOtherServices() {
620621
}
621622

622623
try {
623-
ActivityManagerNative.getDefault().showBootMessage(
624-
context.getResources().getText(
625-
com.android.internal.R.string.android_upgrading_starting_apps),
626-
false);
624+
ActivityManagerNative.getDefault().updateBootProgress(
625+
IActivityManager.BOOT_STAGE_STARTING_APPS, null, 0, 0, false);
627626
} catch (RemoteException e) {
628627
}
629628

0 commit comments

Comments
 (0)