diff options
29 files changed, 864 insertions, 432 deletions
diff --git a/core/java/android/provider/Im.java b/core/java/android/provider/Im.java index b11abe8..b1cf648 100644 --- a/core/java/android/provider/Im.java +++ b/core/java/android/provider/Im.java @@ -1620,6 +1620,9 @@ public class Im { /** specifies the last heartbeat interval received from the server */ public static final String SETTING_HEARTBEAT_INTERVAL = "heartbeat_interval"; + /** specifiy the JID resource used for Google Talk connection */ + public static final String SETTING_JID_RESOURCE = "jid_resource"; + /** * Used for reliable message queue (RMQ). This is for storing the last rmq id received * from the GTalk server @@ -1861,6 +1864,14 @@ public class Im { putLongValue(contentResolver, providerId, SETTING_HEARTBEAT_INTERVAL, interval); } + /** + * A convenience method to set the jid resource. + */ + public static void setJidResource(ContentResolver contentResolver, + long providerId, String jidResource) { + putStringValue(contentResolver, providerId, SETTING_JID_RESOURCE, jidResource); + } + public static class QueryMap extends ContentQueryMap { private ContentResolver mContentResolver; private long mProviderId; @@ -2047,6 +2058,23 @@ public class Im { } /** + * Set the JID resource. + * + * @param jidResource the jid resource to be stored. + */ + public void setJidResource(String jidResource) { + ProviderSettings.setJidResource(mContentResolver, mProviderId, jidResource); + } + /** + * Get the JID resource used for the Google Talk connection + * + * @return the JID resource stored. + */ + public String getJidResource() { + return getString(SETTING_JID_RESOURCE, null); + } + + /** * Convenience function for retrieving a single settings value * as a boolean. * diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 85a2041..d3e4c4c 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -413,8 +413,6 @@ public final class Settings { private static final String TAG = "Settings"; - private static String sJidResource = null; - public static class SettingNotFoundException extends AndroidException { public SettingNotFoundException(String msg) { super(msg); @@ -3622,42 +3620,6 @@ public final class Settings { } /** - * Returns the GTalk JID resource associated with this device. - * - * @return String the JID resource of the device. It uses the device IMEI in the computation - * of the JID resource. If IMEI is not ready (i.e. telephony module not ready), we'll return - * an empty string. - * @hide - */ - // TODO: we shouldn't not have a permenant Jid resource, as that's an easy target for - // spams. We should change it once a while, like when we resubscribe to the subscription feeds - // server. - // (also, should this live in GTalkService?) - public static synchronized String getJidResource() { - if (sJidResource != null) { - return sJidResource; - } - - MessageDigest digest; - try { - digest = MessageDigest.getInstance("SHA-1"); - } catch (NoSuchAlgorithmException e) { - throw new RuntimeException("this should never happen"); - } - - String deviceId = TelephonyManager.getDefault().getDeviceId(); - if (TextUtils.isEmpty(deviceId)) { - return ""; - } - - byte[] hashedDeviceId = digest.digest(deviceId.getBytes()); - String id = new String(Base64.encodeBase64(hashedDeviceId), 0, 12); - id = id.replaceAll("/", "_"); - sJidResource = JID_RESOURCE_PREFIX + id; - return sJidResource; - } - - /** * Returns the device ID that we should use when connecting to the mobile gtalk server. * This is a string like "android-0x1242", where the hex string is the Android ID obtained * from the GoogleLoginService. diff --git a/core/java/android/webkit/CallbackProxy.java b/core/java/android/webkit/CallbackProxy.java index 96bf46e..e77d29b 100644 --- a/core/java/android/webkit/CallbackProxy.java +++ b/core/java/android/webkit/CallbackProxy.java @@ -70,6 +70,9 @@ class CallbackProxy extends Handler { private final WebBackForwardList mBackForwardList; // Used to call startActivity during url override. private final Context mContext; + // Stores the URL being loaded and the viewing mode to switch into when + // the URL finishes loading. + private ChangeViewModeOnFinishedLoad mChange; // Message Ids private static final int PAGE_STARTED = 100; @@ -177,6 +180,37 @@ class CallbackProxy extends Handler { } /** + * Tell the host application that the WebView has changed viewing modes. + * @param toZoomedOut If true, the WebView has zoomed out so that the page + * fits the screen. If false, it is zoomed to the setting + * specified by the user. + */ + /* package */ void uiOnChangeViewingMode(boolean toZoomOverview) { + if (mWebChromeClient != null) { + mWebChromeClient.onChangeViewingMode(toZoomOverview); + } + } + + private static class ChangeViewModeOnFinishedLoad { + boolean mToZoomOverView; + String mOriginalUrl; + ChangeViewModeOnFinishedLoad(boolean toZoomOverview, + String originalUrl) { + mToZoomOverView = toZoomOverview; + mOriginalUrl = originalUrl; + } + } + + /** + * Keep track of the url and the viewing mode to change into. If/when that + * url finishes loading, this will change the viewing mode. + */ + /* package */ void uiChangeViewingModeOnFinishedLoad( + boolean toZoomOverview, String originalUrl) { + if (mWebChromeClient == null) return; + mChange = new ChangeViewModeOnFinishedLoad(toZoomOverview, originalUrl); + } + /** * Called by the UI side. Calling overrideUrlLoading from the WebCore * side will post a message to call this method. */ @@ -237,6 +271,15 @@ class CallbackProxy extends Handler { if (mWebViewClient != null) { mWebViewClient.onPageFinished(mWebView, (String) msg.obj); } + if (mChange != null) { + if (mWebView.getOriginalUrl().equals(mChange.mOriginalUrl)) { + uiOnChangeViewingMode(mChange.mToZoomOverView); + } else { + // The user has gone to a different page, so there is + // no need to hang on to the old object. + mChange = null; + } + } break; case RECEIVED_ICON: diff --git a/core/java/android/webkit/FrameLoader.java b/core/java/android/webkit/FrameLoader.java index 81ed367..c1eeb3b 100644 --- a/core/java/android/webkit/FrameLoader.java +++ b/core/java/android/webkit/FrameLoader.java @@ -128,6 +128,18 @@ class FrameLoader { /* package */ static boolean handleLocalFile(String url, LoadListener loadListener, WebSettings settings) { + // Attempt to decode the percent-encoded url before passing to the + // local loaders. + try { + url = new String(URLUtil.decode(url.getBytes())); + } catch (IllegalArgumentException e) { + loadListener.error(EventHandler.ERROR_BAD_URL, + loadListener.getContext().getString( + com.android.internal.R.string.httpErrorBadUrl)); + // Return true here so we do not trigger an unsupported scheme + // error. + return true; + } if (URLUtil.isAssetUrl(url)) { FileLoader.requestUrl(url, loadListener, loadListener.getContext(), true, settings.getAllowFileAccess()); diff --git a/core/java/android/webkit/MockGeolocation.java b/core/java/android/webkit/MockGeolocation.java new file mode 100644 index 0000000..028cb19 --- /dev/null +++ b/core/java/android/webkit/MockGeolocation.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "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 android.webkit; + +/** + * This class is simply a container for the methods used to configure WebKit's + * mock Geolocation service for use in LayoutTests. + * @hide Pending API council review. + */ +public final class MockGeolocation { + + // Global instance of a MockGeolocation + private static MockGeolocation sMockGeolocation; + + /** + * Set the position for the mock Geolocation service. + */ + public void setPosition(double latitude, double longitude, double accuracy) { + // This should only ever be called on the WebKit thread. + nativeSetPosition(latitude, longitude, accuracy); + } + + /** + * Set the error for the mock Geolocation service. + */ + public void setError(int code, String message) { + // This should only ever be called on the WebKit thread. + nativeSetError(code, message); + } + + /** + * Get the global instance of MockGeolocation. + * @return The global MockGeolocation instance. + */ + public static MockGeolocation getInstance() { + if (sMockGeolocation == null) { + sMockGeolocation = new MockGeolocation(); + } + return sMockGeolocation; + } + + // Native functions + private static native void nativeSetPosition(double latitude, double longitude, double accuracy); + private static native void nativeSetError(int code, String message); +} diff --git a/core/java/android/webkit/WebChromeClient.java b/core/java/android/webkit/WebChromeClient.java index c10bc97..e1c8d4d 100644 --- a/core/java/android/webkit/WebChromeClient.java +++ b/core/java/android/webkit/WebChromeClient.java @@ -23,6 +23,15 @@ import android.view.View; public class WebChromeClient { /** + * Tell the host application that the WebView has changed viewing modes. + * @param toZoomedOut If true, the WebView has zoomed out so that the page + * fits the screen. If false, it is zoomed to the setting + * specified by the user. + * @hide + */ + public void onChangeViewingMode(boolean toZoomedOut) {} + + /** * Tell the host application the current progress of loading a page. * @param view The WebView that initiated the callback. * @param newProgress Current page loading progress, represented by diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index be9daa5..7468aef 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -521,6 +521,7 @@ public class WebView extends AbsoluteLayout // follow the links. Double tap will toggle between zoom overview mode and // the last zoom scale. boolean mInZoomOverview = false; + // ideally mZoomOverviewWidth should be mContentWidth. But sites like espn, // engadget always have wider mContentWidth no matter what viewport size is. int mZoomOverviewWidth = WebViewCore.DEFAULT_VIEWPORT_WIDTH; @@ -4687,6 +4688,7 @@ public class WebView extends AbsoluteLayout mZoomCenterX = mLastTouchX; mZoomCenterY = mLastTouchY; mInZoomOverview = !mInZoomOverview; + mCallbackProxy.uiOnChangeViewingMode(mInZoomOverview); if (mInZoomOverview) { if (getSettings().getBuiltInZoomControls()) { if (mZoomButtonsController.isVisible()) { @@ -5034,6 +5036,14 @@ public class WebView extends AbsoluteLayout mInZoomOverview = ENABLE_DOUBLETAP_ZOOM && settings.getLoadWithOverviewMode(); } + mCallbackProxy.uiOnChangeViewingMode(true); + if (!mInZoomOverview) { + // We are going to start zoomed in. However, we + // truly want to show the title bar, and then hide + // it once the page has loaded + mCallbackProxy.uiChangeViewingModeOnFinishedLoad( + false, getOriginalUrl()); + } setNewZoomScale(mLastScale, false); setContentScrollTo(restoreState.mScrollX, restoreState.mScrollY); diff --git a/core/java/com/android/internal/service/wallpaper/ImageWallpaper.java b/core/java/com/android/internal/service/wallpaper/ImageWallpaper.java index 7266ee3..bfe8696 100644 --- a/core/java/com/android/internal/service/wallpaper/ImageWallpaper.java +++ b/core/java/com/android/internal/service/wallpaper/ImageWallpaper.java @@ -59,6 +59,7 @@ public class ImageWallpaper extends WallpaperService { class WallpaperObserver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { mEngine.updateWallpaper(); + mEngine.drawFrame(); } } @@ -72,14 +73,7 @@ public class ImageWallpaper extends WallpaperService { @Override public void onCreate(SurfaceHolder surfaceHolder) { super.onCreate(surfaceHolder); - mBackground = mWallpaperManager.getDrawable(); - mBounds.left = mBounds.top = 0; - mBounds.right = mBackground.getIntrinsicWidth(); - mBounds.bottom = mBackground.getIntrinsicHeight(); - int offx = (getDesiredMinimumWidth() - mBounds.right) / 2; - int offy = (getDesiredMinimumHeight() - mBounds.bottom) / 2; - mBounds.offset(offx, offy); - mBackground.setBounds(mBounds); + updateWallpaper(); surfaceHolder.setSizeFromLayout(); } @@ -131,6 +125,13 @@ public class ImageWallpaper extends WallpaperService { void updateWallpaper() { synchronized (mLock) { mBackground = mWallpaperManager.getDrawable(); + mBounds.left = mBounds.top = 0; + mBounds.right = mBackground.getIntrinsicWidth(); + mBounds.bottom = mBackground.getIntrinsicHeight(); + int offx = (getDesiredMinimumWidth() - mBounds.right) / 2; + int offy = (getDesiredMinimumHeight() - mBounds.bottom) / 2; + mBounds.offset(offx, offy); + mBackground.setBounds(mBounds); } } } diff --git a/core/res/res/values-en-rUS/donottranslate-names.xml b/core/res/res/values-en-rUS/donottranslate-names.xml new file mode 100644 index 0000000..42c8ab4 --- /dev/null +++ b/core/res/res/values-en-rUS/donottranslate-names.xml @@ -0,0 +1,155 @@ +<?xml version="1.0" encoding="UTF-8"?> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + + <!-- various string resources for Contacts --> + <string-array name="common_nicknames"> + <item>Albert, Al, Bert, Bertie</item> + <item>Alexander, Al, Alex, Lex, Sasha</item> + <item>Alexandra, Al, Alex, Allie, Ally, Lex, Lexie, Sandra, Sandy, Sasha</item> + <item>Alice, Allie, Ally</item> + <item>Alison, Allie, Ally</item> + <item>Allison, Allie, Ally</item> + <item>Amanda, Mandi, Mandy</item> + <item>Andrea, Andie</item> + <item>Andrew, Andy, Drew</item> + <item>Anthony, Tony, Toni, Tone</item> + <item>Arthur, Art, Arty</item> + <item>Barbara, Babs, Barb, Barbie</item> + <item>Benjamin, Ben, Benji, Benny</item> + <item>Bernard, Bern, Bernie</item> + <item>Bertram, Bert, Bertie</item> + <item>Bradly, Brad</item> + <item>Catherine, Cat, Cate, Cath, Catie, Cathy, Kat, Kate, Katie, Kathy</item> + <item>Charles, Chuck, Chaz, Charlie, Buck</item> + <item>Christine, Chris, Chrissy, Chrissie</item> + <item>Christopher, Chris</item> + <item>Cynthia, Cindy, Cynth</item> + <item>Daniel, Dan, Danny</item> + <item>David, Dave</item> + <item>Deborah, Deb, Debbie</item> + <item>Dennis, Den, Denny, Dean</item> + <item>Dolores, Dolly</item> + <item>Donald, Don, Donny</item> + <item>Donnatella, Donna</item> + <item>Dorothea, Dot, Dotty</item> + <item>Dorothy, Dot, Dotty</item> + <item>Douglas, Doug</item> + <item>Edward, Ed, Eddie, Ned, Neddie, Neddy, Ted, Teddy, Teddie</item> + <item>Eleanor, Ella, Ellie, Elle</item> + <item>Elisabetta, Betta</item> + <item>Elizabeth, Beth, Bess, Bessie, Betsy, Betty, Bette, Eliza, Lisa, Liza, Liz</item> + <item>Emily, Em, Ems, Emmy</item> + <item>Emma, Em, Ems, Emmy</item> + <item>Erica, Rikki, Rikkie, Ricky</item> + <item>Eugene, Gene</item> + <item>Florence, Flo</item> + <item>Frances, Fran, Francie</item> + <item>Francis, Fran, Frank</item> + <item>Frederick, Fred, Freddy</item> + <item>Gabriel, Gabe</item> + <item>Geoffrey, Jeff</item> + <item>Gerald, Gerry</item> + <item>Gerard, Gerry</item> + <item>Gregory, Greg</item> + <item>Harold, Hal, Hank, Harry</item> + <item>Henry, Hal, Hank, Harry</item> + <item>Herbert, Bert, Bertie</item> + <item>Irving, Irv</item> + <item>Isabella, Isa, Izzy</item> + <item>Jacob, Jake</item> + <item>Jacqueline, Jackie</item> + <item>James, Jim, Jimmy, Jamie, Jock</item> + <item>Janet, Jan</item> + <item>Janice, Jan</item> + <item>Jason, Jay</item> + <item>Jefferson, Jeff</item> + <item>Jeffrey, Jeff</item> + <item>Jennifer, Jen, Jenny</item> + <item>Jerome, Jerry</item> + <item>Jessica, Jessie</item> + <item>John, Jack, Jacky, Johnny, Jon</item> + <item>Jonathan, Jon, John</item> + <item>Joseph, Joe, Joey</item> + <item>Joshua, Josh</item> + <item>Kaitlyn, Cat, Cate, Catie, Cath, Cathy, Kat, Kate, Katie, Kathy</item> + <item>Katherine, Cat, Cate, Catie, Cath, Cathy, Kat, Kate, Katie, Kathy</item> + <item>Kathleen, Cat, Cate, Catie, Cath, Cathy, Kat, Kate, Katie, Kathy</item> + <item>Katrina, Cat, Cate, Catie, Cath, Cathy, Kat, Kate, Katie, Kathy</item> + <item>Kenneth, Ken</item> + <item>Kevin, Kev</item> + <item>Laura, Lauri, Laurie</item> + <item>Lauren, Lauri, Laurie</item> + <item>Laurence, Larry, Lauri, Laurie</item> + <item>Lawrence, Larry, Lauri, Laurie</item> + <item>Leonard, Leo, Len, Lenny</item> + <item>Leopold, Leo, Len, Lenny</item> + <item>Madeline, Maddie, Maddy</item> + <item>Margaret, Marge, Marg, Maggie, Mags, Meg, Peggy</item> + <item>Matthew, Matt, Mattie</item> + <item>Maureen, Mo</item> + <item>Maurice, Mo</item> + <item>Megan, Meg</item> + <item>Michael, Mickey, Mick, Mike, Mikey</item> + <item>Morris, Mo</item> + <item>Nancy, Nan</item> + <item>Nathan, Nat, Nate</item> + <item>Nathaniel, Nat, Nate</item> + <item>Nicholas, Nick</item> + <item>Pamela, Pam</item> + <item>Patricia, Pat, Patsy, Patty, Trish, Tricia</item> + <item>Patrick, Paddy, Pat, Patty, Patter, Rick, Ricky</item> + <item>Peter, Pete</item> + <item>Raymond, Ray</item> + <item>Philip, Phil</item> + <item>Rebecca, Becca</item> + <item>Richard, Rick, Rich, Dick</item> + <item>Robert, Bob, Rob, Robbie, Bobby, Rab</item> + <item>Roberta, Bobbie</item> + <item>Rodney. Rod</item> + <item>Ronald, Ron, Ronnie</item> + <item>Rosemary, Rosie, Rose</item> + <item>Russell, Russ, Rusty</item> + <item>Ryan, Ry</item> + <item>Samantha, Sam</item> + <item>Samuel, Sam, Sammy</item> + <item>Sophia, Sophie</item> + <item>Stephanie, Steph, Stephie</item> + <item>Stephen, Steve</item> + <item>Steven, Steve</item> + <item>Stuart, Stu</item> + <item>Susan, Sue, Susie, Suzie</item> + <item>Suzanne, Sue, Susie, Suzie</item> + <item>Teresa, Terrie, Terry</item> + <item>Theodora, Teddie, Thea, Theo</item> + <item>Theodore, Ted, Teddy, Theo</item> + <item>Thomas, Tom, Thom, Tommy</item> + <item>Timothy, Tim, Timmy</item> + <item>Valerie, Val</item> + <item>Veronica, Ronnie, Roni, Nica, Nikki, Nikka</item> + <item>Victor, Vic</item> + <item>Victoria, Vicky, Vicki, Vickie, Tori</item> + <item>Vincent, Vince, Vin, Vinnie</item> + <item>Vivian, Vivi</item> + <item>Walter, Walt, Wally</item> + <item>Wendy, Wen, Wendel</item> + <item>William, Bill, Billy, Will, Willy, Liam</item> + <item>Yvonna, Vonna</item> + <item>Zachary, Zach, Zack, Zac</item> + </string-array> + <string name="common_name_prefixes"> + 1LT, 1ST, 2LT, 2ND, 3RD, ADMIRAL, CAPT, CAPTAIN, COL, CPT, DR, + GEN, GENERAL, LCDR, LT, LTC, LTG, LTJG, MAJ, MAJOR, MG, MR, + MRS, MS, PASTOR, PROF, REP, REVEREND, REV, SEN, ST + </string> + <string name="common_name_suffixes"> + B.A., BA, D.D.S., DDS, I, II, III, IV, IX, JR, M.A., M.D, MA, + MD, MS, PH.D., PHD, SR, V, VI, VII, VIII, X + </string> + <string name="common_last_name_prefixes"> + D', DE, DEL, DI, LA, LE, MC, SAN, ST, TER, VAN, VON + </string> + <string name="common_name_conjunctions"> + &, AND, OR + </string> +</resources> diff --git a/core/res/res/values/donottranslate-names.xml b/core/res/res/values/donottranslate-names.xml new file mode 100644 index 0000000..56ae47a --- /dev/null +++ b/core/res/res/values/donottranslate-names.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + + <!-- Various locale-specific string resources for Contacts --> + <string-array name="common_nicknames"></string-array> + <string name="common_name_prefixes"></string> + <string name="common_name_suffixes"></string> + <string name="common_last_name_prefixes"></string> + <string name="common_name_conjunctions"></string> +</resources> diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 815b767..22f9136 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1923,157 +1923,6 @@ <!-- This string appears (on two lines) when you type a number into contacts search, to let you create a contact whose phone number is the number you typed. The first line will be in bigger type than the second. --> <string name="create_contact_using">Create contact\nusing <xliff:g id="number" example="555">%s</xliff:g></string> - <!-- various string resources for Contacts --> - <string-array name="common_nicknames"> - <item>Albert, Al, Bert, Bertie</item> - <item>Alexander, Al, Alex, Lex, Sasha</item> - <item>Alexandra, Al, Alex, Allie, Ally, Lex, Lexie, Sandra, Sandy, Sasha</item> - <item>Alice, Allie, Ally</item> - <item>Alison, Allie, Ally</item> - <item>Allison, Allie, Ally</item> - <item>Amanda, Mandi, Mandy</item> - <item>Andrea, Andie</item> - <item>Andrew, Andy, Drew</item> - <item>Anthony, Tony, Toni, Tone</item> - <item>Arthur, Art, Arty</item> - <item>Barbara, Babs, Barb, Barbie</item> - <item>Benjamin, Ben, Benji, Benny</item> - <item>Bernard, Bern, Bernie</item> - <item>Bertram, Bert, Bertie</item> - <item>Bradly, Brad</item> - <item>Catherine, Cat, Cate, Cath, Catie, Cathy, Kat, Kate, Katie, Kathy</item> - <item>Charles, Chuck, Chaz, Charlie, Buck</item> - <item>Christine, Chris, Chrissy, Chrissie</item> - <item>Christopher, Chris</item> - <item>Cynthia, Cindy, Cynth</item> - <item>Daniel, Dan, Danny</item> - <item>David, Dave</item> - <item>Deborah, Deb, Debbie</item> - <item>Dennis, Den, Denny, Dean</item> - <item>Dolores, Dolly</item> - <item>Donald, Don, Donny</item> - <item>Donnatella, Donna</item> - <item>Dorothea, Dot, Dotty</item> - <item>Dorothy, Dot, Dotty</item> - <item>Douglas, Doug</item> - <item>Edward, Ed, Eddie, Ned, Neddie, Neddy, Ted, Teddy, Teddie</item> - <item>Eleanor, Ella, Ellie, Elle</item> - <item>Elisabetta, Betta</item> - <item>Elizabeth, Beth, Bess, Bessie, Betsy, Betty, Bette, Eliza, Lisa, Liza, Liz</item> - <item>Emily, Em, Ems, Emmy</item> - <item>Emma, Em, Ems, Emmy</item> - <item>Erica, Rikki, Rikkie, Ricky</item> - <item>Eugene, Gene</item> - <item>Florence, Flo</item> - <item>Frances, Fran, Francie</item> - <item>Francis, Fran, Frank</item> - <item>Frederick, Fred, Freddy</item> - <item>Gabriel, Gabe</item> - <item>Geoffrey, Jeff</item> - <item>Gerald, Gerry</item> - <item>Gerard, Gerry</item> - <item>Gregory, Greg</item> - <item>Harold, Hal, Hank, Harry</item> - <item>Henry, Hal, Hank, Harry</item> - <item>Herbert, Bert, Bertie</item> - <item>Irving, Irv</item> - <item>Isabella, Isa, Izzy</item> - <item>Jacob, Jake</item> - <item>Jacqueline, Jackie</item> - <item>James, Jim, Jimmy, Jamie, Jock</item> - <item>Janet, Jan</item> - <item>Janice, Jan</item> - <item>Jason, Jay</item> - <item>Jefferson, Jeff</item> - <item>Jeffrey, Jeff</item> - <item>Jennifer, Jen, Jenny</item> - <item>Jerome, Jerry</item> - <item>Jessica, Jessie</item> - <item>John, Jack, Jacky, Johnny, Jon</item> - <item>Jonathan, Jon, John</item> - <item>Joseph, Joe, Joey</item> - <item>Joshua, Josh</item> - <item>Kaitlyn, Cat, Cate, Catie, Cath, Cathy, Kat, Kate, Katie, Kathy</item> - <item>Katherine, Cat, Cate, Catie, Cath, Cathy, Kat, Kate, Katie, Kathy</item> - <item>Kathleen, Cat, Cate, Catie, Cath, Cathy, Kat, Kate, Katie, Kathy</item> - <item>Katrina, Cat, Cate, Catie, Cath, Cathy, Kat, Kate, Katie, Kathy</item> - <item>Kenneth, Ken</item> - <item>Kevin, Kev</item> - <item>Laura, Lauri, Laurie</item> - <item>Lauren, Lauri, Laurie</item> - <item>Laurence, Larry, Lauri, Laurie</item> - <item>Lawrence, Larry, Lauri, Laurie</item> - <item>Leonard, Leo, Len, Lenny</item> - <item>Leopold, Leo, Len, Lenny</item> - <item>Madeline, Maddie, Maddy</item> - <item>Margaret, Marge, Marg, Maggie, Mags, Meg, Peggy</item> - <item>Matthew, Matt, Mattie</item> - <item>Maureen, Mo</item> - <item>Maurice, Mo</item> - <item>Megan, Meg</item> - <item>Michael, Mickey, Mick, Mike, Mikey</item> - <item>Morris, Mo</item> - <item>Nancy, Nan</item> - <item>Nathan, Nat, Nate</item> - <item>Nathaniel, Nat, Nate</item> - <item>Nicholas, Nick</item> - <item>Pamela, Pam</item> - <item>Patricia, Pat, Patsy, Patty, Trish, Tricia</item> - <item>Patrick, Paddy, Pat, Patty, Patter, Rick, Ricky</item> - <item>Peter, Pete</item> - <item>Raymond, Ray</item> - <item>Philip, Phil</item> - <item>Rebecca, Becca</item> - <item>Richard, Rick, Rich, Dick</item> - <item>Robert, Bob, Rob, Robbie, Bobby, Rab</item> - <item>Roberta, Bobbie</item> - <item>Rodney. Rod</item> - <item>Ronald, Ron, Ronnie</item> - <item>Rosemary, Rosie, Rose</item> - <item>Russell, Russ, Rusty</item> - <item>Ryan, Ry</item> - <item>Samantha, Sam</item> - <item>Samuel, Sam, Sammy</item> - <item>Sophia, Sophie</item> - <item>Stephanie, Steph, Stephie</item> - <item>Stephen, Steve</item> - <item>Steven, Steve</item> - <item>Stuart, Stu</item> - <item>Susan, Sue, Susie, Suzie</item> - <item>Suzanne, Sue, Susie, Suzie</item> - <item>Teresa, Terrie, Terry</item> - <item>Theodora, Teddie, Thea, Theo</item> - <item>Theodore, Ted, Teddy, Theo</item> - <item>Thomas, Tom, Thom, Tommy</item> - <item>Timothy, Tim, Timmy</item> - <item>Valerie, Val</item> - <item>Veronica, Ronnie, Roni, Nica, Nikki, Nikka</item> - <item>Victor, Vic</item> - <item>Victoria, Vicky, Vicki, Vickie, Tori</item> - <item>Vincent, Vince, Vin, Vinnie</item> - <item>Vivian, Vivi</item> - <item>Walter, Walt, Wally</item> - <item>Wendy, Wen, Wendel</item> - <item>William, Bill, Billy, Will, Willy, Liam</item> - <item>Yvonna, Vonna</item> - <item>Zachary, Zach, Zack, Zac</item> - </string-array> - <string name="common_name_prefixes"> - 1LT, 1ST, 2LT, 2ND, 3RD, ADMIRAL, CAPT, CAPTAIN, COL, CPT, DR, - GEN, GENERAL, LCDR, LT, LTC, LTG, LTJG, MAJ, MAJOR, MG, MR, - MRS, MS, PASTOR, PROF, REP, REVEREND, REV, SEN, ST - </string> - <string name="common_name_suffixes"> - B.A., BA, D.D.S., DDS, I, II, III, IV, IX, JR, M.A., M.D, MA, - MD, MS, PH.D., PHD, SR, V, VI, VII, VIII, X - </string> - <string name="common_last_name_prefixes"> - D', DE, DEL, DI, LA, LE, MC, SAN, ST, TER, VAN, VON - </string> - <string name="common_name_conjunctions"> - &, AND, OR - </string> - <!-- This string array should be overridden by the manufacture to present a list of carrier-id,locale,wifi-channel sets. This is used at startup to set system defaults by checking the system property ro.carrier for the carrier-id and searching through this array --> <!-- An Array of [[Carrier-ID] --> <!-- [default-locale] --> diff --git a/graphics/java/android/graphics/DashPathEffect.java b/graphics/java/android/graphics/DashPathEffect.java index 3deca4a..4f16dc4 100644 --- a/graphics/java/android/graphics/DashPathEffect.java +++ b/graphics/java/android/graphics/DashPathEffect.java @@ -23,13 +23,13 @@ public class DashPathEffect extends PathEffect { * the even indices specifying the "on" intervals, and the odd indices * specifying the "off" intervals. phase is an offset into the intervals * array (mod the sum of all of the intervals). The intervals array - * controlls the width of the dashes. The paint's strokeWidth controlls the - * height of the dashes. + * controls the length of the dashes. The paint's strokeWidth controls the + * thickness of the dashes. * Note: this patheffect only affects drawing with the paint's style is set * to STROKE or STROKE_AND_FILL. It is ignored if the drawing is done with * style == FILL. * @param intervals array of ON and OFF distances - * @param phase offset before the first ON interval is drawn + * @param phase offset into the intervals array */ public DashPathEffect(float intervals[], float phase) { if (intervals.length < 2) { diff --git a/include/media/mediametadataretriever.h b/include/media/mediametadataretriever.h index 3db8a0f..9ea2775 100644 --- a/include/media/mediametadataretriever.h +++ b/include/media/mediametadataretriever.h @@ -52,6 +52,7 @@ enum { METADATA_KEY_VIDEO_FORMAT = 18, METADATA_KEY_VIDEO_HEIGHT = 19, METADATA_KEY_VIDEO_WIDTH = 20, + METADATA_KEY_WRITER = 21, // Add more here... }; diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index 60fc0e0..16bf8a2 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -153,20 +153,6 @@ public class AudioManager { @Deprecated public static final int NUM_STREAMS = AudioSystem.NUM_STREAMS; - /** @hide Maximum volume index values for audio streams */ - public static final int[] MAX_STREAM_VOLUME = new int[] { - 6, // STREAM_VOICE_CALL - 8, // STREAM_SYSTEM - 8, // STREAM_RING - 16, // STREAM_MUSIC - 8, // STREAM_ALARM - 8, // STREAM_NOTIFICATION - 16, // STREAM_BLUETOOTH_SCO - 8, // STREAM_SYSTEM_ENFORCED - 16, // STREAM_DTMF - 16 // STREAM_TTS - }; - /** @hide Default volume index values for audio streams */ public static final int[] DEFAULT_STREAM_VOLUME = new int[] { 4, // STREAM_VOICE_CALL diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index 9afe6a1..5a59712 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -44,6 +44,7 @@ import android.provider.Settings; import android.provider.Settings.System; import android.util.Log; import android.view.VolumePanel; +import android.os.SystemProperties; import com.android.internal.telephony.ITelephony; @@ -54,6 +55,7 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; + /** * The implementation of the volume manager service. * <p> @@ -140,6 +142,19 @@ public class AudioService extends IAudioService.Stub { {4, -1} // FX_FOCUS_RETURN }; + /** @hide Maximum volume index values for audio streams */ + private int[] MAX_STREAM_VOLUME = new int[] { + 6, // STREAM_VOICE_CALL + 8, // STREAM_SYSTEM + 8, // STREAM_RING + 16, // STREAM_MUSIC + 8, // STREAM_ALARM + 8, // STREAM_NOTIFICATION + 16, // STREAM_BLUETOOTH_SCO + 8, // STREAM_SYSTEM_ENFORCED + 16, // STREAM_DTMF + 16 // STREAM_TTS + }; /* STREAM_VOLUME_ALIAS[] indicates for each stream if it uses the volume settings * of another stream: This avoids multiplying the volume settings for hidden * stream types that follow other stream behavior for volume settings @@ -231,6 +246,12 @@ public class AudioService extends IAudioService.Stub { public AudioService(Context context) { mContext = context; mContentResolver = context.getContentResolver(); + + // Intialized volume + MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] = SystemProperties.getInt( + "ro.config.vc_call_vol_steps", + MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]); + mVolumePanel = new VolumePanel(context, this); mSettingsObserver = new SettingsObserver(); mMode = AudioSystem.MODE_NORMAL; @@ -249,6 +270,7 @@ public class AudioService extends IAudioService.Stub { intentFilter.addAction(BluetoothA2dp.SINK_STATE_CHANGED_ACTION); intentFilter.addAction(BluetoothIntent.HEADSET_STATE_CHANGED_ACTION); context.registerReceiver(mReceiver, intentFilter); + } private void createAudioSystemThread() { @@ -945,7 +967,7 @@ public class AudioService extends IAudioService.Stub { mStreamType = streamType; final ContentResolver cr = mContentResolver; - mIndexMax = AudioManager.MAX_STREAM_VOLUME[streamType]; + mIndexMax = MAX_STREAM_VOLUME[streamType]; mIndex = Settings.System.getInt(cr, mVolumeIndexSettingName, AudioManager.DEFAULT_STREAM_VOLUME[streamType]); diff --git a/media/java/android/media/MediaMetadataRetriever.java b/media/java/android/media/MediaMetadataRetriever.java index c6a9ae8..cecf4f8 100644 --- a/media/java/android/media/MediaMetadataRetriever.java +++ b/media/java/android/media/MediaMetadataRetriever.java @@ -254,5 +254,6 @@ public class MediaMetadataRetriever public static final int METADATA_KEY_VIDEO_FORMAT = 18; public static final int METADATA_KEY_VIDEO_HEIGHT = 19; public static final int METADATA_KEY_VIDEO_WIDTH = 20; + public static final int METADATA_KEY_WRITER = 21; // Add more here... } diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java index 71af909..376057e 100644 --- a/media/java/android/media/MediaScanner.java +++ b/media/java/android/media/MediaScanner.java @@ -396,6 +396,7 @@ public class MediaScanner private String mPath; private long mLastModified; private long mFileSize; + private String mWriter; public FileCacheEntry beginFile(String path, String mimeType, long lastModified, long fileSize) { @@ -479,6 +480,7 @@ public class MediaScanner mDuration = 0; mPath = path; mLastModified = lastModified; + mWriter = null; return entry; } @@ -593,6 +595,8 @@ public class MediaScanner mTrack = (num * 1000) + (mTrack % 1000); } else if (name.equalsIgnoreCase("duration")) { mDuration = parseSubstring(value, 0, 0); + } else if (name.equalsIgnoreCase("writer") || name.startsWith("writer;")) { + mWriter = value.trim(); } } diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaNames.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaNames.java index e76967d..3f2bc39 100755 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaNames.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaNames.java @@ -372,81 +372,81 @@ public class MediaNames { public static final String META_DATA_MP3 [][] = { {"/sdcard/media_api/metaDataTestMedias/MP3/ID3V1_ID3V2.mp3", "1/10", "ID3V2.3 Album", "ID3V2.3 Artist", "ID3V2.3 Lyricist", "ID3V2.3 Composer", null, "Blues", - "ID3V2.3 Title", "1234", "295", "1"}, + "ID3V2.3 Title", "1234", "295", "1", null}, {"/sdcard/media_api/metaDataTestMedias/MP3/ID3V2.mp3", "1/10", "ID3V2.3 Album", "ID3V2.3 Artist", "ID3V2.3 Lyricist", "ID3V2.3 Composer", null, "Blues", - "ID3V2.3 Title", "1234", "287", "1"}, + "ID3V2.3 Title", "1234", "287", "1", null}, {"/sdcard/media_api/metaDataTestMedias/MP3/ID3V1.mp3", "1", "test ID3V1 Album", "test ID3V1 Artist", - null, null, null, "255", "test ID3V1 Title", "1234", "231332", "1"}, + null, null, null, "255", "test ID3V1 Title", "1234", "231332", "1", null}, {"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V1.mp3" , null, null, null, - null, null, null, null, null, null, "231330", "1"}, + null, null, null, null, null, null, "231330", "1", null}, //The corrupted TALB field in id3v2 would not switch to id3v1 tag automatically {"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TALB.mp3", "01", null, "ID3V2.3 Artist", "ID3V2.3 Lyricist", "ID3V2.3 Composer", null, - "Blues", "ID3V2.3 Title", "1234", "295", "1"}, + "Blues", "ID3V2.3 Title", "1234", "295", "1", null}, {"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TCOM.mp3", "01", "ID3V2.3 Album", "ID3V2.3 Artist", "ID3V2.3 Lyricist", null, null, - "Blues", "ID3V2.3 Title", "1234", "295", "1"}, + "Blues", "ID3V2.3 Title", "1234", "295", "1", null}, {"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TCOM_2.mp3", "01", "ID3V2.3 Album", - "ID3V2.3 Artist", null, null, null, "Blues", "ID3V2.3 Title", "1234", "295", "1"}, + "ID3V2.3 Artist", null, null, null, "Blues", "ID3V2.3 Title", "1234", "295", "1", null}, {"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TRCK.mp3", "dd", "ID3V2.3 Album", "ID3V2.3 Artist", "ID3V2.3 Lyricist", "ID3V2.3 Composer", null, - "Blues", "ID3V2.3 Title", "1234", "295", "1"}, + "Blues", "ID3V2.3 Title", "1234", "295", "1", null}, {"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TRCK_2.mp3", "01", "ID3V2.3 Album", - "ID3V2.3 Artist", null, null, null, "255", "ID3V2.3 Title", "1234", "295", "1"}, + "ID3V2.3 Artist", null, null, null, "255", "ID3V2.3 Title", "1234", "295", "1", null}, {"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TYER.mp3", "01", "ID3V2.3 Album", - "ID3V2.3 Artist", null, null, null, null, "ID3V2.3 Title", "9999", "295", "1"}, + "ID3V2.3 Artist", null, null, null, null, "ID3V2.3 Title", "9999", "295", "1", null}, {"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TYER_2.mp3", "01", "ID3V2.3 Album", "ID3V2.3 Artist", "ID3V2.3 Lyricist", "ID3V2.3 Composer", null, - "Blues", "ID3V2.3 Title", null, "295", "1"}, + "Blues", "ID3V2.3 Title", null, "295", "1", null}, {"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TIT.mp3", null, null, null, - null, null, null, null, null, null, "295", "1"} + null, null, null, null, null, null, "295", "1", null} }; public static final String META_DATA_OTHERS [][] = { {"/sdcard/media_api/metaDataTestMedias/3GP/cat.3gp", null, null, null, null, null, "20080309T002415.000Z", null, - null, null, "1404928", "2"}, + null, null, "1404928", "2", null}, {"/sdcard/media_api/metaDataTestMedias/AMR/AMR_NB.amr", null, null, null, null, null, null, null, - null, null, "126540", "1"}, + null, null, "126540", "1", null}, {"/sdcard/media_api/metaDataTestMedias/AMRWB/AMR_WB.amr", null, null, null, null, null, null, null, - null, null, "231180", "1"}, - {"/sdcard/media_api/metaDataTestMedias/M4A/Jaws Of Life_ver1.m4a", null, "Suspended Animation", + null, null, "231180", "1", null}, + {"/sdcard/media_api/metaDataTestMedias/M4A/Jaws Of Life_ver1.m4a", "1/8", "Suspended Animation", "John Petrucci", null, null, "20070510T125223.000Z", - null, null, "2005", "231180", "1"}, + "13", "Jaws Of Life", "2005", "19815424", "1", "m4a composer"}, {"/sdcard/media_api/metaDataTestMedias/M4V/sample_iPod.m4v", null, null, null, null, null, "20051220T202015.000Z", - null, null, null, "3771392", "2"}, + null, null, null, "3771392", "2", null}, {"/sdcard/media_api/metaDataTestMedias/MIDI/MIDI.mid", null, "Suspended Animation", "John Petrucci", null, null, "20070510T125223.000Z", - null, null, "2005", "231180", "1"}, - {"/sdcard/media_api/metaDataTestMedias/MP4/kung_fu_panda_h264.mp4", null, "mp4 album Kung Fu Panda", + null, null, "2005", "231180", "1", null}, + {"/sdcard/media_api/metaDataTestMedias/MP4/kung_fu_panda_h264.mp4", "2/0", "mp4 album Kung Fu Panda", "mp4 artist Kung Fu Panda", null, null, "20080517T091451.000Z", - "41", "Kung Fu Panda", "2008", "5667840", "2"}, + "41", "Kung Fu Panda", "2008", "5667840", "2", "mp4 composer"}, {"/sdcard/media_api/metaDataTestMedias/OGG/Ring_Classic_02.ogg", null, "Suspended Animation", "John Petrucci", null, null, "20070510T125223.000Z", - null, null, "2005", "231180", "1"}, + null, null, "2005", "231180", "1", null}, {"/sdcard/media_api/metaDataTestMedias/OGG/When You Say Nothing At All.ogg", null, "Suspended Animation", "John Petrucci", - null, null, "20070510T125223.000Z", null, null, "2005", "231180", "1"}, + null, null, "20070510T125223.000Z", null, null, "2005", "231180", "1", null}, {"/sdcard/media_api/metaDataTestMedias/WAV/Im With You.wav", null, null, null, null, null, null, - null, null, null, "224000", "1"}, + null, null, null, "224000", "1", null}, {"/sdcard/media_api/metaDataTestMedias/WMA/WMA9.wma", "6", "Ten Songs in the Key of Betrayal", "Alien Crime Syndicate", "Alien Crime Syndicate", "wma 9 Composer", "20040521T175729.483Z", - "Rock", "Run for the Money", "2004", "134479", "1"}, + "Rock", "Run for the Money", "2004", "134479", "1", null}, {"/sdcard/media_api/metaDataTestMedias/WMA/WMA10.wma", "09", "wma 10 Album", "wma 10 Album Artist", "wma 10 Artist", "wma 10 Composer", "20070705T063625.097Z", - "Acid Jazz", "wma 10 Title", "2010", "126574", "1"}, + "Acid Jazz", "wma 10 Title", "2010", "126574", "1", null}, {"/sdcard/media_api/metaDataTestMedias/WMV/bugs.wmv", "8", "wmv 9 Album", null, "wmv 9 Artist ", null, "20051122T155247.540Z", - null, "Looney Tunes - Hare-Breadth Hurry", "2005", "193482", "2"}, + null, "Looney Tunes - Hare-Breadth Hurry", "2005", "193482", "2", null}, {"/sdcard/media_api/metaDataTestMedias/WMV/clips_ver7.wmv", "50", "wmv 7 Album", null, "Hallau Shoots & Company", null, "20020226T170045.891Z", - null, "CODEC Shootout", "1986", "43709", "2"} + null, "CODEC Shootout", "1986", "43709", "2", null} }; //output recorded video diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaMetadataTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaMetadataTest.java index 3715913..1bf4958 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaMetadataTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaMetadataTest.java @@ -36,7 +36,7 @@ public class MediaMetadataTest extends AndroidTestCase { FILE_PATH,CD_TRACK, ALBUM, ARTIST, AUTHOR, COMPOSER, DATE, GENRE, TITLE, - YEAR, DURATION, NUM_TRACKS + YEAR, DURATION, NUM_TRACKS, WRITER } public static enum MP3_TEST_FILE{ @@ -130,8 +130,6 @@ public class MediaMetadataTest extends AndroidTestCase { validateMetatData(non_mp3_test_file.AMRWB.ordinal(), MediaNames.META_DATA_OTHERS); } - //Bug# 1440173 - skip this test case now - @Suppress @MediumTest public static void testM4A1_Metadata() throws Exception { validateMetatData(non_mp3_test_file.M4A1.ordinal(), MediaNames.META_DATA_OTHERS); @@ -254,6 +252,10 @@ public class MediaMetadataTest extends AndroidTestCase { Log.v(TAG, "Track : "+ value); assertEquals(TAG,meta_data_file[fileIndex][meta.NUM_TRACKS.ordinal()], value); + value = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_WRITER); + Log.v(TAG, "Writer : "+ value); + assertEquals(TAG,meta_data_file[fileIndex][meta.WRITER.ordinal()], value); + retriever.release(); } } diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index 1c60058..72a1192 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -100,6 +100,9 @@ public class ConnectivityService extends IConnectivityManager.Stub { // a process dies private List mFeatureUsers; + private boolean mSystemReady; + private ArrayList<Intent> mDeferredBroadcasts; + private class NetworkAttributes { /** * Class for holding settings read from resources. @@ -820,7 +823,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { (newNet == null || !newNet.isAvailable() ? "" : " other=" + newNet.getNetworkInfo().getTypeName())); - mContext.sendStickyBroadcast(intent); + sendStickyBroadcast(intent); /* * If the failover network is already connected, then immediately send * out a followup broadcast indicating successful failover @@ -843,7 +846,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { intent.putExtra(ConnectivityManager.EXTRA_EXTRA_INFO, info.getExtraInfo()); } - mContext.sendStickyBroadcast(intent); + sendStickyBroadcast(intent); } /** @@ -882,7 +885,33 @@ public class ConnectivityService extends IConnectivityManager.Stub { intent.putExtra(ConnectivityManager.EXTRA_IS_FAILOVER, true); info.setFailover(false); } - mContext.sendStickyBroadcast(intent); + sendStickyBroadcast(intent); + } + + private void sendStickyBroadcast(Intent intent) { + synchronized(this) { + if (mSystemReady) { + mContext.sendStickyBroadcast(intent); + } else { + if (mDeferredBroadcasts == null) { + mDeferredBroadcasts = new ArrayList<Intent>(); + } + mDeferredBroadcasts.add(intent); + } + } + } + + void systemReady() { + synchronized(this) { + mSystemReady = true; + if (mDeferredBroadcasts != null) { + int count = mDeferredBroadcasts.size(); + for (int i = 0; i < count; i++) { + mContext.sendStickyBroadcast(mDeferredBroadcasts.get(i)); + } + mDeferredBroadcasts = null; + } + } } private void handleConnect(NetworkInfo info) { diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index ad8e892..38bf63a 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -85,6 +85,7 @@ class ServerThread extends Thread { HardwareService hardware = null; PowerManagerService power = null; BatteryService battery = null; + ConnectivityService connectivity = null; IPackageManager pm = null; Context context = null; WindowManagerService wm = null; @@ -231,8 +232,8 @@ class ServerThread extends Thread { try { Log.i(TAG, "Starting Connectivity Service."); - ServiceManager.addService(Context.CONNECTIVITY_SERVICE, - ConnectivityService.getInstance(context)); + connectivity = ConnectivityService.getInstance(context); + ServiceManager.addService(Context.CONNECTIVITY_SERVICE, connectivity); } catch (Throwable e) { Log.e(TAG, "Failure starting Connectivity Service", e); } @@ -384,7 +385,8 @@ class ServerThread extends Thread { } if (wallpaper != null) wallpaper.systemReady(); - battery.systemReady(); + if (battery != null) battery.systemReady(); + if (connectivity != null) connectivity.systemReady(); Watchdog.getInstance().start(); Looper.loop(); diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java index 9fe4eee..9a293a9 100644 --- a/services/java/com/android/server/WallpaperManagerService.java +++ b/services/java/com/android/server/WallpaperManagerService.java @@ -38,6 +38,7 @@ import android.os.FileObserver; import android.os.ParcelFileDescriptor; import android.os.RemoteCallbackList; import android.os.ServiceManager; +import android.os.SystemClock; import android.service.wallpaper.IWallpaperConnection; import android.service.wallpaper.IWallpaperEngine; import android.service.wallpaper.IWallpaperService; @@ -68,10 +69,16 @@ class WallpaperManagerService extends IWallpaperManager.Stub { Object mLock = new Object(); - private static final File WALLPAPER_DIR = new File( + /** + * Minimum time between crashes of a wallpaper service for us to consider + * restarting it vs. just reverting to the static wallpaper. + */ + static final long MIN_WALLPAPER_CRASH_TIME = 10000; + + static final File WALLPAPER_DIR = new File( "/data/data/com.android.settings/files"); - private static final String WALLPAPER = "wallpaper"; - private static final File WALLPAPER_FILE = new File(WALLPAPER_DIR, WALLPAPER); + static final String WALLPAPER = "wallpaper"; + static final File WALLPAPER_FILE = new File(WALLPAPER_DIR, WALLPAPER); /** * List of callbacks registered they should each be notified @@ -116,6 +123,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub { String mName = ""; ComponentName mWallpaperComponent; WallpaperConnection mWallpaperConnection; + long mLastDiedTime; class WallpaperConnection extends IWallpaperConnection.Stub implements ServiceConnection { @@ -136,6 +144,14 @@ class WallpaperManagerService extends IWallpaperManager.Stub { synchronized (mLock) { mService = null; mEngine = null; + if (mWallpaperConnection == this) { + Log.w(TAG, "Wallpaper service gone: " + mWallpaperComponent); + if ((mLastDiedTime+MIN_WALLPAPER_CRASH_TIME) + < SystemClock.uptimeMillis()) { + Log.w(TAG, "Reverting to built-in wallpaper!"); + bindWallpaperComponentLocked(null); + } + } } } @@ -195,7 +211,12 @@ class WallpaperManagerService extends IWallpaperManager.Stub { if (f.exists()) { f.delete(); } - bindWallpaperComponentLocked(null); + final long ident = Binder.clearCallingIdentity(); + try { + bindWallpaperComponentLocked(null); + } finally { + Binder.restoreCallingIdentity(ident); + } } } @@ -247,12 +268,17 @@ class WallpaperManagerService extends IWallpaperManager.Stub { public ParcelFileDescriptor setWallpaper(String name) { checkPermission(android.Manifest.permission.SET_WALLPAPER); synchronized (mLock) { - ParcelFileDescriptor pfd = updateWallpaperBitmapLocked(name); - if (pfd != null) { - bindWallpaperComponentLocked(null); - saveSettingsLocked(); + final long ident = Binder.clearCallingIdentity(); + try { + ParcelFileDescriptor pfd = updateWallpaperBitmapLocked(name); + if (pfd != null) { + bindWallpaperComponentLocked(null); + saveSettingsLocked(); + } + return pfd; + } finally { + Binder.restoreCallingIdentity(ident); } - return pfd; } } @@ -299,8 +325,10 @@ class WallpaperManagerService extends IWallpaperManager.Stub { ComponentName realName = name; if (realName == null) { // The default component is our static image wallpaper. - realName = new ComponentName("android", - ImageWallpaper.class.getName()); + //realName = new ComponentName("android", + // ImageWallpaper.class.getName()); + clearWallpaperComponentLocked(); + return; } ServiceInfo si = mContext.getPackageManager().getServiceInfo(realName, PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS); @@ -341,6 +369,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub { clearWallpaperComponentLocked(); mWallpaperComponent = name; mWallpaperConnection = newConn; + mLastDiedTime = SystemClock.uptimeMillis(); try { if (DEBUG) Log.v(TAG, "Adding window token: " + newConn.mToken); mIWindowManager.addWindowToken(newConn.mToken, diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index 2ff73bb..ac80071 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -1194,6 +1194,9 @@ public class WindowManagerService extends IWindowManager.Stub } if (!visible) w = null; + //if (mWallpaperTarget != w) { + // Log.v(TAG, "New wallpaper target: " + w); + //} mWallpaperTarget = w; if (visible) { @@ -6900,10 +6903,10 @@ public class WindowManagerService extends IWindowManager.Stub if (atoken != null) { return mSurface != null && mPolicyVisibility && !mDestroying && ((!mAttachedHidden && !atoken.hiddenRequested) - || mAnimating || atoken.animating); + || mAnimation != null || atoken.animation != null); } else { return mSurface != null && mPolicyVisibility && !mDestroying - && (!mAttachedHidden || mAnimating); + && (!mAttachedHidden || mAnimation != null); } } @@ -6913,10 +6916,11 @@ public class WindowManagerService extends IWindowManager.Stub */ boolean isReadyForDisplay() { final AppWindowToken atoken = mAppToken; - final boolean animating = atoken != null ? atoken.animating : false; + final boolean animating = atoken != null + ? (atoken.animation != null) : false; return mSurface != null && mPolicyVisibility && !mDestroying && ((!mAttachedHidden && !mRootToken.hidden) - || mAnimating || animating); + || mAnimation != null || animating); } /** Is the window or its container currently animating? */ diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java b/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java index 97a8b25..b61b307 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/CallbackProxy.java @@ -18,6 +18,7 @@ package com.android.dumprendertree; import android.os.Handler; import android.os.Message; +import android.webkit.MockGeolocation; import android.webkit.WebStorage; import java.util.HashMap; @@ -325,7 +326,7 @@ public class CallbackProxy extends Handler implements EventSender, LayoutTestCon } public void setWindowIsKey(boolean b) { - obtainMessage(LAYOUT_SET_WINDOW_KEY,b ? 1 : 0, 0).sendToTarget(); + obtainMessage(LAYOUT_SET_WINDOW_KEY, b ? 1 : 0, 0).sendToTarget(); } public void testRepaint() { @@ -352,4 +353,15 @@ public class CallbackProxy extends Handler implements EventSender, LayoutTestCon obtainMessage(LAYOUT_SET_CAN_OPEN_WINDOWS).sendToTarget(); } + public void setMockGeolocationPosition(double latitude, + double longitude, + double accuracy) { + MockGeolocation.getInstance().setPosition(latitude, + longitude, + accuracy); + } + + public void setMockGeolocationError(int code, String message) { + MockGeolocation.getInstance().setError(code, message); + } } diff --git a/tools/layoutlib/bridge/src/android/os/ServiceManager.java b/tools/layoutlib/bridge/src/android/os/ServiceManager.java new file mode 100644 index 0000000..6a68ee2 --- /dev/null +++ b/tools/layoutlib/bridge/src/android/os/ServiceManager.java @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "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 android.os; + +import java.util.Map; + +public final class ServiceManager { + + /** + * Returns a reference to a service with the given name. + * + * @param name the name of the service to get + * @return a reference to the service, or <code>null</code> if the service doesn't exist + */ + public static IBinder getService(String name) { + return null; + } + + /** + * Place a new @a service called @a name into the service + * manager. + * + * @param name the name of the new service + * @param service the service object + */ + public static void addService(String name, IBinder service) { + // pass + } + + /** + * Retrieve an existing service called @a name from the + * service manager. Non-blocking. + */ + public static IBinder checkService(String name) { + return null; + } + + /** + * Return a list of all currently running services. + */ + public static String[] listServices() throws RemoteException { + // actual implementation returns null sometimes, so it's ok + // to return null instead of an empty list. + return null; + } + + /** + * This is only intended to be called when the process is first being brought + * up and bound by the activity manager. There is only one thread in the process + * at that time, so no locking is done. + * + * @param cache the cache of service references + * @hide + */ + public static void initServiceCache(Map<String, IBinder> cache) { + // pass + } +} diff --git a/tools/layoutlib/bridge/src/android/view/accessibility/AccessibilityManager.java b/tools/layoutlib/bridge/src/android/view/accessibility/AccessibilityManager.java new file mode 100644 index 0000000..251c053 --- /dev/null +++ b/tools/layoutlib/bridge/src/android/view/accessibility/AccessibilityManager.java @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "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 android.view.accessibility; + +import android.content.Context; +import android.content.pm.ServiceInfo; + +import java.util.Collections; +import java.util.List; + +/** + * System level service that serves as an event dispatch for {@link AccessibilityEvent}s. + * Such events are generated when something notable happens in the user interface, + * for example an {@link android.app.Activity} starts, the focus or selection of a + * {@link android.view.View} changes etc. Parties interested in handling accessibility + * events implement and register an accessibility service which extends + * {@link android.accessibilityservice.AccessibilityService}. + * + * @see AccessibilityEvent + * @see android.accessibilityservice.AccessibilityService + * @see android.content.Context#getSystemService + */ +public final class AccessibilityManager { + private static AccessibilityManager sInstance = new AccessibilityManager(); + + /** + * Get an AccessibilityManager instance (create one if necessary). + * + * @hide + */ + public static AccessibilityManager getInstance(Context context) { + return sInstance; + } + + /** + * Create an instance. + * + * @param context A {@link Context}. + */ + private AccessibilityManager() { + } + + /** + * Returns if the {@link AccessibilityManager} is enabled. + * + * @return True if this {@link AccessibilityManager} is enabled, false otherwise. + */ + public boolean isEnabled() { + return false; + } + + /** + * Sends an {@link AccessibilityEvent}. If this {@link AccessibilityManager} is not + * enabled the call is a NOOP. + * + * @param event The {@link AccessibilityEvent}. + * + * @throws IllegalStateException if a client tries to send an {@link AccessibilityEvent} + * while accessibility is not enabled. + */ + public void sendAccessibilityEvent(AccessibilityEvent event) { + } + + /** + * Requests interruption of the accessibility feedback from all accessibility services. + */ + public void interrupt() { + } + + /** + * Returns the {@link ServiceInfo}s of the installed accessibility services. + * + * @return An unmodifiable list with {@link ServiceInfo}s. + */ + public List<ServiceInfo> getAccessibilityServiceList() { + // normal implementation does this in some case, so let's do the same + // (unmodifiableList wrapped around null). + List<ServiceInfo> services = null; + return Collections.unmodifiableList(services); + } +} diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContext.java index 69f3d9c..f48c8db 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContext.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContext.java @@ -64,7 +64,7 @@ import java.util.Map.Entry; * Custom implementation of Context to handle non compiled resources. */ public final class BridgeContext extends Context { - + private Resources mResources; private Theme mTheme; private HashMap<View, Object> mViewKeyMap = new HashMap<View, Object>(); @@ -73,12 +73,12 @@ public final class BridgeContext extends Context { private Map<String, Map<String, IResourceValue>> mProjectResources; private Map<String, Map<String, IResourceValue>> mFrameworkResources; private Map<IStyleResourceValue, IStyleResourceValue> mStyleInheritanceMap; - + // maps for dynamically generated id representing style objects (IStyleResourceValue) private Map<Integer, IStyleResourceValue> mDynamicIdToStyleMap; private Map<IStyleResourceValue, Integer> mStyleToDynamicIdMap; private int mDynamicIdGenerator = 0x01030000; // Base id for framework R.style - + // cache for TypedArray generated from IStyleResourceValue object private Map<int[], Map<Integer, TypedArray>> mTypedArrayCache; private BridgeInflater mInflater; @@ -112,7 +112,7 @@ public final class BridgeContext extends Context { mProjectCallback = customViewLoader; mLogger = logger; Configuration config = new Configuration(); - + AssetManager assetManager = BridgeAssetManager.initSystem(); mResources = BridgeResources.initSystem( this, @@ -120,19 +120,19 @@ public final class BridgeContext extends Context { metrics, config, customViewLoader); - + mTheme = mResources.newTheme(); - + mThemeValues = currentTheme; mProjectResources = projectResources; mFrameworkResources = frameworkResources; mStyleInheritanceMap = styleInheritanceMap; } - + public void setBridgeInflater(BridgeInflater inflater) { mInflater = inflater; } - + public void addViewKey(View view, Object viewKey) { mViewKeyMap.put(view, viewKey); } @@ -140,19 +140,19 @@ public final class BridgeContext extends Context { public Object getViewKey(View view) { return mViewKeyMap.get(view); } - + public Object getProjectKey() { return mProjectKey; } - + public IProjectCallback getProjectCallback() { return mProjectCallback; } - + public ILayoutLog getLogger() { return mLogger; } - + // ------------ Context methods @Override @@ -169,14 +169,14 @@ public final class BridgeContext extends Context { public ClassLoader getClassLoader() { return this.getClass().getClassLoader(); } - + @Override public Object getSystemService(String service) { if (LAYOUT_INFLATER_SERVICE.equals(service)) { return mInflater; } - - // AutoCompleteTextView and MultiAutoCompleteTextView want a window + + // AutoCompleteTextView and MultiAutoCompleteTextView want a window // service. We don't have any but it's not worth an exception. if (WINDOW_SERVICE.equals(service)) { return null; @@ -196,38 +196,38 @@ public final class BridgeContext extends Context { throws Resources.NotFoundException { // get the IStyleResourceValue based on the resId; IStyleResourceValue style = getStyleByDynamicId(resid); - + if (style == null) { throw new Resources.NotFoundException(); } if (mTypedArrayCache == null) { mTypedArrayCache = new HashMap<int[], Map<Integer,TypedArray>>(); - + Map<Integer, TypedArray> map = new HashMap<Integer, TypedArray>(); mTypedArrayCache.put(attrs, map); BridgeTypedArray ta = createStyleBasedTypedArray(style, attrs); map.put(resid, ta); - + return ta; } - + // get the 2nd map Map<Integer, TypedArray> map = mTypedArrayCache.get(attrs); if (map == null) { map = new HashMap<Integer, TypedArray>(); mTypedArrayCache.put(attrs, map); } - + // get the array from the 2nd map TypedArray ta = map.get(resid); - + if (ta == null) { ta = createStyleBasedTypedArray(style, attrs); map.put(resid, ta); } - + return ta; } @@ -235,11 +235,11 @@ public final class BridgeContext extends Context { public final TypedArray obtainStyledAttributes(AttributeSet set, int[] attrs) { return obtainStyledAttributes(set, attrs, 0, 0); } - + @Override public TypedArray obtainStyledAttributes(AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) { - + // Hint: for XmlPullParser, attach source //DEVICE_SRC/dalvik/libcore/xml/src/java BridgeXmlBlockParser parser = null; if (set instanceof BridgeXmlBlockParser) { @@ -252,10 +252,10 @@ public final class BridgeContext extends Context { boolean[] frameworkAttributes = new boolean[1]; TreeMap<Integer, String> styleNameMap = searchAttrs(attrs, frameworkAttributes); - + BridgeTypedArray ta = ((BridgeResources) mResources).newTypeArray(attrs.length, parser.isPlatformFile()); - + // resolve the defStyleAttr value into a IStyleResourceValue IStyleResourceValue defStyleValues = null; if (defStyleAttr != 0) { @@ -265,7 +265,7 @@ public final class BridgeContext extends Context { // look for the style in the current theme, and its parent: if (mThemeValues != null) { IResourceValue item = findItemInStyle(mThemeValues, defStyleName); - + if (item != null) { // item is a reference to a style entry. Search for it. item = findResValue(item.getValue()); @@ -279,12 +279,12 @@ public final class BridgeContext extends Context { } } } - + if (defStyleRes != 0) { // FIXME: See what we need to do with this. throw new UnsupportedOperationException(); } - + String namespace = BridgeConstants.NS_RESOURCES; if (frameworkAttributes[0] == false) { // need to use the application namespace @@ -294,32 +294,32 @@ public final class BridgeContext extends Context { if (styleNameMap != null) { for (Entry<Integer, String> styleAttribute : styleNameMap.entrySet()) { int index = styleAttribute.getKey().intValue(); - + String name = styleAttribute.getValue(); String value = parser.getAttributeValue(namespace, name); - + // if there's no direct value for this attribute in the XML, we look for default // values in the widget defStyle, and then in the theme. if (value == null) { IResourceValue resValue = null; - + // look for the value in the defStyle first (and its parent if needed) if (defStyleValues != null) { resValue = findItemInStyle(defStyleValues, name); } - + // if the item is not present in the defStyle, we look in the main theme (and // its parent themes) if (resValue == null && mThemeValues != null) { resValue = findItemInStyle(mThemeValues, name); } - + // if we found a value, we make sure this doesn't reference another value. // So we resolve it. if (resValue != null) { resValue = resolveResValue(resValue); } - + ta.bridgeSetValue(index, name, resValue); } else { // there is a value in the XML, but we need to resolve it in case it's @@ -328,15 +328,20 @@ public final class BridgeContext extends Context { } } } - + ta.sealArray(); - + return ta; } - - + + @Override + public Looper getMainLooper() { + return Looper.myLooper(); + } + + // ------------- private new methods - + /** * Creates a {@link BridgeTypedArray} by filling the values defined by the int[] with the * values found in the given style. @@ -345,30 +350,30 @@ public final class BridgeContext extends Context { private BridgeTypedArray createStyleBasedTypedArray(IStyleResourceValue style, int[] attrs) throws Resources.NotFoundException { TreeMap<Integer, String> styleNameMap = searchAttrs(attrs, null); - + BridgeTypedArray ta = ((BridgeResources) mResources).newTypeArray(attrs.length, false /* platformResourceFlag */); - + // loop through all the values in the style map, and init the TypedArray with // the style we got from the dynamic id for (Entry<Integer, String> styleAttribute : styleNameMap.entrySet()) { int index = styleAttribute.getKey().intValue(); String name = styleAttribute.getValue(); - + // get the value from the style, or its parent styles. IResourceValue resValue = findItemInStyle(style, name); - + // resolve it to make sure there are no references left. ta.bridgeSetValue(index, name, resolveResValue(resValue)); } - + ta.sealArray(); return ta; } - + /** * Resolves the value of a resource, if the value references a theme or resource value. * <p/> @@ -391,13 +396,13 @@ public final class BridgeContext extends Context { // get the IResourceValue referenced by this value IResourceValue resValue = findResValue(value); - + // if resValue is null, but value is not null, this means it was not a reference. // we return the name/value wrapper in a IResourceValue if (resValue == null) { return new ResourceValue(type, name, value); } - + // we resolved a first reference, but we need to make sure this isn't a reference also. return resolveResValue(resValue); } @@ -411,7 +416,7 @@ public final class BridgeContext extends Context { * <p/> * If a value that does not need to be resolved is given, the method will return the input * value. - * + * * @param value the value containing the reference to resolve. * @return a {@link IResourceValue} object or <code>null</code> */ @@ -419,7 +424,7 @@ public final class BridgeContext extends Context { if (value == null) { return null; } - + // if the resource value is a style, we simply return it. if (value instanceof IStyleResourceValue) { return value; @@ -436,7 +441,7 @@ public final class BridgeContext extends Context { // otherwise, we attempt to resolve this new value as well return resolveResValue(resolvedValue); } - + /** * Searches for, and returns a {@link IResourceValue} by its reference. * <p/> @@ -451,7 +456,7 @@ public final class BridgeContext extends Context { * <p/> * The actual format of a reference is <pre>@[namespace:]resType/resName</pre> but this method * only support the android namespace. - * + * * @param reference the resource reference to search for. * @return a {@link IResourceValue} or <code>null</code>. */ @@ -481,7 +486,7 @@ public final class BridgeContext extends Context { // we look for the referenced item name. String referenceName = null; - + if (segments.length == 2) { // there was a resType in the reference. If it's attr, we ignore it // else, we assert for now. @@ -495,7 +500,7 @@ public final class BridgeContext extends Context { // it's just an item name. referenceName = segments[0]; } - + // now we look for android: in the referenceName in order to support format // such as: ?attr/android:name if (referenceName.startsWith(BridgeConstants.PREFIX_ANDROID)) { @@ -512,9 +517,9 @@ public final class BridgeContext extends Context { return findItemInStyle(mThemeValues, referenceName); } else if (reference.startsWith(BridgeConstants.PREFIX_RESOURCE_REF)) { boolean frameworkOnly = false; - + // check for the specific null reference value. - if (BridgeConstants.REFERENCE_NULL.equals(reference)) { + if (BridgeConstants.REFERENCE_NULL.equals(reference)) { return null; } @@ -526,20 +531,20 @@ public final class BridgeContext extends Context { } else { reference = reference.substring(BridgeConstants.PREFIX_RESOURCE_REF.length()); } - + // at this point, value contains type/[android:]name (drawable/foo for instance) String[] segments = reference.split("\\/"); - + // now we look for android: in the resource name in order to support format // such as: @drawable/android:name if (segments[1].startsWith(BridgeConstants.PREFIX_ANDROID)) { frameworkOnly = true; segments[1] = segments[1].substring(BridgeConstants.PREFIX_ANDROID.length()); } - + return findResValue(segments[0], segments[1], frameworkOnly); } - + // Looks like the value didn't reference anything. Return null. return null; } @@ -565,7 +570,7 @@ public final class BridgeContext extends Context { } } } - + // now search in the framework resources. typeMap = mFrameworkResources.get(resType); if (typeMap != null) { @@ -574,11 +579,11 @@ public final class BridgeContext extends Context { return item; } } - + // didn't find the resource anywhere. return null; } - + /** * Returns a framework resource by type and name. The returned resource is resolved. * @param resourceType the type of the resource @@ -587,7 +592,7 @@ public final class BridgeContext extends Context { public IResourceValue getFrameworkResource(String resourceType, String resourceName) { return getResource(resourceType, resourceName, mFrameworkResources); } - + /** * Returns a project resource by type and name. The returned resource is resolved. * @param resourceType the type of the resource @@ -596,7 +601,7 @@ public final class BridgeContext extends Context { public IResourceValue getProjectResource(String resourceType, String resourceName) { return getResource(resourceType, resourceName, mProjectResources); } - + IResourceValue getResource(String resourceType, String resourceName, Map<String, Map<String, IResourceValue>> resourceRepository) { Map<String, IResourceValue> typeMap = resourceRepository.get(resourceType); @@ -607,12 +612,12 @@ public final class BridgeContext extends Context { return item; } } - + // didn't find the resource anywhere. return null; - + } - + /** * Returns the {@link IResourceValue} matching a given name in a given style. If the * item is not directly available in the style, the method looks in its parent style. @@ -622,7 +627,7 @@ public final class BridgeContext extends Context { */ IResourceValue findItemInStyle(IStyleResourceValue style, String itemName) { IResourceValue item = style.findItem(itemName); - + // if we didn't find it, we look in the parent style (if applicable) if (item == null && mStyleInheritanceMap != null) { IStyleResourceValue parentStyle = mStyleInheritanceMap.get(style); @@ -630,7 +635,7 @@ public final class BridgeContext extends Context { return findItemInStyle(parentStyle, itemName); } } - + return item; } @@ -642,7 +647,7 @@ public final class BridgeContext extends Context { * attrs == com.android.internal.R.styleable.View, this returns the list of the "xyz" where * there's a field com.android.internal.R.styleable.View_xyz and the field value is the index * that is used to reference the attribute later in the TypedArray. - * + * * @param attrs An attribute array reference given to obtainStyledAttributes. * @return A sorted map Attribute-Value to Attribute-Name for all attributes declared by the * attribute array. Returns null if nothing is found. @@ -662,14 +667,14 @@ public final class BridgeContext extends Context { attributes.put(i, null); } } - + if (outFrameworkFlag != null) { outFrameworkFlag[0] = true; } - + return attributes; } - + // if the name was not found in the framework resources, look in the project // resources arrayName = mProjectCallback.resolveResourceValue(attrs); @@ -697,7 +702,7 @@ public final class BridgeContext extends Context { /** * Searches for the attribute referenced by its internal id. - * + * * @param attr An attribute reference given to obtainStyledAttributes such as defStyle. * @return The unique name of the attribute, if found, e.g. "buttonStyle". Returns null * if nothing is found. @@ -707,12 +712,12 @@ public final class BridgeContext extends Context { if (info != null) { return info[0]; } - + info = mProjectCallback.resolveResourceValue(attr); if (info != null) { return info[0]; } - + return null; } @@ -722,27 +727,27 @@ public final class BridgeContext extends Context { mDynamicIdToStyleMap = new HashMap<Integer, IStyleResourceValue>(); mStyleToDynamicIdMap = new HashMap<IStyleResourceValue, Integer>(); } - + // look for an existing id Integer id = mStyleToDynamicIdMap.get(resValue); - + if (id == null) { // generate a new id id = Integer.valueOf(++mDynamicIdGenerator); - + // and add it to the maps. mDynamicIdToStyleMap.put(id, resValue); mStyleToDynamicIdMap.put(resValue, id); } - + return id; } - + private IStyleResourceValue getStyleByDynamicId(int i) { if (mDynamicIdToStyleMap != null) { return mDynamicIdToStyleMap.get(i); } - + return null; } @@ -751,10 +756,10 @@ public final class BridgeContext extends Context { if (value != null) { return value.intValue(); } - + return defValue; } - + int getProjectIdValue(String idName, int defValue) { if (mProjectCallback != null) { Integer value = mProjectCallback.getResourceValue(BridgeConstants.RES_ID, idName); @@ -762,7 +767,7 @@ public final class BridgeContext extends Context { return value.intValue(); } } - + return defValue; } @@ -820,7 +825,7 @@ public final class BridgeContext extends Context { @Override public void clearWallpaper() { // TODO Auto-generated method stub - + } @Override @@ -850,46 +855,46 @@ public final class BridgeContext extends Context { @Override public void enforceCallingOrSelfPermission(String arg0, String arg1) { // TODO Auto-generated method stub - + } @Override public void enforceCallingOrSelfUriPermission(Uri arg0, int arg1, String arg2) { // TODO Auto-generated method stub - + } @Override public void enforceCallingPermission(String arg0, String arg1) { // TODO Auto-generated method stub - + } @Override public void enforceCallingUriPermission(Uri arg0, int arg1, String arg2) { // TODO Auto-generated method stub - + } @Override public void enforcePermission(String arg0, int arg1, int arg2, String arg3) { // TODO Auto-generated method stub - + } @Override public void enforceUriPermission(Uri arg0, int arg1, int arg2, int arg3, String arg4) { // TODO Auto-generated method stub - + } @Override public void enforceUriPermission(Uri arg0, String arg1, String arg2, int arg3, int arg4, int arg5, String arg6) { // TODO Auto-generated method stub - + } @Override @@ -965,7 +970,7 @@ public final class BridgeContext extends Context { // TODO Auto-generated method stub return null; } - + @Override public String getPackageResourcePath() { // TODO Auto-generated method stub @@ -1003,7 +1008,7 @@ public final class BridgeContext extends Context { @Override public void grantUriPermission(String arg0, Uri arg1, int arg2) { // TODO Auto-generated method stub - + } @SuppressWarnings("unused") @@ -1051,31 +1056,31 @@ public final class BridgeContext extends Context { @Override public void removeStickyBroadcast(Intent arg0) { // TODO Auto-generated method stub - + } @Override public void revokeUriPermission(Uri arg0, int arg1) { // TODO Auto-generated method stub - + } @Override public void sendBroadcast(Intent arg0) { // TODO Auto-generated method stub - + } @Override public void sendBroadcast(Intent arg0, String arg1) { // TODO Auto-generated method stub - + } @Override public void sendOrderedBroadcast(Intent arg0, String arg1) { // TODO Auto-generated method stub - + } @Override @@ -1083,39 +1088,39 @@ public final class BridgeContext extends Context { BroadcastReceiver arg2, Handler arg3, int arg4, String arg5, Bundle arg6) { // TODO Auto-generated method stub - + } @Override public void sendStickyBroadcast(Intent arg0) { // TODO Auto-generated method stub - + } @Override public void setTheme(int arg0) { // TODO Auto-generated method stub - + } @SuppressWarnings("unused") @Override public void setWallpaper(Bitmap arg0) throws IOException { // TODO Auto-generated method stub - + } @SuppressWarnings("unused") @Override public void setWallpaper(InputStream arg0) throws IOException { // TODO Auto-generated method stub - + } @Override public void startActivity(Intent arg0) { // TODO Auto-generated method stub - + } @Override @@ -1140,20 +1145,15 @@ public final class BridgeContext extends Context { @Override public void unbindService(ServiceConnection arg0) { // TODO Auto-generated method stub - + } @Override public void unregisterReceiver(BroadcastReceiver arg0) { // TODO Auto-generated method stub - - } - @Override - public Looper getMainLooper() { - throw new UnsupportedOperationException(); } - + @Override public Context getApplicationContext() { throw new UnsupportedOperationException(); diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeResources.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeResources.java index 0bcc7fd..8a040e4 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeResources.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeResources.java @@ -43,14 +43,14 @@ import java.io.FileReader; import java.io.InputStream; /** - * + * */ public final class BridgeResources extends Resources { private BridgeContext mContext; private IProjectCallback mProjectCallback; private boolean[] mPlatformResourceFlag = new boolean[1]; - + /** * This initializes the static field {@link Resources#mSystem} which is used * by methods who get global resources using {@link Resources#getSystem()}. @@ -59,7 +59,7 @@ public final class BridgeResources extends Resources { * <p/> * {@link Bridge} calls this method after setting up a new bridge. */ - /*package*/ static Resources initSystem(BridgeContext context, + /*package*/ static Resources initSystem(BridgeContext context, AssetManager assets, DisplayMetrics metrics, Configuration config, @@ -73,7 +73,7 @@ public final class BridgeResources extends Resources { } return Resources.mSystem; } - + /** * Clears the static {@link Resources#mSystem} to make sure we don't leave objects * around that would prevent us from unloading the library. @@ -92,15 +92,15 @@ public final class BridgeResources extends Resources { mContext = context; mProjectCallback = projectCallback; } - + public BridgeTypedArray newTypeArray(int numEntries, boolean platformFile) { return new BridgeTypedArray(this, mContext, numEntries, platformFile); } - + private IResourceValue getResourceValue(int id, boolean[] platformResFlag_out) { // first get the String related to this id in the framework String[] resourceInfo = Bridge.resolveResourceValue(id); - + if (resourceInfo != null) { platformResFlag_out[0] = true; return mContext.getFrameworkResource(resourceInfo[1], resourceInfo[0]); @@ -109,7 +109,7 @@ public final class BridgeResources extends Resources { // didn't find a match in the framework? look in the project. if (mProjectCallback != null) { resourceInfo = mProjectCallback.resolveResourceValue(id); - + if (resourceInfo != null) { platformResFlag_out[0] = false; return mContext.getProjectResource(resourceInfo[1], resourceInfo[0]); @@ -118,26 +118,26 @@ public final class BridgeResources extends Resources { return null; } - + @Override public Drawable getDrawable(int id) throws NotFoundException { IResourceValue value = getResourceValue(id, mPlatformResourceFlag); - + if (value != null) { return ResourceHelper.getDrawable(value.getValue(), mContext, value.isFramework()); } - + // id was not found or not resolved. Throw a NotFoundException. throwException(id); - + // this is not used since the method above always throws return null; } - + @Override public int getColor(int id) throws NotFoundException { IResourceValue value = getResourceValue(id, mPlatformResourceFlag); - + if (value != null) { try { return ResourceHelper.getColor(value.getValue()); @@ -145,18 +145,18 @@ public final class BridgeResources extends Resources { return 0; } } - + // id was not found or not resolved. Throw a NotFoundException. throwException(id); - + // this is not used since the method above always throws return 0; } - + @Override public ColorStateList getColorStateList(int id) throws NotFoundException { IResourceValue value = getResourceValue(id, mPlatformResourceFlag); - + if (value != null) { try { int color = ResourceHelper.getColor(value.getValue()); @@ -165,33 +165,33 @@ public final class BridgeResources extends Resources { return null; } } - + // id was not found or not resolved. Throw a NotFoundException. throwException(id); - + // this is not used since the method above always throws return null; } - + @Override public CharSequence getText(int id) throws NotFoundException { IResourceValue value = getResourceValue(id, mPlatformResourceFlag); - + if (value != null) { return value.getValue(); } - + // id was not found or not resolved. Throw a NotFoundException. throwException(id); - + // this is not used since the method above always throws return null; } - + @Override public XmlResourceParser getLayout(int id) throws NotFoundException { IResourceValue value = getResourceValue(id, mPlatformResourceFlag); - + if (value != null) { File xml = new File(value.getValue()); if (xml.isFile()) { @@ -201,7 +201,7 @@ public final class BridgeResources extends Resources { KXmlParser parser = new KXmlParser(); parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true); parser.setInput(new FileReader(xml)); - + return new BridgeXmlBlockParser(parser, mContext, mPlatformResourceFlag[0]); } catch (XmlPullParserException e) { mContext.getLogger().error(e); @@ -215,22 +215,22 @@ public final class BridgeResources extends Resources { // id was not found or not resolved. Throw a NotFoundException. throwException(id); - + // this is not used since the method above always throws return null; } - + @Override public TypedArray obtainAttributes(AttributeSet set, int[] attrs) { return mContext.obtainStyledAttributes(set, attrs); } - + @Override public TypedArray obtainTypedArray(int id) throws NotFoundException { throw new UnsupportedOperationException(); } - - + + @Override public float getDimension(int id) throws NotFoundException { IResourceValue value = getResourceValue(id, mPlatformResourceFlag); @@ -244,7 +244,7 @@ public final class BridgeResources extends Resources { } else if (v.equals(BridgeConstants.WRAP_CONTENT)) { return LayoutParams.WRAP_CONTENT; } - + if (ResourceHelper.stringToFloat(v, mTmpValue) && mTmpValue.type == TypedValue.TYPE_DIMENSION) { return mTmpValue.getDimension(mMetrics); @@ -254,7 +254,7 @@ public final class BridgeResources extends Resources { // id was not found or not resolved. Throw a NotFoundException. throwException(id); - + // this is not used since the method above always throws return 0; } @@ -276,7 +276,7 @@ public final class BridgeResources extends Resources { // id was not found or not resolved. Throw a NotFoundException. throwException(id); - + // this is not used since the method above always throws return 0; } @@ -298,7 +298,7 @@ public final class BridgeResources extends Resources { // id was not found or not resolved. Throw a NotFoundException. throwException(id); - + // this is not used since the method above always throws return 0; } @@ -306,7 +306,7 @@ public final class BridgeResources extends Resources { @Override public int getInteger(int id) throws NotFoundException { IResourceValue value = getResourceValue(id, mPlatformResourceFlag); - + if (value != null && value.getValue() != null) { String v = value.getValue(); int radix = 10; @@ -320,10 +320,10 @@ public final class BridgeResources extends Resources { // return exception below } } - + // id was not found or not resolved. Throw a NotFoundException. throwException(id); - + // this is not used since the method above always throws return 0; } @@ -348,12 +348,12 @@ public final class BridgeResources extends Resources { String s = getString(id); if (s != null) { return String.format(s, formatArgs); - + } // id was not found or not resolved. Throw a NotFoundException. throwException(id); - + // this is not used since the method above always throws return null; } @@ -361,14 +361,14 @@ public final class BridgeResources extends Resources { @Override public String getString(int id) throws NotFoundException { IResourceValue value = getResourceValue(id, mPlatformResourceFlag); - + if (value != null && value.getValue() != null) { return value.getValue(); } // id was not found or not resolved. Throw a NotFoundException. throwException(id); - + // this is not used since the method above always throws return null; } @@ -385,6 +385,11 @@ public final class BridgeResources extends Resources { if (ResourceHelper.stringToFloat(v, outValue)) { return; } + + // else it's a string + outValue.type = TypedValue.TYPE_STRING; + outValue.string = v; + return; } } @@ -413,7 +418,7 @@ public final class BridgeResources extends Resources { KXmlParser parser = new KXmlParser(); parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true); parser.setInput(new FileReader(f)); - + return new BridgeXmlBlockParser(parser, mContext, mPlatformResourceFlag[0]); } catch (XmlPullParserException e) { NotFoundException newE = new NotFoundException(); @@ -436,6 +441,33 @@ public final class BridgeResources extends Resources { } @Override + public XmlResourceParser loadXmlResourceParser(String file, int id, + int assetCookie, String type) throws NotFoundException { + // even though we know the XML file to load directly, we still need to resolve the + // id so that we can know if it's a platform or project resource. + // (mPlatformResouceFlag will get the result and will be used later). + getResourceValue(id, mPlatformResourceFlag); + + File f = new File(file); + try { + KXmlParser parser = new KXmlParser(); + parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true); + parser.setInput(new FileReader(f)); + + return new BridgeXmlBlockParser(parser, mContext, mPlatformResourceFlag[0]); + } catch (XmlPullParserException e) { + NotFoundException newE = new NotFoundException(); + newE.initCause(e); + throw newE; + } catch (FileNotFoundException e) { + NotFoundException newE = new NotFoundException(); + newE.initCause(e); + throw newE; + } + } + + + @Override public InputStream openRawResource(int id) throws NotFoundException { IResourceValue value = getResourceValue(id, mPlatformResourceFlag); @@ -482,7 +514,7 @@ public final class BridgeResources extends Resources { if (resourceInfo == null && mProjectCallback != null) { resourceInfo = mProjectCallback.resolveResourceValue(id); } - + String message = null; if (resourceInfo != null) { message = String.format( @@ -492,7 +524,7 @@ public final class BridgeResources extends Resources { message = String.format( "Could not resolve resource value: 0x%1$X.", id); } - + throw new NotFoundException(message); } } diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java index 76bd8d4..c07baff 100644 --- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java +++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java @@ -40,7 +40,7 @@ public class Main { for (String path : osJarPath) { log.info("Input : %1$s", path); } - + try { AsmGenerator agen = new AsmGenerator(log, osDestJar[0], new Class<?>[] { // classes to inject in the final JAR @@ -66,8 +66,10 @@ public class Main { "android.graphics.ComposeShader", "android.graphics._Original_ComposeShader", "android.graphics.RadialGradient", "android.graphics._Original_RadialGradient", "android.graphics.SweepGradient", "android.graphics._Original_SweepGradient", + "android.os.ServiceManager", "android.os._Original_ServiceManager", "android.util.FloatMath", "android.util._Original_FloatMath", "android.view.SurfaceView", "android.view._Original_SurfaceView", + "android.view.accessibility.AccessibilityManager", "android.view.accessibility._Original_AccessibilityManager", }, new String[] { // methods deleted from their return type. "android.graphics.Paint", // class to delete method from @@ -101,7 +103,7 @@ public class Main { }); aa.analyze(); agen.generate(); - + // Throw an error if any class failed to get renamed by the generator // // IMPORTANT: if you're building the platform and you get this error message, @@ -123,7 +125,7 @@ public class Main { } System.exit(1); } - + System.exit(0); } catch (IOException e) { log.exception(e, "Failed to load jar"); @@ -158,7 +160,7 @@ public class Main { return false; } } - + if (osJarPath.isEmpty()) { log.error("Missing parameter: path to input jar"); return false; |
