Android日常笔记

1、语言时区
android\build\make\tools\buildinfo.sh

echo "persist.sys.timezone=America/New_York"
echo "ro.product.locale=en-US"

注意中间是中横线,不是下划线,不然不生效的

2、Model
android\build\make\tools\buildinfo_common.sh

echo "ro.product.${partition}.model=product_model"

PRODUCT_BRAND 产品品牌
PRODUCT_DEVICE 产品设备
PRODUCT_MANUFACTURER 产品制造商
PRODUCT_MODEL 产品模型
PRODUCT_NAME 产品名称

3.开机动画
android\device\softwinner\ceres\ceres-b6\system\bootanimation.zip

4.蓝牙
android\device\generic\common\bluetooth\bdroid_buildcfg.h

#define BTM_DEF_LOCAL_NAME   "product_model"

5.开机logo

  • android\longan\device\config\chips\a133\configs\b6\bootlogo.bmp
  • android\longan\device\config\chips\a133\configs\b6\dragonboard\bootlogo.bmp
  • android\longan\device\config\chips\a133\configs\b6\android\bootlogo.bmp需删除此处logo

6.默认壁纸
待选图片放入此三处

  1. android\device\softwinner\ceres\common\overlay\overlay\frameworks\base\core\res\res\drawable-nodpi\default_wallpaper.png
  2. android\device\softwinner\ceres\common\overlay\overlay\frameworks\base\core\res\res\drawable-sw600dp-nodpi\default_wallpaper.png
  3. android\device\softwinner\ceres\common\overlay\overlay\frameworks\base\core\res\res\drawable-sw720dp-nodpi\default_wallpaper.png

此处删除已生成文件

  1. android\out\target\product\ceres-b6\obj\APPS\framework-res__auto_generated_rro_vendor_intermediates
  2. android\out\target\product\ceres-b6\obj\APPS\framework-res_intermediates
  3. android\out\target\common\obj\APPS\framework-res__auto_generated_rro_vendor_intermediates
  4. android\out\target\common\obj\APPS\framework-res_intermediates
  5. android\out\target\product\ceres-b6\vendor\overlay

7/预置壁纸
android\device\softwinner\ceres\C70W\overlay\overlay\packages\apps\WallpaperPicker2\res\drawable-nodpi

Settings的位置
android\frameworks\base\core\java\android\provider\Settings.java
8/Settings – Privacy – show password这个选项要关掉
android\packages\apps\Settings\src\com\android\settings\security\ShowPasswordPreferenceController.java

@Override
    public boolean isChecked() {
        return Settings.System.getInt(mContext.getContentResolver(),
                Settings.System.TEXT_SHOW_PASSWORD, 1) != 0;
}
=>
 @Override
    public boolean isChecked() {
        return Settings.System.getInt(mContext.getContentResolver(),
                Settings.System.TEXT_SHOW_PASSWORD, 0) != 0;
}

jgrep "animation"查找包含animation的文件位置
find -name "battery_scale.png"查找名为battery_scale.png的文件

9、充电动画

  1. android\longan\device\product\boot-resource\boot-resource\bat
    15张图文件可能过大
    分区改大android\device\softwinner\ceres\ceres-b6\system\sys_partition.fex
    name = bootloader_a
    size = 128M

  2. android\device\softwinner\common\health\images\ 替换battery_scale.png

    彩色256 位深度8;11张图

  3. android\system\core\healthd\healthd_mode_charger.cpp

{
  .disp_time = 750,
  .min_level = 0,
  .max_level = 9,
  .surface = NULL,
},
  1. android\device\softwinner\common\health\animation.txt
frame: 750 0 9
  1. 字体路径:

bootable/recovery/minui/graphics.cpp
bootable/recovery/minui/font_10x18.h

  1. 去除充电百分比数字

删掉android\device\softwinner\common\health\images\battery_percent.png

9、
public static String getDeviceBrand() {
FutureTask msvSuffixTask = new FutureTask<>(() -> DeviceInfoUtils.getMsvSuffix());

    msvSuffixTask.run();
    try {
        // Wait for msv suffix value.
        final String msvSuffix = msvSuffixTask.get();
        return Build.BRAND + msvSuffix;
    } catch (ExecutionException e) {
        Log.e(TAG, "Execution error, so we only show brand name");
    } catch (InterruptedException e) {
        Log.e(TAG, "Interruption error, so we only show brand name");
    }
    // If we can't get an msv suffix value successfully,
    // it's better to return brand name.
    return Build.BRAND;
}

10、更改Device name
android\packages\apps\Settings\src\com\android\settings\deviceinfo\DeviceNamePreferenceController.java

  private void initializeDeviceName() {
    //  mDeviceName = Settings.Global.getString(mContext.getContentResolver(),
    //          Settings.Global.DEVICE_NAME);
		mDeviceName = "LINSAY_F10XIPSQ";
        if (mDeviceName == null) {
            mDeviceName = Build.MODEL;
        }
    }

11.修改指纹
android\build\core\Makefile

define generate-common-build-props-with-product-vars-set
	BUILD_FINGERPRINT="$(BUILD_FINGERPRINT_FROM_FILE)" \
	BUILD_ID="$(BUILD_ID)" \
	BUILD_NUMBER="1812785103" \
	BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
	DATE="$(DATE_FROM_FILE)" \
	PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
	PLATFORM_VERSION_LAST_STABLE="$(PLATFORM_VERSION_LAST_STABLE)" \
	PLATFORM_VERSION="$(PLATFORM_VERSION)" \
	TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
	bash $(BUILDINFO_COMMON_SH) "$(1)" >> $(2)
Endef

12、Build number版本号

build\make\tools\buildinfo.sh

echo "ro.build.display.id=$BUILD_DISPLAY_ID"

13、预置apk
device/softwinner/ceres/ceres_b6.mk
vendor/aw/public/prebuild/apk/MDM-30/
Android.mk

LOCAL_CERTIFICATE := platform

14、预置视频
android\packages\services\Mtp\src\com\android\mtp\CopyService.java

copyFile(new File("/system/video/Take Me To Your Heart.mp3"), new File("sdcard/Movies/Take Me To Your Heart.mp3"));

File f1 = new File("/data/data/copy_movie_flag");
Intent scanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
scanIntent.setData(Uri.fromFile(new File("mnt/sdcard/Movies/Take Me To Your Heart.mp3")));

android\device\softwinner\ceres\ceres_b6.mk

# video
PRODUCT_COPY_FILES += $(PRODUCT_DEVICE_PATH)/system/Take Me To Your Heart.mp3:system/video/Take Me To Your Heart.mp3

15、WiFi名称
frameworks/base/packages/SettingsProvider/res/values/defaults.xml

<string name="def_wifi_direct_name" translatable="false">product_name</string>

16、客户要求默认亮度为80%

92 =》 80%

frameworks\base\core\res\res\values\config.xml

<integer name="config_screenBrightnessSettingDefault">92</integer>

device/rockchip/common/overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml

   <integer name="def_screen_brightness">92</integer>

17、横屏状态下,桌面的APK图标的名称packages/apps/Launcher3/src/com/android/launcher3/DeviceProfile.java

-            adjustToHideWorkspaceLabels();
+            //adjustToHideWorkspaceLabels();

18、音量加减互换
frameworks/base/data/keyboards/qwerty.kl
frameworks/base/data/keyboards/Generic.kl

key 114   VOLUME_UP
key 115   VOLUME_DOWN

19、热点默认名称
frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiApConfigStore.java

private SoftApConfiguration getDefaultApConfiguration() {
SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder();
configBuilder.setBand(SoftApConfiguration.BAND_2GHZ);
configBuilder.setSsid(mContext.getResources().getString(R.string.wifi_tether_configure_ssid_default) + "_" + getRandomIntForDefaultSsid());

以上注释掉+ “_” + getRandomIntForDefaultSsid()
frameworks/base/core/res/res/values/config.xml

<string name="wifi_tether_configure_ssid_default" translatable="false">新热点名</string>

20、wifi直连名称
android\frameworks\opt\net\wifi\service\java\com\android\server\wifi\p2p\WifiP2pServiceImpl.java

private String getPersistedDeviceName() {
            String deviceName = mSettingsConfigStore.get(WIFI_P2P_DEVICE_NAME);
            if (deviceName == null) {
                // We use the 4 digits of the ANDROID_ID to have a friendly
                // default that has low likelihood of collision with a peer
                String id = mFrameworkFacade.getSecureStringSetting(mContext,
                        Settings.Secure.ANDROID_ID);
                return "KidsTAB7";//+ id.substring(0, 4);
            }
            return deviceName;
        }

21、导航栏7列变4列
android\device\softwinner\ceres\common\overlay\overlay_go_2gb\packages\apps\Launcher3\go\res\xml

 <grid-option
        launcher:name="5_by_6"
        launcher:numRows="5"
        launcher:numColumns="6"
        launcher:numFolderRows="4"
        launcher:numFolderColumns="5"
        launcher:numHotseatIcons="4"
        launcher:dbFile="launcher_5_by_6.db"
        launcher:defaultLayoutId="@xml/default_workspace_5x6" >

22、取消谷歌包对apk的影响
android\vendor\aw\public\package\apk\Update
Android.mk文件改名(此处改为Android1.mk),让系统读取不到谷歌包中的该文件
android\device\softwinner\ceres\common\gms\config.mk
23、去掉通话apk信息apk
android\vendor\partner_gms\products\google_go_comms_suite.mk
android\vendor\partner_gms\apps_go\

24、修改Launcher3的Hotseat的位置到右侧的方法
把文件android/packages/apps/Launcher3/res/values-sw720dp/config.xml中的hotseat_transpose_layout_with_orientation由false改为true

/25、壁纸居中
Z:\disk04\zjh_work\MZ\A133_r0\android\frameworks\base\core\java\android\app\WallpaperManager.java

26、Fail修改地址
Z:\disk04\zjh_work\MZ\A133_r0\android\frameworks\base\cmds\am\src\com\android\commands\am\Instrument.java

27、丽色模式对比度最小值
android\packages\apps\Settings\src\com\android\settings\display\AwEnhanceModePreferenceController.java

mContrast.setMin(10);

28、指纹
android\build\make\core\Makefile

29、查看指纹
android\out\target\product\ceres-b6\debug_ramdisk\prop.default
30、OTA差分包
在这里插入图片描述

android\build\tools\releasetools\ota_from_target_files

androidgroup06@androidgroup06:~android$ ota_from_target_files -i ota/smr/ceres_b6-signed_target_files-eng.androidgroup06.zip ota/gms/ceres_b6-signed_target_files-eng.androidgroup06.zip update.zip
需要先把out目录下的lib和framework放到build/tools目录下才能编译

ota_from_target_files -i [target_file_v1.zip] [target_file_v1.zip] ota_inc.zip
[target_file_v1.zip] 表示经过签名的版本V1的TargetFile
[target_file_v1.zip] 表示经过签名的版本V1的TargetFile
[ota_inc.zip] 表示命令输出得到的OTA差分包

Z:\disk04\zjh_work\MZ\A133_r0\android\longan\device\config\chips\a133\configs\b6\sys_config.fex
[dram_para2]
;lpddr4 单200ball 特别注意:使用LPDDR4颗粒的时候,1080P方案的DRAM频率要792M
dram_clk = 768

31、去掉紧急呼叫
在这里插入图片描述

android\frameworks\base\core\res\res\values\config.xml

<!--<item>emergency</item>-->

android\frameworks\base\packages\SystemUI\src\com\android\systemui\globalactions\GlobalActionsDialog.java

//addIfShouldShowAction(tempActions, new EmergencyDialerAction());

//return new EmergencyDialerAction();

在这里插入图片描述

33、编译报错

FAILED: build/make/core/Makefile:49: error: overriding commands for
target `out/target/product/ceres-b6/product/etc/sysconfig/google.xml’,
previously defined at build/make/core/base_rules.mk:492 14:30:03 ckati
failed with: exit status 1

android\vendor\partner_gms\products\gms_go.mk

# Workaround for b/138542583
PRODUCT_COPY_FILES += $(ANDROID_PARTNER_GMS_HOME)/etc/sysconfig/google_go.xml:$(TARGET_COPY_OUT_PRODUCT)/etc/sysconfig/google_go.xml

根据需求表里的GMS Express+来看,如果GMS Express+是则为gms-express.xml,如果如果GMS Express+空则为google_go.xml

34、oem锁灰色
android\vendor\partner_gms\products\gms_go.mk
加上OobConfig

PRODUCT_PACKAGES := \
    AndroidPlatformServices \
    ConfigUpdater \
    GoogleExtShared \
    GoogleFeedback \
    GoogleLocationHistory \
    GoogleOneTimeInitializer \
    GooglePackageInstaller \
    GooglePartnerSetup \
    GooglePrintRecommendationService \
    GoogleRestore \
    GoogleServicesFramework \
    GoogleSpeechServices \
    GoogleCalendarSyncAdapter \
    GoogleContactsSyncAdapter \
    GoogleTTS \
    GmsCoreGo \
    Phonesky \
    SetupWizard \
    WebViewGoogle \
    Wellbeing \
	OobConfig

加上OobConfig
35、定义2GB
android\device\softwinner\ceres\ceres_b6.mk

diff --git a/android/device/softwinner/ceres/ceres_b6.mk 
b/android/device/softwinner/ceres/ceres_b6.mk
index a0c7613be0..9d2136c6c0 100644
--- a/android/device/softwinner/ceres/ceres_b6.mk
+++ b/android/device/softwinner/ceres/ceres_b6.mk
@@ -15,6 +15,7 @@ PRODUCT_DEVICE_PATH := $(PRODUCT_PLATFORM_PATH)/$(PRODUCT_DEVICE)
 CONFIG_LOW_RAM_DEVICE := true
 CONFIG_SUPPORT_GMS := true
 CONFIG_OTA_FROM_10 := false
+CONFIG_LOW_RAM_2GB_DEVICE := true
 
 
 PRODUCT_COPY_FILES += $(PRODUCT_PREBUILT_PATH)/bImage:kernel

36、Client-id(在这里插入图片描述) 不能为空
Z:\disk04\zjh_work\JH\android\vendor\partner_gms\products\gms_go_2gb.mk
setupwizard.theme=glif_v3_light
ro.com.google.clientidbase=android-along
ro.opa.eligible_device=true \

37、修改电池曲线3000mA
Z:\disk01\A100R\ChengFeng_V2.2\android\longan\device\product\configs\c70w\board.dts

pmu_battery_rdc= <120>;
			pmu_battery_cap = <3000>;
			pmu_runtime_chgcur = <1200>;
			pmu_suspend_chgcur = <1650>;
			pmu_shutdown_chgcur = <1650>;

38、修改分辨率
Z:\disk04\zjh_work\MZ\A133_r0\android\device\softwinner\ceres\ceres-b6\camera\camera.cfg
在这里插入图片描述

39、常见fail

"android.media.cts.MediaPlayerTest#testRecordedVideoPlayback0",
"android.media.cts.MediaPlayerTest#testRecordedVideoPlayback180",
"android.media.cts.MediaPlayerTest#testRecordedVideoPlayback270",
"android.media.cts.MediaPlayerTest#testRecordedVideoPlayback90",

40、安全补丁日期
Z:\disk01\A100R\ChengFeng_V2.2\android\build\make\core\version_defaults.mk

 PLATFORM_SECURITY_PATCH := 2021-12-05

41、制作patch
./makepatch.sh 序列号1 序列号2
42、过SMR需要的OS
android\build\make\tools\buildinfo.sh

echo "ro.build.version.base_os=$PLATFORM_BASE_OS"
  • 2
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Contents About the Author...............................................................................................xix About the Technical Reviewer and Contributing Author.................xxi Chapter1 Apache and the Internet..............................................1 Apache: The Anatomy of a Web Server.........................................................1 The Apache Source .............................................................................................1 The Apache License............................................................................................1 Support for Apache.............................................................................................2 How Apache Works..............................................................................................3 The Hypertext Transfer Protocol..................................................................7 HTTP Requests and Responses..........................................................................7 HTTP Headers...................................................................................................12 Networking and TCP/IP......................................................................................13 Definitions.........................................................................................................13 Packets and Encapsulation...............................................................................14 ACKs, NAKs, and Other Messages....................................................................15 The TCP/IP Network Model.............................................................................16 Non-IP Protocols...............................................................................................19 IP Addresses and Network Classes...................................................................19 Special IP Addresses..........................................................................................20 Netmasks and Routing......................................................................................21 Web Services: Well-Known Ports......................................................................23 Internet Daemon: The Networking Super Server...........................................24 The Future: IPv6................................................................................................25 Networking Tools...............................................................................................26 Server Hardware...................................................................................................29 Supported Platforms.........................................................................................29 Basic Server Requirements...............................................................................30 Memory..............................................................................................................31 Network Interface..............................................................................................32 Internet Connection.........................................................................................32 Hard Disk and Controller.................................................................................33 Operating System Checklist.............................................................................33 Redundancy and Backup..................................................................................34 Specific Hardware Solutions............................................................................35 Get Someone Else to Do It.............................................................................36 Summary....................................................................................................................36 v 3006_Ch00_CMP2 12/14/03 8:56 AM Page v Chapter 2 Getting Started with Apache.................................37 Installing Apache..............................................................................................38 Getting Apache..................................................................................................38 Installing Apache from Binary Distribution....................................................39 Installing Apache from Source.........................................................................41 Installing Apache from Prebuilt Packages.......................................................41 Installing Apache by Hand...............................................................................45 Upgrading Apache.............................................................................................47 Other Issues.......................................................................................................49 Basic Configuration..........................................................................................50 Decisions............................................................................................................50 Introducing the Master Configuration File.....................................................55 Other Basic Configuration Directives..............................................................56 Starting, Stopping, and Restarting the Server.................................57 Starting Apache on Unix...................................................................................58 Starting Apache on Windows...........................................................................59 Invocation Options...........................................................................................60 Restarting the Server.........................................................................................73 Stopping the Server...........................................................................................75 Starting the Server Automatically....................................................................76 Testing the Server............................................................................................81 Testing with a Browser......................................................................................82 Testing from the Command Line or a Terminal Program..............................82 Testing the Server Configuration Without Starting It.....................................85 Getting the Server Status from the Command Line.......................................86 Using Graphical Configuration Tools.......................................................86 Comanche..........................................................................................................87 TkApache...........................................................................................................91 LinuxConf..........................................................................................................91 Webmin..............................................................................................................91 ApacheConf.......................................................................................................97 Other Configuration Tools................................................................................99 Summary..................................................................................................................100 Chapter 3 Building Apache the Way You Want It...........101 Why Build Apache Yourself?.........................................................................101 Verifying the Apache Source Archive.............................................................103 Building Apache from Source......................................................................105 Configuring and Building Apache.................................................................106 Determining Which Modules to Include.......................................................111 Building Apache As a Dynamic Server..........................................................116 Contents vi 3006_Ch00_CMP2 12/14/03 8:56 AM Page vi Changing the Module Order (Apache 1.3)....................................................118 Checking the Generated Configuration........................................................120 Building Apache from Source As an RPM (Apache 2)..................................122 Advanced Configuration.................................................................................124 Configuring Apache’s Layout..........................................................................124 Choosing a Layout Scheme............................................................................124 Choosing a Multiprocessing Module (Apache 2)..........................................132 Rules (Apache 1.3)...........................................................................................135 Building Apache with suExec support...........................................................137 Configuring Apache’s Supporting Files and Scripts.....................................139 Configuring Apache 2 for Cross-Platform Builds.........................................140 Configuring Apache for Production or Debug Builds..................................142 Configuring Apache for Binary Distribution.................................................143 Configuring Apache’s Library and Include Paths..........................................143 Configuring the Build Environment.........................................................144 Building Modules with configure and apxs..........................................146 Adding Third-Party Modules with configure................................................146 Building Modules with apxs...........................................................................148 Installing Modules with apxs..........................................................................150 Generating Module Templates with apxs......................................................151 Overriding apxs Defaults and Using apxs in makefiles................................152 Summary..................................................................................................................153 Chapter 4 Configuring Apache the Way You Want It...155 Where Apache Looks for Its Configuration..........................................155 Configuration File Syntax...............................................................................156 Configuration for Virtual Hosts......................................................................156 Including Multiple Configuration Files.........................................................157 Per-Directory Configuration..........................................................................159 Conditional Configuration.............................................................................160 How Apache Structures Its Configuration............................................163 Apache’s Container Directives........................................................................164 Directive Types and Locations.......................................................................168 Where Directives Can Go................................................................................171 Container Scope and Nesting.........................................................................172 How Apache Combines Containers and Their Contents.............................174 Legality of Directives in Containers...............................................................175 Options and Overrides....................................................................................176 Enabling and Disabling Features with Options............................................176 Overriding Directives with Per-Directory Configuration.............................179 Contents vii 3006_Ch00_CMP2 12/14/03 8:56 AM Page vii Restricting Access with allow and deny..............................................182 Controlling Access by Name...........................................................................183 Controlling Access by IP Address...................................................................184 Controlling Subnet Access by Network and Netmask..................................185 Controlling Access by HTTP Header.............................................................186 Combining Host-Based Access with User Authentication...........................187 Overriding Host-Based Access.......................................................................188 Directory Listings..........................................................................................188 Enabling and Disabling Directory Indices....................................................189 How mod_autoindex Generates the HTML Page.........................................190 Controlling Which Files Are Seen with IndexIgnore.....................................196 Controlling the Sort Order..............................................................................197 Assigning Icons................................................................................................199 Assigning Descriptions...................................................................................202 Apache’s Environment......................................................................................203 Setting, Unsetting, and Passing Variables from the Shell.............................204 Setting Variables Conditionally......................................................................205 Special Browser Variables...............................................................................207 Detecting Robots with BrowserMatch...........................................................209 Passing Variables to CGI.................................................................................209 Conditional Access Control............................................................................210 Caveats with SetEnvIf vs. SetEnv....................................................................210 Setting Variables with mod_rewrite...............................................................211 Controlling Request and Response Headers..........................................211 Setting Custom Response Headers................................................................213 Setting Custom Request Headers...................................................................215 Inserting Dynamic Values into Headers........................................................216 Setting Custom Headers Conditionally.........................................................217 Retrieving Response Headers from Metadata Files......................................217 Setting Expiry Times.......................................................................................219 Sending Content As-Is....................................................................................222 Controlling the Server Identification Header.................................223 Sending a Content Digest.............................................................................224 Handling the Neighbors.................................................................................225 Controlling Robots with robots.txt................................................................226 Controlling Robots in HTML..........................................................................227 Controlling Robots with Access Control........................................................227 Attracting Robots.............................................................................................228 Making Sure Robots Index the Right Information........................................228 Known Robots, Bad Robots, and Further Reading.......................................229 Summary..................................................................................................................229 Contents viii 3006_Ch00_CMP2 12/14/03 8:56 AM Page viii Chapter 5 Deciding What the Client Needs........................231 Content Handling and Negotiation...........................................................231 File Types.........................................................................................................232 File Encoding...................................................................................................236 File Languages.................................................................................................243 File Character Sets...........................................................................................245 Handling URLs with Extra Path Information................................................247 Content Negotiation.......................................................................................248 Content Negotiation with MultiViews...........................................................250 File Permutations and Valid URLs with MultiViews.....................................256 Magic MIME Types..........................................................................................260 Error and Response Handling......................................................................264 How Apache Handles Errors...........................................................................265 Error and Response Codes.............................................................................265 The ErrorDocument Directive.......................................................................266 Limitations of ErrorDocument......................................................................270 Aliases and Redirection...............................................................................271 Aliases and Script Aliases................................................................................271 Redirections.....................................................................................................273 Rewriting URLs with mod_rewrite.................................................................277 Server-Side Image Maps.................................................................................300 Matching Misspelled URLS............................................................................305 Summary..................................................................................................................306 Chapter 6 Delivering Dynamic Content..................................307 Server-Side Includes......................................................................................308 Enabling SSI.....................................................................................................309 Format of SSI Commands...............................................................................311 The SSI Command Set....................................................................................312 SSI Variables.....................................................................................................312 Passing Trailing Path Information to SSIs (and Other Dynamic Documents).................................................................315 Setting the Date and Error Format.................................................................316 Templating with SSIs.......................................................................................317 Caching Server-Parsed Documents...............................................................319 Identifying Server-Parsed Documents by Execute Permission...................320 CGI: The Common Gateway Interface.........................................................321 CGI and the Environment..............................................................................321 Configuring Apache to Recognize CGI Scripts.............................................323 Setting Up a CGI Directory with ExecCGI: A Simple Way............................327 Triggering CGI Scripts on Events...................................................................330 Contents ix 3006_Ch00_CMP2 12/14/03 8:56 AM Page ix ISINDEX-Style CGI Scripts and Command Line Arguments................332 Writing and Debugging CGI Scripts.........................................................333 A Minimal CGI Script......................................................................................333 Interactive Scripts: A Simple Form................................................................337 Adding Headers...............................................................................................338 Debugging CGI Scripts....................................................................................339 Setting the CGI Daemon Socket.....................................................................345 Limiting CGI Resource Usage.........................................................................346 Actions, Handlers, and Filters................................................................347 Handlers...........................................................................................................348 Filters................................................................................................................354 Dynamic Content and Security....................................................................363 CGI Security Issues..........................................................................................363 Security Advice on the Web............................................................................364 Security Issues with Apache CGI Configuration...........................................364 An Example of an Insecure CGI Script..........................................................365 Known Insecure CGI Scripts...........................................................................370 CGI Wrappers...................................................................................................370 Security Checklist............................................................................................380 Inventing a Better CGI Script with FastCGI......................................381 Summary..................................................................................................................403 Chapter 7 Hosting More Than One Web Site........................405 Implementing User Directories with UserDir......................................406 Enabling and Disabling Specific Users..........................................................407 Redirecting Users to Other Servers................................................................408 Alternative Ways to Implement User Directories.........................................409 Separate Servers..............................................................................................410 Restricting Apache’s Field of View..................................................................411 Specifying Different Configurations and Server Roots................................412 Starting Separate Servers from the Same Configuration.............................412 Sharing External Configuration Files.............................................................413 IP-Based Virtual Hosting.............................................................................414 Multiple IPs, Separate Networks, and Virtual Interfaces..............................415 Configuring What Apache Listens To.............................................................416 Defining IP-Based Virtual Hosts.....................................................................418 Virtual Hosts and the Server-Level Configuration........................................421 Specifying Virtual Host User Privileges..........................................................422 Excluded Directives.........................................................................................426 Default Virtual Hosts....................................................................................427 Contents x 3006_Ch00_CMP2 12/14/03 8:56 AM Page x Name-Based Virtual Hosting.........................................................................428 Defining Named Virtual Hosts.......................................................................428 Server Names and Aliases...............................................................................430 Defining a Default Host for Name-Based Virtual Hosting...........................430 Mixing IP-Based and Name-Based Hosting..................................................431 Issues Affecting Virtual Hosting...........................................................434 Log Files and File Handles..............................................................................434 Virtual Hosts and Server Security..................................................................436 Secure HTTP and Virtual Hosts......................................................................437 Handling HTTP/1.0 Clients with Name-Based Virtual Hosts......................439 Dynamic Virtual Hosting...............................................................................441 Mass Hosting with Virtual-Host Aliases........................................................441 Mapping Hostnames Dynamically with mod_rewrite.................................448 Generating On the Fly and Included Configuration Files with mod_perl..449 Summary..................................................................................................................455 Chapter 8 Improving Apache’s Performance........................457 Apache’s Performance Directives..............................................................458 Configuring MPMs: Processes and Threads..................................................459 Network and IP-Related Performance Directives.........................................470 HTTP-Related Performance Directives.........................................................472 HTTP Limit Directives....................................................................................475 Configuring Apache for Better Performance........................................477 Directives That Affect Performance...............................................................477 Additional Directives for Tuning Performance.............................................482 Benchmarking Apache’s Performance.........................................................490 Benchmarking Apache with ab......................................................................490 Benchmarking Apache with gprof.................................................................495 External Benchmarking Tools........................................................................496 Benchmarking Strategy and Pitfalls...............................................................496 A Performance Checklist...............................................................................497 Proxying................................................................................................................498 Installing and Enabling Proxy Services..........................................................498 Normal Proxy Operation.................................................................................499 Configuring Apache As a Proxy......................................................................500 URL Matching with Directory Containers....................................................502 Blocking Sites via the Proxy............................................................................504 Localizing Remote URLs and Hiding Servers from View.............................504 Relaying Requests to Remote Proxies............................................................508 Proxy Chains and the Via Header...................................................................509 Proxies and Intranets......................................................................................512 Handling Errors...............................................................................................512 Contents xi 3006_Ch00_CMP2 12/14/03 8:56 AM Page xi Timing Out Proxy Requests............................................................................514 Tunneling Other Protocols.............................................................................514 Tuning Proxy Operations................................................................................515 Squid: A High-Performance Proxy Alternative.............................................516 Caching..................................................................................................................516 Enabling Caching............................................................................................516 File-Based Caching.........................................................................................517 In-Memory Caching (Apache 2 Only)............................................................520 Coordinating Memory-Based and Disk-Based Caches................................522 General Cache Configuration.........................................................................522 Maintaining Good Relations with External Caches......................................527 Fault Tolerance and Clustering................................................................529 Backup Server via Redirected Secondary DNS.............................................530 Load Sharing with Round-Robin DNS...........................................................531 Backup Server via Floating IP Address..........................................................531 Hardware Load Balancing..............................................................................532 Clustering with Apache...................................................................................533 Other Clustering Solutions.............................................................................536 Summary..................................................................................................................537 Chapter 9 Monitoring Apache.........................................................539 Logs and Logging..............................................................................................539 Log Files and Security.....................................................................................540 The Error Log...................................................................................................540 Setting the Log Level.......................................................................................541 Logging Errors to the System Log..................................................................542 Transfer Logs...................................................................................................544 Driving Applications Through Logs...............................................................554 Log Rotation....................................................................................................556 Lies, Logs, and Statistics.........................................................................560 What You Can’t Find Out from Logs...............................................................560 Analog: A Log Analyzer...................................................................................561 Server Information..........................................................................................577 Server Status....................................................................................................578 Server Info........................................................................................................581 Securing Access to Server Information.........................................................582 User Tracking.....................................................................................................583 Alternatives to User Tracking.........................................................................584 Cookie Tracking with mod_usertrack............................................................584 URL Tracking with mod_session....................................................................589 Other Session Tracking Options.....................................................................594 Summary..................................................................................................................595 Contents xii 3006_Ch00_CMP2 12/14/03 8:56 AM Page xii Chapter 10Securing Apache..............................................................597 User Authentication........................................................................................597 Apache Authentication Modules...................................................................598 Authentication Configuration Requirements...............................................599 Using Authentication Directives in .htaccess...............................................601 Basic Authentication.......................................................................................601 Digest Authentication.....................................................................................603 Anonymous Authentication...........................................................................606 Setting Up User Information..........................................................................606 Specifying User Requirements.......................................................................614 LDAP Authentication......................................................................................617 Using Multiple Authentication Schemes.......................................................624 Combining User- and Host-Based Authentication......................................626 Securing Basic Authentication with SSL.......................................................627 SSL and Apache...................................................................................................627 Downloading OpenSSL and ModSSL............................................................628 Building and Installing the OpenSSL Library...............................................629 Building and Installing mod_ssl for Apache 2..............................................633 Building and Installing mod_ssl for Apache 1.3...........................................633 Basic SSL Configuration.................................................................................637 Installing a Private Key....................................................................................639 Creating a Certificate Signing Request and Temporary Certificate.............640 Getting a Signed Certificate............................................................................642 Advanced SSL Configuration.........................................................................644 Server-Level Configuration............................................................................644 Client Certification..........................................................................................657 Using Client Certification with User Authentication..................659 SSL and Logging..............................................................................................660 SSL Environment Variables and CGI.............................................................662 SSL and Virtual Hosts......................................................................................666 Advanced Features..........................................................................................668 Summary..................................................................................................................671 Chapter 11Improving Web Server Security..........................673 Apache Features.................................................................................................673 Unwanted Files................................................................................................674 Automatic Directory Indices..........................................................................674 Symbolic Links................................................................................................675 Server-Side Includes.......................................................................................676 ISINDEX-Style CGI Scripts.............................................................................677 Server Tokens...................................................................................................677 Contents xiii 3006_Ch00_CMP2 12/14/03 8:56 AM Page xiii File Permissions..............................................................................................678 Viewing Server Information with mod_info..........................................679 Restricting Server Privileges..................................................................679 Restricting Access by Hostname and IP Address...............................680 Other Server Security Measures................................................................682 Dedicated Server..............................................................................................682 File Integrity...................................................................................................683 md5sum...........................................................................................................684 Tripwire............................................................................................................685 Hardening the Server......................................................................................686 Minimizing Services........................................................................................686 Port Scanning with nmap ..............................................................................688 Probing with Nessus.......................................................................................689 Hardening Windows 2000 and XP..................................................................689 Disabling Network Services.........................................................................690 File Transfer Protocol (FTP)............................................................................690 telnet................................................................................................................690 rlogin, rsh, rexec, rcp.......................................................................................690 Network Filesystem (NFS)..............................................................................690 sendmail/Other Mail Transport Agents (MTAs)...........................................691 Restricting Services with TCP Wrappers........................................................691 Security Fixes, Alerts, and Online Resources.................................693 The WWW Security FAQ..................................................................................693 The BugTraQ Mailing List and Archive..........................................................693 Operating System Newsletters.......................................................................693 Package and Module Notification..................................................................694 Removing Important Data from the Server............................................694 Enabling Secure Logins with SSH..............................................................694 Building and Installing OpenSSH..................................................................695 Authentication Strategies...............................................................................698 Configuring SSH..............................................................................................699 Testing SSH......................................................................................................702 Expanding SSH to Authenticate Users..........................................................703 Secure Server Backups with Rsync and SSH.................................................704 Forwarding Client Connections to Server Applications...............................705 Firewalls and Multifacing Servers.........................................................706 Types of Firewall..............................................................................................706 Designing the Network Topology...................................................................707 Running Apache Under a Virtual chroot Root Directory................709 What chroot Is.................................................................................................709 What chroot Isn’t.............................................................................................710 Setting Up Apache for chroot Operation.......................................................711 Contents xiv 3006_Ch00_CMP2 12/14/03 8:56 AM Page xiv Server Security Checklist...........................................................................723 Avoid Root Services.........................................................................................723 Maintain Logs Properly..................................................................................723 Keep It Simple..................................................................................................724 Block Abusive Clients......................................................................................724 Have an Effective Backup and Restore Process............................................725 Plan for High Availability, Capacity, and Disaster Recovery........................725 Monitor the Server..........................................................................................725 Take Care with Information Flow...................................................................726 Choose an Effective robots.txt Policy............................................................726 Summary..................................................................................................................726 Chapter 12Extending Apache............................................................727 WebDAV....................................................................................................................727 Adding WebDAV to Apache.............................................................................728 The WebDAV Protocol.....................................................................................729 Configuring Apache for WebDAV...................................................................731 Restricting Options and Disabling Overrides...............................................734 WebDAV and Virtual Hosts.............................................................................735 Configuring the DAV Lock Time.....................................................................735 Limitations of File-Based Repositories..........................................................736 Protecting WebDAV Servers............................................................................737 More Advanced Configurations.....................................................................737 Cooperating with CGI and Other Content Handlers....................................740 ISAPI......................................................................................................................741 Supported ISAPI Support Functions.............................................................742 Configuring ISAPI Extensions........................................................................743 Setting the Maximum Initial Request Data Size...........................................744 Logging ISAPI Extensions...............................................................................745 Preloading and Caching ISAPI Extensions....................................................746 Handling Asynchronous ISAPI Extensions...................................................746 Perl.........................................................................................................................746 Building and Installing mod_perl..................................................................748 Migrating mod_perl from Apache 1.3 to Apache 2.......................................755 Configuring and Implementing Perl Handlers.............................................758 Configuring and Implementing Perl Filters..................................................771 Warnings, Taint Mode, and Debugging.........................................................772 Managing Perl Threads in mod_perl 2...........................................................774 Initializing Modules at Startup.......................................................................779 Restarting mod_perl and Auto-Reloading Modules.....................................780 Creating a mod_perl Status Page...................................................................782 Running CGI Scripts Under mod_perl..........................................................782 Contents xv 3006_Ch00_CMP2 12/14/03 8:56 AM Page xv CGI Caveats......................................................................................................785 Passing Variables to Perl Handlers.................................................................787 Using mod_perl with Server-Side Includes...................................................788 Embedding Perl in HTML...............................................................................789 Embedding Perl in Apache’s Configuration..................................................794 PHP...........................................................................................................................795 Installing PHP..................................................................................................796 Getting the PHP source...................................................................................796 Configuring Apache to Work with PHP..........................................................802 Configuring PHP.............................................................................................803 Testing PHP with Apache................................................................................807 Tomcat/Java.........................................................................................................807 So What Is Tomcat?..........................................................................................807 Installation.......................................................................................................808 Tomcat Configuration.....................................................................................813 mod_jk.............................................................................................................818 Mod_python....................................................................................................829 mod_ruby.........................................................................................................835 Summary..................................................................................................................839 Index....................................................................................................................843
重载与覆写/重写的区别 区别 重载 覆写 1 单词 OverLoading Override 2 概念 方法名称相同,参数的类型或个数不同 方法名称相同,参数的类型或个数相 同,返回值类型相同 3 范围 发生在一个类之中 发生在类的继承关系中 4 权限 一个类中所重载多个方法可以不同的权限 被子类所覆写的方法不能拥有比父类更严格 的访问控制权限 重载可以改变返回值类型,但是这样做没有任何的意义, 可是对于覆写而言,绝对不能修改返回值类型,但是在子类中所覆写的方法应该可以继续进行重载。 重载(Overloading)  (1) 方法重载是让类以统一的方式处理不同类型数据的一种手段。多个同名函数同时存在,具有不同的参数个数/类型。   重载Overloading是一个类中多态性的一种表现。 (2) Java的方法重载,就是在类中可以创建多个方法,它们具有相同的名字,但具有不同的参数和不同的定义。   调用方法时通过传递给它们的不同参数个数和参数类型来决定具体使用哪个方法, 这就是多态性。 (3) 重载的时候,方法名要一样,但是参数类型和个数不一样,返回值类型可以相同也可以不相同。     无法以返回值类型作为重载函数的区分标准。 复制代码 /** * 1. 方法重载只可以通过方法名和方法参数来区别,即“方法签名” * @return * @throws NumberFormatException */ public int getSides(Object obj) throws NumberFormatException { return 1; } /** * 2. 不能通过访问权限,返回类型,异常列表进行重载 * * 下面方式错误! */ private Object getSides() throws NumberFormatException, Exception { return 1; } /** * 3. 方法异常类型和数目不会对重载造成影响。 * 下面方式错误! */ public int getSides() throws NumberFormatException, IndexOutOfBoundsException, Exception { } 复制代码 重写(Overriding) (1) 父类与子类之间的多态性,对父类的函数进行重新定义。   如果在子类中定义某方法与其父类有相同的名称和参数,我们说该方法被重写 (Overriding)。   在Java中,子类可继承父类中的方法,而不需要重新编写相同的方法。   但有时子类并不想原封不动地继承父类的方法,而是想作一定的修改,这就需要采用方法的重写。   方法重写又称方法覆盖。 (2)若子类中的方法与父类中的某一方法具有相同的方法名、返回类型和参数表,则新方法将覆盖原有的方法。   如需父类中原有的方法,可使用super关键字,该关键字引用了当前类的父类。 (3)子类函数的访问修饰权限不能小于父类的;  多态性是面向对象编程的一种特性,和方法无关, 简单说,就是同样的一个方法能够根据输入数据的不同,做出不同的处理,   即方法的重载——有不同的参数列表(静态多态性)   而当子类继承自父类的相同方法,输入数据一样,但要做出有别于父类的响应时,你就要覆盖父类方法, 即在子类中重写该方法——相同参数,不同实现(动态多态性) 复制代码 public class Base { void test(int i) { System.out.print(i); } void test(byte b) { System.out.print(b); } } public class Dog extends Base { void test(int i) { i++; System.out.println(i); } public static void main(String[] agrs) { Base b = new Dog(); b.test(0); b.test((byte) 0); } } 复制代码 这时的输出结果是1 0,这是运行时动态绑定的结果。   简单说来重写就是子类对父类(层级上)中非私有成员方法的重新功能定义。 复制代码 // begin /** * 1. 重写方法必须和被重写方法的“方法签名”一致,即方法名+参数必须相同 */ public int getSides() { return 3; } // end // begin /** * 1. 重写方法访问修饰符一定要大于被重写方法访问修饰符 * (public > protected > default > private) * * 原因: * 2. 有一个可以装1升水的瓶子;你需要用另一个瓶子去继承它, 那你觉得你能用一个半升谁的瓶子继承他吗? */ /** * @return * 本方法重写方式错误 */ // protected int getSides() { // return 3; // } /** * 对父类Shape中getSide方法进行重写,实现多态 * @return */ public int getSides() { return 3; } // end // begin /** * 3. 重写和被重写方法返回值必须相同 * 此方法错误 */ // public double getSides() { // return 3d; // } // end // begin /** * 4. 重写方法抛出的异常必须和被重写方法抛出异常一致,或者是其子类 * 详细见:overrideexception包中例子 */ public int getSides() throws NullPointerException { return 3; } // end /** * 5. 父类中private方法不能被子类重写,因为private只有父类本类可见。 */ /** * 6. 静态方法不存在重写概念,重写是面向对象特性,静态方法是类方法,用类名直接访问。 */ 复制代码
好的,我来给你提供一些关于Android Studio的笔记。 1. Android Studio的介绍: - Android Studio是由Google推出的官方Android开发集成开发环境(IDE),用于开发Android应用程序。 - 它基于IntelliJ IDEA开发,提供了丰富的功能和工具,方便开发者进行Android应用程序的开发、调试和测试。 2. Android Studio的安装: - 在官方网站(https://developer.android.com/studio)上下载最新版本的Android Studio。 - 执行安装程序,并按照安装向导的指示进行操作。 - 安装完成后,启动Android Studio并进行必要的配置。 3. Android Studio的主要功能: - 提供了强大的代码编辑器,支持代码补全、语法高亮、代码重构等功能。 - 可以通过布局编辑器(Layout Editor)创建和编辑Android应用程序的用户界面。 - 集成了Android SDK工具,可以方便地管理安卓设备、模拟器以及APK包等。 - 提供了丰富的调试工具,如代码调试器、内存分析器、性能分析器等。 - 支持版本控制系统(如Git)的集成,方便团队协作开发。 4. Android Studio常用操作: - 创建一个新项目:选择"File" -> "New" -> "New Project",按照向导填写项目信息,即可创建一个新的Android项目。 - 打开现有项目:选择"File" -> "Open" -> 选择项目文件夹,即可打开一个已存在的Android项目。 - 运行应用程序:选择"Run" -> "Run 'app'",选择目标设备后即可在设备上运行应用程序。 - 调试应用程序:在代码中设置断点,选择"Debug" -> "Debug 'app'",即可启动调试模式并在代码中进行调试。 - 通过布局编辑器创建UI界面:在res目录下的layout文件夹中选择一个布局文件,然后使用布局编辑器进行UI界面的设计和编辑。 这些是Android Studio的一些基本信息和常用操作。希望对你有帮助!如果你还有其他问题,可以继续问我。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值