Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 050638f9 authored by Steve Kondik's avatar Steve Kondik
Browse files

Merge branch 'gigglebeard' into gingerbread

parents f0d6d581 0b9f0037
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -153,6 +153,7 @@ LOCAL_SRC_FILES += \
	core/java/com/android/internal/app/IBatteryStats.aidl \
	core/java/com/android/internal/app/IUsageStats.aidl \
	core/java/com/android/internal/app/IMediaContainerService.aidl \
	core/java/com/android/internal/app/IAssetRedirectionManager.aidl \
	core/java/com/android/internal/appwidget/IAppWidgetService.aidl \
	core/java/com/android/internal/appwidget/IAppWidgetHost.aidl \
	core/java/com/android/internal/backup/IBackupTransport.aidl \
+12 −0
Original line number Diff line number Diff line
@@ -19598,6 +19598,18 @@
<parameter name="context" type="android.content.Context">
</parameter>
</constructor>
<constructor name="AlertDialog.Builder"
 type="android.app.AlertDialog.Builder"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="context" type="android.content.Context">
</parameter>
<parameter name="theme" type="int">
</parameter>
</constructor>
<method name="create"
 return="android.app.AlertDialog"
 abstract="false"
+5 −3
Original line number Diff line number Diff line
@@ -341,10 +341,12 @@ public final class Pm {
        if (nonLocalized != null) {
            return nonLocalized.toString();
        }
        if (res != 0) {
            Resources r = getResources(pii);
            if (r != null) {
                return r.getString(res);
            }
        }
        return null;
    }

+26 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2007 The Android Open Source Project
 * This code has been modified.  Portions copyright (C) 2010, T-Mobile USA, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -22,6 +23,7 @@ import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.ConfigurationInfo;
import android.content.pm.IPackageDataObserver;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.os.Debug;
import android.os.RemoteException;
@@ -1067,4 +1069,28 @@ public class ActivityManager {
        }
        return false;
    }

    /**
     * @hide
     */
    public Configuration getConfiguration() {
        try {
            return ActivityManagerNative.getDefault().getConfiguration();
        } catch (RemoteException e) {
            return null;
        }
    }

    /**
     * @throws SecurityException Throws SecurityException if the caller does
     * not hold the {@link android.Manifest.permission#CHANGE_CONFIGURATION} permission.
     *
     * @hide
     */
    public void updateConfiguration(Configuration values) throws SecurityException {
        try {
            ActivityManagerNative.getDefault().updateConfiguration(values);
        } catch (RemoteException e) {
        }
    }
}
+177 −17
Original line number Diff line number Diff line
/*
 * Copyright (C) 2006 The Android Open Source Project
 * This code has been modified.  Portions copyright (C) 2010, T-Mobile USA, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -16,32 +17,43 @@

package android.app;

import com.android.internal.app.IAssetRedirectionManager;
import com.android.internal.os.BinderInternal;
import com.android.internal.os.RuntimeInit;
import com.android.internal.os.SamplingProfilerIntegration;

import org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl;

import android.app.backup.BackupAgent;
import android.content.BroadcastReceiver;
import android.content.ComponentCallbacks;
import android.content.ComponentName;
import android.content.ContentProvider;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.IContentProvider;
import android.content.Intent;
import android.content.IIntentReceiver;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.InstrumentationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
import android.content.pm.ServiceInfo;
import android.content.res.AssetManager;
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.content.res.CustomTheme;
import android.content.res.PackageRedirectionMap;
import android.content.res.Resources;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDebug;
import android.database.sqlite.SQLiteDebug.DbStats;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.os.Build;
import android.net.Uri;
import android.os.Bundle;
import android.os.Debug;
import android.os.Handler;
@@ -55,6 +67,7 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.StrictMode;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.AndroidRuntimeException;
import android.util.Config;
import android.util.DisplayMetrics;
@@ -63,6 +76,7 @@ import android.util.Log;
import android.util.LogPrinter;
import android.util.Slog;
import android.view.Display;
import android.view.InflateException;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewManager;
@@ -71,12 +85,6 @@ import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManagerImpl;

import com.android.internal.os.BinderInternal;
import com.android.internal.os.RuntimeInit;
import com.android.internal.os.SamplingProfilerIntegration;

import org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl;

import java.io.File;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
@@ -92,8 +100,6 @@ import java.util.Map;
import java.util.TimeZone;
import java.util.regex.Pattern;

import dalvik.system.SamplingProfiler;

final class SuperNotCalledException extends AndroidRuntimeException {
    public SuperNotCalledException(String msg) {
        super(msg);
@@ -133,6 +139,7 @@ public final class ActivityThread {
    static ContextImpl mSystemContext = null;

    static IPackageManager sPackageManager;
    static IAssetRedirectionManager sAssetRedirectionManager;

    final ApplicationThread mAppThread = new ApplicationThread();
    final Looper mLooper = Looper.myLooper();
@@ -1141,6 +1148,18 @@ public final class ActivityThread {
        return sPackageManager;
    }

    // NOTE: this method can return null if the SystemServer is still
    // initializing (for example, of another SystemServer component is accessing
    // a resources object)
    public static IAssetRedirectionManager getAssetRedirectionManager() {
        if (sAssetRedirectionManager != null) {
            return sAssetRedirectionManager;
        }
        IBinder b = ServiceManager.getService("assetredirection");
        sAssetRedirectionManager = IAssetRedirectionManager.Stub.asInterface(b);
        return sAssetRedirectionManager;
    }

    DisplayMetrics getDisplayMetricsLocked(boolean forceUpdate) {
        if (mDisplayMetrics != null && !forceUpdate) {
            return mDisplayMetrics;
@@ -1191,10 +1210,23 @@ public final class ActivityThread {
        //}
        
        AssetManager assets = new AssetManager();
        assets.setThemeSupport(compInfo.isThemeable);
        if (assets.addAssetPath(resDir) == 0) {
            return null;
        }
        
        /* Attach theme information to the resulting AssetManager when appropriate. */
        Configuration config = getConfiguration();
        if (compInfo.isThemeable && config != null) {
            if (config.customTheme == null) {
                config.customTheme = CustomTheme.getBootTheme();
            }

            if (!TextUtils.isEmpty(config.customTheme.getThemePackageName())) {
                attachThemeAssets(assets, config.customTheme, false);
            }
        }

        //Slog.i(TAG, "Resource: key=" + key + ", display metrics=" + metrics);
        DisplayMetrics metrics = getDisplayMetricsLocked(false);
        r = new Resources(assets, metrics, getConfiguration(), compInfo);
@@ -1220,6 +1252,90 @@ public final class ActivityThread {
        }
    }

    private void detachThemeAssets(AssetManager assets) {
        String themePackageName = assets.getThemePackageName();
        int themeCookie = assets.getThemeCookie();
        if (!TextUtils.isEmpty(themePackageName) && themeCookie != 0) {
            assets.removeAssetPath(themePackageName, themeCookie);
            assets.setThemePackageName(null);
            assets.setThemeCookie(0);
            assets.clearRedirections();
        }
    }

    /**
     * Attach the necessary theme asset paths and meta information to convert an
     * AssetManager to being globally "theme-aware".
     *
     * @param assets
     * @param theme
     * @param updating If true, this AssetManager has already been accessed and
     *            special steps must be taken to update the underlying resource
     *            table.
     * @return true if the AssetManager is now theme-aware; false otherwise.
     *         This can fail, for example, if the theme package has been been
     *         removed and the theme manager has yet to revert formally back to
     *         the framework default.
     */
    private boolean attachThemeAssets(AssetManager assets, CustomTheme theme, boolean updating) {
        IAssetRedirectionManager rm = getAssetRedirectionManager();
        if (rm == null) {
            return false;
        }
        PackageInfo pi = null;
        try {
            pi = getPackageManager().getPackageInfo(theme.getThemePackageName(), 0);
        } catch (RemoteException e) {
        }
        if (pi != null && pi.applicationInfo != null && pi.themeInfos != null) {
            String themeResDir = pi.applicationInfo.publicSourceDir;
            int cookie;
            if (updating) {
                cookie = assets.updateResourcesWithAssetPath(themeResDir);
            } else {
                cookie = assets.addAssetPath(themeResDir);
            }
            if (cookie != 0) {
                String themePackageName = theme.getThemePackageName();
                String themeId = theme.getThemeId();
                int N = assets.getBasePackageCount();
                for (int i = 0; i < N; i++) {
                    String packageName = assets.getBasePackageName(i);
                    int packageId = assets.getBasePackageId(i);

                    /*
                     * For now, we only consider redirections coming from the
                     * framework or regular android packages. This excludes
                     * themes and other specialty APKs we are not aware of.
                     */
                    if (packageId != 0x01 && packageId != 0x7f) {
                        continue;
                    }

                    try {
                        PackageRedirectionMap map = rm.getPackageRedirectionMap(themePackageName, themeId,
                                packageName);
                        if (map != null) {
                            assets.addRedirections(map);
                        }
                    } catch (RemoteException e) {
                        Log.e(TAG, "Failure accessing package redirection map, removing theme support.");
                        assets.removeAssetPath(themePackageName, cookie);
                        return false;
                    }
                }

                assets.setThemePackageName(theme.getThemePackageName());
                assets.setThemeCookie(cookie);
                return true;
            } else {
                Log.e(TAG, "Unable to " + (updating ? "update" : "add") + " theme assets at " +
                        themeResDir);
            }
        }
        return false;
    }

    /**
     * Creates the top level resources for the given package.
     */
@@ -1620,6 +1736,16 @@ public final class ActivityThread {

        } catch (Exception e) {
            if (!mInstrumentation.onException(activity, e)) {
                if (e instanceof InflateException) {
                    Log.e(TAG, "Failed to inflate", e);
                    String pkg = null;
                    if (r.packageInfo != null && !TextUtils.isEmpty(r.packageInfo.getPackageName())) {
                        pkg = r.packageInfo.getPackageName();
                    }
                    Intent intent = new Intent(Intent.ACTION_APP_LAUNCH_FAILURE,
                            (pkg != null)? Uri.fromParts("package", pkg, null) : null);
                    getSystemContext().sendBroadcast(intent);
                }
                throw new RuntimeException(
                    "Unable to start activity " + component
                    + ": " + e.toString(), e);
@@ -2921,14 +3047,20 @@ public final class ActivityThread {
        }
    }

    final boolean applyConfigurationToResourcesLocked(Configuration config) {
    /*
     * Original code returned a boolean here to denote whether changes were
     * detected.  But T-Mobile must know what specifically has changed to check
     * later if the theme had changed, so we return the changes bitmap instead.
     * Caller beware.
     */
    final int applyConfigurationToResourcesLocked(Configuration config) {
        if (mResConfiguration == null) {
            mResConfiguration = new Configuration();
        }
        if (!mResConfiguration.isOtherSeqNewer(config)) {
            if (DEBUG_CONFIGURATION) Slog.v(TAG, "Skipping new config: curSeq="
                    + mResConfiguration.seq + ", newSeq=" + config.seq);
            return false;
            return 0;
        }
        int changes = mResConfiguration.updateFrom(config);
        DisplayMetrics dm = getDisplayMetricsLocked(true);
@@ -2953,7 +3085,20 @@ public final class ActivityThread {
            if (r != null) {
                if (DEBUG_CONFIGURATION) Slog.v(TAG, "Changing resources "
                        + r + " config to: " + config);
                boolean themeChanged = (changes & ActivityInfo.CONFIG_THEME_RESOURCE) != 0;
                if (themeChanged) {
                    AssetManager am = r.getAssets();
                    if (am.hasThemeSupport()) {
                        detachThemeAssets(am);
                        if (!TextUtils.isEmpty(config.customTheme.getThemePackageName())) {
                            attachThemeAssets(am, config.customTheme, true);
                        }
                    }
                }
                r.updateConfiguration(config, dm);
                if (themeChanged) {
                    r.updateStringCache();
                }
                //Slog.i(TAG, "Updated app resources " + v.getKey()
                //        + " " + r + ": " + r.getConfiguration());
            } else {
@@ -2962,13 +3107,15 @@ public final class ActivityThread {
            }
        }
        
        return changes != 0;
        return changes;
    }
    
    final void handleConfigurationChanged(Configuration config) {

        ArrayList<ComponentCallbacks> callbacks = null;

        int diff = 0;

        synchronized (mPackages) {
            if (mPendingConfiguration != null) {
                if (!mPendingConfiguration.isOtherSeqNewer(config)) {
@@ -2984,7 +3131,7 @@ public final class ActivityThread {
            if (DEBUG_CONFIGURATION) Slog.v(TAG, "Handle configuration changed: "
                    + config);
        
            applyConfigurationToResourcesLocked(config);
            diff = applyConfigurationToResourcesLocked(config);
            
            if (!mConfiguration.isOtherSeqNewer(config)) {
                return;
@@ -2997,7 +3144,20 @@ public final class ActivityThread {
        if (callbacks != null) {
            final int N = callbacks.size();
            for (int i=0; i<N; i++) {
                performConfigurationChanged(callbacks.get(i), config);
                ComponentCallbacks cb = callbacks.get(i);

                // We removed the old resources object from the mActiveResources
                // cache, now we need to trigger an update for each application.
                if ((diff & ActivityInfo.CONFIG_THEME_RESOURCE) != 0) {
                    if (cb instanceof Activity || cb instanceof Application) {
                        Context context = ((ContextWrapper)cb).getBaseContext();
                        if (context instanceof ContextImpl) {
                            ((ContextImpl)context).refreshResourcesIfNecessary();
                        }
                    }
                }

                performConfigurationChanged(cb, config);
            }
        }
    }
@@ -3593,7 +3753,7 @@ public final class ActivityThread {
                    // We need to apply this change to the resources
                    // immediately, because upon returning the view
                    // hierarchy will be informed about it.
                    if (applyConfigurationToResourcesLocked(newConfig)) {
                    if (applyConfigurationToResourcesLocked(newConfig) != 0) {
                        // This actually changed the resources!  Tell
                        // everyone about it.
                        if (mPendingConfiguration == null ||
Loading