diff options
Diffstat (limited to 'core/java/android')
44 files changed, 538 insertions, 142 deletions
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java index ff06b74..544331f 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -1600,9 +1600,10 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM case START_BACKUP_AGENT_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); - ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data); + String packageName = data.readString(); int backupRestoreMode = data.readInt(); - boolean success = bindBackupAgent(info, backupRestoreMode); + int userId = data.readInt(); + boolean success = bindBackupAgent(packageName, backupRestoreMode, userId); reply.writeNoException(); reply.writeInt(success ? 1 : 0); return true; @@ -2096,11 +2097,14 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM return true; } - case SHOW_BOOT_MESSAGE_TRANSACTION: { + case UPDATE_BOOT_PROGRESS_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); - CharSequence msg = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data); + int stage = data.readInt(); + ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data); + int current = data.readInt(); + int total = data.readInt(); boolean always = data.readInt() != 0; - showBootMessage(msg, always); + updateBootProgress(stage, info, current, total, always); reply.writeNoException(); return true; } @@ -3874,13 +3878,14 @@ class ActivityManagerProxy implements IActivityManager return binder; } - public boolean bindBackupAgent(ApplicationInfo app, int backupRestoreMode) + public boolean bindBackupAgent(String packageName, int backupRestoreMode, int userId) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); - app.writeToParcel(data, 0); + data.writeString(packageName); data.writeInt(backupRestoreMode); + data.writeInt(userId); mRemote.transact(START_BACKUP_AGENT_TRANSACTION, data, reply, 0); reply.readException(); boolean success = reply.readInt() != 0; @@ -5283,13 +5288,17 @@ class ActivityManagerProxy implements IActivityManager return res; } - public void showBootMessage(CharSequence msg, boolean always) throws RemoteException { + public void updateBootProgress(int stage, ApplicationInfo optimizedApp, + int currentAppPos, int totalAppCount, boolean always) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); - TextUtils.writeToParcel(msg, data, 0); + data.writeInt(stage); + optimizedApp.writeToParcel(data, 0); + data.writeInt(currentAppPos); + data.writeInt(totalAppCount); data.writeInt(always ? 1 : 0); - mRemote.transact(SHOW_BOOT_MESSAGE_TRANSACTION, data, reply, 0); + mRemote.transact(UPDATE_BOOT_PROGRESS_TRANSACTION, data, reply, 0); reply.readException(); data.recycle(); reply.recycle(); diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java index db4e123..c829daa 100644 --- a/core/java/android/app/ApplicationPackageManager.java +++ b/core/java/android/app/ApplicationPackageManager.java @@ -2048,9 +2048,11 @@ final class ApplicationPackageManager extends PackageManager { /** @hide */ @Override - public boolean isComponentProtected(String callingPackage, ComponentName componentName) { + public boolean isComponentProtected(String callingPackage, int callingUid, + ComponentName componentName) { try { - return mPM.isComponentProtected(callingPackage, componentName, mContext.getUserId()); + return mPM.isComponentProtected(callingPackage, callingUid, componentName, + mContext.getUserId()); } catch (RemoteException re) { Log.e(TAG, "Failed to get component protected setting", re); return false; diff --git a/core/java/android/app/ComposedIconInfo.java b/core/java/android/app/ComposedIconInfo.java index f49c230..71321c1 100644 --- a/core/java/android/app/ComposedIconInfo.java +++ b/core/java/android/app/ComposedIconInfo.java @@ -74,11 +74,9 @@ public class ComposedIconInfo implements Parcelable { iconPaletteBack = source.readInt(); swatchType = SwatchType.values()[source.readInt()]; int numDefaultColors = source.readInt(); - if (numDefaultColors > 0) { - defaultSwatchColors = new int[numDefaultColors]; - for (int i = 0; i < numDefaultColors; i++) { - defaultSwatchColors[i] = source.readInt(); - } + defaultSwatchColors = new int[numDefaultColors]; + for (int i = 0; i < numDefaultColors; i++) { + defaultSwatchColors[i] = source.readInt(); } } diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index d443d80..6896c21 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -2018,6 +2018,11 @@ class ContextImpl extends Context { } result.add(dir); } + + // Make sure there is at least one element, let the callers handle that + if (result.size() == 0) { + result.add(null); + } return result.toArray(new File[result.size()]); } diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java index 682ab97..b382b76 100644 --- a/core/java/android/app/DownloadManager.java +++ b/core/java/android/app/DownloadManager.java @@ -1038,7 +1038,7 @@ public class DownloadManager { if (cursor.moveToFirst()) { int status = cursor.getInt(cursor.getColumnIndexOrThrow(COLUMN_STATUS)); if (DownloadManager.STATUS_SUCCESSFUL == status) { - return ContentUris.withAppendedId(Downloads.Impl.CONTENT_URI, id); + return ContentUris.withAppendedId(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, id); } } } finally { @@ -1263,7 +1263,7 @@ public class DownloadManager { * @hide */ public Uri getDownloadUri(long id) { - return ContentUris.withAppendedId(mBaseUri, id); + return ContentUris.withAppendedId(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, id); } /** @@ -1344,7 +1344,7 @@ public class DownloadManager { // return content URI for cache download long downloadId = getLong(getColumnIndex(Downloads.Impl._ID)); - return ContentUris.withAppendedId(mBaseUri, downloadId).toString(); + return ContentUris.withAppendedId(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, downloadId).toString(); } private long getReason(int status) { diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java index 6370268..75951cf 100644 --- a/core/java/android/app/IActivityManager.java +++ b/core/java/android/app/IActivityManager.java @@ -184,7 +184,7 @@ public interface IActivityManager extends IInterface { public IBinder peekService(Intent service, String resolvedType, String callingPackage) throws RemoteException; - public boolean bindBackupAgent(ApplicationInfo appInfo, int backupRestoreMode) + public boolean bindBackupAgent(String packageName, int backupRestoreMode, int userId) throws RemoteException; public void clearPendingBackup() throws RemoteException; public void backupAgentCreated(String packageName, IBinder agent) throws RemoteException; @@ -408,7 +408,8 @@ public interface IActivityManager extends IInterface { public long[] getProcessPss(int[] pids) throws RemoteException; - public void showBootMessage(CharSequence msg, boolean always) throws RemoteException; + public void updateBootProgress(int stage, ApplicationInfo optimizedApp, + int currentAppPos, int totalAppCount, boolean always) throws RemoteException; public void keyguardWaitingForActivityDrawn() throws RemoteException; @@ -622,6 +623,11 @@ public interface IActivityManager extends IInterface { } } + public static final int BOOT_STAGE_STARTING_APPS = 1; + public static final int BOOT_STAGE_FSTRIM = 2; + public static final int BOOT_STAGE_PREPARING_APPS = 3; + public static final int BOOT_STAGE_COMPLETE = 4; + String descriptor = "android.app.IActivityManager"; // Please keep these transaction codes the same -- they are also @@ -757,7 +763,7 @@ public interface IActivityManager extends IInterface { int IS_INTENT_SENDER_TARGETED_TO_PACKAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+134; int UPDATE_PERSISTENT_CONFIGURATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+135; int GET_PROCESS_PSS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+136; - int SHOW_BOOT_MESSAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+137; + int UPDATE_BOOT_PROGRESS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+137; int KILL_ALL_BACKGROUND_PROCESSES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+139; int GET_CONTENT_PROVIDER_EXTERNAL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+140; int REMOVE_CONTENT_PROVIDER_EXTERNAL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+141; diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl index f78fb47..06c064f 100644 --- a/core/java/android/app/INotificationManager.aidl +++ b/core/java/android/app/INotificationManager.aidl @@ -55,6 +55,12 @@ interface INotificationManager void setPackageVisibilityOverride(String pkg, int uid, int visibility); int getPackageVisibilityOverride(String pkg, int uid); + void setShowNotificationForPackageOnKeyguard(String pkg, int uid, int status); + int getShowNotificationForPackageOnKeyguard(String pkg, int uid); + + void setPackageNotificationSoundTimeout(String pkg, int uid, long timeout); + long getPackageNotificationSoundTimeout(String pkg, int uid); + // TODO: Remove this when callers have been migrated to the equivalent // INotificationListener method. StatusBarNotification[] getActiveNotifications(String callingPkg); @@ -77,7 +83,7 @@ interface INotificationManager void setInterruptionFilter(String pkg, int interruptionFilter); ComponentName getEffectsSuppressor(); - boolean matchesCallFilter(in Bundle extras); + boolean[] matchesCallFilter(in Bundle extras); boolean isSystemConditionProviderEnabled(String path); int getZenMode(); @@ -97,4 +103,6 @@ interface INotificationManager void applyRestore(in byte[] payload, int user); ParceledListSlice getAppActiveNotifications(String callingPkg, int userId); + + boolean deviceLightsCan(int lightCapability); } diff --git a/core/java/android/app/IconPackHelper.java b/core/java/android/app/IconPackHelper.java index 80fb401..9c71ddd 100644 --- a/core/java/android/app/IconPackHelper.java +++ b/core/java/android/app/IconPackHelper.java @@ -633,33 +633,42 @@ public class IconPackHelper { } TypedValue tempValue = new TypedValue(); tempValue.setTo(outValue); - outValue.assetCookie = COMPOSED_ICON_COOKIE; - outValue.data = resId & (COMPOSED_ICON_COOKIE << 24 | 0x00ffffff); - outValue.string = getCachedIconPath(pkgName, resId, outValue.density); - int hashCode = outValue.string.hashCode() & 0x7fffffff; - int defaultSwatchColor = 0; - - if (!(new File(outValue.string.toString()).exists())) { - // compose the icon and cache it - int back = 0; - if (iconInfo.swatchType != ComposedIconInfo.SwatchType.None) { - back = iconInfo.iconPaletteBack; - if (iconInfo.defaultSwatchColors.length > 0) { - defaultSwatchColor =iconInfo.defaultSwatchColors[ - hashCode % iconInfo.defaultSwatchColors.length]; + // Catch all exceptions and restore outValue to tempValue if one occurs + try { + outValue.assetCookie = COMPOSED_ICON_COOKIE; + outValue.data = resId & (COMPOSED_ICON_COOKIE << 24 | 0x00ffffff); + outValue.string = getCachedIconPath(pkgName, resId, outValue.density); + int hashCode = outValue.string.hashCode() & 0x7fffffff; + int defaultSwatchColor = 0; + + if (!(new File(outValue.string.toString()).exists())) { + // compose the icon and cache it + int back = 0; + if (iconInfo.swatchType != ComposedIconInfo.SwatchType.None) { + back = iconInfo.iconPaletteBack; + if (iconInfo.defaultSwatchColors.length > 0) { + defaultSwatchColor = iconInfo.defaultSwatchColors[ + hashCode % iconInfo.defaultSwatchColors.length]; + } + } else if (iconInfo.iconBacks != null && iconInfo.iconBacks.length > 0) { + back = iconInfo.iconBacks[hashCode % iconInfo.iconBacks.length]; + } + if (DEBUG) { + Log.d(TAG, "Composing icon for " + pkgName); + } + Bitmap bmp = createIconBitmap(baseIcon, res, back, defaultSwatchColor, + iconInfo); + if (!cacheComposedIcon(bmp, + getCachedIconName(pkgName, resId, outValue.density))) { + Log.w(TAG, "Unable to cache icon " + outValue.string); + // restore the original TypedValue + outValue.setTo(tempValue); } - } else if (iconInfo.iconBacks != null && iconInfo.iconBacks.length > 0) { - back = iconInfo.iconBacks[hashCode % iconInfo.iconBacks.length]; - } - if (DEBUG) { - Log.d(TAG, "Composing icon for " + pkgName); - } - Bitmap bmp = createIconBitmap(baseIcon, res, back, defaultSwatchColor, iconInfo); - if (!cacheComposedIcon(bmp, getCachedIconName(pkgName, resId, outValue.density))) { - Log.w(TAG, "Unable to cache icon " + outValue.string); - // restore the original TypedValue - outValue.setTo(tempValue); } + } catch (Exception e) { + // catch all, restore the original value and log it + outValue.setTo(tempValue); + Log.w(TAG, "getValue failed for " + outValue.string, e); } } diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index d8e01cd..8835a09 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -523,6 +523,21 @@ public class Notification implements Parcelable public int priority; /** + * Default. + * Show all notifications from an app on keyguard. + * + * @hide + */ + public static final int SHOW_ALL_NOTI_ON_KEYGUARD = 0x01; + + /** + * Show only notifications from an app which are not ongoing ones. + * + * @hide + */ + public static final int SHOW_NO_ONGOING_NOTI_ON_KEYGUARD = 0x02; + + /** * Accent color (an ARGB integer like the constants in {@link android.graphics.Color}) * to be applied by the standard Style templates when presenting this notification. * diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java index 605c006..eae2599 100644 --- a/core/java/android/app/NotificationManager.java +++ b/core/java/android/app/NotificationManager.java @@ -19,6 +19,7 @@ package android.app; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SdkConstant; +import android.app.Notification; import android.app.Notification.Builder; import android.content.ComponentName; import android.content.Context; @@ -340,12 +341,12 @@ public class NotificationManager /** * @hide */ - public boolean matchesCallFilter(Bundle extras) { + public boolean[] matchesCallFilter(Bundle extras) { INotificationManager service = getService(); try { return service.matchesCallFilter(extras); } catch (RemoteException e) { - return false; + return null; } } @@ -512,6 +513,16 @@ public class NotificationManager return new ArraySet<String>(); } + /** @hide */ + public int getShowNotificationForPackageOnKeyguard(String pkg, int uid) { + INotificationManager service = getService(); + try { + return getService().getShowNotificationForPackageOnKeyguard(pkg, uid); + } catch (RemoteException e) { + return Notification.SHOW_ALL_NOTI_ON_KEYGUARD; + } + } + private Context mContext; private static void checkRequired(String name, Object value) { @@ -754,4 +765,32 @@ public class NotificationManager default: return defValue; } } + + /** @hide */ + public static final int LIGHTS_RGB_NOTIFICATION = 0; + /** @hide */ + public static final int LIGHTS_RGB_BATTERY = 1 ; + /** @hide */ + public static final int LIGHTS_MULTIPLE_LED = 2; + /** @hide */ + public static final int LIGHTS_LED_PULSE = 3; + /** @hide */ + public static final int LIGHTS_SEGMENTED_BATTERY_LIGHTS = 4; + /** @hide */ + public static final int LIGHTS_ADJUSTABLE_NOTIFICATION_BRIGHTNESS = 5; + + /** @hide */ + public boolean deviceLightsCan(int lightCapability) { + INotificationManager service = getService(); + try { + return service.deviceLightsCan(lightCapability); + } catch (RemoteException e) { + return true; + } catch (NullPointerException e) { + return true; + } + // If the service isn't up yet, assume everything is possible + } + + } diff --git a/core/java/android/app/ResourcesManager.java b/core/java/android/app/ResourcesManager.java index e2d0537..c8aec2e 100644 --- a/core/java/android/app/ResourcesManager.java +++ b/core/java/android/app/ResourcesManager.java @@ -335,18 +335,6 @@ public class ResourcesManager { ResourcesKey key = new ResourcesKey(resDir, displayId, null, compatInfo.applicationScale, isThemeable, themeConfig); - synchronized (this) { - WeakReference<Resources> wr = mActiveResources.get(key); - r = wr != null ? wr.get() : null; - if (r != null && r.getAssets().isUpToDate()) { - if (false) { - Slog.w(TAG, "Returning cached resources " + r + " " + resDir - + ": appScale=" + r.getCompatibilityInfo().applicationScale); - } - return r; - } - } - AssetManager assets = new AssetManager(); assets.setAppName(packageName); assets.setThemeSupport(isThemeable); @@ -387,20 +375,7 @@ public class ResourcesManager { + r.getCompatibilityInfo().applicationScale); } - synchronized (this) { - WeakReference<Resources> wr = mActiveResources.get(key); - Resources existing = wr != null ? wr.get() : null; - if (existing != null && existing.getAssets().isUpToDate()) { - // Someone else already created the resources while we were - // unlocked; go ahead and use theirs. - r.getAssets().close(); - return existing; - } - - // XXX need to remove entries when weak references go away - mActiveResources.put(key, new WeakReference<Resources>(r)); - return r; - } + return r; } /** @@ -576,6 +551,7 @@ public class ResourcesManager { PackageInfo piTheme = null; PackageInfo piTarget = null; PackageInfo piAndroid = null; + PackageInfo piCm = null; // Some apps run in process of another app (eg keyguard/systemUI) so we must get the // package name from the res tables. The 0th base package name will be the android group. @@ -609,16 +585,20 @@ public class ResourcesManager { } piAndroid = getPackageManager().getPackageInfo("android", 0, UserHandle.getCallingUserId()); + piCm = getPackageManager().getPackageInfo("cyanogenmod.platform", 0, + UserHandle.getCallingUserId()); } catch (RemoteException e) { } if (piTheme == null || piTheme.applicationInfo == null || piTarget == null || piTarget.applicationInfo == null || piAndroid == null || piAndroid.applicationInfo == null || + piCm == null || piCm.applicationInfo == null || piTheme.mOverlayTargets == null) { return false; } + // Attach themed resources for target String themePackageName = piTheme.packageName; String themePath = piTheme.applicationInfo.publicSourceDir; if (!piTarget.isThemeApk && piTheme.mOverlayTargets.contains(basePackageName)) { @@ -638,6 +618,24 @@ public class ResourcesManager { } } + // Attach themed resources for cmsdk + if (!piTarget.isThemeApk && !piCm.packageName.equals(basePackageName) && + piTheme.mOverlayTargets.contains(piCm.packageName)) { + String resCachePath= ThemeUtils.getTargetCacheDir(piCm.packageName, + piTheme.packageName); + String prefixPath = ThemeUtils.getOverlayPathToTarget(piCm.packageName); + String targetPackagePath = piCm.applicationInfo.publicSourceDir; + String resApkPath = resCachePath + "/resources.apk"; + String idmapPath = ThemeUtils.getIdmapPath(piCm.packageName, piTheme.packageName); + int cookie = assets.addOverlayPath(idmapPath, themePath, + resApkPath, targetPackagePath, prefixPath); + if (cookie != 0) { + assets.setThemePackageName(themePackageName); + assets.addThemeCookie(cookie); + } + } + + // Attach themed resources for android framework if (!piTarget.isThemeApk && !"android".equals(basePackageName) && piTheme.mOverlayTargets.contains("android")) { String resCachePath= ThemeUtils.getTargetCacheDir(piAndroid.packageName, diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index f924bc1..71183d9 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -2067,13 +2067,14 @@ public final class BluetoothAdapter { } public void onBluetoothServiceDown() { - if (VDBG) Log.d(TAG, "onBluetoothServiceDown: " + mService); + Log.d(TAG, "onBluetoothServiceDown: " + mService); synchronized (mManagerCallback) { mService = null; if (mLeScanClients != null) mLeScanClients.clear(); if (sBluetoothLeAdvertiser != null) sBluetoothLeAdvertiser.cleanup(); if (sBluetoothLeScanner != null) sBluetoothLeScanner.cleanup(); synchronized (mProxyServiceStateCallbacks) { + Log.d(TAG, "onBluetoothServiceDown: Sending callbacks to " + mProxyServiceStateCallbacks.size() + " clients"); for (IBluetoothManagerCallback cb : mProxyServiceStateCallbacks ){ try { if (cb != null) { @@ -2085,6 +2086,7 @@ public final class BluetoothAdapter { } } } + Log.d(TAG, "onBluetoothServiceDown: Finished sending callbacks to registered clients"); } public void onBrEdrDown() { diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java index b4006de..d7d248f 100644 --- a/core/java/android/bluetooth/BluetoothDevice.java +++ b/core/java/android/bluetooth/BluetoothDevice.java @@ -1166,12 +1166,12 @@ public final class BluetoothDevice implements Parcelable { /** * Confirm passkey for {@link #PAIRING_VARIANT_PASSKEY_CONFIRMATION} pairing. - * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}. + * <p>Requires {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED}. * * @return true confirmation has been sent out * false for error */ - @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN) + @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setPairingConfirmation(boolean confirm) { if (sService == null) { Log.e(TAG, "BT not enabled. Cannot set pairing confirmation"); diff --git a/core/java/android/content/IntentFilter.java b/core/java/android/content/IntentFilter.java index 3a17e23..ed5dfa5 100644 --- a/core/java/android/content/IntentFilter.java +++ b/core/java/android/content/IntentFilter.java @@ -883,6 +883,15 @@ public class IntentFilter implements Parcelable { return true; } + @Override + public boolean equals(Object obj) { + if (obj instanceof AuthorityEntry) { + final AuthorityEntry other = (AuthorityEntry)obj; + return match(other); + } + return false; + } + /** * Determine whether this AuthorityEntry matches the given data Uri. * <em>Note that this comparison is case-sensitive, unlike formal @@ -917,7 +926,7 @@ public class IntentFilter implements Parcelable { } return MATCH_CATEGORY_HOST; } - }; + } /** * Add a new Intent data "scheme specific part" to match against. The filter must diff --git a/core/java/android/content/SyncInfo.java b/core/java/android/content/SyncInfo.java index a586d6f..ab3c30b 100644 --- a/core/java/android/content/SyncInfo.java +++ b/core/java/android/content/SyncInfo.java @@ -24,6 +24,13 @@ import android.os.Parcelable; * Information about the sync operation that is currently underway. */ public class SyncInfo implements Parcelable { + /** + * Used when the caller receiving this object doesn't have permission to access the accounts + * on device. + * @See Manifest.permission.GET_ACCOUNTS + */ + private static final Account REDACTED_ACCOUNT = new Account("*****", "*****"); + /** @hide */ public final int authorityId; @@ -44,6 +51,17 @@ public class SyncInfo implements Parcelable { */ public final long startTime; + /** + * Creates a SyncInfo object with an unusable Account. Used when the caller receiving this + * object doesn't have access to the accounts on the device. + * @See Manifest.permission.GET_ACCOUNTS + * @hide + */ + public static SyncInfo createAccountRedacted( + int authorityId, String authority, long startTime) { + return new SyncInfo(authorityId, REDACTED_ACCOUNT, authority, startTime); + } + /** @hide */ public SyncInfo(int authorityId, Account account, String authority, long startTime) { this.authorityId = authorityId; diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl index 6d8b5cb..51f13af 100644 --- a/core/java/android/content/pm/IPackageManager.aidl +++ b/core/java/android/content/pm/IPackageManager.aidl @@ -521,6 +521,9 @@ interface IPackageManager { int processThemeResources(String themePkgName); /** Protected Apps */ - boolean isComponentProtected(in String callingPackage, in ComponentName componentName, - int userId); + boolean isComponentProtected(in String callingPackage, in int callingUid, + in ComponentName componentName, int userId); + + /** protected broadcast ext */ + boolean isProtectedBroadcastAllowed(in String actionName, in int callingUid); } diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index 529d641..8f0500e 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -4564,7 +4564,7 @@ public abstract class PackageManager { * Return whether or not a specific component is protected * @hide */ - public abstract boolean isComponentProtected(String callingPackage, + public abstract boolean isComponentProtected(String callingPackage, int callingUid, ComponentName componentName); /** diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index 6a07b31..bb46ef0 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -1877,14 +1877,18 @@ public class PackageParser { String name = sa.getNonResourceString( com.android.internal.R.styleable.AndroidManifestProtectedBroadcast_name); + String permission = sa.getNonResourceString( + com.android.internal.R.styleable.AndroidManifestProtectedBroadcast_permission); + sa.recycle(); if (name != null && (flags&PARSE_IS_SYSTEM) != 0) { if (pkg.protectedBroadcasts == null) { - pkg.protectedBroadcasts = new ArrayList<String>(); + pkg.protectedBroadcasts = new ArrayMap<>(); } - if (!pkg.protectedBroadcasts.contains(name)) { - pkg.protectedBroadcasts.add(name.intern()); + if (!pkg.protectedBroadcasts.containsKey(name)) { + pkg.protectedBroadcasts.put(name.intern(), + permission != null ? permission.intern() : null); } } @@ -4519,7 +4523,10 @@ public class PackageParser { public final ArrayList<String> requestedPermissions = new ArrayList<String>(); - public ArrayList<String> protectedBroadcasts; + /** + * Maps from package -> permission, null for system (default behavior) + */ + public ArrayMap<String,String> protectedBroadcasts; public ArrayList<String> libraryNames = null; public ArrayList<String> usesLibraries = null; diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index 6a404e2..7fa04f9 100644 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -120,6 +120,8 @@ public class Resources { public static final int THEME_APP_PKG_ID = 0x61; /** @hide */ public static final int THEME_ICON_PKG_ID = 0x62; + /** @hide */ + public static final int THEME_CM_PKG_ID = 0x63; /** * The common resource pkg id needs to be less than the THEME_FRAMEWORK_PKG_ID * otherwise aapt will complain and fail diff --git a/core/java/android/hardware/camera2/legacy/RequestThreadManager.java b/core/java/android/hardware/camera2/legacy/RequestThreadManager.java index a0a03b1..c26d07d 100644 --- a/core/java/android/hardware/camera2/legacy/RequestThreadManager.java +++ b/core/java/android/hardware/camera2/legacy/RequestThreadManager.java @@ -81,6 +81,7 @@ public class RequestThreadManager { private static final int PREVIEW_FRAME_TIMEOUT = 1000; // ms private static final int JPEG_FRAME_TIMEOUT = 4000; // ms (same as CTS for API2) + private static final int HDR_TIMEOUT = 20000; //ms private static final int REQUEST_COMPLETE_TIMEOUT = JPEG_FRAME_TIMEOUT; private static final float ASPECT_RATIO_TOLERANCE = 0.01f; @@ -825,7 +826,9 @@ public class RequestThreadManager { if (holder.hasJpegTargets()) { doJpegCapture(holder); - if (!mReceivedJpeg.block(JPEG_FRAME_TIMEOUT)) { + if (!mReceivedJpeg.block( + mParams.getSceneMode().equals(mParams.SCENE_MODE_HDR) + ? HDR_TIMEOUT : JPEG_FRAME_TIMEOUT)) { Log.e(TAG, "Hit timeout for jpeg callback!"); mCaptureCollector.failNextJpeg(); } diff --git a/core/java/android/hardware/fingerprint/FingerprintManager.java b/core/java/android/hardware/fingerprint/FingerprintManager.java index 122df23..62396a3 100644 --- a/core/java/android/hardware/fingerprint/FingerprintManager.java +++ b/core/java/android/hardware/fingerprint/FingerprintManager.java @@ -258,6 +258,7 @@ public class FingerprintManager { public static class AuthenticationResult { private Fingerprint mFingerprint; private CryptoObject mCryptoObject; + private int mUserId; /** * Authentication result @@ -266,9 +267,10 @@ public class FingerprintManager { * @param fingerprint the recognized fingerprint data, if allowed. * @hide */ - public AuthenticationResult(CryptoObject crypto, Fingerprint fingerprint) { + public AuthenticationResult(CryptoObject crypto, Fingerprint fingerprint, int userId) { mCryptoObject = crypto; mFingerprint = fingerprint; + mUserId = userId; } /** @@ -285,6 +287,12 @@ public class FingerprintManager { * @hide */ public Fingerprint getFingerprint() { return mFingerprint; } + + /** + * Obtain the userId for which this fingerprint was authenticated. + * @hide + */ + public int getUserId() { return mUserId; } }; /** @@ -754,7 +762,7 @@ public class FingerprintManager { sendAcquiredResult((Long) msg.obj /* deviceId */, msg.arg1 /* acquire info */); break; case MSG_AUTHENTICATION_SUCCEEDED: - sendAuthenticatedSucceeded((Fingerprint) msg.obj); + sendAuthenticatedSucceeded((Fingerprint) msg.obj, msg.arg1 /* userId */); break; case MSG_AUTHENTICATION_FAILED: sendAuthenticatedFailed(); @@ -799,9 +807,10 @@ public class FingerprintManager { } } - private void sendAuthenticatedSucceeded(Fingerprint fp) { + private void sendAuthenticatedSucceeded(Fingerprint fp, int userId) { if (mAuthenticationCallback != null) { - final AuthenticationResult result = new AuthenticationResult(mCryptoObject, fp); + final AuthenticationResult result = + new AuthenticationResult(mCryptoObject, fp, userId); mAuthenticationCallback.onAuthenticationSucceeded(result); } } @@ -941,8 +950,8 @@ public class FingerprintManager { } @Override // binder call - public void onAuthenticationSucceeded(long deviceId, Fingerprint fp) { - mHandler.obtainMessage(MSG_AUTHENTICATION_SUCCEEDED, fp).sendToTarget(); + public void onAuthenticationSucceeded(long deviceId, Fingerprint fp, int userId) { + mHandler.obtainMessage(MSG_AUTHENTICATION_SUCCEEDED, userId, 0, fp).sendToTarget(); } @Override // binder call diff --git a/core/java/android/hardware/fingerprint/IFingerprintServiceReceiver.aidl b/core/java/android/hardware/fingerprint/IFingerprintServiceReceiver.aidl index 57a429f..b024b29 100644 --- a/core/java/android/hardware/fingerprint/IFingerprintServiceReceiver.aidl +++ b/core/java/android/hardware/fingerprint/IFingerprintServiceReceiver.aidl @@ -26,7 +26,7 @@ import android.os.UserHandle; oneway interface IFingerprintServiceReceiver { void onEnrollResult(long deviceId, int fingerId, int groupId, int remaining); void onAcquired(long deviceId, int acquiredInfo); - void onAuthenticationSucceeded(long deviceId, in Fingerprint fp); + void onAuthenticationSucceeded(long deviceId, in Fingerprint fp, int userId); void onAuthenticationFailed(long deviceId); void onError(long deviceId, int error); void onRemoved(long deviceId, int fingerId, int groupId); diff --git a/core/java/android/net/INetworkStatsService.aidl b/core/java/android/net/INetworkStatsService.aidl index 6436e42..17033c4 100644 --- a/core/java/android/net/INetworkStatsService.aidl +++ b/core/java/android/net/INetworkStatsService.aidl @@ -57,4 +57,5 @@ interface INetworkStatsService { /** Advise persistance threshold; may be overridden internally. */ void advisePersistThreshold(long thresholdBytes); + void resetDataUsageHistoryForAllUid(in NetworkTemplate template); } diff --git a/core/java/android/net/NetworkPolicyManager.java b/core/java/android/net/NetworkPolicyManager.java index eab22b8..7f4d6e3 100644 --- a/core/java/android/net/NetworkPolicyManager.java +++ b/core/java/android/net/NetworkPolicyManager.java @@ -49,6 +49,12 @@ public class NetworkPolicyManager { public static final int POLICY_REJECT_METERED_BACKGROUND = 0x1; /** Allow network use (metered or not) in the background in battery save mode. */ public static final int POLICY_ALLOW_BACKGROUND_BATTERY_SAVE = 0x2; + /** Reject application network traffic on wifi network **/ + public static final int POLICY_REJECT_ON_WLAN = 0x8000; + /** Reject application network traffic on cellular network **/ + public static final int POLICY_REJECT_ON_DATA = 0x10000; + /** Reject application background network traffic on WiFi network **/ + public static final int POLICY_REJECT_ON_WLAN_BACKGROUND = 0x20000; /* RULE_* are not masks and they must be exclusive */ public static final int RULE_UNKNOWN = -1; diff --git a/core/java/android/net/PacProxySelector.java b/core/java/android/net/PacProxySelector.java index 9bdf4f6..85bf79a 100644 --- a/core/java/android/net/PacProxySelector.java +++ b/core/java/android/net/PacProxySelector.java @@ -30,6 +30,7 @@ import java.net.Proxy.Type; import java.net.ProxySelector; import java.net.SocketAddress; import java.net.URI; +import java.net.URISyntaxException; import java.util.List; /** @@ -67,7 +68,15 @@ public class PacProxySelector extends ProxySelector { String response = null; String urlString; try { + // Strip path and username/password from URI so it's not visible to PAC script. The + // path often contains credentials the app does not want exposed to a potentially + // malicious PAC script. + if (!"http".equalsIgnoreCase(uri.getScheme())) { + uri = new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(), "/", null, null); + } urlString = uri.toURL().toString(); + } catch (URISyntaxException e) { + urlString = uri.getHost(); } catch (MalformedURLException e) { urlString = uri.getHost(); } diff --git a/core/java/android/net/ZeroBalanceHelper.java b/core/java/android/net/ZeroBalanceHelper.java new file mode 100644 index 0000000..e0ffca5 --- /dev/null +++ b/core/java/android/net/ZeroBalanceHelper.java @@ -0,0 +1,99 @@ +/* + ** Copyright (c) 2015, The Linux Foundation. All rights reserved. + + ** Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are + ** met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above + ** copyright notice, this list of conditions and the following + ** disclaimer in the documentation and/or other materials provided + ** with the distribution. + ** * Neither the name of The Linux Foundation nor the names of its + ** contributors may be used to endorse or promote products derived + ** from this software without specific prior written permission. + + ** THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + ** BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + ** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + ** BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + ** OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + ** IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package android.net; + +import android.app.ActivityThread; +import android.content.Context; +import android.content.Intent; +import android.os.SystemProperties; +import android.os.UserHandle; +import android.util.Log; + +import com.android.internal.R; + +/** @hide */ +public final class ZeroBalanceHelper { + + public static final String BACKGROUND_DATA_PROPERTY = "sys.background.data.disable"; + public static final String BACKGROUND_DATA_BROADCAST = "org.codeaurora.background.data"; + public static final String TAG = "ZeroBalance"; + + private static int sRedirectCount = 0; + private static int sRedirectMaxCount = 3; + + private Context mContext = null; + + public ZeroBalanceHelper() { + mContext = ActivityThread.currentApplication(); + } + + public void setBgDataProperty(String enabled) { + Intent intent = new Intent(); + intent.setAction(BACKGROUND_DATA_BROADCAST); + intent.putExtra("enabled", enabled); + mContext.sendBroadcast(intent); + } + + public String getBgDataProperty() { + String isBgDataPropertySet = SystemProperties.get(BACKGROUND_DATA_PROPERTY, "false"); + if (Boolean.parseBoolean(isBgDataPropertySet)) { + sRedirectCount = 0; + } + return isBgDataPropertySet; + } + + private String getConfiguredRedirectURL() { + String redirectURL = mContext.getResources().getString( + com.android.internal.R.string.operator_config_url); + Log.d(TAG, "Returning the configured redirect URL : " + + redirectURL); + return redirectURL; + } + + public synchronized void setHttpRedirectCount(String url) { + String redirectUrl = getConfiguredRedirectURL(); + if (redirectUrl != null && url.contains(redirectUrl)) { + sRedirectCount++; + Log.d(TAG, "http:sRedirectCount="+sRedirectCount); + if (sRedirectCount >= sRedirectMaxCount) { + Log.d(TAG,"http:Background Data will be disabled" ); + setBgDataProperty("true"); + sRedirectCount = 0; + } + } else { + Log.d(TAG,"http: resetting the counter "); + sRedirectCount = 0; + } + } + + public boolean getFeatureConfigValue() { + return mContext.getResources().getBoolean(R.bool.config_zero_balance_operator); + } +} diff --git a/core/java/android/nfc/INfcAdapter.aidl b/core/java/android/nfc/INfcAdapter.aidl index 961a3f4..0107d93 100644 --- a/core/java/android/nfc/INfcAdapter.aidl +++ b/core/java/android/nfc/INfcAdapter.aidl @@ -1,4 +1,7 @@ /* + * Copyright (c) 2015, The Linux Foundation. All rights reserved. + * Not a Contribution. + * * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,6 +31,7 @@ import android.nfc.INfcTag; import android.nfc.INfcCardEmulation; import android.nfc.INfcUnlockHandler; import android.os.Bundle; +import android.os.IBinder; /** * @hide @@ -37,6 +41,7 @@ interface INfcAdapter INfcTag getNfcTagInterface(); INfcCardEmulation getNfcCardEmulationInterface(); INfcAdapterExtras getNfcAdapterExtrasInterface(in String pkg); + IBinder getNfcAdapterVendorInterface(in String vendor); int getState(); boolean disable(boolean saveState); diff --git a/core/java/android/nfc/cardemulation/AidGroup.java b/core/java/android/nfc/cardemulation/AidGroup.java index 78a9401..9abf325 100644 --- a/core/java/android/nfc/cardemulation/AidGroup.java +++ b/core/java/android/nfc/cardemulation/AidGroup.java @@ -1,6 +1,9 @@ /* * Copyright (C) 2015 The Android Open Source Project * + * Copyright (c) 2015, The Linux Foundation. All rights reserved. + * Not a Contribution. + * * 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 @@ -37,7 +40,7 @@ import android.util.Log; * * @hide */ -public final class AidGroup implements Parcelable { +public class AidGroup implements Parcelable { /** * The maximum number of AIDs that can be present in any one group. */ @@ -45,9 +48,9 @@ public final class AidGroup implements Parcelable { static final String TAG = "AidGroup"; - final List<String> aids; - final String category; - final String description; + protected List<String> aids; + protected String category; + protected String description; /** * Creates a new AidGroup object. diff --git a/core/java/android/nfc/tech/MifareClassic.java b/core/java/android/nfc/tech/MifareClassic.java index 8c92288..302c02d 100644 --- a/core/java/android/nfc/tech/MifareClassic.java +++ b/core/java/android/nfc/tech/MifareClassic.java @@ -1,4 +1,6 @@ /* + * Copyright (C) 2015 NXP Semiconductors + * The original Work has been changed by NXP Semiconductors. * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -173,6 +175,10 @@ public final class MifareClassic extends BasicTagTechnology { mType = TYPE_CLASSIC; mSize = SIZE_4K; break; + case 0x19: + mType = TYPE_CLASSIC; + mSize = SIZE_2K; + break; case 0x28: mType = TYPE_CLASSIC; mSize = SIZE_1K; diff --git a/core/java/android/nfc/tech/NfcA.java b/core/java/android/nfc/tech/NfcA.java index 88730f9..b7fa455 100644 --- a/core/java/android/nfc/tech/NfcA.java +++ b/core/java/android/nfc/tech/NfcA.java @@ -1,4 +1,6 @@ /* + * Copyright (C) 2015 NXP Semiconductors + * The original Work has been changed by NXP Semiconductors. * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -66,8 +68,15 @@ public final class NfcA extends BasicTagTechnology { /** @hide */ public NfcA(Tag tag) throws RemoteException { super(tag, TagTechnology.NFC_A); - Bundle extras = tag.getTechExtras(TagTechnology.NFC_A); - mSak = extras.getShort(EXTRA_SAK); + Bundle extras; + mSak = 0; + if(tag.hasTech(TagTechnology.MIFARE_CLASSIC)) + { + extras = tag.getTechExtras(TagTechnology.MIFARE_CLASSIC); + mSak = extras.getShort(EXTRA_SAK); + } + extras = tag.getTechExtras(TagTechnology.NFC_A); + mSak |= extras.getShort(EXTRA_SAK); mAtqa = extras.getByteArray(EXTRA_ATQA); } diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java index 862f4c4..2df9be2 100644 --- a/core/java/android/os/Build.java +++ b/core/java/android/os/Build.java @@ -23,7 +23,11 @@ import com.android.internal.telephony.TelephonyProperties; import dalvik.system.VMRuntime; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * Information about the current build, extracted from system properties. @@ -664,6 +668,7 @@ public class Build { /** The type of build, like "user" or "eng". */ public static final String TYPE = getString("ro.build.type"); + private static String TYPE_FOR_APPS = parseBuildTypeFromFingerprint(); /** Comma-separated tags describing the build, like "unsigned,debug". */ public static final String TAGS = getString("ro.build.tags"); @@ -690,6 +695,42 @@ public class Build { return finger; } + // Some apps like to compare the build type embedded in fingerprint + // to the actual build type. As the fingerprint in our case is almost + // always hardcoded to the stock ROM fingerprint, provide that instead + // of the actual one if possible. + private static String parseBuildTypeFromFingerprint() { + final String fingerprint = SystemProperties.get("ro.build.fingerprint"); + if (TextUtils.isEmpty(fingerprint)) { + return null; + } + Pattern fingerprintPattern = + Pattern.compile("(.*)\\/(.*)\\/(.*):(.*)\\/(.*)\\/(.*):(.*)\\/(.*)"); + Matcher matcher = fingerprintPattern.matcher(fingerprint); + return matcher.matches() ? matcher.group(7) : null; + } + + /** @hide */ + public static void adjustBuildTypeIfNeeded() { + if (UserHandle.isApp(Process.myUid()) && !TextUtils.isEmpty(TYPE_FOR_APPS)) { + try { + // This is sick. TYPE is final (which can't be changed because it's an API + // guarantee), but we have to reassign it. Resort to reflection to unset the + // final modifier, change the value and restore the final modifier afterwards. + Field typeField = Build.class.getField("TYPE"); + Field accessFlagsField = Field.class.getDeclaredField("accessFlags"); + accessFlagsField.setAccessible(true); + int currentFlags = accessFlagsField.getInt(typeField); + accessFlagsField.setInt(typeField, currentFlags & ~Modifier.FINAL); + typeField.set(null, TYPE_FOR_APPS); + accessFlagsField.setInt(typeField, currentFlags); + accessFlagsField.setAccessible(false); + } catch (Exception e) { + // shouldn't happen, but we don't want to crash the app even if it does happen + } + } + } + /** * Ensure that raw fingerprint system property is defined. If it was derived * dynamically by {@link #deriveFingerprint()} this is where we push the diff --git a/core/java/android/os/INetworkManagementService.aidl b/core/java/android/os/INetworkManagementService.aidl index cd84c8f..aa3921a 100644 --- a/core/java/android/os/INetworkManagementService.aidl +++ b/core/java/android/os/INetworkManagementService.aidl @@ -440,4 +440,7 @@ interface INetworkManagementService void addInterfaceToLocalNetwork(String iface, in List<RouteInfo> routes); void removeInterfaceFromLocalNetwork(String iface); + + void restrictAppOnData(int uid, boolean restrict); + void restrictAppOnWlan(int uid, boolean restrict); } diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java index 65b09eb..02466cc 100644 --- a/core/java/android/os/Process.java +++ b/core/java/android/os/Process.java @@ -539,6 +539,15 @@ public class Process { ZygoteState zygoteState, ArrayList<String> args) throws ZygoteStartFailedEx { try { + // Throw early if any of the arguments are malformed. This means we can + // avoid writing a partial response to the zygote. + int sz = args.size(); + for (int i = 0; i < sz; i++) { + if (args.get(i).indexOf('\n') >= 0) { + throw new ZygoteStartFailedEx("embedded newlines not allowed"); + } + } + /** * See com.android.internal.os.ZygoteInit.readArgumentList() * Presently the wire format to the zygote process is: @@ -555,13 +564,8 @@ public class Process { writer.write(Integer.toString(args.size())); writer.newLine(); - int sz = args.size(); for (int i = 0; i < sz; i++) { String arg = args.get(i); - if (arg.indexOf('\n') >= 0) { - throw new ZygoteStartFailedEx( - "embedded newlines not allowed"); - } writer.write(arg); writer.newLine(); } @@ -570,11 +574,16 @@ public class Process { // Should there be a timeout on this? ProcessStartResult result = new ProcessStartResult(); + + // Always read the entire result from the input stream to avoid leaving + // bytes in the stream for future process starts to accidentally stumble + // upon. result.pid = inputStream.readInt(); + result.usingWrapper = inputStream.readBoolean(); + if (result.pid < 0) { throw new ZygoteStartFailedEx("fork() failed"); } - result.usingWrapper = inputStream.readBoolean(); return result; } catch (IOException ex) { zygoteState.close(); diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java index 4b6e6c1..d277e65 100644 --- a/core/java/android/os/RecoverySystem.java +++ b/core/java/android/os/RecoverySystem.java @@ -335,22 +335,27 @@ public class RecoverySystem { throws IOException { String filename = packageFile.getCanonicalPath(); - FileWriter uncryptFile = new FileWriter(UNCRYPT_FILE); - try { - uncryptFile.write(filename + "\n"); - } finally { - uncryptFile.close(); - } - // UNCRYPT_FILE needs to be readable by system server on bootup. - if (!UNCRYPT_FILE.setReadable(true, false)) { - Log.e(TAG, "Error setting readable for " + UNCRYPT_FILE.getCanonicalPath()); - } - Log.w(TAG, "!!! REBOOTING TO INSTALL " + filename + " !!!"); + final String cryptoStatus = SystemProperties.get("ro.crypto.state", "unsupported"); + final boolean isEncrypted = "encrypted".equalsIgnoreCase(cryptoStatus); - // If the package is on the /data partition, write the block map file - // into COMMAND_FILE instead. - if (filename.startsWith("/data/")) { - filename = "@/cache/recovery/block.map"; + if (isEncrypted) { + FileWriter uncryptFile = new FileWriter(UNCRYPT_FILE); + try { + uncryptFile.write(filename + "\n"); + } finally { + uncryptFile.close(); + } + // UNCRYPT_FILE needs to be readable by system server on bootup. + if (!UNCRYPT_FILE.setReadable(true, false)) { + Log.e(TAG, "Error setting readable for " + UNCRYPT_FILE.getCanonicalPath()); + } + Log.w(TAG, "!!! REBOOTING TO INSTALL " + filename + " !!!"); + + // If the package is on the /data partition, write the block map file + // into COMMAND_FILE instead. + if (filename.startsWith("/data/")) { + filename = "@/cache/recovery/block.map"; + } } final String filenameArg = "--update_package=" + filename; @@ -372,18 +377,18 @@ public class RecoverySystem { * @throws SecurityException if the current user is not allowed to wipe data. */ public static void rebootWipeUserData(Context context) throws IOException { - rebootWipeUserData(context, false, context.getPackageName(), false); + rebootWipeUserData(context, false, context.getPackageName(), true); } /** {@hide} */ public static void rebootWipeUserData(Context context, String reason) throws IOException { - rebootWipeUserData(context, false, reason, false); + rebootWipeUserData(context, false, reason, true); } /** {@hide} */ public static void rebootWipeUserData(Context context, boolean shutdown) throws IOException { - rebootWipeUserData(context, shutdown, context.getPackageName(), false); + rebootWipeUserData(context, shutdown, context.getPackageName(), true); } /** diff --git a/core/java/android/preference/SeekBarVolumizer.java b/core/java/android/preference/SeekBarVolumizer.java index 72f5de5..e5f71a0 100644 --- a/core/java/android/preference/SeekBarVolumizer.java +++ b/core/java/android/preference/SeekBarVolumizer.java @@ -412,10 +412,11 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba int streamValue = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, -1); updateVolumeSlider(streamType, streamValue); } else if (AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION.equals(action)) { + final int oldRingerMode = mRingerMode; if (mNotificationOrRing) { mRingerMode = mAudioManager.getRingerModeInternal(); } - if (mAffectedByRingerMode) { + if (mAffectedByRingerMode && oldRingerMode != mRingerMode) { updateSlider(); } } else if (AudioManager.STREAM_DEVICES_CHANGED_ACTION.equals(action)) { diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java index 3a3eca4..f6c68dd 100644 --- a/core/java/android/provider/CallLog.java +++ b/core/java/android/provider/CallLog.java @@ -27,6 +27,7 @@ import android.database.Cursor; import android.location.Country; import android.location.CountryDetector; import android.net.Uri; +import android.os.Bundle; import android.os.UserHandle; import android.os.UserManager; import android.provider.ContactsContract.CommonDataKinds.Callable; @@ -401,6 +402,12 @@ public class CallLog { private static final int MIN_DURATION_FOR_NORMALIZED_NUMBER_UPDATE_MS = 1000 * 10; /** + * If a call has an origin inside of the OS, this column will be filled out. + * <P>Type: String </P> + */ + private static final String ORIGIN = "origin"; + + /** * Adds a call to the call log. * * @param ci the CallerInfo object to get the target contact from. Can be null @@ -417,15 +424,16 @@ public class CallLog { * @param duration call duration in seconds * @param dataUsage data usage for the call in bytes, null if data usage was not tracked for * the call. + * @param callExtras Bundle of extra data from the call. * @result The URI of the call log entry belonging to the user that made or received this * call. * {@hide} */ public static Uri addCall(CallerInfo ci, Context context, String number, int presentation, int callType, int features, PhoneAccountHandle accountHandle, - long start, int duration, Long dataUsage) { + long start, int duration, Long dataUsage, Bundle callExtras) { return addCall(ci, context, number, presentation, callType, features, accountHandle, - start, duration, dataUsage, false, false); + start, duration, dataUsage, false, false, callExtras); } @@ -448,16 +456,17 @@ public class CallLog { * the call. * @param addForAllUsers If true, the call is added to the call log of all currently * running users. The caller must have the MANAGE_USERS permission if this is true. - * + * @param callExtras Bundle of extra data from the call. * @result The URI of the call log entry belonging to the user that made or received this * call. * {@hide} */ public static Uri addCall(CallerInfo ci, Context context, String number, int presentation, int callType, int features, PhoneAccountHandle accountHandle, - long start, int duration, Long dataUsage, boolean addForAllUsers) { + long start, int duration, Long dataUsage, boolean addForAllUsers, + Bundle callExtras) { return addCall(ci, context, number, presentation, callType, features, accountHandle, - start, duration, dataUsage, addForAllUsers, false); + start, duration, dataUsage, addForAllUsers, false, callExtras); } /** @@ -481,6 +490,7 @@ public class CallLog { * running users. The caller must have the MANAGE_USERS permission if this is true. * @param is_read Flag to show if the missed call log has been read by the user or not. * Used for call log restore of missed calls. + * @param callExtras Bundle of extra data from the call. * * @result The URI of the call log entry belonging to the user that made or received this * call. @@ -488,7 +498,8 @@ public class CallLog { */ public static Uri addCall(CallerInfo ci, Context context, String number, int presentation, int callType, int features, PhoneAccountHandle accountHandle, - long start, int duration, Long dataUsage, boolean addForAllUsers, boolean is_read) { + long start, int duration, Long dataUsage, boolean addForAllUsers, boolean is_read, + Bundle callExtras) { final ContentResolver resolver = context.getContentResolver(); int numberPresentation = PRESENTATION_ALLOWED; @@ -547,6 +558,9 @@ public class CallLog { if (dataUsage != null) { values.put(DATA_USAGE, dataUsage); } + if (callExtras != null && callExtras.containsKey(PhoneConstants.EXTRA_CALL_ORIGIN)) { + values.put(ORIGIN, callExtras.getString(PhoneConstants.EXTRA_CALL_ORIGIN)); + } values.put(PHONE_ACCOUNT_COMPONENT_NAME, accountComponentString); values.put(PHONE_ACCOUNT_ID, accountId); values.put(PHONE_ACCOUNT_ADDRESS, accountAddress); diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index f6642d8..3ab16fe 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -1509,7 +1509,6 @@ public final class Settings { // At one time in System, then Global, but now back in Secure MOVED_TO_SECURE.add(Secure.INSTALL_NON_MARKET_APPS); - MOVED_TO_SECURE.add(System.DEV_FORCE_SHOW_NAVBAR); MOVED_TO_SECURE.add(System.KEYBOARD_BRIGHTNESS); MOVED_TO_SECURE.add(System.BUTTON_BRIGHTNESS); MOVED_TO_SECURE.add(System.BUTTON_BACKLIGHT_TIMEOUT); @@ -6445,6 +6444,18 @@ public final class Settings { public static final String BLUETOOTH_DISABLED_PROFILES = "bluetooth_disabled_profiles"; /** + * A semi-colon separated list of Bluetooth interoperability workarounds. + * Each entry is a partial Bluetooth device address string and an integer representing + * the feature to be disabled, separated by a comma. The integer must correspond + * to a interoperability feature as defined in "interop.h" in /system/bt. + * <p> + * Example: <br/> + * "00:11:22,0;01:02:03:04,2" + * @hide + */ + public static final String BLUETOOTH_INTEROPERABILITY_LIST = "bluetooth_interoperability_list"; + + /** * The policy for deciding when Wi-Fi should go to sleep (which will in * turn switch to using the mobile data as an Internet connection). * <p> diff --git a/core/java/android/service/voice/VoiceInteractionServiceInfo.java b/core/java/android/service/voice/VoiceInteractionServiceInfo.java index 463eb5b..8393f7e 100644 --- a/core/java/android/service/voice/VoiceInteractionServiceInfo.java +++ b/core/java/android/service/voice/VoiceInteractionServiceInfo.java @@ -58,6 +58,10 @@ public class VoiceInteractionServiceInfo { } public VoiceInteractionServiceInfo(PackageManager pm, ServiceInfo si) { + if (si == null) { + mParseError = "Service not available"; + return; + } if (!Manifest.permission.BIND_VOICE_INTERACTION.equals(si.permission)) { mParseError = "Service does not require permission " + Manifest.permission.BIND_VOICE_INTERACTION; diff --git a/core/java/android/util/Patterns.java b/core/java/android/util/Patterns.java index 6fc8ae5..f1b3feb 100644 --- a/core/java/android/util/Patterns.java +++ b/core/java/android/util/Patterns.java @@ -136,7 +136,7 @@ public class Patterns { * RFC 1035 Section 2.3.4 limits the labels to a maximum 63 octets. */ private static final String IRI = - "[" + GOOD_IRI_HOST_CHAR + "]([" + GOOD_IRI_HOST_CHAR + "\\-]{0,61}[" + "[" + GOOD_IRI_HOST_CHAR + "]([" + GOOD_IRI_HOST_CHAR + "\\-_~]{0,61}[" + GOOD_IRI_HOST_CHAR + "]){0,1}"; private static final String GOOD_GTLD_CHAR = diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index 55735c7..b3f4046 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -287,4 +287,6 @@ interface IWindowManager * @return The frame statistics or null if the window does not exist. */ WindowContentFrameStats getWindowContentFrameStats(IBinder token); + + void setLiveLockscreenEdgeDetector(boolean enable); } diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java index 527d7e5..e0c9d59 100644 --- a/core/java/android/view/MotionEvent.java +++ b/core/java/android/view/MotionEvent.java @@ -417,6 +417,21 @@ public final class MotionEvent extends InputEvent implements Parcelable { public static final int FLAG_WINDOW_IS_OBSCURED = 0x1; /** + * This flag indicates that the window that received this motion event is partly + * or wholly obscured by another visible window above it. This flag is set to true + * even if the event did not directly pass through the obscured area. + * A security sensitive application can check this flag to identify situations in which + * a malicious application may have covered up part of its content for the purpose + * of misleading the user or hijacking touches. An appropriate response might be + * to drop the suspect touches or to take additional precautions to confirm the user's + * actual intent. + * + * Unlike FLAG_WINDOW_IS_OBSCURED, this is actually true. + * @hide + */ + public static final int FLAG_WINDOW_IS_PARTIALLY_OBSCURED = 0x2; + + /** * Private flag that indicates when the system has detected that this motion event * may be inconsistent with respect to the sequence of previously delivered motion events, * such as when a pointer move event is sent but the pointer is not down. diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java index 3616622..50a926f 100644 --- a/core/java/android/view/Window.java +++ b/core/java/android/view/Window.java @@ -869,10 +869,6 @@ public abstract class Window { } private void setPrivateFlags(int flags, int mask) { - if ((flags & mask & WindowManager.LayoutParams.PRIVATE_FLAG_PREVENT_POWER_KEY) != 0){ - mContext.enforceCallingOrSelfPermission("android.permission.PREVENT_POWER_KEY", - "No permission to prevent power key"); - } final WindowManager.LayoutParams attrs = getAttributes(); attrs.privateFlags = (attrs.privateFlags & ~mask) | (flags & mask); dispatchWindowAttributesChanged(attrs); diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 1125b44..36f593e 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -1154,7 +1154,13 @@ public interface WindowManager extends ViewManager { public static final int PRIVATE_FLAG_WAS_NOT_FULLSCREEN = 0x02000000; /** - * Window flag: Overrides default power key behavior + * Window flag: Overrides default system key behavior. + * {@hide} + */ + public static final int PRIVATE_FLAG_PREVENT_SYSTEM_KEYS = 0x10000000; + + /** + * Window flag: Overrides default system key behavior. * {@hide} */ public static final int PRIVATE_FLAG_PREVENT_POWER_KEY = 0x20000000; diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index a962f2a..9d7c741 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -20,6 +20,7 @@ import android.annotation.IntDef; import android.annotation.SystemApi; import android.content.Context; import android.content.pm.ActivityInfo; +import android.content.pm.ApplicationInfo; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.graphics.Rect; @@ -665,6 +666,11 @@ public interface WindowManagerPolicy { public WindowState getWinShowWhenLockedLw(); /** + * Returns the current keyguard panel, if such a thing exists. + */ + public WindowState getWinKeyguardPanelLw(); + + /** * Called when the system would like to show a UI to indicate that an * application is starting. You can use this to add a * APPLICATION_STARTING_TYPE window with the given appToken to the window @@ -1166,9 +1172,10 @@ public interface WindowManagerPolicy { public void systemBooted(); /** - * Show boot time message to the user. + * Update UI for boot-up progress. */ - public void showBootMessage(final CharSequence msg, final boolean always); + public void updateBootProgress(final int stage, final ApplicationInfo optimizedApp, + final int currentAppPos, final int totalAppCount); /** * Hide the UI for showing boot messages, never to be displayed again. @@ -1320,4 +1327,6 @@ public interface WindowManagerPolicy { * @param fadeoutDuration the duration of the exit animation, in milliseconds */ public void startKeyguardExitAnimation(long startTime, long fadeoutDuration); + + public void setLiveLockscreenEdgeDetector(boolean enable); } |