Merge "Added ACCESS_COARSE_LOCATION permission for BT" into mnc-dev
diff --git a/Android.mk b/Android.mk
index 121bc8e..a7a2ecb 100644
--- a/Android.mk
+++ b/Android.mk
@@ -285,7 +285,7 @@
core/java/com/android/internal/appwidget/IAppWidgetHost.aidl \
core/java/com/android/internal/backup/IBackupTransport.aidl \
core/java/com/android/internal/backup/IObbBackupService.aidl \
- core/java/com/android/internal/policy/IKeyguardShowCallback.aidl \
+ core/java/com/android/internal/policy/IKeyguardDrawnCallback.aidl \
core/java/com/android/internal/policy/IKeyguardExitCallback.aidl \
core/java/com/android/internal/policy/IKeyguardService.aidl \
core/java/com/android/internal/policy/IKeyguardStateCallback.aidl \
diff --git a/api/current.txt b/api/current.txt
index 79d5ea0..7c5115f 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -66,6 +66,7 @@
field public static final java.lang.String FACTORY_TEST = "android.permission.FACTORY_TEST";
field public static final java.lang.String FLASHLIGHT = "android.permission.FLASHLIGHT";
field public static final java.lang.String GET_ACCOUNTS = "android.permission.GET_ACCOUNTS";
+ field public static final java.lang.String GET_ACCOUNTS_PRIVILEGED = "android.permission.GET_ACCOUNTS_PRIVILEGED";
field public static final java.lang.String GET_PACKAGE_SIZE = "android.permission.GET_PACKAGE_SIZE";
field public static final deprecated java.lang.String GET_TASKS = "android.permission.GET_TASKS";
field public static final java.lang.String GLOBAL_SEARCH = "android.permission.GLOBAL_SEARCH";
@@ -9313,6 +9314,7 @@
field public static final java.lang.String FEATURE_FAKETOUCH = "android.hardware.faketouch";
field public static final java.lang.String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
field public static final java.lang.String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
+ field public static final java.lang.String FEATURE_FINGERPRINT = "android.hardware.fingerprint";
field public static final java.lang.String FEATURE_GAMEPAD = "android.hardware.gamepad";
field public static final java.lang.String FEATURE_HIFI_SENSORS = "android.hardware.sensor.hifi_sensors";
field public static final java.lang.String FEATURE_HOME_SCREEN = "android.software.home_screen";
@@ -9445,6 +9447,7 @@
method public java.lang.CharSequence loadDescription(android.content.pm.PackageManager);
field public static final android.os.Parcelable.Creator<android.content.pm.PermissionInfo> CREATOR;
field public static final int FLAG_COSTS_MONEY = 1; // 0x1
+ field public static final int FLAG_INSTALLED = 1073741824; // 0x40000000
field public static final int PROTECTION_DANGEROUS = 1; // 0x1
field public static final int PROTECTION_FLAG_APPOP = 64; // 0x40
field public static final int PROTECTION_FLAG_DEVELOPMENT = 32; // 0x20
@@ -28829,6 +28832,7 @@
method public boolean onKeyLongPress(int, android.view.KeyEvent);
method public boolean onKeyMultiple(int, int, android.view.KeyEvent);
method public boolean onKeyUp(int, android.view.KeyEvent);
+ method public void onLockscreenShown();
method public void onLowMemory();
method public void onRequestAbortVoice(android.service.voice.VoiceInteractionSession.AbortVoiceRequest);
method public void onRequestCommand(android.service.voice.VoiceInteractionSession.CommandRequest);
diff --git a/api/system-current.txt b/api/system-current.txt
index 0af72d5..a08a011 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -95,6 +95,7 @@
field public static final java.lang.String FORCE_BACK = "android.permission.FORCE_BACK";
field public static final java.lang.String FORCE_STOP_PACKAGES = "android.permission.FORCE_STOP_PACKAGES";
field public static final java.lang.String GET_ACCOUNTS = "android.permission.GET_ACCOUNTS";
+ field public static final java.lang.String GET_ACCOUNTS_PRIVILEGED = "android.permission.GET_ACCOUNTS_PRIVILEGED";
field public static final java.lang.String GET_APP_OPS_STATS = "android.permission.GET_APP_OPS_STATS";
field public static final java.lang.String GET_PACKAGE_IMPORTANCE = "android.permission.GET_PACKAGE_IMPORTANCE";
field public static final java.lang.String GET_PACKAGE_SIZE = "android.permission.GET_PACKAGE_SIZE";
@@ -9607,6 +9608,7 @@
field public static final java.lang.String FEATURE_FAKETOUCH = "android.hardware.faketouch";
field public static final java.lang.String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
field public static final java.lang.String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
+ field public static final java.lang.String FEATURE_FINGERPRINT = "android.hardware.fingerprint";
field public static final java.lang.String FEATURE_GAMEPAD = "android.hardware.gamepad";
field public static final java.lang.String FEATURE_HIFI_SENSORS = "android.hardware.sensor.hifi_sensors";
field public static final java.lang.String FEATURE_HOME_SCREEN = "android.software.home_screen";
@@ -9783,6 +9785,7 @@
method public java.lang.CharSequence loadDescription(android.content.pm.PackageManager);
field public static final android.os.Parcelable.Creator<android.content.pm.PermissionInfo> CREATOR;
field public static final int FLAG_COSTS_MONEY = 1; // 0x1
+ field public static final int FLAG_INSTALLED = 1073741824; // 0x40000000
field public static final int PROTECTION_DANGEROUS = 1; // 0x1
field public static final int PROTECTION_FLAG_APPOP = 64; // 0x40
field public static final int PROTECTION_FLAG_DEVELOPMENT = 32; // 0x20
@@ -30981,6 +30984,7 @@
method public boolean onKeyLongPress(int, android.view.KeyEvent);
method public boolean onKeyMultiple(int, int, android.view.KeyEvent);
method public boolean onKeyUp(int, android.view.KeyEvent);
+ method public void onLockscreenShown();
method public void onLowMemory();
method public void onRequestAbortVoice(android.service.voice.VoiceInteractionSession.AbortVoiceRequest);
method public void onRequestCommand(android.service.voice.VoiceInteractionSession.CommandRequest);
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java
index 9f4bc52..96c0dbd 100644
--- a/cmds/am/src/com/android/commands/am/Am.java
+++ b/cmds/am/src/com/android/commands/am/Am.java
@@ -26,6 +26,7 @@
import android.app.IActivityManager;
import android.app.IInstrumentationWatcher;
import android.app.Instrumentation;
+import android.app.IStopUserCallback;
import android.app.ProfilerInfo;
import android.app.UiAutomationConnection;
import android.app.usage.ConfigurationStats;
@@ -133,7 +134,7 @@
" am to-app-uri [INTENT]\n" +
" am switch-user <USER_ID>\n" +
" am start-user <USER_ID>\n" +
- " am stop-user <USER_ID>\n" +
+ " am stop-user [-w] <USER_ID>\n" +
" am stack start <DISPLAY_ID> <INTENT>\n" +
" am stack movetask <TASK_ID> <STACK_ID> [true|false]\n" +
" am stack resize <STACK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" +
@@ -257,6 +258,7 @@
"\n" +
"am stop-user: stop execution of USER_ID, not allowing it to run any\n" +
" code until a later explicit start or switch to it.\n" +
+ " -w: wait for stop-user to complete.\n" +
"\n" +
"am stack start: start a new activity on <DISPLAY_ID> using <INTENT>.\n" +
"\n" +
@@ -293,7 +295,7 @@
"\n" +
"am get-inactive: returns the inactive state of an app.\n" +
"\n" +
- " am send-trim-memory: Send a memory trim event to a <PROCESS>.\n" +
+ "am send-trim-memory: Send a memory trim event to a <PROCESS>.\n" +
"\n" +
"<INTENT> specifications include these flags and arguments:\n" +
" [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]\n" +
@@ -1303,9 +1305,45 @@
}
}
+ private static class StopUserCallback extends IStopUserCallback.Stub {
+ private boolean mFinished = false;
+
+ public synchronized void waitForFinish() {
+ try {
+ while (!mFinished) wait();
+ } catch (InterruptedException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ @Override
+ public synchronized void userStopped(int userId) {
+ mFinished = true;
+ notifyAll();
+ }
+
+ @Override
+ public synchronized void userStopAborted(int userId) {
+ mFinished = true;
+ notifyAll();
+ }
+ }
+
private void runStopUser() throws Exception {
- String user = nextArgRequired();
- int res = mAm.stopUser(Integer.parseInt(user), null);
+ boolean wait = false;
+ String opt = null;
+ while ((opt = nextOption()) != null) {
+ if ("-w".equals(opt)) {
+ wait = true;
+ } else {
+ System.err.println("Error: unknown option: " + opt);
+ return;
+ }
+ }
+ int user = Integer.parseInt(nextArgRequired());
+ StopUserCallback callback = wait ? new StopUserCallback() : null;
+
+ int res = mAm.stopUser(user, callback);
if (res != ActivityManager.USER_OP_SUCCESS) {
String txt = "";
switch (res) {
@@ -1317,6 +1355,8 @@
break;
}
System.err.println("Switch failed: " + res + txt);
+ } else if (callback != null) {
+ callback.waitForFinish();
}
}
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index 2dcd9cb..b39376c 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -16,6 +16,11 @@
package com.android.commands.pm;
+import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
+import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK;
+import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS;
+import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER;
+
import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.IActivityManager;
@@ -212,6 +217,14 @@
return runSetPermissionEnforced();
}
+ if ("set-app-link".equals(op)) {
+ return runSetAppLink();
+ }
+
+ if ("get-app-link".equals(op)) {
+ return runGetAppLink();
+ }
+
if ("set-install-location".equals(op)) {
return runSetInstallLocation();
}
@@ -827,6 +840,148 @@
return Integer.toString(result);
}
+ // pm set-app-link [--user USER_ID] PACKAGE {always|ask|never|undefined}
+ private int runSetAppLink() {
+ int userId = UserHandle.USER_OWNER;
+
+ String opt;
+ while ((opt = nextOption()) != null) {
+ if (opt.equals("--user")) {
+ userId = Integer.parseInt(nextOptionData());
+ if (userId < 0) {
+ System.err.println("Error: user must be >= 0");
+ return 1;
+ }
+ } else {
+ System.err.println("Error: unknown option: " + opt);
+ showUsage();
+ return 1;
+ }
+ }
+
+ // Package name to act on; required
+ final String pkg = nextArg();
+ if (pkg == null) {
+ System.err.println("Error: no package specified.");
+ showUsage();
+ return 1;
+ }
+
+ // State to apply; {always|ask|never|undefined}, required
+ final String modeString = nextArg();
+ if (modeString == null) {
+ System.err.println("Error: no app link state specified.");
+ showUsage();
+ return 1;
+ }
+
+ final int newMode;
+ switch (modeString.toLowerCase()) {
+ case "undefined":
+ newMode = INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
+ break;
+
+ case "always":
+ newMode = INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS;
+ break;
+
+ case "ask":
+ newMode = INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK;
+ break;
+
+ case "never":
+ newMode = INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER;
+ break;
+
+ default:
+ System.err.println("Error: unknown app link state '" + modeString + "'");
+ return 1;
+ }
+
+ try {
+ final PackageInfo info = mPm.getPackageInfo(pkg, 0, userId);
+ if (info == null) {
+ System.err.println("Error: package " + pkg + " not found.");
+ return 1;
+ }
+
+ if ((info.applicationInfo.privateFlags & ApplicationInfo.PRIVATE_FLAG_HAS_DOMAIN_URLS) == 0) {
+ System.err.println("Error: package " + pkg + " does not handle web links.");
+ return 1;
+ }
+
+ if (!mPm.updateIntentVerificationStatus(pkg, newMode, userId)) {
+ System.err.println("Error: unable to update app link status for " + pkg);
+ return 1;
+ }
+ } catch (Exception e) {
+ System.err.println(e.toString());
+ System.err.println(PM_NOT_RUNNING_ERR);
+ return 1;
+ }
+
+ return 0;
+ }
+
+ // pm get-app-link [--user USER_ID] PACKAGE
+ private int runGetAppLink() {
+ int userId = UserHandle.USER_OWNER;
+
+ String opt;
+ while ((opt = nextOption()) != null) {
+ if (opt.equals("--user")) {
+ userId = Integer.parseInt(nextOptionData());
+ if (userId < 0) {
+ System.err.println("Error: user must be >= 0");
+ return 1;
+ }
+ } else {
+ System.err.println("Error: unknown option: " + opt);
+ showUsage();
+ return 1;
+ }
+ }
+
+ // Package name to act on; required
+ final String pkg = nextArg();
+ if (pkg == null) {
+ System.err.println("Error: no package specified.");
+ showUsage();
+ return 1;
+ }
+
+ try {
+ final PackageInfo info = mPm.getPackageInfo(pkg, 0, userId);
+ if (info == null) {
+ System.err.println("Error: package " + pkg + " not found.");
+ return 1;
+ }
+
+ if ((info.applicationInfo.privateFlags & ApplicationInfo.PRIVATE_FLAG_HAS_DOMAIN_URLS) == 0) {
+ System.err.println("Error: package " + pkg + " does not handle web links.");
+ return 1;
+ }
+
+ System.out.println(linkStateToString(mPm.getIntentVerificationStatus(pkg, userId)));
+ } catch (Exception e) {
+ System.err.println(e.toString());
+ System.err.println(PM_NOT_RUNNING_ERR);
+ return 1;
+ }
+
+ return 0;
+ }
+
+ private String linkStateToString(int state) {
+ switch (state) {
+ case INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED: return "undefined";
+ case INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK: return "ask";
+ case INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS: return "always";
+ case INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER: return "never";
+ }
+ return "Unknown link state: " + state;
+ }
+
private int runSetInstallLocation() {
int loc;
@@ -1936,6 +2091,8 @@
System.err.println(" pm grant [--user USER_ID] PACKAGE PERMISSION");
System.err.println(" pm revoke [--user USER_ID] PACKAGE PERMISSION");
System.err.println(" pm reset-permissions");
+ System.err.println(" pm set-app-link [--user USER_ID] PACKAGE {always|ask|never|undefined}");
+ System.err.println(" pm get-app-link [--user USER_ID] PACKAGE");
System.err.println(" pm set-install-location [0/auto] [1/internal] [2/external]");
System.err.println(" pm get-install-location");
System.err.println(" pm set-permission-enforced PERMISSION [true|false]");
diff --git a/cmds/sm/src/com/android/commands/sm/Sm.java b/cmds/sm/src/com/android/commands/sm/Sm.java
index 0dad4dc..0a1ba4d1 100644
--- a/cmds/sm/src/com/android/commands/sm/Sm.java
+++ b/cmds/sm/src/com/android/commands/sm/Sm.java
@@ -81,6 +81,8 @@
runUnmount();
} else if ("format".equals(op)) {
runFormat();
+ } else if ("benchmark".equals(op)) {
+ runBenchmark();
} else if ("forget".equals(op)) {
runForget();
} else {
@@ -89,9 +91,12 @@
}
public void runListDisks() throws RemoteException {
+ final boolean onlyAdoptable = "adoptable".equals(nextArg());
final DiskInfo[] disks = mSm.getDisks();
for (DiskInfo disk : disks) {
- System.out.println(disk.getId());
+ if (!onlyAdoptable || disk.isAdoptable()) {
+ System.out.println(disk.getId());
+ }
}
}
@@ -161,6 +166,11 @@
mSm.format(volId);
}
+ public void runBenchmark() throws RemoteException {
+ final String volId = nextArg();
+ mSm.benchmark(volId);
+ }
+
public void runForget() throws RemoteException{
final String fsUuid = nextArg();
if ("all".equals(fsUuid)) {
@@ -180,7 +190,7 @@
}
private static int showUsage() {
- System.err.println("usage: sm list-disks");
+ System.err.println("usage: sm list-disks [adoptable]");
System.err.println(" sm list-volumes [public|private|emulated|all]");
System.err.println(" sm has-adoptable");
System.err.println(" sm get-primary-storage-uuid");
@@ -190,6 +200,7 @@
System.err.println(" sm mount VOLUME");
System.err.println(" sm unmount VOLUME");
System.err.println(" sm format VOLUME");
+ System.err.println(" sm benchmark VOLUME");
System.err.println("");
System.err.println(" sm forget [UUID|all]");
System.err.println("");
diff --git a/cmds/wm/src/com/android/commands/wm/Wm.java b/cmds/wm/src/com/android/commands/wm/Wm.java
index fb050e5..f7f7c88 100644
--- a/cmds/wm/src/com/android/commands/wm/Wm.java
+++ b/cmds/wm/src/com/android/commands/wm/Wm.java
@@ -65,7 +65,10 @@
"\n" +
"wm scaling: set display scaling mode.\n" +
"\n" +
- "wm screen-capture: enable/disable screen capture.\n"
+ "wm screen-capture: enable/disable screen capture.\n" +
+ "\n" +
+ "wm dismiss-keyguard: dismiss the keyguard, prompting the user for auth if " +
+ "necessary.\n"
);
}
@@ -90,6 +93,8 @@
runDisplayScaling();
} else if (op.equals("screen-capture")) {
runSetScreenCapture();
+ } else if (op.equals("dismiss-keyguard")) {
+ runDismissKeyguard();
} else {
showError("Error: unknown command '" + op + "'");
return;
@@ -240,6 +245,10 @@
}
}
+ private void runDismissKeyguard() throws Exception {
+ mWm.dismissKeyguard();
+ }
+
private int parseDimension(String s) throws NumberFormatException {
if (s.endsWith("px")) {
return Integer.parseInt(s.substring(0, s.length() - 2));
diff --git a/core/java/android/app/BackStackRecord.java b/core/java/android/app/BackStackRecord.java
index 13030ca..84cbea9 100644
--- a/core/java/android/app/BackStackRecord.java
+++ b/core/java/android/app/BackStackRecord.java
@@ -1094,8 +1094,10 @@
container.getViewTreeObserver().removeOnPreDrawListener(this);
// Don't include any newly-hidden fragments in the transition.
- excludeHiddenFragments(hiddenFragmentViews, inFragment.mContainerId,
- overallTransition);
+ if (inFragment != null) {
+ excludeHiddenFragments(hiddenFragmentViews, inFragment.mContainerId,
+ overallTransition);
+ }
ArrayMap<String, View> namedViews = null;
if (sharedElementTransition != null) {
@@ -1692,7 +1694,7 @@
private static void setNameOverrides(TransitionState state, ArrayList<String> sourceNames,
ArrayList<String> targetNames) {
- if (sourceNames != null) {
+ if (sourceNames != null && targetNames != null) {
for (int i = 0; i < sourceNames.size(); i++) {
String source = sourceNames.get(i);
String target = targetNames.get(i);
@@ -1703,7 +1705,9 @@
private void setBackNameOverrides(TransitionState state, ArrayMap<String, View> namedViews,
boolean isEnd) {
- int count = mSharedElementTargetNames == null ? 0 : mSharedElementTargetNames.size();
+ int targetCount = mSharedElementTargetNames == null ? 0 : mSharedElementTargetNames.size();
+ int sourceCount = mSharedElementSourceNames == null ? 0 : mSharedElementSourceNames.size();
+ final int count = Math.min(targetCount, sourceCount);
for (int i = 0; i < count; i++) {
String source = mSharedElementSourceNames.get(i);
String originalTarget = mSharedElementTargetNames.get(i);
diff --git a/core/java/android/app/IUiAutomationConnection.aidl b/core/java/android/app/IUiAutomationConnection.aidl
index 8ab9ac3..474154b 100644
--- a/core/java/android/app/IUiAutomationConnection.aidl
+++ b/core/java/android/app/IUiAutomationConnection.aidl
@@ -38,10 +38,12 @@
boolean injectInputEvent(in InputEvent event, boolean sync);
boolean setRotation(int rotation);
Bitmap takeScreenshot(int width, int height);
- void shutdown();
boolean clearWindowContentFrameStats(int windowId);
WindowContentFrameStats getWindowContentFrameStats(int windowId);
void clearWindowAnimationFrameStats();
WindowAnimationFrameStats getWindowAnimationFrameStats();
void executeShellCommand(String command, in ParcelFileDescriptor fd);
+
+ // Called from the system process.
+ oneway void shutdown();
}
diff --git a/core/java/android/app/assist/AssistStructure.java b/core/java/android/app/assist/AssistStructure.java
index 40126d6..ee0fc91 100644
--- a/core/java/android/app/assist/AssistStructure.java
+++ b/core/java/android/app/assist/AssistStructure.java
@@ -4,6 +4,7 @@
import android.content.ComponentName;
import android.graphics.Matrix;
import android.graphics.Rect;
+import android.os.BadParcelableException;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
@@ -31,8 +32,12 @@
static final String TAG = "AssistStructure";
static final boolean DEBUG_PARCEL = false;
+ static final boolean DEBUG_PARCEL_CHILDREN = false;
static final boolean DEBUG_PARCEL_TREE = false;
+ static final int VALIDATE_WINDOW_TOKEN = 0x11111111;
+ static final int VALIDATE_VIEW_TOKEN = 0x22222222;
+
boolean mHaveData;
ComponentName mActivityComponent;
@@ -173,6 +178,26 @@
mCurViewStackEntry = entry;
}
+ void writeView(ViewNode child, Parcel out, PooledStringWriter pwriter, int levelAdj) {
+ if (DEBUG_PARCEL) Log.d(TAG, "write view: at " + out.dataPosition()
+ + ", windows=" + mNumWrittenWindows
+ + ", views=" + mNumWrittenViews
+ + ", level=" + (mCurViewStackPos+levelAdj));
+ out.writeInt(VALIDATE_VIEW_TOKEN);
+ int flags = child.writeSelfToParcel(out, pwriter, mTmpMatrix);
+ mNumWrittenViews++;
+ // If the child has children, push it on the stack to write them next.
+ if ((flags&ViewNode.FLAGS_HAS_CHILDREN) != 0) {
+ if (DEBUG_PARCEL_TREE || DEBUG_PARCEL_CHILDREN) Log.d(TAG,
+ "Preparing to write " + child.mChildren.length
+ + " children: @ #" + mNumWrittenViews
+ + ", level " + (mCurViewStackPos+levelAdj));
+ out.writeInt(child.mChildren.length);
+ int pos = ++mCurViewStackPos;
+ pushViewStackEntry(child, pos);
+ }
+ }
+
boolean writeNextEntryToParcel(AssistStructure as, Parcel out, PooledStringWriter pwriter) {
// Write next view node if appropriate.
if (mCurViewStackEntry != null) {
@@ -182,20 +207,7 @@
+ mCurViewStackEntry.curChild + " in " + mCurViewStackEntry.node);
ViewNode child = mCurViewStackEntry.node.mChildren[mCurViewStackEntry.curChild];
mCurViewStackEntry.curChild++;
- if (DEBUG_PARCEL) Log.d(TAG, "write view: at " + out.dataPosition()
- + ", windows=" + mNumWrittenWindows
- + ", views=" + mNumWrittenViews);
- out.writeInt(1);
- int flags = child.writeSelfToParcel(out, pwriter, mTmpMatrix);
- mNumWrittenViews++;
- // If the child has children, push it on the stack to write them next.
- if ((flags&ViewNode.FLAGS_HAS_CHILDREN) != 0) {
- if (DEBUG_PARCEL_TREE) Log.d(TAG, "Preparing to write "
- + child.mChildren.length + " children under " + child);
- out.writeInt(child.mChildren.length);
- int pos = ++mCurViewStackPos;
- pushViewStackEntry(child, pos);
- }
+ writeView(child, out, pwriter, 1);
return true;
}
@@ -223,13 +235,13 @@
if (DEBUG_PARCEL) Log.d(TAG, "write window #" + pos + ": at " + out.dataPosition()
+ ", windows=" + mNumWrittenWindows
+ ", views=" + mNumWrittenViews);
- out.writeInt(1);
+ out.writeInt(VALIDATE_WINDOW_TOKEN);
win.writeSelfToParcel(out, pwriter, mTmpMatrix);
mNumWrittenWindows++;
ViewNode root = win.mRoot;
mCurViewStackPos = 0;
- if (DEBUG_PARCEL_TREE) Log.d(TAG, "Pushing initial root view " + root);
- pushViewStackEntry(root, 0);
+ if (DEBUG_PARCEL_TREE) Log.d(TAG, "Writing initial root view " + root);
+ writeView(root, out, pwriter, 0);
return true;
}
@@ -271,11 +283,16 @@
+ ", views=" + mNumReadViews);
}
- Parcel readParcel() {
+ Parcel readParcel(int validateToken, int level) {
if (DEBUG_PARCEL) Log.d(TAG, "readParcel: at " + mCurParcel.dataPosition()
+ ", avail=" + mCurParcel.dataAvail() + ", windows=" + mNumReadWindows
- + ", views=" + mNumReadViews);
- if (mCurParcel.readInt() != 0) {
+ + ", views=" + mNumReadViews + ", level=" + level);
+ int token = mCurParcel.readInt();
+ if (token != 0) {
+ if (token != validateToken) {
+ throw new BadParcelableException("Got token " + Integer.toHexString(token)
+ + ", expected token " + Integer.toHexString(validateToken));
+ }
return mCurParcel;
}
// We have run out of partial data, need to read another batch.
@@ -406,7 +423,7 @@
}
WindowNode(ParcelTransferReader reader) {
- Parcel in = reader.readParcel();
+ Parcel in = reader.readParcel(VALIDATE_WINDOW_TOKEN, 0);
reader.mNumReadWindows++;
mX = in.readInt();
mY = in.readInt();
@@ -414,7 +431,7 @@
mHeight = in.readInt();
mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
mDisplayId = in.readInt();
- mRoot = new ViewNode(reader);
+ mRoot = new ViewNode(reader, 0);
}
void writeSelfToParcel(Parcel out, PooledStringWriter pwriter, float[] tmpMatrix) {
@@ -548,8 +565,8 @@
ViewNode() {
}
- ViewNode(ParcelTransferReader reader) {
- final Parcel in = reader.readParcel();
+ ViewNode(ParcelTransferReader reader, int nestingLevel) {
+ final Parcel in = reader.readParcel(VALIDATE_VIEW_TOKEN, nestingLevel);
reader.mNumReadViews++;
final PooledStringReader preader = reader.mStringReader;
mClassName = preader.readString();
@@ -604,9 +621,13 @@
}
if ((flags&FLAGS_HAS_CHILDREN) != 0) {
final int NCHILDREN = in.readInt();
+ if (DEBUG_PARCEL_TREE || DEBUG_PARCEL_CHILDREN) Log.d(TAG,
+ "Preparing to read " + NCHILDREN
+ + " children: @ #" + reader.mNumReadViews
+ + ", level " + nestingLevel);
mChildren = new ViewNode[NCHILDREN];
for (int i=0; i<NCHILDREN; i++) {
- mChildren[i] = new ViewNode(reader);
+ mChildren[i] = new ViewNode(reader, nestingLevel + 1);
}
}
}
diff --git a/core/java/android/bluetooth/le/BluetoothLeScanner.java b/core/java/android/bluetooth/le/BluetoothLeScanner.java
index e09ab56..2ba87744 100644
--- a/core/java/android/bluetooth/le/BluetoothLeScanner.java
+++ b/core/java/android/bluetooth/le/BluetoothLeScanner.java
@@ -79,6 +79,10 @@
* delivered through {@code callback}.
* <p>
* Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
+ * An app must hold
+ * {@link android.Manifest.permission#ACCESS_COARSE_LOCATION ACCESS_COARSE_LOCATION} or
+ * {@link android.Manifest.permission#ACCESS_FINE_LOCATION ACCESS_FINE_LOCATION} permission
+ * in order to get results.
*
* @param callback Callback used to deliver scan results.
* @throws IllegalArgumentException If {@code callback} is null.
@@ -95,6 +99,10 @@
* Start Bluetooth LE scan. The scan results will be delivered through {@code callback}.
* <p>
* Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
+ * An app must hold
+ * {@link android.Manifest.permission#ACCESS_COARSE_LOCATION ACCESS_COARSE_LOCATION} or
+ * {@link android.Manifest.permission#ACCESS_FINE_LOCATION ACCESS_FINE_LOCATION} permission
+ * in order to get results.
*
* @param filters {@link ScanFilter}s for finding exact BLE devices.
* @param settings Settings for the scan.
diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl
index ceb610a..bc24d67 100644
--- a/core/java/android/content/pm/IPackageManager.aidl
+++ b/core/java/android/content/pm/IPackageManager.aidl
@@ -253,7 +253,7 @@
List<PackageInfo> getPreferredPackages(int flags);
- void resetPreferredActivities(int userId);
+ void resetApplicationPreferences(int userId);
ResolveInfo getLastChosenActivity(in Intent intent,
String resolvedType, int flags);
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 6533bbc..cda5816 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -1514,6 +1514,13 @@
/**
* Feature for {@link #getSystemAvailableFeatures} and
+ * {@link #hasSystemFeature}: The device has biometric hardware to detect a fingerprint.
+ */
+ @SdkConstant(SdkConstantType.FEATURE)
+ public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint";
+
+ /**
+ * Feature for {@link #getSystemAvailableFeatures} and
* {@link #hasSystemFeature}: The device supports portrait orientation
* screens. For backwards compatibility, you can assume that if neither
* this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
diff --git a/core/java/android/content/pm/PermissionInfo.java b/core/java/android/content/pm/PermissionInfo.java
index 2828d83..d514513 100644
--- a/core/java/android/content/pm/PermissionInfo.java
+++ b/core/java/android/content/pm/PermissionInfo.java
@@ -145,12 +145,10 @@
public static final int FLAG_COSTS_MONEY = 1<<0;
/**
- * Flag for {@link #protectionLevel}, corresponding
- * to the <code>hide</code> value of
- * {@link android.R.attr#permissionFlags}.
- * @hide
+ * Flag for {@link #flags}, indicating that this permission has been
+ * installed into the system's globally defined permissions.
*/
- public static final int PROTECTION_FLAG_HIDE = 1<<1;
+ public static final int FLAG_INSTALLED = 1<<30;
/**
* Additional flags about this permission as given by
@@ -210,6 +208,15 @@
if ((level&PermissionInfo.PROTECTION_FLAG_PRE23) != 0) {
protLevel += "|pre23";
}
+ if ((level&PermissionInfo.PROTECTION_FLAG_INSTALLER) != 0) {
+ protLevel += "|installer";
+ }
+ if ((level&PermissionInfo.PROTECTION_FLAG_VERIFIER) != 0) {
+ protLevel += "|verifier";
+ }
+ if ((level&PermissionInfo.PROTECTION_FLAG_PREINSTALLED) != 0) {
+ protLevel += "|preinstalled";
+ }
return protLevel;
}
diff --git a/core/java/android/hardware/fingerprint/FingerprintManager.java b/core/java/android/hardware/fingerprint/FingerprintManager.java
index c5f142a..ee37047 100644
--- a/core/java/android/hardware/fingerprint/FingerprintManager.java
+++ b/core/java/android/hardware/fingerprint/FingerprintManager.java
@@ -321,6 +321,14 @@
* Called when a fingerprint is valid but not recognized.
*/
public void onAuthenticationFailed() { }
+
+ /**
+ * Called when a fingerprint image has been acquired, but wasn't processed yet.
+ *
+ * @param acquireInfo one of FINGERPRINT_ACQUIRED_* constants
+ * @hide
+ */
+ public void onAuthenticationAcquired(int acquireInfo) {}
};
/**
@@ -737,9 +745,13 @@
}
private void sendAcquiredResult(long deviceId, int acquireInfo) {
+ if (mAuthenticationCallback != null) {
+ mAuthenticationCallback.onAuthenticationAcquired(acquireInfo);
+ }
final String msg = getAcquiredString(acquireInfo);
- if (msg == null) return;
-
+ if (msg == null) {
+ return;
+ }
if (mEnrollmentCallback != null) {
mEnrollmentCallback.onEnrollmentHelp(acquireInfo, msg);
} else if (mAuthenticationCallback != null) {
diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java
index 864225a..af4c2bc 100644
--- a/core/java/android/os/FileUtils.java
+++ b/core/java/android/os/FileUtils.java
@@ -16,6 +16,7 @@
package android.os;
+import android.annotation.NonNull;
import android.provider.DocumentsContract.Document;
import android.system.ErrnoException;
import android.system.Os;
@@ -69,6 +70,8 @@
/** Regular expression for safe filenames: no spaces or metacharacters */
private static final Pattern SAFE_FILENAME_PATTERN = Pattern.compile("[\\w%+,./=_-]+");
+ private static final File[] EMPTY = new File[0];
+
/**
* Set owner and mode of of given {@link File}.
*
@@ -634,4 +637,13 @@
return new File(parent, name + "." + ext);
}
}
+
+ public static @NonNull File[] listFilesOrEmpty(File dir) {
+ File[] res = dir.listFiles();
+ if (res != null) {
+ return res;
+ } else {
+ return EMPTY;
+ }
+ }
}
diff --git a/core/java/android/os/IDeviceIdleController.aidl b/core/java/android/os/IDeviceIdleController.aidl
index b768852..d3eec1e 100644
--- a/core/java/android/os/IDeviceIdleController.aidl
+++ b/core/java/android/os/IDeviceIdleController.aidl
@@ -29,5 +29,6 @@
boolean isPowerSaveWhitelistApp(String name);
void addPowerSaveTempWhitelistApp(String name, long duration, int userId, String reason);
long addPowerSaveTempWhitelistAppForMms(String name, int userId, String reason);
+ long addPowerSaveTempWhitelistAppForSms(String name, int userId, String reason);
void exitIdle(String reason);
}
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index b104135..79fb805 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -45,7 +45,9 @@
private final Context mContext;
/**
- * Specifies if a user is disallowed from adding and removing accounts.
+ * Specifies if a user is disallowed from adding and removing accounts, unless they are
+ * {@link android.accounts.AccountManager#addAccountExplicitly programmatically} added by
+ * Authenticator.
* The default value is <code>false</code>.
*
* <p/>Key for user restrictions.
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index fff355b4..a79970c 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -7578,14 +7578,6 @@
public static final String WFC_IMS_ROAMING_ENABLED = "wfc_ims_roaming_enabled";
/**
- * Global override to disable VoLTE (independent of user setting)
- * <p>
- * Type: int (1 for disable VoLTE, 0 to use user configuration)
- * @hide
- */
- public static final String VOLTE_FEATURE_DISABLED = "volte_feature_disabled";
-
- /**
* Whether user can enable/disable LTE as a preferred network. A carrier might control
* this via gservices, OMA-DM, carrier app, etc.
* <p>
diff --git a/core/java/android/security/keymaster/KeymasterDefs.java b/core/java/android/security/keymaster/KeymasterDefs.java
index bae5455..04d5952 100644
--- a/core/java/android/security/keymaster/KeymasterDefs.java
+++ b/core/java/android/security/keymaster/KeymasterDefs.java
@@ -51,6 +51,7 @@
public static final int KM_TAG_DIGEST = KM_ENUM_REP | 5;
public static final int KM_TAG_PADDING = KM_ENUM_REP | 6;
public static final int KM_TAG_CALLER_NONCE = KM_BOOL | 7;
+ public static final int KM_TAG_MIN_MAC_LENGTH = KM_UINT | 8;
public static final int KM_TAG_RESCOPING_ADD = KM_ENUM_REP | 101;
public static final int KM_TAG_RESCOPING_DEL = KM_ENUM_REP | 102;
@@ -194,6 +195,9 @@
public static final int KM_ERROR_KEY_RATE_LIMIT_EXCEEDED = -54;
public static final int KM_ERROR_CALLER_NONCE_PROHIBITED = -55;
public static final int KM_ERROR_KEY_MAX_OPS_EXCEEDED = -56;
+ public static final int KM_ERROR_INVALID_MAC_LENGTH = -57;
+ public static final int KM_ERROR_MISSING_MIN_MAC_LENGTH = -58;
+ public static final int KM_ERROR_UNSUPPORTED_MIN_MAC_LENGTH = -59;
public static final int KM_ERROR_UNIMPLEMENTED = -100;
public static final int KM_ERROR_VERSION_MISMATCH = -101;
public static final int KM_ERROR_UNKNOWN_ERROR = -1000;
@@ -237,6 +241,8 @@
sErrorCodeToString.put(KM_ERROR_INVALID_NONCE, "Invalid IV");
sErrorCodeToString.put(KM_ERROR_CALLER_NONCE_PROHIBITED,
"Caller-provided IV not permitted");
+ sErrorCodeToString.put(KM_ERROR_INVALID_MAC_LENGTH,
+ "Invalid MAC or authentication tag length");
sErrorCodeToString.put(KM_ERROR_UNIMPLEMENTED, "Not implemented");
sErrorCodeToString.put(KM_ERROR_UNKNOWN_ERROR, "Unknown error");
}
diff --git a/core/java/android/service/voice/IVoiceInteractionSession.aidl b/core/java/android/service/voice/IVoiceInteractionSession.aidl
index 8fe84e1..dbc28f7 100644
--- a/core/java/android/service/voice/IVoiceInteractionSession.aidl
+++ b/core/java/android/service/voice/IVoiceInteractionSession.aidl
@@ -35,5 +35,6 @@
void taskStarted(in Intent intent, int taskId);
void taskFinished(in Intent intent, int taskId);
void closeSystemDialogs();
+ void onLockscreenShown();
void destroy();
}
diff --git a/core/java/android/service/voice/VoiceInteractionSession.java b/core/java/android/service/voice/VoiceInteractionSession.java
index f08e93c..f647aa6 100644
--- a/core/java/android/service/voice/VoiceInteractionSession.java
+++ b/core/java/android/service/voice/VoiceInteractionSession.java
@@ -265,6 +265,11 @@
}
@Override
+ public void onLockscreenShown() {
+ mHandlerCaller.sendMessage(mHandlerCaller.obtainMessage(MSG_ON_LOCKSCREEN_SHOWN));
+ }
+
+ @Override
public void destroy() {
mHandlerCaller.sendMessage(mHandlerCaller.obtainMessage(MSG_DESTROY));
}
@@ -674,6 +679,7 @@
static final int MSG_HANDLE_SCREENSHOT = 105;
static final int MSG_SHOW = 106;
static final int MSG_HIDE = 107;
+ static final int MSG_ON_LOCKSCREEN_SHOWN = 108;
class MyCallbacks implements HandlerCaller.Callback, SoftInputWindow.Callback {
@Override
@@ -752,6 +758,10 @@
if (DEBUG) Log.d(TAG, "doHide");
doHide();
break;
+ case MSG_ON_LOCKSCREEN_SHOWN:
+ if (DEBUG) Log.d(TAG, "onLockscreenShown");
+ onLockscreenShown();
+ break;
}
if (args != null) {
args.recycle();
@@ -1296,6 +1306,13 @@
hide();
}
+ /**
+ * Called when the lockscreen was shown.
+ */
+ public void onLockscreenShown() {
+ hide();
+ }
+
@Override
public void onConfigurationChanged(Configuration newConfig) {
}
diff --git a/core/java/android/view/inputmethod/InputMethodManagerInternal.java b/core/java/android/view/inputmethod/InputMethodManagerInternal.java
new file mode 100644
index 0000000..c22127b
--- /dev/null
+++ b/core/java/android/view/inputmethod/InputMethodManagerInternal.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2015 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+package android.view.inputmethod;
+
+/**
+ * Input method manager local system service interface.
+ *
+ * @hide Only for use within the system server.
+ */
+public interface InputMethodManagerInternal {
+ /**
+ * Called by the power manager to tell the input method manager whether it
+ * should start watching for wake events.
+ */
+ public void setInteractive(boolean interactive);
+}
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index b2b98db..ed858e7 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -1556,13 +1556,6 @@
if (accessibilityId == getAccessibilityViewId()) {
return this;
}
- // If the data changed the children are invalid since the data model changed.
- // Hence, we pretend they do not exist. After a layout the children will sync
- // with the model at which point we notify that the accessibility state changed,
- // so a service will be able to re-fetch the views.
- if (mDataChanged) {
- return null;
- }
return super.findViewByAccessibilityIdTraversal(accessibilityId);
}
@@ -2409,18 +2402,6 @@
class ListItemAccessibilityDelegate extends AccessibilityDelegate {
@Override
- public AccessibilityNodeInfo createAccessibilityNodeInfo(View host) {
- // If the data changed the children are invalid since the data model changed.
- // Hence, we pretend they do not exist. After a layout the children will sync
- // with the model at which point we notify that the accessibility state changed,
- // so a service will be able to re-fetch the views.
- if (mDataChanged) {
- return null;
- }
- return super.createAccessibilityNodeInfo(host);
- }
-
- @Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(host, info);
diff --git a/core/java/android/widget/AppSecurityPermissions.java b/core/java/android/widget/AppSecurityPermissions.java
index e3ce6f2..a12b15e 100644
--- a/core/java/android/widget/AppSecurityPermissions.java
+++ b/core/java/android/widget/AppSecurityPermissions.java
@@ -533,6 +533,12 @@
int existingReqFlags) {
final int base = pInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE;
final boolean isNormal = (base == PermissionInfo.PROTECTION_NORMAL);
+
+ // We do not show normal permissions in the UI.
+ if (isNormal) {
+ return false;
+ }
+
final boolean isDangerous = (base == PermissionInfo.PROTECTION_DANGEROUS)
|| ((pInfo.protectionLevel&PermissionInfo.PROTECTION_FLAG_PRE23) != 0);
final boolean isRequired =
@@ -546,7 +552,7 @@
// Dangerous and normal permissions are always shown to the user if the permission
// is required, or it was previously granted
- if ((isNormal || isDangerous) && (isRequired || wasGranted || isGranted)) {
+ if (isDangerous && (isRequired || wasGranted || isGranted)) {
return true;
}
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 15d13ae..e169ceb 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -1004,7 +1004,8 @@
}
if (!handled && mTextActionMode != null) {
- if (touchPositionIsInSelection()) {
+ // TODO: Fix dragging in extracted mode.
+ if (touchPositionIsInSelection() && !mTextView.isInExtractedMode()) {
// Start a drag
final int start = mTextView.getSelectionStart();
final int end = mTextView.getSelectionEnd();
diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java
index dac02fa..6a561e6 100644
--- a/core/java/android/widget/RelativeLayout.java
+++ b/core/java/android/widget/RelativeLayout.java
@@ -731,7 +731,8 @@
// Negative values in a mySize value in RelativeLayout
// measurement is code for, "we got an unspecified mode in the
// RelativeLayout's measure spec."
- if (mySize < 0 && !mAllowBrokenMeasureSpecs) {
+ final boolean isUnspecified = mySize < 0;
+ if (isUnspecified && !mAllowBrokenMeasureSpecs) {
if (childStart != VALUE_NOT_SET && childEnd != VALUE_NOT_SET) {
// Constraints fixed both edges, so child has an exact size.
childSpecSize = Math.max(0, childEnd - childStart);
@@ -767,7 +768,7 @@
if (childStart != VALUE_NOT_SET && childEnd != VALUE_NOT_SET) {
// Constraints fixed both edges, so child must be an exact size.
- childSpecMode = MeasureSpec.EXACTLY;
+ childSpecMode = isUnspecified ? MeasureSpec.UNSPECIFIED : MeasureSpec.EXACTLY;
childSpecSize = Math.max(0, maxAvailable);
} else {
if (childSize >= 0) {
@@ -784,7 +785,7 @@
} else if (childSize == LayoutParams.MATCH_PARENT) {
// Child wanted to be as big as possible. Give all available
// space.
- childSpecMode = MeasureSpec.EXACTLY;
+ childSpecMode = isUnspecified ? MeasureSpec.UNSPECIFIED : MeasureSpec.EXACTLY;
childSpecSize = Math.max(0, maxAvailable);
} else if (childSize == LayoutParams.WRAP_CONTENT) {
// Child wants to wrap content. Use AT_MOST to communicate
diff --git a/core/java/com/android/internal/app/AssistUtils.java b/core/java/com/android/internal/app/AssistUtils.java
index 0910daf..d552e54 100644
--- a/core/java/com/android/internal/app/AssistUtils.java
+++ b/core/java/com/android/internal/app/AssistUtils.java
@@ -122,6 +122,16 @@
}
}
+ public void onLockscreenShown() {
+ try {
+ if (mVoiceInteractionManagerService != null) {
+ mVoiceInteractionManagerService.onLockscreenShown();
+ }
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to call onLockscreenShown", e);
+ }
+ }
+
public ComponentName getAssistComponentForUser(int userId) {
final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(),
Settings.Secure.ASSISTANT, userId);
diff --git a/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl b/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl
index dc946abc..1a963f3 100644
--- a/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl
+++ b/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl
@@ -131,4 +131,9 @@
* from the lockscreen.
*/
boolean activeServiceSupportsLaunchFromKeyguard();
+
+ /**
+ * Called when the lockscreen got shown.
+ */
+ void onLockscreenShown();
}
diff --git a/core/java/com/android/internal/logging/MetricsLogger.java b/core/java/com/android/internal/logging/MetricsLogger.java
index cbe535f..91ae27b 100644
--- a/core/java/com/android/internal/logging/MetricsLogger.java
+++ b/core/java/com/android/internal/logging/MetricsLogger.java
@@ -27,7 +27,20 @@
*/
public class MetricsLogger implements MetricsConstants {
// Temporary constants go here, to await migration to MetricsConstants.
- // next value is 227;
+ // next value is 238;
+
+ public static final int TUNER = 227;
+ public static final int TUNER_QS = 228;
+ public static final int TUNER_DEMO_MODE = 229;
+
+ public static final int TUNER_QS_REORDER = 230;
+ public static final int TUNER_QS_ADD = 231;
+ public static final int TUNER_QS_REMOVE = 232;
+ public static final int TUNER_STATUS_BAR_ENABLE = 233;
+ public static final int TUNER_STATUS_BAR_DISABLE = 234;
+ public static final int TUNER_DEMO_MODE_ENABLED = 235;
+ public static final int TUNER_DEMO_MODE_ON = 236;
+ public static final int TUNER_BATTERY_PERCENTAGE = 237;
public static void visible(Context context, int category) throws IllegalArgumentException {
if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) {
diff --git a/core/java/com/android/internal/os/BatteryStatsHelper.java b/core/java/com/android/internal/os/BatteryStatsHelper.java
index 264b8c1..9caf78a 100644
--- a/core/java/com/android/internal/os/BatteryStatsHelper.java
+++ b/core/java/com/android/internal/os/BatteryStatsHelper.java
@@ -47,6 +47,7 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import java.util.Locale;
/**
* A helper class for retrieving the power usage information for all applications and services.
@@ -267,15 +268,20 @@
public static String makemAh(double power) {
if (power == 0) return "0";
- else if (power < .00001) return String.format("%.8f", power);
- else if (power < .0001) return String.format("%.7f", power);
- else if (power < .001) return String.format("%.6f", power);
- else if (power < .01) return String.format("%.5f", power);
- else if (power < .1) return String.format("%.4f", power);
- else if (power < 1) return String.format("%.3f", power);
- else if (power < 10) return String.format("%.2f", power);
- else if (power < 100) return String.format("%.1f", power);
- else return String.format("%.0f", power);
+
+ final String format;
+ if (power < .00001) format = "%.8f";
+ else if (power < .0001) format = "%.7f";
+ else if (power < .001) format = "%.6f";
+ else if (power < .01) format = "%.5f";
+ else if (power < .1) format = "%.4f";
+ else if (power < 1) format = "%.3f";
+ else if (power < 10) format = "%.2f";
+ else if (power < 100) format = "%.1f";
+ else format = "%.0f";
+
+ // Use English locale because this is never used in UI (only in checkin and dump).
+ return String.format(Locale.ENGLISH, format, power);
}
/**
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 60f47d6..e7c58f4 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -2560,14 +2560,24 @@
addHistoryEventLocked(elapsedRealtime, uptime, code, name, uid);
}
+ boolean ensureStartClockTime(final long currentTime) {
+ final long ABOUT_ONE_YEAR = 365*24*60*60*1000L;
+ if (currentTime > ABOUT_ONE_YEAR && mStartClockTime < (currentTime-ABOUT_ONE_YEAR)) {
+ // If the start clock time has changed by more than a year, then presumably
+ // the previous time was completely bogus. So we are going to figure out a
+ // new time based on how much time has elapsed since we started counting.
+ mStartClockTime = currentTime - (SystemClock.elapsedRealtime()-(mRealtimeStart/1000));
+ return true;
+ }
+ return false;
+ }
+
public void noteCurrentTimeChangedLocked() {
final long currentTime = System.currentTimeMillis();
final long elapsedRealtime = SystemClock.elapsedRealtime();
final long uptime = SystemClock.uptimeMillis();
recordCurrentTimeChangeLocked(currentTime, elapsedRealtime, uptime);
- if (isStartClockTimeValid()) {
- mStartClockTime = currentTime;
- }
+ ensureStartClockTime(currentTime);
}
public void noteProcessStartLocked(String name, int uid) {
@@ -4306,19 +4316,11 @@
}
}
- boolean isStartClockTimeValid() {
- return mStartClockTime > 365*24*60*60*1000L;
- }
-
@Override public long getStartClockTime() {
- if (!isStartClockTimeValid()) {
- // If the last clock time we got was very small, then we hadn't had a real
- // time yet, so try to get it again.
- mStartClockTime = System.currentTimeMillis();
- if (isStartClockTimeValid()) {
- recordCurrentTimeChangeLocked(mStartClockTime, SystemClock.elapsedRealtime(),
- SystemClock.uptimeMillis());
- }
+ final long currentTime = System.currentTimeMillis();
+ if (ensureStartClockTime(currentTime)) {
+ recordCurrentTimeChangeLocked(currentTime, SystemClock.elapsedRealtime(),
+ SystemClock.uptimeMillis());
}
return mStartClockTime;
}
diff --git a/core/java/com/android/internal/os/KernelWakelockReader.java b/core/java/com/android/internal/os/KernelWakelockReader.java
index 768d586..0369c3f 100644
--- a/core/java/com/android/internal/os/KernelWakelockReader.java
+++ b/core/java/com/android/internal/os/KernelWakelockReader.java
@@ -68,12 +68,12 @@
try {
FileInputStream is;
try {
- is = new FileInputStream(sWakeupSourceFile);
- wakeup_sources = true;
+ is = new FileInputStream(sWakelockFile);
+ wakeup_sources = false;
} catch (java.io.FileNotFoundException e) {
try {
- is = new FileInputStream(sWakelockFile);
- wakeup_sources = false;
+ is = new FileInputStream(sWakeupSourceFile);
+ wakeup_sources = true;
} catch (java.io.FileNotFoundException e2) {
return null;
}
diff --git a/core/java/com/android/internal/policy/IKeyguardShowCallback.aidl b/core/java/com/android/internal/policy/IKeyguardDrawnCallback.aidl
similarity index 89%
rename from core/java/com/android/internal/policy/IKeyguardShowCallback.aidl
rename to core/java/com/android/internal/policy/IKeyguardDrawnCallback.aidl
index a2784d9..ef8478c 100644
--- a/core/java/com/android/internal/policy/IKeyguardShowCallback.aidl
+++ b/core/java/com/android/internal/policy/IKeyguardDrawnCallback.aidl
@@ -15,6 +15,6 @@
*/
package com.android.internal.policy;
-oneway interface IKeyguardShowCallback {
- void onShown(IBinder windowToken);
+oneway interface IKeyguardDrawnCallback {
+ void onDrawn();
}
diff --git a/core/java/com/android/internal/policy/IKeyguardService.aidl b/core/java/com/android/internal/policy/IKeyguardService.aidl
index 7ab4651..79af452 100644
--- a/core/java/com/android/internal/policy/IKeyguardService.aidl
+++ b/core/java/com/android/internal/policy/IKeyguardService.aidl
@@ -15,7 +15,7 @@
*/
package com.android.internal.policy;
-import com.android.internal.policy.IKeyguardShowCallback;
+import com.android.internal.policy.IKeyguardDrawnCallback;
import com.android.internal.policy.IKeyguardStateCallback;
import com.android.internal.policy.IKeyguardExitCallback;
@@ -57,7 +57,13 @@
/**
* Called when the device has started waking up.
*/
- void onStartedWakingUp(IKeyguardShowCallback callback);
+ void onStartedWakingUp();
+
+ /**
+ * Called when the device screen is turning on.
+ */
+ void onScreenTurningOn(IKeyguardDrawnCallback callback);
+
void setKeyguardEnabled(boolean enabled);
void onSystemReady();
void doKeyguardTimeout(in Bundle options);
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 0c0ba7f..3e22e09 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -331,7 +331,7 @@
<!-- Used for runtime permissions related to user's contacts and profile. -->
<permission-group android:name="android.permission-group.CONTACTS"
- android:icon="@drawable/perm_group_social_info"
+ android:icon="@drawable/perm_group_contacts"
android:label="@string/permgrouplab_contacts"
android:description="@string/permgroupdesc_contacts"
android:priority="100" />
@@ -391,7 +391,7 @@
<!-- Used for runtime permissions related to user's SMS messages. -->
<permission-group android:name="android.permission-group.SMS"
- android:icon="@drawable/perm_group_messages"
+ android:icon="@drawable/perm_group_sms"
android:label="@string/permgrouplab_sms"
android:description="@string/permgroupdesc_sms"
android:priority="300" />
@@ -729,6 +729,7 @@
<!-- Used for permissions that are associated with accessing
camera or capturing images/video from the device. -->
<permission-group android:name="android.permission-group.SENSORS"
+ android:icon="@drawable/perm_group_sensors"
android:label="@string/permgrouplab_sensors"
android:description="@string/permgroupdesc_sensors"
android:priority="800" />
@@ -1535,7 +1536,9 @@
<permission android:name="android.permission.CHANGE_CONFIGURATION"
android:protectionLevel="signature|privileged|development" />
- <!-- Allows an application to read or write the system settings. -->
+ <!-- Allows an application to read or write the system settings.
+ <p>Protection level: signature
+ -->
<permission android:name="android.permission.WRITE_SETTINGS"
android:label="@string/permlab_writeSettings"
android:description="@string/permdesc_writeSettings"
@@ -1746,6 +1749,10 @@
<!-- ==================================== -->
<eat-comment />
+ <!-- @SystemApi Allows access to the list of accounts in the Accounts Service. -->
+ <permission android:name="android.permission.GET_ACCOUNTS_PRIVILEGED"
+ android:protectionLevel="signature|privileged" />
+
<!-- @SystemApi Allows applications to RW to diagnostic resources.
<p>Not for use by third-party applications. -->
<permission android:name="android.permission.DIAGNOSTIC"
diff --git a/core/res/res/drawable/ic_more_items.xml b/core/res/res/drawable/ic_more_items.xml
new file mode 100644
index 0000000..5fdcdce
--- /dev/null
+++ b/core/res/res/drawable/ic_more_items.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
+ <path
+ android:fillColor="#000000"
+ android:pathData="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7
+7v2h14V7H7z" />
+ <path
+ android:pathData="M0 0h24v24H0z" />
+</vector>
\ No newline at end of file
diff --git a/core/res/res/drawable/perm_group_calendar.xml b/core/res/res/drawable/perm_group_calendar.xml
index a0f9dd2..4dc7b37 100644
--- a/core/res/res/drawable/perm_group_calendar.xml
+++ b/core/res/res/drawable/perm_group_calendar.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
@@ -14,11 +15,15 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24.0dp"
- android:height="24.0dp"
- android:viewportWidth="48.0"
- android:viewportHeight="48.0">
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
<path
- android:fillColor="#FF000000"
- android:pathData="M34.0,24.0L24.0,24.0l0.0,10.0l10.0,0.0L34.0,24.0zM32.0,2.0l0.0,4.0L16.0,6.0L16.0,2.0l-4.0,0.0l0.0,4.0l-2.0,0.0c-2.21,0.0 -3.98,1.79 -3.98,4.0L6.0,38.0c0.0,2.21 1.79,4.0 4.0,4.0l28.0,0.0c2.21,0.0 4.0,-1.79 4.0,-4.0L42.0,10.0c0.0,-2.21 -1.79,-4.0 -4.0,-4.0l-2.0,0.0L36.0,2.0l-4.0,0.0zm6.0,36.0L10.0,38.0L10.0,16.0l28.0,0.0l0.0,22.0z"/>
-</vector>
+ android:fillColor="#000000"
+ android:pathData="M17 12h-5v5h5v-5zM16 1v2H8V1H6v2H5c-1.11 0-1.99 .9 -1.99 2L3 19c0 1.1 .89 2 2
+2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2h-1V1h-2zm3 18H5V8h14v11z" />
+ <path
+ android:pathData="M0 0h24v24H0z" />
+</vector>
\ No newline at end of file
diff --git a/core/res/res/drawable/perm_group_camera.xml b/core/res/res/drawable/perm_group_camera.xml
index 30d31ce..741a40e 100644
--- a/core/res/res/drawable/perm_group_camera.xml
+++ b/core/res/res/drawable/perm_group_camera.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
@@ -14,11 +15,19 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24.0dp"
- android:height="24.0dp"
- android:viewportWidth="48.0"
- android:viewportHeight="48.0">
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
<path
- android:fillColor="#FF000000"
- android:pathData="M18.8,21.0l9.53,-16.51C26.94,4.18 25.49,4.0 24.0,4.0c-4.8,0.0 -9.19,1.69 -12.64,4.51l7.33,12.6 0.11,-0.2zm24.28,-3.0c-1.84,-5.85 -6.3,-10.52 -11.99,-12.68L23.77,18.0l19.31,0.0zm0.52,2.0L28.62,20.0l0.58,1.0 9.53,16.5C41.99,33.94 44.0,29.21 44.0,24.0c0.0,-1.37 -0.14,-2.71 -0.4,-4.0zm-26.53,4.0l-7.8,-13.5C6.01,14.06 4.0,18.79 4.0,24.0c0.0,1.3 0.14,2.7 0.4,4.0l14.98,0.0l-2.31,-4.0zM4.92,30.0c1.84,5.85 6.3,10.52 11.99,12.68L24.23,30.0L4.92,30.0zm22.54,0.0l-7.8,13.51c1.0,0.31 2.8,0.49 4.3,0.49 4.8,0.0 9.19,-1.69 12.64,-4.51L29.31,26.8 27.46,30.0z"/>
-</vector>
+ android:fillColor="#000000"
+ android:pathData="M 12 8.8 C 13.7673111995 8.8 15.2 10.2326888005 15.2 12 C 15.2 13.7673111995 13.7673111995 15.2 12 15.2 C 10.2326888005 15.2 8.8 13.7673111995 8.8 12 C 8.8 10.2326888005 10.2326888005 8.8 12 8.8 Z" />
+ <path
+ android:fillColor="#000000"
+ android:pathData="M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1 .9 2 2 2h16c1.1 0 2-.9
+2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5
+5-2.24 5-5 5z" />
+ <path
+ android:pathData="M0 0h24v24H0z" />
+</vector>
\ No newline at end of file
diff --git a/core/res/res/drawable/perm_group_contacts.xml b/core/res/res/drawable/perm_group_contacts.xml
new file mode 100644
index 0000000..d698fd1
--- /dev/null
+++ b/core/res/res/drawable/perm_group_contacts.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
+ <path
+ android:pathData="M0 0h24v24H0zm0 0h24v24H0zm0 0h24v24H0z" />
+ <path
+ android:fillColor="#000000"
+ android:pathData="M20 0H4v2h16V0zM4 24h16v-2H4v2zM20 4H4c-1.1 0-2 .9-2 2v12c0 1.1 .9 2 2 2h16c1.1
+0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-8 2.75c1.24 0 2.25 1.01 2.25 2.25s-1.01 2.25-2.25
+2.25S9.75 10.24 9.75 9 10.76 6.75 12 6.75zM17 17H7v-1.5c0-1.67 3.33-2.5 5-2.5s5
+.83 5 2.5V17z" />
+</vector>
\ No newline at end of file
diff --git a/core/res/res/drawable/perm_group_location.xml b/core/res/res/drawable/perm_group_location.xml
index 4184cf9..fbc6066 100644
--- a/core/res/res/drawable/perm_group_location.xml
+++ b/core/res/res/drawable/perm_group_location.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
@@ -14,11 +15,15 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24.0dp"
- android:height="24.0dp"
- android:viewportWidth="48.0"
- android:viewportHeight="48.0">
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
<path
- android:fillColor="#FF000000"
- android:pathData="M24.0,16.0c-4.42,0.0 -8.0,3.58 -8.0,8.0s3.58,8.0 8.0,8.0 8.0,-3.58 8.0,-8.0 -3.58,-8.0 -8.0,-8.0zm17.88,6.0C40.96,13.66 34.34,7.04 26.0,6.12L26.0,2.0l-4.0,0.0l0.0,4.12C13.66,7.04 7.04,13.66 6.12,22.0L2.0,22.0l0.0,4.0l4.12,0.0c0.92,8.34 7.54,14.96 15.88,15.88L22.0,46.0l4.0,0.0l0.0,-4.12c8.34,-0.92 14.96,-7.54 15.88,-15.88L46.0,26.0l0.0,-4.0l-4.12,0.0zM24.0,38.0c-7.73,0.0 -14.0,-6.27 -14.0,-14.0s6.27,-14.0 14.0,-14.0 14.0,6.27 14.0,14.0 -6.27,14.0 -14.0,14.0z"/>
-</vector>
+ android:fillColor="#000000"
+ android:pathData="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0
+9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z" />
+ <path
+ android:pathData="M0 0h24v24H0z" />
+</vector>
\ No newline at end of file
diff --git a/core/res/res/drawable/perm_group_messages.xml b/core/res/res/drawable/perm_group_messages.xml
deleted file mode 100644
index 4140e6c..0000000
--- a/core/res/res/drawable/perm_group_messages.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- Copyright (C) 2015 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
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- 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.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24.0dp"
- android:height="24.0dp"
- android:viewportWidth="48.0"
- android:viewportHeight="48.0">
- <path
- android:fillColor="#FF000000"
- android:pathData="M40.0,4.0L8.0,4.0C5.79,4.0 4.02,5.79 4.02,8.0L4.0,44.0l8.0,-8.0l28.0,0.0c2.21,0.0 4.0,-1.79 4.0,-4.0L44.0,8.0c0.0,-2.21 -1.79,-4.0 -4.0,-4.0zm-4.0,24.0L12.0,28.0l0.0,-4.0l16.0,0.0l0.0,4.0zm0.0,-6.0L12.0,22.0l0.0,-4.0l24.0,0.0l0.0,4.0zm0.0,-6.0L12.0,16.0l0.0,-4.0l24.0,0.0l0.0,4.0z"/>
-</vector>
diff --git a/core/res/res/drawable/perm_group_microphone.xml b/core/res/res/drawable/perm_group_microphone.xml
index 670ef98..c565d20 100644
--- a/core/res/res/drawable/perm_group_microphone.xml
+++ b/core/res/res/drawable/perm_group_microphone.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
@@ -14,11 +15,16 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24.0dp"
- android:height="24.0dp"
- android:viewportWidth="48.0"
- android:viewportHeight="48.0">
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
<path
- android:fillColor="#FF000000"
- android:pathData="M24.0,28.0c3.31,0.0 5.98,-2.69 5.98,-6.0L30.0,10.0c0.0,-3.32 -2.68,-6.0 -6.0,-6.0 -3.31,0.0 -6.0,2.68 -6.0,6.0l0.0,12.0c0.0,3.31 2.69,6.0 6.0,6.0zm10.6,-6.0c0.0,6.0 -5.07,10.2 -10.6,10.2 -5.52,0.0 -10.6,-4.2 -10.6,-10.2L10.0,22c0.0,6.83 5.44,12.47 12.0,13.44L22.0,42.0l4.0,0.0l0.0,-6.56c6.56,-0.97 12.0,-6.61 12.0,-13.44l-3.4,0.0z"/>
-</vector>
+ android:fillColor="#000000"
+ android:pathData="M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3
+3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6
+6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z" />
+ <path
+ android:pathData="M0 0h24v24H0z" />
+</vector>
\ No newline at end of file
diff --git a/core/res/res/drawable/perm_group_phone_calls.xml b/core/res/res/drawable/perm_group_phone_calls.xml
index 04ac6b9..a647894 100644
--- a/core/res/res/drawable/perm_group_phone_calls.xml
+++ b/core/res/res/drawable/perm_group_phone_calls.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
@@ -14,11 +15,17 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24.0dp"
- android:height="24.0dp"
- android:viewportWidth="48.0"
- android:viewportHeight="48.0">
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
<path
- android:fillColor="#FF000000"
- android:pathData="M13.25,21.59c2.88,5.66 7.51,10.29 13.18,13.17l4.4,-4.41c0.55,-0.55 1.34,-0.71 2.03,-0.49C35.1,30.6 37.51,31.0 40.0,31.0c1.11,0.0 2.0,0.89 2.0,2.0l0.0,7.0c0.0,1.11 -0.89,2.0 -2.0,2.0C21.22,42.0 6.0,26.78 6.0,8.0c0.0,-1.1 0.9,-2.0 2.0,-2.0l7.0,0.0c1.11,0.0 2.0,0.89 2.0,2.0 0.0,2.4 0.4,4.9 1.14,7.1 0.2,0.6 0.06,1.48 -0.49,2.03l-4.4,4.42z"/>
-</vector>
+ android:pathData="M0 0h24v24H0z" />
+ <path
+ android:fillColor="#000000"
+ android:pathData="M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27 .67 -.36 1.02-.24 1.12
+.37 2.33 .57 3.57 .57 .55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17
+0-.55 .45 -1 1-1h3.5c.55 0 1 .45 1 1 0 1.25 .2 2.45 .57 3.57 .11 .35 .03 .74-.25
+1.02l-2.2 2.2z" />
+</vector>
\ No newline at end of file
diff --git a/core/res/res/drawable/perm_group_sensors.xml b/core/res/res/drawable/perm_group_sensors.xml
new file mode 100644
index 0000000..ce36c13
--- /dev/null
+++ b/core/res/res/drawable/perm_group_sensors.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
+ <path
+ android:fillColor="#000000"
+ android:pathData="M13.49 5.48c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm-3.6 13.9l1-4.4 2.1
+2v6h2v-7.5l-2.1-2 .6-3c1.3 1.5 3.3 2.5 5.5 2.5v-2c-1.9
+0-3.5-1-4.3-2.4l-1-1.6c-.4-.6-1-1-1.7-1-.3 0-.5 .1 -.8 .1 l-5.2
+2.2v4.7h2v-3.4l1.8-.7-1.6 8.1-4.9-1-.4 2 7 1.4z" />
+</vector>
\ No newline at end of file
diff --git a/core/res/res/drawable/perm_group_sms.xml b/core/res/res/drawable/perm_group_sms.xml
new file mode 100644
index 0000000..9b32c601
--- /dev/null
+++ b/core/res/res/drawable/perm_group_sms.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
+ <path
+ android:fillColor="#000000"
+ android:pathData="M20 2H4c-1.1 0-1.99 .9 -1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM9
+11H7V9h2v2zm4 0h-2V9h2v2zm4 0h-2V9h2v2z" />
+ <path
+ android:pathData="M0 0h24v24H0z" />
+</vector>
\ No newline at end of file
diff --git a/core/res/res/drawable/perm_group_social_info.xml b/core/res/res/drawable/perm_group_social_info.xml
deleted file mode 100644
index f0f7a90..0000000
--- a/core/res/res/drawable/perm_group_social_info.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- Copyright (C) 2015 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
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- 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.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24.0dp"
- android:height="24.0dp"
- android:viewportWidth="48.0"
- android:viewportHeight="48.0">
- <path
- android:fillColor="#FF000000"
- android:pathData="M32.0,22.0c3.31,0.0 5.98,-2.69 5.98,-6.0s-2.67,-6.0 -5.98,-6.0c-3.31,0.0 -6.0,2.69 -6.0,6.0s2.69,6.0 6.0,6.0zm-16.0,0.0c3.31,0.0 5.98,-2.69 5.98,-6.0s-2.67,-6.0 -5.98,-6.0c-3.31,0.0 -6.0,2.69 -6.0,6.0s2.69,6.0 6.0,6.0zm0.0,4.0c-4.67,0.0 -14.0,2.34 -14.0,7.0l0.0,5.0l28.0,0.0l0.0,-5.0c0.0,-4.66 -9.33,-7.0 -14.0,-7.0zm16.0,0.0c-0.58,0.0 -1.2,0.04 -1.9,0.11C32.39,27.78 34.0,30.03 34.0,33.0l0.0,5.0l12.0,0.0l0.0,-5.0c0.0,-4.66 -9.33,-7.0 -14.0,-7.0z"/>
-</vector>
diff --git a/core/res/res/drawable/perm_group_storage.xml b/core/res/res/drawable/perm_group_storage.xml
index 74f16d8..477270d 100644
--- a/core/res/res/drawable/perm_group_storage.xml
+++ b/core/res/res/drawable/perm_group_storage.xml
@@ -1,7 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
<!--
-Copyright (C) 2015 The Android Open Source Project
+ Copyright (C) 2015 The Android Open Source Project
- Licensed under the Apache License, Version 2.0 (the "License");
+ 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
@@ -14,11 +15,15 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="48.0"
- android:viewportHeight="48.0">
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
<path
- android:pathData="M20,8H8c-2.2,0 -4,1.8 -4,4l0,24c0,2.2 1.8,4 4,4h32c2.2,0 4,-1.8 4,-4V16c0,-2.2 -1.8,-4 -4,-4H24L20,8z"
- android:fillColor="#FFFFFF"/>
-</vector>
+ android:fillColor="#000000"
+ android:pathData="M10 4H4c-1.1 0-1.99 .9 -1.99 2L2 18c0 1.1 .9 2 2 2h16c1.1 0 2-.9
+2-2V8c0-1.1-.9-2-2-2h-8l-2-2z" />
+ <path
+ android:pathData="M0 0h24v24H0z" />
+</vector>
\ No newline at end of file
diff --git a/core/res/res/values-es/strings.xml b/core/res/res/values-es/strings.xml
index be2b962..0533317 100644
--- a/core/res/res/values-es/strings.xml
+++ b/core/res/res/values-es/strings.xml
@@ -1001,7 +1001,7 @@
<string name="sms_short_code_remember_undo_instruction" msgid="4960944133052287484">"Puedes cambiar esta opción más tarde en Ajustes > Aplicaciones."</string>
<string name="sms_short_code_confirm_always_allow" msgid="3241181154869493368">"Permitir siempre"</string>
<string name="sms_short_code_confirm_never_allow" msgid="446992765774269673">"No permitir nunca"</string>
- <string name="sim_removed_title" msgid="6227712319223226185">"Tarjeta SIM eliminada"</string>
+ <string name="sim_removed_title" msgid="6227712319223226185">"Tarjeta SIM retirada"</string>
<string name="sim_removed_message" msgid="5450336489923274918">"La red móvil no estará disponible hasta que reinicies el dispositivo con una tarjeta SIM válida insertada."</string>
<string name="sim_done_button" msgid="827949989369963775">"Listo"</string>
<string name="sim_added_title" msgid="3719670512889674693">"Tarjeta SIM añadida"</string>
diff --git a/core/res/res/values-mcc310-mnc260-pt-rBR/strings.xml b/core/res/res/values-mcc310-mnc260-pt-rBR/strings.xml
new file mode 100644
index 0000000..bad49c3
--- /dev/null
+++ b/core/res/res/values-mcc310-mnc260-pt-rBR/strings.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/*
+** Copyright 2015, 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 my obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** 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.
+*/
+ -->
+
+<!-- These resources are around just to allow their values to be customized
+ for different hardware and product builds. -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string-array name="wfcOperatorErrorAlertMessages">
+ <item msgid="7239039348648848288">"Para fazer chamadas e enviar mensagens por Wi-Fi, primeiro peça à sua operadora para configurar esse serviço. Depois ative novamente as chamadas por Wi-Fi nas configurações."</item>
+ </string-array>
+ <string-array name="wfcOperatorErrorNotificationMessages">
+ <item msgid="483847327467331298">"Faça registro na sua operadora"</item>
+ </string-array>
+ <string name="wfcSpnFormat" msgid="4982938551498609442">"%s chamada Wi-Fi"</string>
+</resources>
diff --git a/core/res/res/values-mcc425/config.xml b/core/res/res/values-mcc425/config.xml
new file mode 100644
index 0000000..95d30a4
--- /dev/null
+++ b/core/res/res/values-mcc425/config.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 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.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** 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.
+*/
+-->
+<resources>
+ <bool name="config_use_sim_language_file">false</bool>
+</resources>
diff --git a/core/res/res/values-mcc432/config.xml b/core/res/res/values-mcc432/config.xml
new file mode 100644
index 0000000..95d30a4
--- /dev/null
+++ b/core/res/res/values-mcc432/config.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 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.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** 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.
+*/
+-->
+<resources>
+ <bool name="config_use_sim_language_file">false</bool>
+</resources>
diff --git a/core/res/res/values-mn-rMN/strings.xml b/core/res/res/values-mn-rMN/strings.xml
index be72354..df9f2805 100644
--- a/core/res/res/values-mn-rMN/strings.xml
+++ b/core/res/res/values-mn-rMN/strings.xml
@@ -1042,7 +1042,7 @@
<string name="usb_accessory_notification_title" msgid="7848236974087653666">"USB төхөөрөмжид холбогдов"</string>
<string name="usb_notification_message" msgid="7347368030849048437">"Нэмэлт сонголтыг харахын тулд дарна."</string>
<string name="adb_active_notification_title" msgid="6729044778949189918">"USB дебаг холбогдсон"</string>
- <string name="adb_active_notification_message" msgid="1016654627626476142">"USB дебаг хийхийг идэвхгүй болгох бол хүрнэ үү."</string>
+ <string name="adb_active_notification_message" msgid="1016654627626476142">"USB дебагийг идэвхгүй болгох бол хүрнэ үү."</string>
<string name="select_input_method" msgid="8547250819326693584">"Гарыг өөрчлөх"</string>
<string name="configure_input_methods" msgid="4769971288371946846">"Гар сонгох"</string>
<string name="show_ime" msgid="9157568568695230830">"Оруулах аргыг харуулах"</string>
diff --git a/core/res/res/values-pt-rBR-watch/strings.xml b/core/res/res/values-pt-rBR-watch/strings.xml
new file mode 100644
index 0000000..120e4a5
--- /dev/null
+++ b/core/res/res/values-pt-rBR-watch/strings.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/* //device/apps/common/assets/res/any/strings.xml
+**
+** Copyright 2015, 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
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** 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.
+*/
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="android_upgrading_apk" msgid="1090732262010398759">"App <xliff:g id="NUMBER_0">%1$d</xliff:g> de <xliff:g id="NUMBER_1">%2$d</xliff:g>."</string>
+</resources>
diff --git a/core/res/res/values-sq-rAL/strings.xml b/core/res/res/values-sq-rAL/strings.xml
index 549c5ef7..2bde626 100644
--- a/core/res/res/values-sq-rAL/strings.xml
+++ b/core/res/res/values-sq-rAL/strings.xml
@@ -21,7 +21,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="byteShort" msgid="8340973892742019101">"B"</string>
- <string name="kilobyteShort" msgid="5973789783504771878">"kilobajt"</string>
+ <string name="kilobyteShort" msgid="5973789783504771878">"KB"</string>
<string name="megabyteShort" msgid="6355851576770428922">"MB"</string>
<string name="gigabyteShort" msgid="3259882455212193214">"GB"</string>
<string name="terabyteShort" msgid="231613018159186962">"terabajt"</string>
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 06b6389..54848e9 100755
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -408,6 +408,7 @@
<integer translatable="false" name="config_wifi_framework_wifi_score_good_link_speed_24">24</integer>
<integer translatable="false" name="config_wifi_framework_wifi_score_good_link_speed_5">36</integer>
<string translatable="false" name="config_wifi_random_mac_oui">DA-A1-19</string>
+ <string translatable="false" name="config_wifi_framework_sap_2G_channel_list">1,6,11</string>
<bool translatable="false" name="config_wifi_framework_cellular_handover_enable_user_triggered_adjustment">true</bool>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index f590ebe..8070986 100755
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -337,6 +337,7 @@
<java-symbol type="integer" name="config_wifi_active_rx_cur_ma" />
<java-symbol type="integer" name="config_wifi_tx_cur_ma" />
<java-symbol type="integer" name="config_wifi_operating_voltage_mv" />
+ <java-symbol type="string" name="config_wifi_framework_sap_2G_channel_list" />
<java-symbol type="bool" name="editable_voicemailnumber" />
@@ -2313,4 +2314,6 @@
<java-symbol type="bool" name="config_eap_sim_based_auth_supported" />
<java-symbol type="array" name="config_cell_retries_per_error_code" />
+ <java-symbol type="drawable" name="ic_more_items" />
+
</resources>
diff --git a/docs/html/design/wear/structure.jd b/docs/html/design/wear/structure.jd
index c1d9ef9..768aa7f 100644
--- a/docs/html/design/wear/structure.jd
+++ b/docs/html/design/wear/structure.jd
@@ -166,8 +166,11 @@
<li>A map that asks the user to drop a pin should exit when the pin is dropped.</li>
<li>A short game can exit when the game finishes.</li>
<li>A drawing app can finish after 5 seconds of inactivity.</li>
+
+ <p class="note">An app generally should not exit in {@link android.app.Activity#onPause onPause()}. This is because events such as <a href="{@docRoot}guide/topics/ui/notifiers/notifications.html#Heads-up">Heads-up Notifications</a> can trigger the {@link android.app.Activity#onPause() onPause()} callback.</p>
</ul>
+
<h3>Manually exiting</h3>
<p>Even with logical exit points like these, some cases may exist where the user may want to
diff --git a/docs/html/training/articles/keystore.jd b/docs/html/training/articles/keystore.jd
index 52cb13e..aa1ed0a 100644
--- a/docs/html/training/articles/keystore.jd
+++ b/docs/html/training/articles/keystore.jd
@@ -7,14 +7,15 @@
<ol>
<li><a href="#SecurityFeatures">Security Features</a></li>
<li><a href="#WhichShouldIUse">Choosing Between a Keychain or the Android Keystore Provider</a></li>
- <li><a href="#UsingAndroidKeyStore">Using Android Keystore Provider
- </a></li>
+ <li><a href="#UsingAndroidKeyStore">Using Android Keystore Provider</a>
<ol>
<li><a href="#GeneratingANewPrivateKey">Generating a New Private Key</a></li>
<li><a href="#WorkingWithKeyStoreEntries">Working with Keystore Entries</a></li>
<li><a href="#ListingEntries">Listing Entries</a></li>
<li><a href="#SigningAndVerifyingData">Signing and Verifying Data</a></li>
</ol>
+ </li>
+ <li><a href="#SupportedAlgorithms">Supported Algorithms</a></li>
</ol>
<h2>Blog articles</h2>
@@ -27,6 +28,14 @@
</div>
</div>
+<style type="text/css">
+ tr.deprecated {
+ background-color: #ccc;
+ color: #999;
+ font-style: italic;
+ }
+</style>
+
<p>The Android Keystore system lets you store cryptographic keys in a container
to make it more difficult to extract from the device. Once keys are in the
keystore, they can be used for cryptographic operations with the key material
@@ -213,4 +222,456 @@
{@link android.hardware.fingerprint.FingerprintManager#hasEnrolledFingerprints() FingerprintManager.hasEnrolledFingerprints}).
These keys become permanently invalidated once a new fingerprint is enrolled or all fingerprints
are unenrolled.</li>
-</ul>
\ No newline at end of file
+</ul>
+
+<h2 id="SupportedAlgorithms">Supported Algorithms</h2>
+
+<ul>
+ <li><a href="#SupportedCiphers">{@code Cipher}</a></li>
+ <li><a href="#SupportedKeyGenerators">{@code KeyGenerator}</a></li>
+ <li><a href="#SupportedKeyFactories">{@code KeyFactory}</a></li>
+ <li><a href="#SupportedKeyPairGenerators">{@code KeyPairGenerator}</a></li>
+ <li><a href="#SupportedMacs">{@code Mac}</a></li>
+ <li><a href="#SupportedSignatures">{@code Signature}</a></li>
+ <li><a href="#SupportedSecretKeyFactories">{@code SecretKeyFactory}</a></li>
+</ul>
+
+<h3 id="SupportedCiphers">Cipher</h3>
+<table>
+ <thead>
+ <tr>
+ <th>Algorithm</th>
+ <th>Supported (API Levels)</th>
+ <th>Notes</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>AES/CBC/NoPadding</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>AES/CBC/PKCS7Padding</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>AES/CTR/NoPadding</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>AES/ECB/NoPadding</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>AES/ECB/PKCS7Padding</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>AES/GCM/NoPadding</td>
+ <td>23+</td>
+ <td>Only 12-byte long IVs supported.</td>
+ </tr>
+ <tr>
+ <td>RSA/ECB/NoPadding</td>
+ <td>18+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>RSA/ECB/PKCS1Padding</td>
+ <td>18+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>RSA/ECB/OAEPWithSHA-1AndMGF1Padding</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>RSA/ECB/OAEPWithSHA-224AndMGF1Padding</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>RSA/ECB/OAEPWithSHA-256AndMGF1Padding</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>RSA/ECB/OAEPWithSHA-384AndMGF1Padding</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>RSA/ECB/OAEPWithSHA-512AndMGF1Padding</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>RSA/ECB/OAEPPadding</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="SupportedKeyGenerators">KeyGenerator</h3>
+<table>
+ <thead>
+ <tr>
+ <th>Algorithm</th>
+ <th>Supported (API Levels)</th>
+ <th>Notes</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>AES</td>
+ <td>23+</td>
+ <td>Supported sizes: 128, 192, 256</td>
+ </tr>
+ <tr>
+ <td>HmacSHA1</td>
+ <td>23+</td>
+ <td>
+ <ul>
+ <li>Supported sizes: 8--1024 (inclusive), must be multiple of 8</li>
+ <li>Default size: 160</li>
+ <ul>
+ </td>
+ </tr>
+ <tr>
+ <td>HmacSHA224</td>
+ <td>23+</td>
+ <td>
+ <ul>
+ <li>Supported sizes: 8--1024 (inclusive), must be multiple of 8</li>
+ <li>Default size: 224</li>
+ <ul>
+ </td>
+ </tr>
+ <tr>
+ <td>HmacSHA256</td>
+ <td>23+</td>
+ <td>
+ <ul>
+ <li>Supported sizes: 8--1024 (inclusive), must be multiple of 8</li>
+ <li>Default size: 256</li>
+ <ul>
+ </td>
+ </tr>
+ <tr>
+ <td>HmacSHA384</td>
+ <td>23+</td>
+ <td>
+ <ul>
+ <li>Supported sizes: 8--1024 (inclusive), must be multiple of 8</li>
+ <li>Default size: 384</li>
+ <ul>
+ </td>
+ </tr>
+ <tr>
+ <td>HmacSHA512</td>
+ <td>23+</td>
+ <td>
+ <ul>
+ <li>Supported sizes: 8--1024 (inclusive), must be multiple of 8</li>
+ <li>Default size: 512</li>
+ <ul>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="SupportedKeyFactories">KeyFactory</h3>
+<table>
+ <thead>
+ <tr>
+ <th>Algorithm</th>
+ <th>Supported (API Levels)</th>
+ <th>Notes</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>EC</td>
+ <td>23+</td>
+ <td>Supported key specs: {@link android.security.keystore.KeyInfo} (private key only),
+ {@link java.security.spec.ECPublicKeySpec} (public key only),
+ {@link java.security.spec.X509EncodedKeySpec} (public key only)
+ </td>
+ </tr>
+ <tr>
+ <td>RSA</td>
+ <td>23+</td>
+ <td>Supported key specs: {@link android.security.keystore.KeyInfo} (private key only),
+ {@link java.security.spec.RSAPublicKeySpec} (public key only),
+ {@link java.security.spec.X509EncodedKeySpec} (public key only)
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="SupportedKeyStoreKeys">KeyStore</h3>
+KeyStore supports the same key types as
+<a href="#SupportedKeyPairGenerators">{@code KeyPairGenerator}</a> and
+<a href="#SupportedKeyGenerators">{@code KeyGenerator}</a>.
+
+<h3 id="SupportedKeyPairGenerators">KeyPairGenerator</h3>
+<table>
+ <thead>
+ <tr>
+ <th>Algorithm</th>
+ <th>Supported (API Levels)</th>
+ <th>Notes</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr class="deprecated">
+ <td>DSA</td>
+ <td>19–22</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>EC</td>
+ <td>23+</td>
+ <td>
+ <ul>
+ <li>Supported sizes: 224, 256, 384, 521</li>
+ <li>Supported named curves: P-224 (secp256r1), P-256 (aka secp256r1 and prime256v1), P-384
+ (aka secp384r1), P-521 (aka secp521r1)</li>
+ </ul>
+
+ <p>Prior to API Level 23, EC keys can be generated using KeyPairGenerator of algorithm "RSA"
+ initialized {@link android.security.KeyPairGeneratorSpec} whose key type is set to "EC"
+ using {@link android.security.KeyPairGeneratorSpec.Builder#setKeyType(String)}. EC curve
+ name cannot be specified using this method -- a NIST P-curve is automatically chosen based
+ on the requested key size.
+ </td>
+ </tr>
+ <tr>
+ <td>RSA</td>
+ <td>18+</td>
+ <td>
+ <ul>
+ <li>Supported sizes: 512, 768, 1024, 2048, 3072, 4096</li>
+ <li>Supported public exponents: 3, 65537</li>
+ <li>Default public exponent: 65537</li>
+ </ul>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="SupportedMacs">Mac</h3>
+<table>
+ <thead>
+ <tr>
+ <th>Algorithm</th>
+ <th>Supported (API Levels)</th>
+ <th>Notes</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>HmacSHA1</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>HmacSHA224</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>HmacSHA256</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>HmacSHA384</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>HmacSHA512</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="SupportedSignatures">Signature</h3>
+<table>
+ <thead>
+ <tr>
+ <th>Algorithm</th>
+ <th>Supported (API Levels)</th>
+ <th>Notes</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>MD5withRSA</td>
+ <td>18+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>NONEwithECDSA</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>NONEwithRSA</td>
+ <td>18+</td>
+ <td></td>
+ </tr>
+ <tr class="deprecated">
+ <td>SHA1withDSA</td>
+ <td>19–22</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>SHA1withECDSA</td>
+ <td>19+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>SHA1withRSA</td>
+ <td>18+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>SHA1withRSA/PSS</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ <tr class="deprecated">
+ <td>SHA224withDSA</td>
+ <td>20–22</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>SHA224withECDSA</td>
+ <td>20+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>SHA224withRSA</td>
+ <td>20+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>SHA224withRSA/PSS</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ <tr class="deprecated">
+ <td>SHA256withDSA</td>
+ <td>19–22</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>SHA256withECDSA</td>
+ <td>19+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>SHA256withRSA</td>
+ <td>18+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>SHA256withRSA/PSS</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ <tr class="deprecated">
+ <td>SHA384withDSA</td>
+ <td>19–22</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>SHA384withECDSA</td>
+ <td>19+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>SHA384withRSA</td>
+ <td>18+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>SHA384withRSA/PSS</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ <tr class="deprecated">
+ <td>SHA512withDSA</td>
+ <td>19–22</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>SHA512withECDSA</td>
+ <td>19+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>SHA512withRSA</td>
+ <td>18+</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>SHA512withRSA/PSS</td>
+ <td>23+</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="SupportedSecretKeyFactories">SecretKeyFactory</h3>
+<table>
+ <thead>
+ <tr>
+ <th>Algorithm</th>
+ <th>Supported (API Levels)</th>
+ <th>Notes</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>AES</td>
+ <td>23+</td>
+ <td>Supported key specs: {@link android.security.keystore.KeyInfo}</td>
+ </tr>
+ <tr>
+ <td>HmacSHA1</td>
+ <td>23+</td>
+ <td>Supported key specs: {@link android.security.keystore.KeyInfo}</td>
+ </tr>
+ <tr>
+ <td>HmacSHA224</td>
+ <td>23+</td>
+ <td>Supported key specs: {@link android.security.keystore.KeyInfo}</td>
+ </tr>
+ <tr>
+ <td>HmacSHA256</td>
+ <td>23+</td>
+ <td>Supported key specs: {@link android.security.keystore.KeyInfo}</td>
+ </tr>
+ <tr>
+ <td>HmacSHA384</td>
+ <td>23+</td>
+ <td>Supported key specs: {@link android.security.keystore.KeyInfo}</td>
+ </tr>
+ <tr>
+ <td>HmacSHA512</td>
+ <td>23+</td>
+ <td>Supported key specs: {@link android.security.keystore.KeyInfo}</td>
+ </tr>
+ </tbody>
+</table>
\ No newline at end of file
diff --git a/keystore/java/android/security/keystore/AndroidKeyStoreAuthenticatedAESCipherSpi.java b/keystore/java/android/security/keystore/AndroidKeyStoreAuthenticatedAESCipherSpi.java
index 5459bea..441ee66 100644
--- a/keystore/java/android/security/keystore/AndroidKeyStoreAuthenticatedAESCipherSpi.java
+++ b/keystore/java/android/security/keystore/AndroidKeyStoreAuthenticatedAESCipherSpi.java
@@ -51,7 +51,7 @@
abstract class AndroidKeyStoreAuthenticatedAESCipherSpi extends AndroidKeyStoreCipherSpiBase {
abstract static class GCM extends AndroidKeyStoreAuthenticatedAESCipherSpi {
- private static final int MIN_SUPPORTED_TAG_LENGTH_BITS = 96;
+ static final int MIN_SUPPORTED_TAG_LENGTH_BITS = 96;
private static final int MAX_SUPPORTED_TAG_LENGTH_BITS = 128;
private static final int DEFAULT_TAG_LENGTH_BITS = 128;
private static final int IV_LENGTH_BYTES = 12;
diff --git a/keystore/java/android/security/keystore/AndroidKeyStoreKeyGeneratorSpi.java b/keystore/java/android/security/keystore/AndroidKeyStoreKeyGeneratorSpi.java
index fd014eb..4c174f1 100644
--- a/keystore/java/android/security/keystore/AndroidKeyStoreKeyGeneratorSpi.java
+++ b/keystore/java/android/security/keystore/AndroidKeyStoreKeyGeneratorSpi.java
@@ -171,7 +171,7 @@
"Key size must be positive: " + mKeySizeBits);
} else if ((mKeySizeBits % 8) != 0) {
throw new InvalidAlgorithmParameterException(
- "Key size in must be a multiple of 8: " + mKeySizeBits);
+ "Key size must be a multiple of 8: " + mKeySizeBits);
}
try {
@@ -272,6 +272,11 @@
KeymasterUtils.addUserAuthArgs(args,
spec.isUserAuthenticationRequired(),
spec.getUserAuthenticationValidityDurationSeconds());
+ KeymasterUtils.addMinMacLengthAuthorizationIfNecessary(
+ args,
+ mKeymasterAlgorithm,
+ mKeymasterBlockModes,
+ mKeymasterDigests);
args.addDateIfNotNull(KeymasterDefs.KM_TAG_ACTIVE_DATETIME, spec.getKeyValidityStart());
args.addDateIfNotNull(KeymasterDefs.KM_TAG_ORIGINATION_EXPIRE_DATETIME,
spec.getKeyValidityForOriginationEnd());
diff --git a/keystore/java/android/security/keystore/AndroidKeyStoreSpi.java b/keystore/java/android/security/keystore/AndroidKeyStoreSpi.java
index 88858de..915d86f 100644
--- a/keystore/java/android/security/keystore/AndroidKeyStoreSpi.java
+++ b/keystore/java/android/security/keystore/AndroidKeyStoreSpi.java
@@ -672,6 +672,11 @@
KeymasterUtils.addUserAuthArgs(args,
params.isUserAuthenticationRequired(),
params.getUserAuthenticationValidityDurationSeconds());
+ KeymasterUtils.addMinMacLengthAuthorizationIfNecessary(
+ args,
+ keymasterAlgorithm,
+ keymasterBlockModes,
+ keymasterDigests);
args.addDateIfNotNull(KeymasterDefs.KM_TAG_ACTIVE_DATETIME,
params.getKeyValidityStart());
args.addDateIfNotNull(KeymasterDefs.KM_TAG_ORIGINATION_EXPIRE_DATETIME,
diff --git a/keystore/java/android/security/keystore/KeyStoreCryptoOperationChunkedStreamer.java b/keystore/java/android/security/keystore/KeyStoreCryptoOperationChunkedStreamer.java
index ea0f4b9..dbb79bc 100644
--- a/keystore/java/android/security/keystore/KeyStoreCryptoOperationChunkedStreamer.java
+++ b/keystore/java/android/security/keystore/KeyStoreCryptoOperationChunkedStreamer.java
@@ -19,12 +19,14 @@
import android.os.IBinder;
import android.security.KeyStore;
import android.security.KeyStoreException;
+import android.security.keymaster.KeymasterDefs;
import android.security.keymaster.OperationResult;
import libcore.util.EmptyArray;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.security.ProviderException;
/**
* Helper for streaming a crypto operation's input and output via {@link KeyStore} service's
@@ -135,14 +137,15 @@
mBuffered = EmptyArray.BYTE;
mBufferedOffset = 0;
mBufferedLength = 0;
- } else if (opResult.inputConsumed == 0) {
+ } else if (opResult.inputConsumed <= 0) {
// Nothing was consumed. More input needed.
if (inputLength > 0) {
// More input is available, but it wasn't included into the previous chunk
// because the chunk reached its maximum permitted size.
// Shouldn't have happened.
- throw new IllegalStateException("Nothing consumed from max-sized chunk: "
- + chunk.length + " bytes");
+ throw new KeyStoreException(KeymasterDefs.KM_ERROR_UNKNOWN_ERROR,
+ "Keystore consumed nothing from max-sized chunk: " + chunk.length
+ + " bytes");
}
mBuffered = chunk;
mBufferedOffset = 0;
@@ -153,8 +156,9 @@
mBufferedOffset = opResult.inputConsumed;
mBufferedLength = chunk.length - opResult.inputConsumed;
} else {
- throw new IllegalStateException("Consumed more than provided: "
- + opResult.inputConsumed + ", provided: " + chunk.length);
+ throw new KeyStoreException(KeymasterDefs.KM_ERROR_UNKNOWN_ERROR,
+ "Keystore consumed more input than provided. Provided: " + chunk.length
+ + ", consumed: " + opResult.inputConsumed);
}
if ((opResult.output != null) && (opResult.output.length > 0)) {
@@ -165,7 +169,7 @@
try {
bufferedOutput.write(opResult.output);
} catch (IOException e) {
- throw new IllegalStateException("Failed to buffer output", e);
+ throw new ProviderException("Failed to buffer output", e);
}
}
} else {
@@ -179,7 +183,7 @@
try {
bufferedOutput.write(opResult.output);
} catch (IOException e) {
- throw new IllegalStateException("Failed to buffer output", e);
+ throw new ProviderException("Failed to buffer output", e);
}
result = bufferedOutput.toByteArray();
}
@@ -229,27 +233,71 @@
return EmptyArray.BYTE;
}
- byte[] chunk = ArrayUtils.subarray(mBuffered, mBufferedOffset, mBufferedLength);
- mBuffered = EmptyArray.BYTE;
- mBufferedLength = 0;
- mBufferedOffset = 0;
+ // Keep invoking the update operation with remaining buffered data until either all of the
+ // buffered data is consumed or until update fails to consume anything.
+ ByteArrayOutputStream bufferedOutput = null;
+ while (mBufferedLength > 0) {
+ byte[] chunk = ArrayUtils.subarray(mBuffered, mBufferedOffset, mBufferedLength);
+ OperationResult opResult = mKeyStoreStream.update(chunk);
+ if (opResult == null) {
+ throw new KeyStoreConnectException();
+ } else if (opResult.resultCode != KeyStore.NO_ERROR) {
+ throw KeyStore.getKeyStoreException(opResult.resultCode);
+ }
- OperationResult opResult = mKeyStoreStream.update(chunk);
- if (opResult == null) {
- throw new KeyStoreConnectException();
- } else if (opResult.resultCode != KeyStore.NO_ERROR) {
- throw KeyStore.getKeyStoreException(opResult.resultCode);
+ if (opResult.inputConsumed <= 0) {
+ // Nothing was consumed. Break out of the loop to avoid an infinite loop.
+ break;
+ }
+
+ if (opResult.inputConsumed >= chunk.length) {
+ // All of the input was consumed
+ mBuffered = EmptyArray.BYTE;
+ mBufferedOffset = 0;
+ mBufferedLength = 0;
+ } else {
+ // Some of the input was not consumed
+ mBuffered = chunk;
+ mBufferedOffset = opResult.inputConsumed;
+ mBufferedLength = chunk.length - opResult.inputConsumed;
+ }
+
+ if (opResult.inputConsumed > chunk.length) {
+ throw new KeyStoreException(KeymasterDefs.KM_ERROR_UNKNOWN_ERROR,
+ "Keystore consumed more input than provided. Provided: "
+ + chunk.length + ", consumed: " + opResult.inputConsumed);
+ }
+
+ if ((opResult.output != null) && (opResult.output.length > 0)) {
+ // Some output was produced by this update operation
+ if (bufferedOutput == null) {
+ // No output buffered yet.
+ if (mBufferedLength == 0) {
+ // No more output will be produced by this flush operation
+ mProducedOutputSizeBytes += opResult.output.length;
+ return opResult.output;
+ } else {
+ // More output might be produced by this flush operation -- buffer output.
+ bufferedOutput = new ByteArrayOutputStream();
+ }
+ }
+ // Buffer the output from this update operation
+ try {
+ bufferedOutput.write(opResult.output);
+ } catch (IOException e) {
+ throw new ProviderException("Failed to buffer output", e);
+ }
+ }
}
- if (opResult.inputConsumed < chunk.length) {
- throw new IllegalStateException("Keystore failed to consume all input. Provided: "
- + chunk.length + ", consumed: " + opResult.inputConsumed);
- } else if (opResult.inputConsumed > chunk.length) {
- throw new IllegalStateException("Keystore consumed more input than provided"
- + " . Provided: " + chunk.length + ", consumed: " + opResult.inputConsumed);
+ if (mBufferedLength > 0) {
+ throw new KeyStoreException(KeymasterDefs.KM_ERROR_INVALID_INPUT_LENGTH,
+ "Keystore failed to consume last "
+ + ((mBufferedLength != 1) ? (mBufferedLength + " bytes") : "byte")
+ + " of input");
}
- byte[] result = (opResult.output != null) ? opResult.output : EmptyArray.BYTE;
+ byte[] result = (bufferedOutput != null) ? bufferedOutput.toByteArray() : EmptyArray.BYTE;
mProducedOutputSizeBytes += result.length;
return result;
}
diff --git a/keystore/java/android/security/keystore/KeymasterUtils.java b/keystore/java/android/security/keystore/KeymasterUtils.java
index 92d636c..feafbfa 100644
--- a/keystore/java/android/security/keystore/KeymasterUtils.java
+++ b/keystore/java/android/security/keystore/KeymasterUtils.java
@@ -22,6 +22,8 @@
import android.security.keymaster.KeymasterArguments;
import android.security.keymaster.KeymasterDefs;
+import java.security.ProviderException;
+
/**
* @hide
*/
@@ -133,4 +135,45 @@
userAuthenticationValidityDurationSeconds);
}
}
+
+ /**
+ * Adds {@code KM_TAG_MIN_MAC_LENGTH} tag, if necessary, to the keymaster arguments for
+ * generating or importing a key. This tag may only be needed for symmetric keys (e.g., HMAC,
+ * AES-GCM).
+ */
+ public static void addMinMacLengthAuthorizationIfNecessary(KeymasterArguments args,
+ int keymasterAlgorithm,
+ int[] keymasterBlockModes,
+ int[] keymasterDigests) {
+ switch (keymasterAlgorithm) {
+ case KeymasterDefs.KM_ALGORITHM_AES:
+ if (com.android.internal.util.ArrayUtils.contains(
+ keymasterBlockModes, KeymasterDefs.KM_MODE_GCM)) {
+ // AES GCM key needs the minimum length of AEAD tag specified.
+ args.addUnsignedInt(KeymasterDefs.KM_TAG_MIN_MAC_LENGTH,
+ AndroidKeyStoreAuthenticatedAESCipherSpi.GCM
+ .MIN_SUPPORTED_TAG_LENGTH_BITS);
+ }
+ break;
+ case KeymasterDefs.KM_ALGORITHM_HMAC:
+ // HMAC key needs the minimum length of MAC set to the output size of the associated
+ // digest. This is because we do not offer a way to generate shorter MACs and
+ // don't offer a way to verify MACs (other than by generating them).
+ if (keymasterDigests.length != 1) {
+ throw new ProviderException(
+ "Unsupported number of authorized digests for HMAC key: "
+ + keymasterDigests.length
+ + ". Exactly one digest must be authorized");
+ }
+ int keymasterDigest = keymasterDigests[0];
+ int digestOutputSizeBits = getDigestOutputSizeBits(keymasterDigest);
+ if (digestOutputSizeBits == -1) {
+ throw new ProviderException(
+ "HMAC key authorized for unsupported digest: "
+ + KeyProperties.Digest.fromKeymaster(keymasterDigest));
+ }
+ args.addUnsignedInt(KeymasterDefs.KM_TAG_MIN_MAC_LENGTH, digestOutputSizeBits);
+ break;
+ }
+ }
}
diff --git a/libs/hwui/AnimatorManager.cpp b/libs/hwui/AnimatorManager.cpp
index 966959a..0dababd 100644
--- a/libs/hwui/AnimatorManager.cpp
+++ b/libs/hwui/AnimatorManager.cpp
@@ -117,7 +117,6 @@
uint32_t dirty = animateCommon(info);
- mParent.mProperties.updateMatrix();
info.damageAccumulator->pushTransform(&mParent);
mParent.damageSelf(info);
@@ -136,6 +135,7 @@
newEnd = std::remove_if(mAnimators.begin(), mAnimators.end(), functor);
mAnimators.erase(newEnd, mAnimators.end());
mAnimationHandle->notifyAnimationsRan();
+ mParent.mProperties.updateMatrix();
return functor.dirtyMask;
}
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp
index 1030451..aa73d44 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -248,11 +248,6 @@
void Caches::flush(FlushMode mode) {
FLUSH_LOGD("Flushing caches (mode %d)", mode);
- // We must stop tasks before clearing caches
- if (mode > kFlushMode_Layers) {
- tasks.stop();
- }
-
switch (mode) {
case kFlushMode_Full:
textureCache.clear();
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp
index 80f349a..0951fc1 100644
--- a/libs/hwui/RenderNode.cpp
+++ b/libs/hwui/RenderNode.cpp
@@ -214,10 +214,10 @@
info.renderer->pushLayerUpdate(mLayer);
}
- if (CC_UNLIKELY(info.canvasContext)) {
- // If canvasContext is not null that means there are prefetched layers
- // that need to be accounted for. That might be us, so tell CanvasContext
- // that this layer is in the tree and should not be destroyed.
+ if (info.canvasContext) {
+ // There might be prefetched layers that need to be accounted for.
+ // That might be us, so tell CanvasContext that this layer is in the
+ // tree and should not be destroyed.
info.canvasContext->markLayerInUse(this);
}
}
@@ -339,7 +339,8 @@
TextureCache& cache = Caches::getInstance().textureCache;
info.out.hasFunctors |= subtree->functors.size();
for (size_t i = 0; info.prepareTextures && i < subtree->bitmapResources.size(); i++) {
- info.prepareTextures = cache.prefetchAndMarkInUse(subtree->bitmapResources[i]);
+ info.prepareTextures = cache.prefetchAndMarkInUse(
+ info.canvasContext, subtree->bitmapResources[i]);
}
for (size_t i = 0; i < subtree->children().size(); i++) {
DrawRenderNodeOp* op = subtree->children()[i];
diff --git a/libs/hwui/Texture.h b/libs/hwui/Texture.h
index 7227ce0..4bcd96d 100644
--- a/libs/hwui/Texture.h
+++ b/libs/hwui/Texture.h
@@ -97,7 +97,7 @@
* Whether or not the Texture is marked in use and thus not evictable for
* the current frame. This is reset at the start of a new frame.
*/
- bool isInUse = false;
+ void* isInUse = nullptr;
private:
/**
diff --git a/libs/hwui/TextureCache.cpp b/libs/hwui/TextureCache.cpp
index 2a90087..fda0091 100644
--- a/libs/hwui/TextureCache.cpp
+++ b/libs/hwui/TextureCache.cpp
@@ -122,10 +122,12 @@
mAssetAtlas = assetAtlas;
}
-void TextureCache::resetMarkInUse() {
+void TextureCache::resetMarkInUse(void* ownerToken) {
LruCache<uint32_t, Texture*>::Iterator iter(mCache);
while (iter.next()) {
- iter.value()->isInUse = false;
+ if (iter.value()->isInUse == ownerToken) {
+ iter.value()->isInUse = nullptr;
+ }
}
}
@@ -189,10 +191,10 @@
return texture;
}
-bool TextureCache::prefetchAndMarkInUse(const SkBitmap* bitmap) {
+bool TextureCache::prefetchAndMarkInUse(void* ownerToken, const SkBitmap* bitmap) {
Texture* texture = getCachedTexture(bitmap, AtlasUsageType::Use);
if (texture) {
- texture->isInUse = true;
+ texture->isInUse = ownerToken;
}
return texture;
}
diff --git a/libs/hwui/TextureCache.h b/libs/hwui/TextureCache.h
index 83c6e91..7a7ee5a 100644
--- a/libs/hwui/TextureCache.h
+++ b/libs/hwui/TextureCache.h
@@ -66,14 +66,14 @@
/**
* Resets all Textures to not be marked as in use
*/
- void resetMarkInUse();
+ void resetMarkInUse(void* ownerToken);
/**
* Attempts to precache the SkBitmap. Returns true if a Texture was successfully
* acquired for the bitmap, false otherwise. If a Texture was acquired it is
* marked as in use.
*/
- bool prefetchAndMarkInUse(const SkBitmap* bitmap);
+ bool prefetchAndMarkInUse(void* ownerToken, const SkBitmap* bitmap);
/**
* Returns the texture associated with the specified bitmap from either within the cache, or
diff --git a/libs/hwui/TreeInfo.h b/libs/hwui/TreeInfo.h
index 0799c6c..ed853f7 100644
--- a/libs/hwui/TreeInfo.h
+++ b/libs/hwui/TreeInfo.h
@@ -95,7 +95,7 @@
// layer updates or similar. May be NULL.
OpenGLRenderer* renderer;
ErrorHandler* errorHandler;
- // TODO: Remove this? May be NULL
+ // May be NULL (TODO: can it really?)
renderthread::CanvasContext* canvasContext;
struct Out {
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index 09f93b8..e472e93 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -178,16 +178,13 @@
info.damageAccumulator = &mDamageAccumulator;
info.renderer = mCanvas;
- if (mPrefetechedLayers.size() && info.mode == TreeInfo::MODE_FULL) {
- info.canvasContext = this;
- }
+ info.canvasContext = this;
+
mAnimationContext->startFrame(info.mode);
mRootRenderNode->prepareTree(info);
mAnimationContext->runRemainingAnimations(info);
- if (info.canvasContext) {
- freePrefetechedLayers();
- }
+ freePrefetechedLayers();
if (CC_UNLIKELY(!mNativeWindow.get())) {
mCurrentFrameInfo->addFlag(FrameInfoFlags::SkippedFrame);
@@ -369,7 +366,11 @@
if (mEglManager.hasEglContext()) {
freePrefetechedLayers();
mRootRenderNode->destroyHardwareResources();
- Caches::getInstance().flush(Caches::kFlushMode_Layers);
+ Caches& caches = Caches::getInstance();
+ // Make sure to release all the textures we were owning as there won't
+ // be another draw
+ caches.textureCache.resetMarkInUse(this);
+ caches.flush(Caches::kFlushMode_Layers);
}
}
diff --git a/libs/hwui/renderthread/DrawFrameTask.cpp b/libs/hwui/renderthread/DrawFrameTask.cpp
index 6507ce8..a4ac13b 100644
--- a/libs/hwui/renderthread/DrawFrameTask.cpp
+++ b/libs/hwui/renderthread/DrawFrameTask.cpp
@@ -114,7 +114,7 @@
int64_t vsync = mFrameInfo[static_cast<int>(FrameInfoIndex::Vsync)];
mRenderThread->timeLord().vsyncReceived(vsync);
mContext->makeCurrent();
- Caches::getInstance().textureCache.resetMarkInUse();
+ Caches::getInstance().textureCache.resetMarkInUse(mContext);
for (size_t i = 0; i < mLayers.size(); i++) {
mContext->processLayerUpdate(mLayers[i].get());
diff --git a/media/java/android/media/IRingtonePlayer.aidl b/media/java/android/media/IRingtonePlayer.aidl
index aa5fde3..8091421 100644
--- a/media/java/android/media/IRingtonePlayer.aidl
+++ b/media/java/android/media/IRingtonePlayer.aidl
@@ -33,4 +33,7 @@
/** Used for Notification sound playback. */
void playAsync(in Uri uri, in UserHandle user, boolean looping, in AudioAttributes aa);
void stopAsync();
+
+ /** Return the title of the media. */
+ String getTitle(in Uri uri);
}
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java
index a4d3485..13b2878 100644
--- a/media/java/android/media/MediaPlayer.java
+++ b/media/java/android/media/MediaPlayer.java
@@ -2292,7 +2292,7 @@
private void scanInternalSubtitleTracks() {
if (mSubtitleController == null) {
- Log.w(TAG, "setSubtitleAnchor in MediaPlayer");
+ Log.d(TAG, "setSubtitleAnchor in MediaPlayer");
setSubtitleAnchor();
}
diff --git a/media/java/android/media/Ringtone.java b/media/java/android/media/Ringtone.java
index faeebe6..9e9d602 100644
--- a/media/java/android/media/Ringtone.java
+++ b/media/java/android/media/Ringtone.java
@@ -27,6 +27,7 @@
import android.os.RemoteException;
import android.provider.MediaStore;
import android.provider.Settings;
+import android.provider.MediaStore.MediaColumns;
import android.util.Log;
import java.io.IOException;
@@ -50,6 +51,8 @@
MediaStore.Audio.Media.DATA,
MediaStore.Audio.Media.TITLE
};
+ /** Selection that limits query results to just audio files */
+ private static final String MEDIA_SELECTION = MediaColumns.MIME_TYPE + " LIKE 'audio/%'";
// keep references on active Ringtones until stopped or completion listener called.
private static final ArrayList<Ringtone> sActiveRingtones = new ArrayList<Ringtone>();
@@ -193,11 +196,14 @@
*/
public String getTitle(Context context) {
if (mTitle != null) return mTitle;
- return mTitle = getTitle(context, mUri, true);
+ return mTitle = getTitle(context, mUri, true /*followSettingsUri*/, mAllowRemote);
}
- private static String getTitle(Context context, Uri uri, boolean followSettingsUri) {
- Cursor cursor = null;
+ /**
+ * @hide
+ */
+ public static String getTitle(
+ Context context, Uri uri, boolean followSettingsUri, boolean allowRemote) {
ContentResolver res = context.getContentResolver();
String title = null;
@@ -209,31 +215,45 @@
if (followSettingsUri) {
Uri actualUri = RingtoneManager.getActualDefaultRingtoneUri(context,
RingtoneManager.getDefaultType(uri));
- String actualTitle = getTitle(context, actualUri, false);
+ String actualTitle = getTitle(
+ context, actualUri, false /*followSettingsUri*/, allowRemote);
title = context
.getString(com.android.internal.R.string.ringtone_default_with_actual,
actualTitle);
}
} else {
+ Cursor cursor = null;
try {
if (MediaStore.AUTHORITY.equals(authority)) {
- cursor = res.query(uri, MEDIA_COLUMNS, null, null, null);
+ final String mediaSelection = allowRemote ? null : MEDIA_SELECTION;
+ cursor = res.query(uri, MEDIA_COLUMNS, mediaSelection, null, null);
+ if (cursor != null && cursor.getCount() == 1) {
+ cursor.moveToFirst();
+ return cursor.getString(2);
+ }
+ // missing cursor is handled below
}
} catch (SecurityException e) {
- // missing cursor is handled below
- }
-
- try {
- if (cursor != null && cursor.getCount() == 1) {
- cursor.moveToFirst();
- return cursor.getString(2);
- } else {
- title = uri.getLastPathSegment();
+ IRingtonePlayer mRemotePlayer = null;
+ if (allowRemote) {
+ AudioManager audioManager =
+ (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
+ mRemotePlayer = audioManager.getRingtonePlayer();
+ }
+ if (mRemotePlayer != null) {
+ try {
+ title = mRemotePlayer.getTitle(uri);
+ } catch (RemoteException re) {
+ }
}
} finally {
if (cursor != null) {
cursor.close();
}
+ cursor = null;
+ }
+ if (title == null) {
+ title = uri.getLastPathSegment();
}
}
}
diff --git a/media/java/android/media/RingtoneManager.java b/media/java/android/media/RingtoneManager.java
index a1b8a3b..025029e 100644
--- a/media/java/android/media/RingtoneManager.java
+++ b/media/java/android/media/RingtoneManager.java
@@ -23,9 +23,11 @@
import android.app.Activity;
import android.content.ContentUris;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.Environment;
+import android.os.Process;
import android.provider.MediaStore;
import android.provider.Settings;
import android.provider.Settings.System;
@@ -359,7 +361,10 @@
* If {@link RingtoneManager#RingtoneManager(Activity)} was not used, the
* caller should manage the returned cursor through its activity's life
* cycle to prevent leaking the cursor.
- *
+ * <p>
+ * Note that the list of ringtones available will differ depending on whether the caller
+ * has the {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission.
+ *
* @return A {@link Cursor} of all the ringtones available.
* @see #ID_COLUMN_INDEX
* @see #TITLE_COLUMN_INDEX
@@ -455,8 +460,10 @@
/**
* Returns a valid ringtone URI. No guarantees on which it returns. If it
- * cannot find one, returns null.
- *
+ * cannot find one, returns null. If it can only find one on external storage and the caller
+ * doesn't have the {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission,
+ * returns null.
+ *
* @param context The context to use for querying.
* @return A ringtone URI, or null if one cannot be found.
*/
@@ -495,6 +502,12 @@
}
private Cursor getMediaRingtones() {
+ if (PackageManager.PERMISSION_GRANTED != mContext.checkPermission(
+ android.Manifest.permission.READ_EXTERNAL_STORAGE,
+ Process.myPid(), Process.myUid())) {
+ Log.w(TAG, "No READ_EXTERNAL_STORAGE permission, ignoring ringtones on ext storage");
+ return null;
+ }
// Get the external media cursor. First check to see if it is mounted.
final String status = Environment.getExternalStorageState();
diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java
index 86e8560..053d43b6 100644
--- a/media/java/android/media/tv/TvInputService.java
+++ b/media/java/android/media/tv/TvInputService.java
@@ -20,6 +20,7 @@
import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
+import android.app.ActivityManager;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
@@ -1200,12 +1201,15 @@
// We make the overlay view non-focusable and non-touchable so that
// the application that owns the window token can decide whether to consume or
// dispatch the input events.
- int flag = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
- | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
- | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
+ int flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
+ | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
+ | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
+ if (ActivityManager.isHighEndGfx()) {
+ flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
+ }
mWindowParams = new WindowManager.LayoutParams(
frame.right - frame.left, frame.bottom - frame.top,
- frame.left, frame.top, type, flag, PixelFormat.TRANSPARENT);
+ frame.left, frame.top, type, flags, PixelFormat.TRANSPARENT);
mWindowParams.privateFlags |=
WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION;
mWindowParams.gravity = Gravity.START | Gravity.TOP;
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardConstants.java b/packages/Keyguard/src/com/android/keyguard/KeyguardConstants.java
index e5f3dc9..3927122 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardConstants.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardConstants.java
@@ -27,4 +27,5 @@
*/
public static final boolean DEBUG = false;
public static final boolean DEBUG_SIM_STATES = false;
+ public static final boolean DEBUG_FP_WAKELOCK = true;
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 9e5644e..b098258 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -44,7 +44,9 @@
import android.os.Handler;
import android.os.IRemoteCallback;
import android.os.Message;
+import android.os.PowerManager;
import android.os.RemoteException;
+import android.os.SystemClock;
import android.os.UserHandle;
import android.provider.Settings;
@@ -90,12 +92,15 @@
private static final String TAG = "KeyguardUpdateMonitor";
private static final boolean DEBUG = KeyguardConstants.DEBUG;
private static final boolean DEBUG_SIM_STATES = KeyguardConstants.DEBUG_SIM_STATES;
+ private static final boolean DEBUG_FP_WAKELOCK = KeyguardConstants.DEBUG_FP_WAKELOCK;
private static final int LOW_BATTERY_THRESHOLD = 20;
+ private static final long FINGERPRINT_WAKELOCK_TIMEOUT_MS = 15 * 1000;
private static final String ACTION_FACE_UNLOCK_STARTED
= "com.android.facelock.FACE_UNLOCK_STARTED";
private static final String ACTION_FACE_UNLOCK_STOPPED
= "com.android.facelock.FACE_UNLOCK_STOPPED";
+ private static final String FINGERPRINT_WAKE_LOCK_NAME = "wake-and-unlock wakelock";
// Callback messages
private static final int MSG_TIME_UPDATE = 301;
@@ -114,10 +119,6 @@
private static final int MSG_SCREEN_TURNED_ON = 319;
private static final int MSG_SCREEN_TURNED_OFF = 320;
private static final int MSG_KEYGUARD_BOUNCER_CHANGED = 322;
- private static final int MSG_FINGERPRINT_AUTHENTICATED = 323;
- private static final int MSG_FINGERPRINT_ERROR = 324;
- private static final int MSG_FINGERPRINT_HELP = 325;
- private static final int MSG_FINGERPRINT_AUTH_FAILED = 326;
private static final int MSG_FACE_UNLOCK_STATE_CHANGED = 327;
private static final int MSG_SIM_SUBSCRIPTION_INFO_CHANGED = 328;
private static final int MSG_AIRPLANE_MODE_CHANGED = 329;
@@ -157,6 +158,7 @@
private List<SubscriptionInfo> mSubscriptionInfo;
private boolean mFingerprintDetectionRunning;
private TrustManager mTrustManager;
+ private PowerManager mPowerManager;
private final Handler mHandler = new Handler() {
@Override
@@ -210,18 +212,6 @@
case MSG_SCREEN_TURNED_ON:
handleScreenTurnedOn();
break;
- case MSG_FINGERPRINT_AUTHENTICATED:
- handleFingerprintAuthenticated();
- break;
- case MSG_FINGERPRINT_HELP:
- handleFingerprintHelp(msg.arg1 /* msgId */, (String) msg.obj /* errString */);
- break;
- case MSG_FINGERPRINT_ERROR:
- handleFingerprintError(msg.arg1 /* msgId */, (String) msg.obj /* errString */);
- break;
- case MSG_FINGERPRINT_AUTH_FAILED:
- handleFingerprintAuthFailed();
- break;
case MSG_FACE_UNLOCK_STATE_CHANGED:
handleFaceUnlockStateChanged(msg.arg1 != 0, msg.arg2);
break;
@@ -253,6 +243,8 @@
private static int sCurrentUser;
+ private boolean mWakeAndUnlocking;
+
public synchronized static void setCurrentUser(int currentUser) {
sCurrentUser = currentUser;
}
@@ -353,23 +345,72 @@
}
}
- private void onFingerprintAuthenticated(int userId) {
+ private void onFingerprintAuthenticated(int userId, boolean wakeAndUnlocking) {
mUserFingerprintAuthenticated.put(userId, true);
for (int i = 0; i < mCallbacks.size(); i++) {
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
if (cb != null) {
- cb.onFingerprintAuthenticated(userId);
+ cb.onFingerprintAuthenticated(userId, wakeAndUnlocking);
}
}
}
private void handleFingerprintAuthFailed() {
+ releaseFingerprintWakeLock();
stopListeningForFingerprint();
handleFingerprintHelp(-1, mContext.getString(R.string.fingerprint_not_recognized));
updateFingerprintListeningState();
}
+ private void handleFingerprintAcquired(int acquireInfo) {
+ if (acquireInfo != FingerprintManager.FINGERPRINT_ACQUIRED_GOOD) {
+ return;
+ }
+ if (!mScreenOn) {
+ releaseFingerprintWakeLock();
+ mWakeLock = mPowerManager.newWakeLock(
+ PowerManager.PARTIAL_WAKE_LOCK, FINGERPRINT_WAKE_LOCK_NAME);
+ mWakeLock.acquire();
+ mWakeAndUnlocking = true;
+ if (DEBUG_FP_WAKELOCK) {
+ Log.i(TAG, "fingerprint acquired, grabbing fp wakelock");
+ }
+ mHandler.postDelayed(mReleaseFingerprintWakeLockRunnable,
+ FINGERPRINT_WAKELOCK_TIMEOUT_MS);
+ } else {
+ mWakeAndUnlocking = false;
+ }
+ }
+
+ private final Runnable mReleaseFingerprintWakeLockRunnable = new Runnable() {
+ @Override
+ public void run() {
+ if (DEBUG_FP_WAKELOCK) {
+ Log.i(TAG, "fp wakelock: TIMEOUT!!");
+ }
+ releaseFingerprintWakeLock();
+ }
+ };
+
+ private void releaseFingerprintWakeLock() {
+ if (mWakeLock != null) {
+ mHandler.removeCallbacks(mReleaseFingerprintWakeLockRunnable);
+ if (DEBUG_FP_WAKELOCK) {
+ Log.i(TAG, "releasing fp wakelock");
+ }
+ mWakeLock.release();
+ mWakeLock = null;
+ }
+ }
+
private void handleFingerprintAuthenticated() {
+ if (mWakeAndUnlocking) {
+ if (DEBUG_FP_WAKELOCK) {
+ Log.i(TAG, "fp wakelock: Authenticated, waking up...");
+ }
+ mPowerManager.wakeUp(SystemClock.uptimeMillis());
+ }
+ releaseFingerprintWakeLock();
try {
final int userId;
try {
@@ -382,7 +423,7 @@
Log.d(TAG, "Fingerprint disabled by DPM for userId: " + userId);
return;
}
- onFingerprintAuthenticated(userId);
+ onFingerprintAuthenticated(userId, mWakeAndUnlocking);
} finally {
setFingerprintRunningDetectionRunning(false);
}
@@ -555,26 +596,32 @@
@Override
public void onAuthenticationFailed() {
- mHandler.obtainMessage(MSG_FINGERPRINT_AUTH_FAILED).sendToTarget();
+ handleFingerprintAuthFailed();
};
@Override
public void onAuthenticationSucceeded(AuthenticationResult result) {
- mHandler.obtainMessage(MSG_FINGERPRINT_AUTHENTICATED).sendToTarget();
+ handleFingerprintAuthenticated();
}
@Override
public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) {
- mHandler.obtainMessage(MSG_FINGERPRINT_HELP, helpMsgId, 0, helpString).sendToTarget();
+ handleFingerprintHelp(helpMsgId, helpString.toString());
}
@Override
public void onAuthenticationError(int errMsgId, CharSequence errString) {
- mHandler.obtainMessage(MSG_FINGERPRINT_ERROR, errMsgId, 0, errString).sendToTarget();
+ handleFingerprintError(errMsgId, errString.toString());
+ }
+
+ @Override
+ public void onAuthenticationAcquired(int acquireInfo) {
+ handleFingerprintAcquired(acquireInfo);
}
};
private CancellationSignal mFingerprintCancelSignal;
private FingerprintManager mFpm;
+ private PowerManager.WakeLock mWakeLock;
/**
* When we receive a
@@ -741,6 +788,7 @@
private KeyguardUpdateMonitor(Context context) {
mContext = context;
mSubscriptionManager = SubscriptionManager.from(context);
+ mPowerManager = context.getSystemService(PowerManager.class);
mDeviceProvisioned = isDeviceProvisionedInSettingsDb();
// Since device can't be un-provisioned, we only need to register a content observer
// to update mDeviceProvisioned when we are...
@@ -819,7 +867,7 @@
}
private boolean shouldListenForFingerprint() {
- return mScreenOn && mKeyguardIsVisible && !mSwitchingUser
+ return mKeyguardIsVisible && !mSwitchingUser
&& mTrustManager.hasUserAuthenticatedSinceBoot(ActivityManager.getCurrentUser());
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
index 26e6973..9fd8d30 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
@@ -178,8 +178,10 @@
/**
* Called when a fingerprint is recognized.
* @param userId the user id for which the fingerprint was authenticated
+ * @param wakeAndUnlocking whether the authentication woke the device up and thus we'd like to
+ * dismiss the lockscreen before turning on the screen
*/
- public void onFingerprintAuthenticated(int userId) { }
+ public void onFingerprintAuthenticated(int userId, boolean wakeAndUnlocking) { }
/**
* Called when fingerprint provides help string (e.g. "Try again")
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index b3be490..659a906 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -406,5 +406,13 @@
android:exported="true"
android:singleUser="true"
android:permission="android.permission.BIND_DREAM_SERVICE" />
+
+ <receiver
+ android:name=".tuner.TunerService$ClearReceiver"
+ android:exported="false">
+ <intent-filter>
+ <action android:name="com.android.systemui.action.CLEAR_TUNER" />
+ </intent-filter>
+ </receiver>
</application>
</manifest>
diff --git a/packages/SystemUI/res/drawable-nodpi/tuner.xml b/packages/SystemUI/res/drawable-nodpi/tuner.xml
index e27423f..0596aa4 100644
--- a/packages/SystemUI/res/drawable-nodpi/tuner.xml
+++ b/packages/SystemUI/res/drawable-nodpi/tuner.xml
@@ -1,7 +1,7 @@
<!--
- Copyright (C) 2015 The Android Open Source Project
+ Copyright (C) 2015 The Android Open Source Project
- Licensed under the Apache License, Version 2.0 (the "License");
+ 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
@@ -14,14 +14,11 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="48.0dp"
- android:height="48.0dp"
- android:viewportWidth="48.0"
- android:viewportHeight="48.0">
+ android:width="24.0dp"
+ android:height="24.0dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
<path
- android:fillColor="#FF000000"
- android:pathData="M29.9,24.8c0.0,-0.3 0.1,-0.5 0.1,-0.8s0.0,-0.5 -0.1,-0.8l1.7,-1.3c0.2,-0.1 0.2,-0.3 0.1,-0.5l-1.6,-2.8c-0.1,-0.2 -0.3,-0.2 -0.5,-0.2l-2.0,0.8c-0.4,-0.3 -0.9,-0.6 -1.4,-0.8L26.0,16.3c0.0,-0.2 -0.2,-0.3 -0.4,-0.3l-3.2,0.0c-0.2,0.0 -0.4,0.1 -0.4,0.3l-0.3,2.1c-0.5,0.2 -0.9,0.5 -1.4,0.8l-2.0,-0.8c-0.2,-0.1 -0.4,0.0 -0.5,0.2l-1.6,2.8c-0.1,0.2 -0.1,0.4 0.1,0.5l1.7,1.3c0.0,0.3 -0.1,0.5 -0.1,0.8s0.0,0.5 0.1,0.8l-1.7,1.3c-0.2,0.1 -0.2,0.3 -0.1,0.5l1.6,2.8c0.1,0.2 0.3,0.2 0.5,0.2l2.0,-0.8c0.4,0.3 0.9,0.6 1.4,0.8l0.3,2.1c0.0,0.2 0.2,0.3 0.4,0.3l3.2,0.0c0.2,0.0 0.4,-0.1 0.4,-0.3l0.3,-2.1c0.5,-0.2 0.9,-0.5 1.4,-0.8l2.0,0.8c0.2,0.1 0.4,0.0 0.5,-0.2l1.6,-2.8c0.1,-0.2 0.1,-0.4 -0.1,-0.5L29.9,24.8zM24.0,26.8c-1.5,0.0 -2.8,-1.3 -2.8,-2.8s1.3,-2.8 2.8,-2.8s2.8,1.3 2.8,2.8S25.5,26.8 24.0,26.8z"/>
- <path
- android:fillColor="#FF000000"
- android:pathData="M18.0,38.0c-0.6,0.0 -1.0,-0.4 -1.0,-1.0s0.4,-1.0 1.0,-1.0s1.0,0.4 1.0,1.0S18.6,38.0 18.0,38.0zM24.0,38.0c-0.6,0.0 -1.0,-0.4 -1.0,-1.0s0.4,-1.0 1.0,-1.0s1.0,0.4 1.0,1.0S24.6,38.0 24.0,38.0zM30.0,38.0c-0.6,0.0 -1.0,-0.4 -1.0,-1.0s0.4,-1.0 1.0,-1.0s1.0,0.4 1.0,1.0S30.6,38.0 30.0,38.0zM42.0,6.0L6.0,6.0c-2.2,0.0 -4.0,1.8 -4.0,4.0l0.0,28.0c0.0,2.2 1.8,4.0 4.0,4.0l36.0,0.0c2.2,0.0 4.0,-1.8 4.0,-4.0L46.0,10.0C46.0,7.8 44.2,6.0 42.0,6.0zM42.0,34.0L6.0,34.0L6.0,14.0l36.0,0.0L42.0,34.0zM9.0,12.0L7.0,12.0l0.0,-2.0l2.0,0.0L9.0,12.0zM13.0,12.0l-2.0,0.0l0.0,-2.0l2.0,0.0L13.0,12.0zM17.0,12.0l-2.0,0.0l0.0,-2.0l2.0,0.0L17.0,12.0z"/>
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M22.7,19.0l-9.1,-9.1c0.9,-2.0 0.4,-5.0 -1.5,-6.9 -2.0,-2.0 -5.0,-2.4 -7.4,-1.3L9.0,6.0 6.0,9.0 1.6,4.7C0.4,7.0 0.9,10.1 2.9,12.1c1.9,1.9 4.6,2.4 6.9,1.5l9.1,9.1c0.4,0.4 1.0,0.4 1.4,0.0l2.3,-2.3c0.5,-0.4 0.5,-1.0 0.1,-1.4z"/>
</vector>
diff --git a/packages/SystemUI/res/layout/keyguard_bottom_area.xml b/packages/SystemUI/res/layout/keyguard_bottom_area.xml
index 1488ad6..444f0f0 100644
--- a/packages/SystemUI/res/layout/keyguard_bottom_area.xml
+++ b/packages/SystemUI/res/layout/keyguard_bottom_area.xml
@@ -26,7 +26,7 @@
<com.android.systemui.statusbar.phone.KeyguardIndicationTextView
android:id="@+id/keyguard_indication_text"
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/keyguard_indication_margin_bottom"
android:layout_gravity="bottom|center_horizontal"
diff --git a/packages/SystemUI/res/layout/status_bar_expanded_header.xml b/packages/SystemUI/res/layout/status_bar_expanded_header.xml
index 7262ed2..8c8a3dd 100644
--- a/packages/SystemUI/res/layout/status_bar_expanded_header.xml
+++ b/packages/SystemUI/res/layout/status_bar_expanded_header.xml
@@ -44,14 +44,31 @@
android:scaleType="centerInside"/>
</com.android.systemui.statusbar.phone.MultiUserSwitch>
- <com.android.keyguard.AlphaOptimizedImageButton android:id="@+id/settings_button"
- style="@android:style/Widget.Material.Button.Borderless"
- android:layout_toStartOf="@id/multi_user_switch"
+ <com.android.keyguard.AlphaOptimizedLinearLayout
+ android:id="@+id/settings_button_container"
android:layout_width="48dp"
android:layout_height="@dimen/status_bar_header_height"
- android:background="@drawable/ripple_drawable"
- android:src="@drawable/ic_settings"
- android:contentDescription="@string/accessibility_desc_settings" />
+ android:paddingStart="12dp"
+ android:clipChildren="false"
+ android:clipToPadding="false"
+ android:layout_toStartOf="@id/multi_user_switch">
+
+ <com.android.systemui.statusbar.phone.SettingsButton android:id="@+id/settings_button"
+ style="@android:style/Widget.Material.Button.Borderless"
+ android:layout_width="24dp"
+ android:layout_height="@dimen/status_bar_header_height"
+ android:background="@drawable/ripple_drawable"
+ android:src="@drawable/ic_settings"
+ android:contentDescription="@string/accessibility_desc_settings" />
+ <com.android.systemui.statusbar.AlphaOptimizedImageView android:id="@+id/tuner_icon"
+ android:layout_width="12dp"
+ android:layout_height="@dimen/status_bar_header_height"
+ android:tint="#4DFFFFFF"
+ android:tintMode="src_in"
+ android:visibility="invisible"
+ android:src="@drawable/tuner" />
+
+ </com.android.keyguard.AlphaOptimizedLinearLayout>
<LinearLayout android:id="@+id/system_icons_super_container"
android:layout_width="wrap_content"
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index fcf7e3e..3eac84f 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1032,7 +1032,7 @@
<string name="volume_stream_vibrate_dnd" translatable="false">%s vibrate — Priority only</string>
<!-- Name of special SystemUI debug settings -->
- <string name="system_ui_tuner">System UI tuner</string>
+ <string name="system_ui_tuner">System UI Tuner</string>
<!-- Preference to show/hide embedded battery percentage [CHAR LIMIT=50] -->
<string name="show_battery_percentage">Show embedded battery percentage</string>
@@ -1099,4 +1099,25 @@
<!-- Accessibility label for managed profile icon (not shown on screen) [CHAR LIMIT=NONE] -->
<string name="accessibility_managed_profile">Work profile</string>
+ <!-- Title of warning when entering System UI tuner for first time [CHAR LIMIT=NONE] -->
+ <string name="tuner_warning_title">Fun for some but not for all</string>
+
+ <!-- Warning for users entering the System UI tuner for the first time [CHAR LIMIT=NONE]-->
+ <string name="tuner_warning">System UI Tuner gives you extra ways to tweak and customize the Android user interface. These experimental features may change, break, or disappear in future releases. Proceed with caution.</string>
+
+ <!-- Warning for users entering the System UI tuner [CHAR LIMIT=NONE]-->
+ <string name="tuner_persistent_warning">These experimental features may change, break, or disappear in future releases. Proceed with caution.</string>
+
+ <!-- Generic "got it" acceptance of dialog or cling [CHAR LIMIT=NONE] -->
+ <string name="got_it">Got it</string>
+
+ <!-- Toast describing tuner has been enabled [CHAR LIMIT=NONE] -->
+ <string name="tuner_toast">Congrats! System UI Tuner has been added to Settings</string>
+
+ <!-- Option to remove the tuner from settings [CHAR LIMIT=NONE] -->
+ <string name="remove_from_settings">Remove from Settings</string>
+
+ <!-- Dialog asking if the tuner should really be removed from settings [CHAR LIMIT=NONE]-->
+ <string name="remove_from_settings_prompt">Remove System UI Tuner from Settings and stop using all of its features?"</string>
+
</resources>
diff --git a/packages/SystemUI/res/xml/tuner_prefs.xml b/packages/SystemUI/res/xml/tuner_prefs.xml
index 8c1acc3..3a41c3c 100644
--- a/packages/SystemUI/res/xml/tuner_prefs.xml
+++ b/packages/SystemUI/res/xml/tuner_prefs.xml
@@ -76,4 +76,8 @@
android:key="demo_mode"
android:title="@string/demo_mode" />
+ <Preference
+ android:summary="@string/tuner_persistent_warning"
+ android:selectable="false" />
+
</PreferenceScreen>
diff --git a/packages/SystemUI/src/com/android/systemui/DemoMode.java b/packages/SystemUI/src/com/android/systemui/DemoMode.java
index d406f5b..11996d0 100644
--- a/packages/SystemUI/src/com/android/systemui/DemoMode.java
+++ b/packages/SystemUI/src/com/android/systemui/DemoMode.java
@@ -20,6 +20,8 @@
public interface DemoMode {
+ public static final String DEMO_MODE_ALLOWED = "sysui_demo_allowed";
+
void dispatchDemoCommand(String command, Bundle args);
public static final String ACTION_DEMO = "com.android.systemui.demo";
diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
index f66a7dd..9265b63 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
@@ -304,4 +304,8 @@
public void onUserSwitched(int newUserId) {
updateAssistInfo();
}
+
+ public void onLockscreenShown() {
+ mAssistUtils.onLockscreenShown();
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
index 98558b4..9f21dbe 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
@@ -25,9 +25,9 @@
import android.os.Process;
import android.util.Log;
+import com.android.internal.policy.IKeyguardDrawnCallback;
import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardService;
-import com.android.internal.policy.IKeyguardShowCallback;
import com.android.internal.policy.IKeyguardStateCallback;
import com.android.systemui.SystemUIApplication;
@@ -120,9 +120,15 @@
}
@Override // Binder interface
- public void onStartedWakingUp(IKeyguardShowCallback callback) {
+ public void onStartedWakingUp() {
checkPermission();
- mKeyguardViewMediator.onStartedWakingUp(callback);
+ mKeyguardViewMediator.onStartedWakingUp();
+ }
+
+ @Override // Binder interface
+ public void onScreenTurningOn(IKeyguardDrawnCallback callback) {
+ checkPermission();
+ mKeyguardViewMediator.onScreenTurningOn(callback);
}
@Override // Binder interface
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 009a0d6..c01a485 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -41,6 +41,7 @@
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
+import android.os.Trace;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
@@ -55,8 +56,9 @@
import android.view.WindowManagerPolicy;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
+
+import com.android.internal.policy.IKeyguardDrawnCallback;
import com.android.internal.policy.IKeyguardExitCallback;
-import com.android.internal.policy.IKeyguardShowCallback;
import com.android.internal.policy.IKeyguardStateCallback;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.widget.LockPatternUtils;
@@ -77,7 +79,6 @@
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
-
/**
* Mediates requests related to the keyguard. This includes queries about the
* state of the keyguard, power management events that effect whether the keyguard
@@ -138,7 +139,7 @@
private static final int RESET = 4;
private static final int VERIFY_UNLOCK = 5;
private static final int NOTIFY_SCREEN_OFF = 6;
- private static final int NOTIFY_SCREEN_ON = 7;
+ private static final int NOTIFY_SCREEN_TURNING_ON = 7;
private static final int KEYGUARD_DONE = 9;
private static final int KEYGUARD_DONE_DRAWING = 10;
private static final int KEYGUARD_DONE_AUTHENTICATING = 11;
@@ -148,6 +149,7 @@
private static final int START_KEYGUARD_EXIT_ANIM = 18;
private static final int ON_ACTIVITY_DRAWN = 19;
private static final int KEYGUARD_DONE_PENDING_TIMEOUT = 20;
+ private static final int NOTIFY_STARTED_WAKING_UP = 21;
/**
* The default amount of time we stay awake (used for all key input)
@@ -311,11 +313,14 @@
private boolean mPendingReset;
/**
- * When starting goign to sleep, we figured out that we need to lock Keyguard and this should be
+ * When starting going to sleep, we figured out that we need to lock Keyguard and this should be
* committed when finished going to sleep.
*/
private boolean mPendingLock;
+ private boolean mWakeAndUnlocking;
+ private IKeyguardDrawnCallback mDrawnCallback;
+
KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() {
@Override
@@ -454,12 +459,17 @@
}
@Override
- public void onFingerprintAuthenticated(int userId) {
+ public void onFingerprintAuthenticated(int userId, boolean wakeAndUnlocking) {
if (mStatusBarKeyguardViewManager.isBouncerShowing()) {
mStatusBarKeyguardViewManager.notifyKeyguardAuthenticated();
} else {
- mStatusBarKeyguardViewManager.animateCollapsePanels(
- FINGERPRINT_COLLAPSE_SPEEDUP_FACTOR);
+ if (wakeAndUnlocking) {
+ mWakeAndUnlocking = true;
+ keyguardDone(true, true);
+ } else {
+ mStatusBarKeyguardViewManager.animateCollapsePanels(
+ FINGERPRINT_COLLAPSE_SPEEDUP_FACTOR);
+ }
}
};
@@ -752,21 +762,23 @@
/**
* Let's us know when the device is waking up.
*/
- public void onStartedWakingUp(IKeyguardShowCallback callback) {
+ public void onStartedWakingUp() {
// TODO: Rename all screen off/on references to interactive/sleeping
synchronized (this) {
mDeviceInteractive = true;
cancelDoKeyguardLaterLocked();
if (DEBUG) Log.d(TAG, "onStartedWakingUp, seq = " + mDelayedShowingSequence);
- if (callback != null) {
- notifyScreenOnLocked(callback);
- }
+ notifyStartedWakingUp();
}
KeyguardUpdateMonitor.getInstance(mContext).dispatchScreenTurnedOn();
maybeSendUserPresentBroadcast();
}
+ public void onScreenTurningOn(IKeyguardDrawnCallback callback) {
+ notifyScreenOnLocked(callback);
+ }
+
private void maybeSendUserPresentBroadcast() {
if (mSystemReady && mLockPatternUtils.isLockScreenDisabled(
KeyguardUpdateMonitor.getCurrentUser())) {
@@ -1093,14 +1105,14 @@
mHandler.sendEmptyMessage(NOTIFY_SCREEN_OFF);
}
- /**
- * Send a message to keyguard telling it the screen just turned on.
- * @see #onScreenTurnedOn
- * @see #handleNotifyScreenOn
- */
- private void notifyScreenOnLocked(IKeyguardShowCallback result) {
+ private void notifyStartedWakingUp() {
+ if (DEBUG) Log.d(TAG, "notifyStartedWakingUp");
+ mHandler.sendEmptyMessage(NOTIFY_STARTED_WAKING_UP);
+ }
+
+ private void notifyScreenOnLocked(IKeyguardDrawnCallback callback) {
if (DEBUG) Log.d(TAG, "notifyScreenOnLocked");
- Message msg = mHandler.obtainMessage(NOTIFY_SCREEN_ON, result);
+ Message msg = mHandler.obtainMessage(NOTIFY_SCREEN_TURNING_ON, callback);
mHandler.sendMessage(msg);
}
@@ -1190,8 +1202,11 @@
case NOTIFY_SCREEN_OFF:
handleNotifyScreenOff();
break;
- case NOTIFY_SCREEN_ON:
- handleNotifyScreenOn((IKeyguardShowCallback) msg.obj);
+ case NOTIFY_SCREEN_TURNING_ON:
+ handleNotifyScreenTurningOn((IKeyguardDrawnCallback) msg.obj);
+ break;
+ case NOTIFY_STARTED_WAKING_UP:
+ handleNotifyStartedWakingUp();
break;
case KEYGUARD_DONE:
handleKeyguardDone(msg.arg1 != 0, msg.arg2 != 0);
@@ -1354,6 +1369,7 @@
setShowingLocked(true);
mStatusBarKeyguardViewManager.show(options);
mHiding = false;
+ mWakeAndUnlocking = false;
resetKeyguardDonePendingLocked();
mHideAnimationRun = false;
updateActivityLockScreenState();
@@ -1375,7 +1391,8 @@
// manager until it tells us it's safe to do so with
// startKeyguardExitAnimation.
ActivityManagerNative.getDefault().keyguardGoingAway(
- mStatusBarKeyguardViewManager.shouldDisableWindowAnimationsForUnlock(),
+ mStatusBarKeyguardViewManager.shouldDisableWindowAnimationsForUnlock()
+ || mWakeAndUnlocking,
mStatusBarKeyguardViewManager.isGoingToNotificationShade());
} catch (RemoteException e) {
Log.e(TAG, "Error while calling WindowManager", e);
@@ -1437,6 +1454,9 @@
updateActivityLockScreenState();
adjustStatusBarLocked();
sendUserPresentBroadcast();
+ if (mWakeAndUnlocking && mDrawnCallback != null) {
+ notifyDrawn(mDrawnCallback);
+ }
}
}
@@ -1508,14 +1528,31 @@
}
}
- /**
- * Handle message sent by {@link #notifyScreenOnLocked}
- * @see #NOTIFY_SCREEN_ON
- */
- private void handleNotifyScreenOn(IKeyguardShowCallback callback) {
+ private void handleNotifyStartedWakingUp() {
synchronized (KeyguardViewMediator.this) {
- if (DEBUG) Log.d(TAG, "handleNotifyScreenOn");
- mStatusBarKeyguardViewManager.onScreenTurnedOn(callback);
+ if (DEBUG) Log.d(TAG, "handleNotifyWakingUp");
+ mStatusBarKeyguardViewManager.onScreenTurnedOn();
+ }
+ }
+
+ private void handleNotifyScreenTurningOn(IKeyguardDrawnCallback callback) {
+ synchronized (KeyguardViewMediator.this) {
+ if (DEBUG) Log.d(TAG, "handleNotifyScreenTurningOn");
+ if (callback != null) {
+ if (mWakeAndUnlocking) {
+ mDrawnCallback = callback;
+ } else {
+ notifyDrawn(callback);
+ }
+ }
+ }
+ }
+
+ private void notifyDrawn(final IKeyguardDrawnCallback callback) {
+ try {
+ callback.onDrawn();
+ } catch (RemoteException e) {
+ Slog.w(TAG, "Exception calling onDrawn():", e);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/media/RingtonePlayer.java b/packages/SystemUI/src/com/android/systemui/media/RingtonePlayer.java
index e9a256c..fe876d7 100644
--- a/packages/SystemUI/src/com/android/systemui/media/RingtonePlayer.java
+++ b/packages/SystemUI/src/com/android/systemui/media/RingtonePlayer.java
@@ -171,6 +171,13 @@
}
mAsyncPlayer.stop();
}
+
+ @Override
+ public String getTitle(Uri uri) {
+ final UserHandle user = Binder.getCallingUserHandle();
+ return Ringtone.getTitle(getContextForUser(user), uri,
+ false /*followSettingsUri*/, false /*allowRemote*/);
+ }
};
private Context getContextForUser(UserHandle user) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
index 07406b9..f3ad9d8 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
@@ -45,6 +45,8 @@
private final MobileDataController mDataController;
private final CellularDetailAdapter mDetailAdapter;
+ private final CellSignalCallback mSignalCallback = new CellSignalCallback();
+
public CellularTile(Host host) {
super(host);
mController = host.getNetworkController();
@@ -90,8 +92,10 @@
protected void handleUpdateState(SignalState state, Object arg) {
state.visible = mController.hasMobileDataFeature();
if (!state.visible) return;
- final CallbackInfo cb = (CallbackInfo) arg;
- if (cb == null) return;
+ CallbackInfo cb = (CallbackInfo) arg;
+ if (cb == null) {
+ cb = mSignalCallback.mInfo;
+ }
final Resources r = mContext.getResources();
final int iconId = cb.noSim ? R.drawable.ic_qs_no_sim
@@ -152,7 +156,7 @@
boolean isDataTypeIconWide;
}
- private final SignalCallback mSignalCallback = new SignalCallbackAdapter() {
+ private final class CellSignalCallback extends SignalCallbackAdapter {
private final CallbackInfo mInfo = new CallbackInfo();
@Override
public void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/IntentTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/IntentTile.java
index f7f7acb..3d0dc7b 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/IntentTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/IntentTile.java
@@ -45,6 +45,8 @@
private int mCurrentUserId;
private String mIntentPackage;
+ private Intent mLastIntent;
+
private IntentTile(Host host, String action) {
super(host);
mContext.registerReceiver(mReceiver, new IntentFilter(action));
@@ -112,8 +114,16 @@
@Override
protected void handleUpdateState(State state, Object arg) {
- if (!(arg instanceof Intent)) return;
- final Intent intent = (Intent) arg;
+ Intent intent = (Intent) arg;
+ if (intent == null) {
+ if (mLastIntent == null) {
+ return;
+ }
+ // No intent but need to refresh state, just use the last one.
+ intent = mLastIntent;
+ }
+ // Save the last one in case we need it later.
+ mLastIntent = intent;
state.visible = intent.getBooleanExtra("visible", true);
state.contentDescription = intent.getStringExtra("contentDescription");
state.label = intent.getStringExtra("label");
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
index 3bfff2f..e654efd 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
@@ -35,7 +35,6 @@
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.NetworkController.AccessPointController;
import com.android.systemui.statusbar.policy.NetworkController.IconState;
-import com.android.systemui.statusbar.policy.NetworkController.SignalCallback;
import com.android.systemui.statusbar.policy.SignalCallbackAdapter;
import java.util.List;
@@ -49,6 +48,8 @@
private final WifiDetailAdapter mDetailAdapter;
private final QSTile.SignalState mStateBeforeClick = newTileState();
+ private final WifiSignalCallback mSignalCallback = new WifiSignalCallback();
+
public WifiTile(Host host) {
super(host);
mController = host.getNetworkController();
@@ -118,8 +119,10 @@
protected void handleUpdateState(SignalState state, Object arg) {
state.visible = true;
if (DEBUG) Log.d(TAG, "handleUpdateState arg=" + arg);
- if (arg == null) return;
CallbackInfo cb = (CallbackInfo) arg;
+ if (cb == null) {
+ cb = mSignalCallback.mInfo;
+ }
boolean wifiConnected = cb.enabled && (cb.wifiSignalIconId > 0) && (cb.enabledDesc != null);
boolean wifiNotConnected = (cb.wifiSignalIconId > 0) && (cb.enabledDesc == null);
@@ -213,20 +216,21 @@
}
}
- private final SignalCallback mSignalCallback = new SignalCallbackAdapter() {
+ private final class WifiSignalCallback extends SignalCallbackAdapter {
+ final CallbackInfo mInfo = new CallbackInfo();
+
@Override
public void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
boolean activityIn, boolean activityOut, String description) {
if (DEBUG) Log.d(TAG, "onWifiSignalChanged enabled=" + enabled);
- final CallbackInfo info = new CallbackInfo();
- info.enabled = enabled;
- info.connected = qsIcon.visible;
- info.wifiSignalIconId = qsIcon.icon;
- info.enabledDesc = description;
- info.activityIn = activityIn;
- info.activityOut = activityOut;
- info.wifiSignalContentDescription = qsIcon.contentDescription;
- refreshState(info);
+ mInfo.enabled = enabled;
+ mInfo.connected = qsIcon.visible;
+ mInfo.wifiSignalIconId = qsIcon.icon;
+ mInfo.enabledDesc = description;
+ mInfo.activityIn = activityIn;
+ mInfo.activityOut = activityOut;
+ mInfo.wifiSignalContentDescription = qsIcon.contentDescription;
+ refreshState(mInfo);
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index f62dc59..a2e6632 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -729,11 +729,15 @@
}
protected void setNotificationShown(StatusBarNotification n) {
- mNotificationListener.setNotificationsShown(new String[] { n.getKey() });
+ setNotificationsShown(new String[]{n.getKey()});
}
protected void setNotificationsShown(String[] keys) {
- mNotificationListener.setNotificationsShown(keys);
+ try {
+ mNotificationListener.setNotificationsShown(keys);
+ } catch (RuntimeException e) {
+ Log.d(TAG, "failed setNotificationsShown: ", e);
+ }
}
protected boolean isCurrentProfile(int userId) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardAffordanceView.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardAffordanceView.java
index 58fb2b1..164c496 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardAffordanceView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardAffordanceView.java
@@ -69,7 +69,7 @@
private float mCircleStartValue;
private boolean mCircleWillBeHidden;
private int[] mTempPoint = new int[2];
- private float mImageScale;
+ private float mImageScale = 1f;
private int mCircleColor;
private boolean mIsLeft;
private View mPreviewView;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java
index 6670ae0..10019f9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java
@@ -86,9 +86,9 @@
mContext = context;
mCallback = callback;
initIcons();
- updateIcon(mLeftIcon, 0.0f, mLeftIcon.getRestingAlpha(), false, false);
- updateIcon(mCenterIcon, 0.0f, mCenterIcon.getRestingAlpha(), false, false);
- updateIcon(mRightIcon, 0.0f, mRightIcon.getRestingAlpha(), false, false);
+ updateIcon(mLeftIcon, 0.0f, mLeftIcon.getRestingAlpha(), false, false, true);
+ updateIcon(mCenterIcon, 0.0f, mCenterIcon.getRestingAlpha(), false, false, true);
+ updateIcon(mRightIcon, 0.0f, mRightIcon.getRestingAlpha(), false, false, true);
initDimens();
}
@@ -387,15 +387,15 @@
boolean slowAnimation = isReset && isBelowFalsingThreshold();
if (!isReset) {
updateIcon(targetView, radius, alpha + fadeOutAlpha * targetView.getRestingAlpha(),
- false, false);
+ false, false, false);
} else {
updateIcon(targetView, 0.0f, fadeOutAlpha * targetView.getRestingAlpha(),
- animateIcons, slowAnimation);
+ animateIcons, slowAnimation, false);
}
updateIcon(otherView, 0.0f, fadeOutAlpha * otherView.getRestingAlpha(),
- animateIcons, slowAnimation);
+ animateIcons, slowAnimation, false);
updateIcon(mCenterIcon, 0.0f, fadeOutAlpha * mCenterIcon.getRestingAlpha(),
- animateIcons, slowAnimation);
+ animateIcons, slowAnimation, false);
mTranslation = translation;
}
@@ -431,13 +431,13 @@
public void animateHideLeftRightIcon() {
cancelAnimation();
- updateIcon(mRightIcon, 0f, 0f, true, false);
- updateIcon(mLeftIcon, 0f, 0f, true, false);
+ updateIcon(mRightIcon, 0f, 0f, true, false, false);
+ updateIcon(mLeftIcon, 0f, 0f, true, false, false);
}
private void updateIcon(KeyguardAffordanceView view, float circleRadius, float alpha,
- boolean animate, boolean slowRadiusAnimation) {
- if (view.getVisibility() != View.VISIBLE) {
+ boolean animate, boolean slowRadiusAnimation, boolean force) {
+ if (view.getVisibility() != View.VISIBLE && !force) {
return;
}
view.setCircleRadius(circleRadius, slowRadiusAnimation);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
index 91adc460..4558288 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
@@ -106,6 +106,7 @@
private PhoneStatusBar mPhoneStatusBar;
private final Interpolator mLinearOutSlowInInterpolator;
+ private boolean mUserSetupComplete;
private boolean mPrewarmBound;
private Messenger mPrewarmMessenger;
private final ServiceConnection mPrewarmConnection = new ServiceConnection() {
@@ -250,6 +251,12 @@
updateCameraVisibility(); // in case onFinishInflate() was called too early
}
+ public void setUserSetupComplete(boolean userSetupComplete) {
+ mUserSetupComplete = userSetupComplete;
+ updateCameraVisibility();
+ updateLeftAffordanceIcon();
+ }
+
private Intent getCameraIntent() {
KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
boolean canSkipBouncer = updateMonitor.getUserCanSkipBouncer(
@@ -267,7 +274,8 @@
PackageManager.MATCH_DEFAULT_ONLY,
KeyguardUpdateMonitor.getCurrentUser());
boolean visible = !isCameraDisabledByDpm() && resolved != null
- && getResources().getBoolean(R.bool.config_keyguardShowCameraAffordance);
+ && getResources().getBoolean(R.bool.config_keyguardShowCameraAffordance)
+ && mUserSetupComplete;
mCameraImageView.setVisibility(visible ? View.VISIBLE : View.GONE);
}
@@ -275,16 +283,16 @@
mLeftIsVoiceAssist = canLaunchVoiceAssist();
int drawableId;
int contentDescription;
+ boolean visible = mUserSetupComplete;
if (mLeftIsVoiceAssist) {
- mLeftAffordanceView.setVisibility(View.VISIBLE);
drawableId = R.drawable.ic_mic_26dp;
contentDescription = R.string.accessibility_voice_assist_button;
} else {
- boolean visible = isPhoneVisible();
- mLeftAffordanceView.setVisibility(visible ? View.VISIBLE : View.GONE);
+ visible &= isPhoneVisible();
drawableId = R.drawable.ic_phone_24dp;
contentDescription = R.string.accessibility_phone_button;
}
+ mLeftAffordanceView.setVisibility(visible ? View.VISIBLE : View.GONE);
mLeftAffordanceView.setImageDrawable(mContext.getDrawable(drawableId));
mLeftAffordanceView.setContentDescription(mContext.getString(contentDescription));
}
@@ -641,7 +649,7 @@
}
@Override
- public void onFingerprintAuthenticated(int userId) {
+ public void onFingerprintAuthenticated(int userId, boolean wakeAndUnlocking) {
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 10191ed..03bdf97 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -965,6 +965,7 @@
private void onQsExpansionStarted(int overscrollAmount) {
cancelQsAnimation();
cancelHeightAnimator();
+ notifyExpandingFinished();
// Reset scroll position and apply that position to the expanded height.
float height = mQsExpansionHeight - mScrollView.getScrollY() - overscrollAmount;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index 889160d..0d20d52 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -111,7 +111,7 @@
*/
private float mNextCollapseSpeedUpFactor = 1.0f;
- private boolean mExpanding;
+ protected boolean mExpanding;
private boolean mGestureWaitForTouchSlop;
private boolean mIgnoreXTouchSlop;
private Runnable mPeekRunnable = new Runnable() {
@@ -137,7 +137,7 @@
}
}
- private void notifyExpandingFinished() {
+ protected final void notifyExpandingFinished() {
if (mExpanding) {
mExpanding = false;
onExpandingFinished();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 2248905..38e2d61 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -198,6 +198,8 @@
public static final boolean SHOW_LOCKSCREEN_MEDIA_ARTWORK = true;
+ public static final String ACTION_FAKE_ARTWORK = "fake_artwork";
+
private static final int MSG_OPEN_NOTIFICATION_PANEL = 1000;
private static final int MSG_CLOSE_PANELS = 1001;
private static final int MSG_OPEN_SETTINGS_PANEL = 1002;
@@ -364,6 +366,9 @@
mUserSetup = userSetup;
if (!mUserSetup && mStatusBarView != null)
animateCollapseQuickSettings();
+ if (mKeyguardBottomArea != null) {
+ mKeyguardBottomArea.setUserSetupComplete(mUserSetup);
+ }
}
if (mIconPolicy != null) {
mIconPolicy.setCurrentUserSetup(mUserSetup);
@@ -434,6 +439,12 @@
public void onPlaybackStateChanged(PlaybackState state) {
super.onPlaybackStateChanged(state);
if (DEBUG_MEDIA) Log.v(TAG, "DEBUG_MEDIA: onPlaybackStateChanged: " + state);
+ if (state != null) {
+ if (!isPlaybackActive(state.getState())) {
+ clearCurrentMediaNotification();
+ updateMediaMetaData(true);
+ }
+ }
}
@Override
@@ -834,6 +845,7 @@
mFlashlightController = new FlashlightController(mContext);
mKeyguardBottomArea.setFlashlightController(mFlashlightController);
mKeyguardBottomArea.setPhoneStatusBar(this);
+ mKeyguardBottomArea.setUserSetupComplete(mUserSetup);
mAccessibilityController = new AccessibilityController(mContext);
mKeyguardBottomArea.setAccessibilityController(mAccessibilityController);
mNextAlarmController = new NextAlarmController(mContext);
@@ -890,12 +902,16 @@
filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_SCREEN_ON);
- if (DEBUG_MEDIA_FAKE_ARTWORK) {
- filter.addAction("fake_artwork");
- }
- filter.addAction(ACTION_DEMO);
context.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null);
+ IntentFilter demoFilter = new IntentFilter();
+ if (DEBUG_MEDIA_FAKE_ARTWORK) {
+ demoFilter.addAction(ACTION_FAKE_ARTWORK);
+ }
+ demoFilter.addAction(ACTION_DEMO);
+ context.registerReceiverAsUser(mDemoReceiver, UserHandle.ALL, demoFilter,
+ android.Manifest.permission.DUMP, null);
+
// listen for USER_SETUP_COMPLETE setting (per-user)
resetUserSetupObserver();
@@ -1193,6 +1209,10 @@
if (mHeadsUpManager.isHeadsUp(key)) {
deferRemoval = !mHeadsUpManager.removeNotification(key);
}
+ if (key.equals(mMediaNotificationKey)) {
+ clearCurrentMediaNotification();
+ updateMediaMetaData(true);
+ }
if (deferRemoval) {
mLatestRankingMap = ranking;
mHeadsUpEntriesToRemoveOnSwitch.add(mHeadsUpManager.getEntry(key));
@@ -1486,23 +1506,31 @@
synchronized (mNotificationData) {
ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications();
final int N = activeNotifications.size();
+
+ // Promote the media notification with a controller in 'playing' state, if any.
Entry mediaNotification = null;
MediaController controller = null;
for (int i = 0; i < N; i++) {
final Entry entry = activeNotifications.get(i);
if (isMediaNotification(entry)) {
- final MediaSession.Token token = entry.notification.getNotification().extras
+ final MediaSession.Token token =
+ entry.notification.getNotification().extras
.getParcelable(Notification.EXTRA_MEDIA_SESSION);
if (token != null) {
- controller = new MediaController(mContext, token);
- if (controller != null) {
- // we've got a live one, here
+ MediaController aController = new MediaController(mContext, token);
+ if (PlaybackState.STATE_PLAYING ==
+ getMediaControllerPlaybackState(aController)) {
+ if (DEBUG_MEDIA) {
+ Log.v(TAG, "DEBUG_MEDIA: found mediastyle controller matching "
+ + entry.notification.getKey());
+ }
mediaNotification = entry;
+ controller = aController;
+ break;
}
}
}
}
-
if (mediaNotification == null) {
// Still nothing? OK, let's just look for live media sessions and see if they match
// one of our notifications. This will catch apps that aren't (yet!) using media
@@ -1515,83 +1543,88 @@
UserHandle.USER_ALL);
for (MediaController aController : sessions) {
- if (aController == null) continue;
- final PlaybackState state = aController.getPlaybackState();
- if (state == null) continue;
- switch (state.getState()) {
- case PlaybackState.STATE_STOPPED:
- case PlaybackState.STATE_ERROR:
- continue;
- default:
- // now to see if we have one like this
- final String pkg = aController.getPackageName();
+ if (PlaybackState.STATE_PLAYING ==
+ getMediaControllerPlaybackState(aController)) {
+ // now to see if we have one like this
+ final String pkg = aController.getPackageName();
- for (int i = 0; i < N; i++) {
- final Entry entry = activeNotifications.get(i);
- if (entry.notification.getPackageName().equals(pkg)) {
- if (DEBUG_MEDIA) {
- Log.v(TAG, "DEBUG_MEDIA: found controller matching "
- + entry.notification.getKey());
- }
- controller = aController;
- mediaNotification = entry;
- break;
+ for (int i = 0; i < N; i++) {
+ final Entry entry = activeNotifications.get(i);
+ if (entry.notification.getPackageName().equals(pkg)) {
+ if (DEBUG_MEDIA) {
+ Log.v(TAG, "DEBUG_MEDIA: found controller matching "
+ + entry.notification.getKey());
}
+ controller = aController;
+ mediaNotification = entry;
+ break;
}
+ }
}
}
}
}
- if (!sameSessions(mMediaController, controller)) {
+ if (controller != null && !sameSessions(mMediaController, controller)) {
// We have a new media session
-
- if (mMediaController != null) {
- // something old was playing
- Log.v(TAG, "DEBUG_MEDIA: Disconnecting from old controller: "
- + mMediaController);
- mMediaController.unregisterCallback(mMediaListener);
- }
+ clearCurrentMediaNotification();
mMediaController = controller;
-
- if (mMediaController != null) {
- mMediaController.registerCallback(mMediaListener);
- mMediaMetadata = mMediaController.getMetadata();
- if (DEBUG_MEDIA) {
- Log.v(TAG, "DEBUG_MEDIA: insert listener, receive metadata: "
- + mMediaMetadata);
- }
-
- final String notificationKey = mediaNotification == null
- ? null
- : mediaNotification.notification.getKey();
-
- if (notificationKey == null || !notificationKey.equals(mMediaNotificationKey)) {
- // we have a new notification!
- if (DEBUG_MEDIA) {
- Log.v(TAG, "DEBUG_MEDIA: Found new media notification: key="
- + notificationKey + " controller=" + controller);
- }
- mMediaNotificationKey = notificationKey;
- }
- } else {
- mMediaMetadata = null;
- mMediaNotificationKey = null;
- }
-
- metaDataChanged = true;
- } else {
- // Media session unchanged
-
+ mMediaController.registerCallback(mMediaListener);
+ mMediaMetadata = mMediaController.getMetadata();
if (DEBUG_MEDIA) {
- Log.v(TAG, "DEBUG_MEDIA: Continuing media notification: key=" + mMediaNotificationKey);
+ Log.v(TAG, "DEBUG_MEDIA: insert listener, receive metadata: "
+ + mMediaMetadata);
}
+
+ if (mediaNotification != null) {
+ mMediaNotificationKey = mediaNotification.notification.getKey();
+ if (DEBUG_MEDIA) {
+ Log.v(TAG, "DEBUG_MEDIA: Found new media notification: key="
+ + mMediaNotificationKey + " controller=" + mMediaController);
+ }
+ }
+ metaDataChanged = true;
}
}
+ if (metaDataChanged) {
+ updateNotifications();
+ }
updateMediaMetaData(metaDataChanged);
}
+ private int getMediaControllerPlaybackState(MediaController controller) {
+ if (controller != null) {
+ final PlaybackState playbackState = controller.getPlaybackState();
+ if (playbackState != null) {
+ return playbackState.getState();
+ }
+ }
+ return PlaybackState.STATE_NONE;
+ }
+
+ private boolean isPlaybackActive(int state) {
+ if (state != PlaybackState.STATE_STOPPED
+ && state != PlaybackState.STATE_ERROR
+ && state != PlaybackState.STATE_NONE) {
+ return true;
+ }
+ return false;
+ }
+
+ private void clearCurrentMediaNotification() {
+ mMediaNotificationKey = null;
+ mMediaMetadata = null;
+ if (mMediaController != null) {
+ if (DEBUG_MEDIA) {
+ Log.v(TAG, "DEBUG_MEDIA: Disconnecting from old controller: "
+ + mMediaController.getPackageName());
+ }
+ mMediaController.unregisterCallback(mMediaListener);
+ }
+ mMediaController = null;
+ }
+
private boolean sameSessions(MediaController a, MediaController b) {
if (a == b) return true;
if (a == null) return false;
@@ -1657,7 +1690,8 @@
}
if (metaDataChanged) {
if (mBackdropBack.getDrawable() != null) {
- Drawable drawable = mBackdropBack.getDrawable();
+ Drawable drawable =
+ mBackdropBack.getDrawable().getConstantState().newDrawable().mutate();
mBackdropFront.setImageDrawable(drawable);
if (mScrimSrcModeEnabled) {
mBackdropFront.getDrawable().mutate().setXfermode(mSrcOverXferMode);
@@ -1730,7 +1764,7 @@
}
private int adjustDisableFlags(int state) {
- if (!mLaunchTransitionFadingAway
+ if (!mLaunchTransitionFadingAway && !mKeyguardFadingAway
&& (mExpandedVisible || mBouncerShowing || mWaitingForKeyguardExit)) {
state |= StatusBarManager.DISABLE_NOTIFICATION_ICONS;
state |= StatusBarManager.DISABLE_SYSTEM_INFO;
@@ -2852,7 +2886,14 @@
mScreenOn = true;
notifyNavigationBarScreenOn(true);
}
- else if (ACTION_DEMO.equals(action)) {
+ }
+ };
+
+ private BroadcastReceiver mDemoReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ if (DEBUG) Log.v(TAG, "onReceive: " + intent);
+ String action = intent.getAction();
+ if (ACTION_DEMO.equals(action)) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
String command = bundle.getString("command", "").trim().toLowerCase();
@@ -2864,7 +2905,7 @@
}
}
}
- } else if ("fake_artwork".equals(action)) {
+ } else if (ACTION_FAKE_ARTWORK.equals(action)) {
if (DEBUG_MEDIA_FAKE_ARTWORK) {
updateMediaMetaData(true);
}
@@ -2913,7 +2954,7 @@
updateRowStates();
mIconController.updateResources();
mScreenPinningRequest.onConfigurationChanged();
- mNetworkController.handleConfigurationChanged();
+ mNetworkController.onConfigurationChanged();
}
@Override
@@ -3188,6 +3229,7 @@
mHandlerThread = null;
}
mContext.unregisterReceiver(mBroadcastReceiver);
+ mContext.unregisterReceiver(mDemoReceiver);
mAssistManager.destroy();
final SignalClusterView signalCluster =
@@ -3211,7 +3253,7 @@
public void dispatchDemoCommand(String command, Bundle args) {
if (!mDemoModeAllowed) {
mDemoModeAllowed = Settings.Global.getInt(mContext.getContentResolver(),
- "sysui_demo_allowed", 0) != 0;
+ DEMO_MODE_ALLOWED, 0) != 0;
}
if (!mDemoModeAllowed) return;
if (command.equals(COMMAND_ENTER)) {
@@ -3311,6 +3353,7 @@
mDraggedDownRow.notifyHeightChanged(false /* needsAnimation */);
mDraggedDownRow = null;
}
+ mAssistManager.onLockscreenShown();
}
private void onLaunchTransitionFadingEnded() {
@@ -3460,7 +3503,7 @@
startTime + fadeoutDuration
- StatusBarIconController.DEFAULT_TINT_ANIMATION_DURATION,
StatusBarIconController.DEFAULT_TINT_ANIMATION_DURATION);
- disable(mDisabledUnmodified1, mDisabledUnmodified2, true /* animate */);
+ disable(mDisabledUnmodified1, mDisabledUnmodified2, fadeoutDuration > 0 /* animate */);
}
public boolean isKeyguardFadingAway() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SettingsButton.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SettingsButton.java
new file mode 100644
index 0000000..a1e9ece
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SettingsButton.java
@@ -0,0 +1,174 @@
+/*
+ * Copyright (C) 2015 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+package com.android.systemui.statusbar.phone;
+
+import android.animation.Animator;
+import android.animation.Animator.AnimatorListener;
+import android.animation.ObjectAnimator;
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewConfiguration;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+
+import com.android.keyguard.AlphaOptimizedImageButton;
+
+public class SettingsButton extends AlphaOptimizedImageButton {
+
+ private static final long LONG_PRESS_LENGTH = 1000;
+ private static final long ACCEL_LENGTH = 750;
+ private static final long FULL_SPEED_LENGTH = 375;
+ private static final long RUN_DURATION = 350;
+
+ private boolean mUpToSpeed;
+ private ObjectAnimator mAnimator;
+
+ private float mSlop;
+
+ public SettingsButton(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
+ }
+
+ public boolean isAnimating() {
+ return mAnimator != null && mAnimator.isRunning();
+ }
+
+ public boolean isTunerClick() {
+ return mUpToSpeed;
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ switch (event.getActionMasked()) {
+ case MotionEvent.ACTION_DOWN:
+ postDelayed(mLongPressCallback, LONG_PRESS_LENGTH);
+ break;
+ case MotionEvent.ACTION_UP:
+ if (mUpToSpeed) {
+ startExitAnimation();
+ } else {
+ cancelLongClick();
+ }
+ break;
+ case MotionEvent.ACTION_CANCEL:
+ cancelLongClick();
+ break;
+ case MotionEvent.ACTION_MOVE:
+ float x = event.getX();
+ float y = event.getY();
+ if ((x < -mSlop) || (y < -mSlop) || (x > getWidth() + mSlop)
+ || (y > getHeight() + mSlop)) {
+ cancelLongClick();
+ }
+ break;
+ }
+ return super.onTouchEvent(event);
+ }
+
+ private void cancelLongClick() {
+ cancelAnimation();
+ mUpToSpeed = false;
+ removeCallbacks(mLongPressCallback);
+ }
+
+ private void cancelAnimation() {
+ if (mAnimator != null) {
+ mAnimator.removeAllListeners();
+ mAnimator.cancel();
+ mAnimator = null;
+ }
+ }
+
+ private void startExitAnimation() {
+ animate()
+ .translationX(((View) getParent().getParent()).getWidth() - getX())
+ .alpha(0)
+ .setDuration(RUN_DURATION)
+ .setInterpolator(AnimationUtils.loadInterpolator(mContext,
+ android.R.interpolator.accelerate_cubic))
+ .setListener(new AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ setAlpha(1f);
+ setTranslationX(0);
+ cancelLongClick();
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ }
+ })
+ .start();
+ }
+
+ protected void startAccelSpin() {
+ cancelAnimation();
+ mAnimator = ObjectAnimator.ofFloat(this, View.ROTATION, 0, 360);
+ mAnimator.setInterpolator(AnimationUtils.loadInterpolator(mContext,
+ android.R.interpolator.accelerate_quad));
+ mAnimator.setDuration(ACCEL_LENGTH);
+ mAnimator.addListener(new AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ startContinuousSpin();
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ }
+ });
+ mAnimator.start();
+ }
+
+ protected void startContinuousSpin() {
+ cancelAnimation();
+ mUpToSpeed = true;
+ mAnimator = ObjectAnimator.ofFloat(this, View.ROTATION, 0, 360);
+ mAnimator.setInterpolator(AnimationUtils.loadInterpolator(mContext,
+ android.R.interpolator.linear));
+ mAnimator.setDuration(FULL_SPEED_LENGTH);
+ mAnimator.setRepeatCount(Animation.INFINITE);
+ mAnimator.start();
+ }
+
+ private final Runnable mLongPressCallback = new Runnable() {
+ @Override
+ public void run() {
+ startAccelSpin();
+ }
+ };
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
index a81f06e2..5d58cd0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
@@ -37,6 +37,7 @@
import android.widget.RelativeLayout;
import android.widget.Switch;
import android.widget.TextView;
+import android.widget.Toast;
import com.android.keyguard.KeyguardStatusView;
import com.android.systemui.BatteryMeterView;
@@ -48,6 +49,7 @@
import com.android.systemui.statusbar.policy.NetworkControllerImpl.EmergencyListener;
import com.android.systemui.statusbar.policy.NextAlarmController;
import com.android.systemui.statusbar.policy.UserInfoController;
+import com.android.systemui.tuner.TunerService;
import java.text.NumberFormat;
@@ -73,7 +75,8 @@
private TextView mDateExpanded;
private LinearLayout mSystemIcons;
private View mSignalCluster;
- private View mSettingsButton;
+ private SettingsButton mSettingsButton;
+ private View mSettingsContainer;
private View mQsDetailHeader;
private TextView mQsDetailHeaderTitle;
private Switch mQsDetailHeaderSwitch;
@@ -142,7 +145,8 @@
mMultiUserAvatar = (ImageView) findViewById(R.id.multi_user_avatar);
mDateCollapsed = (TextView) findViewById(R.id.date_collapsed);
mDateExpanded = (TextView) findViewById(R.id.date_expanded);
- mSettingsButton = findViewById(R.id.settings_button);
+ mSettingsButton = (SettingsButton) findViewById(R.id.settings_button);
+ mSettingsContainer = findViewById(R.id.settings_button_container);
mSettingsButton.setOnClickListener(this);
mQsDetailHeader = findViewById(R.id.qs_detail_header);
mQsDetailHeader.setAlpha(0);
@@ -323,13 +327,15 @@
mDateCollapsed.setVisibility(mExpanded && mAlarmShowing ? View.VISIBLE : View.INVISIBLE);
mDateExpanded.setVisibility(mExpanded && mAlarmShowing ? View.INVISIBLE : View.VISIBLE);
mAlarmStatus.setVisibility(mExpanded && mAlarmShowing ? View.VISIBLE : View.INVISIBLE);
- mSettingsButton.setVisibility(mExpanded ? View.VISIBLE : View.INVISIBLE);
+ mSettingsContainer.setVisibility(mExpanded ? View.VISIBLE : View.INVISIBLE);
mQsDetailHeader.setVisibility(mExpanded && mShowingDetail? View.VISIBLE : View.INVISIBLE);
if (mSignalCluster != null) {
updateSignalClusterDetachment();
}
mEmergencyCallsOnly.setVisibility(mExpanded && mShowEmergencyCallsOnly ? VISIBLE : GONE);
mBatteryLevel.setVisibility(mExpanded ? View.VISIBLE : View.GONE);
+ mSettingsContainer.findViewById(R.id.tuner_icon).setVisibility(
+ TunerService.isTunerEnabled(mContext) ? View.VISIBLE : View.INVISIBLE);
}
private void updateSignalClusterDetachment() {
@@ -352,7 +358,7 @@
private void updateSystemIconsLayoutParams() {
RelativeLayout.LayoutParams lp = (LayoutParams) mSystemIconsSuperContainer.getLayoutParams();
int rule = mExpanded
- ? mSettingsButton.getId()
+ ? mSettingsContainer.getId()
: mMultiUserSwitch.getId();
if (rule != lp.getRules()[RelativeLayout.START_OF]) {
lp.addRule(RelativeLayout.START_OF, rule);
@@ -495,6 +501,20 @@
@Override
public void onClick(View v) {
if (v == mSettingsButton) {
+ if (mSettingsButton.isTunerClick()) {
+ if (TunerService.isTunerEnabled(mContext)) {
+ TunerService.showResetRequest(mContext, new Runnable() {
+ @Override
+ public void run() {
+ // Relaunch settings so that the tuner disappears.
+ startSettingsActivity();
+ }
+ });
+ } else {
+ Toast.makeText(getContext(), R.string.tuner_toast, Toast.LENGTH_LONG).show();
+ TunerService.setTunerEnabled(mContext, true);
+ }
+ }
startSettingsActivity();
} else if (v == mSystemIconsSuperContainer) {
startBatteryActivity();
@@ -567,10 +587,10 @@
}
target.batteryY = mSystemIconsSuperContainer.getTop() + mSystemIconsContainer.getTop();
target.batteryLevelAlpha = getAlphaForVisibility(mBatteryLevel);
- target.settingsAlpha = getAlphaForVisibility(mSettingsButton);
+ target.settingsAlpha = getAlphaForVisibility(mSettingsContainer);
target.settingsTranslation = mExpanded
? 0
- : mMultiUserSwitch.getLeft() - mSettingsButton.getLeft();
+ : mMultiUserSwitch.getLeft() - mSettingsContainer.getLeft();
target.signalClusterAlpha = mSignalClusterDetached ? 0f : 1f;
target.settingsRotation = !mExpanded ? 90f : 0f;
}
@@ -622,9 +642,11 @@
mSignalCluster.setTranslationX(0f);
mSignalCluster.setTranslationY(0f);
}
- mSettingsButton.setTranslationY(mSystemIconsSuperContainer.getTranslationY());
- mSettingsButton.setTranslationX(values.settingsTranslation);
- mSettingsButton.setRotation(values.settingsRotation);
+ if (!mSettingsButton.isAnimating()) {
+ mSettingsContainer.setTranslationY(mSystemIconsSuperContainer.getTranslationY());
+ mSettingsContainer.setTranslationX(values.settingsTranslation);
+ mSettingsButton.setRotation(values.settingsRotation);
+ }
applyAlpha(mEmergencyCallsOnly, values.emergencyCallsOnlyAlpha);
if (!mShowingDetail && !mDetailTransitioning) {
// Otherwise it needs to stay invisible
@@ -633,7 +655,7 @@
applyAlpha(mDateCollapsed, values.dateCollapsedAlpha);
applyAlpha(mDateExpanded, values.dateExpandedAlpha);
applyAlpha(mBatteryLevel, values.batteryLevelAlpha);
- applyAlpha(mSettingsButton, values.settingsAlpha);
+ applyAlpha(mSettingsContainer, values.settingsAlpha);
applyAlpha(mSignalCluster, values.signalClusterAlpha);
if (!mExpanded) {
mTime.setScaleX(1f);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
index a69416a..e622144 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -19,15 +19,12 @@
import android.content.ComponentCallbacks2;
import android.content.Context;
import android.os.Bundle;
-import android.os.RemoteException;
import android.os.SystemClock;
-import android.util.Slog;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManagerGlobal;
-import com.android.internal.policy.IKeyguardShowCallback;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.ViewMediatorCallback;
@@ -163,26 +160,10 @@
mBouncer.onScreenTurnedOff();
}
- public void onScreenTurnedOn(final IKeyguardShowCallback callback) {
+ public void onScreenTurnedOn() {
mScreenOn = true;
mScreenWillWakeUp = false;
mPhoneStatusBar.onScreenTurnedOn();
- if (callback != null) {
- callbackAfterDraw(callback);
- }
- }
-
- private void callbackAfterDraw(final IKeyguardShowCallback callback) {
- mContainer.post(new Runnable() {
- @Override
- public void run() {
- try {
- callback.onShown(mContainer.getWindowToken());
- } catch (RemoteException e) {
- Slog.w(TAG, "Exception calling onShown():", e);
- }
- }
- });
}
public void notifyScreenWakeUpRequested() {
@@ -270,16 +251,22 @@
mPhoneStatusBar.setKeyguardFadingAway(startTime, delay, fadeoutDuration);
boolean staying = mPhoneStatusBar.hideKeyguard();
if (!staying) {
- mStatusBarWindowManager.setKeyguardFadingAway(true);
- mScrimController.animateKeyguardFadingOut(delay, fadeoutDuration, new Runnable() {
- @Override
- public void run() {
- mStatusBarWindowManager.setKeyguardFadingAway(false);
- mPhoneStatusBar.finishKeyguardFadingAway();
- WindowManagerGlobal.getInstance().trimMemory(
- ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN);
- }
- });
+ if (fadeoutDuration == 0) {
+ mPhoneStatusBar.finishKeyguardFadingAway();
+ WindowManagerGlobal.getInstance().trimMemory(
+ ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN);
+ } else {
+ mStatusBarWindowManager.setKeyguardFadingAway(true);
+ mScrimController.animateKeyguardFadingOut(delay, fadeoutDuration, new Runnable() {
+ @Override
+ public void run() {
+ mStatusBarWindowManager.setKeyguardFadingAway(false);
+ mPhoneStatusBar.finishKeyguardFadingAway();
+ WindowManagerGlobal.getInstance().trimMemory(
+ ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN);
+ }
+ });
+ }
} else {
mScrimController.animateGoingToFullShade(delay, fadeoutDuration);
mPhoneStatusBar.finishKeyguardFadingAway();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java
index 6fc15a8..f31311d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java
@@ -132,7 +132,7 @@
}
@Override
- public void onFingerprintAuthenticated(int userId) {
+ public void onFingerprintAuthenticated(int userId, boolean wakeAndUnlocking) {
update(false /* updateAlways */);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
index 81f2d532..57dfff5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
@@ -31,6 +31,7 @@
import android.os.Handler;
import android.os.Looper;
import android.provider.Settings;
+import android.telephony.ServiceState;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
@@ -117,6 +118,9 @@
// Handler that all callbacks are made on.
private final CallbackHandler mCallbackHandler;
+ @VisibleForTesting
+ ServiceState mLastServiceState;
+
/**
* Construct this controller object and register for updates.
*/
@@ -194,10 +198,10 @@
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
filter.addAction(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
filter.addAction(TelephonyIntents.ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED);
+ filter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
filter.addAction(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION);
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
filter.addAction(ConnectivityManager.INET_CONDITION_ACTION);
- filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
mContext.registerReceiver(this, filter, null, mReceiverHandler);
mListening = true;
@@ -260,6 +264,11 @@
}
public boolean isEmergencyOnly() {
+ if (mMobileSignalControllers.size() == 0) {
+ // When there are no active subscriptions, determine emengency state from last
+ // broadcast.
+ return mLastServiceState != null && mLastServiceState.isEmergencyOnly();
+ }
int voiceSubId = mSubDefaults.getDefaultVoiceSubId();
if (!SubscriptionManager.isValidSubscriptionId(voiceSubId)) {
for (MobileSignalController mobileSignalController :
@@ -339,8 +348,6 @@
if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION) ||
action.equals(ConnectivityManager.INET_CONDITION_ACTION)) {
updateConnectivity();
- } else if (action.equals(Intent.ACTION_CONFIGURATION_CHANGED)) {
- handleConfigurationChanged();
} else if (action.equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)) {
refreshLocale();
updateAirplaneMode(false);
@@ -356,6 +363,13 @@
} else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
// Might have different subscriptions now.
updateMobileControllers();
+ } else if (action.equals(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED)) {
+ mLastServiceState = ServiceState.newFromBundle(intent.getExtras());
+ if (mMobileSignalControllers.size() == 0) {
+ // If none of the subscriptions are active, we might need to recalculate
+ // emergency state.
+ recalculateEmergency();
+ }
} else {
int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
@@ -373,8 +387,18 @@
}
}
- public void handleConfigurationChanged() {
+ public void onConfigurationChanged() {
mConfig = Config.readConfig(mContext);
+ mReceiverHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ handleConfigurationChanged();
+ }
+ });
+ }
+
+ @VisibleForTesting
+ void handleConfigurationChanged() {
for (MobileSignalController mobileSignalController : mMobileSignalControllers.values()) {
mobileSignalController.setConfiguration(mConfig);
}
@@ -580,6 +604,8 @@
pw.println(mAirplaneMode);
pw.print(" mLocale=");
pw.println(mLocale);
+ pw.print(" mLastServiceState=");
+ pw.println(mLastServiceState);
for (MobileSignalController mobileSignalController : mMobileSignalControllers.values()) {
mobileSignalController.dump(pw);
diff --git a/packages/SystemUI/src/com/android/systemui/tuner/DemoModeFragment.java b/packages/SystemUI/src/com/android/systemui/tuner/DemoModeFragment.java
index 3f5ca58..a2b062c 100644
--- a/packages/SystemUI/src/com/android/systemui/tuner/DemoModeFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/tuner/DemoModeFragment.java
@@ -28,13 +28,14 @@
import android.preference.PreferenceScreen;
import android.preference.SwitchPreference;
import android.provider.Settings;
+import android.view.MenuItem;
+import com.android.internal.logging.MetricsLogger;
import com.android.systemui.DemoMode;
import com.android.systemui.R;
public class DemoModeFragment extends PreferenceFragment implements OnPreferenceChangeListener {
- private static final String DEMO_MODE_ALLOWED = "sysui_demo_allowed";
private static final String DEMO_MODE_ON = "sysui_tuner_demo_on";
private static final String[] STATUS_ICONS = {
@@ -75,10 +76,33 @@
updateDemoModeEnabled();
updateDemoModeOn();
ContentResolver contentResolver = getContext().getContentResolver();
- contentResolver.registerContentObserver(Settings.Global.getUriFor(DEMO_MODE_ALLOWED), false,
- mDemoModeObserver);
+ contentResolver.registerContentObserver(Settings.Global.getUriFor(
+ DemoMode.DEMO_MODE_ALLOWED), false, mDemoModeObserver);
contentResolver.registerContentObserver(Settings.Global.getUriFor(DEMO_MODE_ON), false,
mDemoModeObserver);
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ getFragmentManager().popBackStack();
+ break;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ MetricsLogger.visibility(getContext(), MetricsLogger.TUNER_DEMO_MODE, true);
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ MetricsLogger.visibility(getContext(), MetricsLogger.TUNER_DEMO_MODE, false);
}
@Override
@@ -89,7 +113,7 @@
private void updateDemoModeEnabled() {
boolean enabled = Settings.Global.getInt(getContext().getContentResolver(),
- DEMO_MODE_ALLOWED, 0) != 0;
+ DemoMode.DEMO_MODE_ALLOWED, 0) != 0;
mEnabledSwitch.setChecked(enabled);
mOnSwitch.setEnabled(enabled);
}
@@ -102,15 +126,18 @@
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
+ boolean enabled = newValue == Boolean.TRUE;
if (preference == mEnabledSwitch) {
- if (newValue != Boolean.TRUE) {
+ if (!enabled) {
// Make sure we aren't in demo mode when disabling it.
mOnSwitch.setChecked(false);
stopDemoMode();
}
- setGlobal(DEMO_MODE_ALLOWED, newValue == Boolean.TRUE ? 1 : 0);
+ MetricsLogger.action(getContext(), MetricsLogger.TUNER_DEMO_MODE_ENABLED, enabled);
+ setGlobal(DemoMode.DEMO_MODE_ALLOWED, enabled ? 1 : 0);
} else if (preference == mOnSwitch) {
- if (newValue == Boolean.TRUE) {
+ MetricsLogger.action(getContext(), MetricsLogger.TUNER_DEMO_MODE_ON, enabled);
+ if (enabled) {
startDemoMode();
} else {
stopDemoMode();
diff --git a/packages/SystemUI/src/com/android/systemui/tuner/QsTuner.java b/packages/SystemUI/src/com/android/systemui/tuner/QsTuner.java
index a5b244e..37ac098 100644
--- a/packages/SystemUI/src/com/android/systemui/tuner/QsTuner.java
+++ b/packages/SystemUI/src/com/android/systemui/tuner/QsTuner.java
@@ -40,6 +40,7 @@
import android.widget.FrameLayout;
import android.widget.ScrollView;
+import com.android.internal.logging.MetricsLogger;
import com.android.systemui.R;
import com.android.systemui.qs.QSPanel;
import com.android.systemui.qs.QSTile;
@@ -79,12 +80,25 @@
menu.add(0, MENU_RESET, 0, com.android.internal.R.string.reset);
}
+ public void onResume() {
+ super.onResume();
+ MetricsLogger.visibility(getContext(), MetricsLogger.TUNER_QS, true);
+ }
+
+ public void onPause() {
+ super.onPause();
+ MetricsLogger.visibility(getContext(), MetricsLogger.TUNER_QS, false);
+ }
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_RESET:
mTileHost.reset();
break;
+ case android.R.id.home:
+ getFragmentManager().popBackStack();
+ break;
}
return super.onOptionsItemSelected(item);
}
@@ -205,6 +219,8 @@
if (oldTile.equals(newTile)) {
return;
}
+ MetricsLogger.action(getContext(), MetricsLogger.TUNER_QS_REORDER, oldTile + ","
+ + newTile);
List<String> order = new ArrayList<>(mTileSpecs);
int index = order.indexOf(oldTile);
if (index < 0) {
@@ -217,12 +233,14 @@
}
public void remove(String tile) {
+ MetricsLogger.action(getContext(), MetricsLogger.TUNER_QS_REMOVE, tile);
List<String> tiles = new ArrayList<>(mTileSpecs);
tiles.remove(tile);
setTiles(tiles);
}
public void add(String tile) {
+ MetricsLogger.action(getContext(), MetricsLogger.TUNER_QS_ADD, tile);
List<String> tiles = new ArrayList<>(mTileSpecs);
tiles.add(tile);
setTiles(tiles);
diff --git a/packages/SystemUI/src/com/android/systemui/tuner/StatusBarSwitch.java b/packages/SystemUI/src/com/android/systemui/tuner/StatusBarSwitch.java
index d4cc56d..e5b550e 100644
--- a/packages/SystemUI/src/com/android/systemui/tuner/StatusBarSwitch.java
+++ b/packages/SystemUI/src/com/android/systemui/tuner/StatusBarSwitch.java
@@ -23,6 +23,7 @@
import android.text.TextUtils;
import android.util.AttributeSet;
+import com.android.internal.logging.MetricsLogger;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.tuner.TunerService.Tunable;
@@ -50,11 +51,14 @@
if (!value) {
// If not enabled add to blacklist.
if (!mBlacklist.contains(getKey())) {
+ MetricsLogger.action(getContext(), MetricsLogger.TUNER_STATUS_BAR_DISABLE,
+ getKey());
mBlacklist.add(getKey());
setList(mBlacklist);
}
} else {
if (mBlacklist.remove(getKey())) {
+ MetricsLogger.action(getContext(), MetricsLogger.TUNER_STATUS_BAR_ENABLE, getKey());
setList(mBlacklist);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/tuner/TunerFragment.java b/packages/SystemUI/src/com/android/systemui/tuner/TunerFragment.java
index 4a8c2e4..71b5de5 100644
--- a/packages/SystemUI/src/com/android/systemui/tuner/TunerFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/tuner/TunerFragment.java
@@ -17,7 +17,10 @@
import static com.android.systemui.BatteryMeterView.SHOW_PERCENT_SETTING;
+import android.app.AlertDialog;
import android.app.FragmentTransaction;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Bundle;
@@ -28,19 +31,29 @@
import android.preference.PreferenceFragment;
import android.preference.PreferenceGroup;
import android.preference.SwitchPreference;
+import android.provider.Settings;
import android.provider.Settings.System;
+import android.view.Menu;
+import android.view.MenuInflater;
import android.view.MenuItem;
+import com.android.internal.logging.MetricsLogger;
import com.android.systemui.R;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.tuner.TunerService.Tunable;
public class TunerFragment extends PreferenceFragment {
+ private static final String TAG = "TunerFragment";
+
private static final String KEY_QS_TUNER = "qs_tuner";
private static final String KEY_DEMO_MODE = "demo_mode";
private static final String KEY_BATTERY_PCT = "battery_pct";
+ public static final String SETTING_SEEN_TUNER_WARNING = "seen_tuner_warning";
+
+ private static final int MENU_REMOVE = Menu.FIRST + 1;
+
private final SettingObserver mSettingObserver = new SettingObserver();
private SwitchPreference mBatteryPct;
@@ -73,6 +86,19 @@
}
});
mBatteryPct = (SwitchPreference) findPreference(KEY_BATTERY_PCT);
+ if (Settings.Secure.getInt(getContext().getContentResolver(), SETTING_SEEN_TUNER_WARNING,
+ 0) == 0) {
+ new AlertDialog.Builder(getContext())
+ .setTitle(R.string.tuner_warning_title)
+ .setMessage(R.string.tuner_warning)
+ .setPositiveButton(R.string.got_it, new OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Settings.Secure.putInt(getContext().getContentResolver(),
+ SETTING_SEEN_TUNER_WARNING, 1);
+ }
+ }).show();
+ }
}
@Override
@@ -83,6 +109,7 @@
System.getUriFor(SHOW_PERCENT_SETTING), false, mSettingObserver);
registerPrefs(getPreferenceScreen());
+ MetricsLogger.visibility(getContext(), MetricsLogger.TUNER, true);
}
@Override
@@ -91,6 +118,7 @@
getContext().getContentResolver().unregisterContentObserver(mSettingObserver);
unregisterPrefs(getPreferenceScreen());
+ MetricsLogger.visibility(getContext(), MetricsLogger.TUNER, false);
}
private void registerPrefs(PreferenceGroup group) {
@@ -120,11 +148,24 @@
}
@Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ menu.add(Menu.NONE, MENU_REMOVE, Menu.NONE, R.string.remove_from_settings);
+ }
+
+ @Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
getActivity().finish();
return true;
+ case MENU_REMOVE:
+ TunerService.showResetRequest(getContext(), new Runnable() {
+ @Override
+ public void run() {
+ getActivity().finish();
+ }
+ });
+ return true;
}
return super.onOptionsItemSelected(item);
}
@@ -152,6 +193,7 @@
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean v = (Boolean) newValue;
+ MetricsLogger.action(getContext(), MetricsLogger.TUNER_BATTERY_PERCENTAGE, v);
System.putInt(getContext().getContentResolver(), SHOW_PERCENT_SETTING, v ? 1 : 0);
return true;
}
diff --git a/packages/SystemUI/src/com/android/systemui/tuner/TunerService.java b/packages/SystemUI/src/com/android/systemui/tuner/TunerService.java
index de5aaf6..d3f33ab 100644
--- a/packages/SystemUI/src/com/android/systemui/tuner/TunerService.java
+++ b/packages/SystemUI/src/com/android/systemui/tuner/TunerService.java
@@ -16,8 +16,15 @@
package com.android.systemui.tuner;
import android.app.ActivityManager;
+import android.app.AlertDialog;
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
+import android.content.Intent;
+import android.content.pm.PackageManager;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Handler;
@@ -25,9 +32,13 @@
import android.provider.Settings;
import android.util.ArrayMap;
+import com.android.systemui.BatteryMeterView;
+import com.android.systemui.DemoMode;
+import com.android.systemui.R;
import com.android.systemui.SystemUI;
import com.android.systemui.SystemUIApplication;
import com.android.systemui.settings.CurrentUserTracker;
+import com.android.systemui.statusbar.phone.SystemUIDialog;
import java.util.ArrayList;
import java.util.HashMap;
@@ -36,6 +47,8 @@
public class TunerService extends SystemUI {
+ public static final String ACTION_CLEAR = "com.android.systemui.action.CLEAR_TUNER";
+
private final Observer mObserver = new Observer();
// Map of Uris we listen on to their settings keys.
private final ArrayMap<Uri, String> mListeningUris = new ArrayMap<>();
@@ -118,6 +131,19 @@
}
}
+ public void clearAll() {
+ // A couple special cases.
+ Settings.Global.putString(mContentResolver, DemoMode.DEMO_MODE_ALLOWED, null);
+ Settings.System.putString(mContentResolver, BatteryMeterView.SHOW_PERCENT_SETTING, null);
+ Intent intent = new Intent(DemoMode.ACTION_DEMO);
+ intent.putExtra(DemoMode.EXTRA_COMMAND, DemoMode.COMMAND_EXIT);
+ mContext.sendBroadcast(intent);
+
+ for (String key : mTunableLookup.keySet()) {
+ Settings.Secure.putString(mContentResolver, key, null);
+ }
+ }
+
// Only used in other processes, such as the tuner.
private static TunerService sInstance;
@@ -141,6 +167,44 @@
return sInstance;
}
+ public static final void showResetRequest(final Context context, final Runnable onDisabled) {
+ SystemUIDialog dialog = new SystemUIDialog(context);
+ dialog.setMessage(R.string.remove_from_settings_prompt);
+ dialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(R.string.cancel),
+ (OnClickListener) null);
+ dialog.setButton(DialogInterface.BUTTON_POSITIVE,
+ context.getString(R.string.guest_exit_guest_dialog_remove), new OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ // Tell the tuner (in main SysUI process) to clear all its settings.
+ context.sendBroadcast(new Intent(TunerService.ACTION_CLEAR));
+ // Disable access to tuner.
+ TunerService.setTunerEnabled(context, false);
+ // Make them sit through the warning dialog again.
+ Settings.Secure.putInt(context.getContentResolver(),
+ TunerFragment.SETTING_SEEN_TUNER_WARNING, 0);
+ if (onDisabled != null) {
+ onDisabled.run();
+ }
+ }
+ });
+ dialog.show();
+ }
+
+ public static final void setTunerEnabled(Context context, boolean enabled) {
+ context.getPackageManager().setComponentEnabledSetting(
+ new ComponentName(context, TunerActivity.class),
+ enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
+ : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
+ PackageManager.DONT_KILL_APP);
+ }
+
+ public static final boolean isTunerEnabled(Context context) {
+ return context.getPackageManager().getComponentEnabledSetting(
+ new ComponentName(context, TunerActivity.class))
+ == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
+ }
+
private class Observer extends ContentObserver {
public Observer() {
super(new Handler(Looper.getMainLooper()));
@@ -157,4 +221,13 @@
public interface Tunable {
void onTuningChanged(String key, String newValue);
}
+
+ public static class ClearReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (ACTION_CLEAR.equals(intent.getAction())) {
+ get(context).clearAll();
+ }
+ }
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java
index 52dea40..d9b9063 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java
@@ -21,6 +21,7 @@
import android.net.ConnectivityManager;
import android.net.NetworkCapabilities;
import android.os.Looper;
+import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SubscriptionInfo;
import android.telephony.TelephonyManager;
@@ -70,11 +71,20 @@
public void testEmergencyOnlyNoSubscriptions() {
setupDefaultSignal();
+ setSubscriptions();
+ mNetworkController.mLastServiceState = new ServiceState();
+ mNetworkController.mLastServiceState.setEmergencyOnly(true);
+ mNetworkController.recalculateEmergency();
+ verifyEmergencyOnly(true);
+ }
+
+ public void testNoEmengencyNoSubscriptions() {
+ setupDefaultSignal();
+ setSubscriptions();
+ mNetworkController.mLastServiceState = new ServiceState();
+ mNetworkController.mLastServiceState.setEmergencyOnly(false);
mNetworkController.recalculateEmergency();
verifyEmergencyOnly(false);
-
- setSubscriptions();
- verifyEmergencyOnly(true);
}
public void testNoSimlessIconWithoutMobile() {
diff --git a/services/core/java/com/android/server/AssetAtlasService.java b/services/core/java/com/android/server/AssetAtlasService.java
index ebc810f..4569dae 100644
--- a/services/core/java/com/android/server/AssetAtlasService.java
+++ b/services/core/java/com/android/server/AssetAtlasService.java
@@ -93,7 +93,7 @@
// Defines the number of int fields used to represent a single entry
// in the atlas map. This number defines the size of the array returned
// by the getMap(). See the mAtlasMap field for more information
- private static final int ATLAS_MAP_ENTRY_FIELD_COUNT = 4;
+ private static final int ATLAS_MAP_ENTRY_FIELD_COUNT = 3;
// Specifies how our GraphicBuffer will be used. To get proper swizzling
// the buffer will be written to using OpenGL (from JNI) so we can leave
diff --git a/services/core/java/com/android/server/DeviceIdleController.java b/services/core/java/com/android/server/DeviceIdleController.java
index c7c9d29..7561c7d 100644
--- a/services/core/java/com/android/server/DeviceIdleController.java
+++ b/services/core/java/com/android/server/DeviceIdleController.java
@@ -253,6 +253,8 @@
"max_temp_app_whitelist_duration";
private static final String KEY_MMS_TEMP_APP_WHITELIST_DURATION =
"mms_temp_app_whitelist_duration";
+ private static final String KEY_SMS_TEMP_APP_WHITELIST_DURATION =
+ "sms_temp_app_whitelist_duration";
/**
* This is the time, after becoming inactive, at which we start looking at the
@@ -357,6 +359,13 @@
*/
public long MMS_TEMP_APP_WHITELIST_DURATION;
+ /**
+ * Amount of time we would like to whitelist an app that is receiving an SMS.
+ * @see Settings.Global#DEVICE_IDLE_CONSTANTS
+ * @see #KEY_SMS_TEMP_APP_WHITELIST_DURATION
+ */
+ public long SMS_TEMP_APP_WHITELIST_DURATION;
+
private final ContentResolver mResolver;
private final KeyValueListParser mParser = new KeyValueListParser(',');
@@ -410,6 +419,8 @@
KEY_MAX_TEMP_APP_WHITELIST_DURATION, 5 * 60 * 1000L);
MMS_TEMP_APP_WHITELIST_DURATION = mParser.getLong(
KEY_MMS_TEMP_APP_WHITELIST_DURATION, 60 * 1000L);
+ SMS_TEMP_APP_WHITELIST_DURATION = mParser.getLong(
+ KEY_SMS_TEMP_APP_WHITELIST_DURATION, 20 * 1000L);
}
}
@@ -465,6 +476,10 @@
pw.print(" "); pw.print(KEY_MMS_TEMP_APP_WHITELIST_DURATION); pw.print("=");
TimeUtils.formatDuration(MMS_TEMP_APP_WHITELIST_DURATION, pw);
pw.println();
+
+ pw.print(" "); pw.print(KEY_SMS_TEMP_APP_WHITELIST_DURATION); pw.print("=");
+ TimeUtils.formatDuration(SMS_TEMP_APP_WHITELIST_DURATION, pw);
+ pw.println();
}
}
@@ -617,6 +632,13 @@
return duration;
}
+ @Override public long addPowerSaveTempWhitelistAppForSms(String packageName,
+ int userId, String reason) throws RemoteException {
+ long duration = mConstants.SMS_TEMP_APP_WHITELIST_DURATION;
+ addPowerSaveTempWhitelistApp(packageName, duration, userId, reason);
+ return duration;
+ }
+
@Override public void exitIdle(String reason) {
getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,
null);
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java
index dbe8781..64ee5f1 100644
--- a/services/core/java/com/android/server/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/InputMethodManagerService.java
@@ -114,6 +114,7 @@
import android.view.inputmethod.InputMethod;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
+import android.view.inputmethod.InputMethodManagerInternal;
import android.view.inputmethod.InputMethodSubtype;
import android.view.inputmethod.InputMethodSubtype.InputMethodSubtypeBuilder;
import android.widget.ArrayAdapter;
@@ -166,6 +167,7 @@
static final int MSG_UNBIND_METHOD = 3000;
static final int MSG_BIND_METHOD = 3010;
static final int MSG_SET_ACTIVE = 3020;
+ static final int MSG_SET_INTERACTIVE = 3030;
static final int MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER = 3040;
static final int MSG_HARD_KEYBOARD_SWITCH_CHANGED = 4000;
@@ -394,9 +396,9 @@
SessionState mEnabledSession;
/**
- * True if the screen is on. The value is true initially.
+ * True if the device is currently interactive with user. The value is true initially.
*/
- boolean mScreenOn = true;
+ boolean mIsInteractive = true;
int mCurUserActionNotificationSequenceNumber = 0;
@@ -492,30 +494,12 @@
}
class ImmsBroadcastReceiver extends android.content.BroadcastReceiver {
- private void updateActive() {
- // Inform the current client of the change in active status
- if (mCurClient != null && mCurClient.client != null) {
- executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO(
- MSG_SET_ACTIVE, mScreenOn ? 1 : 0, mCurClient));
- }
- }
-
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
- if (Intent.ACTION_SCREEN_ON.equals(action)) {
- mScreenOn = true;
- updateSystemUi(mCurToken, mImeWindowVis, mBackDisposition);
- updateActive();
- return;
- } else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
- mScreenOn = false;
- updateSystemUi(mCurToken, 0 /* vis */, mBackDisposition);
- updateActive();
- return;
- } else if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
+ if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
hideInputMethodMenu();
- // No need to updateActive
+ // No need to update mIsInteractive
return;
} else if (Intent.ACTION_USER_ADDED.equals(action)
|| Intent.ACTION_USER_REMOVED.equals(action)) {
@@ -817,8 +801,6 @@
mShowOngoingImeSwitcherForPhones = false;
final IntentFilter broadcastFilter = new IntentFilter();
- broadcastFilter.addAction(Intent.ACTION_SCREEN_ON);
- broadcastFilter.addAction(Intent.ACTION_SCREEN_OFF);
broadcastFilter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
broadcastFilter.addAction(Intent.ACTION_USER_ADDED);
broadcastFilter.addAction(Intent.ACTION_USER_REMOVED);
@@ -938,6 +920,7 @@
}
}
}, filter);
+ LocalServices.addService(InputMethodManagerInternal.class, new LocalServiceImpl(mHandler));
}
private void resetDefaultImeLocked(Context context) {
@@ -1379,9 +1362,9 @@
+ cs.client.asBinder() + " keyguard=" + mCurClientInKeyguard);
// If the screen is on, inform the new client it is active
- if (mScreenOn) {
+ if (mIsInteractive) {
executeOrSendMessage(cs.client, mCaller.obtainMessageIO(
- MSG_SET_ACTIVE, mScreenOn ? 1 : 0, cs));
+ MSG_SET_ACTIVE, mIsInteractive ? 1 : 0, cs));
}
}
@@ -2851,6 +2834,9 @@
+ ((ClientState)msg.obj).uid);
}
return true;
+ case MSG_SET_INTERACTIVE:
+ handleSetInteractive(msg.arg1 != 0);
+ return true;
case MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER: {
final int sequenceNumber = msg.arg1;
final ClientState clientState = (ClientState)msg.obj;
@@ -2874,6 +2860,19 @@
return false;
}
+ private void handleSetInteractive(final boolean interactive) {
+ synchronized (mMethodMap) {
+ mIsInteractive = interactive;
+ updateSystemUiLocked(mCurToken, interactive ? mImeWindowVis : 0, mBackDisposition);
+
+ // Inform the current client of the change in active status
+ if (mCurClient != null && mCurClient.client != null) {
+ executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO(
+ MSG_SET_ACTIVE, mIsInteractive ? 1 : 0, mCurClient));
+ }
+ }
+ }
+
private boolean chooseNewDefaultIMELocked() {
final InputMethodInfo imi = InputMethodUtils.getMostApplicableDefaultIME(
mSettings.getEnabledInputMethodListLocked());
@@ -3734,6 +3733,22 @@
}
}
+ private static final class LocalServiceImpl implements InputMethodManagerInternal {
+ @NonNull
+ private final Handler mHandler;
+
+ LocalServiceImpl(@NonNull final Handler handler) {
+ mHandler = handler;
+ }
+
+ @Override
+ public void setInteractive(boolean interactive) {
+ // Do everything in handler so as not to block the caller.
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_SET_INTERACTIVE,
+ interactive ? 1 : 0, 0));
+ }
+ }
+
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
@@ -3784,7 +3799,7 @@
+ " mInputShown=" + mInputShown);
p.println(" mCurUserActionNotificationSequenceNumber="
+ mCurUserActionNotificationSequenceNumber);
- p.println(" mSystemReady=" + mSystemReady + " mInteractive=" + mScreenOn);
+ p.println(" mSystemReady=" + mSystemReady + " mInteractive=" + mIsInteractive);
p.println(" mSettingsObserver=" + mSettingsObserver);
p.println(" mSwitchingController:");
mSwitchingController.dump(p);
diff --git a/services/core/java/com/android/server/MountService.java b/services/core/java/com/android/server/MountService.java
index 92b98a7..ed136e9 100644
--- a/services/core/java/com/android/server/MountService.java
+++ b/services/core/java/com/android/server/MountService.java
@@ -3431,6 +3431,11 @@
}
public boolean hasExternalStorage(int uid, String packageName) {
+ // No need to check for system uid. This avoids a deadlock between
+ // PackageManagerService and AppOpsService.
+ if (uid == Process.SYSTEM_UID) {
+ return true;
+ }
// No locking - CopyOnWriteArrayList
for (ExternalStorageMountPolicy policy : mPolicies) {
final boolean policyHasStorage = policy.hasExternalStorage(uid, packageName);
diff --git a/services/core/java/com/android/server/accounts/AccountManagerService.java b/services/core/java/com/android/server/accounts/AccountManagerService.java
index cb294fd..32fd56a 100644
--- a/services/core/java/com/android/server/accounts/AccountManagerService.java
+++ b/services/core/java/com/android/server/accounts/AccountManagerService.java
@@ -3799,7 +3799,8 @@
* access accounts of the specified account.
*/
boolean isPermitted =
- isPermitted(callingUid, Manifest.permission.GET_ACCOUNTS);
+ isPermitted(callingUid, Manifest.permission.GET_ACCOUNTS,
+ Manifest.permission.GET_ACCOUNTS_PRIVILEGED);
boolean isAccountManagedByCaller = isAccountManagedByCaller(accountType, callingUid);
Log.w(TAG, String.format(
"isReadAccountPermitted: isPermitted: %s, isAM: %s",
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index eb6579c9..bad0668 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -1355,6 +1355,7 @@
static final int DISPATCH_UIDS_CHANGED_MSG = 54;
static final int REPORT_TIME_TRACKER_MSG = 55;
static final int REPORT_USER_SWITCH_COMPLETE_MSG = 56;
+ static final int SHUTDOWN_UI_AUTOMATION_CONNECTION_MSG = 57;
static final int FIRST_ACTIVITY_STACK_MSG = 100;
static final int FIRST_BROADCAST_QUEUE_MSG = 200;
@@ -2019,6 +2020,17 @@
case REPORT_USER_SWITCH_COMPLETE_MSG: {
dispatchUserSwitchComplete(msg.arg1);
} break;
+ case SHUTDOWN_UI_AUTOMATION_CONNECTION_MSG: {
+ IUiAutomationConnection connection = (IUiAutomationConnection) msg.obj;
+ try {
+ connection.shutdown();
+ } catch (RemoteException e) {
+ Slog.w(TAG, "Error shutting down UiAutomationConnection");
+ }
+ // Only a UiAutomation can set this flag and now that
+ // it is finished we make sure it is reset to its default.
+ mUserIsMonkey = false;
+ } break;
}
}
};
@@ -3640,7 +3652,7 @@
@Override
public boolean setProcessMemoryTrimLevel(String process, int userId, int level) {
synchronized (this) {
- final ProcessRecord app = getProcessRecordLocked(process, userId, true);
+ final ProcessRecord app = findProcessLocked(process, userId, "setProcessMemoryTrimLevel");
if (app == null) {
return false;
}
@@ -17102,16 +17114,11 @@
} catch (RemoteException e) {
}
}
- if (app.instrumentationUiAutomationConnection != null) {
- try {
- app.instrumentationUiAutomationConnection.shutdown();
- } catch (RemoteException re) {
- /* ignore */
- }
- // Only a UiAutomation can set this flag and now that
- // it is finished we make sure it is reset to its default.
- mUserIsMonkey = false;
- }
+
+ // Can't call out of the system process with a lock held, so post a message.
+ mHandler.obtainMessage(SHUTDOWN_UI_AUTOMATION_CONNECTION_MSG,
+ app.instrumentationUiAutomationConnection).sendToTarget();
+
app.instrumentationWatcher = null;
app.instrumentationUiAutomationConnection = null;
app.instrumentationClass = null;
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index e57e3ff..a75cc48 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -617,12 +617,9 @@
for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
ActivityRecord r = activities.get(activityNdx);
if (notCurrentUserTask && (r.info.flags & FLAG_SHOW_FOR_ALL_USERS) == 0) {
- return null;
+ continue;
}
if (!r.finishing && r.intent.getComponent().equals(cls) && r.userId == userId) {
- //Slog.i(TAG, "Found matching class!");
- //dump();
- //Slog.i(TAG, "For Intent " + intent + " bringing to top: " + r.intent);
return r;
}
}
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index eef3d63..1223a00 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -5126,6 +5126,11 @@
if (UserHandle.getAppId(pkg.applicationInfo.uid) < FIRST_APPLICATION_UID) {
continue;
}
+ // Skip packages that have permission to interact across users
+ if (pm.checkPermission(Manifest.permission.INTERACT_ACROSS_USERS, pkg.packageName)
+ == PackageManager.PERMISSION_GRANTED) {
+ continue;
+ }
if (homeActivityName != null
&& pkg.packageName.equals(homeActivityName.getPackageName())
&& pkg.applicationInfo.isSystemApp()) {
diff --git a/services/core/java/com/android/server/fingerprint/FingerprintService.java b/services/core/java/com/android/server/fingerprint/FingerprintService.java
index 8871e64..c705fbf 100644
--- a/services/core/java/com/android/server/fingerprint/FingerprintService.java
+++ b/services/core/java/com/android/server/fingerprint/FingerprintService.java
@@ -74,7 +74,6 @@
private static final int MSG_USER_SWITCHING = 10;
private static final int ENROLLMENT_TIMEOUT_MS = 60 * 1000; // 1 minute
- private boolean mIsKeyguard; // true if the authentication client is keyguard
private ClientMonitor mAuthClient = null;
private ClientMonitor mEnrollClient = null;
private ClientMonitor mRemoveClient = null;
@@ -124,20 +123,29 @@
public void binderDied() {
Slog.v(TAG, "fingerprintd died");
mDaemon = null;
+ dispatchError(mHalDeviceId, FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE);
}
public IFingerprintDaemon getFingerprintDaemon() {
if (mDaemon == null) {
mDaemon = IFingerprintDaemon.Stub.asInterface(ServiceManager.getService(FINGERPRINTD));
- if (mDaemon == null) {
- Slog.w(TAG, "fingerprind service not available");
- } else {
+ if (mDaemon != null) {
try {
mDaemon.asBinder().linkToDeath(this, 0);
- } catch (RemoteException e) {
- Slog.w(TAG, "caught remote exception in linkToDeath: ", e);
- mDaemon = null; // try again!
+ mDaemon.init(mDaemonCallback);
+ mHalDeviceId = mDaemon.openHal();
+ if (mHalDeviceId != 0) {
+ updateActiveGroup(ActivityManager.getCurrentUser());
+ } else {
+ Slog.w(TAG, "Failed to open Fingerprint HAL!");
+ mDaemon = null;
+ }
+ } catch (RemoteException e) {
+ Slog.e(TAG, "Failed to open fingeprintd HAL", e);
+ mDaemon = null; // try again later!
}
+ } else {
+ Slog.w(TAG, "fingerprint service not available");
}
}
return mDaemon;
@@ -156,7 +164,6 @@
protected void dispatchRemoved(long deviceId, int fingerId, int groupId) {
final ClientMonitor client = mRemoveClient;
if (fingerId != 0) {
- ContentResolver res = mContext.getContentResolver();
removeTemplateForUser(mRemoveClient, fingerId);
}
if (client != null && client.sendRemoved(fingerId, groupId)) {
@@ -577,12 +584,6 @@
result |= true; // we have a valid fingerprint
mLockoutReset.run();
}
- // For fingerprint devices that support touch-to-wake, this will ensure the device
- // wakes up and turns the screen on when fingerprint is authenticated.
- if (mIsKeyguard && authenticated) {
- mPowerManager.wakeUp(SystemClock.uptimeMillis(),
- "android.server.fingerprint:AUTH");
- }
return result;
}
@@ -727,7 +728,6 @@
mHandler.post(new Runnable() {
@Override
public void run() {
- mIsKeyguard = KEYGUARD_PACKAGE.equals(opPackageName);
startAuthentication(token, opId, groupId, receiver, flags, restricted);
}
});
@@ -821,15 +821,6 @@
public void onStart() {
publishBinderService(Context.FINGERPRINT_SERVICE, new FingerprintServiceWrapper());
IFingerprintDaemon daemon = getFingerprintDaemon();
- if (daemon != null) {
- try {
- daemon.init(mDaemonCallback);
- mHalDeviceId = daemon.openHal();
- updateActiveGroup(ActivityManager.getCurrentUser());
- } catch (RemoteException e) {
- Slog.e(TAG, "Failed to open fingeprintd HAL", e);
- }
- }
if (DEBUG) Slog.v(TAG, "Fingerprint HAL id: " + mHalDeviceId);
listenForUserSwitches();
}
diff --git a/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java b/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java
index f04790e..0d1d1ea 100644
--- a/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java
+++ b/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java
@@ -495,6 +495,16 @@
}
}
+ // Voice recognition
+ Intent voiceRecoIntent = new Intent("android.speech.RecognitionService");
+ voiceRecoIntent.addCategory(Intent.CATEGORY_DEFAULT);
+ PackageParser.Package voiceRecoPackage = getDefaultSystemHandlerServicePackageLPr(
+ voiceRecoIntent, userId);
+ if (voiceRecoPackage != null
+ && doesPackageSupportRuntimePermissions(voiceRecoPackage)) {
+ grantRuntimePermissionsLPw(voiceRecoPackage, MICROPHONE_PERMISSIONS, userId);
+ }
+
// Location
if (locationPackageNames != null) {
for (String packageName : locationPackageNames) {
@@ -627,6 +637,26 @@
return null;
}
+ private PackageParser.Package getDefaultSystemHandlerServicePackageLPr(
+ Intent intent, int userId) {
+ List<ResolveInfo> handlers = mService.queryIntentServices(intent,
+ intent.resolveType(mService.mContext.getContentResolver()),
+ PackageManager.GET_DISABLED_COMPONENTS, userId);
+ if (handlers == null) {
+ return null;
+ }
+ final int handlerCount = handlers.size();
+ for (int i = 0; i < handlerCount; i++) {
+ ResolveInfo handler = handlers.get(i);
+ PackageParser.Package handlerPackage = getSystemPackageLPr(
+ handler.serviceInfo.packageName);
+ if (handlerPackage != null) {
+ return handlerPackage;
+ }
+ }
+ return null;
+ }
+
private List<PackageParser.Package> getHeadlessSyncAdapterPackagesLPr(
String[] syncAdapterPackageNames, int userId) {
List<PackageParser.Package> syncAdapterPackages = new ArrayList<>();
diff --git a/services/core/java/com/android/server/pm/PackageInstallerService.java b/services/core/java/com/android/server/pm/PackageInstallerService.java
index 07de6f5..0366fff 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerService.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerService.java
@@ -91,7 +91,6 @@
import com.android.internal.util.ImageUtils;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.IoThread;
-import com.google.android.collect.Sets;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -106,6 +105,7 @@
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Random;
@@ -221,7 +221,7 @@
reconcileStagesLocked(StorageManager.UUID_PRIVATE_INTERNAL);
- final ArraySet<File> unclaimedIcons = Sets.newArraySet(
+ final ArraySet<File> unclaimedIcons = newArraySet(
mSessionsDir.listFiles());
// Ignore stages and icons claimed by active sessions
@@ -245,7 +245,7 @@
private void reconcileStagesLocked(String volumeUuid) {
final File stagingDir = buildStagingDir(volumeUuid);
- final ArraySet<File> unclaimedStages = Sets.newArraySet(
+ final ArraySet<File> unclaimedStages = newArraySet(
stagingDir.listFiles(sStageFilter));
// Ignore stages claimed by active sessions
@@ -1091,6 +1091,15 @@
.build();
}
+ public static <E> ArraySet<E> newArraySet(E... elements) {
+ final ArraySet<E> set = new ArraySet<E>();
+ if (elements != null) {
+ set.ensureCapacity(elements.length);
+ Collections.addAll(set, elements);
+ }
+ return set;
+ }
+
private static class Callbacks extends Handler {
private static final int MSG_SESSION_CREATED = 1;
private static final int MSG_SESSION_BADGING_CHANGED = 2;
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index c139389..61ed1a7 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -3555,7 +3555,7 @@
continue;
}
PackageSetting ps = (PackageSetting) pkg.mExtras;
- resetUserChangesToRuntimePermissionsAndFlagsLocked(ps, userId);
+ resetUserChangesToRuntimePermissionsAndFlagsLPw(ps, userId);
}
}
}
@@ -3605,10 +3605,14 @@
enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false,
"updatePermissionFlags");
- // Only the system can change system fixed flags.
+ // Only the system can change these flags and nothing else.
if (getCallingUid() != Process.SYSTEM_UID) {
flagMask &= ~PackageManager.FLAG_PERMISSION_SYSTEM_FIXED;
flagValues &= ~PackageManager.FLAG_PERMISSION_SYSTEM_FIXED;
+ flagMask &= ~PackageManager.FLAG_PERMISSION_POLICY_FIXED;
+ flagValues &= ~PackageManager.FLAG_PERMISSION_POLICY_FIXED;
+ flagMask &= ~PackageManager.FLAG_PERMISSION_GRANTED_BY_DEFAULT;
+ flagValues &= ~PackageManager.FLAG_PERMISSION_GRANTED_BY_DEFAULT;
}
synchronized (mPackages) {
@@ -7321,6 +7325,9 @@
for (i=0; i<N; i++) {
PackageParser.Permission p = pkg.permissions.get(i);
+ // Assume by default that we did not install this permission into the system.
+ p.info.flags &= ~PermissionInfo.FLAG_INSTALLED;
+
// Now that permission groups have a special meaning, we ignore permission
// groups for legacy apps to prevent unexpected behavior. In particular,
// permissions for one app being granted to someone just becuase they happen
@@ -7350,6 +7357,7 @@
bp.perm = p;
bp.uid = pkg.applicationInfo.uid;
bp.sourcePackage = p.info.packageName;
+ p.info.flags |= PermissionInfo.FLAG_INSTALLED;
} else if (!currentOwnerIsSystem) {
String msg = "New decl " + p.owner + " of permission "
+ p.info.name + " is system; overriding " + bp.sourcePackage;
@@ -7375,6 +7383,7 @@
bp.perm = p;
bp.uid = pkg.applicationInfo.uid;
bp.sourcePackage = p.info.packageName;
+ p.info.flags |= PermissionInfo.FLAG_INSTALLED;
if ((parseFlags&PackageParser.PARSE_CHATTY) != 0) {
if (r == null) {
r = new StringBuilder(256);
@@ -12918,10 +12927,6 @@
synchronized (mPackages) {
PackageSetting ps = mSettings.mPackages.get(newPkg.packageName);
- // Propagate the permissions state as we do want to drop on the floor
- // runtime permissions. The update permissions method below will take
- // care of removing obsolete permissions and grant install permissions.
- ps.getPermissionsState().copyFrom(disabledPs.getPermissionsState());
updatePermissionsLPw(newPkg.packageName, newPkg,
UPDATE_PERMISSIONS_ALL | UPDATE_PERMISSIONS_REPLACE_PKG);
@@ -12935,6 +12940,8 @@
+ " => " + perUserInstalled[i]);
}
ps.setInstalled(perUserInstalled[i], allUserHandles[i]);
+
+ mSettings.writeRuntimePermissionsForUserLPr(allUserHandles[i], false);
}
// Regardless of writeSettings we need to ensure that this restriction
// state propagation is persisted
@@ -13085,7 +13092,7 @@
if (clearPackagePreferredActivitiesLPw(packageName, removeUser)) {
scheduleWritePackageRestrictionsLocked(removeUser);
}
- resetUserChangesToRuntimePermissionsAndFlagsLocked(ps, removeUser);
+ resetUserChangesToRuntimePermissionsAndFlagsLPw(ps, removeUser);
}
return true;
}
@@ -13246,7 +13253,7 @@
}
PackageSetting ps = (PackageSetting) pkg.mExtras;
- resetUserChangesToRuntimePermissionsAndFlagsLocked(ps, userId);
+ resetUserChangesToRuntimePermissionsAndFlagsLPw(ps, userId);
}
// Always delete data directories for package, even if we found no other
@@ -13278,12 +13285,27 @@
}
/**
+ * Reverts user permission state changes (permissions and flags) in
+ * all packages for a given user.
+ *
+ * @param userId The device user for which to do a reset.
+ */
+ private void resetUserChangesToRuntimePermissionsAndFlagsLPw(int userId) {
+ final int packageCount = mPackages.size();
+ for (int i = 0; i < packageCount; i++) {
+ PackageParser.Package pkg = mPackages.valueAt(i);
+ PackageSetting ps = (PackageSetting) pkg.mExtras;
+ resetUserChangesToRuntimePermissionsAndFlagsLPw(ps, userId);
+ }
+ }
+
+ /**
* Reverts user permission state changes (permissions and flags).
*
* @param ps The package for which to reset.
* @param userId The device user for which to do a reset.
*/
- private void resetUserChangesToRuntimePermissionsAndFlagsLocked(
+ private void resetUserChangesToRuntimePermissionsAndFlagsLPw(
final PackageSetting ps, final int userId) {
if (ps.pkg == null) {
return;
@@ -13783,6 +13805,15 @@
}
/** This method takes a specific user id as well as UserHandle.USER_ALL. */
+ private void clearIntentFilterVerificationsLPw(int userId) {
+ final int packageCount = mPackages.size();
+ for (int i = 0; i < packageCount; i++) {
+ PackageParser.Package pkg = mPackages.valueAt(i);
+ clearIntentFilterVerificationsLPw(pkg.packageName, userId);
+ }
+ }
+
+ /** This method takes a specific user id as well as UserHandle.USER_ALL. */
void clearIntentFilterVerificationsLPw(String packageName, int userId) {
if (userId == UserHandle.USER_ALL) {
if (mSettings.removeIntentFilterVerificationLPw(packageName,
@@ -13798,7 +13829,6 @@
}
}
-
void clearDefaultBrowserIfNeeded(String packageName) {
for (int oneUserId : sUserManager.getUserIds()) {
String defaultBrowserPackageName = getDefaultBrowserPackageName(oneUserId);
@@ -13810,17 +13840,27 @@
}
@Override
- public void resetPreferredActivities(int userId) {
+ public void resetApplicationPreferences(int userId) {
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.SET_PREFERRED_APPLICATIONS, null);
// writer
synchronized (mPackages) {
- clearPackagePreferredActivitiesLPw(null, userId);
- mSettings.applyDefaultPreferredAppsLPw(this, userId);
- applyFactoryDefaultBrowserLPw(userId);
- primeDomainVerificationsLPw(userId);
-
- scheduleWritePackageRestrictionsLocked(userId);
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ clearPackagePreferredActivitiesLPw(null, userId);
+ mSettings.applyDefaultPreferredAppsLPw(this, userId);
+ // TODO: We have to reset the default SMS and Phone. This requires
+ // significant refactoring to keep all default apps in the package
+ // manager (cleaner but more work) or have the services provide
+ // callbacks to the package manager to request a default app reset.
+ applyFactoryDefaultBrowserLPw(userId);
+ clearIntentFilterVerificationsLPw(userId);
+ primeDomainVerificationsLPw(userId);
+ resetUserChangesToRuntimePermissionsAndFlagsLPw(userId);
+ scheduleWritePackageRestrictionsLocked(userId);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
}
}
@@ -14688,12 +14728,12 @@
pw.println(" s[hared-users]: dump shared user IDs");
pw.println(" m[essages]: print collected runtime messages");
pw.println(" v[erifiers]: print package verifier info");
- pw.println(" version: print database version info");
- pw.println(" write: write current settings now");
- pw.println(" <package.name>: info about given package");
- pw.println(" installs: details about install sessions");
pw.println(" d[omain-preferred-apps]: print domains preferred apps");
pw.println(" i[ntent-filter-verifiers]|ifv: print intent filter verifier info");
+ pw.println(" version: print database version info");
+ pw.println(" write: write current settings now");
+ pw.println(" installs: details about install sessions");
+ pw.println(" <package.name>: info about given package");
return;
} else if ("--checkin".equals(opt)) {
checkin = true;
@@ -15600,12 +15640,8 @@
* recycled.
*/
private void reconcileUsers(String volumeUuid) {
- final File[] files = Environment.getDataUserDirectory(volumeUuid).listFiles();
- if (ArrayUtils.isEmpty(files)) {
- Slog.d(TAG, "No users found on " + volumeUuid);
- return;
- }
-
+ final File[] files = FileUtils
+ .listFilesOrEmpty(Environment.getDataUserDirectory(volumeUuid));
for (File file : files) {
if (!file.isDirectory()) continue;
@@ -15661,12 +15697,8 @@
* another volume.
*/
private void reconcileApps(String volumeUuid) {
- final File[] files = Environment.getDataAppDirectory(volumeUuid).listFiles();
- if (ArrayUtils.isEmpty(files)) {
- Slog.d(TAG, "No apps found on " + volumeUuid);
- return;
- }
-
+ final File[] files = FileUtils
+ .listFilesOrEmpty(Environment.getDataAppDirectory(volumeUuid));
for (File file : files) {
final boolean isPackage = (isApkFile(file) || file.isDirectory())
&& !PackageInstallerService.isStageName(file.getName());
@@ -15797,7 +15829,12 @@
}
// Now that we're guarded by frozen state, kill app during move
- killApplication(packageName, appId, "move pkg");
+ final long token = Binder.clearCallingIdentity();
+ try {
+ killApplication(packageName, appId, "move pkg");
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
final Bundle extras = new Bundle();
extras.putString(Intent.EXTRA_PACKAGE_NAME, packageName);
diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java
index 92b9da6..736b153 100644
--- a/services/core/java/com/android/server/pm/Settings.java
+++ b/services/core/java/com/android/server/pm/Settings.java
@@ -4120,6 +4120,28 @@
pw.print(prefix); pw.print(" pkgFlags="); printFlags(pw, ps.pkgFlags, FLAG_DUMP_SPEC);
pw.println();
+ if (ps.pkg != null && ps.pkg.permissions != null && ps.pkg.permissions.size() > 0) {
+ final ArrayList<PackageParser.Permission> perms = ps.pkg.permissions;
+ pw.print(prefix); pw.println(" declared permissions:");
+ for (int i=0; i<perms.size(); i++) {
+ PackageParser.Permission perm = perms.get(i);
+ if (permissionNames != null
+ && !permissionNames.contains(perm.info.name)) {
+ continue;
+ }
+ pw.print(prefix); pw.print(" "); pw.print(perm.info.name);
+ pw.print(": prot=");
+ pw.print(PermissionInfo.protectionToString(perm.info.protectionLevel));
+ if ((perm.info.flags&PermissionInfo.FLAG_COSTS_MONEY) != 0) {
+ pw.print(", COSTS_MONEY");
+ }
+ if ((perm.info.flags&PermissionInfo.FLAG_INSTALLED) != 0) {
+ pw.print(", INSTALLED");
+ }
+ pw.println();
+ }
+ }
+
if (ps.sharedUser == null || permissionNames != null) {
PermissionsState permissionsState = ps.getPermissionsState();
dumpInstallPermissionsLPr(pw, prefix + " ", permissionNames, permissionsState);
@@ -4155,14 +4177,14 @@
if (cmp != null && cmp.size() > 0) {
pw.print(prefix); pw.println(" disabledComponents:");
for (String s : cmp) {
- pw.print(prefix); pw.print(" "); pw.println(s);
+ pw.print(prefix); pw.print(" "); pw.println(s);
}
}
cmp = ps.getEnabledComponents(user.id);
if (cmp != null && cmp.size() > 0) {
pw.print(prefix); pw.println(" enabledComponents:");
for (String s : cmp) {
- pw.print(prefix); pw.print(" "); pw.println(s);
+ pw.print(prefix); pw.print(" "); pw.println(s);
}
}
}
@@ -4267,11 +4289,14 @@
pw.print(" type="); pw.print(p.type);
pw.print(" prot=");
pw.println(PermissionInfo.protectionToString(p.protectionLevel));
- if (p.packageSetting != null) {
- pw.print(" packageSetting="); pw.println(p.packageSetting);
- }
if (p.perm != null) {
pw.print(" perm="); pw.println(p.perm);
+ if (p.perm.info.flags != PermissionInfo.FLAG_INSTALLED) {
+ pw.print(" flags=0x"); pw.println(Integer.toHexString(p.perm.info.flags));
+ }
+ }
+ if (p.packageSetting != null) {
+ pw.print(" packageSetting="); pw.println(p.packageSetting);
}
if (READ_EXTERNAL_STORAGE.equals(p.name)) {
pw.print(" enforced=");
@@ -4372,24 +4397,32 @@
continue;
}
pw.print(prefix); pw.print(" "); pw.print(permissionState.getName());
- pw.print(", granted="); pw.print(permissionState.isGranted());
- pw.print(", flags="); pw.println(permissionFlagsToString(
- permissionState.getFlags()));
+ pw.print(": granted="); pw.print(permissionState.isGranted());
+ pw.println(permissionFlagsToString(", flags=",
+ permissionState.getFlags()));
}
}
}
- private static String permissionFlagsToString(int flags) {
- StringBuilder flagsString = new StringBuilder();
- flagsString.append("[ ");
+ private static String permissionFlagsToString(String prefix, int flags) {
+ StringBuilder flagsString = null;
while (flags != 0) {
+ if (flagsString == null) {
+ flagsString = new StringBuilder();
+ flagsString.append(prefix);
+ flagsString.append("[ ");
+ }
final int flag = 1 << Integer.numberOfTrailingZeros(flags);
flags &= ~flag;
flagsString.append(PackageManager.permissionFlagToString(flag));
flagsString.append(' ');
}
- flagsString.append(']');
- return flagsString.toString();
+ if (flagsString != null) {
+ flagsString.append(']');
+ return flagsString.toString();
+ } else {
+ return "";
+ }
}
void dumpInstallPermissionsLPr(PrintWriter pw, String prefix, ArraySet<String> permissionNames,
@@ -4403,8 +4436,8 @@
continue;
}
pw.print(prefix); pw.print(" "); pw.print(permissionState.getName());
- pw.print(", granted="); pw.print(permissionState.isGranted());
- pw.print(", flags="); pw.println(permissionFlagsToString(
+ pw.print(": granted="); pw.print(permissionState.isGranted());
+ pw.println(permissionFlagsToString(", flags=",
permissionState.getFlags()));
}
}
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 28cbaab..dc3e2d6 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -119,7 +119,7 @@
import com.android.internal.widget.PointerLocationView;
import com.android.server.LocalServices;
import com.android.server.policy.keyguard.KeyguardServiceDelegate;
-import com.android.server.policy.keyguard.KeyguardServiceDelegate.ShowListener;
+import com.android.server.policy.keyguard.KeyguardServiceDelegate.DrawnListener;
import java.io.File;
import java.io.FileReader;
@@ -323,10 +323,10 @@
mHandler.sendEmptyMessage(MSG_WINDOW_MANAGER_DRAWN_COMPLETE);
}
};
- final ShowListener mKeyguardDelegateCallback = new ShowListener() {
+ final DrawnListener mKeyguardDrawnCallback = new DrawnListener() {
@Override
- public void onShown(IBinder windowToken) {
- if (DEBUG_WAKEUP) Slog.d(TAG, "mKeyguardDelegate.ShowListener.onShown.");
+ public void onDrawn() {
+ if (DEBUG_WAKEUP) Slog.d(TAG, "mKeyguardDelegate.ShowListener.onDrawn.");
mHandler.sendEmptyMessage(MSG_KEYGUARD_DRAWN_COMPLETE);
}
};
@@ -5496,11 +5496,7 @@
}
if (mKeyguardDelegate != null) {
- mKeyguardDelegate.onStartedWakingUp(mKeyguardDelegateCallback);
- // ... eventually calls finishKeyguardDrawn
- } else {
- if (DEBUG_WAKEUP) Slog.d(TAG, "null mKeyguardDelegate: setting mKeyguardDrawComplete.");
- finishKeyguardDrawn();
+ mKeyguardDelegate.onStartedWakingUp();
}
}
@@ -5539,9 +5535,13 @@
if (mKeyguardDelegate != null) {
mHandler.removeMessages(MSG_KEYGUARD_DRAWN_TIMEOUT);
}
+ mWindowManagerDrawComplete = false;
}
- finishScreenTurningOn();
+ // ... eventually calls finishWindowsDrawn which will finalize our screen turn on
+ // as well as enabling the orientation change logic/sensor.
+ mWindowManagerInternal.waitForAllWindowsDrawn(mWindowManagerDrawCallback,
+ WAITING_FOR_DRAWN_TIMEOUT);
}
// Called on the DisplayManager's DisplayPowerController thread.
@@ -5570,12 +5570,15 @@
mScreenOnFully = false;
mWindowManagerDrawComplete = false;
mScreenOnListener = screenOnListener;
- }
- mWindowManagerInternal.waitForAllWindowsDrawn(mWindowManagerDrawCallback,
- WAITING_FOR_DRAWN_TIMEOUT);
- // ... eventually calls finishWindowsDrawn which will finalize our screen turn on
- // as well as enabling the orientation change logic/sensor.
+ if (mKeyguardDelegate != null) {
+ mKeyguardDelegate.onScreenTurningOn(mKeyguardDrawnCallback);
+ } else {
+ if (DEBUG_WAKEUP) Slog.d(TAG,
+ "null mKeyguardDelegate: setting mKeyguardDrawComplete.");
+ finishKeyguardDrawn();
+ }
+ }
}
private void finishWindowsDrawn() {
diff --git a/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java b/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java
index 1406789..0f3a199 100644
--- a/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java
+++ b/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java
@@ -18,9 +18,9 @@
import android.view.WindowManager;
import android.view.WindowManagerPolicy.OnKeyguardExitResult;
+import com.android.internal.policy.IKeyguardDrawnCallback;
import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardService;
-import com.android.internal.policy.IKeyguardShowCallback;
/**
* A local class that keeps a cache of keyguard state that can be restored in the event
@@ -35,7 +35,7 @@
private final Context mContext;
private final View mScrim; // shown if keyguard crashes
private final KeyguardState mKeyguardState = new KeyguardState();
- private ShowListener mShowListenerWhenConnect;
+ private DrawnListener mDrawnListenerWhenConnect;
private static final class KeyguardState {
KeyguardState() {
@@ -61,23 +61,23 @@
public boolean bootCompleted;
};
- public interface ShowListener {
- public void onShown(IBinder windowToken);
+ public interface DrawnListener {
+ void onDrawn();
}
// A delegate class to map a particular invocation with a ShowListener object.
- private final class KeyguardShowDelegate extends IKeyguardShowCallback.Stub {
- private ShowListener mShowListener;
+ private final class KeyguardShowDelegate extends IKeyguardDrawnCallback.Stub {
+ private DrawnListener mDrawnListener;
- KeyguardShowDelegate(ShowListener showListener) {
- mShowListener = showListener;
+ KeyguardShowDelegate(DrawnListener drawnListener) {
+ mDrawnListener = drawnListener;
}
@Override
- public void onShown(IBinder windowToken) throws RemoteException {
+ public void onDrawn() throws RemoteException {
if (DEBUG) Log.v(TAG, "**** SHOWN CALLED ****");
- if (mShowListener != null) {
- mShowListener.onShown(windowToken);
+ if (mDrawnListener != null) {
+ mDrawnListener.onDrawn();
}
hideScrim();
}
@@ -141,9 +141,10 @@
// If the system is ready, it means keyguard crashed and restarted.
mKeyguardService.onSystemReady();
// This is used to hide the scrim once keyguard displays.
- mKeyguardService.onStartedWakingUp(new KeyguardShowDelegate(
- mShowListenerWhenConnect));
- mShowListenerWhenConnect = null;
+ mKeyguardService.onStartedWakingUp();
+ mKeyguardService.onScreenTurningOn(
+ new KeyguardShowDelegate(mDrawnListenerWhenConnect));
+ mDrawnListenerWhenConnect = null;
}
if (mKeyguardState.bootCompleted) {
mKeyguardService.onBootCompleted();
@@ -221,16 +222,23 @@
mKeyguardState.dreaming = false;
}
- public void onStartedWakingUp(final ShowListener showListener) {
+ public void onStartedWakingUp() {
if (mKeyguardService != null) {
- if (DEBUG) Log.v(TAG, "onScreenTurnedOn(showListener = " + showListener + ")");
- mKeyguardService.onStartedWakingUp(new KeyguardShowDelegate(showListener));
+ if (DEBUG) Log.v(TAG, "onStartedWakingUp()");
+ mKeyguardService.onStartedWakingUp();
+ }
+ }
+
+ public void onScreenTurningOn(final DrawnListener drawnListener) {
+ if (mKeyguardService != null) {
+ if (DEBUG) Log.v(TAG, "onScreenTurnedOn(showListener = " + drawnListener + ")");
+ mKeyguardService.onScreenTurningOn(new KeyguardShowDelegate(drawnListener));
} else {
// try again when we establish a connection
- Slog.w(TAG, "onScreenTurnedOn(): no keyguard service!");
+ Slog.w(TAG, "onScreenTurningOn(): no keyguard service!");
// This shouldn't happen, but if it does, show the scrim immediately and
// invoke the listener's callback after the service actually connects.
- mShowListenerWhenConnect = showListener;
+ mDrawnListenerWhenConnect = drawnListener;
showScrim();
}
}
diff --git a/services/core/java/com/android/server/policy/keyguard/KeyguardServiceWrapper.java b/services/core/java/com/android/server/policy/keyguard/KeyguardServiceWrapper.java
index 51d59fa..5810a45 100644
--- a/services/core/java/com/android/server/policy/keyguard/KeyguardServiceWrapper.java
+++ b/services/core/java/com/android/server/policy/keyguard/KeyguardServiceWrapper.java
@@ -22,9 +22,9 @@
import android.os.RemoteException;
import android.util.Slog;
+import com.android.internal.policy.IKeyguardDrawnCallback;
import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardService;
-import com.android.internal.policy.IKeyguardShowCallback;
import com.android.internal.policy.IKeyguardStateCallback;
/**
@@ -124,9 +124,18 @@
}
@Override
- public void onStartedWakingUp(IKeyguardShowCallback callback) {
+ public void onStartedWakingUp() {
try {
- mService.onStartedWakingUp(callback);
+ mService.onStartedWakingUp();
+ } catch (RemoteException e) {
+ Slog.w(TAG , "Remote Exception", e);
+ }
+ }
+
+ @Override
+ public void onScreenTurningOn(IKeyguardDrawnCallback callback) {
+ try {
+ mService.onScreenTurningOn(callback);
} catch (RemoteException e) {
Slog.w(TAG , "Remote Exception", e);
}
diff --git a/services/core/java/com/android/server/power/Notifier.java b/services/core/java/com/android/server/power/Notifier.java
index c5ad7fe..7108f4a 100644
--- a/services/core/java/com/android/server/power/Notifier.java
+++ b/services/core/java/com/android/server/power/Notifier.java
@@ -48,6 +48,7 @@
import android.util.EventLog;
import android.util.Slog;
import android.view.WindowManagerPolicy;
+import android.view.inputmethod.InputMethodManagerInternal;
/**
* Sends broadcasts about important power state changes.
@@ -89,6 +90,7 @@
private final WindowManagerPolicy mPolicy;
private final ActivityManagerInternal mActivityManagerInternal;
private final InputManagerInternal mInputManagerInternal;
+ private final InputMethodManagerInternal mInputMethodManagerInternal;
private final NotifierHandler mHandler;
private final Intent mScreenOnIntent;
@@ -133,6 +135,7 @@
mPolicy = policy;
mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class);
mInputManagerInternal = LocalServices.getService(InputManagerInternal.class);
+ mInputMethodManagerInternal = LocalServices.getService(InputMethodManagerInternal.class);
mHandler = new NotifierHandler(looper);
mScreenOnIntent = new Intent(Intent.ACTION_SCREEN_ON);
@@ -314,6 +317,7 @@
// Start input as soon as we start waking up or going to sleep.
mInputManagerInternal.setInteractive(interactive);
+ mInputMethodManagerInternal.setInteractive(interactive);
// Notify battery stats.
try {
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 4f2b1f9..d9828cc 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -10029,70 +10029,70 @@
WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
if (DEBUG_LAYOUT_REPEATS) {
debugLayoutRepeats(
- "dream and commitFinishDrawingLocked true",
- displayContent.pendingLayoutChanges);
+ "dream and commitFinishDrawingLocked true",
+ displayContent.pendingLayoutChanges);
}
}
if ((w.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) {
if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
- "First draw done in potential wallpaper target " + w);
+ "First draw done in potential wallpaper target " + w);
mInnerFields.mWallpaperMayChange = true;
displayContent.pendingLayoutChanges |=
WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
if (DEBUG_LAYOUT_REPEATS) {
debugLayoutRepeats(
- "wallpaper and commitFinishDrawingLocked true",
- displayContent.pendingLayoutChanges);
+ "wallpaper and commitFinishDrawingLocked true",
+ displayContent.pendingLayoutChanges);
}
}
}
winAnimator.setSurfaceBoundariesLocked(recoveringMemory);
+ }
- final AppWindowToken atoken = w.mAppToken;
- if (DEBUG_STARTING_WINDOW && atoken != null
- && w == atoken.startingWindow) {
- Slog.d(TAG, "updateWindows: starting " + w + " isOnScreen="
- + w.isOnScreen() + " allDrawn=" + atoken.allDrawn
- + " freezingScreen=" + atoken.mAppAnimator.freezingScreen);
+ final AppWindowToken atoken = w.mAppToken;
+ if (DEBUG_STARTING_WINDOW && atoken != null
+ && w == atoken.startingWindow) {
+ Slog.d(TAG, "updateWindows: starting " + w + " isOnScreen="
+ + w.isOnScreen() + " allDrawn=" + atoken.allDrawn
+ + " freezingScreen=" + atoken.mAppAnimator.freezingScreen);
+ }
+ if (atoken != null
+ && (!atoken.allDrawn || atoken.mAppAnimator.freezingScreen)) {
+ if (atoken.lastTransactionSequence != mTransactionSequence) {
+ atoken.lastTransactionSequence = mTransactionSequence;
+ atoken.numInterestingWindows = atoken.numDrawnWindows = 0;
+ atoken.startingDisplayed = false;
}
- if (atoken != null
- && (!atoken.allDrawn || atoken.mAppAnimator.freezingScreen)) {
- if (atoken.lastTransactionSequence != mTransactionSequence) {
- atoken.lastTransactionSequence = mTransactionSequence;
- atoken.numInterestingWindows = atoken.numDrawnWindows = 0;
- atoken.startingDisplayed = false;
+ if ((w.isOnScreenIgnoringKeyguard()
+ || winAnimator.mAttrType == TYPE_BASE_APPLICATION)
+ && !w.mExiting && !w.mDestroying) {
+ if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) {
+ Slog.v(TAG, "Eval win " + w + ": isDrawn=" + w.isDrawnLw()
+ + ", isAnimating=" + winAnimator.isAnimating());
+ if (!w.isDrawnLw()) {
+ Slog.v(TAG, "Not displayed: s=" + winAnimator.mSurfaceControl
+ + " pv=" + w.mPolicyVisibility
+ + " mDrawState=" + winAnimator.drawStateToString()
+ + " ah=" + w.mAttachedHidden
+ + " th=" + atoken.hiddenRequested
+ + " a=" + winAnimator.mAnimating);
+ }
}
- if ((w.isOnScreenIgnoringKeyguard()
- || winAnimator.mAttrType == TYPE_BASE_APPLICATION)
- && !w.mExiting && !w.mDestroying) {
- if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) {
- Slog.v(TAG, "Eval win " + w + ": isDrawn=" + w.isDrawnLw()
- + ", isAnimating=" + winAnimator.isAnimating());
- if (!w.isDrawnLw()) {
- Slog.v(TAG, "Not displayed: s=" + winAnimator.mSurfaceControl
- + " pv=" + w.mPolicyVisibility
- + " mDrawState=" + winAnimator.drawStateToString()
- + " ah=" + w.mAttachedHidden
- + " th=" + atoken.hiddenRequested
- + " a=" + winAnimator.mAnimating);
+ if (w != atoken.startingWindow) {
+ if (!atoken.mAppAnimator.freezingScreen || !w.mAppFreezing) {
+ atoken.numInterestingWindows++;
+ if (w.isDrawnLw()) {
+ atoken.numDrawnWindows++;
+ if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) Slog.v(TAG,
+ "tokenMayBeDrawn: " + atoken
+ + " freezingScreen=" + atoken.mAppAnimator.freezingScreen
+ + " mAppFreezing=" + w.mAppFreezing);
+ updateAllDrawn = true;
}
}
- if (w != atoken.startingWindow) {
- if (!atoken.mAppAnimator.freezingScreen || !w.mAppFreezing) {
- atoken.numInterestingWindows++;
- if (w.isDrawnLw()) {
- atoken.numDrawnWindows++;
- if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) Slog.v(TAG,
- "tokenMayBeDrawn: " + atoken
- + " freezingScreen=" + atoken.mAppAnimator.freezingScreen
- + " mAppFreezing=" + w.mAppFreezing);
- updateAllDrawn = true;
- }
- }
- } else if (w.isDrawnLw()) {
- atoken.startingDisplayed = true;
- }
+ } else if (w.isDrawnLw()) {
+ atoken.startingDisplayed = true;
}
}
}
diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp
index f3edbd1..e29d0a9 100644
--- a/services/core/jni/com_android_server_input_InputManagerService.cpp
+++ b/services/core/jni/com_android_server_input_InputManagerService.cpp
@@ -27,6 +27,8 @@
#include "JNIHelp.h"
#include "jni.h"
+#include <atomic>
+#include <cinttypes>
#include <limits.h>
#include <android_runtime/AndroidRuntime.h>
#include <android_runtime/Log.h>
@@ -56,6 +58,8 @@
#include "com_android_server_input_InputApplicationHandle.h"
#include "com_android_server_input_InputWindowHandle.h"
+#define INDENT " "
+
namespace android {
// The exponent used to calculate the pointer speed scaling factor.
@@ -126,6 +130,10 @@
return a > b ? a : b;
}
+static inline const char* toString(bool value) {
+ return value ? "true" : "false";
+}
+
static jobject getInputApplicationHandleObjLocalRef(JNIEnv* env,
const sp<InputApplicationHandle>& inputApplicationHandle) {
if (inputApplicationHandle == NULL) {
@@ -262,7 +270,7 @@
wp<PointerController> pointerController;
} mLocked;
- volatile bool mInteractive;
+ std::atomic<bool> mInteractive;
void updateInactivityTimeoutLocked(const sp<PointerController>& controller);
void handleInterceptActions(jint wmActions, nsecs_t when, uint32_t& policyFlags);
@@ -292,6 +300,7 @@
mLocked.pointerGesturesEnabled = true;
mLocked.showTouches = false;
}
+ mInteractive = true;
sp<EventHub> eventHub = new EventHub();
mInputManager = new InputManager(eventHub, this, this);
@@ -305,6 +314,21 @@
}
void NativeInputManager::dump(String8& dump) {
+ dump.append("Input Manager State:\n");
+ {
+ dump.appendFormat(INDENT "Interactive: %s\n", toString(mInteractive.load()));
+ }
+ {
+ AutoMutex _l(mLock);
+ dump.appendFormat(INDENT "System UI Visibility: 0x%0" PRIx32 "\n",
+ mLocked.systemUiVisibility);
+ dump.appendFormat(INDENT "Pointer Speed: %" PRId32 "\n", mLocked.pointerSpeed);
+ dump.appendFormat(INDENT "Pointer Gestures Enabled: %s\n",
+ toString(mLocked.pointerGesturesEnabled));
+ dump.appendFormat(INDENT "Show Touches: %s\n", toString(mLocked.showTouches));
+ }
+ dump.append("\n");
+
mInputManager->getReader()->dump(dump);
dump.append("\n");
@@ -830,7 +854,8 @@
// - Ignore untrusted events and pass them along.
// - Ask the window manager what to do with normal events and trusted injected events.
// - For normal events wake and brighten the screen if currently off or dim.
- if (mInteractive) {
+ bool interactive = mInteractive.load();
+ if (interactive) {
policyFlags |= POLICY_FLAG_INTERACTIVE;
}
if ((policyFlags & POLICY_FLAG_TRUSTED)) {
@@ -854,7 +879,7 @@
handleInterceptActions(wmActions, when, /*byref*/ policyFlags);
} else {
- if (mInteractive) {
+ if (interactive) {
policyFlags |= POLICY_FLAG_PASS_TO_USER;
}
}
@@ -866,7 +891,8 @@
// - No special filtering for injected events required at this time.
// - Filter normal events based on screen state.
// - For normal events brighten (but do not wake) the screen if currently dim.
- if (mInteractive) {
+ bool interactive = mInteractive.load();
+ if (interactive) {
policyFlags |= POLICY_FLAG_INTERACTIVE;
}
if ((policyFlags & POLICY_FLAG_TRUSTED) && !(policyFlags & POLICY_FLAG_INJECTED)) {
@@ -885,7 +911,7 @@
handleInterceptActions(wmActions, when, /*byref*/ policyFlags);
}
} else {
- if (mInteractive) {
+ if (interactive) {
policyFlags |= POLICY_FLAG_PASS_TO_USER;
}
}
diff --git a/services/usage/java/com/android/server/usage/UsageStatsDatabase.java b/services/usage/java/com/android/server/usage/UsageStatsDatabase.java
index 4498b84..f8ae03f 100644
--- a/services/usage/java/com/android/server/usage/UsageStatsDatabase.java
+++ b/services/usage/java/com/android/server/usage/UsageStatsDatabase.java
@@ -21,6 +21,7 @@
import android.os.Build;
import android.util.AtomicFile;
import android.util.Slog;
+import android.util.TimeUtils;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -191,7 +192,11 @@
for (File f : files) {
final AtomicFile af = new AtomicFile(f);
- mSortedStatFiles[i].put(UsageStatsXml.parseBeginTime(af), af);
+ try {
+ mSortedStatFiles[i].put(UsageStatsXml.parseBeginTime(af), af);
+ } catch (IOException e) {
+ Slog.e(TAG, "failed to index file: " + f, e);
+ }
}
}
}
@@ -273,14 +278,21 @@
public void onTimeChanged(long timeDiffMillis) {
synchronized (mLock) {
+ StringBuilder logBuilder = new StringBuilder();
+ logBuilder.append("Time changed by ");
+ TimeUtils.formatDuration(timeDiffMillis, logBuilder);
+ logBuilder.append(".");
+
+ int filesDeleted = 0;
+ int filesMoved = 0;
+
for (TimeSparseArray<AtomicFile> files : mSortedStatFiles) {
final int fileCount = files.size();
for (int i = 0; i < fileCount; i++) {
final AtomicFile file = files.valueAt(i);
final long newTime = files.keyAt(i) + timeDiffMillis;
if (newTime < 0) {
- Slog.i(TAG, "Deleting file " + file.getBaseFile().getAbsolutePath()
- + " for it is in the future now.");
+ filesDeleted++;
file.delete();
} else {
try {
@@ -295,14 +307,17 @@
}
final File newFile = new File(file.getBaseFile().getParentFile(), newName);
- Slog.i(TAG, "Moving file " + file.getBaseFile().getAbsolutePath() + " to "
- + newFile.getAbsolutePath());
+ filesMoved++;
file.getBaseFile().renameTo(newFile);
}
}
files.clear();
}
+ logBuilder.append(" files deleted: ").append(filesDeleted);
+ logBuilder.append(" files moved: ").append(filesMoved);
+ Slog.i(TAG, logBuilder.toString());
+
// Now re-index the new files.
indexFilesLocked();
}
@@ -506,7 +521,14 @@
if (path.endsWith(BAK_SUFFIX)) {
f = new File(path.substring(0, path.length() - BAK_SUFFIX.length()));
}
- long beginTime = UsageStatsXml.parseBeginTime(f);
+
+ long beginTime;
+ try {
+ beginTime = UsageStatsXml.parseBeginTime(f);
+ } catch (IOException e) {
+ beginTime = 0;
+ }
+
if (beginTime < expiryTime) {
new AtomicFile(f).delete();
}
diff --git a/services/usage/java/com/android/server/usage/UsageStatsService.java b/services/usage/java/com/android/server/usage/UsageStatsService.java
index b0a14c8..a433ec45 100644
--- a/services/usage/java/com/android/server/usage/UsageStatsService.java
+++ b/services/usage/java/com/android/server/usage/UsageStatsService.java
@@ -42,6 +42,7 @@
import android.content.res.Configuration;
import android.database.ContentObserver;
import android.hardware.display.DisplayManager;
+import android.net.NetworkScoreManager;
import android.os.BatteryManager;
import android.os.BatteryStats;
import android.os.Binder;
@@ -812,6 +813,10 @@
return false;
}
+ if (isActiveNetworkScorer(packageName)) {
+ return false;
+ }
+
if (mAppWidgetManager != null
&& mAppWidgetManager.isBoundWidgetPackage(packageName, userId)) {
return false;
@@ -847,6 +852,12 @@
== TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS;
}
+ private boolean isActiveNetworkScorer(String packageName) {
+ NetworkScoreManager nsm = (NetworkScoreManager) getContext().getSystemService(
+ Context.NETWORK_SCORE_SERVICE);
+ return packageName != null && packageName.equals(nsm.getActiveScorerPackage());
+ }
+
void informListeners(String packageName, int userId, boolean isIdle) {
for (AppIdleStateChangeListener listener : mPackageAccessListeners) {
listener.onAppIdleStateChanged(packageName, userId, isIdle);
diff --git a/services/usage/java/com/android/server/usage/UsageStatsXml.java b/services/usage/java/com/android/server/usage/UsageStatsXml.java
index 186813e..543f361 100644
--- a/services/usage/java/com/android/server/usage/UsageStatsXml.java
+++ b/services/usage/java/com/android/server/usage/UsageStatsXml.java
@@ -33,11 +33,11 @@
private static final String VERSION_ATTR = "version";
static final String CHECKED_IN_SUFFIX = "-c";
- public static long parseBeginTime(AtomicFile file) {
+ public static long parseBeginTime(AtomicFile file) throws IOException {
return parseBeginTime(file.getBaseFile());
}
- public static long parseBeginTime(File file) {
+ public static long parseBeginTime(File file) throws IOException {
String name = file.getName();
// Eat as many occurrences of -c as possible. This is due to a bug where -c
@@ -47,7 +47,12 @@
while (name.endsWith(CHECKED_IN_SUFFIX)) {
name = name.substring(0, name.length() - CHECKED_IN_SUFFIX.length());
}
- return Long.parseLong(name);
+
+ try {
+ return Long.parseLong(name);
+ } catch (NumberFormatException e) {
+ throw new IOException(e);
+ }
}
public static void read(AtomicFile file, IntervalStats statsOut) throws IOException {
diff --git a/services/usb/java/com/android/server/usb/UsbHostManager.java b/services/usb/java/com/android/server/usb/UsbHostManager.java
index 6300a9a..965341e 100644
--- a/services/usb/java/com/android/server/usb/UsbHostManager.java
+++ b/services/usb/java/com/android/server/usb/UsbHostManager.java
@@ -231,6 +231,8 @@
mNewConfigurations = null;
mNewInterfaces = null;
mNewEndpoints = null;
+ mNewConfiguration = null;
+ mNewInterface = null;
}
}
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
index b57c413..a8874d0 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
@@ -894,6 +894,28 @@
}
@Override
+ public void onLockscreenShown() {
+ enforceCallingPermission(Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE);
+ synchronized (this) {
+ if (mImpl == null) {
+ return;
+ }
+ final long caller = Binder.clearCallingIdentity();
+ try {
+ if (mImpl.mActiveSession != null && mImpl.mActiveSession.mSession != null) {
+ try {
+ mImpl.mActiveSession.mSession.onLockscreenShown();
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to call onLockscreenShown", e);
+ }
+ }
+ } finally {
+ Binder.restoreCallingIdentity(caller);
+ }
+ }
+ }
+
+ @Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (mContext.checkCallingOrSelfPermission(Manifest.permission.DUMP)
!= PackageManager.PERMISSION_GRANTED) {
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index e861668..e9c41a1 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -273,6 +273,14 @@
*/
public static final String KEY_DEFAULT_SIM_CALL_MANAGER_STRING = "default_sim_call_manager_string";
+ /**
+ * The default flag specifying whether ETWS/CMAS test setting is forcibly disabled in
+ * Settings->More->Emergency broadcasts menu even though developer options is turned on.
+ * @hide
+ */
+ public static final String KEY_CARRIER_FORCE_DISABLE_ETWS_CMAS_TEST_BOOL =
+ "carrier_force_disable_etws_cmas_test_bool";
+
/* The following 3 fields are related to carrier visual voicemail. */
/**
@@ -381,6 +389,7 @@
sDefaults.putBoolean(KEY_CARRIER_VOLTE_AVAILABLE_BOOL, false);
sDefaults.putBoolean(KEY_CARRIER_VT_AVAILABLE_BOOL, false);
sDefaults.putBoolean(KEY_CARRIER_WFC_IMS_AVAILABLE_BOOL, false);
+ sDefaults.putBoolean(KEY_CARRIER_FORCE_DISABLE_ETWS_CMAS_TEST_BOOL, false);
sDefaults.putBoolean(KEY_CARRIER_VOLTE_PROVISIONING_REQUIRED_BOOL, false);
sDefaults.putBoolean(KEY_CARRIER_VOLTE_TTY_SUPPORTED_BOOL, true);
sDefaults.putBoolean(KEY_CARRIER_ALLOW_TURNOFF_IMS_BOOL, true);
diff --git a/tests/Assist/src/com/android/test/assist/AssistInteractionSession.java b/tests/Assist/src/com/android/test/assist/AssistInteractionSession.java
index 43f1e32..851bda9 100644
--- a/tests/Assist/src/com/android/test/assist/AssistInteractionSession.java
+++ b/tests/Assist/src/com/android/test/assist/AssistInteractionSession.java
@@ -24,6 +24,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.service.voice.VoiceInteractionSession;
+import android.util.Log;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.ViewTreeObserver;
@@ -69,6 +70,7 @@
@Override
public void onCreate() {
+ super.onCreate();
// Simulate slowness of Assist app
try {
Thread.sleep(1000);
@@ -105,6 +107,12 @@
}
}
+ @Override
+ public void onLockscreenShown() {
+ super.onLockscreenShown();
+ Log.i("Assistant", "Lockscreen was shown");
+ }
+
private void playAssistAnimation() {
Interpolator linearOutSlowIn = AnimationUtils.loadInterpolator(mBackground.getContext(),
android.R.interpolator.linear_out_slow_in);
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
index 3ae10f2..48ca7d8 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
@@ -50,6 +50,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Arrays;
+import java.util.Comparator;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashMap;
@@ -93,7 +94,7 @@
/**
* Same as sRMap except for int[] instead of int resources. This is for android.R only.
*/
- private final static Map<IntArray, String> sRArrayMap = new HashMap<IntArray, String>();
+ private final static Map<IntArray, String> sRArrayMap = new HashMap<IntArray, String>(384);
/**
* Reverse map compared to sRMap, resource type -> (resource name -> id).
* This is for com.android.internal.R.
@@ -182,7 +183,7 @@
*/
private static LayoutLog sCurrentLog = sDefaultLog;
- private static final int LAST_SUPPORTED_FEATURE = Features.RENDER_ALL_DRAWABLE_STATES;
+ private static final int LAST_SUPPORTED_FEATURE = Features.RECYCLER_VIEW_ADAPTER;
@Override
public int getApiLevel() {
@@ -249,37 +250,56 @@
// the internal version), and put the content in the maps.
try {
Class<?> r = com.android.internal.R.class;
+ // Parse the styleable class first, since it may contribute to attr values.
+ parseStyleable();
for (Class<?> inner : r.getDeclaredClasses()) {
+ if (inner == com.android.internal.R.styleable.class) {
+ // Already handled the styleable case. Not skipping attr, as there may be attrs
+ // that are not referenced from styleables.
+ continue;
+ }
String resTypeName = inner.getSimpleName();
ResourceType resType = ResourceType.getEnum(resTypeName);
if (resType != null) {
- Map<String, Integer> fullMap = new HashMap<String, Integer>();
- sRevRMap.put(resType, fullMap);
+ Map<String, Integer> fullMap = null;
+ switch (resType) {
+ case ATTR:
+ fullMap = sRevRMap.get(ResourceType.ATTR);
+ break;
+ case STRING:
+ case STYLE:
+ // Slightly less than thousand entries in each.
+ fullMap = new HashMap<String, Integer>(1280);
+ // no break.
+ default:
+ if (fullMap == null) {
+ fullMap = new HashMap<String, Integer>();
+ }
+ sRevRMap.put(resType, fullMap);
+ }
for (Field f : inner.getDeclaredFields()) {
// only process static final fields. Since the final attribute may have
// been altered by layoutlib_create, we only check static
- int modifiers = f.getModifiers();
- if (Modifier.isStatic(modifiers)) {
- Class<?> type = f.getType();
- if (type.isArray() && type.getComponentType() == int.class) {
- // if the object is an int[] we put it in sRArrayMap using an IntArray
- // wrapper that properly implements equals and hashcode for the array
- // objects, as required by the map contract.
- sRArrayMap.put(new IntArray((int[]) f.get(null)), f.getName());
- } else if (type == int.class) {
- Integer value = (Integer) f.get(null);
- sRMap.put(value, Pair.of(resType, f.getName()));
- fullMap.put(f.getName(), value);
- } else {
- assert false;
- }
+ if (!isValidRField(f)) {
+ continue;
+ }
+ Class<?> type = f.getType();
+ if (type.isArray()) {
+ // if the object is an int[] we put it in sRArrayMap using an IntArray
+ // wrapper that properly implements equals and hashcode for the array
+ // objects, as required by the map contract.
+ sRArrayMap.put(new IntArray((int[]) f.get(null)), f.getName());
+ } else {
+ Integer value = (Integer) f.get(null);
+ sRMap.put(value, Pair.of(resType, f.getName()));
+ fullMap.put(f.getName(), value);
}
}
}
}
- } catch (Throwable throwable) {
+ } catch (Exception throwable) {
if (log != null) {
log.error(LayoutLog.TAG_BROKEN,
"Failed to load com.android.internal.R from the layout library jar",
@@ -291,6 +311,90 @@
return true;
}
+ /**
+ * Tests if the field is pubic, static and one of int or int[].
+ */
+ private static boolean isValidRField(Field field) {
+ int modifiers = field.getModifiers();
+ boolean isAcceptable = Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers);
+ Class<?> type = field.getType();
+ return isAcceptable && type == int.class ||
+ (type.isArray() && type.getComponentType() == int.class);
+
+ }
+
+ private static void parseStyleable() throws Exception {
+ // R.attr doesn't contain all the needed values. There are too many resources in the
+ // framework for all to be in the R class. Only the ones specified manually in
+ // res/values/symbols.xml are put in R class. Since, we need to create a map of all attr
+ // values, we try and find them from the styleables.
+
+ // There were 1500 elements in this map at M timeframe.
+ Map<String, Integer> revRAttrMap = new HashMap<String, Integer>(2048);
+ sRevRMap.put(ResourceType.ATTR, revRAttrMap);
+ // There were 2000 elements in this map at M timeframe.
+ Map<String, Integer> revRStyleableMap = new HashMap<String, Integer>(3072);
+ sRevRMap.put(ResourceType.STYLEABLE, revRStyleableMap);
+ Class<?> c = com.android.internal.R.styleable.class;
+ Field[] fields = c.getDeclaredFields();
+ // Sort the fields to bring all arrays to the beginning, so that indices into the array are
+ // able to refer back to the arrays (i.e. no forward references).
+ Arrays.sort(fields, new Comparator<Field>() {
+ @Override
+ public int compare(Field o1, Field o2) {
+ if (o1 == o2) {
+ return 0;
+ }
+ Class<?> t1 = o1.getType();
+ Class<?> t2 = o2.getType();
+ if (t1.isArray() && !t2.isArray()) {
+ return -1;
+ } else if (t2.isArray() && !t1.isArray()) {
+ return 1;
+ }
+ return o1.getName().compareTo(o2.getName());
+ }
+ });
+ Map<String, int[]> styleables = new HashMap<String, int[]>();
+ for (Field field : fields) {
+ if (!isValidRField(field)) {
+ // Only consider public static fields that are int or int[].
+ // Don't check the final flag as it may have been modified by layoutlib_create.
+ continue;
+ }
+ String name = field.getName();
+ if (field.getType().isArray()) {
+ int[] styleableValue = (int[]) field.get(null);
+ sRArrayMap.put(new IntArray(styleableValue), name);
+ styleables.put(name, styleableValue);
+ continue;
+ }
+ // Not an array.
+ String arrayName = name;
+ int[] arrayValue = null;
+ int index;
+ while ((index = arrayName.lastIndexOf('_')) >= 0) {
+ // Find the name of the corresponding styleable.
+ // Search in reverse order so that attrs like LinearLayout_Layout_layout_gravity
+ // are mapped to LinearLayout_Layout and not to LinearLayout.
+ arrayName = arrayName.substring(0, index);
+ arrayValue = styleables.get(arrayName);
+ if (arrayValue != null) {
+ break;
+ }
+ }
+ index = (Integer) field.get(null);
+ if (arrayValue != null) {
+ String attrName = name.substring(arrayName.length() + 1);
+ int attrValue = arrayValue[index];
+ sRMap.put(attrValue, Pair.of(ResourceType.ATTR, attrName));
+ revRAttrMap.put(attrName, attrValue);
+ }
+ sRMap.put(index, Pair.of(ResourceType.STYLEABLE, name));
+ revRStyleableMap.put(name, index);
+ }
+ }
+
@Override
public boolean dispose() {
BridgeAssetManager.clearSystem();
@@ -490,9 +594,13 @@
/**
* Returns the integer id of a framework resource, from a given resource type and resource name.
+ * <p/>
+ * If no resource is found, it creates a dynamic id for the resource.
+ *
* @param type the type of the resource
* @param name the name of the resource.
- * @return an {@link Integer} containing the resource id, or null if no resource were found.
+ *
+ * @return an {@link Integer} containing the resource id.
*/
@NonNull
public static Integer getResourceId(ResourceType type, String name) {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/AppCompatActionBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/AppCompatActionBar.java
index 958b7aa..868c6d3 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/AppCompatActionBar.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/AppCompatActionBar.java
@@ -31,7 +31,6 @@
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.FrameLayout;
import java.lang.reflect.InvocationTargetException;
@@ -51,9 +50,8 @@
/**
* Inflate the action bar and attach it to {@code parentView}
*/
- public AppCompatActionBar(@NonNull BridgeContext context, @NonNull SessionParams params,
- @NonNull ViewGroup parentView) {
- super(context, params, parentView);
+ public AppCompatActionBar(@NonNull BridgeContext context, @NonNull SessionParams params) {
+ super(context, params);
int contentRootId = context.getProjectResourceValue(ResourceType.ID,
"action_bar_activity_content", 0);
View contentView = getDecorContent().findViewById(contentRootId);
@@ -64,7 +62,9 @@
// Something went wrong. Create a new FrameLayout in the enclosing layout.
FrameLayout contentRoot = new FrameLayout(context);
setMatchParent(contentRoot);
- mEnclosingLayout.addView(contentRoot);
+ if (mEnclosingLayout != null) {
+ mEnclosingLayout.addView(contentRoot);
+ }
setContentRoot(contentRoot);
}
try {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/BridgeActionBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/BridgeActionBar.java
index a19b689f1..f900b45 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/BridgeActionBar.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/BridgeActionBar.java
@@ -24,6 +24,7 @@
import com.android.layoutlib.bridge.android.BridgeContext;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -39,7 +40,7 @@
@NonNull protected final BridgeContext mBridgeContext;
@NonNull protected final SessionParams mParams;
// A Layout that contains the inflated action bar. The menu popup is added to this layout.
- @NonNull protected final ViewGroup mEnclosingLayout;
+ @Nullable protected final ViewGroup mEnclosingLayout;
private final View mDecorContent;
private final ActionBarCallback mCallback;
@@ -47,8 +48,7 @@
@SuppressWarnings("NullableProblems") // Should be initialized by subclasses.
@NonNull private FrameLayout mContentRoot;
- public BridgeActionBar(@NonNull BridgeContext context, @NonNull SessionParams params,
- @NonNull ViewGroup parentView) {
+ public BridgeActionBar(@NonNull BridgeContext context, @NonNull SessionParams params) {
mBridgeContext = context;
mParams = params;
mCallback = params.getLayoutlibCallback().getActionBarCallback();
@@ -75,14 +75,13 @@
// added.
mEnclosingLayout = new RelativeLayout(mBridgeContext);
setMatchParent(mEnclosingLayout);
- parentView.addView(mEnclosingLayout);
} else {
- mEnclosingLayout = parentView;
+ mEnclosingLayout = null;
}
// Inflate action bar layout.
- mDecorContent = getInflater(context).inflate(layoutId, mEnclosingLayout, true);
-
+ mDecorContent =
+ getInflater(context).inflate(layoutId, mEnclosingLayout, mEnclosingLayout != null);
}
/**
@@ -153,6 +152,13 @@
public abstract void createMenuPopup();
+ /**
+ * The root view that represents the action bar and possibly the content included in it.
+ */
+ public View getRootView() {
+ return mEnclosingLayout == null ? mDecorContent : mEnclosingLayout;
+ }
+
public ActionBarCallback getCallBack() {
return mCallback;
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java
index 90a1c75..145a03a 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java
@@ -32,7 +32,6 @@
import org.xmlpull.v1.XmlPullParserException;
import android.annotation.NonNull;
-import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.Bitmap_Delegate;
@@ -68,7 +67,7 @@
protected abstract TextView getStyleableTextView();
protected CustomBar(BridgeContext context, int orientation, String layoutPath,
- String name, int simulatedPlatformVersion) throws XmlPullParserException {
+ String name, int simulatedPlatformVersion) {
super(context);
mSimulatedPlatformVersion = simulatedPlatformVersion;
setOrientation(orientation);
@@ -78,14 +77,18 @@
setGravity(Gravity.CENTER_HORIZONTAL);
}
- LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
- Context.LAYOUT_INFLATER_SERVICE);
+ LayoutInflater inflater = LayoutInflater.from(mContext);
- XmlPullParser parser = ParserFactory.create(getClass().getResourceAsStream(layoutPath),
- name);
+ XmlPullParser parser;
+ try {
+ parser = ParserFactory.create(getClass().getResourceAsStream(layoutPath), name);
+ } catch (XmlPullParserException e) {
+ // Should not happen as the resource is bundled with the jar, and ParserFactory should
+ // have been initialized.
+ throw new AssertionError(e);
+ }
- BridgeXmlBlockParser bridgeParser = new BridgeXmlBlockParser(
- parser, (BridgeContext) context, false /*platformFile*/);
+ BridgeXmlBlockParser bridgeParser = new BridgeXmlBlockParser(parser, context, false);
try {
inflater.inflate(bridgeParser, this, true);
@@ -154,7 +157,7 @@
protected void setStyle(String themeEntryName) {
- BridgeContext bridgeContext = (BridgeContext) mContext;
+ BridgeContext bridgeContext = getContext();
RenderResources res = bridgeContext.getRenderResources();
ResourceValue value = res.findItemInTheme(themeEntryName, true /*isFrameworkAttr*/);
@@ -214,27 +217,47 @@
}
}
+ @Override
+ public BridgeContext getContext() {
+ return (BridgeContext) mContext;
+ }
+
/**
- * Given a theme attribute name, get the color referenced by it. The theme attribute may be
- * used in a layout like "?attr/foo".
+ * Find the background color for this bar from the theme attributes. Only relevant to StatusBar
+ * and NavigationBar.
* <p/>
* Returns 0 if not found.
*
+ * @param colorAttrName the attribute name for the background color
+ * @param translucentAttrName the attribute name for the translucency property of the bar.
+ *
* @throws NumberFormatException if color resolved to an invalid string.
*/
- protected int getThemeAttrColor(@NonNull String attrName, boolean isFramework) {
+ protected int getBarColor(@NonNull String colorAttrName, @NonNull String translucentAttrName) {
if (!Config.isGreaterOrEqual(mSimulatedPlatformVersion, LOLLIPOP)) {
return 0;
}
- assert mContext instanceof BridgeContext;
- BridgeContext context = ((BridgeContext) mContext);
- RenderResources renderResources = context.getRenderResources();
- // From ?attr/foo to @color/bar. This is most likely an ItemResourceValue.
- ResourceValue resource = renderResources.findItemInTheme(attrName, isFramework);
- if (resource != null) {
- // Form @color/bar to the #AARRGGBB
- resource = renderResources.resolveResValue(resource);
+ RenderResources renderResources = getContext().getRenderResources();
+ // First check if the bar is translucent.
+ boolean translucent = ResourceHelper.getBooleanThemeValue(renderResources,
+ translucentAttrName, true, false);
+ if (translucent) {
+ // Keep in sync with R.color.system_bar_background_semi_transparent from system ui.
+ return 0x66000000; // 40% black.
}
+ boolean transparent = ResourceHelper.getBooleanThemeValue(renderResources,
+ "windowDrawsSystemBarBackgrounds", true, false);
+ if (transparent) {
+ return getColor(renderResources, colorAttrName);
+ }
+ return 0;
+ }
+
+ private static int getColor(RenderResources renderResources, String attr) {
+ // From ?attr/foo to @color/bar. This is most likely an ItemResourceValue.
+ ResourceValue resource = renderResources.findItemInTheme(attr, true);
+ // Form @color/bar to the #AARRGGBB
+ resource = renderResources.resolveResValue(resource);
if (resource != null && ResourceType.COLOR.equals(resource.getResourceType())) {
return ResourceHelper.getColor(resource.getValue());
}
@@ -242,8 +265,7 @@
}
private ResourceValue getResourceValue(String reference) {
- BridgeContext bridgeContext = (BridgeContext) mContext;
- RenderResources res = bridgeContext.getRenderResources();
+ RenderResources res = getContext().getRenderResources();
// find the resource
ResourceValue value = res.findResValue(reference, false);
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/FrameworkActionBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/FrameworkActionBar.java
index bb3d13f..d2a5117 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/FrameworkActionBar.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/FrameworkActionBar.java
@@ -60,23 +60,24 @@
/**
* Inflate the action bar and attach it to {@code parentView}
*/
- public FrameworkActionBar(@NonNull BridgeContext context, @NonNull SessionParams params,
- @NonNull ViewGroup parentView) {
- super(context, params, parentView);
+ public FrameworkActionBar(@NonNull BridgeContext context, @NonNull SessionParams params) {
+ super(context, params);
View decorContent = getDecorContent();
mActionBar = FrameworkActionBarWrapper.getActionBarWrapper(context, getCallBack(),
decorContent);
- FrameLayout contentRoot = (FrameLayout) mEnclosingLayout.findViewById(android.R.id.content);
+ FrameLayout contentRoot = (FrameLayout) decorContent.findViewById(android.R.id.content);
// If something went wrong and we were not able to initialize the content root,
// just add a frame layout inside this and return.
if (contentRoot == null) {
contentRoot = new FrameLayout(context);
setMatchParent(contentRoot);
- mEnclosingLayout.addView(contentRoot);
+ if (mEnclosingLayout != null) {
+ mEnclosingLayout.addView(contentRoot);
+ }
setContentRoot(contentRoot);
} else {
setContentRoot(contentRoot);
@@ -162,6 +163,7 @@
listView.setDivider(a.getDrawable(R.attr.actionBarDivider));
a.recycle();
listView.setElevation(mActionBar.getMenuPopupElevation());
+ assert mEnclosingLayout != null : "Unable to find view to attach ActionMenuPopup.";
mEnclosingLayout.addView(listView);
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/FrameworkActionBarWrapper.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/FrameworkActionBarWrapper.java
index daad602..af6ba24 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/FrameworkActionBarWrapper.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/FrameworkActionBarWrapper.java
@@ -79,7 +79,7 @@
}
}
- FrameworkActionBarWrapper(@NonNull BridgeContext context, ActionBarCallback callback,
+ FrameworkActionBarWrapper(@NonNull BridgeContext context, @NonNull ActionBarCallback callback,
@NonNull ActionBar actionBar) {
mActionBar = actionBar;
mCallback = callback;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/NavigationBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/NavigationBar.java
index dcf82a3..9c89bfe2 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/NavigationBar.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/NavigationBar.java
@@ -19,8 +19,6 @@
import com.android.layoutlib.bridge.android.BridgeContext;
import com.android.resources.Density;
-import org.xmlpull.v1.XmlPullParserException;
-
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.util.AttributeSet;
@@ -33,6 +31,8 @@
/** Navigation bar background color attribute name. */
private static final String ATTR_COLOR = "navigationBarColor";
+ /** Attribute for translucency property. */
+ public static final String ATTR_TRANSLUCENT = "windowTranslucentNavigation";
// These correspond to @dimen/navigation_side_padding in the system ui code.
private static final int PADDING_WIDTH_DEFAULT = 36;
private static final int PADDING_WIDTH_SW360 = 40;
@@ -49,8 +49,8 @@
* Constructor to be used when creating the {@link NavigationBar} as a regular control.
* This is currently used by the theme editor.
*/
- public NavigationBar(Context context, AttributeSet attrs)
- throws XmlPullParserException {
+ @SuppressWarnings("unused")
+ public NavigationBar(Context context, AttributeSet attrs) {
this((BridgeContext) context,
Density.getEnum(((BridgeContext) context).getMetrics().densityDpi),
LinearLayout.HORIZONTAL, // In this mode, it doesn't need to be render vertically
@@ -61,11 +61,11 @@
}
public NavigationBar(BridgeContext context, Density density, int orientation, boolean isRtl,
- boolean rtlEnabled, int simulatedPlatformVersion) throws XmlPullParserException {
+ boolean rtlEnabled, int simulatedPlatformVersion) {
super(context, orientation, getShortestWidth(context)>= 600 ? LAYOUT_600DP_XML : LAYOUT_XML,
"navigation_bar.xml", simulatedPlatformVersion);
- int color = getThemeAttrColor(ATTR_COLOR, true);
+ int color = getBarColor(ATTR_COLOR, ATTR_TRANSLUCENT);
setBackgroundColor(color == 0 ? 0xFF000000 : color);
// Cannot access the inside items through id because no R.id values have been
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java
index a0ed0e8..2dc7c65 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java
@@ -26,6 +26,7 @@
import org.xmlpull.v1.XmlPullParserException;
import android.content.Context;
+import android.content.pm.ApplicationInfo;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.Gravity;
@@ -42,22 +43,26 @@
private final int mSimulatedPlatformVersion;
/** Status bar background color attribute name. */
private static final String ATTR_COLOR = "statusBarColor";
+ /** Attribute for translucency property. */
+ public static final String ATTR_TRANSLUCENT = "windowTranslucentStatus";
/**
* Constructor to be used when creating the {@link StatusBar} as a regular control. This
* is currently used by the theme editor.
*/
- public StatusBar(Context context, AttributeSet attrs) throws XmlPullParserException {
+ @SuppressWarnings("UnusedParameters")
+ public StatusBar(Context context, AttributeSet attrs) {
this((BridgeContext) context,
Density.getEnum(((BridgeContext) context).getMetrics().densityDpi),
- LinearLayout.HORIZONTAL, // In this mode, it doesn't need to be render vertically
((BridgeContext) context).getConfiguration().getLayoutDirection() ==
View.LAYOUT_DIRECTION_RTL,
+ (context.getApplicationInfo().flags & ApplicationInfo.FLAG_SUPPORTS_RTL) != 0,
context.getApplicationInfo().targetSdkVersion);
}
- public StatusBar(BridgeContext context, Density density, int direction, boolean RtlEnabled,
- int simulatedPlatformVersion) throws XmlPullParserException {
+ @SuppressWarnings("UnusedParameters")
+ public StatusBar(BridgeContext context, Density density, boolean isRtl, boolean rtlEnabled,
+ int simulatedPlatformVersion) {
// FIXME: if direction is RTL but it's not enabled in application manifest, mirror this bar.
super(context, LinearLayout.HORIZONTAL, "/bars/status_bar.xml", "status_bar.xml",
simulatedPlatformVersion);
@@ -66,7 +71,7 @@
// FIXME: use FILL_H?
setGravity(Gravity.START | Gravity.TOP | Gravity.RIGHT);
- int color = getThemeAttrColor(ATTR_COLOR, true);
+ int color = getBarColor(ATTR_COLOR, ATTR_TRANSLUCENT);
setBackgroundColor(color == 0 ? Config.getStatusBarColor(simulatedPlatformVersion) : color);
// Cannot access the inside items through id because no R.id values have been
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/TitleBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/TitleBar.java
index c610601..4fe1001 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/TitleBar.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/TitleBar.java
@@ -27,8 +27,7 @@
private TextView mTextView;
- public TitleBar(BridgeContext context, String label, int simulatedPlatformVersion)
- throws XmlPullParserException {
+ public TitleBar(BridgeContext context, String label, int simulatedPlatformVersion) {
super(context, LinearLayout.HORIZONTAL, "/bars/title_bar.xml", "title_bar.xml",
simulatedPlatformVersion);
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java
new file mode 100644
index 0000000..89d8319
--- /dev/null
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java
@@ -0,0 +1,459 @@
+/*
+ * Copyright (C) 2015 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+package com.android.layoutlib.bridge.impl;
+
+import com.android.ide.common.rendering.api.HardwareConfig;
+import com.android.ide.common.rendering.api.RenderResources;
+import com.android.ide.common.rendering.api.ResourceValue;
+import com.android.ide.common.rendering.api.SessionParams;
+import com.android.ide.common.rendering.api.StyleResourceValue;
+import com.android.layoutlib.bridge.Bridge;
+import com.android.layoutlib.bridge.android.BridgeContext;
+import com.android.layoutlib.bridge.bars.AppCompatActionBar;
+import com.android.layoutlib.bridge.bars.BridgeActionBar;
+import com.android.layoutlib.bridge.bars.Config;
+import com.android.layoutlib.bridge.bars.FrameworkActionBar;
+import com.android.layoutlib.bridge.bars.NavigationBar;
+import com.android.layoutlib.bridge.bars.StatusBar;
+import com.android.layoutlib.bridge.bars.TitleBar;
+import com.android.resources.Density;
+import com.android.resources.ResourceType;
+import com.android.resources.ScreenOrientation;
+
+import android.annotation.NonNull;
+import android.graphics.drawable.Drawable;
+import android.util.DisplayMetrics;
+import android.util.TypedValue;
+import android.view.View;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
+import static android.widget.LinearLayout.VERTICAL;
+
+/**
+ * The Layout used to create the system decor.
+ *
+ * The layout inflated will contain a content frame where the user's layout can be inflated.
+ * <pre>
+ * +-------------------------------------------------+---+
+ * | Status bar | N |
+ * +-------------------------------------------------+ a |
+ * | Title/Action bar (optional) | v |
+ * +-------------------------------------------------+ |
+ * | Content, vertical extending | b |
+ * | | a |
+ * | | r |
+ * +-------------------------------------------------+---+
+ * </pre>
+ * or
+ * <pre>
+ * +-------------------------------------+
+ * | Status bar |
+ * +-------------------------------------+
+ * | Title/Action bar (optional) |
+ * +-------------------------------------+
+ * | Content, vertical extending |
+ * | |
+ * | |
+ * +-------------------------------------+
+ * | Nav bar |
+ * +-------------------------------------+
+ * </pre>
+ *
+ */
+class Layout extends RelativeLayout {
+
+ // Theme attributes used for configuring appearance of the system decor.
+ private static final String ATTR_WINDOW_FLOATING = "windowIsFloating";
+ private static final String ATTR_WINDOW_BACKGROUND = "windowBackground";
+ private static final String ATTR_WINDOW_FULL_SCREEN = "windowFullScreen";
+ private static final String ATTR_NAV_BAR_HEIGHT = "navigation_bar_height";
+ private static final String ATTR_NAV_BAR_WIDTH = "navigation_bar_width";
+ private static final String ATTR_STATUS_BAR_HEIGHT = "status_bar_height";
+ private static final String ATTR_WINDOW_ACTION_BAR = "windowActionBar";
+ private static final String ATTR_ACTION_BAR_SIZE = "actionBarSize";
+ private static final String ATTR_WINDOW_NO_TITLE = "windowNoTitle";
+ private static final String ATTR_WINDOW_TITLE_SIZE = "windowTitleSize";
+ private static final String ATTR_WINDOW_TRANSLUCENT_STATUS = StatusBar.ATTR_TRANSLUCENT;
+ private static final String ATTR_WINDOW_TRANSLUCENT_NAV = NavigationBar.ATTR_TRANSLUCENT;
+ private static final String PREFIX_THEME_APPCOMPAT = "Theme.AppCompat";
+
+ // Default sizes
+ private static final int DEFAULT_STATUS_BAR_HEIGHT = 25;
+ private static final int DEFAULT_TITLE_BAR_HEIGHT = 25;
+ private static final int DEFAULT_NAV_BAR_SIZE = 48;
+
+ // Ids assigned to components created. This is so that we can refer to other components in
+ // layout params.
+ private static final String ID_NAV_BAR = "navBar";
+ private static final String ID_STATUS_BAR = "statusBar";
+ private static final String ID_TITLE_BAR = "titleBar";
+ // Prefix used with the above ids in order to make them unique in framework namespace.
+ private static final String ID_PREFIX = "android_layoutlib_";
+
+ /**
+ * Temporarily store the builder so that it doesn't have to be passed to all methods used
+ * during inflation.
+ */
+ private Builder mBuilder;
+
+ /**
+ * This holds user's layout.
+ */
+ private FrameLayout mContentRoot;
+
+ public Layout(@NonNull Builder builder) {
+ super(builder.mContext);
+ mBuilder = builder;
+ if (builder.mWindowBackground != null) {
+ Drawable d = ResourceHelper.getDrawable(builder.mWindowBackground, builder.mContext);
+ setBackground(d);
+ }
+
+ int simulatedPlatformVersion = getParams().getSimulatedPlatformVersion();
+ HardwareConfig hwConfig = getParams().getHardwareConfig();
+ Density density = hwConfig.getDensity();
+ boolean isRtl = Bridge.isLocaleRtl(getParams().getLocale());
+
+ NavigationBar navBar = null;
+ if (mBuilder.hasNavBar()) {
+ navBar = createNavBar(getContext(), density, isRtl, getParams().isRtlSupported(),
+ simulatedPlatformVersion);
+ }
+
+ StatusBar statusBar = null;
+ if (builder.mStatusBarSize > 0) {
+ statusBar = createStatusBar(getContext(), density, isRtl, getParams().isRtlSupported(),
+ simulatedPlatformVersion);
+ }
+
+ View actionBar = null;
+ TitleBar titleBar = null;
+ if (builder.mActionBarSize > 0) {
+ BridgeActionBar bar = createActionBar(getContext(), getParams());
+ mContentRoot = bar.getContentRoot();
+ actionBar = bar.getRootView();
+ } else if (mBuilder.mTitleBarSize > 0) {
+ titleBar = createTitleBar(getContext(), getParams().getAppLabel(),
+ simulatedPlatformVersion);
+ }
+
+ addViews(titleBar, mContentRoot == null ? (mContentRoot = createContentFrame()) : actionBar,
+ statusBar, navBar);
+ // Done with the builder. Don't hold a reference to it.
+ mBuilder = null;
+ }
+
+ @NonNull
+ private FrameLayout createContentFrame() {
+ FrameLayout contentRoot = new FrameLayout(getContext());
+ LayoutParams params = createLayoutParams(MATCH_PARENT, MATCH_PARENT);
+ int rule = mBuilder.isNavBarVertical() ? START_OF : ABOVE;
+ if (mBuilder.solidBars()) {
+ params.addRule(rule, getId(ID_NAV_BAR));
+ }
+ int below = -1;
+ if (mBuilder.mActionBarSize <= 0 && mBuilder.mTitleBarSize > 0) {
+ below = getId(ID_TITLE_BAR);
+ } else if (mBuilder.solidBars()) {
+ below = getId(ID_STATUS_BAR);
+ }
+ if (below != -1) {
+ params.addRule(BELOW, below);
+ }
+ contentRoot.setLayoutParams(params);
+ return contentRoot;
+ }
+
+ @NonNull
+ private LayoutParams createLayoutParams(int width, int height) {
+ DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
+ if (width > 0) {
+ width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, width, metrics);
+ }
+ if (height > 0) {
+ height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, height, metrics);
+ }
+ return new LayoutParams(width, height);
+ }
+
+ @NonNull
+ public FrameLayout getContentRoot() {
+ return mContentRoot;
+ }
+
+ @NonNull
+ private SessionParams getParams() {
+ return mBuilder.mParams;
+ }
+
+ @NonNull
+ @Override
+ public BridgeContext getContext(){
+ return (BridgeContext) super.getContext();
+ }
+
+ /**
+ * @param isRtl whether the current locale is an RTL locale.
+ * @param isRtlSupported whether the applications supports RTL (i.e. has supportsRtl=true
+ * in the manifest and targetSdkVersion >= 17.
+ */
+ @NonNull
+ private StatusBar createStatusBar(BridgeContext context, Density density, boolean isRtl,
+ boolean isRtlSupported, int simulatedPlatformVersion) {
+ StatusBar statusBar =
+ new StatusBar(context, density, isRtl, isRtlSupported, simulatedPlatformVersion);
+ LayoutParams params = createLayoutParams(MATCH_PARENT, mBuilder.mStatusBarSize);
+ if (mBuilder.isNavBarVertical()) {
+ params.addRule(START_OF, getId(ID_NAV_BAR));
+ }
+ statusBar.setLayoutParams(params);
+ statusBar.setId(getId(ID_STATUS_BAR));
+ return statusBar;
+ }
+
+ private BridgeActionBar createActionBar(@NonNull BridgeContext context,
+ @NonNull SessionParams params) {
+ BridgeActionBar actionBar;
+ if (mBuilder.isThemeAppCompat()) {
+ actionBar = new AppCompatActionBar(context, params);
+ } else {
+ actionBar = new FrameworkActionBar(context, params);
+ }
+ LayoutParams layoutParams = createLayoutParams(MATCH_PARENT, MATCH_PARENT);
+ int rule = mBuilder.isNavBarVertical() ? START_OF : ABOVE;
+ if (mBuilder.solidBars()) {
+ layoutParams.addRule(rule, getId(ID_NAV_BAR));
+ }
+ if (mBuilder.solidBars()) {
+ layoutParams.addRule(BELOW, getId(ID_STATUS_BAR));
+ }
+ actionBar.getRootView().setLayoutParams(layoutParams);
+ actionBar.createMenuPopup();
+ return actionBar;
+ }
+
+ @NonNull
+ private TitleBar createTitleBar(BridgeContext context, String title,
+ int simulatedPlatformVersion) {
+ TitleBar titleBar = new TitleBar(context, title, simulatedPlatformVersion);
+ LayoutParams params = createLayoutParams(MATCH_PARENT, mBuilder.mTitleBarSize);
+ if (mBuilder.solidBars()) {
+ params.addRule(BELOW, getId(ID_STATUS_BAR));
+ }
+ if (mBuilder.isNavBarVertical() && mBuilder.solidBars()) {
+ params.addRule(START_OF, getId(ID_NAV_BAR));
+ }
+ titleBar.setLayoutParams(params);
+ titleBar.setId(getId(ID_TITLE_BAR));
+ return titleBar;
+ }
+
+ /**
+ * @param isRtl whether the current locale is an RTL locale.
+ * @param isRtlSupported whether the applications supports RTL (i.e. has supportsRtl=true
+ * in the manifest and targetSdkVersion >= 17.
+ */
+ @NonNull
+ private NavigationBar createNavBar(BridgeContext context, Density density, boolean isRtl,
+ boolean isRtlSupported, int simulatedPlatformVersion) {
+ int orientation = mBuilder.mNavBarOrientation;
+ int size = mBuilder.mNavBarSize;
+ NavigationBar navBar = new NavigationBar(context, density, orientation, isRtl,
+ isRtlSupported, simulatedPlatformVersion);
+ boolean isVertical = mBuilder.isNavBarVertical();
+ int w = isVertical ? size : MATCH_PARENT;
+ int h = isVertical ? MATCH_PARENT : size;
+ LayoutParams params = createLayoutParams(w, h);
+ params.addRule(isVertical ? ALIGN_PARENT_END : ALIGN_PARENT_BOTTOM);
+ navBar.setLayoutParams(params);
+ navBar.setId(getId(ID_NAV_BAR));
+ return navBar;
+ }
+
+ private void addViews(@NonNull View... views) {
+ for (View view : views) {
+ if (view != null) {
+ addView(view);
+ }
+ }
+ }
+
+ private int getId(String name) {
+ return Bridge.getResourceId(ResourceType.ID, ID_PREFIX + name);
+ }
+
+ /**
+ * A helper class to help initialize the Layout.
+ */
+ static class Builder {
+ @NonNull
+ private final SessionParams mParams;
+ @NonNull
+ private final BridgeContext mContext;
+ private final RenderResources mResources;
+
+ private final boolean mWindowIsFloating;
+ private ResourceValue mWindowBackground;
+ private int mStatusBarSize;
+ private int mNavBarSize;
+ private int mNavBarOrientation;
+ private int mActionBarSize;
+ private int mTitleBarSize;
+ private boolean mTranslucentStatus;
+ private boolean mTranslucentNav;
+
+ private Boolean mIsThemeAppCompat;
+
+ public Builder(@NonNull SessionParams params, @NonNull BridgeContext context) {
+ mParams = params;
+ mContext = context;
+ mResources = mParams.getResources();
+ mWindowIsFloating = ResourceHelper.getBooleanThemeValue(mResources, ATTR_WINDOW_FLOATING, true, true);
+
+ findBackground();
+ findStatusBar();
+ findActionBar();
+ findNavBar();
+ }
+
+ public boolean isNavBarVertical() {
+ return mNavBarOrientation == VERTICAL;
+ }
+
+ private void findBackground() {
+ if (!mParams.isBgColorOverridden()) {
+ mWindowBackground = mResources.findItemInTheme(ATTR_WINDOW_BACKGROUND, true);
+ mWindowBackground = mResources.resolveResValue(mWindowBackground);
+ }
+ }
+
+ private void findStatusBar() {
+ boolean windowFullScreen =
+ ResourceHelper.getBooleanThemeValue(mResources, ATTR_WINDOW_FULL_SCREEN, true, false);
+ if (!windowFullScreen && !mWindowIsFloating) {
+ mStatusBarSize =
+ getDimension(ATTR_STATUS_BAR_HEIGHT, true, DEFAULT_STATUS_BAR_HEIGHT);
+ mTranslucentStatus = ResourceHelper.getBooleanThemeValue(mResources,
+ ATTR_WINDOW_TRANSLUCENT_STATUS, true, false);
+ }
+ }
+
+ private void findActionBar() {
+ if (mWindowIsFloating) {
+ return;
+ }
+ // Check if an actionbar is needed
+ boolean windowActionBar = ResourceHelper.getBooleanThemeValue(mResources, ATTR_WINDOW_ACTION_BAR,
+ !isThemeAppCompat(), true);
+ if (windowActionBar) {
+ mActionBarSize = getDimension(ATTR_ACTION_BAR_SIZE, true, DEFAULT_TITLE_BAR_HEIGHT);
+ } else {
+ // Maybe the gingerbread era title bar is needed
+ boolean windowNoTitle =
+ ResourceHelper.getBooleanThemeValue(mResources, ATTR_WINDOW_NO_TITLE, true, false);
+ if (!windowNoTitle) {
+ mTitleBarSize =
+ getDimension(ATTR_WINDOW_TITLE_SIZE, true, DEFAULT_TITLE_BAR_HEIGHT);
+ }
+ }
+ }
+
+ private void findNavBar() {
+ if (hasSoftwareButtons() && !mWindowIsFloating) {
+
+ // get orientation
+ HardwareConfig hwConfig = mParams.getHardwareConfig();
+ boolean barOnBottom = true;
+
+ if (hwConfig.getOrientation() == ScreenOrientation.LANDSCAPE) {
+ int shortSize = hwConfig.getScreenHeight();
+ int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT /
+ hwConfig.getDensity().getDpiValue();
+
+ // 0-599dp: "phone" UI with bar on the side
+ // 600+dp: "tablet" UI with bar on the bottom
+ barOnBottom = shortSizeDp >= 600;
+ }
+
+ mNavBarOrientation = barOnBottom ? LinearLayout.HORIZONTAL : VERTICAL;
+ mNavBarSize = getDimension(barOnBottom ? ATTR_NAV_BAR_HEIGHT : ATTR_NAV_BAR_WIDTH,
+ true, DEFAULT_NAV_BAR_SIZE);
+ mTranslucentNav = ResourceHelper.getBooleanThemeValue(mResources,
+ ATTR_WINDOW_TRANSLUCENT_NAV, true, false);
+ }
+ }
+
+ private int getDimension(String attr, boolean isFramework, int defaultValue) {
+ ResourceValue value = mResources.findItemInTheme(attr, isFramework);
+ value = mResources.resolveResValue(value);
+ if (value != null) {
+ TypedValue typedValue = ResourceHelper.getValue(attr, value.getValue(), true);
+ if (typedValue != null) {
+ return (int) typedValue.getDimension(mContext.getMetrics());
+ }
+ }
+ return defaultValue;
+ }
+
+ private boolean hasSoftwareButtons() {
+ return mParams.getHardwareConfig().hasSoftwareButtons();
+ }
+
+ private boolean isThemeAppCompat() {
+ // If a cached value exists, return it.
+ if (mIsThemeAppCompat != null) {
+ return mIsThemeAppCompat;
+ }
+ // Ideally, we should check if the corresponding activity extends
+ // android.support.v7.app.ActionBarActivity, and not care about the theme name at all.
+ StyleResourceValue defaultTheme = mResources.getDefaultTheme();
+ // We can't simply check for parent using resources.themeIsParentOf() since the
+ // inheritance structure isn't really what one would expect. The first common parent
+ // between Theme.AppCompat.Light and Theme.AppCompat is Theme.Material (for v21).
+ boolean isThemeAppCompat = false;
+ for (int i = 0; i < 50; i++) {
+ if (defaultTheme == null) {
+ break;
+ }
+ // for loop ensures that we don't run into cyclic theme inheritance.
+ if (defaultTheme.getName().startsWith(PREFIX_THEME_APPCOMPAT)) {
+ isThemeAppCompat = true;
+ break;
+ }
+ defaultTheme = mResources.getParent(defaultTheme);
+ }
+ mIsThemeAppCompat = isThemeAppCompat;
+ return isThemeAppCompat;
+ }
+
+ /**
+ * Return if both status bar and nav bar are solid (content doesn't overlap with these
+ * bars).
+ */
+ private boolean solidBars() {
+ return hasNavBar() && !mTranslucentNav && !mTranslucentStatus && mStatusBarSize > 0;
+ }
+
+ private boolean hasNavBar() {
+ return Config.showOnScreenNavBar(mParams.getSimulatedPlatformVersion()) &&
+ hasSoftwareButtons() && mNavBarSize > 0;
+ }
+ }
+}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
index 6a9d5dd6..ac7c409 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
@@ -29,10 +29,8 @@
import com.android.ide.common.rendering.api.Result.Status;
import com.android.ide.common.rendering.api.SessionParams;
import com.android.ide.common.rendering.api.SessionParams.RenderingMode;
-import com.android.ide.common.rendering.api.StyleResourceValue;
import com.android.ide.common.rendering.api.ViewInfo;
import com.android.ide.common.rendering.api.ViewType;
-import com.android.internal.util.XmlUtils;
import com.android.internal.view.menu.ActionMenuItemView;
import com.android.internal.view.menu.BridgeMenuItemImpl;
import com.android.internal.view.menu.IconMenuItemView;
@@ -45,22 +43,11 @@
import com.android.layoutlib.bridge.android.BridgeXmlBlockParser;
import com.android.layoutlib.bridge.android.RenderParamsFlags;
import com.android.layoutlib.bridge.android.support.DesignLibUtil;
-import com.android.layoutlib.bridge.bars.AppCompatActionBar;
-import com.android.layoutlib.bridge.bars.BridgeActionBar;
-import com.android.layoutlib.bridge.bars.Config;
-import com.android.layoutlib.bridge.bars.FrameworkActionBar;
-import com.android.layoutlib.bridge.bars.NavigationBar;
-import com.android.layoutlib.bridge.bars.StatusBar;
-import com.android.layoutlib.bridge.bars.TitleBar;
import com.android.layoutlib.bridge.impl.binding.FakeAdapter;
import com.android.layoutlib.bridge.impl.binding.FakeExpandableAdapter;
-import com.android.resources.Density;
import com.android.resources.ResourceType;
-import com.android.resources.ScreenOrientation;
import com.android.util.Pair;
-import org.xmlpull.v1.XmlPullParserException;
-
import android.animation.AnimationThread;
import android.animation.Animator;
import android.animation.AnimatorInflater;
@@ -72,10 +59,7 @@
import android.graphics.Bitmap;
import android.graphics.Bitmap_Delegate;
import android.graphics.Canvas;
-import android.graphics.drawable.Drawable;
import android.preference.Preference_Delegate;
-import android.util.DisplayMetrics;
-import android.util.TypedValue;
import android.view.AttachInfo_Accessor;
import android.view.BridgeInflater;
import android.view.IWindowManager;
@@ -126,33 +110,22 @@
*/
public class RenderSessionImpl extends RenderAction<SessionParams> {
- private static final int DEFAULT_TITLE_BAR_HEIGHT = 25;
- private static final int DEFAULT_STATUS_BAR_HEIGHT = 25;
-
// scene state
private RenderSession mScene;
private BridgeXmlBlockParser mBlockParser;
private BridgeInflater mInflater;
- private ResourceValue mWindowBackground;
private ViewGroup mViewRoot;
private FrameLayout mContentRoot;
private Canvas mCanvas;
private int mMeasuredScreenWidth = -1;
private int mMeasuredScreenHeight = -1;
private boolean mIsAlphaChannelImage;
- private boolean mWindowIsFloating;
- private Boolean mIsThemeAppCompat;
-
- private int mStatusBarSize;
- private int mNavigationBarSize;
- private int mNavigationBarOrientation = LinearLayout.HORIZONTAL;
- private int mTitleBarSize;
- private int mActionBarSize;
// information being returned through the API
private BufferedImage mImage;
private List<ViewInfo> mViewInfoList;
private List<ViewInfo> mSystemViewInfoList;
+ private Layout.Builder mLayoutBuilder;
private static final class PostInflateException extends Exception {
private static final long serialVersionUID = 1L;
@@ -196,34 +169,24 @@
SessionParams params = getParams();
BridgeContext context = getContext();
-
- RenderResources resources = getParams().getResources();
- DisplayMetrics metrics = getContext().getMetrics();
-
// use default of true in case it's not found to use alpha by default
- mIsAlphaChannelImage = getBooleanThemeValue(resources, "windowIsFloating", true, true);
- // FIXME: Find out why both variables are taking the same value.
- mWindowIsFloating = getBooleanThemeValue(resources, "windowIsFloating", true, true);
+ mIsAlphaChannelImage = ResourceHelper.getBooleanThemeValue(params.getResources(),
+ "windowIsFloating", true, true);
- findBackground(resources);
- findStatusBar(resources, metrics);
- findActionBar(resources, metrics);
- findNavigationBar(resources, metrics);
+ mLayoutBuilder = new Layout.Builder(params, context);
// FIXME: find those out, and possibly add them to the render params
boolean hasNavigationBar = true;
//noinspection ConstantConditions
IWindowManager iwm = new IWindowManagerImpl(getContext().getConfiguration(),
- metrics, Surface.ROTATION_0,
- hasNavigationBar);
+ context.getMetrics(), Surface.ROTATION_0, hasNavigationBar);
WindowManagerGlobal_Delegate.setWindowManagerService(iwm);
// build the inflater and parser.
mInflater = new BridgeInflater(context, params.getLayoutlibCallback());
context.setBridgeInflater(mInflater);
- mBlockParser = new BridgeXmlBlockParser(
- params.getLayoutDescription(), context, false /* platformResourceFlag */);
+ mBlockParser = new BridgeXmlBlockParser(params.getLayoutDescription(), context, false);
return SUCCESS.createResult();
}
@@ -240,164 +203,11 @@
checkLock();
try {
-
+ mViewRoot = new Layout(mLayoutBuilder);
+ mLayoutBuilder = null; // Done with the builder.
+ mContentRoot = ((Layout) mViewRoot).getContentRoot();
SessionParams params = getParams();
- HardwareConfig hardwareConfig = params.getHardwareConfig();
BridgeContext context = getContext();
- boolean isRtl = Bridge.isLocaleRtl(params.getLocale());
- int layoutDirection = isRtl ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR;
-
- // the view group that receives the window background.
- ViewGroup backgroundView;
-
- if (mWindowIsFloating || params.isForceNoDecor()) {
- backgroundView = mViewRoot = mContentRoot = new FrameLayout(context);
- mViewRoot.setLayoutDirection(layoutDirection);
- } else {
- int simulatedPlatformVersion = params.getSimulatedPlatformVersion();
- if (hasSoftwareButtons() && mNavigationBarOrientation == LinearLayout.VERTICAL) {
- /*
- * This is a special case where the navigation bar is on the right.
- +-------------------------------------------------+---+
- | Status bar (always) | |
- +-------------------------------------------------+ |
- | (Layout with background drawable) | |
- | +---------------------------------------------+ | |
- | | Title/Action bar (optional) | | |
- | +---------------------------------------------+ | |
- | | Content, vertical extending | | |
- | | | | |
- | +---------------------------------------------+ | |
- +-------------------------------------------------+---+
-
- So we create a horizontal layout, with the nav bar on the right,
- and the left part is the normal layout below without the nav bar at
- the bottom
- */
- LinearLayout topLayout = new LinearLayout(context);
- topLayout.setLayoutDirection(layoutDirection);
- mViewRoot = topLayout;
- topLayout.setOrientation(LinearLayout.HORIZONTAL);
-
- if (Config.showOnScreenNavBar(simulatedPlatformVersion)) {
- try {
- NavigationBar navigationBar = createNavigationBar(context,
- hardwareConfig.getDensity(), isRtl, params.isRtlSupported(),
- simulatedPlatformVersion);
- topLayout.addView(navigationBar);
- } catch (XmlPullParserException ignored) {
- }
- }
- }
-
- /*
- * we're creating the following layout
- *
- +-------------------------------------------------+
- | Status bar (always) |
- +-------------------------------------------------+
- | (Layout with background drawable) |
- | +---------------------------------------------+ |
- | | Title/Action bar (optional) | |
- | +---------------------------------------------+ |
- | | Content, vertical extending | |
- | | | |
- | +---------------------------------------------+ |
- +-------------------------------------------------+
- | Navigation bar for soft buttons, maybe see above|
- +-------------------------------------------------+
-
- */
-
- LinearLayout topLayout = new LinearLayout(context);
- topLayout.setOrientation(LinearLayout.VERTICAL);
- topLayout.setLayoutDirection(layoutDirection);
- // if we don't already have a view root this is it
- if (mViewRoot == null) {
- mViewRoot = topLayout;
- } else {
- int topLayoutWidth =
- params.getHardwareConfig().getScreenWidth() - mNavigationBarSize;
- LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
- topLayoutWidth, LayoutParams.MATCH_PARENT);
- topLayout.setLayoutParams(layoutParams);
-
- // this is the case of soft buttons + vertical bar.
- // this top layout is the first layout in the horizontal layout. see above)
- if (isRtl && params.isRtlSupported()) {
- // If RTL is enabled, layoutlib will mirror the layouts. So, add the
- // topLayout to the right of Navigation Bar and layoutlib will draw it
- // to the left.
- mViewRoot.addView(topLayout);
- } else {
- // Add the top layout to the left of the Navigation Bar.
- mViewRoot.addView(topLayout, 0);
- }
- }
-
- if (mStatusBarSize > 0) {
- // system bar
- try {
- StatusBar statusBar = createStatusBar(context, hardwareConfig.getDensity(),
- layoutDirection, params.isRtlSupported(),
- simulatedPlatformVersion);
- topLayout.addView(statusBar);
- } catch (XmlPullParserException ignored) {
-
- }
- }
-
- LinearLayout backgroundLayout = new LinearLayout(context);
- backgroundView = backgroundLayout;
- backgroundLayout.setOrientation(LinearLayout.VERTICAL);
- LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
- LayoutParams.MATCH_PARENT, 0);
- layoutParams.weight = 1;
- backgroundLayout.setLayoutParams(layoutParams);
- topLayout.addView(backgroundLayout);
-
-
- // if the theme says no title/action bar, then the size will be 0
- if (mActionBarSize > 0) {
- BridgeActionBar actionBar = createActionBar(context, params, backgroundLayout);
- actionBar.createMenuPopup();
- mContentRoot = actionBar.getContentRoot();
- } else if (mTitleBarSize > 0) {
- try {
- TitleBar titleBar = createTitleBar(context,
- params.getAppLabel(),
- simulatedPlatformVersion);
- backgroundLayout.addView(titleBar);
- } catch (XmlPullParserException ignored) {
-
- }
- }
-
- // content frame
- if (mContentRoot == null) {
- mContentRoot = new FrameLayout(context);
- layoutParams = new LinearLayout.LayoutParams(
- LayoutParams.MATCH_PARENT, 0);
- layoutParams.weight = 1;
- mContentRoot.setLayoutParams(layoutParams);
- backgroundLayout.addView(mContentRoot);
- }
-
- if (Config.showOnScreenNavBar(simulatedPlatformVersion) &&
- mNavigationBarOrientation == LinearLayout.HORIZONTAL &&
- mNavigationBarSize > 0) {
- // system bar
- try {
- NavigationBar navigationBar = createNavigationBar(context,
- hardwareConfig.getDensity(), isRtl, params.isRtlSupported(),
- simulatedPlatformVersion);
- topLayout.addView(navigationBar);
- } catch (XmlPullParserException ignored) {
-
- }
- }
- }
-
// Sets the project callback (custom view loader) to the fragment delegate so that
// it can instantiate the custom Fragment.
@@ -408,7 +218,7 @@
View view;
if (isPreference) {
view = Preference_Delegate.inflatePreference(getContext(), mBlockParser,
- mContentRoot);
+ mContentRoot);
} else {
view = mInflater.inflate(mBlockParser, mContentRoot);
}
@@ -427,12 +237,6 @@
setActiveToolbar(view, context, params);
- // get the background drawable
- if (mWindowBackground != null) {
- Drawable d = ResourceHelper.getDrawable(mWindowBackground, context);
- backgroundView.setBackground(d);
- }
-
return SUCCESS.createResult();
} catch (PostInflateException e) {
return ERROR_INFLATION.createResult(e.getMessage(), e);
@@ -1073,198 +877,6 @@
}
}
-
- private void findBackground(RenderResources resources) {
- if (!getParams().isBgColorOverridden()) {
- mWindowBackground = resources.findItemInTheme("windowBackground",
- true /*isFrameworkAttr*/);
- if (mWindowBackground != null) {
- mWindowBackground = resources.resolveResValue(mWindowBackground);
- }
- }
- }
-
- private boolean hasSoftwareButtons() {
- return getParams().getHardwareConfig().hasSoftwareButtons();
- }
-
- private void findStatusBar(RenderResources resources, DisplayMetrics metrics) {
- boolean windowFullscreen = getBooleanThemeValue(resources,
- "windowFullscreen", false, true);
-
- if (!windowFullscreen && !mWindowIsFloating) {
- // default value
- mStatusBarSize = DEFAULT_STATUS_BAR_HEIGHT;
-
- // get the real value
- ResourceValue value = resources.getFrameworkResource(ResourceType.DIMEN,
- "status_bar_height");
-
- if (value != null) {
- TypedValue typedValue = ResourceHelper.getValue("status_bar_height",
- value.getValue(), true /*requireUnit*/);
- if (typedValue != null) {
- // compute the pixel value based on the display metrics
- mStatusBarSize = (int)typedValue.getDimension(metrics);
- }
- }
- }
- }
-
- private void findActionBar(RenderResources resources, DisplayMetrics metrics) {
- if (mWindowIsFloating) {
- return;
- }
-
- boolean windowActionBar = getBooleanThemeValue(resources,
- "windowActionBar", true, !isThemeAppCompat(resources));
-
- // if there's a value and it's false (default is true)
- if (windowActionBar) {
-
- // default size of the window title bar
- mActionBarSize = DEFAULT_TITLE_BAR_HEIGHT;
-
- // get value from the theme.
- ResourceValue value = resources.findItemInTheme("actionBarSize",
- true /*isFrameworkAttr*/);
-
- // resolve it
- value = resources.resolveResValue(value);
-
- if (value != null) {
- // get the numerical value, if available
- TypedValue typedValue = ResourceHelper.getValue("actionBarSize", value.getValue(),
- true /*requireUnit*/);
- if (typedValue != null) {
- // compute the pixel value based on the display metrics
- mActionBarSize = (int)typedValue.getDimension(metrics);
- }
- }
- } else {
- // action bar overrides title bar so only look for this one if action bar is hidden
- boolean windowNoTitle = getBooleanThemeValue(resources, "windowNoTitle", false, true);
-
- if (!windowNoTitle) {
-
- // default size of the window title bar
- mTitleBarSize = DEFAULT_TITLE_BAR_HEIGHT;
-
- // get value from the theme.
- ResourceValue value = resources.findItemInTheme("windowTitleSize",
- true /*isFrameworkAttr*/);
-
- // resolve it
- value = resources.resolveResValue(value);
-
- if (value != null) {
- // get the numerical value, if available
- TypedValue typedValue = ResourceHelper.getValue("windowTitleSize",
- value.getValue(), true /*requireUnit*/);
- if (typedValue != null) {
- // compute the pixel value based on the display metrics
- mTitleBarSize = (int)typedValue.getDimension(metrics);
- }
- }
- }
-
- }
- }
-
- private void findNavigationBar(RenderResources resources, DisplayMetrics metrics) {
- if (hasSoftwareButtons() && !mWindowIsFloating) {
-
- // default value
- mNavigationBarSize = 48; // ??
-
- HardwareConfig hardwareConfig = getParams().getHardwareConfig();
-
- boolean barOnBottom = true;
-
- if (hardwareConfig.getOrientation() == ScreenOrientation.LANDSCAPE) {
- // compute the dp of the screen.
- int shortSize = hardwareConfig.getScreenHeight();
-
- // compute in dp
- int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT /
- hardwareConfig.getDensity().getDpiValue();
-
- // 0-599dp: "phone" UI with bar on the side
- // 600+dp: "tablet" UI with bar on the bottom
- barOnBottom = shortSizeDp >= 600;
- }
-
- if (barOnBottom) {
- mNavigationBarOrientation = LinearLayout.HORIZONTAL;
- } else {
- mNavigationBarOrientation = LinearLayout.VERTICAL;
- }
-
- // get the real value
- ResourceValue value = resources.getFrameworkResource(ResourceType.DIMEN,
- barOnBottom ? "navigation_bar_height" : "navigation_bar_width");
-
- if (value != null) {
- TypedValue typedValue = ResourceHelper.getValue("navigation_bar_height",
- value.getValue(), true /*requireUnit*/);
- if (typedValue != null) {
- // compute the pixel value based on the display metrics
- mNavigationBarSize = (int)typedValue.getDimension(metrics);
- }
- }
- }
- }
-
- private boolean isThemeAppCompat(RenderResources resources) {
- // Ideally, we should check if the corresponding activity extends
- // android.support.v7.app.ActionBarActivity, and not care about the theme name at all.
- if (mIsThemeAppCompat == null) {
- StyleResourceValue defaultTheme = resources.getDefaultTheme();
- // We can't simply check for parent using resources.themeIsParentOf() since the
- // inheritance structure isn't really what one would expect. The first common parent
- // between Theme.AppCompat.Light and Theme.AppCompat is Theme.Material (for v21).
- boolean isThemeAppCompat = false;
- for (int i = 0; i < 50; i++) {
- if (defaultTheme == null) {
- break;
- }
- // for loop ensures that we don't run into cyclic theme inheritance.
- if (defaultTheme.getName().startsWith("Theme.AppCompat")) {
- isThemeAppCompat = true;
- break;
- }
- defaultTheme = resources.getParent(defaultTheme);
- }
- mIsThemeAppCompat = isThemeAppCompat;
- }
- return mIsThemeAppCompat;
- }
-
- /**
- * Looks for an attribute in the current theme.
- *
- * @param resources the render resources
- * @param name the name of the attribute
- * @param defaultValue the default value.
- * @param isFrameworkAttr if the attribute is in android namespace
- * @return the value of the attribute or the default one if not found.
- */
- private boolean getBooleanThemeValue(RenderResources resources,
- String name, boolean defaultValue, boolean isFrameworkAttr) {
-
- ResourceValue value = resources.findItemInTheme(name, isFrameworkAttr);
-
- // because it may reference something else, we resolve it.
- value = resources.resolveResValue(value);
-
- // if there's no value, return the default.
- if (value == null || value.getValue() == null) {
- return defaultValue;
- }
-
- return XmlUtils.convertValueToBoolean(value.getValue(), defaultValue);
- }
-
/**
* Post process on a view hierarchy that was just inflated.
* <p/>
@@ -1737,63 +1349,6 @@
mMeasuredScreenWidth = mMeasuredScreenHeight = -1;
}
- /**
- * Creates the status bar with wifi and battery icons.
- */
- private StatusBar createStatusBar(BridgeContext context, Density density, int direction,
- boolean isRtlSupported, int platformVersion) throws XmlPullParserException {
- StatusBar statusBar = new StatusBar(context, density,
- direction, isRtlSupported, platformVersion);
- statusBar.setLayoutParams(
- new LinearLayout.LayoutParams(
- LayoutParams.MATCH_PARENT, mStatusBarSize));
- return statusBar;
- }
-
- /**
- * Creates the navigation bar with back, home and recent buttons.
- *
- * @param isRtl true if the current locale is right-to-left
- * @param isRtlSupported true is the project manifest declares that the application
- * is RTL aware.
- */
- private NavigationBar createNavigationBar(BridgeContext context, Density density,
- boolean isRtl, boolean isRtlSupported, int simulatedPlatformVersion)
- throws XmlPullParserException {
- NavigationBar navigationBar = new NavigationBar(context,
- density, mNavigationBarOrientation, isRtl,
- isRtlSupported, simulatedPlatformVersion);
- if (mNavigationBarOrientation == LinearLayout.VERTICAL) {
- navigationBar.setLayoutParams(new LinearLayout.LayoutParams(mNavigationBarSize,
- LayoutParams.MATCH_PARENT));
- } else {
- navigationBar.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
- mNavigationBarSize));
- }
- return navigationBar;
- }
-
- private TitleBar createTitleBar(BridgeContext context, String title,
- int simulatedPlatformVersion)
- throws XmlPullParserException {
- TitleBar titleBar = new TitleBar(context, title, simulatedPlatformVersion);
- titleBar.setLayoutParams(
- new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, mTitleBarSize));
- return titleBar;
- }
-
- /**
- * Creates the action bar. Also queries the project callback for missing information.
- */
- private BridgeActionBar createActionBar(BridgeContext context, SessionParams params,
- ViewGroup parentView) {
- if (mIsThemeAppCompat == Boolean.TRUE) {
- return new AppCompatActionBar(context, params, parentView);
- } else {
- return new FrameworkActionBar(context, params, parentView);
- }
- }
-
public BufferedImage getImage() {
return mImage;
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
index ca77193..c72eeb1 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
@@ -21,6 +21,7 @@
import com.android.ide.common.rendering.api.LayoutLog;
import com.android.ide.common.rendering.api.RenderResources;
import com.android.ide.common.rendering.api.ResourceValue;
+import com.android.internal.util.XmlUtils;
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.android.BridgeContext;
import com.android.layoutlib.bridge.android.BridgeXmlBlockParser;
@@ -327,6 +328,25 @@
return null;
}
+ /**
+ * Looks for an attribute in the current theme.
+ *
+ * @param resources the render resources
+ * @param name the name of the attribute
+ * @param defaultValue the default value.
+ * @param isFrameworkAttr if the attribute is in android namespace
+ * @return the value of the attribute or the default one if not found.
+ */
+ public static boolean getBooleanThemeValue(@NonNull RenderResources resources, String name,
+ boolean isFrameworkAttr, boolean defaultValue) {
+ ResourceValue value = resources.findItemInTheme(name, isFrameworkAttr);
+ value = resources.resolveResValue(value);
+ if (value == null) {
+ return defaultValue;
+ }
+ return XmlUtils.convertValueToBoolean(value.getValue(), defaultValue);
+ }
+
// ------- TypedValue stuff
// This is taken from //device/libs/utils/ResourceTypes.cpp
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index f390075..d915e5d 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -1302,7 +1302,7 @@
* Return the results of the latest access point scan.
* @return the list of access points found in the most recent scan. An app must hold
* {@link android.Manifest.permission#ACCESS_COARSE_LOCATION ACCESS_COARSE_LOCATION} or
- * {@link android.Manifest.permission#ACCESS_COARSE_LOCATION ACCESS_FINE_LOCATION} permission
+ * {@link android.Manifest.permission#ACCESS_FINE_LOCATION ACCESS_FINE_LOCATION} permission
* in order to get valid results.
*/
public List<ScanResult> getScanResults() {