This pop-up window is the display popup for the boot Systemui:
First, add the source class file in the Systemui source directory, the directory is Frameworks/base/packages/systemui/src/com/android/systemui /settings, the class name is tentatively taken as Updateui.java contents are as follows:
/*
* Copyright (C) The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You are not a use this file except in compliance with the License.
* Obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable or agreed to writing, software
* Distributed under the License is distributed on a "as is" BASIS,
* Without warranties or CONDITIONS of any KIND, either express or implied.
* See the License for the specific language governing permissions and
* Limitations under the License.
*/
Package com.android.systemui.settings;
Import Android.app.ActivityManager;
Import Android.app.ActivityManager.RunningTaskInfo;
Import Android.app.AlertDialog;
Import Android.app.Dialog;
Import Android.app.XXDialog;
Import Android.content.BroadcastReceiver;
Import Android.content.ComponentName;
Import Android.content.ContentResolver;
Import android.content.SharedPreferences;
Import Android.content.SharedPreferences.Editor;
Import Android.content.Context;
Import Android.content.DialogInterface;
Import Android.content.DialogInterface.OnDismissListener;
Import android.content.Intent;
Import Android.content.IntentFilter;
Import Android.net.Uri;
Import Android.os.UserHandle;
Import android.provider.Settings;
Import Android.util.Slog;
Import Android.view.View;
Import android.view.MotionEvent;
Import Android.view.WindowManager;
Import Android.widget.Button;
Import Android.widget.TextView;
Import COM.ANDROID.SYSTEMUI.R;
Import Com.android.systemui.SystemUI;
Import Android.app.XXDialog.ButtonClickListener;
Import Java.io.FileDescriptor;
Import Java.io.PrintWriter;
Import Java.util.Arrays;
Import java.util.List;
public class UpdateUI extends Systemui {
Static final String TAG = "UpdateUI";
Static final String ACTION = "Android.hm.WITH_UPGRADE_ICON";
Static final String Sourceflag = "From_check_service";
Static final String Forceflag = "Force";
Static final String Update = "com." XX.ota.MainActivity ";
private static Boolean fromservice = false;
private static Boolean forceupdate = false;
Private String vers;
Private Sharedpreferences sp;
Xxdialog Mupdatedialog;
TextView Mupdatetextview;
Private Long mscreenofftime =-1;
public void Start () {
Register for Intent broadcasts ...
Intentfilter filter = new Intentfilter ();
Filter.addaction (ACTION);
Mcontext.registerreceiver (mintentreceiver, filter, NULL, NULL);
}
Private Boolean shouldshow (Final String str) {
The Broadcast data field is processed here, and if it is the same as the data that already exists in the XML, the popup is no longer prompted, otherwise the popup window and the XML data are updated.
SP = mcontext.getsharedpreferences ("version", context.mode_private);
String Version = sp.getstring ("Version", "");
if (!str.equals (version)) {
Editor ed = Sp.edit ();
Ed.putstring ("version", Vers);
Ed.commit ();
return true;
}
return false;
}
Private Boolean Gettopwindow () {
Activitymanager am = (activitymanager) (Mcontext). Getsystemservice (Context.activity_service);
ComponentName cn = Am.getrunningtasks (1). Get (0). topactivity;
SLOG.E (TAG, "activity:" + cn.getclassname (). toString ());
if (Cn.getclassname (). Contains (Update))
return true;
return false;
}
Private Broadcastreceiver Mintentreceiver = new Broadcastreceiver () {
@Override
public void OnReceive (context context, Intent Intent) {
String action = Intent.getaction ();
if (Action.equals (action)) {
Fromservice = Intent.getbooleanextra (Sourceflag, false);
ForceUpdate = Intent.getbooleanextra (Forceflag, false);
Vers = Intent.getstringextra ("version");
if (Fromservice &&!gettopwindow ()) {
if (forceupdate) {
Showupdatedialog (forceupdate);
Return
} else if (Shouldshow (vers)) {
Showupdatedialog (forceupdate);
Return
}
}
}
}
};
void Dismissupdatedialog () {
if (mupdatedialog! = null) {
Mupdatedialog.dismiss ();
Mupdatedialog = null;
}
}
void Showupdatedialog (Final boolean bool) {
SLOG.E (TAG, "= = = Show update Dialog = = = =");
This dialog is added to the framework's standard dialog for third parties,the Android.app.XXDialog.
Xxdialog.builder B = new Xxdialog.builder (mcontext);
Xxdialog dialog = B.create ();
Dialog.setrightbuttonname (mcontext.getstring (r.string.sure));
Dialog.setleftbuttonname (mcontext.getstring (r.string.cancel));
Dialog.setcontent (mcontext.getstring (R.string.update_notice));
Dialog.settitle (mcontext.getstring (r.string.system_update));
Dialog.notcloseontouch ();
if (bool) {
Dialog.setleftbuttonvisible (FALSE);
Dialog.setmiddlelinevisible (FALSE);
}
Final Intent Intent = new Intent ();
ComponentName comp = new ComponentName ("com. Xx.ota ",
"com. XX.ota.MainActivity ");
Intent.setcomponent (comp);
Intent.setaction ("Android.intent.action.VIEW");
Intent.setflags (Intent.flag_activity_new_task);
if (Intent.resolveactivity (Mcontext.getpackagemanager ()) = null) {
Dialog.setclicklistener (New Buttonclicklistener () {
@Override
public void RightClick () {
Mcontext.startactivityasuser (Intent, userhandle.current);
Dismissupdatedialog ();
}
@Override
public void Leftclick () {
if (!bool)
Dismissupdatedialog ();
}
});
}
Dialog.getwindow (). SetType (WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
Dialog.getwindow (). GetAttributes (). Privateflags |=
WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
Dialog.show ();
Mupdatedialog = Dialog;
}
}
The class is then added to the list of service class names that systemui boot up:
Modify File Frameworks/base/packages/systemui/src/com/android/systemui/systemuiservice.java
Private final class<?>[] SERVICES = new class[] {
Com.android.systemui.recent.Recents.class,
Com.android.systemui.statusbar.SystemBars.class,
Com.android.systemui.usb.StorageNotification.class,
Com.android.systemui.power.PowerUI.class,
Com.android.systemui.media.RingtonePlayer.class,
Com.android.systemui.settings.SettingsUI.class,
Com.android.systemui.settings.UpdateUI.class,
Com.android.systemui.net.NetWorkWarningUI.class,
};
At this point, the addition is complete ...
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Systemui Add dialog Pop-up window