diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/app/ActivityManager.java | 3 | ||||
-rw-r--r-- | core/java/android/hardware/Camera.java | 22 | ||||
-rw-r--r-- | core/java/android/provider/Settings.java | 7 | ||||
-rw-r--r-- | core/java/android/service/wallpaper/WallpaperService.java | 2 | ||||
-rw-r--r-- | core/java/android/view/HardwareRenderer.java | 5 | ||||
-rw-r--r-- | core/java/com/android/internal/widget/LockPatternUtils.java | 72 | ||||
-rw-r--r-- | core/jni/android_hardware_Camera.cpp | 43 | ||||
-rw-r--r-- | core/jni/android_view_DisplayListCanvas.cpp | 11 | ||||
-rw-r--r-- | core/res/res/drawable-nodpi/stat_sys_adb.xml | 20 | ||||
-rw-r--r-- | core/res/res/raw/color_fade_frag.frag | 6 |
10 files changed, 174 insertions, 17 deletions
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index 0ae9187..5fc3437 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -529,7 +529,8 @@ public class ActivityManager { static public boolean isHighEndGfx() { return (!isLowRamDeviceStatic() && !Resources.getSystem().getBoolean(com.android.internal.R.bool.config_avoidGfxAccel)) - || isForcedHighEndGfx(); + || isForcedHighEndGfx() + || "0".equals(SystemProperties.get("ro.softwaregl", "0")); } /** diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java index dd15d38..16727fe 100644 --- a/core/java/android/hardware/Camera.java +++ b/core/java/android/hardware/Camera.java @@ -1147,7 +1147,16 @@ public class Camera { // Set to oneshot mode again. setHasPreviewCallback(true, false); } - pCb.onPreviewFrame((byte[])msg.obj, mCamera); + + byte[] luminances = (byte[])msg.obj; + if(getParameters().getPreviewFormat() == ImageFormat.RGB_565) + // Convert to greyscale + // Apps expect YUV as default format. Greyscale is + // only the first layer of YUV, but it's all that's + // needed by barcode scanner apps. + rgbToBw(luminances); + + pCb.onPreviewFrame(luminances, mCamera); } return; @@ -1216,6 +1225,17 @@ public class Camera { } } + private void rgbToBw(byte[] pixels) + { + Size previewsize = getParameters().getPreviewSize(); + int height = previewsize.height; + int width = previewsize.width; + + native_rgbToBw(pixels, width, height); + } + + private native void native_rgbToBw(byte[] pixelBuffer, int bufWidth, int bufHeight); + private static void postEventFromNative(Object camera_ref, int what, int arg1, int arg2, Object obj) { diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 3ab16fe..e6f1f4a 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -4926,6 +4926,13 @@ public final class Settings { "lock_screen_allow_private_notifications"; /** + * Separate password for encryption and the lockscreen. + * @hide + */ + public static final String LOCK_SEPARATE_ENCRYPTION_PASSWORD = + "lock_separate_encryption_password"; + + /** * Set by the system to track if the user needs to see the call to action for * the lockscreen notification policy. * @hide diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index d598291..fa3d9c9 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -189,7 +189,7 @@ public abstract class WallpaperService extends Service { final BaseSurfaceHolder mSurfaceHolder = new BaseSurfaceHolder() { { - mRequestedFormat = PixelFormat.RGBX_8888; + mRequestedFormat = PixelFormat.RGBA_8888; } @Override diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java index 5e58250..f67bb9c 100644 --- a/core/java/android/view/HardwareRenderer.java +++ b/core/java/android/view/HardwareRenderer.java @@ -19,6 +19,7 @@ package android.view; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Rect; +import android.os.SystemProperties; import android.view.Surface.OutOfResourcesException; import java.io.File; @@ -161,14 +162,14 @@ public abstract class HardwareRenderer { * * @hide */ - public static boolean sRendererDisabled = false; + public static boolean sRendererDisabled = SystemProperties.get("ro.softwaregl").equals("1") ? true : false; /** * Further hardware renderer disabling for the system process. * * @hide */ - public static boolean sSystemRendererDisabled = false; + public static boolean sSystemRendererDisabled = SystemProperties.get("ro.softwaregl").equals("1") ? true : false; private boolean mEnabled; private boolean mRequested = true; diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index 5dc91d2..d25f995 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -462,7 +462,8 @@ public class LockPatternUtils { // well, we tried... } - if (userHandle == UserHandle.USER_OWNER) { + if (userHandle == UserHandle.USER_OWNER + && !isSeparateEncryptionPasswordEnabled()) { // Set the encryption password to default. updateEncryptionPassword(StorageManager.CRYPT_TYPE_DEFAULT, null); } @@ -523,7 +524,8 @@ public class LockPatternUtils { // Update the device encryption password. if (userId == UserHandle.USER_OWNER - && LockPatternUtils.isDeviceEncryptionEnabled()) { + && LockPatternUtils.isDeviceEncryptionEnabled() + && !isSeparateEncryptionPasswordEnabled()) { if (!shouldEncryptWithCredentials(true)) { clearEncryptionPassword(); } else { @@ -732,7 +734,8 @@ public class LockPatternUtils { // Update the device encryption password. if (userHandle == UserHandle.USER_OWNER - && LockPatternUtils.isDeviceEncryptionEnabled()) { + && LockPatternUtils.isDeviceEncryptionEnabled() + && !isSeparateEncryptionPasswordEnabled()) { if (!shouldEncryptWithCredentials(true)) { clearEncryptionPassword(); } else { @@ -1089,6 +1092,69 @@ public class LockPatternUtils { } } + private void updateEncryptionPasswordFromPassword(String password) { + if (!TextUtils.isEmpty(password)) { + int computedQuality = computePasswordQuality(password); + boolean numeric = computedQuality + == DevicePolicyManager.PASSWORD_QUALITY_NUMERIC; + boolean numericComplex = computedQuality + == DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX; + int type = numeric || numericComplex ? StorageManager.CRYPT_TYPE_PIN + : StorageManager.CRYPT_TYPE_PASSWORD; + updateEncryptionPassword(type, password); + } else { + clearEncryptionPassword(); + } + } + + /** + * Set the encryption password separately from the lockscreen password. + * + * @param password The password to save + */ + public void setSeparateEncryptionPassword(String password) { + updateEncryptionPasswordFromPassword(password); + setSeparateEncryptionPasswordEnabled(true); + } + + /** + * Replace the separate encryption password by tying it to the lockscreen + * password. No change will occur if the provided lockscreen password is + * incorrect. + * + * @param password The current lockscreen password + * @return Whether the lockscreen password was correct. + */ + public void replaceSeparateEncryptionPassword(String password) { + updateEncryptionPasswordFromPassword(password); + setSeparateEncryptionPasswordEnabled(false); + } + + /** + * Replace the separate encryption password by tying it to the lockscreen + * pattern. No change will occur if the provided lockscreen password is + * incorrect. + * + * @param pattern The current lockscreen pattern + * @return Whether the lockscreen pattern was correct. + */ + public void replaceSeparateEncryptionPasswordWithPattern(List<LockPatternView.Cell> pattern, int userId) { + String stringPattern = patternToString(pattern, userId); + updateEncryptionPassword(StorageManager.CRYPT_TYPE_PATTERN, stringPattern); + setSeparateEncryptionPasswordEnabled(false); + } + + /** + * @return Whether the encryption password is separate from the lockscreen password. + */ + public boolean isSeparateEncryptionPasswordEnabled() { + return getBoolean(Settings.Secure.LOCK_SEPARATE_ENCRYPTION_PASSWORD, false, UserHandle.USER_OWNER); + } + + private void setSeparateEncryptionPasswordEnabled(boolean enabled) { + setBoolean(Settings.Secure.LOCK_SEPARATE_ENCRYPTION_PASSWORD, enabled, UserHandle.USER_OWNER); + } + /** * @return Whether tactile feedback for the pattern is enabled. */ diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp index 4cf317e..3bb6af3 100644 --- a/core/jni/android_hardware_Camera.cpp +++ b/core/jni/android_hardware_Camera.cpp @@ -79,6 +79,8 @@ struct fields_t { static fields_t fields; static Mutex sLock; +int bwDataSize = 0; + // provides persistent context for calls from native code to Java class JNICameraContext: public CameraListener { @@ -933,6 +935,44 @@ static jstring android_hardware_Camera_getParameters(JNIEnv *env, jobject thiz) return env->NewStringUTF(params8.string()); } +static void android_hardware_Camera_rgbToBw(JNIEnv *env, jobject thiz, jbyteArray pixelBuffer, jint bufWidth, jint bufHeight) +{ + int width = bufWidth; + int height = bufHeight; + int size = width * height; + + static jbyte* pixeldata; + static jbyte* luminances; + + if(bwDataSize != size) { + pixeldata = (jbyte *)malloc(size*2); + luminances = (jbyte *)malloc(size); + bwDataSize = size; + ALOGV("Allocated buffer of size %d", size); + } + + env->GetByteArrayRegion(pixelBuffer, 0, size*2, pixeldata); + + // Convert the entire image to grayscale + for (int y = 0; y < height; y++) { + int offset = y * width *2; + for (int x = 0; x < width *2; x+=2) { + jbyte pixel = pixeldata[offset +x]; + jbyte pixel2 = pixeldata[offset +x + 1]; + // little endian + // GGGBBBBB | RRRRRGGG + jbyte b = (jbyte)(pixel & 0x1f); // 5 bits + jbyte g = (jbyte)(((pixel >> 5) & 0x07) | ((pixel2 & 0x07) << 3)); // 6 bits + jbyte r = (jbyte)((pixel2 >> 3) & 0x1f); // 5 bits + + // Calculate luminance cheaply, favoring green. + luminances[(offset + x)/2] = (jbyte)((r + g + b) << 1); + } + } + + env->SetByteArrayRegion(pixelBuffer, 0, size, luminances); +} + static void android_hardware_Camera_reconnect(JNIEnv *env, jobject thiz) { ALOGV("reconnect"); @@ -1146,6 +1186,9 @@ static JNINativeMethod camMethods[] = { { "native_getParameters", "()Ljava/lang/String;", (void *)android_hardware_Camera_getParameters }, + { "native_rgbToBw", + "([BII)V", + (void *)android_hardware_Camera_rgbToBw }, { "reconnect", "()V", (void*)android_hardware_Camera_reconnect }, diff --git a/core/jni/android_view_DisplayListCanvas.cpp b/core/jni/android_view_DisplayListCanvas.cpp index ef1e4ab..fedb37d 100644 --- a/core/jni/android_view_DisplayListCanvas.cpp +++ b/core/jni/android_view_DisplayListCanvas.cpp @@ -222,14 +222,19 @@ static void android_view_DisplayListCanvas_drawLayer(JNIEnv* env, jobject clazz, static jboolean android_view_DisplayListCanvas_isAvailable(JNIEnv* env, jobject clazz) { char prop[PROPERTY_VALUE_MAX]; - if (property_get("ro.kernel.qemu", prop, NULL) == 0) { - // not in the emulator + char software_rendering[PROPERTY_VALUE_MAX]; + + property_get("ro.softwaregl", software_rendering, "0"); + + if (property_get("ro.kernel.qemu", prop, NULL) == 0 && !atoi(software_rendering)) { + // not in the emulator and device has hardware acceleration return JNI_TRUE; } + // In the emulator this property will be set to 1 when hardware GLES is // enabled, 0 otherwise. On old emulator versions it will be undefined. property_get("ro.kernel.qemu.gles", prop, "0"); - return atoi(prop) == 1 ? JNI_TRUE : JNI_FALSE; + return (atoi(prop) == 1 && !atoi(software_rendering)) ? JNI_TRUE : JNI_FALSE; } // ---------------------------------------------------------------------------- diff --git a/core/res/res/drawable-nodpi/stat_sys_adb.xml b/core/res/res/drawable-nodpi/stat_sys_adb.xml index d72d801..8cc9961 100644 --- a/core/res/res/drawable-nodpi/stat_sys_adb.xml +++ b/core/res/res/drawable-nodpi/stat_sys_adb.xml @@ -1,5 +1,5 @@ <!-- -Copyright (C) 2017 The LineageOS Project +Copyright (C) 2014 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. @@ -19,8 +19,18 @@ Copyright (C) 2017 The LineageOS Project android:viewportWidth="24.0" android:viewportHeight="24.0"> <path - android:fillColor="#FFFFFFFF" - android:pathData="M12,6 C15.3,6,18,8.7,18,12 S15.3,18,12,18 S6,15.3,6,12 S8.7,6,12,6 M12,4 -C7.6,4,4,7.6,4,12 S7.6,20,12,20 S20,16.4,20,12 S16.4,4,12,4 Z M12,9 -C10.3,9,9,10.3,9,12 S10.3,15,12,15 S15,13.7,15,12 S13.7,9,12,9 Z" /> + android:pathData="M8.4,5.3c-0.2,0.0 -0.4,-0.2 -0.5,-0.4L7.1,1.6C7.0,1.4 7.2,1.1 7.4,1.0C7.7,0.9 8.0,1.1 8.0,1.4l0.8,3.3c0.1,0.3 -0.1,0.5 -0.4,0.6C8.5,5.3 8.4,5.3 8.4,5.3z" + android:fillColor="#FFFFFF"/> + <path + android:pathData="M15.6,5.3c0.0,0.0 -0.1,0.0 -0.1,0.0c-0.3,-0.1 -0.4,-0.3 -0.4,-0.6L16.0,1.4C16.0,1.1 16.3,0.9 16.6,1.0c0.3,0.1 0.4,0.3 0.4,0.6l-0.8,3.3C16.1,5.1 15.9,5.3 15.6,5.3z" + android:fillColor="#FFFFFF"/> + <path + android:pathData="M18.6,5.4c-0.1,-0.1 -0.2,-0.1 -0.3,-0.2c0.2,0.2 0.3,0.3 0.3,0.5c0.0,0.9 -2.9,1.7 -6.6,1.7S5.4,6.7 5.4,5.7c0.0,-0.2 0.1,-0.3 0.3,-0.5C5.6,5.3 5.5,5.4 5.4,5.4C5.0,5.9 4.0,8.0 4.0,12.0s1.0,6.1 1.4,6.6C5.9,19.0 8.0,20.0 12.0,20.0s6.1,-1.0 6.6,-1.4C19.0,18.1 20.0,16.0 20.0,12.0S19.0,5.9 18.6,5.4zM8.0,13.0c-0.6,0.0 -1.0,-0.4 -1.0,-1.0c0.0,-0.6 0.4,-1.0 1.0,-1.0s1.0,0.4 1.0,1.0C9.0,12.6 8.6,13.0 8.0,13.0zM16.0,13.0c-0.6,0.0 -1.0,-0.4 -1.0,-1.0c0.0,-0.6 0.4,-1.0 1.0,-1.0s1.0,0.4 1.0,1.0C17.0,12.6 16.6,13.0 16.0,13.0z" + android:fillColor="#FFFFFF"/> + <path + android:pathData="M5.35,5.7 + a 6.6 1.75 0 1 1 13.25 0 + a 6.6 1.75 0 1 1 -13.25 0 + z" + android:fillColor="#BBFFFFFF" /> </vector> diff --git a/core/res/res/raw/color_fade_frag.frag b/core/res/res/raw/color_fade_frag.frag index a66a5a7..df3d704 100644 --- a/core/res/res/raw/color_fade_frag.frag +++ b/core/res/res/raw/color_fade_frag.frag @@ -7,6 +7,7 @@ uniform float saturation; uniform float gamma; varying vec2 UV; +/* vec3 rgb2hsl(vec3 rgb) { float e = 1.0e-7; @@ -32,11 +33,14 @@ vec3 hsl2rgb(vec3 hsl) float c = (1.0 - abs(2.0 * hsl.z - 1.0)) * hsl.y; return (rgb - vec3(0.5)) * c + hsl.z; } +*/ void main() { +/* vec4 color = texture2D(texUnit, UV); vec3 hsl = rgb2hsl(color.xyz); vec3 rgb = pow(hsl2rgb(vec3(hsl.x, hsl.y * saturation, hsl.z * opacity)), vec3(gamma)); - gl_FragColor = vec4(rgb, 1.0); +*/ + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); } |