Year-end small inventory: Do you know all of the 18 Android development essentials?

Keywords: Android shell Google Java

This article mainly introduces some of the knowledge points in Android development. By reading this article, you will get the following:

1. Check CPU temperature
2. Startup Wizard Debugging Related Methods
3. View APP Start Time
4. Method of judging user,userdebug version
5. Modify the default storage path for screenshots
6. Resolving the kernel dump method
7. SPRD default open Ylog and dumpsys enable methods
8. Methods for judging whether a monkey test is in progress
9. Method of modifying MTK log mode
10. MTK Platform Open Only Mobile log Method
11. SPRD platform only opens Android log method
12. Notes on Power Consumption Log of SPRD Platform
13. Get the Top Activity package name
14. Modify the Welcome Message of the Google Startup Wizard
15. Modify status bar time display seconds
16. Judging multi-user methods
17. Fuzzy Removal in Low RAM(1G)
18. Round corner scheme around screen

Friends who want to see past studies
You can see my GitHub: https://github.com/Meng997998/AndroidJX

1. Check CPU temperature

  • 1. Use ADB to view CPU temperature (debug version)

View the CPU commands as follows:

adb shell cat /sys/class/thermal/thermal_zone*/temp
  • 2. View CPU return content corresponding classification information
adb shell cat /sys/class/thermal/thermal_zone*/type

CPU Temperature View Command Method

The CPU temperature thus viewed consists of the last three decimal points, with the decimal points omitted. This method is suitable for MTK platforms.

  • 3. View CPU temperature in MTK log

Search keyword T_AP in the kernel log to see CPU temperature.

2. Startup Wizard Debugging Related Methods

1.debug version skips boot-up wizard scenario

  • 1. Click on the shortcut four times
    You can skip the power-on wizard by clicking on the four corners of the screen continuously (top left --> top right --> bottom right --> bottom left).

  • 2.adb command disable startup Wizard
adb shell settings put secure user_setup_complete 1adb shell settings put global device_provisioned 1adb shell pm disable com.google.android.setupwizard/.SetupWizardActivity

2.debug restart wizard scenario

If you skip the power-on wizard and want to walk away from it again, you can try the following commands.

  • 1. Reset the values set after the power-on wizard is completed

The commands are as follows:

adb shell settings put secure user_setup_complete 0adb shell settings put global device_provisioned 0
  • 2. Set the Startup Wizard to be available and start

After the startup wizard is over, the startup wizard apk will be set to be unavailable.
At this point we should set the power-on wizard to enble state.

adb shell pm enable com.google.android.setupwizard/.SetupWizardActivityadb shell am start -n com.google.android.setupwizard/.SetupWizardActivity

3. Boot-up Wizard log Debugging

Open the Startup Wizard to debug the Log as follows:

adb shell setprop log.tag.SetupWizard VERBOSE

4. Ways to skip the startup wizard in your code

Skip the startup wizard in your code as follows:

        private  void  SkipSetupwizard(){            ActivityManager activityAanager = (ActivityManager) mContext                .getSystemService(Context.ACTIVITY_SERVICE);            ComponentName cn = activityAanager.getRunningTasks(1).get(0).topActivity;            String pName = cn.getPackageName();            if("com.google.android.setupwizard".equals(pName))            {                Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);                Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1);                activityAanager.forceStopPackage("com.google.android.setupwizard");                Log.i("wjwj","----------skip com.google.android.setupwizard--------");            }               }

3. View APP Start Time

1. Use adb command to grab log to view

adb logcat | findstr Displayed
Or grab the adb Log directly and search for the keyword Displayed


APP cold start time statistics


Search keyword Display in adb Log

2. View ways to cold start app s multiple times

The following are the ways to test the 10 cold starts of Chrome:
adb shell am start -S -R10 -W com.android.chrome/com.google.android.apps.chrome.Main

The test results are as follows:

C:\Users\Administrator>adb shell am start -S -R10 -W com.android.chrome/com.google.android.apps.chrome.MainStopping: com.android.chromeStarting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.android.chrome/com.google.android.apps.chrome.Main }Status: okActivity: com.android.chrome/org.chromium.chrome.browser.firstrun.FirstRunActivityTotalTime: 1514WaitTime: 1525CompleteStopping: com.android.chromeStarting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.android.chrome/com.google.android.apps.chrome.Main }Status: okActivity: com.android.chrome/org.chromium.chrome.browser.firstrun.FirstRunActivityTotalTime: 534WaitTime: 549Complete

4. Method of judging user, userdebug version

private static final boolean USER_BUILD = android.os.Build.IS_USER;

Looking at Build.java, we found that these methods are hidden from the external apk and can only be used by applications signed by the system platform.

    /** {@hide} */    public static final boolean IS_ENG = "eng".equals(TYPE);    /** {@hide} */    public static final boolean IS_USERDEBUG = "userdebug".equals(TYPE);    /** {@hide} */    public static final boolean IS_USER = "user".equals(TYPE);

5. Modify the default storage path for screenshots

/frameworks/base/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java

       // import com.mediatek.storage.StorageManagerEx;       String defaultWritePath = StorageManagerEx.getDefaultPath()+File.separator+"Pictures";        mScreenshotDir = new File(defaultWritePath, SCREENSHOTS_DIR_NAME);

6. Resolving the kernel dump method

1. Append all systemdump files to one file

First we need to grab the dumpsys log and append all the systemcore* files to one file.

cat systemcore* > all

Append all sysdump files to one file

2. Resolve dump files using the corresponding version of vmlinux

Parse dump file using crash_arm command

  • The 32-bit system uses the following:
    ./crash_arm vmlinux all -m phys_base=0x80000000

  • 64-bit systems use the following commands:
    ./crash_arm64 vmlinux all -m phys_offset=0x80000000

3. Debug after successful parsing

Parse log method after successfully parsing dump
log > log.txt

Use log command to read log to specified file

7. SPRD default open Ylog and dumpsys enable methods

Modify device\sprd\xxx\common\rootdir\root\init.common.rc
Add the following to on post-fs-data:

on post-fs-data     .....       setprop persist.ylog.enabled 1//Add this sentence to open ylog setprop debug.sysdump.enabled true //Add this sentence to open sysdump setprop persist.sys.eng.reset 1 //Add this sentence to start ylog

8. Methods for judging whether a monkey test is in progress

    public boolean isMonkeyRunning() {        return ActivityManager.isUserAMonkey();    }

9. Method of modifying MTK log mode

Modify the attribute values configured under the following paths to be alps\device\mediatekcommon\mtklog
Change false to true to open the corresponding log

mtklog_path = internal_sdcom.mediatek.log.mobile.enabled = falsecom.mediatek.log.mobile.maxsize = 500com.mediatek.log.mobile.totalmaxsize = 1000com.mediatek.log.modem.enabled = falsecom.mediatek.log.modem.maxsize = 2000com.mediatek.log.net.enabled = falsecom.mediatek.log.net.maxsize = 600com.mediatek.log.gps.enabled = false

10. MTK Platform Open Only Mobile log Method

Enter the code *#*#46633#*#**, enter the MTK Logger interface, open Logger Setting in the upper right corner, and manually close the switch except Moblie Log.

See the following figure for the closing method:

Open Mobile log Reference on mtk platform

11. SPRD platform only opens Android log method

Enter the code *#*#83781#*#***, enter the SPRD Logger interface, open Settings in the upper right corner, click Custom scene, close the switch except Android log, and see the figure below.

SPRD Platform Opens Android log Reference

12. Notes on Power Consumption Log of SPRD Platform

  1. Open only Android Log (refer to 11, SPRD platform open only Android log method)

  2. Enter DEBUG&Log interface, system info-> Power Log;

  3. Open PowerGuru log and wakelock log;

  4. Restart the device.

  5. Reset battery history using the following command
adb shell dumpsys batterystats --enable full-wake-historyadb shell dumpsys batterystats --reset
  1. When the test is complete, use the following command to grab bugreport
adb rootadb bugreport > bugreport.zip
  1. Finally, both the andorid log and bugreport.zip are provided.

13. Get the Top Activity package name

Get the Activity Top as follows:

//import android.app.ActivityManager;//import android.app.ActivityManager.RunningTaskInfo;//import android.content.ComponentName;//import java.util.List; //get top activity APK public String getTopActivityPackageName (Context context) {String ActivityPackage = null; ActivityManager activityManager = (Manag ActivityManag Activity(context.getSystemService (android.content.Context.ACTIVITY_SERVICE)); List <RunningTaskInfo> runningTaskInfos = activityManager.getRunningTasks(1); if (runningTaskInfos!= null) {ComponentName f = InfrunningTaskos.get(0). topyActivity; topyPackage= f.getPackageName(); //Slog.e("wangjie", "------- topActivityPackage-----"+topActivityPackage);} return topActivityPackage;}

14. Modify the Welcome Message of the Google Startup Wizard

Bangladeshi Startup Wizard welcome is incorrect, the customer requested to remove the Startup Wizard interface welcome method.

idh.code/frameworks/base/core/java/android/widget/TextView.java

public class TextView extends View implements ViewTreeObserver.OnPreDrawListener {... ...     public void setTextLocale(@NonNull Locale locale) {+        // add for  Bangla language+        if (getContext().getClass().getName().equals("com.google.android.setupwizard.user.WelcomeActivity") &&+                locale.getLanguage().equals("bn") && locale.getCountry().equals("BD"))+        {+            Log.i(LOG_TAG, "find text:" + getText());+            if (!getText().equals("") && !getText().toString().contains("("))+            Log.i(LOG_TAG, "set text:" + getText());+            setText("");+        }+        // add for  Bangla language         mLocalesChanged = true;         mTextPaint.setTextLocale(locale);         ... ...          }... ...}

15. Modify status bar time display seconds

Modify the status bar time display seconds on the display platform as follows

adb shell pm enable com.android.systemui/com.android.systemui.tuner.TunerActivityadb shell am start -n com.android.systemui/com.android.systemui.tuner.TunerActivity

Enter Settings--System--Interface Tuner--Status Bar--Time--Display Hours and Seconds.

16. Judging multi-user methods

The following are the ways to judge multiuser:

// import android.os.UserHandle; if (UserHandle.myUserId()!= UserHandle.USER_OWNER) {//Operate for Administrator User}

17. Fuzzy Removal in Low RAM(1G)

In the Android GO version, some UI experiences are sacrificed for compatibility with system performance, such as the recent blurred task list, the Settings interface loading from blurred to clear, and the Launcher icon loading from blurred to clear, but this affects the user experience. Personally, the solution to remove the blurring effect is as follows:

1. The following documents need to be modified:

 frameworks/base/services/core/java/com/android/server/wm/AppWindowContainerController.java  frameworks/base/services/core/java/com/android/server/wm/TaskSnapshotController.java     frameworks/base/services/core/java/com/android/server/wm/TaskSnapshotPersister.java
  • 1.AppWindowContainerController Modification Method

In the AppWindowContainerController.java class, comment out the scheduleAddStartingWindow method implementation.

public class AppWindowContainerController        extends WindowContainerController<AppWindowToken, AppWindowContainerListener> {... ...// Comment out the method void scheduleAddStarting Window () {// Note: we really want to do sendMessageAtFrontOfQueue () because we // want to process the message ASAP, before any other queued // messages. /*** if (!MService.mAnimationHandler.hasCallbacks (mAddStarting Window)) {mContainer.starting = trUe; if (DEBUG_STARTING_WINDOW) Slog.v (TAG_WM,'Enqueueing ADD_STARTING'); mService.mAnimationHandler.postAtFrontOfQueue (mAddStartingWindow);} ***/}...}
  • 2.TaskSnapshotController Modification Method

Manually set the system to a non-low memory device, such as isLowRamDevice =false state.

class TaskSnapshotController {... ...// Manually set the system to non-low memory device final boolean isLowRamDevice = false; //final boolean isLowRamDevice = ActivityManager.isLowRamDeviceStatic();......
  • 3.TaskSnapshotPersister Modification Method

In the TaskSnapshotPersister class, set the DISABLE_FULL_SIZED_BITMAPS state to false.

class TaskSnapshotPersister {... ...// Set the DISABLE_FULL_SIZED_BITMAPS state to false.static final boolean DISABLE_FULL_SIZED_BITMAPS = false;//static final boolean DISABLE_FULL_SIZED_BITMAPS = ActivityManager.isLowRamDeviceStatic();...}

18. Round corner scheme around screen

The SPRD screen rounding scheme requires modification of the ***.dtsi file.
Taking sc7731e.dtsi as an example, the file path that needs to be modified is kernel4.4/arch/arm/boot/dts/sc7731e.dtsi, where 15 represents the radian of a rounded corner and the default right angle is 90 degrees
The modifications are as follows:

soc: soc {        ap-ahb {            dispc0: dispc@20800000 {                ... ...                sprd,ip = "dpu-lite-r1p0";                sprd,soc = "pike2";                                // 15 denotes the radian SPRD of a rounded corner, corner-radius = <15>; /* output port */ port {dispc0_out: endpoint@0 {remote-endpoint = <&dsi0_in>;};};...};

Last

Friends who read this article for the first time can follow me and my column, publish factory interviews, Android architecture technical points and parsing, and learn PDF+source notes+interview documents+advanced video sharing from time to time.

More wonderful learning is here Android Architect Learning Material

Posted by chaiwei on Tue, 07 Jan 2020 10:04:11 -0800