文件路径:frameworks\base\services\core\java\com\android\server\power\ShutdownThread.java

在beginShutdownSequence()方法中:

 private static void beginShutdownSequence(Context context) {
...... // throw up an indeterminate system dialog to indicate radio is
// shutting down.
//*********************** 系统默认的Dialog ***********************
/*ProgressDialog pd = new ProgressDialog(context);
pd.setTitle(context.getText(com.android.internal.R.string.power_off));
pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress));
pd.setIndeterminate(true);
pd.setCancelable(false);
pd.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
pd.show();*/
//*********************** 替换为自定义的全屏Dialog ***********************
Point outSize = new Point();
Dialog dialog = new Dialog(context, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
IndeterminateProgressBar view = new IndeterminateProgressBar(context);
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
dialog.getWindow().getWindowManager().getDefaultDisplay().getSize(outSize); //获取屏幕宽高
dialog.setContentView(view, new LayoutParams(outSize.x, outSize.y)); //设置自定义view宽高为全屏
dialog.show(); ......
}
 
注意:必须要设置 dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); 之前忘了加导致什么都不显示
 
替换的自定义View:
 
 class IndeterminateProgressBar extends View {
static final String TAG = "ProgressBar";
private int delayMillis = 30;
private Handler mHandler;
private ArrayList<Entity> entities;
private int width = 0;
// private int height = 0;
private int r = 15;
private int shift = 20;
private int radius = 3;
private int color = Color.WHITE;
private long time = 0;
private boolean started = false;
public IndeterminateProgressBar(Context context) {
super(context);
init();
}
@Override
protected void onLayout(boolean changed, int left, int top, int right,
int bottom) {
super.onLayout(changed, left, top, right, bottom);
width = getLayoutParams().width / 2;
// height = getLayoutParams().height;
if (width > 0) {
radius = width / 20;
r = 2 * width / 5;
//shift = width / 2;
shift = width / 1;
}
}
private void init() {
setBackgroundResource(android.R.color.transparent);
mHandler = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
for (Entity e : entities) {
e.update();
}
invalidate();
mHandler.sendEmptyMessageDelayed(0, delayMillis);
time += delayMillis;
return false;
}
});
}
public void setColor(int color) {
this.color = color;
}
public void stop() {
mHandler.removeMessages(0);
started = false;
invalidate();
}
public boolean isStart() {
return started;
}
public void start() {
if (started)
return;
started = true;
time = 0;
entities = new ArrayList<IndeterminateProgressBar.Entity>();
float s = .25f;
entities.add(new Entity(0, color, 0));
entities.add(new Entity(1 * s, color, delayMillis * 4));
entities.add(new Entity(2 * s, color, delayMillis * 8));
entities.add(new Entity(3 * s, color, delayMillis * 12));
entities.add(new Entity(4 * s, color, delayMillis * 16));
// entities.add(new Entity(5 * s, color, delayMillis * 20));
if (mHandler != null)
mHandler.sendEmptyMessage(0);
}
@Override
protected void onDraw(Canvas canvas) {
if (entities != null && entities.size() > 0) {
for (Entity e : entities) {
e.draw(canvas);
}
}
super.onDraw(canvas);
}
class Entity {
private float x;
private float y;
private int color;
private Paint paint;
private double sp = 0;
private long delay;
private int sec = 0;
private float pec = 0;
boolean visiable = true;
public float getInterpolation(float input) {
return (float) (Math.cos((input + 1) * Math.PI) / 2.0f) + 0.5f;
}
public Entity(float sp, int color, int delay) {
paint = new Paint();
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.FILL);
this.color = color;
this.sp = sp;
this.delay = delay;
paint.setColor(this.color);
}
public void update() {
if (time < delay)
return;
visiable = true;
pec += 0.03;
if (pec > 1) {
pec = 0;
sec = ++sec == 3 ? 0 : sec;
delay = sec == 0 ? time + delayMillis * 22 : time + delayMillis
* 3;
visiable = sec == 0 ? false : true;
}
double θ = Math.PI
* .5
+ (sec == 0 ? 0 : sec * Math.PI / sec)
- (sec == 0 ? 0 : sp)
+ (Math.PI * (sec == 1 ? 2 : 1) - (sec == 0 ? sp : 0) + (sec == 2 ? sp
: 0)) * getInterpolation(pec);
x = (float) (r / 2 * Math.cos(θ)) + shift / 2;
y = (float) (r / 2 * Math.sin(θ)) + shift / 2;
}
public void draw(Canvas canvas) {
if (!visiable || x == 0 || y == 0)
return;
canvas.save();
canvas.translate(x, y);
canvas.drawCircle(x, y, radius, paint);
canvas.restore();
}
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (getVisibility() == View.VISIBLE) {
start();
}
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
stop();
}
public void setDelayMillis(int delayMillis) {
this.delayMillis = delayMillis;
}
}

效果图:

修改Android系统关机动画的更多相关文章

  1. 修改android系统开机动画

    本文转载自:http://blog.csdn.net/u012301841/article/details/51598115 修改android系统开机动画

  2. 修改Android系统属性SystemProperties.set("sys.powerctl", "shutdown")关机分析

    简介: 从之前的博文中我们提到过,关机流程中最后是通过修改Android属性进行关机操作(SystemProperties.java通过JNI调用访问系统属性),当然我们也可以通过adb命令修改And ...

  3. Windows在生产体系Android开关机动画

    在Windows根据系统.办Android开关机动画,几个需要注意的问题: 1.压缩的选择 2.压缩的格式: 版权声明:本文博客原创文章,博客,未经同意,不得转载.

  4. Android系统关机或重启的几种实现方式

    前阵子工作上遇到一些关于Android系统关机或重启的系统修改,于是,做了一些尝试,也搜集了一下资料,现在整理一下,做一些总结,方便学习或者日后工作的需要. 默认的SDK并没有提供应用开发者直接的An ...

  5. 修改Android系统字号(二)

    /*********************************************************************** * 修改Android系统字号(二) * 说明: * ...

  6. 修改Android系统字号(一)

    /*********************************************************************** * 修改Android系统字号(一) * 说明: * ...

  7. Android系统关机或几种方式重启

    ---------------------------------------------------------------------------------------------------- ...

  8. Android源码分析(九)-----如何修改Android系统默认时间

    一 : 修改Android系统默认时间 源码路径:frameworks/base/services/java/com/android/server/SystemServer.java 主要变量EARL ...

  9. 修改Android系统的触摸提示音【学习笔记】

    平台信息:内核:Linux version 3.10.0系统:android/android6.0平台:rk3288 作者:庄泽彬(欢迎转载,请注明作者) 邮箱:2760715357@qq.com 本 ...

随机推荐

  1. ArrayList深度分析:ArrayList和数组间的相互转换

    一.ArrayList转换为数组ArrayList提供public <T> T[] toArray(T[] a)方法返回一个按照正确的顺序包含此列表中所有元素的数组,返回数组的运行时类型就 ...

  2. Gym - 101845F 最大流

    The UN finals are here!, the coaches/ex-coaches team is creating a new exciting contest to select wh ...

  3. 17.Merge Two Binary Trees(合并两个二叉树)

    Level:   Easy 题目描述: Given two binary trees and imagine that when you put one of them to cover the ot ...

  4. Express全系列教程之(十):jade模板引擎

    一.前言 随着前端业务的不断发展,页面交互逻辑的不断提高,让数据和界面实现分离渐渐被提了出来.JavaScript的MVC思想也流行了起来,在这种背景下,基于node.js的模板引擎也随之出现. 什么 ...

  5. opencv-视频基本操作

    写视频 # encoding: utf-8 ''' @author: gaoyongxian666 @file: opencv_video_write.py @time: 2018/4/15 11:1 ...

  6. springboot整合mybatis,redis,代码(四)

    一 说明 这是spring整合redis注解开发的系类: 二 正文 在注解开发时候,会有这几个注解需要注意: 具体含义: 1.@Cacheable 可以标记在方法上,也可以标记在类上.当标记在方法上时 ...

  7. P3800 Power收集

    传送门 DP每次向下一格,显然是DP方程也十分显然:设$f[i][j]$为到第$i$行第$j$列时能得到的最大价值显然$f[i][j]=max(f[i-1][k]+v[i][j]),( max(0,j ...

  8. POJ2686 Traveling by Stagecoach(状压DP)

    题意: 有一个旅行家计划乘马车旅行.他所在的国家里共有m个城市,在城市之间有若干道路相连.从某个城市沿着某条道路到相邻的城市需要乘坐马车.而乘坐马车需要使用车票,每用一张车票只可以通过一条道路.每张车 ...

  9. 转——深度学习之BN算法(Batch Normailization)

    Batch Normalization 学习笔记 原文地址:http://blog.csdn.net/hjimce/article/details/50866313 作者:hjimce 一.背景意义 ...

  10. my23_pxc其中一个节点重建记录

    PXC报废了一个节点,时间大概在周五,而此时故障的数据库节点比较多,警告信息也成百上千,此信息混合于已有的故障节点信息中,没有被及时发现:然后周六.周日各报废一个,在周一的时候,业务已经没有节点可以写 ...