1,自定义书签
此功能可以利用Android AOSP现有source实现
android/packages/providers/PartnerBookmarksProvider/src/com/android/providers/partnerbookmarks/PartnerBookmarksProvider.java
只需要修改:android/packages/providers/PartnerBookmarksProvider/res/values/
strings.xml
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <string name="bookmarks_folder_name" translatable="false">Partner Bookmarks</string> <string-array name="bookmarks" > <item>Baidu</item> <item>http://www.baidu.com/</item> </string-array> </resources>
bookmarks_icons.xml
<resources> <array name="bookmark_preloads" > <item>@raw/a</item> </array> </resources>
2,主页配置
可以集成网上成熟的apk,这里附加了地址;https://download.csdn.net/download/baidu_40808339/13010204
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
// Package path can be changed, but should match <manifest package="..."> in AndroidManifest.xml. package com.android.partnerbrowsercustomizations.example;
import android.content.ContentProvider; import android.content.ContentValues; import android.content.UriMatcher; import android.database.Cursor; import android.database.MatrixCursor; import android.net.Uri;
// Class name can be changed, but should match <provider android:name="..."> in AndroidManifest.xml. public class PartnerHomepageProviderExample extends ContentProvider { // "http://www.android.com/" is just an example. Please replace this to actual homepage. // Other strings in this class must remain as it is. private static String HOMEPAGE_URI = "http://www.baidu.com"; private static final int URI_MATCH_HOMEPAGE = 0; private static final UriMatcher URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH); static { URI_MATCHER.addURI("com.android.partnerbrowsercustomizations", "homepage", URI_MATCH_HOMEPAGE); }
@Override public boolean onCreate() { return true; }
@Override public String getType(Uri uri) { // In fact, Chrome does not call this. // Just a recommaned ContentProvider practice in general. switch (URI_MATCHER.match(uri)) { case URI_MATCH_HOMEPAGE: return "vnd.android.cursor.item/partnerhomepage"; default: return null; } }
@Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { switch (URI_MATCHER.match(uri)) { case URI_MATCH_HOMEPAGE: MatrixCursor cursor = new MatrixCursor(new String[] { "homepage" }, 1); cursor.addRow(new Object[] { HOMEPAGE_URI }); return cursor; default: return null; } }
@Override public Uri insert(Uri uri, ContentValues values) { throw new UnsupportedOperationException(); }
@Override public int delete(Uri uri, String selection, String[] selectionArgs) { throw new UnsupportedOperationException(); }
@Override public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { throw new UnsupportedOperationException(); }
}
可以直接安装这个apk,集成在system\priv-app\HomePage即可。
谢谢。
