[2013.9.8网络首发]导入Android4.2源码里的Gallery2和Camera模块

(自带的,然后将新建CompatibilityInfoHolder.java。[备注:在有的版本上并没有遇到这个问题,有可能是android4.2将这个类去除了。]

package android.view;import android.content.res.CompatibilityInfo;/** @hide */ public class CompatibilityInfoHolder {private volatile CompatibilityInfo mCompatInfo = CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO;public void set(CompatibilityInfo compatInfo) {if (compatInfo != null && (compatInfo.isScalingRequired()|| !compatInfo.supportsScreen())) {mCompatInfo = compatInfo;} else {mCompatInfo = CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO;}}public CompatibilityInfo get() {return mCompatInfo;}public CompatibilityInfo getIfNeeded() {CompatibilityInfo ci = mCompatInfo;if (ci == null || ci == CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO) {return null;}return ci;} }

12、 再次clean编译会报错:某个函数需要的api版本要大于11,当前最低版本为10.需修改AndroidManifest.xml文件,最低api版本为11,,目标版本为17,因为我们的手机是4.2对应级别为17。

13、 再次clean编译会报错:在ImageFilterSharpen.java函数里找不到forEach_root()函数。通过对源码编译的输出路径out进行搜索,在/out/target/common/obj/APPS/GALLERY2_intermediates/src/com/android/Gallery3d/filtershow/filters文件夹下找到ScriptC_convolve3x3.java一共可以找到3份同名的文件,只有这个路径下的代码有forEach_root(Allocation, Allocation)接口。将此文件复制出来一份,粘贴到com.android.gallery3d.filtershow.filters下,将名字改为MyScriptC_convolve3x3.java,否则会跟gen文件下的文件重名,并在类的构造函数等其他地方更改名字,包名也要改。

/* * Copyright (C) 2011-2012 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 * * * * 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. *//* * This file is auto-generated. DO NOT MODIFY! * The source Renderscript file: packages/apps/Gallery2/src/com/ku/cameragal/filtershow/filters/convolve3x3.rs */package com.android.gallery3d.filtershow.filters;import android.renderscript.*;import android.content.res.Resources;/** * @hide */public class MyScriptC_convolve3x3 extends ScriptC {private static final String __rs_resource_name = "convolve3x3";// Constructorpublic MyScriptC_convolve3x3(RenderScript rs) {this(rs,rs.getApplicationContext().getResources(),rs.getApplicationContext().getResources().getIdentifier(__rs_resource_name, "raw",rs.getApplicationContext().getPackageName()));}public MyScriptC_convolve3x3(RenderScript rs, Resources resources, int id) {super(rs, resources, id);__I32 = Element.I32(rs);__ALLOCATION = Element.ALLOCATION(rs);__F32 = Element.F32(rs);__U8_4 = Element.U8_4(rs);}private Element __ALLOCATION;private Element __F32;private Element __I32;private Element __U8_4;private FieldPacker __rs_fp_ALLOCATION;private FieldPacker __rs_fp_F32;private FieldPacker __rs_fp_I32;private final static int mExportVarIdx_gWidth = 0;private int mExportVar_gWidth;public synchronized void set_gWidth(int v) {setVar(mExportVarIdx_gWidth, v);mExportVar_gWidth = v;}public int get_gWidth() {return mExportVar_gWidth;}public Script.FieldID getFieldID_gWidth() {return createFieldID(mExportVarIdx_gWidth, null);}private final static int mExportVarIdx_gHeight = 1;private int mExportVar_gHeight;public synchronized void set_gHeight(int v) {setVar(mExportVarIdx_gHeight, v);mExportVar_gHeight = v;}public int get_gHeight() {return mExportVar_gHeight;}public Script.FieldID getFieldID_gHeight() {return createFieldID(mExportVarIdx_gHeight, null);}private final static int mExportVarIdx_gPixels = 2;private Allocation mExportVar_gPixels;public void bind_gPixels(Allocation v) {mExportVar_gPixels = v;if (v == null) bindAllocation(null, mExportVarIdx_gPixels);else bindAllocation(v, mExportVarIdx_gPixels);}public Allocation get_gPixels() {return mExportVar_gPixels;}private final static int mExportVarIdx_gIn = 3;private Allocation mExportVar_gIn;public synchronized void set_gIn(Allocation v) {setVar(mExportVarIdx_gIn, v);mExportVar_gIn = v;}public Allocation get_gIn() {return mExportVar_gIn;}public Script.FieldID getFieldID_gIn() {return createFieldID(mExportVarIdx_gIn, null);}private final static int mExportVarIdx_gCoeffs = 4;private float[] mExportVar_gCoeffs;public synchronized void set_gCoeffs(float[] v) {mExportVar_gCoeffs = v;FieldPacker fp = new FieldPacker(36);for (int ct1 = 0; ct1 < 9; ct1++) {fp.addF32(v[ct1]);}int []__dimArr = new int[1];__dimArr[0] = 9;setVar(mExportVarIdx_gCoeffs, fp, __F32, __dimArr);}public float[] get_gCoeffs() {return mExportVar_gCoeffs;}public Script.FieldID getFieldID_gCoeffs() {return createFieldID(mExportVarIdx_gCoeffs, null);}private final static int mExportForEachIdx_root = 0;public Script.KernelID getKernelID_root() {return createKernelID(mExportForEachIdx_root, 3, null, null);}public void forEach_root(Allocation ain, Allocation aout) {// check ainif (!ain.getType().getElement().isCompatible(__U8_4)) {throw new RSRuntimeException("Type mismatch with U8_4!");}// check aoutif (!aout.getType().getElement().isCompatible(__U8_4)) {throw new RSRuntimeException("Type mismatch with U8_4!");}// Verify dimensionsType tIn = ain.getType();Type tOut = aout.getType();if ((tIn.getCount() != tOut.getCount()) ||(tIn.getX() != tOut.getX()) ||(tIn.getY() != tOut.getY()) ||(tIn.getZ() != tOut.getZ()) ||(tIn.hasFaces() != tOut.hasFaces()) ||(tIn.hasMipmaps() != tOut.hasMipmaps())) {throw new RSRuntimeException("Dimension mismatch between input and output parameters!");}forEach(mExportForEachIdx_root, ain, aout, null);}}大海,别为森林的渺小而沮丧,

[2013.9.8网络首发]导入Android4.2源码里的Gallery2和Camera模块

相关文章:

你感兴趣的文章:

标签云: