Skip to content

Commit ec6e01a

Browse files
amartinztemasek
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 Conflicts: services/core/java/com/android/server/policy/PhoneWindowManager.java
1 parent 5d304b2 commit ec6e01a

File tree

8 files changed

+60
-87
lines changed

8 files changed

+60
-87
lines changed

core/java/android/app/ActivityManagerNative.java

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

2110-
case SHOW_BOOT_MESSAGE_TRANSACTION: {
2110+
case UPDATE_BOOT_PROGRESS_TRANSACTION: {
21112111
data.enforceInterface(IActivityManager.descriptor);
2112-
CharSequence msg = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
2112+
int stage = data.readInt();
2113+
ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data);
2114+
int current = data.readInt();
2115+
int total = data.readInt();
21132116
boolean always = data.readInt() != 0;
2114-
showBootMessage(msg, always);
2117+
updateBootProgress(stage, info, current, total, always);
21152118
reply.writeNoException();
21162119
return true;
21172120
}
@@ -5310,13 +5313,17 @@ public long[] getProcessPss(int[] pids) throws RemoteException {
53105313
return res;
53115314
}
53125315

5313-
public void showBootMessage(CharSequence msg, boolean always) throws RemoteException {
5316+
public void updateBootProgress(int stage, ApplicationInfo optimizedApp,
5317+
int currentAppPos, int totalAppCount, boolean always) throws RemoteException {
53145318
Parcel data = Parcel.obtain();
53155319
Parcel reply = Parcel.obtain();
53165320
data.writeInterfaceToken(IActivityManager.descriptor);
5317-
TextUtils.writeToParcel(msg, data, 0);
5321+
data.writeInt(stage);
5322+
optimizedApp.writeToParcel(data, 0);
5323+
data.writeInt(currentAppPos);
5324+
data.writeInt(totalAppCount);
53185325
data.writeInt(always ? 1 : 0);
5319-
mRemote.transact(SHOW_BOOT_MESSAGE_TRANSACTION, data, reply, 0);
5326+
mRemote.transact(UPDATE_BOOT_PROGRESS_TRANSACTION, data, reply, 0);
53205327
reply.readException();
53215328
data.recycle();
53225329
reply.recycle();

core/java/android/app/IActivityManager.java

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

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

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

414415
public void keyguardWaitingForActivityDrawn() throws RemoteException;
415416

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

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

628634
// Please keep these transaction codes the same -- they are also
@@ -758,7 +764,7 @@ private WaitResult(Parcel source) {
758764
int IS_INTENT_SENDER_TARGETED_TO_PACKAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+134;
759765
int UPDATE_PERSISTENT_CONFIGURATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+135;
760766
int GET_PROCESS_PSS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+136;
761-
int SHOW_BOOT_MESSAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+137;
767+
int UPDATE_BOOT_PROGRESS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+137;
762768
int KILL_ALL_BACKGROUND_PROCESSES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+139;
763769
int GET_CONTENT_PROVIDER_EXTERNAL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+140;
764770
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;
@@ -6567,12 +6568,14 @@ void enableScreenAfterBoot() {
65676568
}
65686569

65696570
@Override
6570-
public void showBootMessage(final CharSequence msg, final boolean always) {
6571+
public void updateBootProgress(final int stage, final ApplicationInfo optimizedApp,
6572+
final int currentAppPos, final int totalAppCount, final boolean always) {
65716573
if (Binder.getCallingUid() != Process.myUid()) {
65726574
// These days only the core system can call this, so apps can't get in
65736575
// the way of what we show about running them.
65746576
}
6575-
mWindowManager.showBootMessage(msg, always);
6577+
mWindowManager.updateBootProgress(stage, optimizedApp,
6578+
currentAppPos, totalAppCount, always);
65766579
}
65776580

65786581
@Override
@@ -12015,8 +12018,8 @@ void go() {
1201512018
intent.setComponent(comp);
1201612019
doneReceivers.add(comp);
1201712020
lastRi = curRi;
12018-
CharSequence label = ai.loadLabel(mContext.getPackageManager());
12019-
showBootMessage(mContext.getString(R.string.android_preparing_apk, label), false);
12021+
updateBootProgress(IActivityManager.BOOT_STAGE_PREPARING_APPS,
12022+
ai.applicationInfo, 0, 0, false);
1202012023
}
1202112024
Slog.i(TAG, "Pre-boot of " + intent.getComponent().toShortString()
1202212025
+ " for user " + users[curUser]);
@@ -12139,9 +12142,8 @@ public void run() {
1213912142
synchronized (ActivityManagerService.this) {
1214012143
mDidUpdate = true;
1214112144
}
12142-
showBootMessage(mContext.getText(
12143-
R.string.android_upgrading_complete),
12144-
false);
12145+
updateBootProgress(IActivityManager.BOOT_STAGE_COMPLETE,
12146+
null, 0, 0, false);
1214512147
writeLastDonePreBootReceivers(doneReceivers);
1214612148
systemReady(goingCallback);
1214712149
}

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6391,9 +6391,8 @@ public void performBootDexOpt() {
63916391
if (doTrim) {
63926392
if (!isFirstBoot()) {
63936393
try {
6394-
ActivityManagerNative.getDefault().showBootMessage(
6395-
mContext.getResources().getString(
6396-
R.string.android_upgrading_fstrim), true);
6394+
ActivityManagerNative.getDefault().updateBootProgress(
6395+
IActivityManager.BOOT_STAGE_FSTRIM, null, 0, 0, true);
63976396
} catch (RemoteException e) {
63986397
}
63996398
}
@@ -6520,9 +6519,9 @@ private void performBootDexOpt(PackageParser.Package pkg, int curr, int total) {
65206519
Log.i(TAG, "Optimizing app " + curr + " of " + total + ": " + pkg.packageName);
65216520
}
65226521
try {
6523-
ActivityManagerNative.getDefault().showBootMessage(
6524-
mContext.getResources().getString(R.string.android_upgrading_apk,
6525-
curr, total), true);
6522+
ActivityManagerNative.getDefault().updateBootProgress(
6523+
IActivityManager.BOOT_STAGE_PREPARING_APPS,
6524+
pkg.applicationInfo, curr, total, true);
65266525
} catch (RemoteException e) {
65276526
}
65286527
PackageParser.Package p = pkg;

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

Lines changed: 9 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import android.app.ActivityManagerNative;
2323
import android.app.AppOpsManager;
2424
import android.app.IUiModeManager;
25-
import android.app.ProgressDialog;
2625
import android.app.SearchManager;
2726
import android.app.StatusBarManager;
2827
import android.app.UiModeManager;
@@ -36,6 +35,7 @@
3635
import android.content.IntentFilter;
3736
import android.content.ServiceConnection;
3837
import android.content.pm.ActivityInfo;
38+
import android.content.pm.ApplicationInfo;
3939
import android.content.pm.PackageManager;
4040
import android.content.pm.ResolveInfo;
4141
import android.content.res.CompatibilityInfo;
@@ -144,6 +144,8 @@
144144
import com.android.server.policy.keyguard.KeyguardServiceDelegate;
145145
import com.android.server.policy.keyguard.KeyguardServiceDelegate.DrawnListener;
146146

147+
import org.cyanogenmod.internal.BootDexoptDialog;
148+
147149
import java.io.File;
148150
import java.io.FileReader;
149151
import java.io.IOException;
@@ -7397,68 +7399,18 @@ public void systemBooted() {
73977399
screenTurnedOn();
73987400
}
73997401

7400-
ProgressDialog mBootMsgDialog = null;
7402+
BootDexoptDialog mBootMsgDialog = null;
74017403

74027404
/** {@inheritDoc} */
74037405
@Override
7404-
public void showBootMessage(final CharSequence msg, final boolean always) {
7406+
public void updateBootProgress(final int stage, final ApplicationInfo optimizedApp,
7407+
final int currentAppPos, final int totalAppCount) {
74057408
mHandler.post(new Runnable() {
74067409
@Override public void run() {
74077410
if (mBootMsgDialog == null) {
7408-
int theme;
7409-
if (mContext.getPackageManager().hasSystemFeature(
7410-
PackageManager.FEATURE_WATCH)) {
7411-
theme = com.android.internal.R.style.Theme_Micro_Dialog_Alert;
7412-
} else if (mContext.getPackageManager().hasSystemFeature(
7413-
PackageManager.FEATURE_TELEVISION)) {
7414-
theme = com.android.internal.R.style.Theme_Leanback_Dialog_Alert;
7415-
} else {
7416-
theme = 0;
7417-
}
7418-
7419-
mBootMsgDialog = new ProgressDialog(mContext, theme) {
7420-
// This dialog will consume all events coming in to
7421-
// it, to avoid it trying to do things too early in boot.
7422-
@Override public boolean dispatchKeyEvent(KeyEvent event) {
7423-
return true;
7424-
}
7425-
@Override public boolean dispatchKeyShortcutEvent(KeyEvent event) {
7426-
return true;
7427-
}
7428-
@Override public boolean dispatchTouchEvent(MotionEvent ev) {
7429-
return true;
7430-
}
7431-
@Override public boolean dispatchTrackballEvent(MotionEvent ev) {
7432-
return true;
7433-
}
7434-
@Override public boolean dispatchGenericMotionEvent(MotionEvent ev) {
7435-
return true;
7436-
}
7437-
@Override public boolean dispatchPopulateAccessibilityEvent(
7438-
AccessibilityEvent event) {
7439-
return true;
7440-
}
7441-
};
7442-
if (mContext.getPackageManager().isUpgrade()) {
7443-
mBootMsgDialog.setTitle(R.string.android_upgrading_title);
7444-
} else {
7445-
mBootMsgDialog.setTitle(R.string.android_start_title);
7446-
}
7447-
mBootMsgDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
7448-
mBootMsgDialog.setIndeterminate(true);
7449-
mBootMsgDialog.getWindow().setType(
7450-
WindowManager.LayoutParams.TYPE_BOOT_PROGRESS);
7451-
mBootMsgDialog.getWindow().addFlags(
7452-
WindowManager.LayoutParams.FLAG_DIM_BEHIND
7453-
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
7454-
mBootMsgDialog.getWindow().setDimAmount(1);
7455-
WindowManager.LayoutParams lp = mBootMsgDialog.getWindow().getAttributes();
7456-
lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
7457-
mBootMsgDialog.getWindow().setAttributes(lp);
7458-
mBootMsgDialog.setCancelable(false);
7459-
mBootMsgDialog.show();
7460-
}
7461-
mBootMsgDialog.setMessage(msg);
7411+
mBootMsgDialog = BootDexoptDialog.create(mContext);
7412+
}
7413+
mBootMsgDialog.setProgress(stage, optimizedApp, currentAppPos, totalAppCount);
74627414
}
74637415
});
74647416
}

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import android.content.Intent;
3131
import android.content.IntentFilter;
3232
import android.content.pm.ActivityInfo;
33+
import android.content.pm.ApplicationInfo;
3334
import android.content.pm.PackageManager;
3435
import android.content.res.CompatibilityInfo;
3536
import android.content.res.Configuration;
@@ -6112,13 +6113,18 @@ private boolean checkBootAnimationCompleteLocked() {
61126113
return true;
61136114
}
61146115

6115-
public void showBootMessage(final CharSequence msg, final boolean always) {
6116+
public void updateBootProgress(final int stage, final ApplicationInfo optimizedApp,
6117+
final int currentAppPos, final int totalAppCount, final boolean always) {
61166118
boolean first = false;
61176119
synchronized(mWindowMap) {
61186120
if (DEBUG_BOOT) {
61196121
RuntimeException here = new RuntimeException("here");
61206122
here.fillInStackTrace();
6121-
Slog.i(TAG, "showBootMessage: msg=" + msg + " always=" + always
6123+
Slog.i(TAG, "updateBootProgress: stage=" + stage
6124+
+ " optimizedApp=" + optimizedApp
6125+
+ " currentAppPos=" + currentAppPos
6126+
+ " totalAppCount=" + totalAppCount
6127+
+ " always=" + always
61226128
+ " mAllowBootMessages=" + mAllowBootMessages
61236129
+ " mShowingBootMessages=" + mShowingBootMessages
61246130
+ " mSystemBooted=" + mSystemBooted, here);
@@ -6136,7 +6142,7 @@ public void showBootMessage(final CharSequence msg, final boolean always) {
61366142
return;
61376143
}
61386144
mShowingBootMessages = true;
6139-
mPolicy.showBootMessage(msg, always);
6145+
mPolicy.updateBootProgress(stage, optimizedApp, currentAppPos, totalAppCount);
61406146
}
61416147
if (first) {
61426148
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;
@@ -622,10 +623,8 @@ private void startOtherServices() {
622623
}
623624

624625
try {
625-
ActivityManagerNative.getDefault().showBootMessage(
626-
context.getResources().getText(
627-
com.android.internal.R.string.android_upgrading_starting_apps),
628-
false);
626+
ActivityManagerNative.getDefault().updateBootProgress(
627+
IActivityManager.BOOT_STAGE_STARTING_APPS, null, 0, 0, false);
629628
} catch (RemoteException e) {
630629
}
631630

0 commit comments

Comments
 (0)