Search in sources :

Example 26 with Resources

use of android.content.res.Resources in project atlas by alibaba.

the class InstrumentationHook method ValidateActivityResource.

private boolean ValidateActivityResource(Activity activity) {
    String exceptionString = null;
    String bundleName = AtlasBundleInfoManager.instance().getBundleForComponet(activity.getLocalClassName());
    BundleImpl b = (BundleImpl) Framework.getBundle(bundleName);
    String bundlePath = null;
    if (b != null) {
        bundlePath = b.getArchive().getArchiveFile().getAbsolutePath();
    }
    Resources resource = null;
    if (AtlasHacks.ContextThemeWrapper_mResources != null) {
        resource = AtlasHacks.ContextThemeWrapper_mResources.get(activity);
    } else {
        resource = activity.getResources();
    }
    Resources resource_runtime = RuntimeVariables.delegateResources;
    if (resource == resource_runtime) {
        return true;
    }
    List<String> paths = getAssetPathFromResources(resource);
    String pathsOfHis = DelegateResources.getCurrentAssetpathStr(RuntimeVariables.androidApplication.getAssets());
    List<String> pathsRuntime = getAssetPathFromResources(resource_runtime);
    if ((bundlePath != null) && (paths != null) && !paths.contains(bundlePath)) {
        exceptionString += "(1.1) Activity Resources path not contains:" + b.getArchive().getArchiveFile().getAbsolutePath();
        if (!pathsOfHis.contains(bundlePath)) {
            exceptionString += "(1.2) paths in history not contains:" + b.getArchive().getArchiveFile().getAbsolutePath();
        }
        if (!pathsRuntime.contains(bundlePath)) {
            exceptionString += "(1.3) paths in runtime not contains:" + b.getArchive().getArchiveFile().getAbsolutePath();
        }
        if (b.getArchive().getArchiveFile().exists() == false) {
            exceptionString += "(1.4) Bundle archive file not exist:" + b.getArchive().getArchiveFile().getAbsolutePath();
        }
        exceptionString += "(1.5) Activity Resources paths length:" + paths.size();
    }
    if (exceptionString != null) {
        return false;
    }
    return true;
}
Also used : BundleImpl(android.taobao.atlas.framework.BundleImpl) Resources(android.content.res.Resources)

Example 27 with Resources

use of android.content.res.Resources in project atlas by alibaba.

the class InstrumentationHook method HandleResourceNotFound.

private void HandleResourceNotFound(Activity activity, Bundle icicle, Exception e) {
    if (activity != null && !ErrorActivityRecords.contains(activity.getClass().getName())) {
        //fix #8224429
        ErrorActivityRecords.add(activity.getClass().getName());
        try {
            activity.finish();
        } catch (Throwable e2) {
        }
        return;
    }
    String exceptionString = null;
    try {
        Resources resource = null;
        if (AtlasHacks.ContextThemeWrapper_mResources != null) {
            resource = AtlasHacks.ContextThemeWrapper_mResources.get(activity);
        } else {
            resource = activity.getResources();
        }
        List<String> paths = getAssetPathFromResources(resource);
        List<String> pathsRuntime = getAssetPathFromResources(RuntimeVariables.delegateResources);
        String pathsOfHis = DelegateResources.getCurrentAssetpathStr(resource.getAssets());
        String bundleName = AtlasBundleInfoManager.instance().getBundleForComponet(activity.getLocalClassName());
        BundleImpl b = (BundleImpl) Framework.getBundle(bundleName);
        exceptionString += "Paths: " + paths;
        if (b != null) {
            String bundlePath = b.getArchive().getArchiveFile().getAbsolutePath();
            if (!paths.contains(bundlePath)) {
                exceptionString += "(2.1) Activity Resources path not contains:" + b.getArchive().getArchiveFile().getAbsolutePath();
            }
            if (!pathsRuntime.contains(bundlePath)) {
                exceptionString += "(2.2) Activity Resources path not contains:" + b.getArchive().getArchiveFile().getAbsolutePath();
            }
            if (!pathsOfHis.contains(bundlePath)) {
                exceptionString += "(2.3) paths in history not contains:" + b.getArchive().getArchiveFile().getAbsolutePath();
            }
            if (b.getArchive().getArchiveFile().exists() == false) {
                exceptionString += "(2.4) Bundle archive file not exist:" + b.getArchive().getArchiveFile().getAbsolutePath();
            }
            if (FileUtils.CheckFileValidation(b.getArchive().getArchiveFile().getAbsolutePath())) {
                exceptionString += "(2.5) Bundle archive file can not opened with stream:" + b.getArchive().getArchiveFile().getAbsolutePath();
            }
        }
        if (resource == RuntimeVariables.delegateResources) {
            exceptionString += "(2.6) DelegateResources equals Activity Resources";
        }
        exceptionString += "(2.7) Activity Resources paths length:" + paths.size();
        AtlasMonitor.getInstance().trace(AtlasMonitor.BUNDLE_INSTALL_FAIL, bundleName, AtlasMonitor.GET_RESOURCES_FAIL_MSG, FileUtils.getDataAvailableSpace());
    } catch (Exception e1) {
        String pathsInRunTime = " " + DelegateResources.getCurrentAssetpathStr(RuntimeVariables.androidApplication.getAssets());
        exceptionString = "(2.8) paths in history:" + pathsInRunTime + " getAssetPath fail: " + e1;
    }
    throw new RuntimeException(exceptionString, e);
}
Also used : BundleImpl(android.taobao.atlas.framework.BundleImpl) Resources(android.content.res.Resources)

Example 28 with Resources

use of android.content.res.Resources in project android_frameworks_base by ParanoidAndroid.

the class GlobalScreenshot method notifyScreenshotError.

static void notifyScreenshotError(Context context, NotificationManager nManager) {
    Resources r = context.getResources();
    // Clear all existing notification, compose the new notification and show it
    Notification.Builder b = new Notification.Builder(context).setTicker(r.getString(R.string.screenshot_failed_title)).setContentTitle(r.getString(R.string.screenshot_failed_title)).setContentText(r.getString(R.string.screenshot_failed_text)).setSmallIcon(R.drawable.stat_notify_image_error).setWhen(System.currentTimeMillis()).setAutoCancel(true);
    Notification n = new Notification.BigTextStyle(b).bigText(r.getString(R.string.screenshot_failed_text)).build();
    nManager.notify(SCREENSHOT_NOTIFICATION_ID, n);
}
Also used : Resources(android.content.res.Resources) Notification(android.app.Notification)

Example 29 with Resources

use of android.content.res.Resources in project android_frameworks_base by ParanoidAndroid.

the class NavigationBarView method updateResources.

protected void updateResources() {
    final Resources res = mContext.getResources();
    getIcons(res);
}
Also used : Resources(android.content.res.Resources)

Example 30 with Resources

use of android.content.res.Resources in project android_frameworks_base by ParanoidAndroid.

the class TabletStatusBar method loadDimens.

protected void loadDimens() {
    final Resources res = mContext.getResources();
    mNaturalBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height);
    int newIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.system_bar_icon_size);
    int newIconHPadding = res.getDimensionPixelSize(R.dimen.status_bar_icon_padding);
    int newNavIconWidth = res.getDimensionPixelSize(R.dimen.navigation_key_width);
    int newMenuNavIconWidth = res.getDimensionPixelSize(R.dimen.navigation_menu_key_width);
    if (mNavigationArea != null && newNavIconWidth != mNavIconWidth) {
        mNavIconWidth = newNavIconWidth;
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(mNavIconWidth, ViewGroup.LayoutParams.MATCH_PARENT);
        mBackButton.setLayoutParams(lp);
        mHomeButton.setLayoutParams(lp);
        RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(mNavIconWidth, ViewGroup.LayoutParams.MATCH_PARENT);
        mRecentButton.setLayoutParams(rlp);
    }
    if (mNavigationArea != null && newMenuNavIconWidth != mMenuNavIconWidth) {
        mMenuNavIconWidth = newMenuNavIconWidth;
        RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(mMenuNavIconWidth, ViewGroup.LayoutParams.MATCH_PARENT);
        // Whether to show the menu button separately or contained inside the recent-button to gain space
        if (Settings.System.getInt(mContext.getContentResolver(), Settings.System.NAV_BAR_TABUI_MENU, 0) == 1) {
            rlp.addRule(RelativeLayout.RIGHT_OF, R.id.recent_apps);
            rlp.setMargins(-(res.getDimensionPixelSize(R.dimen.navigation_menu_key_width) / 3), 0, 0, 0);
            ((ImageView) mMenuButton).setImageDrawable(res.getDrawable(R.drawable.ic_sysbar_menu));
        }
        mMenuButton.setLayoutParams(rlp);
    }
    if (newIconHPadding != mIconHPadding || newIconSize != mIconSize) {
        //            Slog.d(TAG, "size=" + newIconSize + " padding=" + newIconHPadding);
        mIconHPadding = newIconHPadding;
        mIconSize = newIconSize;
        // reload the tray
        reloadAllNotificationIcons();
    }
    int numOriginalIcons = res.getInteger(R.integer.config_maxNotificationIcons);
    final int numIcons = numOriginalIcons == 2 ? Settings.System.getInt(mContext.getContentResolver(), Settings.System.MAX_NOTIFICATION_ICONS, 2) : numOriginalIcons;
    if (numIcons != mMaxNotificationIcons) {
        mMaxNotificationIcons = numIcons;
        if (DEBUG)
            Slog.d(TAG, "max notification icons: " + mMaxNotificationIcons);
        reloadAllNotificationIcons();
    }
}
Also used : MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) LayoutParams(android.view.ViewGroup.LayoutParams) RelativeLayout(android.widget.RelativeLayout) Resources(android.content.res.Resources) ImageView(android.widget.ImageView) Point(android.graphics.Point) LinearLayout(android.widget.LinearLayout)

Aggregations

Resources (android.content.res.Resources)3195 Context (android.content.Context)292 Intent (android.content.Intent)280 View (android.view.View)236 TextView (android.widget.TextView)214 IOException (java.io.IOException)209 PackageManager (android.content.pm.PackageManager)206 Drawable (android.graphics.drawable.Drawable)197 Paint (android.graphics.Paint)178 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)176 Bitmap (android.graphics.Bitmap)174 DisplayMetrics (android.util.DisplayMetrics)165 Configuration (android.content.res.Configuration)151 Point (android.graphics.Point)151 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)137 ArrayList (java.util.ArrayList)134 XmlResourceParser (android.content.res.XmlResourceParser)132 TypedArray (android.content.res.TypedArray)129 Test (org.junit.Test)126 PendingIntent (android.app.PendingIntent)122