Skip to content

Commit

Permalink
[2/2] base: cm custom boot dexopt UI
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
amartinz authored and temasek committed Aug 11, 2016
1 parent 5d304b2 commit ec6e01a
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 87 deletions.
19 changes: 13 additions & 6 deletions core/java/android/app/ActivityManagerNative.java
Original file line number Diff line number Diff line change
Expand Up @@ -2107,11 +2107,14 @@ public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
return true;
}

case SHOW_BOOT_MESSAGE_TRANSACTION: {
case UPDATE_BOOT_PROGRESS_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
CharSequence msg = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
int stage = data.readInt();
ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data);
int current = data.readInt();
int total = data.readInt();
boolean always = data.readInt() != 0;
showBootMessage(msg, always);
updateBootProgress(stage, info, current, total, always);
reply.writeNoException();
return true;
}
Expand Down Expand Up @@ -5310,13 +5313,17 @@ public long[] getProcessPss(int[] pids) throws RemoteException {
return res;
}

public void showBootMessage(CharSequence msg, boolean always) throws RemoteException {
public void updateBootProgress(int stage, ApplicationInfo optimizedApp,
int currentAppPos, int totalAppCount, boolean always) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
TextUtils.writeToParcel(msg, data, 0);
data.writeInt(stage);
optimizedApp.writeToParcel(data, 0);
data.writeInt(currentAppPos);
data.writeInt(totalAppCount);
data.writeInt(always ? 1 : 0);
mRemote.transact(SHOW_BOOT_MESSAGE_TRANSACTION, data, reply, 0);
mRemote.transact(UPDATE_BOOT_PROGRESS_TRANSACTION, data, reply, 0);
reply.readException();
data.recycle();
reply.recycle();
Expand Down
10 changes: 8 additions & 2 deletions core/java/android/app/IActivityManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@ public void setPackageAskScreenCompat(String packageName, boolean ask)

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

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

public void keyguardWaitingForActivityDrawn() throws RemoteException;

Expand Down Expand Up @@ -623,6 +624,11 @@ private WaitResult(Parcel source) {
}
}

public static final int BOOT_STAGE_STARTING_APPS = 1;
public static final int BOOT_STAGE_FSTRIM = 2;
public static final int BOOT_STAGE_PREPARING_APPS = 3;
public static final int BOOT_STAGE_COMPLETE = 4;

String descriptor = "android.app.IActivityManager";

// Please keep these transaction codes the same -- they are also
Expand Down Expand Up @@ -758,7 +764,7 @@ private WaitResult(Parcel source) {
int IS_INTENT_SENDER_TARGETED_TO_PACKAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+134;
int UPDATE_PERSISTENT_CONFIGURATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+135;
int GET_PROCESS_PSS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+136;
int SHOW_BOOT_MESSAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+137;
int UPDATE_BOOT_PROGRESS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+137;
int KILL_ALL_BACKGROUND_PROCESSES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+139;
int GET_CONTENT_PROVIDER_EXTERNAL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+140;
int REMOVE_CONTENT_PROVIDER_EXTERNAL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+141;
Expand Down
6 changes: 4 additions & 2 deletions core/java/android/view/WindowManagerPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.annotation.SystemApi;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.graphics.Rect;
Expand Down Expand Up @@ -1171,9 +1172,10 @@ public boolean rotationHasCompatibleMetricsLw(@ActivityInfo.ScreenOrientation in
public void systemBooted();

/**
* Show boot time message to the user.
* Update UI for boot-up progress.
*/
public void showBootMessage(final CharSequence msg, final boolean always);
public void updateBootProgress(final int stage, final ApplicationInfo optimizedApp,
final int currentAppPos, final int totalAppCount);

/**
* Hide the UI for showing boot messages, never to be displayed again.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import android.app.BroadcastOptions;
import android.app.IActivityContainer;
import android.app.IActivityContainerCallback;
import android.app.IActivityManager;
import android.app.IAppTask;
import android.app.ITaskStackListener;
import android.app.ProfilerInfo;
Expand Down Expand Up @@ -6567,12 +6568,14 @@ void enableScreenAfterBoot() {
}

@Override
public void showBootMessage(final CharSequence msg, final boolean always) {
public void updateBootProgress(final int stage, final ApplicationInfo optimizedApp,
final int currentAppPos, final int totalAppCount, final boolean always) {
if (Binder.getCallingUid() != Process.myUid()) {
// These days only the core system can call this, so apps can't get in
// the way of what we show about running them.
}
mWindowManager.showBootMessage(msg, always);
mWindowManager.updateBootProgress(stage, optimizedApp,
currentAppPos, totalAppCount, always);
}

@Override
Expand Down Expand Up @@ -12015,8 +12018,8 @@ void go() {
intent.setComponent(comp);
doneReceivers.add(comp);
lastRi = curRi;
CharSequence label = ai.loadLabel(mContext.getPackageManager());
showBootMessage(mContext.getString(R.string.android_preparing_apk, label), false);
updateBootProgress(IActivityManager.BOOT_STAGE_PREPARING_APPS,
ai.applicationInfo, 0, 0, false);
}
Slog.i(TAG, "Pre-boot of " + intent.getComponent().toShortString()
+ " for user " + users[curUser]);
Expand Down Expand Up @@ -12139,9 +12142,8 @@ public void run() {
synchronized (ActivityManagerService.this) {
mDidUpdate = true;
}
showBootMessage(mContext.getText(
R.string.android_upgrading_complete),
false);
updateBootProgress(IActivityManager.BOOT_STAGE_COMPLETE,
null, 0, 0, false);
writeLastDonePreBootReceivers(doneReceivers);
systemReady(goingCallback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6391,9 +6391,8 @@ public void performBootDexOpt() {
if (doTrim) {
if (!isFirstBoot()) {
try {
ActivityManagerNative.getDefault().showBootMessage(
mContext.getResources().getString(
R.string.android_upgrading_fstrim), true);
ActivityManagerNative.getDefault().updateBootProgress(
IActivityManager.BOOT_STAGE_FSTRIM, null, 0, 0, true);
} catch (RemoteException e) {
}
}
Expand Down Expand Up @@ -6520,9 +6519,9 @@ private void performBootDexOpt(PackageParser.Package pkg, int curr, int total) {
Log.i(TAG, "Optimizing app " + curr + " of " + total + ": " + pkg.packageName);
}
try {
ActivityManagerNative.getDefault().showBootMessage(
mContext.getResources().getString(R.string.android_upgrading_apk,
curr, total), true);
ActivityManagerNative.getDefault().updateBootProgress(
IActivityManager.BOOT_STAGE_PREPARING_APPS,
pkg.applicationInfo, curr, total, true);
} catch (RemoteException e) {
}
PackageParser.Package p = pkg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import android.app.ActivityManagerNative;
import android.app.AppOpsManager;
import android.app.IUiModeManager;
import android.app.ProgressDialog;
import android.app.SearchManager;
import android.app.StatusBarManager;
import android.app.UiModeManager;
Expand All @@ -36,6 +35,7 @@
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.CompatibilityInfo;
Expand Down Expand Up @@ -144,6 +144,8 @@
import com.android.server.policy.keyguard.KeyguardServiceDelegate;
import com.android.server.policy.keyguard.KeyguardServiceDelegate.DrawnListener;

import org.cyanogenmod.internal.BootDexoptDialog;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
Expand Down Expand Up @@ -7397,68 +7399,18 @@ public void systemBooted() {
screenTurnedOn();
}

ProgressDialog mBootMsgDialog = null;
BootDexoptDialog mBootMsgDialog = null;

/** {@inheritDoc} */
@Override
public void showBootMessage(final CharSequence msg, final boolean always) {
public void updateBootProgress(final int stage, final ApplicationInfo optimizedApp,
final int currentAppPos, final int totalAppCount) {
mHandler.post(new Runnable() {
@Override public void run() {
if (mBootMsgDialog == null) {
int theme;
if (mContext.getPackageManager().hasSystemFeature(
PackageManager.FEATURE_WATCH)) {
theme = com.android.internal.R.style.Theme_Micro_Dialog_Alert;
} else if (mContext.getPackageManager().hasSystemFeature(
PackageManager.FEATURE_TELEVISION)) {
theme = com.android.internal.R.style.Theme_Leanback_Dialog_Alert;
} else {
theme = 0;
}

mBootMsgDialog = new ProgressDialog(mContext, theme) {
// This dialog will consume all events coming in to
// it, to avoid it trying to do things too early in boot.
@Override public boolean dispatchKeyEvent(KeyEvent event) {
return true;
}
@Override public boolean dispatchKeyShortcutEvent(KeyEvent event) {
return true;
}
@Override public boolean dispatchTouchEvent(MotionEvent ev) {
return true;
}
@Override public boolean dispatchTrackballEvent(MotionEvent ev) {
return true;
}
@Override public boolean dispatchGenericMotionEvent(MotionEvent ev) {
return true;
}
@Override public boolean dispatchPopulateAccessibilityEvent(
AccessibilityEvent event) {
return true;
}
};
if (mContext.getPackageManager().isUpgrade()) {
mBootMsgDialog.setTitle(R.string.android_upgrading_title);
} else {
mBootMsgDialog.setTitle(R.string.android_start_title);
}
mBootMsgDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
mBootMsgDialog.setIndeterminate(true);
mBootMsgDialog.getWindow().setType(
WindowManager.LayoutParams.TYPE_BOOT_PROGRESS);
mBootMsgDialog.getWindow().addFlags(
WindowManager.LayoutParams.FLAG_DIM_BEHIND
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
mBootMsgDialog.getWindow().setDimAmount(1);
WindowManager.LayoutParams lp = mBootMsgDialog.getWindow().getAttributes();
lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
mBootMsgDialog.getWindow().setAttributes(lp);
mBootMsgDialog.setCancelable(false);
mBootMsgDialog.show();
}
mBootMsgDialog.setMessage(msg);
mBootMsgDialog = BootDexoptDialog.create(mContext);
}
mBootMsgDialog.setProgress(stage, optimizedApp, currentAppPos, totalAppCount);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
Expand Down Expand Up @@ -6112,13 +6113,18 @@ private boolean checkBootAnimationCompleteLocked() {
return true;
}

public void showBootMessage(final CharSequence msg, final boolean always) {
public void updateBootProgress(final int stage, final ApplicationInfo optimizedApp,
final int currentAppPos, final int totalAppCount, final boolean always) {
boolean first = false;
synchronized(mWindowMap) {
if (DEBUG_BOOT) {
RuntimeException here = new RuntimeException("here");
here.fillInStackTrace();
Slog.i(TAG, "showBootMessage: msg=" + msg + " always=" + always
Slog.i(TAG, "updateBootProgress: stage=" + stage
+ " optimizedApp=" + optimizedApp
+ " currentAppPos=" + currentAppPos
+ " totalAppCount=" + totalAppCount
+ " always=" + always
+ " mAllowBootMessages=" + mAllowBootMessages
+ " mShowingBootMessages=" + mShowingBootMessages
+ " mSystemBooted=" + mSystemBooted, here);
Expand All @@ -6136,7 +6142,7 @@ public void showBootMessage(final CharSequence msg, final boolean always) {
return;
}
mShowingBootMessages = true;
mPolicy.showBootMessage(msg, always);
mPolicy.updateBootProgress(stage, optimizedApp, currentAppPos, totalAppCount);
}
if (first) {
performEnableScreen();
Expand Down
7 changes: 3 additions & 4 deletions services/java/com/android/server/SystemServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import android.app.ActivityManagerNative;
import android.app.ActivityThread;
import android.app.IActivityManager;
import android.app.IAlarmManager;
import android.app.INotificationManager;
import android.app.usage.UsageStatsManagerInternal;
Expand Down Expand Up @@ -622,10 +623,8 @@ private void startOtherServices() {
}

try {
ActivityManagerNative.getDefault().showBootMessage(
context.getResources().getText(
com.android.internal.R.string.android_upgrading_starting_apps),
false);
ActivityManagerNative.getDefault().updateBootProgress(
IActivityManager.BOOT_STAGE_STARTING_APPS, null, 0, 0, false);
} catch (RemoteException e) {
}

Expand Down

0 comments on commit ec6e01a

Please sign in to comment.