summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-rw-r--r--services/Android.mk4
-rw-r--r--services/accessibility/java/com/android/server/accessibility/GestureUtils.java6
-rw-r--r--services/core/java/com/android/server/AlarmManagerService.java2
-rw-r--r--services/core/java/com/android/server/LocationManagerService.java3
-rw-r--r--services/core/java/com/android/server/MountService.java30
-rw-r--r--services/core/java/com/android/server/NetworkManagementService.java93
-rw-r--r--services/core/java/com/android/server/TwilightCalculator.java15
-rwxr-xr-xservices/core/java/com/android/server/am/ActiveServices.java1
-rw-r--r--[-rwxr-xr-x]services/core/java/com/android/server/am/ActivityManagerService.java104
-rw-r--r--[-rwxr-xr-x]services/core/java/com/android/server/am/ActivityStack.java5
-rw-r--r--services/core/java/com/android/server/am/ProcessStatsService.java32
-rw-r--r--services/core/java/com/android/server/location/GpsLocationProvider.java2
-rw-r--r--services/core/java/com/android/server/location/GpsXtraDownloader.java86
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java2
-rw-r--r--services/core/java/com/android/server/pm/SELinuxMMAC.java732
-rw-r--r--services/core/java/com/android/server/updates/ConfigUpdateInstallReceiver.java1
-rw-r--r--services/core/java/com/android/server/wm/DisplayContent.java1
-rw-r--r--services/core/java/com/android/server/wm/StackTapPointerEventListener.java29
-rw-r--r--services/core/java/com/android/server/wm/TaskStack.java4
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java30
-rw-r--r--services/core/java/com/android/server/wm/WindowState.java34
-rw-r--r--services/core/jni/Android.mk8
-rw-r--r--services/core/jni/com_android_server_AlarmManagerService.cpp82
-rw-r--r--services/core/jni/com_android_server_AssetAtlasService.cpp4
-rw-r--r--services/core/jni/com_android_server_ConsumerIrService.cpp6
-rw-r--r--services/core/jni/com_android_server_SerialService.cpp2
-rw-r--r--services/core/jni/com_android_server_SystemServer.cpp2
-rw-r--r--services/core/jni/com_android_server_UsbDeviceManager.cpp20
-rw-r--r--services/core/jni/com_android_server_UsbHostManager.cpp5
-rw-r--r--services/core/jni/com_android_server_VibratorService.cpp6
-rw-r--r--services/core/jni/com_android_server_connectivity_Vpn.cpp14
-rw-r--r--services/core/jni/com_android_server_hdmi_HdmiCecController.cpp1
-rw-r--r--services/core/jni/com_android_server_input_InputApplicationHandle.cpp1
-rw-r--r--services/core/jni/com_android_server_input_InputManagerService.cpp75
-rw-r--r--services/core/jni/com_android_server_input_InputWindowHandle.cpp1
-rw-r--r--services/core/jni/com_android_server_lights_LightsService.cpp6
-rw-r--r--services/core/jni/com_android_server_location_FlpHardwareProvider.cpp30
-rw-r--r--services/core/jni/com_android_server_location_GpsLocationProvider.cpp100
-rw-r--r--services/core/jni/com_android_server_power_PowerManagerService.cpp9
-rw-r--r--services/core/jni/com_android_server_tv_TvInputHal.cpp1
-rw-r--r--services/core/jni/onload.cpp2
-rw-r--r--services/java/com/android/server/SystemServer.java3
42 files changed, 1044 insertions, 550 deletions
diff --git a/services/Android.mk b/services/Android.mk
index 3c94f43..da85528 100644
--- a/services/Android.mk
+++ b/services/Android.mk
@@ -48,10 +48,6 @@ include $(wildcard $(LOCAL_PATH)/*/jni/Android.mk)
LOCAL_CFLAGS += -DEGL_EGLEXT_PROTOTYPES -DGL_GLEXT_PROTOTYPES
-ifeq ($(WITH_MALLOC_LEAK_CHECK),true)
- LOCAL_CFLAGS += -DMALLOC_LEAK_CHECK
-endif
-
LOCAL_MODULE:= libandroid_servers
include $(BUILD_SHARED_LIBRARY)
diff --git a/services/accessibility/java/com/android/server/accessibility/GestureUtils.java b/services/accessibility/java/com/android/server/accessibility/GestureUtils.java
index b68b09f..bc76191 100644
--- a/services/accessibility/java/com/android/server/accessibility/GestureUtils.java
+++ b/services/accessibility/java/com/android/server/accessibility/GestureUtils.java
@@ -69,8 +69,7 @@ final class GestureUtils {
return true;
}
- final float firstMagnitude =
- (float) Math.sqrt(firstDeltaX * firstDeltaX + firstDeltaY * firstDeltaY);
+ final float firstMagnitude = (float) Math.hypot(firstDeltaX, firstDeltaY);
final float firstXNormalized =
(firstMagnitude > 0) ? firstDeltaX / firstMagnitude : firstDeltaX;
final float firstYNormalized =
@@ -83,8 +82,7 @@ final class GestureUtils {
return true;
}
- final float secondMagnitude =
- (float) Math.sqrt(secondDeltaX * secondDeltaX + secondDeltaY * secondDeltaY);
+ final float secondMagnitude = (float) Math.hypot(secondDeltaX, secondDeltaY);
final float secondXNormalized =
(secondMagnitude > 0) ? secondDeltaX / secondMagnitude : secondDeltaX;
final float secondYNormalized =
diff --git a/services/core/java/com/android/server/AlarmManagerService.java b/services/core/java/com/android/server/AlarmManagerService.java
index a9a756e..45fa373 100644
--- a/services/core/java/com/android/server/AlarmManagerService.java
+++ b/services/core/java/com/android/server/AlarmManagerService.java
@@ -1604,7 +1604,7 @@ class AlarmManagerService extends SystemService {
if (mLastAlarmDeliveryTime <= 0) {
return false;
}
- if (mPendingNonWakeupAlarms.size() > 0 && mNextNonWakeupDeliveryTime > nowELAPSED) {
+ if (mPendingNonWakeupAlarms.size() > 0 && mNextNonWakeupDeliveryTime < nowELAPSED) {
// This is just a little paranoia, if somehow we have pending non-wakeup alarms
// and the next delivery time is in the past, then just deliver them all. This
// avoids bugs where we get stuck in a loop trying to poll for alarms.
diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java
index be83b9b..eca6ec7 100644
--- a/services/core/java/com/android/server/LocationManagerService.java
+++ b/services/core/java/com/android/server/LocationManagerService.java
@@ -1452,14 +1452,13 @@ public class LocationManagerService extends ILocationManager.Stub {
if (receiver == null) {
receiver = new Receiver(listener, null, pid, uid, packageName, workSource,
hideFromAppOps);
- mReceivers.put(binder, receiver);
-
try {
receiver.getListener().asBinder().linkToDeath(receiver, 0);
} catch (RemoteException e) {
Slog.e(TAG, "linkToDeath failed:", e);
return null;
}
+ mReceivers.put(binder, receiver);
}
return receiver;
}
diff --git a/services/core/java/com/android/server/MountService.java b/services/core/java/com/android/server/MountService.java
index 6c981c0..1405fc1 100644
--- a/services/core/java/com/android/server/MountService.java
+++ b/services/core/java/com/android/server/MountService.java
@@ -76,9 +76,8 @@ import com.android.server.pm.PackageManagerService;
import com.android.server.pm.UserManagerService;
import com.google.android.collect.Lists;
import com.google.android.collect.Maps;
+import libcore.util.HexEncoding;
-import org.apache.commons.codec.binary.Hex;
-import org.apache.commons.codec.DecoderException;
import org.xmlpull.v1.XmlPullParserException;
import java.io.File;
@@ -892,6 +891,10 @@ class MountService extends IMountService.Stub
// Temporary workaround for http://b/17945169.
Slog.d(TAG, "Setting system properties to " + systemLocale + " from mount service");
+ SystemProperties.set("persist.sys.locale", locale.toLanguageTag());
+
+ // TODO: Stop setting these properties once we've removed all
+ // references to them.
SystemProperties.set("persist.sys.language", locale.getLanguage());
SystemProperties.set("persist.sys.country", locale.getCountry());
}
@@ -2204,25 +2207,21 @@ class MountService extends IMountService.Stub
}
}
- private String toHex(String password) {
+ private static String toHex(String password) {
if (password == null) {
- return new String();
+ return "";
}
byte[] bytes = password.getBytes(StandardCharsets.UTF_8);
- return new String(Hex.encodeHex(bytes));
+ return new String(HexEncoding.encode(bytes));
}
- private String fromHex(String hexPassword) {
+ private static String fromHex(String hexPassword) throws IllegalArgumentException {
if (hexPassword == null) {
return null;
}
- try {
- byte[] bytes = Hex.decodeHex(hexPassword.toCharArray());
- return new String(bytes, StandardCharsets.UTF_8);
- } catch (DecoderException e) {
- return null;
- }
+ final byte[] bytes = HexEncoding.decode(hexPassword.toCharArray(), false);
+ return new String(bytes, StandardCharsets.UTF_8);
}
@Override
@@ -2424,9 +2423,16 @@ class MountService extends IMountService.Stub
final NativeDaemonEvent event;
try {
event = mConnector.execute("cryptfs", "getpw");
+ if ("-1".equals(event.getMessage())) {
+ // -1 equals no password
+ return null;
+ }
return fromHex(event.getMessage());
} catch (NativeDaemonConnectorException e) {
throw e.rethrowAsParcelableException();
+ } catch (IllegalArgumentException e) {
+ Slog.e(TAG, "Invalid response to getPassword");
+ return null;
}
}
diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java
index 748018d..60649a6 100644
--- a/services/core/java/com/android/server/NetworkManagementService.java
+++ b/services/core/java/com/android/server/NetworkManagementService.java
@@ -24,9 +24,6 @@ import static android.net.NetworkStats.TAG_ALL;
import static android.net.NetworkStats.TAG_NONE;
import static android.net.NetworkStats.UID_ALL;
import static android.net.TrafficStats.UID_TETHERING;
-import static android.net.RouteInfo.RTN_THROW;
-import static android.net.RouteInfo.RTN_UNICAST;
-import static android.net.RouteInfo.RTN_UNREACHABLE;
import static com.android.server.NetworkManagementService.NetdResponseCode.ClatdStatusResult;
import static com.android.server.NetworkManagementService.NetdResponseCode.InterfaceGetCfgResult;
import static com.android.server.NetworkManagementService.NetdResponseCode.InterfaceListResult;
@@ -38,6 +35,7 @@ import static com.android.server.NetworkManagementService.NetdResponseCode.Tethe
import static com.android.server.NetworkManagementService.NetdResponseCode.TtyListResult;
import static com.android.server.NetworkManagementSocketTagger.PROP_QTAGUID_ENABLED;
+import android.app.ActivityManagerNative;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.INetworkManagementEventObserver;
@@ -61,6 +59,7 @@ import android.os.Process;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.StrictMode;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.telephony.DataConnectionRealTimeInfo;
@@ -70,9 +69,12 @@ import android.telephony.TelephonyManager;
import android.util.Log;
import android.util.Slog;
import android.util.SparseBooleanArray;
+import android.util.SparseIntArray;
+import com.android.internal.annotations.GuardedBy;
import com.android.internal.app.IBatteryStats;
import com.android.internal.net.NetworkStatsFactory;
+import com.android.internal.util.HexDump;
import com.android.internal.util.Preconditions;
import com.android.server.NativeDaemonConnector.Command;
import com.android.server.NativeDaemonConnector.SensitiveArg;
@@ -87,8 +89,6 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
-import java.net.Inet4Address;
-import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.InterfaceAddress;
import java.net.NetworkInterface;
@@ -145,6 +145,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
public static final int InterfaceAddressChange = 614;
public static final int InterfaceDnsServerInfo = 615;
public static final int RouteChange = 616;
+ public static final int StrictCleartext = 617;
}
static final int DAEMON_MSG_MOBILE_CONN_REAL_TIME_INFO = 1;
@@ -174,12 +175,19 @@ public class NetworkManagementService extends INetworkManagementService.Stub
private final NetworkStatsFactory mStatsFactory = new NetworkStatsFactory();
private Object mQuotaLock = new Object();
+
/** Set of interfaces with active quotas. */
+ @GuardedBy("mQuotaLock")
private HashMap<String, Long> mActiveQuotas = Maps.newHashMap();
/** Set of interfaces with active alerts. */
+ @GuardedBy("mQuotaLock")
private HashMap<String, Long> mActiveAlerts = Maps.newHashMap();
/** Set of UIDs with active reject rules. */
+ @GuardedBy("mQuotaLock")
private SparseBooleanArray mUidRejectOnQuota = new SparseBooleanArray();
+ /** Set of UIDs with cleartext penalties. */
+ @GuardedBy("mQuotaLock")
+ private SparseIntArray mUidCleartextPolicy = new SparseIntArray();
private Object mIdleTimerLock = new Object();
/** Set of interfaces with active idle timers. */
@@ -198,6 +206,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
private volatile boolean mBandwidthControlEnabled;
private volatile boolean mFirewallEnabled;
+ private volatile boolean mStrictEnabled;
private boolean mMobileActivityFromRadio = false;
private int mLastPowerStateFromRadio = DataConnectionRealTimeInfo.DC_POWER_STATE_LOW;
@@ -495,11 +504,18 @@ public class NetworkManagementService extends INetworkManagementService.Stub
}
}
+ try {
+ mConnector.execute("strict", "enable");
+ mStrictEnabled = true;
+ } catch (NativeDaemonConnectorException e) {
+ Log.wtf(TAG, "Failed strict enable", e);
+ }
+
// push any existing quota or UID rules
synchronized (mQuotaLock) {
int size = mActiveQuotas.size();
if (size > 0) {
- Slog.d(TAG, "pushing " + size + " active quota rules");
+ Slog.d(TAG, "Pushing " + size + " active quota rules");
final HashMap<String, Long> activeQuotas = mActiveQuotas;
mActiveQuotas = Maps.newHashMap();
for (Map.Entry<String, Long> entry : activeQuotas.entrySet()) {
@@ -509,7 +525,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
size = mActiveAlerts.size();
if (size > 0) {
- Slog.d(TAG, "pushing " + size + " active alert rules");
+ Slog.d(TAG, "Pushing " + size + " active alert rules");
final HashMap<String, Long> activeAlerts = mActiveAlerts;
mActiveAlerts = Maps.newHashMap();
for (Map.Entry<String, Long> entry : activeAlerts.entrySet()) {
@@ -519,13 +535,23 @@ public class NetworkManagementService extends INetworkManagementService.Stub
size = mUidRejectOnQuota.size();
if (size > 0) {
- Slog.d(TAG, "pushing " + size + " active uid rules");
+ Slog.d(TAG, "Pushing " + size + " active UID rules");
final SparseBooleanArray uidRejectOnQuota = mUidRejectOnQuota;
mUidRejectOnQuota = new SparseBooleanArray();
for (int i = 0; i < uidRejectOnQuota.size(); i++) {
setUidNetworkRules(uidRejectOnQuota.keyAt(i), uidRejectOnQuota.valueAt(i));
}
}
+
+ size = mUidCleartextPolicy.size();
+ if (size > 0) {
+ Slog.d(TAG, "Pushing " + size + " active UID cleartext policies");
+ final SparseIntArray local = mUidCleartextPolicy;
+ mUidCleartextPolicy = new SparseIntArray();
+ for (int i = 0; i < local.size(); i++) {
+ setUidCleartextNetworkPolicy(local.keyAt(i), local.valueAt(i));
+ }
+ }
}
// TODO: Push any existing firewall state
@@ -792,6 +818,14 @@ public class NetworkManagementService extends INetworkManagementService.Stub
}
throw new IllegalStateException(errorMessage);
// break;
+ case NetdResponseCode.StrictCleartext:
+ final int uid = Integer.parseInt(cooked[1]);
+ final byte[] firstPacket = HexDump.hexStringToByteArray(cooked[2]);
+ try {
+ ActivityManagerNative.getDefault().notifyCleartextNetwork(uid, firstPacket);
+ } catch (RemoteException ignored) {
+ }
+ break;
default: break;
}
return false;
@@ -1652,6 +1686,49 @@ public class NetworkManagementService extends INetworkManagementService.Stub
}
@Override
+ public void setUidCleartextNetworkPolicy(int uid, int policy) {
+ if (Binder.getCallingUid() != uid) {
+ mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
+ }
+
+ synchronized (mQuotaLock) {
+ final int oldPolicy = mUidCleartextPolicy.get(uid, StrictMode.NETWORK_POLICY_ACCEPT);
+ if (oldPolicy == policy) {
+ return;
+ }
+
+ if (!mStrictEnabled) {
+ // Module isn't enabled yet; stash the requested policy away to
+ // apply later once the daemon is connected.
+ mUidCleartextPolicy.put(uid, policy);
+ return;
+ }
+
+ final String policyString;
+ switch (policy) {
+ case StrictMode.NETWORK_POLICY_ACCEPT:
+ policyString = "accept";
+ break;
+ case StrictMode.NETWORK_POLICY_LOG:
+ policyString = "log";
+ break;
+ case StrictMode.NETWORK_POLICY_REJECT:
+ policyString = "reject";
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown policy " + policy);
+ }
+
+ try {
+ mConnector.execute("strict", "set_uid_cleartext_policy", uid, policyString);
+ mUidCleartextPolicy.put(uid, policy);
+ } catch (NativeDaemonConnectorException e) {
+ throw e.rethrowAsParcelableException();
+ }
+ }
+ }
+
+ @Override
public boolean isBandwidthControlEnabled() {
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
return mBandwidthControlEnabled;
diff --git a/services/core/java/com/android/server/TwilightCalculator.java b/services/core/java/com/android/server/TwilightCalculator.java
index a5c93b5..5839b16 100644
--- a/services/core/java/com/android/server/TwilightCalculator.java
+++ b/services/core/java/com/android/server/TwilightCalculator.java
@@ -17,7 +17,6 @@
package com.android.server;
import android.text.format.DateUtils;
-import android.util.FloatMath;
/** @hide */
public class TwilightCalculator {
@@ -75,24 +74,24 @@ public class TwilightCalculator {
final float meanAnomaly = 6.240059968f + daysSince2000 * 0.01720197f;
// true anomaly
- final float trueAnomaly = meanAnomaly + C1 * FloatMath.sin(meanAnomaly) + C2
- * FloatMath.sin(2 * meanAnomaly) + C3 * FloatMath.sin(3 * meanAnomaly);
+ final double trueAnomaly = meanAnomaly + C1 * Math.sin(meanAnomaly) + C2
+ * Math.sin(2 * meanAnomaly) + C3 * Math.sin(3 * meanAnomaly);
// ecliptic longitude
- final float solarLng = trueAnomaly + 1.796593063f + (float) Math.PI;
+ final double solarLng = trueAnomaly + 1.796593063d + Math.PI;
// solar transit in days since 2000
final double arcLongitude = -longitude / 360;
float n = Math.round(daysSince2000 - J0 - arcLongitude);
- double solarTransitJ2000 = n + J0 + arcLongitude + 0.0053f * FloatMath.sin(meanAnomaly)
- + -0.0069f * FloatMath.sin(2 * solarLng);
+ double solarTransitJ2000 = n + J0 + arcLongitude + 0.0053d * Math.sin(meanAnomaly)
+ + -0.0069d * Math.sin(2 * solarLng);
// declination of sun
- double solarDec = Math.asin(FloatMath.sin(solarLng) * FloatMath.sin(OBLIQUITY));
+ double solarDec = Math.asin(Math.sin(solarLng) * Math.sin(OBLIQUITY));
final double latRad = latiude * DEGREES_TO_RADIANS;
- double cosHourAngle = (FloatMath.sin(ALTIDUTE_CORRECTION_CIVIL_TWILIGHT) - Math.sin(latRad)
+ double cosHourAngle = (Math.sin(ALTIDUTE_CORRECTION_CIVIL_TWILIGHT) - Math.sin(latRad)
* Math.sin(solarDec)) / (Math.cos(latRad) * Math.cos(solarDec));
// The day or night never ends for the given date and location, if this value is out of
// range.
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java
index aefbf60..059dde1 100755
--- a/services/core/java/com/android/server/am/ActiveServices.java
+++ b/services/core/java/com/android/server/am/ActiveServices.java
@@ -1341,6 +1341,7 @@ public final class ActiveServices {
// We are now bringing the service up, so no longer in the
// restarting state.
if (mRestartingServices.remove(r)) {
+ r.resetRestartCounter();
clearRestartingIfNeededLocked(r);
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index e8f3757..b4c8fea 100755..100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -410,16 +410,6 @@ public final class ActivityManagerService extends ActivityManagerNative
return (isFg) ? mFgBroadcastQueue : mBgBroadcastQueue;
}
- BroadcastRecord broadcastRecordForReceiverLocked(IBinder receiver) {
- for (BroadcastQueue queue : mBroadcastQueues) {
- BroadcastRecord r = queue.getMatchingOrderedReceiver(receiver);
- if (r != null) {
- return r;
- }
- }
- return null;
- }
-
/**
* Activity we have told the window manager to have key focus.
*/
@@ -1270,6 +1260,7 @@ public final class ActivityManagerService extends ActivityManagerNative
static final int SEND_LOCALE_TO_MOUNT_DAEMON_MSG = 47;
static final int DISMISS_DIALOG_MSG = 48;
static final int NOTIFY_TASK_STACK_CHANGE_LISTENERS_MSG = 49;
+ static final int NOTIFY_CLEARTEXT_NETWORK_MSG = 50;
static final int FIRST_ACTIVITY_STACK_MSG = 100;
static final int FIRST_BROADCAST_QUEUE_MSG = 200;
@@ -1807,6 +1798,23 @@ public final class ActivityManagerService extends ActivityManagerNative
}
break;
}
+ case NOTIFY_CLEARTEXT_NETWORK_MSG: {
+ final int uid = msg.arg1;
+ final byte[] firstPacket = (byte[]) msg.obj;
+
+ synchronized (mPidsSelfLocked) {
+ for (int i = 0; i < mPidsSelfLocked.size(); i++) {
+ final ProcessRecord p = mPidsSelfLocked.valueAt(i);
+ if (p.uid == uid) {
+ try {
+ p.thread.notifyCleartextNetwork(firstPacket);
+ } catch (RemoteException ignored) {
+ }
+ }
+ }
+ }
+ break;
+ }
}
}
};
@@ -5833,6 +5841,7 @@ public final class ActivityManagerService extends ActivityManagerNative
// Take care of any services that are waiting for the process.
mServices.processStartTimedOutLocked(app);
app.kill("start timeout", true);
+ removeLruProcessLocked(app);
if (mBackupTarget != null && mBackupTarget.app.pid == pid) {
Slog.w(TAG, "Unattached app died before backup, skipping");
try {
@@ -9413,11 +9422,13 @@ public final class ActivityManagerService extends ActivityManagerNative
if (DEBUG_PROVIDER) {
Slog.d(TAG, "Installing in existing process " + proc);
}
- checkTime(startTime, "getContentProviderImpl: scheduling install");
- proc.pubProviders.put(cpi.name, cpr);
- try {
- proc.thread.scheduleInstallProvider(cpi);
- } catch (RemoteException e) {
+ if (!proc.pubProviders.containsKey(cpi.name)) {
+ checkTime(startTime, "getContentProviderImpl: scheduling install");
+ proc.pubProviders.put(cpi.name, cpr);
+ try {
+ proc.thread.scheduleInstallProvider(cpi);
+ } catch (RemoteException e) {
+ }
}
} else {
checkTime(startTime, "getContentProviderImpl: before start process");
@@ -9982,10 +9993,9 @@ public final class ActivityManagerService extends ActivityManagerNative
} finally {
// Ensure that whatever happens, we clean up the identity state
sCallerIdentity.remove();
+ // Ensure we're done with the provider.
+ removeContentProviderExternalUnchecked(name, null, userId);
}
-
- // We've got the fd now, so we're done with the provider.
- removeContentProviderExternalUnchecked(name, null, userId);
} else {
Slog.d(TAG, "Failed to get provider for authority '" + name + "'");
}
@@ -10071,6 +10081,11 @@ public final class ActivityManagerService extends ActivityManagerNative
}
@Override
+ public void notifyCleartextNetwork(int uid, byte[] firstPacket) {
+ mHandler.obtainMessage(NOTIFY_CLEARTEXT_NETWORK_MSG, uid, 0, firstPacket).sendToTarget();
+ }
+
+ @Override
public boolean shutdown(int timeout) {
if (checkCallingPermission(android.Manifest.permission.SHUTDOWN)
!= PackageManager.PERMISSION_GRANTED) {
@@ -11700,8 +11715,12 @@ public final class ActivityManagerService extends ActivityManagerNative
sb.append("\n");
if (info.crashInfo != null && info.crashInfo.stackTrace != null) {
sb.append(info.crashInfo.stackTrace);
+ sb.append("\n");
+ }
+ if (info.message != null) {
+ sb.append(info.message);
+ sb.append("\n");
}
- sb.append("\n");
// Only buffer up to ~64k. Various logging bits truncate
// things at 128k.
@@ -15692,11 +15711,11 @@ public final class ActivityManagerService extends ActivityManagerNative
synchronized(this) {
ReceiverList rl = mRegisteredReceivers.get(receiver.asBinder());
if (rl != null) {
- if (rl.curBroadcast != null) {
- BroadcastRecord r = rl.curBroadcast;
- final boolean doNext = finishReceiverLocked(
- receiver.asBinder(), r.resultCode, r.resultData,
- r.resultExtras, r.resultAbort);
+ final BroadcastRecord r = rl.curBroadcast;
+ if (r != null && r == r.queue.getMatchingOrderedReceiver(r)) {
+ final boolean doNext = r.queue.finishReceiverLocked(
+ r, r.resultCode, r.resultData, r.resultExtras,
+ r.resultAbort, false);
if (doNext) {
doTrim = true;
r.queue.processNextBroadcast(false);
@@ -16387,17 +16406,6 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
- private final boolean finishReceiverLocked(IBinder receiver, int resultCode,
- String resultData, Bundle resultExtras, boolean resultAbort) {
- final BroadcastRecord r = broadcastRecordForReceiverLocked(receiver);
- if (r == null) {
- Slog.w(TAG, "finishReceiver called but not found on queue");
- return false;
- }
-
- return r.queue.finishReceiverLocked(r, resultCode, resultData, resultExtras, resultAbort, false);
- }
-
void backgroundServicesFinishedLocked(int userId) {
for (BroadcastQueue queue : mBroadcastQueues) {
queue.backgroundServicesFinishedLocked(userId);
@@ -16405,7 +16413,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
public void finishReceiver(IBinder who, int resultCode, String resultData,
- Bundle resultExtras, boolean resultAbort) {
+ Bundle resultExtras, boolean resultAbort, int flags) {
if (DEBUG_BROADCAST) Slog.v(TAG, "Finish receiver: " + who);
// Refuse possible leaked file descriptors
@@ -16419,7 +16427,9 @@ public final class ActivityManagerService extends ActivityManagerNative
BroadcastRecord r;
synchronized(this) {
- r = broadcastRecordForReceiverLocked(who);
+ BroadcastQueue queue = (flags & Intent.FLAG_RECEIVER_FOREGROUND) != 0
+ ? mFgBroadcastQueue : mBgBroadcastQueue;
+ r = queue.getMatchingOrderedReceiver(who);
if (r != null) {
doNext = r.queue.finishReceiverLocked(r, resultCode,
resultData, resultExtras, resultAbort, true);
@@ -16788,15 +16798,27 @@ public final class ActivityManagerService extends ActivityManagerNative
}
/**
- * Save the locale. You must be inside a synchronized (this) block.
+ * Save the locale. You must be inside a synchronized (this) block.
*/
private void saveLocaleLocked(Locale l, boolean isDiff, boolean isPersist) {
- if(isDiff) {
+ final String languageTag = l.toLanguageTag();
+ if (isDiff) {
+ SystemProperties.set("user.locale", languageTag);
+
+ // TODO: Who uses these ? There are no references to these system
+ // properties in documents or code. Did the author intend to call
+ // System.setProperty() instead ? Even that wouldn't have any effect.
SystemProperties.set("user.language", l.getLanguage());
SystemProperties.set("user.region", l.getCountry());
- }
+ }
+
+ if (isPersist) {
+ SystemProperties.set("persist.sys.locale", languageTag);
- if(isPersist) {
+ // These values are *deprecated*, use persist.sys.locale instead.
+ //
+ // TODO: Stop setting these values once all code that references
+ // them has been removed.
SystemProperties.set("persist.sys.language", l.getLanguage());
SystemProperties.set("persist.sys.country", l.getCountry());
SystemProperties.set("persist.sys.localevar", l.getVariant());
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 6497cd7..fe09115 100755..100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -1567,6 +1567,7 @@ final class ActivityStack {
mStackSupervisor.mGoingToSleepActivities.remove(next);
next.sleeping = false;
mStackSupervisor.mWaitingVisibleActivities.remove(next);
+ next.waitingVisible = false;
if (DEBUG_SWITCH) Slog.v(TAG, "Resuming " + next);
@@ -2237,7 +2238,7 @@ final class ActivityStack {
// In this case, we want to finish this activity
// and everything above it, so be sneaky and pretend
// like these are all in the reply chain.
- end = numActivities - 1;
+ end = activities.size() - 1;
} else if (replyChainEnd < 0) {
end = i;
} else {
@@ -2776,6 +2777,7 @@ final class ActivityStack {
mStackSupervisor.mStoppingActivities.remove(r);
mStackSupervisor.mGoingToSleepActivities.remove(r);
mStackSupervisor.mWaitingVisibleActivities.remove(r);
+ r.waitingVisible = false;
if (mResumedActivity == r) {
mResumedActivity = null;
}
@@ -2977,6 +2979,7 @@ final class ActivityStack {
// down to the max limit while they are still waiting to finish.
mStackSupervisor.mFinishingActivities.remove(r);
mStackSupervisor.mWaitingVisibleActivities.remove(r);
+ r.waitingVisible = false;
// Remove any pending results.
if (r.finishing && r.pendingResults != null) {
diff --git a/services/core/java/com/android/server/am/ProcessStatsService.java b/services/core/java/com/android/server/am/ProcessStatsService.java
index 55aec65..9634dff 100644
--- a/services/core/java/com/android/server/am/ProcessStatsService.java
+++ b/services/core/java/com/android/server/am/ProcessStatsService.java
@@ -445,14 +445,14 @@ public final class ProcessStatsService extends IProcessStats.Stub {
mAm.mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.PACKAGE_USAGE_STATS, null);
Parcel current = Parcel.obtain();
+ synchronized (mAm) {
+ long now = SystemClock.uptimeMillis();
+ mProcessStats.mTimePeriodEndRealtime = SystemClock.elapsedRealtime();
+ mProcessStats.mTimePeriodEndUptime = now;
+ mProcessStats.writeToParcel(current, now, 0);
+ }
mWriteLock.lock();
try {
- synchronized (mAm) {
- long now = SystemClock.uptimeMillis();
- mProcessStats.mTimePeriodEndRealtime = SystemClock.elapsedRealtime();
- mProcessStats.mTimePeriodEndUptime = now;
- mProcessStats.writeToParcel(current, now, 0);
- }
if (historic != null) {
ArrayList<String> files = getCommittedFiles(0, false, true);
if (files != null) {
@@ -476,18 +476,18 @@ public final class ProcessStatsService extends IProcessStats.Stub {
public ParcelFileDescriptor getStatsOverTime(long minTime) {
mAm.mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.PACKAGE_USAGE_STATS, null);
+ Parcel current = Parcel.obtain();
+ long curTime;
+ synchronized (mAm) {
+ long now = SystemClock.uptimeMillis();
+ mProcessStats.mTimePeriodEndRealtime = SystemClock.elapsedRealtime();
+ mProcessStats.mTimePeriodEndUptime = now;
+ mProcessStats.writeToParcel(current, now, 0);
+ curTime = mProcessStats.mTimePeriodEndRealtime
+ - mProcessStats.mTimePeriodStartRealtime;
+ }
mWriteLock.lock();
try {
- Parcel current = Parcel.obtain();
- long curTime;
- synchronized (mAm) {
- long now = SystemClock.uptimeMillis();
- mProcessStats.mTimePeriodEndRealtime = SystemClock.elapsedRealtime();
- mProcessStats.mTimePeriodEndUptime = now;
- mProcessStats.writeToParcel(current, now, 0);
- curTime = mProcessStats.mTimePeriodEndRealtime
- - mProcessStats.mTimePeriodStartRealtime;
- }
if (curTime < minTime) {
// Need to add in older stats to reach desired time.
ArrayList<String> files = getCommittedFiles(0, false, true);
diff --git a/services/core/java/com/android/server/location/GpsLocationProvider.java b/services/core/java/com/android/server/location/GpsLocationProvider.java
index bec0e22..2a1f7d6 100644
--- a/services/core/java/com/android/server/location/GpsLocationProvider.java
+++ b/services/core/java/com/android/server/location/GpsLocationProvider.java
@@ -916,7 +916,7 @@ public class GpsLocationProvider implements LocationProviderInterface {
AsyncTask.THREAD_POOL_EXECUTOR.execute(new Runnable() {
@Override
public void run() {
- GpsXtraDownloader xtraDownloader = new GpsXtraDownloader(mContext, mProperties);
+ GpsXtraDownloader xtraDownloader = new GpsXtraDownloader(mProperties);
byte[] data = xtraDownloader.downloadXtraData();
if (data != null) {
if (DEBUG) {
diff --git a/services/core/java/com/android/server/location/GpsXtraDownloader.java b/services/core/java/com/android/server/location/GpsXtraDownloader.java
index a5eef6a..c820a43 100644
--- a/services/core/java/com/android/server/location/GpsXtraDownloader.java
+++ b/services/core/java/com/android/server/location/GpsXtraDownloader.java
@@ -17,20 +17,14 @@
package com.android.server.location;
import android.content.Context;
-import android.net.Proxy;
-import android.net.http.AndroidHttpClient;
import android.text.TextUtils;
import android.util.Log;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpResponse;
-import org.apache.http.StatusLine;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.conn.params.ConnRouteParams;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import libcore.io.IoUtils;
+import libcore.io.Streams;
-import java.io.DataInputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.Random;
@@ -46,15 +40,12 @@ public class GpsXtraDownloader {
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private static final String DEFAULT_USER_AGENT = "Android";
- private final Context mContext;
private final String[] mXtraServers;
// to load balance our server requests
private int mNextServerIndex;
private final String mUserAgent;
- GpsXtraDownloader(Context context, Properties properties) {
- mContext = context;
-
+ GpsXtraDownloader(Properties properties) {
// read XTRA servers from the Properties object
int count = 0;
String server1 = properties.getProperty("XTRA_SERVER_1");
@@ -75,7 +66,6 @@ public class GpsXtraDownloader {
if (count == 0) {
Log.e(TAG, "No XTRA servers were specified in the GPS configuration");
mXtraServers = null;
- return;
} else {
mXtraServers = new String[count];
count = 0;
@@ -90,9 +80,6 @@ public class GpsXtraDownloader {
}
byte[] downloadXtraData() {
- String proxyHost = Proxy.getHost(mContext);
- int proxyPort = Proxy.getPort(mContext);
- boolean useProxy = (proxyHost != null && proxyPort != -1);
byte[] result = null;
int startIndex = mNextServerIndex;
@@ -102,7 +89,7 @@ public class GpsXtraDownloader {
// load balance our requests among the available servers
while (result == null) {
- result = doDownload(mXtraServers[mNextServerIndex], useProxy, proxyHost, proxyPort);
+ result = doDownload(mXtraServers[mNextServerIndex]);
// increment mNextServerIndex and wrap around if necessary
mNextServerIndex++;
@@ -116,65 +103,32 @@ public class GpsXtraDownloader {
return result;
}
- protected byte[] doDownload(String url, boolean isProxySet,
- String proxyHost, int proxyPort) {
+ protected byte[] doDownload(String url) {
if (DEBUG) Log.d(TAG, "Downloading XTRA data from " + url);
- AndroidHttpClient client = null;
+ HttpURLConnection connection = null;
try {
- if (DEBUG) Log.d(TAG, "XTRA user agent: " + mUserAgent);
- client = AndroidHttpClient.newInstance(mUserAgent);
- HttpUriRequest req = new HttpGet(url);
-
- if (isProxySet) {
- HttpHost proxy = new HttpHost(proxyHost, proxyPort);
- ConnRouteParams.setDefaultProxy(req.getParams(), proxy);
- }
-
- req.addHeader(
+ connection = (HttpURLConnection) (new URL(url)).openConnection();
+ connection.setRequestProperty(
"Accept",
"*/*, application/vnd.wap.mms-message, application/vnd.wap.sic");
-
- req.addHeader(
+ connection.setRequestProperty(
"x-wap-profile",
"http://www.openmobilealliance.org/tech/profiles/UAPROF/ccppschema-20021212#");
- HttpResponse response = client.execute(req);
- StatusLine status = response.getStatusLine();
- if (status.getStatusCode() != 200) { // HTTP 200 is success.
- if (DEBUG) Log.d(TAG, "HTTP error: " + status.getReasonPhrase());
+ connection.connect();
+ int statusCode = connection.getResponseCode();
+ if (statusCode != HttpURLConnection.HTTP_OK) {
+ if (DEBUG) Log.d(TAG, "HTTP error downloading gps XTRA: " + statusCode);
return null;
}
- HttpEntity entity = response.getEntity();
- byte[] body = null;
- if (entity != null) {
- try {
- if (entity.getContentLength() > 0) {
- body = new byte[(int) entity.getContentLength()];
- DataInputStream dis = new DataInputStream(entity.getContent());
- try {
- dis.readFully(body);
- } finally {
- try {
- dis.close();
- } catch (IOException e) {
- Log.e(TAG, "Unexpected IOException.", e);
- }
- }
- }
- } finally {
- if (entity != null) {
- entity.consumeContent();
- }
- }
- }
- return body;
- } catch (Exception e) {
- if (DEBUG) Log.d(TAG, "error " + e);
+ return Streams.readFully(connection.getInputStream());
+ } catch (IOException ioe) {
+ if (DEBUG) Log.d(TAG, "Error downloading gps XTRA: ", ioe);
} finally {
- if (client != null) {
- client.close();
+ if (connection != null) {
+ connection.disconnect();
}
}
return null;
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 5b17eaa..d3fede7 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -4310,6 +4310,8 @@ public class PackageManagerService extends IPackageManager.Stub {
+ " to " + scanFile);
updatedPkg.codePath = scanFile;
updatedPkg.codePathString = scanFile.toString();
+ updatedPkg.resourcePath = scanFile;
+ updatedPkg.resourcePathString = scanFile.toString();
}
updatedPkg.pkg = pkg;
throw new PackageManagerException(INSTALL_FAILED_DUPLICATE_PACKAGE, null);
diff --git a/services/core/java/com/android/server/pm/SELinuxMMAC.java b/services/core/java/com/android/server/pm/SELinuxMMAC.java
index 81302b9..95ed7bc 100644
--- a/services/core/java/com/android/server/pm/SELinuxMMAC.java
+++ b/services/core/java/com/android/server/pm/SELinuxMMAC.java
@@ -35,13 +35,22 @@ import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/**
- * Centralized access to SELinux MMAC (middleware MAC) implementation.
+ * Centralized access to SELinux MMAC (middleware MAC) implementation. This
+ * class is responsible for loading the appropriate mac_permissions.xml file
+ * as well as providing an interface for assigning seinfo values to apks.
+ *
* {@hide}
*/
public final class SELinuxMMAC {
@@ -51,11 +60,9 @@ public final class SELinuxMMAC {
private static final boolean DEBUG_POLICY = false;
private static final boolean DEBUG_POLICY_INSTALL = DEBUG_POLICY || false;
- // Signature seinfo values read from policy.
- private static HashMap<Signature, Policy> sSigSeinfo = new HashMap<Signature, Policy>();
-
- // Default seinfo read from policy.
- private static String sDefaultSeinfo = null;
+ // All policy stanzas read from mac_permissions.xml. This is also the lock
+ // to synchronize access during policy load and access attempts.
+ private static final List<Policy> sPolicies = new ArrayList<Policy>();
// Data policy override version file.
private static final String DATA_VERSION_FILE =
@@ -94,285 +101,289 @@ public final class SELinuxMMAC {
private static final String SEAPP_HASH_FILE =
Environment.getDataDirectory().toString() + "/system/seapp_hash";
+ /**
+ * Load the mac_permissions.xml file containing all seinfo assignments used to
+ * label apps. The loaded mac_permissions.xml file is determined by the
+ * MAC_PERMISSIONS class variable which is set at class load time which itself
+ * is based on the USE_OVERRIDE_POLICY class variable. For further guidance on
+ * the proper structure of a mac_permissions.xml file consult the source code
+ * located at external/sepolicy/mac_permissions.xml.
+ *
+ * @return boolean indicating if policy was correctly loaded. A value of false
+ * typically indicates a structural problem with the xml or incorrectly
+ * constructed policy stanzas. A value of true means that all stanzas
+ * were loaded successfully; no partial loading is possible.
+ */
+ public static boolean readInstallPolicy() {
+ // Temp structure to hold the rules while we parse the xml file. We add
+ // all the rules once we know there's no problems.
+ List<Policy> policies = new ArrayList<>();
- // Signature policy stanzas
- static class Policy {
- private String seinfo;
- private final HashMap<String, String> pkgMap;
-
- Policy() {
- seinfo = null;
- pkgMap = new HashMap<String, String>();
- }
-
- void putSeinfo(String seinfoValue) {
- seinfo = seinfoValue;
- }
-
- void putPkg(String pkg, String seinfoValue) {
- pkgMap.put(pkg, seinfoValue);
- }
-
- // Valid policy stanza means there exists a global
- // seinfo value or at least one package policy.
- boolean isValid() {
- return (seinfo != null) || (!pkgMap.isEmpty());
- }
-
- String checkPolicy(String pkgName) {
- // Check for package name seinfo value first.
- String seinfoValue = pkgMap.get(pkgName);
- if (seinfoValue != null) {
- return seinfoValue;
- }
-
- // Return the global seinfo value.
- return seinfo;
- }
- }
-
- private static void flushInstallPolicy() {
- sSigSeinfo.clear();
- sDefaultSeinfo = null;
- }
+ // A separate structure to hold the default stanza. We need to add this to
+ // the end of the policies list structure.
+ Policy defaultPolicy = null;
- public static boolean readInstallPolicy() {
- // Temp structures to hold the rules while we parse the xml file.
- // We add all the rules together once we know there's no structural problems.
- HashMap<Signature, Policy> sigSeinfo = new HashMap<Signature, Policy>();
- String defaultSeinfo = null;
+ // Track sets of known policy certs so we can enforce rules across stanzas.
+ Set<Set<Signature>> knownCerts = new HashSet<>();
FileReader policyFile = null;
+ XmlPullParser parser = Xml.newPullParser();
try {
policyFile = new FileReader(MAC_PERMISSIONS);
Slog.d(TAG, "Using policy file " + MAC_PERMISSIONS);
- XmlPullParser parser = Xml.newPullParser();
parser.setInput(policyFile);
+ parser.nextTag();
+ parser.require(XmlPullParser.START_TAG, null, "policy");
- XmlUtils.beginDocument(parser, "policy");
- while (true) {
- XmlUtils.nextElement(parser);
- if (parser.getEventType() == XmlPullParser.END_DOCUMENT) {
- break;
+ while (parser.next() != XmlPullParser.END_TAG) {
+ if (parser.getEventType() != XmlPullParser.START_TAG) {
+ continue;
}
String tagName = parser.getName();
if ("signer".equals(tagName)) {
- String cert = parser.getAttributeValue(null, "signature");
- if (cert == null) {
- Slog.w(TAG, "<signer> without signature at "
- + parser.getPositionDescription());
- XmlUtils.skipCurrentTag(parser);
- continue;
- }
- Signature signature;
- try {
- signature = new Signature(cert);
- } catch (IllegalArgumentException e) {
- Slog.w(TAG, "<signer> with bad signature at "
- + parser.getPositionDescription(), e);
- XmlUtils.skipCurrentTag(parser);
- continue;
- }
- Policy policy = readPolicyTags(parser);
- if (policy.isValid()) {
- sigSeinfo.put(signature, policy);
+ Policy signerPolicy = readSignerOrThrow(parser);
+ // Return of a Policy instance ensures certain invariants have
+ // passed, however, we still want to do some cross policy checking.
+ // Thus, check that we haven't seen the certs in another stanza.
+ Set<Signature> certs = signerPolicy.getSignatures();
+ if (knownCerts.contains(certs)) {
+ String msg = "Separate stanzas have identical certs";
+ throw new IllegalStateException(msg);
}
+ knownCerts.add(certs);
+ policies.add(signerPolicy);
} else if ("default".equals(tagName)) {
- // Value is null if default tag is absent or seinfo tag is malformed.
- defaultSeinfo = readSeinfoTag(parser);
- if (DEBUG_POLICY_INSTALL)
- Slog.i(TAG, "<default> tag assigned seinfo=" + defaultSeinfo);
-
+ Policy defPolicy = readDefaultOrThrow(parser);
+ // Return of a Policy instance ensures certain invariants have
+ // passed, however, we still want to do some cross policy checking.
+ // Thus, check that we haven't already seen a default stanza.
+ if (defaultPolicy != null) {
+ String msg = "Multiple default stanzas identified";
+ throw new IllegalStateException(msg);
+ }
+ defaultPolicy = defPolicy;
} else {
- XmlUtils.skipCurrentTag(parser);
+ skip(parser);
}
}
- } catch (XmlPullParserException xpe) {
- Slog.w(TAG, "Got exception parsing " + MAC_PERMISSIONS, xpe);
+ } catch (IllegalStateException | IllegalArgumentException |
+ XmlPullParserException ex) {
+ StringBuilder sb = new StringBuilder("Exception @");
+ sb.append(parser.getPositionDescription());
+ sb.append(" while parsing ");
+ sb.append(MAC_PERMISSIONS);
+ sb.append(":");
+ sb.append(ex);
+ Slog.w(TAG, sb.toString());
return false;
} catch (IOException ioe) {
- Slog.w(TAG, "Got exception parsing " + MAC_PERMISSIONS, ioe);
+ Slog.w(TAG, "Exception parsing " + MAC_PERMISSIONS, ioe);
return false;
} finally {
IoUtils.closeQuietly(policyFile);
}
- flushInstallPolicy();
- sSigSeinfo = sigSeinfo;
- sDefaultSeinfo = defaultSeinfo;
+ // Add the default policy to the end if there is one. This will ensure that
+ // the default stanza is consulted last when performing policy lookups.
+ if (defaultPolicy != null) {
+ policies.add(defaultPolicy);
+ }
+
+ synchronized (sPolicies) {
+ sPolicies.clear();
+ sPolicies.addAll(policies);
+ }
return true;
}
- private static Policy readPolicyTags(XmlPullParser parser) throws
- IOException, XmlPullParserException {
+ /**
+ * Loop over a signer tag looking for seinfo, package and cert tags. A {@link Policy}
+ * instance will be created and returned in the process. During the pass all other
+ * tag elements will be skipped.
+ *
+ * @param parser an XmlPullParser object representing a signer element.
+ * @return the constructed {@link Policy} instance
+ * @throws IOException
+ * @throws XmlPullParserException
+ * @throws IllegalArgumentException if any of the validation checks fail while
+ * parsing tag values.
+ * @throws IllegalStateException if any of the invariants fail when constructing
+ * the {@link Policy} instance.
+ */
+ private static Policy readSignerOrThrow(XmlPullParser parser) throws IOException,
+ XmlPullParserException {
- int type;
- int outerDepth = parser.getDepth();
- Policy policy = new Policy();
- while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
- && (type != XmlPullParser.END_TAG
- || parser.getDepth() > outerDepth)) {
- if (type == XmlPullParser.END_TAG
- || type == XmlPullParser.TEXT) {
+ parser.require(XmlPullParser.START_TAG, null, "signer");
+ Policy.PolicyBuilder pb = new Policy.PolicyBuilder();
+
+ // Check for a cert attached to the signer tag. We allow a signature
+ // to appear as an attribute as well as those attached to cert tags.
+ String cert = parser.getAttributeValue(null, "signature");
+ if (cert != null) {
+ pb.addSignature(cert);
+ }
+
+ while (parser.next() != XmlPullParser.END_TAG) {
+ if (parser.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String tagName = parser.getName();
if ("seinfo".equals(tagName)) {
- String seinfo = parseSeinfo(parser);
- if (seinfo != null) {
- policy.putSeinfo(seinfo);
- }
- XmlUtils.skipCurrentTag(parser);
+ String seinfo = parser.getAttributeValue(null, "value");
+ pb.setGlobalSeinfoOrThrow(seinfo);
+ readSeinfo(parser);
} else if ("package".equals(tagName)) {
- String pkg = parser.getAttributeValue(null, "name");
- if (!validatePackageName(pkg)) {
- Slog.w(TAG, "<package> without valid name at "
- + parser.getPositionDescription());
- XmlUtils.skipCurrentTag(parser);
- continue;
- }
-
- String seinfo = readSeinfoTag(parser);
- if (seinfo != null) {
- policy.putPkg(pkg, seinfo);
- }
+ readPackageOrThrow(parser, pb);
+ } else if ("cert".equals(tagName)) {
+ String sig = parser.getAttributeValue(null, "signature");
+ pb.addSignature(sig);
+ readCert(parser);
} else {
- XmlUtils.skipCurrentTag(parser);
+ skip(parser);
}
}
- return policy;
+
+ return pb.build();
}
- private static String readSeinfoTag(XmlPullParser parser) throws
- IOException, XmlPullParserException {
+ /**
+ * Loop over a default element looking for seinfo child tags. A {@link Policy}
+ * instance will be created and returned in the process. All other tags encountered
+ * will be skipped.
+ *
+ * @param parser an XmlPullParser object representing a default element.
+ * @return the constructed {@link Policy} instance
+ * @throws IOException
+ * @throws XmlPullParserException
+ * @throws IllegalArgumentException if any of the validation checks fail while
+ * parsing tag values.
+ * @throws IllegalStateException if any of the invariants fail when constructing
+ * the {@link Policy} instance.
+ */
+ private static Policy readDefaultOrThrow(XmlPullParser parser) throws IOException,
+ XmlPullParserException {
- int type;
- int outerDepth = parser.getDepth();
- String seinfo = null;
- while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
- && (type != XmlPullParser.END_TAG
- || parser.getDepth() > outerDepth)) {
- if (type == XmlPullParser.END_TAG
- || type == XmlPullParser.TEXT) {
+ parser.require(XmlPullParser.START_TAG, null, "default");
+ Policy.PolicyBuilder pb = new Policy.PolicyBuilder();
+ pb.setAsDefaultPolicy();
+
+ while (parser.next() != XmlPullParser.END_TAG) {
+ if (parser.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String tagName = parser.getName();
if ("seinfo".equals(tagName)) {
- seinfo = parseSeinfo(parser);
+ String seinfo = parser.getAttributeValue(null, "value");
+ pb.setGlobalSeinfoOrThrow(seinfo);
+ readSeinfo(parser);
+ } else {
+ skip(parser);
}
- XmlUtils.skipCurrentTag(parser);
}
- return seinfo;
- }
-
- private static String parseSeinfo(XmlPullParser parser) {
- String seinfoValue = parser.getAttributeValue(null, "value");
- if (!validateValue(seinfoValue)) {
- Slog.w(TAG, "<seinfo> without valid value at "
- + parser.getPositionDescription());
- seinfoValue = null;
- }
- return seinfoValue;
+ return pb.build();
}
/**
- * General validation routine for package names.
- * Returns a boolean indicating if the passed string
- * is a valid android package name.
+ * Loop over a package element looking for seinfo child tags. If found return the
+ * value attribute of the seinfo tag, otherwise return null. All other tags encountered
+ * will be skipped.
+ *
+ * @param parser an XmlPullParser object representing a package element.
+ * @param pb a Policy.PolicyBuilder instance to build
+ * @throws IOException
+ * @throws XmlPullParserException
+ * @throws IllegalArgumentException if any of the validation checks fail while
+ * parsing tag values.
+ * @throws IllegalStateException if there is a duplicate seinfo tag for the current
+ * package tag.
*/
- private static boolean validatePackageName(String name) {
- if (name == null)
- return false;
+ private static void readPackageOrThrow(XmlPullParser parser, Policy.PolicyBuilder pb) throws
+ IOException, XmlPullParserException {
+ parser.require(XmlPullParser.START_TAG, null, "package");
+ String pkgName = parser.getAttributeValue(null, "name");
- final int N = name.length();
- boolean hasSep = false;
- boolean front = true;
- for (int i=0; i<N; i++) {
- final char c = name.charAt(i);
- if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
- front = false;
+ while (parser.next() != XmlPullParser.END_TAG) {
+ if (parser.getEventType() != XmlPullParser.START_TAG) {
continue;
}
- if (!front) {
- if ((c >= '0' && c <= '9') || c == '_') {
- continue;
- }
- }
- if (c == '.') {
- hasSep = true;
- front = true;
- continue;
+
+ String tagName = parser.getName();
+ if ("seinfo".equals(tagName)) {
+ String seinfo = parser.getAttributeValue(null, "value");
+ pb.addInnerPackageMapOrThrow(pkgName, seinfo);
+ readSeinfo(parser);
+ } else {
+ skip(parser);
}
- return false;
}
- return hasSep;
}
- /**
- * General validation routine for tag values.
- * Returns a boolean indicating if the passed string
- * contains only letters or underscores.
- */
- private static boolean validateValue(String name) {
- if (name == null)
- return false;
+ private static void readCert(XmlPullParser parser) throws IOException,
+ XmlPullParserException {
+ parser.require(XmlPullParser.START_TAG, null, "cert");
+ parser.nextTag();
+ }
- final int N = name.length();
- if (N == 0)
- return false;
+ private static void readSeinfo(XmlPullParser parser) throws IOException,
+ XmlPullParserException {
+ parser.require(XmlPullParser.START_TAG, null, "seinfo");
+ parser.nextTag();
+ }
- for (int i = 0; i < N; i++) {
- final char c = name.charAt(i);
- if ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c != '_')) {
- return false;
+ private static void skip(XmlPullParser p) throws IOException, XmlPullParserException {
+ if (p.getEventType() != XmlPullParser.START_TAG) {
+ throw new IllegalStateException();
+ }
+ int depth = 1;
+ while (depth != 0) {
+ switch (p.next()) {
+ case XmlPullParser.END_TAG:
+ depth--;
+ break;
+ case XmlPullParser.START_TAG:
+ depth++;
+ break;
}
}
- return true;
}
/**
- * Labels a package based on an seinfo tag from install policy.
- * The label is attached to the ApplicationInfo instance of the package.
+ * Applies a security label to a package based on an seinfo tag taken from a matched
+ * policy. All signature based policy stanzas are consulted first and, if no match
+ * is found, the default policy stanza is then consulted. The security label is
+ * attached to the ApplicationInfo instance of the package in the event that a matching
+ * policy was found.
+ *
* @param pkg object representing the package to be labeled.
- * @return boolean which determines whether a non null seinfo label
- * was assigned to the package. A null value simply meaning that
- * no policy matched.
+ * @return boolean which determines whether a non null seinfo label was assigned
+ * to the package. A null value simply represents that no policy matched.
*/
public static boolean assignSeinfoValue(PackageParser.Package pkg) {
-
- // We just want one of the signatures to match.
- for (Signature s : pkg.mSignatures) {
- if (s == null)
- continue;
-
- Policy policy = sSigSeinfo.get(s);
- if (policy != null) {
- String seinfo = policy.checkPolicy(pkg.packageName);
+ synchronized (sPolicies) {
+ for (Policy policy : sPolicies) {
+ String seinfo = policy.getMatchedSeinfo(pkg);
if (seinfo != null) {
pkg.applicationInfo.seinfo = seinfo;
- if (DEBUG_POLICY_INSTALL)
- Slog.i(TAG, "package (" + pkg.packageName +
- ") labeled with seinfo=" + seinfo);
-
+ if (DEBUG_POLICY_INSTALL) {
+ Slog.i(TAG, "package (" + pkg.packageName + ") labeled with " +
+ "seinfo=" + seinfo);
+ }
return true;
}
}
}
- // If we have a default seinfo value then great, otherwise
- // we set a null object and that is what we started with.
- pkg.applicationInfo.seinfo = sDefaultSeinfo;
- if (DEBUG_POLICY_INSTALL)
- Slog.i(TAG, "package (" + pkg.packageName + ") labeled with seinfo="
- + (sDefaultSeinfo == null ? "null" : sDefaultSeinfo));
-
- return (sDefaultSeinfo != null);
+ if (DEBUG_POLICY_INSTALL) {
+ Slog.i(TAG, "package (" + pkg.packageName + ") doesn't match any policy; " +
+ "seinfo will remain null");
+ }
+ return false;
}
/**
@@ -477,3 +488,312 @@ public final class SELinuxMMAC {
return false;
}
}
+
+/**
+ * Holds valid policy representations of individual stanzas from a mac_permissions.xml
+ * file. Each instance can further be used to assign seinfo values to apks using the
+ * {@link Policy#getMatchedSeinfo} method. To create an instance of this use the
+ * {@link PolicyBuilder} pattern class, where each instance is validated against a set
+ * of invariants before being built and returned. Each instance can be guaranteed to
+ * hold one valid policy stanza as outlined in the external/sepolicy/mac_permissions.xml
+ * file.
+ * </p>
+ * The following is an example of how to use {@link Policy.PolicyBuilder} to create a
+ * signer based Policy instance.
+ * </p>
+ * <pre>
+ * {@code
+ * Policy policy = new Policy.PolicyBuilder()
+ * .addSignature("308204a8...")
+ * .addSignature("483538c8...")
+ * .setGlobalSeinfoOrThrow("paltform")
+ * .addInnerPackageMapOrThrow("com.foo.", "bar")
+ * .addInnerPackageMapOrThrow("com.foo.other", "bar")
+ * .build();
+ * }
+ * </pre>
+ * <p>
+ * An example of how to use {@link Policy.PolicyBuilder} to create a default based Policy
+ * instance.
+ * </p>
+ * <pre>
+ * {@code
+ * Policy policy = new Policy.PolicyBuilder()
+ * .setAsDefaultPolicy()
+ * .setGlobalSeinfoOrThrow("defualt")
+ * .build();
+ * }
+ * </pre>
+ */
+final class Policy {
+
+ private final String mSeinfo;
+ private final boolean mDefaultStanza;
+ private final Set<Signature> mCerts;
+ private final Map<String, String> mPkgMap;
+
+ // Use the PolicyBuilder pattern to instantiate
+ private Policy(PolicyBuilder builder) {
+ mSeinfo = builder.mSeinfo;
+ mDefaultStanza = builder.mDefaultStanza;
+ mCerts = Collections.unmodifiableSet(builder.mCerts);
+ mPkgMap = Collections.unmodifiableMap(builder.mPkgMap);
+ }
+
+ /**
+ * Return all the certs stored with this policy stanza.
+ *
+ * @return A set of Signature objects representing all the certs stored
+ * with the policy.
+ */
+ public Set<Signature> getSignatures() {
+ return mCerts;
+ }
+
+ /**
+ * <p>
+ * Determine the seinfo value to assign to an apk. The appropriate seinfo value
+ * is determined using the following steps:
+ * </p>
+ * <ul>
+ * <li> If this Policy instance is defined as a default stanza:
+ * <ul><li>Return the global seinfo value</li></ul>
+ * </li>
+ * <li> If this Policy instance is defined as a signer stanza:
+ * <ul>
+ * <li> All certs used to sign the apk and all certs stored with this policy
+ * instance are tested for set equality. If this fails then null is returned.
+ * </li>
+ * <li> If all certs match then an appropriate inner package stanza is
+ * searched based on package name alone. If matched, the stored seinfo
+ * value for that mapping is returned.
+ * </li>
+ * <li> If all certs matched and no inner package stanza matches then return
+ * the global seinfo value. The returned value can be null in this case.
+ * </li>
+ * </ul>
+ * </li>
+ * </ul>
+ * <p>
+ * In all cases, a return value of null should be interpreted as the apk failing
+ * to match this Policy instance; i.e. failing this policy stanza.
+ * </p>
+ * @param pkg the apk to check given as a PackageParser.Package object
+ * @return A string representing the seinfo matched during policy lookup.
+ * A value of null can also be returned if no match occured.
+ */
+ public String getMatchedSeinfo(PackageParser.Package pkg) {
+ if (!mDefaultStanza) {
+ // Check for exact signature matches across all certs.
+ Signature[] certs = mCerts.toArray(new Signature[0]);
+ if (!Signature.areExactMatch(certs, pkg.mSignatures)) {
+ return null;
+ }
+
+ // Check for inner package name matches given that the
+ // signature checks already passed.
+ String seinfoValue = mPkgMap.get(pkg.packageName);
+ if (seinfoValue != null) {
+ return seinfoValue;
+ }
+ }
+
+ // Return the global seinfo value (even if it's null).
+ return mSeinfo;
+ }
+
+ /**
+ * A nested builder class to create {@link Policy} instances. A {@link Policy}
+ * class instance represents one valid policy stanza found in a mac_permissions.xml
+ * file. A valid policy stanza is defined to be either a signer or default stanza
+ * which obeys the rules outlined in external/sepolicy/mac_permissions.xml. The
+ * {@link #build} method ensures a set of invariants are upheld enforcing the correct
+ * stanza structure before returning a valid Policy object.
+ */
+ public static final class PolicyBuilder {
+
+ private String mSeinfo;
+ private boolean mDefaultStanza;
+ private final Set<Signature> mCerts;
+ private final Map<String, String> mPkgMap;
+
+ public PolicyBuilder() {
+ mCerts = new HashSet<Signature>(2);
+ mPkgMap = new HashMap<String, String>(2);
+ }
+
+ /**
+ * Sets this stanza as a defualt stanza. All policy stanzas are assumed to
+ * be signer stanzas unless this method is explicitly called. Default stanzas
+ * are treated differently with respect to allowable child tags, ordering and
+ * when and how policy decisions are enforced.
+ *
+ * @return The reference to this PolicyBuilder.
+ */
+ public PolicyBuilder setAsDefaultPolicy() {
+ mDefaultStanza = true;
+ return this;
+ }
+
+ /**
+ * Adds a signature to the set of certs used for validation checks. The purpose
+ * being that all contained certs will need to be matched against all certs
+ * contained with an apk.
+ *
+ * @param cert the signature to add given as a String.
+ * @return The reference to this PolicyBuilder.
+ * @throws IllegalArgumentException if the cert value fails validation;
+ * null or is an invalid hex-encoded ASCII string.
+ */
+ public PolicyBuilder addSignature(String cert) {
+ if (cert == null) {
+ String err = "Invalid signature value " + cert;
+ throw new IllegalArgumentException(err);
+ }
+
+ mCerts.add(new Signature(cert));
+ return this;
+ }
+
+ /**
+ * Set the global seinfo tag for this policy stanza. The global seinfo tag
+ * represents the seinfo element that is used in one of two ways depending on
+ * its context. When attached to a signer tag the global seinfo represents an
+ * assignment when there isn't a further inner package refinement in policy.
+ * When used with a default tag, it represents the only allowable assignment
+ * value.
+ *
+ * @param seinfo the seinfo value given as a String.
+ * @return The reference to this PolicyBuilder.
+ * @throws IllegalArgumentException if the seinfo value fails validation;
+ * null, zero length or contains non-valid characters [^a-zA-Z_\._0-9].
+ * @throws IllegalStateException if an seinfo value has already been found
+ */
+ public PolicyBuilder setGlobalSeinfoOrThrow(String seinfo) {
+ if (!validateValue(seinfo)) {
+ String err = "Invalid seinfo value " + seinfo;
+ throw new IllegalArgumentException(err);
+ }
+
+ if (mSeinfo != null && !mSeinfo.equals(seinfo)) {
+ String err = "Duplicate seinfo tag found";
+ throw new IllegalStateException(err);
+ }
+
+ mSeinfo = seinfo;
+ return this;
+ }
+
+ /**
+ * Create a package name to seinfo value mapping. Each mapping represents
+ * the seinfo value that will be assigned to the described package name.
+ * These localized mappings allow the global seinfo to be overriden. This
+ * mapping provides no value when used in conjunction with a default stanza;
+ * enforced through the {@link #build} method.
+ *
+ * @param pkgName the android package name given to the app
+ * @param seinfo the seinfo value that will be assigned to the passed pkgName
+ * @return The reference to this PolicyBuilder.
+ * @throws IllegalArgumentException if the seinfo value fails validation;
+ * null, zero length or contains non-valid characters [^a-zA-Z_\.0-9].
+ * Or, if the package name isn't a valid android package name.
+ * @throws IllegalStateException if trying to reset a package mapping with a
+ * different seinfo value.
+ */
+ public PolicyBuilder addInnerPackageMapOrThrow(String pkgName, String seinfo) {
+ if (!validateValue(pkgName)) {
+ String err = "Invalid package name " + pkgName;
+ throw new IllegalArgumentException(err);
+ }
+ if (!validateValue(seinfo)) {
+ String err = "Invalid seinfo value " + seinfo;
+ throw new IllegalArgumentException(err);
+ }
+
+ String pkgValue = mPkgMap.get(pkgName);
+ if (pkgValue != null && !pkgValue.equals(seinfo)) {
+ String err = "Conflicting seinfo value found";
+ throw new IllegalStateException(err);
+ }
+
+ mPkgMap.put(pkgName, seinfo);
+ return this;
+ }
+
+ /**
+ * General validation routine for the attribute strings of an element. Checks
+ * if the string is non-null, positive length and only contains [a-zA-Z_\.0-9].
+ *
+ * @param name the string to validate.
+ * @return boolean indicating if the string was valid.
+ */
+ private boolean validateValue(String name) {
+ if (name == null)
+ return false;
+
+ // Want to match on [0-9a-zA-Z_.]
+ if (!name.matches("\\A[\\.\\w]+\\z")) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * <p>
+ * Create a {@link Policy} instance based on the current configuration. This
+ * method checks for certain policy invariants used to enforce certain guarantees
+ * about the expected structure of a policy stanza.
+ * Those invariants are:
+ * </p>
+ * <ul>
+ * <li> If a default stanza
+ * <ul>
+ * <li> an attached global seinfo tag must be present </li>
+ * <li> no signatures and no package names can be present </li>
+ * </ul>
+ * </li>
+ * <li> If a signer stanza
+ * <ul>
+ * <li> at least one cert must be found </li>
+ * <li> either a global seinfo value is present OR at least one
+ * inner package mapping must be present. </li>
+ * </ul>
+ * </li>
+ * </ul>
+ *
+ * @return an instance of {@link Policy} with the options set from this builder
+ * @throws IllegalStateException if an invariant is violated.
+ */
+ public Policy build() {
+ Policy p = new Policy(this);
+
+ if (p.mDefaultStanza) {
+ if (p.mSeinfo == null) {
+ String err = "Missing global seinfo tag with default stanza.";
+ throw new IllegalStateException(err);
+ }
+ if (p.mCerts.size() != 0) {
+ String err = "Certs not allowed with default stanza.";
+ throw new IllegalStateException(err);
+ }
+ if (!p.mPkgMap.isEmpty()) {
+ String err = "Inner package mappings not allowed with default stanza.";
+ throw new IllegalStateException(err);
+ }
+ } else {
+ if (p.mCerts.size() == 0) {
+ String err = "Missing certs with signer tag. Expecting at least one.";
+ throw new IllegalStateException(err);
+ }
+ if ((p.mSeinfo == null) && (p.mPkgMap.isEmpty())) {
+ String err = "Missing seinfo OR package tags with signer tag. At " +
+ "least one must be present.";
+ throw new IllegalStateException(err);
+ }
+ }
+
+ return p;
+ }
+ }
+}
diff --git a/services/core/java/com/android/server/updates/ConfigUpdateInstallReceiver.java b/services/core/java/com/android/server/updates/ConfigUpdateInstallReceiver.java
index 7f7aae3..1135dfe 100644
--- a/services/core/java/com/android/server/updates/ConfigUpdateInstallReceiver.java
+++ b/services/core/java/com/android/server/updates/ConfigUpdateInstallReceiver.java
@@ -47,7 +47,6 @@ public class ConfigUpdateInstallReceiver extends BroadcastReceiver {
private static final String TAG = "ConfigUpdateInstallReceiver";
- private static final String EXTRA_CONTENT_PATH = "CONTENT_PATH";
private static final String EXTRA_REQUIRED_HASH = "REQUIRED_HASH";
private static final String EXTRA_SIGNATURE = "SIGNATURE";
private static final String EXTRA_VERSION_NUMBER = "VERSION";
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index f57adaf..4f20f50 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -241,6 +241,7 @@ class DisplayContent {
mTouchExcludeRegion.op(mTmpRect, Region.Op.DIFFERENCE);
}
}
+ mTapDetector.setTouchExcludeRegion(mTouchExcludeRegion);
}
void switchUserStacks(int newUserId) {
diff --git a/services/core/java/com/android/server/wm/StackTapPointerEventListener.java b/services/core/java/com/android/server/wm/StackTapPointerEventListener.java
index 19d8ab3..1a85993 100644
--- a/services/core/java/com/android/server/wm/StackTapPointerEventListener.java
+++ b/services/core/java/com/android/server/wm/StackTapPointerEventListener.java
@@ -31,7 +31,7 @@ public class StackTapPointerEventListener implements PointerEventListener {
private float mDownX;
private float mDownY;
private int mPointerId;
- final private Region mTouchExcludeRegion;
+ final private Region mTouchExcludeRegion = new Region();
private final WindowManagerService mService;
private final DisplayContent mDisplayContent;
@@ -39,7 +39,6 @@ public class StackTapPointerEventListener implements PointerEventListener {
DisplayContent displayContent) {
mService = service;
mDisplayContent = displayContent;
- mTouchExcludeRegion = displayContent.mTouchExcludeRegion;
DisplayInfo info = displayContent.getDisplayInfo();
mMotionSlop = (int)(info.logicalDensityDpi * TAP_MOTION_SLOP_INCHES);
}
@@ -57,8 +56,9 @@ public class StackTapPointerEventListener implements PointerEventListener {
if (mPointerId >= 0) {
int index = motionEvent.findPointerIndex(mPointerId);
if ((motionEvent.getEventTime() - motionEvent.getDownTime()) > TAP_TIMEOUT_MSEC
- || (motionEvent.getX(index) - mDownX) > mMotionSlop
- || (motionEvent.getY(index) - mDownY) > mMotionSlop) {
+ || index < 0
+ || Math.abs(motionEvent.getX(index) - mDownX) > mMotionSlop
+ || Math.abs(motionEvent.getY(index) - mDownY) > mMotionSlop) {
mPointerId = -1;
}
}
@@ -71,12 +71,15 @@ public class StackTapPointerEventListener implements PointerEventListener {
if (mPointerId == motionEvent.getPointerId(index)) {
final int x = (int)motionEvent.getX(index);
final int y = (int)motionEvent.getY(index);
- if ((motionEvent.getEventTime() - motionEvent.getDownTime())
- < TAP_TIMEOUT_MSEC
- && (x - mDownX) < mMotionSlop && (y - mDownY) < mMotionSlop
- && !mTouchExcludeRegion.contains(x, y)) {
- mService.mH.obtainMessage(H.TAP_OUTSIDE_STACK, x, y,
- mDisplayContent).sendToTarget();
+ synchronized(this) {
+ if ((motionEvent.getEventTime() - motionEvent.getDownTime())
+ < TAP_TIMEOUT_MSEC
+ && Math.abs(x - mDownX) < mMotionSlop
+ && Math.abs(y - mDownY) < mMotionSlop
+ && !mTouchExcludeRegion.contains(x, y)) {
+ mService.mH.obtainMessage(H.TAP_OUTSIDE_STACK, x, y,
+ mDisplayContent).sendToTarget();
+ }
}
mPointerId = -1;
}
@@ -84,4 +87,10 @@ public class StackTapPointerEventListener implements PointerEventListener {
}
}
}
+
+ void setTouchExcludeRegion(Region newRegion) {
+ synchronized (this) {
+ mTouchExcludeRegion.set(newRegion);
+ }
+ }
}
diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java
index 238c77e..802cf4b 100644
--- a/services/core/java/com/android/server/wm/TaskStack.java
+++ b/services/core/java/com/android/server/wm/TaskStack.java
@@ -191,7 +191,9 @@ public class TaskStack {
mTasks.add(stackNdx, task);
task.mStack = this;
- mDisplayContent.moveStack(this, true);
+ if (toTop) {
+ mDisplayContent.moveStack(this, true);
+ }
EventLog.writeEvent(EventLogTags.WM_TASK_MOVED, task.taskId, toTop ? 1 : 0, stackNdx);
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index a1fe16b..2ace842 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -4037,6 +4037,15 @@ public class WindowManagerService extends IWindowManager.Stub
if (changed) {
mFocusedApp = newFocus;
mInputMonitor.setFocusedAppLw(newFocus);
+ setFocusedStackFrame();
+ if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION setFocusedApp");
+ SurfaceControl.openTransaction();
+ try {
+ setFocusedStackLayer();
+ } finally {
+ SurfaceControl.closeTransaction();
+ if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, ">>> CLOSE TRANSACTION setFocusedApp");
+ }
}
if (moveFocusNow && changed) {
@@ -4873,8 +4882,19 @@ public class WindowManagerService extends IWindowManager.Stub
if (NW > 0) {
mWindowsChanged = true;
}
+ int targetDisplayId = -1;
+ Task targetTask = mTaskIdToTask.get(token.appWindowToken.groupId);
+ if (targetTask != null) {
+ DisplayContent targetDisplayContent = targetTask.getDisplayContent();
+ if (targetDisplayContent != null) {
+ targetDisplayId = targetDisplayContent.getDisplayId();
+ }
+ }
for (int i = 0; i < NW; i++) {
WindowState win = windows.get(i);
+ if (targetDisplayId != -1 && win.getDisplayId() != targetDisplayId) {
+ continue;
+ }
if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, "Tmp removing app window " + win);
win.getWindowList().remove(win);
int j = win.mChildWindows.size();
@@ -6187,9 +6207,13 @@ public class WindowManagerService extends IWindowManager.Stub
}
if (ws.mAppToken != null && ws.mAppToken.token == appToken &&
- ws.isDisplayedLw()) {
+ ws.isDisplayedLw() && winAnim.mSurfaceShown) {
screenshotReady = true;
}
+
+ if (ws.isFullscreen(dw, dh) && ws.isOpaqueDrawn()){
+ break;
+ }
}
if (appToken != null && appWin == null) {
@@ -7235,6 +7259,7 @@ public class WindowManagerService extends IWindowManager.Stub
displayInfo.getAppMetrics(mDisplayMetrics);
mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager(
displayContent.getDisplayId(), displayInfo);
+ displayContent.mBaseDisplayRect.set(0, 0, dw, dh);
}
if (false) {
Slog.i(TAG, "Set app display size: " + appWidth + " x " + appHeight);
@@ -8898,7 +8923,8 @@ public class WindowManagerService extends IWindowManager.Stub
if (!gone || !win.mHaveFrame || win.mLayoutNeeded
|| ((win.isConfigChanged() || win.setInsetsChanged()) &&
((win.mAttrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 ||
- win.mAppToken != null && win.mAppToken.layoutConfigChanges))
+ (win.mHasSurface && win.mAppToken != null &&
+ win.mAppToken.layoutConfigChanges)))
|| win.mAttrs.type == TYPE_UNIVERSE_BACKGROUND) {
if (!win.mLayoutAttached) {
if (initial) {
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 021a6e4..978f5c3 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -407,28 +407,26 @@ final class WindowState implements WindowManagerPolicy.WindowState {
mAttachedWindow = attachedWindow;
if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + this + " to " + mAttachedWindow);
- int children_size = mAttachedWindow.mChildWindows.size();
- if (children_size == 0) {
- mAttachedWindow.mChildWindows.add(this);
+ final WindowList childWindows = mAttachedWindow.mChildWindows;
+ final int numChildWindows = childWindows.size();
+ if (numChildWindows == 0) {
+ childWindows.add(this);
} else {
- for (int i = 0; i < children_size; i++) {
- WindowState child = (WindowState)mAttachedWindow.mChildWindows.get(i);
- if (this.mSubLayer < child.mSubLayer) {
- mAttachedWindow.mChildWindows.add(i, this);
+ boolean added = false;
+ for (int i = 0; i < numChildWindows; i++) {
+ final int childSubLayer = childWindows.get(i).mSubLayer;
+ if (mSubLayer < childSubLayer
+ || (mSubLayer == childSubLayer && childSubLayer < 0)) {
+ // We insert the child window into the list ordered by the sub-layer. For
+ // same sub-layers, the negative one should go below others; the positive
+ // one should go above others.
+ childWindows.add(i, this);
+ added = true;
break;
- } else if (this.mSubLayer > child.mSubLayer) {
- continue;
- }
-
- if (this.mBaseLayer <= child.mBaseLayer) {
- mAttachedWindow.mChildWindows.add(i, this);
- break;
- } else {
- continue;
}
}
- if (children_size == mAttachedWindow.mChildWindows.size()) {
- mAttachedWindow.mChildWindows.add(this);
+ if (!added) {
+ childWindows.add(this);
}
}
diff --git a/services/core/jni/Android.mk b/services/core/jni/Android.mk
index d81cdd9..dc073ad 100644
--- a/services/core/jni/Android.mk
+++ b/services/core/jni/Android.mk
@@ -2,7 +2,7 @@
# files
LOCAL_REL_DIR := core/jni
-LOCAL_CFLAGS += -Wno-unused-parameter
+LOCAL_CFLAGS += -Wall -Werror -Wno-unused-parameter
LOCAL_SRC_FILES += \
$(LOCAL_REL_DIR)/com_android_server_AlarmManagerService.cpp \
@@ -27,8 +27,6 @@ LOCAL_SRC_FILES += \
$(LOCAL_REL_DIR)/com_android_server_PersistentDataBlockService.cpp \
$(LOCAL_REL_DIR)/onload.cpp
-include external/stlport/libstlport.mk
-
LOCAL_C_INCLUDES += \
$(JNI_H_INCLUDE) \
frameworks/base/services \
@@ -37,8 +35,8 @@ LOCAL_C_INCLUDES += \
frameworks/native/services \
libcore/include \
libcore/include/libsuspend \
- $(call include-path-for, libhardware)/hardware \
- $(call include-path-for, libhardware_legacy)/hardware_legacy \
+ $(call include-path-for, libhardware)/hardware \
+ $(call include-path-for, libhardware_legacy)/hardware_legacy \
LOCAL_SHARED_LIBRARIES += \
libandroid_runtime \
diff --git a/services/core/jni/com_android_server_AlarmManagerService.cpp b/services/core/jni/com_android_server_AlarmManagerService.cpp
index a58b00bce..3fd0f84 100644
--- a/services/core/jni/com_android_server_AlarmManagerService.cpp
+++ b/services/core/jni/com_android_server_AlarmManagerService.cpp
@@ -21,7 +21,9 @@
#include "jni.h"
#include <utils/Log.h>
#include <utils/misc.h>
+#include <utils/String8.h>
+#include <dirent.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
@@ -80,8 +82,8 @@ public:
class AlarmImplTimerFd : public AlarmImpl
{
public:
- AlarmImplTimerFd(int fds[N_ANDROID_TIMERFDS], int epollfd) :
- AlarmImpl(fds, N_ANDROID_TIMERFDS), epollfd(epollfd) { }
+ AlarmImplTimerFd(int fds[N_ANDROID_TIMERFDS], int epollfd, int rtc_id) :
+ AlarmImpl(fds, N_ANDROID_TIMERFDS), epollfd(epollfd), rtc_id(rtc_id) { }
~AlarmImplTimerFd();
int set(int type, struct timespec *ts);
@@ -90,6 +92,7 @@ public:
private:
int epollfd;
+ int rtc_id;
};
AlarmImpl::AlarmImpl(int *fds_, size_t n_fds) : fds(new int[n_fds]),
@@ -170,9 +173,16 @@ int AlarmImplTimerFd::setTime(struct timeval *tv)
return -1;
}
- fd = open("/dev/rtc0", O_RDWR);
+ if (rtc_id < 0) {
+ ALOGV("Not setting RTC because wall clock RTC was not found");
+ errno = ENODEV;
+ return -1;
+ }
+
+ android::String8 rtc_dev = String8::format("/dev/rtc%d", rtc_id);
+ fd = open(rtc_dev.string(), O_RDWR);
if (fd < 0) {
- ALOGV("Unable to open RTC driver: %s\n", strerror(errno));
+ ALOGV("Unable to open %s: %s\n", rtc_dev.string(), strerror(errno));
return res;
}
@@ -283,6 +293,66 @@ static jlong init_alarm_driver()
return reinterpret_cast<jlong>(ret);
}
+static const char rtc_sysfs[] = "/sys/class/rtc";
+
+static bool rtc_is_hctosys(unsigned int rtc_id)
+{
+ android::String8 hctosys_path = String8::format("%s/rtc%u/hctosys",
+ rtc_sysfs, rtc_id);
+
+ FILE *file = fopen(hctosys_path.string(), "re");
+ if (!file) {
+ ALOGE("failed to open %s: %s", hctosys_path.string(), strerror(errno));
+ return false;
+ }
+
+ unsigned int hctosys;
+ bool ret = false;
+ int err = fscanf(file, "%u", &hctosys);
+ if (err == EOF)
+ ALOGE("failed to read from %s: %s", hctosys_path.string(),
+ strerror(errno));
+ else if (err == 0)
+ ALOGE("%s did not have expected contents", hctosys_path.string());
+ else
+ ret = hctosys;
+
+ fclose(file);
+ return ret;
+}
+
+static int wall_clock_rtc()
+{
+ DIR *dir = opendir(rtc_sysfs);
+ if (!dir) {
+ ALOGE("failed to open %s: %s", rtc_sysfs, strerror(errno));
+ return -1;
+ }
+
+ struct dirent *dirent;
+ while (errno = 0, dirent = readdir(dir)) {
+ unsigned int rtc_id;
+ int matched = sscanf(dirent->d_name, "rtc%u", &rtc_id);
+
+ if (matched < 0)
+ break;
+ else if (matched != 1)
+ continue;
+
+ if (rtc_is_hctosys(rtc_id)) {
+ ALOGV("found wall clock RTC %u", rtc_id);
+ return rtc_id;
+ }
+ }
+
+ if (errno == 0)
+ ALOGW("no wall clock RTC found");
+ else
+ ALOGE("failed to enumerate RTCs: %s", strerror(errno));
+
+ return -1;
+}
+
static jlong init_timerfd()
{
int epollfd;
@@ -290,7 +360,7 @@ static jlong init_timerfd()
epollfd = epoll_create(N_ANDROID_TIMERFDS);
if (epollfd < 0) {
- ALOGV("epoll_create(%u) failed: %s", N_ANDROID_TIMERFDS,
+ ALOGV("epoll_create(%zu) failed: %s", N_ANDROID_TIMERFDS,
strerror(errno));
return 0;
}
@@ -308,7 +378,7 @@ static jlong init_timerfd()
}
}
- AlarmImpl *ret = new AlarmImplTimerFd(fds, epollfd);
+ AlarmImpl *ret = new AlarmImplTimerFd(fds, epollfd, wall_clock_rtc());
for (size_t i = 0; i < N_ANDROID_TIMERFDS; i++) {
epoll_event event;
diff --git a/services/core/jni/com_android_server_AssetAtlasService.cpp b/services/core/jni/com_android_server_AssetAtlasService.cpp
index 3696e24..e4f242e 100644
--- a/services/core/jni/com_android_server_AssetAtlasService.cpp
+++ b/services/core/jni/com_android_server_AssetAtlasService.cpp
@@ -29,8 +29,12 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
+// Disable warnings for Skia.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <SkCanvas.h>
#include <SkBitmap.h>
+#pragma GCC diagnostic pop
namespace android {
diff --git a/services/core/jni/com_android_server_ConsumerIrService.cpp b/services/core/jni/com_android_server_ConsumerIrService.cpp
index 3a50ff7..f5121cd 100644
--- a/services/core/jni/com_android_server_ConsumerIrService.cpp
+++ b/services/core/jni/com_android_server_ConsumerIrService.cpp
@@ -29,7 +29,7 @@
namespace android {
-static jlong halOpen(JNIEnv *env, jobject obj) {
+static jlong halOpen(JNIEnv* /* env */, jobject /* obj */) {
hw_module_t const* module;
consumerir_device_t *dev;
int err;
@@ -50,7 +50,7 @@ static jlong halOpen(JNIEnv *env, jobject obj) {
return reinterpret_cast<jlong>(dev);
}
-static jint halTransmit(JNIEnv *env, jobject obj, jlong halObject,
+static jint halTransmit(JNIEnv *env, jobject /* obj */, jlong halObject,
jint carrierFrequency, jintArray pattern) {
int ret;
@@ -66,7 +66,7 @@ static jint halTransmit(JNIEnv *env, jobject obj, jlong halObject,
return reinterpret_cast<jint>(ret);
}
-static jintArray halGetCarrierFrequencies(JNIEnv *env, jobject obj,
+static jintArray halGetCarrierFrequencies(JNIEnv *env, jobject /* obj */,
jlong halObject) {
consumerir_device_t *dev = reinterpret_cast<consumerir_device_t*>(halObject);
consumerir_freq_range_t *ranges;
diff --git a/services/core/jni/com_android_server_SerialService.cpp b/services/core/jni/com_android_server_SerialService.cpp
index b889b78..d48d159 100644
--- a/services/core/jni/com_android_server_SerialService.cpp
+++ b/services/core/jni/com_android_server_SerialService.cpp
@@ -34,7 +34,7 @@ static struct parcel_file_descriptor_offsets_t
jmethodID mConstructor;
} gParcelFileDescriptorOffsets;
-static jobject android_server_SerialService_open(JNIEnv *env, jobject thiz, jstring path)
+static jobject android_server_SerialService_open(JNIEnv *env, jobject /* thiz */, jstring path)
{
const char *pathStr = env->GetStringUTFChars(path, NULL);
diff --git a/services/core/jni/com_android_server_SystemServer.cpp b/services/core/jni/com_android_server_SystemServer.cpp
index 0625544..c50d63c 100644
--- a/services/core/jni/com_android_server_SystemServer.cpp
+++ b/services/core/jni/com_android_server_SystemServer.cpp
@@ -25,7 +25,7 @@
namespace android {
-static void android_server_SystemServer_nativeInit(JNIEnv* env, jobject clazz) {
+static void android_server_SystemServer_nativeInit(JNIEnv* /* env */, jobject /* clazz */) {
char propBuf[PROPERTY_VALUE_MAX];
property_get("system_init.startsensorservice", propBuf, "1");
if (strcmp(propBuf, "1") == 0) {
diff --git a/services/core/jni/com_android_server_UsbDeviceManager.cpp b/services/core/jni/com_android_server_UsbDeviceManager.cpp
index 3551733..a1bff9d 100644
--- a/services/core/jni/com_android_server_UsbDeviceManager.cpp
+++ b/services/core/jni/com_android_server_UsbDeviceManager.cpp
@@ -41,20 +41,12 @@ static struct parcel_file_descriptor_offsets_t
jmethodID mConstructor;
} gParcelFileDescriptorOffsets;
-static void checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodName) {
- if (env->ExceptionCheck()) {
- ALOGE("An exception was thrown by callback '%s'.", methodName);
- LOGE_EX(env);
- env->ExceptionClear();
- }
-}
-
static void set_accessory_string(JNIEnv *env, int fd, int cmd, jobjectArray strArray, int index)
{
char buffer[256];
buffer[0] = 0;
- int length = ioctl(fd, cmd, buffer);
+ ioctl(fd, cmd, buffer);
if (buffer[0]) {
jstring obj = env->NewStringUTF(buffer);
env->SetObjectArrayElement(strArray, index, obj);
@@ -63,7 +55,8 @@ static void set_accessory_string(JNIEnv *env, int fd, int cmd, jobjectArray strA
}
-static jobjectArray android_server_UsbDeviceManager_getAccessoryStrings(JNIEnv *env, jobject thiz)
+static jobjectArray android_server_UsbDeviceManager_getAccessoryStrings(JNIEnv *env,
+ jobject /* thiz */)
{
int fd = open(DRIVER_NAME, O_RDWR);
if (fd < 0) {
@@ -85,7 +78,7 @@ out:
return strArray;
}
-static jobject android_server_UsbDeviceManager_openAccessory(JNIEnv *env, jobject thiz)
+static jobject android_server_UsbDeviceManager_openAccessory(JNIEnv *env, jobject /* thiz */)
{
int fd = open(DRIVER_NAME, O_RDWR);
if (fd < 0) {
@@ -100,7 +93,8 @@ static jobject android_server_UsbDeviceManager_openAccessory(JNIEnv *env, jobjec
gParcelFileDescriptorOffsets.mConstructor, fileDescriptor);
}
-static jboolean android_server_UsbDeviceManager_isStartRequested(JNIEnv *env, jobject thiz)
+static jboolean android_server_UsbDeviceManager_isStartRequested(JNIEnv* /* env */,
+ jobject /* thiz */)
{
int fd = open(DRIVER_NAME, O_RDWR);
if (fd < 0) {
@@ -112,7 +106,7 @@ static jboolean android_server_UsbDeviceManager_isStartRequested(JNIEnv *env, jo
return (result == 1);
}
-static jint android_server_UsbDeviceManager_getAudioMode(JNIEnv *env, jobject thiz)
+static jint android_server_UsbDeviceManager_getAudioMode(JNIEnv* /* env */, jobject /* thiz */)
{
int fd = open(DRIVER_NAME, O_RDWR);
if (fd < 0) {
diff --git a/services/core/jni/com_android_server_UsbHostManager.cpp b/services/core/jni/com_android_server_UsbHostManager.cpp
index 32c3f95..ee50ff9 100644
--- a/services/core/jni/com_android_server_UsbHostManager.cpp
+++ b/services/core/jni/com_android_server_UsbHostManager.cpp
@@ -148,7 +148,7 @@ static int usb_device_removed(const char *devname, void* client_data) {
return 0;
}
-static void android_server_UsbHostManager_monitorUsbHostBus(JNIEnv *env, jobject thiz)
+static void android_server_UsbHostManager_monitorUsbHostBus(JNIEnv* /* env */, jobject thiz)
{
struct usb_host_context* context = usb_host_init();
if (!context) {
@@ -159,7 +159,8 @@ static void android_server_UsbHostManager_monitorUsbHostBus(JNIEnv *env, jobject
usb_host_run(context, usb_device_added, usb_device_removed, NULL, (void *)thiz);
}
-static jobject android_server_UsbHostManager_openDevice(JNIEnv *env, jobject thiz, jstring deviceName)
+static jobject android_server_UsbHostManager_openDevice(JNIEnv *env, jobject /* thiz */,
+ jstring deviceName)
{
const char *deviceNameStr = env->GetStringUTFChars(deviceName, NULL);
struct usb_device* device = usb_device_open(deviceNameStr);
diff --git a/services/core/jni/com_android_server_VibratorService.cpp b/services/core/jni/com_android_server_VibratorService.cpp
index 2b3f74a..fb1166b 100644
--- a/services/core/jni/com_android_server_VibratorService.cpp
+++ b/services/core/jni/com_android_server_VibratorService.cpp
@@ -29,18 +29,18 @@
namespace android
{
-static jboolean vibratorExists(JNIEnv *env, jobject clazz)
+static jboolean vibratorExists(JNIEnv* /* env */, jobject /* clazz */)
{
return vibrator_exists() > 0 ? JNI_TRUE : JNI_FALSE;
}
-static void vibratorOn(JNIEnv *env, jobject clazz, jlong timeout_ms)
+static void vibratorOn(JNIEnv* /* env */, jobject /* clazz */, jlong timeout_ms)
{
// ALOGI("vibratorOn\n");
vibrator_on(timeout_ms);
}
-static void vibratorOff(JNIEnv *env, jobject clazz)
+static void vibratorOff(JNIEnv* /* env */, jobject /* clazz */)
{
// ALOGI("vibratorOff\n");
vibrator_off();
diff --git a/services/core/jni/com_android_server_connectivity_Vpn.cpp b/services/core/jni/com_android_server_connectivity_Vpn.cpp
index 2a16dfe..7faeb49 100644
--- a/services/core/jni/com_android_server_connectivity_Vpn.cpp
+++ b/services/core/jni/com_android_server_connectivity_Vpn.cpp
@@ -226,12 +226,12 @@ static bool modifyAddress(JNIEnv *env, jobject thiz, jstring jName, jstring jAdd
jniThrowNullPointerException(env, "address");
} else {
if (add) {
- if (error = ifc_add_address(name, address, jPrefixLength)) {
+ if ((error = ifc_add_address(name, address, jPrefixLength)) != 0) {
ALOGE("Cannot add address %s/%d on interface %s (%s)", address, jPrefixLength, name,
strerror(-error));
}
} else {
- if (error = ifc_del_address(name, address, jPrefixLength)) {
+ if ((error = ifc_del_address(name, address, jPrefixLength)) != 0) {
ALOGE("Cannot del address %s/%d on interface %s (%s)", address, jPrefixLength, name,
strerror(-error));
}
@@ -258,7 +258,7 @@ static void throwException(JNIEnv *env, int error, const char *message)
}
}
-static jint create(JNIEnv *env, jobject thiz, jint mtu)
+static jint create(JNIEnv *env, jobject /* thiz */, jint mtu)
{
int tun = create_interface(mtu);
if (tun < 0) {
@@ -268,7 +268,7 @@ static jint create(JNIEnv *env, jobject thiz, jint mtu)
return tun;
}
-static jstring getName(JNIEnv *env, jobject thiz, jint tun)
+static jstring getName(JNIEnv *env, jobject /* thiz */, jint tun)
{
char name[IFNAMSIZ];
if (get_interface_name(name, tun) < 0) {
@@ -278,7 +278,7 @@ static jstring getName(JNIEnv *env, jobject thiz, jint tun)
return env->NewStringUTF(name);
}
-static jint setAddresses(JNIEnv *env, jobject thiz, jstring jName,
+static jint setAddresses(JNIEnv *env, jobject /* thiz */, jstring jName,
jstring jAddresses)
{
const char *name = NULL;
@@ -311,7 +311,7 @@ error:
return count;
}
-static void reset(JNIEnv *env, jobject thiz, jstring jName)
+static void reset(JNIEnv *env, jobject /* thiz */, jstring jName)
{
const char *name = jName ? env->GetStringUTFChars(jName, NULL) : NULL;
if (!name) {
@@ -324,7 +324,7 @@ static void reset(JNIEnv *env, jobject thiz, jstring jName)
env->ReleaseStringUTFChars(jName, name);
}
-static jint check(JNIEnv *env, jobject thiz, jstring jName)
+static jint check(JNIEnv *env, jobject /* thiz */, jstring jName)
{
const char *name = jName ? env->GetStringUTFChars(jName, NULL) : NULL;
if (!name) {
diff --git a/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp b/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp
index a35af91..f2d0f06 100644
--- a/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp
+++ b/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp
@@ -408,6 +408,7 @@ static JNINativeMethod sMethods[] = {
int register_android_server_hdmi_HdmiCecController(JNIEnv* env) {
int res = jniRegisterNativeMethods(env, CLASS_PATH, sMethods, NELEM(sMethods));
LOG_FATAL_IF(res < 0, "Unable to register native methods.");
+ (void)res; // Don't scream about unused variable in the LOG_NDEBUG case
return 0;
}
diff --git a/services/core/jni/com_android_server_input_InputApplicationHandle.cpp b/services/core/jni/com_android_server_input_InputApplicationHandle.cpp
index f943d16..11388d8 100644
--- a/services/core/jni/com_android_server_input_InputApplicationHandle.cpp
+++ b/services/core/jni/com_android_server_input_InputApplicationHandle.cpp
@@ -137,6 +137,7 @@ static JNINativeMethod gInputApplicationHandleMethods[] = {
int register_android_server_InputApplicationHandle(JNIEnv* env) {
int res = jniRegisterNativeMethods(env, "com/android/server/input/InputApplicationHandle",
gInputApplicationHandleMethods, NELEM(gInputApplicationHandleMethods));
+ (void) res; // Faked use when LOG_NDEBUG.
LOG_FATAL_IF(res < 0, "Unable to register native methods.");
jclass clazz;
diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp
index cddca92..7c5980a 100644
--- a/services/core/jni/com_android_server_input_InputManagerService.cpp
+++ b/services/core/jni/com_android_server_input_InputManagerService.cpp
@@ -350,14 +350,14 @@ void NativeInputManager::setDisplayViewport(bool external, const DisplayViewport
}
}
-status_t NativeInputManager::registerInputChannel(JNIEnv* env,
+status_t NativeInputManager::registerInputChannel(JNIEnv* /* env */,
const sp<InputChannel>& inputChannel,
const sp<InputWindowHandle>& inputWindowHandle, bool monitor) {
return mInputManager->getDispatcher()->registerInputChannel(
inputChannel, inputWindowHandle, monitor);
}
-status_t NativeInputManager::unregisterInputChannel(JNIEnv* env,
+status_t NativeInputManager::unregisterInputChannel(JNIEnv* /* env */,
const sp<InputChannel>& inputChannel) {
return mInputManager->getDispatcher()->unregisterInputChannel(inputChannel);
}
@@ -428,7 +428,7 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon
} // release lock
}
-sp<PointerControllerInterface> NativeInputManager::obtainPointerController(int32_t deviceId) {
+sp<PointerControllerInterface> NativeInputManager::obtainPointerController(int32_t /* deviceId */) {
AutoMutex _l(mLock);
sp<PointerController> controller = mLocked.pointerController.promote();
@@ -548,7 +548,7 @@ String8 NativeInputManager::getDeviceAlias(const InputDeviceIdentifier& identifi
}
void NativeInputManager::notifySwitch(nsecs_t when,
- uint32_t switchValues, uint32_t switchMask, uint32_t policyFlags) {
+ uint32_t switchValues, uint32_t switchMask, uint32_t /* policyFlags */) {
#if DEBUG_INPUT_DISPATCHER_POLICY
ALOGD("notifySwitch - when=%lld, switchValues=0x%08x, switchMask=0x%08x, policyFlags=0x%x",
when, switchValues, switchMask, policyFlags);
@@ -1006,7 +1006,7 @@ void NativeInputManager::loadPointerResources(PointerResources* outResources) {
// ----------------------------------------------------------------------------
-static jlong nativeInit(JNIEnv* env, jclass clazz,
+static jlong nativeInit(JNIEnv* env, jclass /* clazz */,
jobject serviceObj, jobject contextObj, jobject messageQueueObj) {
sp<MessageQueue> messageQueue = android_os_MessageQueue_getMessageQueue(env, messageQueueObj);
if (messageQueue == NULL) {
@@ -1020,7 +1020,7 @@ static jlong nativeInit(JNIEnv* env, jclass clazz,
return reinterpret_cast<jlong>(im);
}
-static void nativeStart(JNIEnv* env, jclass clazz, jlong ptr) {
+static void nativeStart(JNIEnv* env, jclass /* clazz */, jlong ptr) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
status_t result = im->getInputManager()->start();
@@ -1029,8 +1029,8 @@ static void nativeStart(JNIEnv* env, jclass clazz, jlong ptr) {
}
}
-static void nativeSetDisplayViewport(JNIEnv* env, jclass clazz, jlong ptr, jboolean external,
- jint displayId, jint orientation,
+static void nativeSetDisplayViewport(JNIEnv* /* env */, jclass /* clazz */, jlong ptr,
+ jboolean external, jint displayId, jint orientation,
jint logicalLeft, jint logicalTop, jint logicalRight, jint logicalBottom,
jint physicalLeft, jint physicalTop, jint physicalRight, jint physicalBottom,
jint deviceWidth, jint deviceHeight) {
@@ -1052,7 +1052,7 @@ static void nativeSetDisplayViewport(JNIEnv* env, jclass clazz, jlong ptr, jbool
im->setDisplayViewport(external, v);
}
-static jint nativeGetScanCodeState(JNIEnv* env, jclass clazz,
+static jint nativeGetScanCodeState(JNIEnv* /* env */, jclass /* clazz */,
jlong ptr, jint deviceId, jint sourceMask, jint scanCode) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
@@ -1060,7 +1060,7 @@ static jint nativeGetScanCodeState(JNIEnv* env, jclass clazz,
deviceId, uint32_t(sourceMask), scanCode);
}
-static jint nativeGetKeyCodeState(JNIEnv* env, jclass clazz,
+static jint nativeGetKeyCodeState(JNIEnv* /* env */, jclass /* clazz */,
jlong ptr, jint deviceId, jint sourceMask, jint keyCode) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
@@ -1068,7 +1068,7 @@ static jint nativeGetKeyCodeState(JNIEnv* env, jclass clazz,
deviceId, uint32_t(sourceMask), keyCode);
}
-static jint nativeGetSwitchState(JNIEnv* env, jclass clazz,
+static jint nativeGetSwitchState(JNIEnv* /* env */, jclass /* clazz */,
jlong ptr, jint deviceId, jint sourceMask, jint sw) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
@@ -1076,7 +1076,7 @@ static jint nativeGetSwitchState(JNIEnv* env, jclass clazz,
deviceId, uint32_t(sourceMask), sw);
}
-static jboolean nativeHasKeys(JNIEnv* env, jclass clazz,
+static jboolean nativeHasKeys(JNIEnv* env, jclass /* clazz */,
jlong ptr, jint deviceId, jint sourceMask, jintArray keyCodes, jbooleanArray outFlags) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
@@ -1106,7 +1106,7 @@ static void throwInputChannelNotInitialized(JNIEnv* env) {
}
static void handleInputChannelDisposed(JNIEnv* env,
- jobject inputChannelObj, const sp<InputChannel>& inputChannel, void* data) {
+ jobject /* inputChannelObj */, const sp<InputChannel>& inputChannel, void* data) {
NativeInputManager* im = static_cast<NativeInputManager*>(data);
ALOGW("Input channel object '%s' was disposed without first being unregistered with "
@@ -1114,7 +1114,7 @@ static void handleInputChannelDisposed(JNIEnv* env,
im->unregisterInputChannel(env, inputChannel);
}
-static void nativeRegisterInputChannel(JNIEnv* env, jclass clazz,
+static void nativeRegisterInputChannel(JNIEnv* env, jclass /* clazz */,
jlong ptr, jobject inputChannelObj, jobject inputWindowHandleObj, jboolean monitor) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
@@ -1143,7 +1143,7 @@ static void nativeRegisterInputChannel(JNIEnv* env, jclass clazz,
}
}
-static void nativeUnregisterInputChannel(JNIEnv* env, jclass clazz,
+static void nativeUnregisterInputChannel(JNIEnv* env, jclass /* clazz */,
jlong ptr, jobject inputChannelObj) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
@@ -1164,14 +1164,14 @@ static void nativeUnregisterInputChannel(JNIEnv* env, jclass clazz,
}
}
-static void nativeSetInputFilterEnabled(JNIEnv* env, jclass clazz,
+static void nativeSetInputFilterEnabled(JNIEnv* /* env */, jclass /* clazz */,
jlong ptr, jboolean enabled) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
im->getInputManager()->getDispatcher()->setInputFilterEnabled(enabled);
}
-static jint nativeInjectInputEvent(JNIEnv* env, jclass clazz,
+static jint nativeInjectInputEvent(JNIEnv* env, jclass /* clazz */,
jlong ptr, jobject inputEventObj, jint displayId, jint injectorPid, jint injectorUid,
jint syncMode, jint timeoutMillis, jint policyFlags) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
@@ -1203,36 +1203,36 @@ static jint nativeInjectInputEvent(JNIEnv* env, jclass clazz,
}
}
-static void nativeSetInputWindows(JNIEnv* env, jclass clazz,
+static void nativeSetInputWindows(JNIEnv* env, jclass /* clazz */,
jlong ptr, jobjectArray windowHandleObjArray) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
im->setInputWindows(env, windowHandleObjArray);
}
-static void nativeSetFocusedApplication(JNIEnv* env, jclass clazz,
+static void nativeSetFocusedApplication(JNIEnv* env, jclass /* clazz */,
jlong ptr, jobject applicationHandleObj) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
im->setFocusedApplication(env, applicationHandleObj);
}
-static void nativeSetInputDispatchMode(JNIEnv* env,
- jclass clazz, jlong ptr, jboolean enabled, jboolean frozen) {
+static void nativeSetInputDispatchMode(JNIEnv* /* env */,
+ jclass /* clazz */, jlong ptr, jboolean enabled, jboolean frozen) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
im->setInputDispatchMode(enabled, frozen);
}
-static void nativeSetSystemUiVisibility(JNIEnv* env,
- jclass clazz, jlong ptr, jint visibility) {
+static void nativeSetSystemUiVisibility(JNIEnv* /* env */,
+ jclass /* clazz */, jlong ptr, jint visibility) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
im->setSystemUiVisibility(visibility);
}
static jboolean nativeTransferTouchFocus(JNIEnv* env,
- jclass clazz, jlong ptr, jobject fromChannelObj, jobject toChannelObj) {
+ jclass /* clazz */, jlong ptr, jobject fromChannelObj, jobject toChannelObj) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
sp<InputChannel> fromChannel =
@@ -1252,15 +1252,15 @@ static jboolean nativeTransferTouchFocus(JNIEnv* env,
}
}
-static void nativeSetPointerSpeed(JNIEnv* env,
- jclass clazz, jlong ptr, jint speed) {
+static void nativeSetPointerSpeed(JNIEnv* /* env */,
+ jclass /* clazz */, jlong ptr, jint speed) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
im->setPointerSpeed(speed);
}
-static void nativeSetShowTouches(JNIEnv* env,
- jclass clazz, jlong ptr, jboolean enabled) {
+static void nativeSetShowTouches(JNIEnv* /* env */,
+ jclass /* clazz */, jlong ptr, jboolean enabled) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
im->setShowTouches(enabled);
@@ -1279,7 +1279,7 @@ static void nativeReloadCalibration(JNIEnv* env, jclass clazz, jlong ptr) {
}
static void nativeVibrate(JNIEnv* env,
- jclass clazz, jlong ptr, jint deviceId, jlongArray patternObj,
+ jclass /* clazz */, jlong ptr, jint deviceId, jlongArray patternObj,
jint repeat, jint token) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
@@ -1303,30 +1303,30 @@ static void nativeVibrate(JNIEnv* env,
im->getInputManager()->getReader()->vibrate(deviceId, pattern, patternSize, repeat, token);
}
-static void nativeCancelVibrate(JNIEnv* env,
- jclass clazz, jlong ptr, jint deviceId, jint token) {
+static void nativeCancelVibrate(JNIEnv* /* env */,
+ jclass /* clazz */, jlong ptr, jint deviceId, jint token) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
im->getInputManager()->getReader()->cancelVibrate(deviceId, token);
}
-static void nativeReloadKeyboardLayouts(JNIEnv* env,
- jclass clazz, jlong ptr) {
+static void nativeReloadKeyboardLayouts(JNIEnv* /* env */,
+ jclass /* clazz */, jlong ptr) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
im->getInputManager()->getReader()->requestRefreshConfiguration(
InputReaderConfiguration::CHANGE_KEYBOARD_LAYOUTS);
}
-static void nativeReloadDeviceAliases(JNIEnv* env,
- jclass clazz, jlong ptr) {
+static void nativeReloadDeviceAliases(JNIEnv* /* env */,
+ jclass /* clazz */, jlong ptr) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
im->getInputManager()->getReader()->requestRefreshConfiguration(
InputReaderConfiguration::CHANGE_DEVICE_ALIAS);
}
-static jstring nativeDump(JNIEnv* env, jclass clazz, jlong ptr) {
+static jstring nativeDump(JNIEnv* env, jclass /* clazz */, jlong ptr) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
String8 dump;
@@ -1334,7 +1334,7 @@ static jstring nativeDump(JNIEnv* env, jclass clazz, jlong ptr) {
return env->NewStringUTF(dump.string());
}
-static void nativeMonitor(JNIEnv* env, jclass clazz, jlong ptr) {
+static void nativeMonitor(JNIEnv* /* env */, jclass /* clazz */, jlong ptr) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
im->getInputManager()->getReader()->monitor();
@@ -1416,6 +1416,7 @@ static JNINativeMethod gInputManagerMethods[] = {
int register_android_server_InputManager(JNIEnv* env) {
int res = jniRegisterNativeMethods(env, "com/android/server/input/InputManagerService",
gInputManagerMethods, NELEM(gInputManagerMethods));
+ (void) res; // Faked use when LOG_NDEBUG.
LOG_FATAL_IF(res < 0, "Unable to register native methods.");
// Callbacks
diff --git a/services/core/jni/com_android_server_input_InputWindowHandle.cpp b/services/core/jni/com_android_server_input_InputWindowHandle.cpp
index 46ec1f4..01c51cf 100644
--- a/services/core/jni/com_android_server_input_InputWindowHandle.cpp
+++ b/services/core/jni/com_android_server_input_InputWindowHandle.cpp
@@ -227,6 +227,7 @@ static JNINativeMethod gInputWindowHandleMethods[] = {
int register_android_server_InputWindowHandle(JNIEnv* env) {
int res = jniRegisterNativeMethods(env, "com/android/server/input/InputWindowHandle",
gInputWindowHandleMethods, NELEM(gInputWindowHandleMethods));
+ (void) res; // Faked use when LOG_NDEBUG.
LOG_FATAL_IF(res < 0, "Unable to register native methods.");
jclass clazz;
diff --git a/services/core/jni/com_android_server_lights_LightsService.cpp b/services/core/jni/com_android_server_lights_LightsService.cpp
index d51e044..b2b2783 100644
--- a/services/core/jni/com_android_server_lights_LightsService.cpp
+++ b/services/core/jni/com_android_server_lights_LightsService.cpp
@@ -60,7 +60,7 @@ static light_device_t* get_device(hw_module_t* module, char const* name)
}
}
-static jlong init_native(JNIEnv *env, jobject clazz)
+static jlong init_native(JNIEnv* /* env */, jobject /* clazz */)
{
int err;
hw_module_t* module;
@@ -93,7 +93,7 @@ static jlong init_native(JNIEnv *env, jobject clazz)
return (jlong)devices;
}
-static void finalize_native(JNIEnv *env, jobject clazz, jlong ptr)
+static void finalize_native(JNIEnv* /* env */, jobject /* clazz */, jlong ptr)
{
Devices* devices = (Devices*)ptr;
if (devices == NULL) {
@@ -103,7 +103,7 @@ static void finalize_native(JNIEnv *env, jobject clazz, jlong ptr)
free(devices);
}
-static void setLight_native(JNIEnv *env, jobject clazz, jlong ptr,
+static void setLight_native(JNIEnv* /* env */, jobject /* clazz */, jlong ptr,
jint light, jint colorARGB, jint flashMode, jint onMS, jint offMS, jint brightnessMode)
{
Devices* devices = (Devices*)ptr;
diff --git a/services/core/jni/com_android_server_location_FlpHardwareProvider.cpp b/services/core/jni/com_android_server_location_FlpHardwareProvider.cpp
index 37a3eaa..049e455 100644
--- a/services/core/jni/com_android_server_location_FlpHardwareProvider.cpp
+++ b/services/core/jni/com_android_server_location_FlpHardwareProvider.cpp
@@ -698,14 +698,14 @@ static void Init(JNIEnv* env, jobject obj) {
// TODO: inject any device context if when needed
}
-static jboolean IsSupported(JNIEnv* env, jclass clazz) {
+static jboolean IsSupported(JNIEnv* /* env */, jclass /* clazz */) {
if (sFlpInterface == NULL) {
return JNI_FALSE;
}
return JNI_TRUE;
}
-static jint GetBatchSize(JNIEnv* env, jobject object) {
+static jint GetBatchSize(JNIEnv* env, jobject /* object */) {
if(sFlpInterface == NULL) {
ThrowOnError(env, FLP_RESULT_ERROR, __FUNCTION__);
}
@@ -715,7 +715,7 @@ static jint GetBatchSize(JNIEnv* env, jobject object) {
static void StartBatching(
JNIEnv* env,
- jobject object,
+ jobject /* object */,
jint id,
jobject optionsObject) {
if(sFlpInterface == NULL || optionsObject == NULL) {
@@ -730,7 +730,7 @@ static void StartBatching(
static void UpdateBatchingOptions(
JNIEnv* env,
- jobject object,
+ jobject /* object */,
jint id,
jobject optionsObject) {
if(sFlpInterface == NULL || optionsObject == NULL) {
@@ -743,7 +743,7 @@ static void UpdateBatchingOptions(
ThrowOnError(env, result, __FUNCTION__);
}
-static void StopBatching(JNIEnv* env, jobject object, jint id) {
+static void StopBatching(JNIEnv* env, jobject /* object */, jint id) {
if(sFlpInterface == NULL) {
ThrowOnError(env, FLP_RESULT_ERROR, __FUNCTION__);
}
@@ -751,7 +751,7 @@ static void StopBatching(JNIEnv* env, jobject object, jint id) {
sFlpInterface->stop_batching(id);
}
-static void Cleanup(JNIEnv* env, jobject object) {
+static void Cleanup(JNIEnv* env, jobject /* object */) {
if(sFlpInterface == NULL) {
ThrowOnError(env, FLP_RESULT_ERROR, __FUNCTION__);
}
@@ -774,7 +774,7 @@ static void Cleanup(JNIEnv* env, jobject object) {
}
}
-static void GetBatchedLocation(JNIEnv* env, jobject object, jint lastNLocations) {
+static void GetBatchedLocation(JNIEnv* env, jobject /* object */, jint lastNLocations) {
if(sFlpInterface == NULL) {
ThrowOnError(env, FLP_RESULT_ERROR, __FUNCTION__);
}
@@ -782,7 +782,7 @@ static void GetBatchedLocation(JNIEnv* env, jobject object, jint lastNLocations)
sFlpInterface->get_batched_location(lastNLocations);
}
-static void InjectLocation(JNIEnv* env, jobject object, jobject locationObject) {
+static void InjectLocation(JNIEnv* env, jobject /* object */, jobject locationObject) {
if(locationObject == NULL) {
ALOGE("Invalid location for injection: %p", locationObject);
ThrowOnError(env, FLP_RESULT_ERROR, __FUNCTION__);
@@ -806,7 +806,7 @@ static jboolean IsDiagnosticSupported() {
return sFlpDiagnosticInterface != NULL;
}
-static void InjectDiagnosticData(JNIEnv* env, jobject object, jstring stringData) {
+static void InjectDiagnosticData(JNIEnv* env, jobject /* object */, jstring stringData) {
if(stringData == NULL) {
ALOGE("Invalid diagnostic data for injection: %p", stringData);
ThrowOnError(env, FLP_RESULT_ERROR, __FUNCTION__);
@@ -830,7 +830,7 @@ static jboolean IsDeviceContextSupported() {
return sFlpDeviceContextInterface != NULL;
}
-static void InjectDeviceContext(JNIEnv* env, jobject object, jint enabledMask) {
+static void InjectDeviceContext(JNIEnv* env, jobject /* object */, jint enabledMask) {
if(sFlpDeviceContextInterface == NULL) {
ThrowOnError(env, FLP_RESULT_ERROR, __FUNCTION__);
}
@@ -845,7 +845,7 @@ static jboolean IsGeofencingSupported() {
static void AddGeofences(
JNIEnv* env,
- jobject object,
+ jobject /* object */,
jobjectArray geofenceRequestsArray) {
if(geofenceRequestsArray == NULL) {
ALOGE("Invalid Geofences to add: %p", geofenceRequestsArray);
@@ -885,7 +885,7 @@ static void AddGeofences(
}
}
-static void PauseGeofence(JNIEnv* env, jobject object, jint geofenceId) {
+static void PauseGeofence(JNIEnv* env, jobject /* object */, jint geofenceId) {
if(sFlpGeofencingInterface == NULL) {
ThrowOnError(env, FLP_RESULT_ERROR, __FUNCTION__);
}
@@ -895,7 +895,7 @@ static void PauseGeofence(JNIEnv* env, jobject object, jint geofenceId) {
static void ResumeGeofence(
JNIEnv* env,
- jobject object,
+ jobject /* object */,
jint geofenceId,
jint monitorTransitions) {
if(sFlpGeofencingInterface == NULL) {
@@ -907,7 +907,7 @@ static void ResumeGeofence(
static void ModifyGeofenceOption(
JNIEnv* env,
- jobject object,
+ jobject /* object */,
jint geofenceId,
jint lastTransition,
jint monitorTransitions,
@@ -931,7 +931,7 @@ static void ModifyGeofenceOption(
static void RemoveGeofences(
JNIEnv* env,
- jobject object,
+ jobject /* object */,
jintArray geofenceIdsArray) {
if(sFlpGeofencingInterface == NULL) {
ThrowOnError(env, FLP_RESULT_ERROR, __FUNCTION__);
diff --git a/services/core/jni/com_android_server_location_GpsLocationProvider.cpp b/services/core/jni/com_android_server_location_GpsLocationProvider.cpp
index 8183321..0cd6eb5 100644
--- a/services/core/jni/com_android_server_location_GpsLocationProvider.cpp
+++ b/services/core/jni/com_android_server_location_GpsLocationProvider.cpp
@@ -214,7 +214,7 @@ static void agps_status_callback(AGpsStatus* agps_status)
size_t status_size = agps_status->size;
if (status_size == sizeof(AGpsStatus_v3)) {
- ALOGV("AGpsStatus is V3: %d", status_size);
+ ALOGV("AGpsStatus is V3: %zd", status_size);
switch (agps_status->addr.ss_family)
{
case AF_INET:
@@ -256,7 +256,7 @@ static void agps_status_callback(AGpsStatus* agps_status)
break;
}
} else if (status_size >= sizeof(AGpsStatus_v2)) {
- ALOGV("AGpsStatus is V2+: %d", status_size);
+ ALOGV("AGpsStatus is V2+: %zd", status_size);
// for back-compatibility reasons we check in v2 that the data structure size is greater or
// equal to the declared size in gps.h
uint32_t ipaddr = agps_status->ipaddr;
@@ -266,12 +266,12 @@ static void agps_status_callback(AGpsStatus* agps_status)
isSupported = true;
}
} else if (status_size >= sizeof(AGpsStatus_v1)) {
- ALOGV("AGpsStatus is V1+: %d", status_size);
+ ALOGV("AGpsStatus is V1+: %zd", status_size);
// because we have to check for >= with regards to v2, we also need to relax the check here
// and only make sure that the size is at least what we expect
isSupported = true;
} else {
- ALOGE("Invalid size of AGpsStatus found: %d.", status_size);
+ ALOGE("Invalid size of AGpsStatus found: %zd.", status_size);
}
if (isSupported) {
@@ -509,7 +509,8 @@ static void android_location_GpsLocationProvider_class_init_native(JNIEnv* env,
}
}
-static jboolean android_location_GpsLocationProvider_is_supported(JNIEnv* env, jclass clazz) {
+static jboolean android_location_GpsLocationProvider_is_supported(JNIEnv* /* env */,
+ jclass /* clazz */) {
if (sGpsInterface != NULL) {
return JNI_TRUE;
} else {
@@ -543,14 +544,15 @@ static jboolean android_location_GpsLocationProvider_init(JNIEnv* env, jobject o
return JNI_TRUE;
}
-static void android_location_GpsLocationProvider_cleanup(JNIEnv* env, jobject obj)
+static void android_location_GpsLocationProvider_cleanup(JNIEnv* /* env */, jobject /* obj */)
{
if (sGpsInterface)
sGpsInterface->cleanup();
}
-static jboolean android_location_GpsLocationProvider_set_position_mode(JNIEnv* env, jobject obj,
- jint mode, jint recurrence, jint min_interval, jint preferred_accuracy, jint preferred_time)
+static jboolean android_location_GpsLocationProvider_set_position_mode(JNIEnv* /* env */,
+ jobject /* obj */, jint mode, jint recurrence, jint min_interval, jint preferred_accuracy,
+ jint preferred_time)
{
if (sGpsInterface) {
if (sGpsInterface->set_position_mode(mode, recurrence, min_interval, preferred_accuracy,
@@ -564,7 +566,7 @@ static jboolean android_location_GpsLocationProvider_set_position_mode(JNIEnv* e
return JNI_FALSE;
}
-static jboolean android_location_GpsLocationProvider_start(JNIEnv* env, jobject obj)
+static jboolean android_location_GpsLocationProvider_start(JNIEnv* /* env */, jobject /* obj */)
{
if (sGpsInterface) {
if (sGpsInterface->start() == 0) {
@@ -577,7 +579,7 @@ static jboolean android_location_GpsLocationProvider_start(JNIEnv* env, jobject
return JNI_FALSE;
}
-static jboolean android_location_GpsLocationProvider_stop(JNIEnv* env, jobject obj)
+static jboolean android_location_GpsLocationProvider_stop(JNIEnv* /* env */, jobject /* obj */)
{
if (sGpsInterface) {
if (sGpsInterface->stop() == 0) {
@@ -590,13 +592,15 @@ static jboolean android_location_GpsLocationProvider_stop(JNIEnv* env, jobject o
return JNI_FALSE;
}
-static void android_location_GpsLocationProvider_delete_aiding_data(JNIEnv* env, jobject obj, jint flags)
+static void android_location_GpsLocationProvider_delete_aiding_data(JNIEnv* /* env */,
+ jobject /* obj */,
+ jint flags)
{
if (sGpsInterface)
sGpsInterface->delete_aiding_data(flags);
}
-static jint android_location_GpsLocationProvider_read_sv_status(JNIEnv* env, jobject obj,
+static jint android_location_GpsLocationProvider_read_sv_status(JNIEnv* env, jobject /* obj */,
jintArray prnArray, jfloatArray snrArray, jfloatArray elevArray, jfloatArray azumArray,
jintArray maskArray)
{
@@ -627,8 +631,8 @@ static jint android_location_GpsLocationProvider_read_sv_status(JNIEnv* env, job
return (jint) num_svs;
}
-static void android_location_GpsLocationProvider_agps_set_reference_location_cellid(JNIEnv* env,
- jobject obj, jint type, jint mcc, jint mnc, jint lac, jint cid)
+static void android_location_GpsLocationProvider_agps_set_reference_location_cellid(
+ JNIEnv* /* env */, jobject /* obj */, jint type, jint mcc, jint mnc, jint lac, jint cid)
{
AGpsRefLocation location;
@@ -655,7 +659,7 @@ static void android_location_GpsLocationProvider_agps_set_reference_location_cel
}
static void android_location_GpsLocationProvider_agps_send_ni_message(JNIEnv* env,
- jobject obj, jbyteArray ni_msg, jint size)
+ jobject /* obj */, jbyteArray ni_msg, jint size)
{
size_t sz;
@@ -671,8 +675,8 @@ static void android_location_GpsLocationProvider_agps_send_ni_message(JNIEnv* en
env->ReleaseByteArrayElements(ni_msg,b,0);
}
-static void android_location_GpsLocationProvider_agps_set_id(JNIEnv *env,
- jobject obj, jint type, jstring setid_string)
+static void android_location_GpsLocationProvider_agps_set_id(JNIEnv *env, jobject /* obj */,
+ jint type, jstring setid_string)
{
if (!sAGpsRilInterface) {
ALOGE("no AGPS RIL interface in agps_set_id");
@@ -684,7 +688,7 @@ static void android_location_GpsLocationProvider_agps_set_id(JNIEnv *env,
env->ReleaseStringUTFChars(setid_string, setid);
}
-static jint android_location_GpsLocationProvider_read_nmea(JNIEnv* env, jobject obj,
+static jint android_location_GpsLocationProvider_read_nmea(JNIEnv* env, jobject /* obj */,
jbyteArray nmeaArray, jint buffer_size)
{
// this should only be called from within a call to reportNmea
@@ -697,21 +701,22 @@ static jint android_location_GpsLocationProvider_read_nmea(JNIEnv* env, jobject
return (jint) length;
}
-static void android_location_GpsLocationProvider_inject_time(JNIEnv* env, jobject obj,
+static void android_location_GpsLocationProvider_inject_time(JNIEnv* /* env */, jobject /* obj */,
jlong time, jlong timeReference, jint uncertainty)
{
if (sGpsInterface)
sGpsInterface->inject_time(time, timeReference, uncertainty);
}
-static void android_location_GpsLocationProvider_inject_location(JNIEnv* env, jobject obj,
- jdouble latitude, jdouble longitude, jfloat accuracy)
+static void android_location_GpsLocationProvider_inject_location(JNIEnv* /* env */,
+ jobject /* obj */, jdouble latitude, jdouble longitude, jfloat accuracy)
{
if (sGpsInterface)
sGpsInterface->inject_location(latitude, longitude, accuracy);
}
-static jboolean android_location_GpsLocationProvider_supports_xtra(JNIEnv* env, jobject obj)
+static jboolean android_location_GpsLocationProvider_supports_xtra(JNIEnv* /* env */,
+ jobject /* obj */)
{
if (sGpsXtraInterface != NULL) {
return JNI_TRUE;
@@ -720,7 +725,7 @@ static jboolean android_location_GpsLocationProvider_supports_xtra(JNIEnv* env,
}
}
-static void android_location_GpsLocationProvider_inject_xtra_data(JNIEnv* env, jobject obj,
+static void android_location_GpsLocationProvider_inject_xtra_data(JNIEnv* env, jobject /* obj */,
jbyteArray data, jint length)
{
if (!sGpsXtraInterface) {
@@ -734,7 +739,7 @@ static void android_location_GpsLocationProvider_inject_xtra_data(JNIEnv* env, j
}
static void android_location_GpsLocationProvider_agps_data_conn_open(
- JNIEnv* env, jobject obj, jstring apn, jint apnIpType)
+ JNIEnv* env, jobject /* obj */, jstring apn, jint apnIpType)
{
if (!sAGpsInterface) {
ALOGE("no AGPS interface in agps_data_conn_open");
@@ -753,13 +758,14 @@ static void android_location_GpsLocationProvider_agps_data_conn_open(
} else if (interface_size == sizeof(AGpsInterface_v1)) {
sAGpsInterface->data_conn_open(apnStr);
} else {
- ALOGE("Invalid size of AGpsInterface found: %d.", interface_size);
+ ALOGE("Invalid size of AGpsInterface found: %zd.", interface_size);
}
env->ReleaseStringUTFChars(apn, apnStr);
}
-static void android_location_GpsLocationProvider_agps_data_conn_closed(JNIEnv* env, jobject obj)
+static void android_location_GpsLocationProvider_agps_data_conn_closed(JNIEnv* /* env */,
+ jobject /* obj */)
{
if (!sAGpsInterface) {
ALOGE("no AGPS interface in agps_data_conn_closed");
@@ -768,7 +774,8 @@ static void android_location_GpsLocationProvider_agps_data_conn_closed(JNIEnv* e
sAGpsInterface->data_conn_closed();
}
-static void android_location_GpsLocationProvider_agps_data_conn_failed(JNIEnv* env, jobject obj)
+static void android_location_GpsLocationProvider_agps_data_conn_failed(JNIEnv* /* env */,
+ jobject /* obj */)
{
if (!sAGpsInterface) {
ALOGE("no AGPS interface in agps_data_conn_failed");
@@ -777,7 +784,7 @@ static void android_location_GpsLocationProvider_agps_data_conn_failed(JNIEnv* e
sAGpsInterface->data_conn_failed();
}
-static void android_location_GpsLocationProvider_set_agps_server(JNIEnv* env, jobject obj,
+static void android_location_GpsLocationProvider_set_agps_server(JNIEnv* env, jobject /* obj */,
jint type, jstring hostname, jint port)
{
if (!sAGpsInterface) {
@@ -789,8 +796,8 @@ static void android_location_GpsLocationProvider_set_agps_server(JNIEnv* env, jo
env->ReleaseStringUTFChars(hostname, c_hostname);
}
-static void android_location_GpsLocationProvider_send_ni_response(JNIEnv* env, jobject obj,
- jint notifId, jint response)
+static void android_location_GpsLocationProvider_send_ni_response(JNIEnv* /* env */,
+ jobject /* obj */, jint notifId, jint response)
{
if (!sGpsNiInterface) {
ALOGE("no NI interface in send_ni_response");
@@ -800,8 +807,8 @@ static void android_location_GpsLocationProvider_send_ni_response(JNIEnv* env, j
sGpsNiInterface->respond(notifId, response);
}
-static jstring android_location_GpsLocationProvider_get_internal_state(JNIEnv* env, jobject obj)
-{
+static jstring android_location_GpsLocationProvider_get_internal_state(JNIEnv* env,
+ jobject /* obj */) {
jstring result = NULL;
if (sGpsDebugInterface) {
const size_t maxLength = 2047;
@@ -814,7 +821,7 @@ static jstring android_location_GpsLocationProvider_get_internal_state(JNIEnv* e
return result;
}
-static void android_location_GpsLocationProvider_update_network_state(JNIEnv* env, jobject obj,
+static void android_location_GpsLocationProvider_update_network_state(JNIEnv* env, jobject /* obj */,
jboolean connected, jint type, jboolean roaming, jboolean available, jstring extraInfo, jstring apn)
{
@@ -837,16 +844,17 @@ static void android_location_GpsLocationProvider_update_network_state(JNIEnv* en
}
}
-static jboolean android_location_GpsLocationProvider_is_geofence_supported(JNIEnv* env,
- jobject obj) {
+static jboolean android_location_GpsLocationProvider_is_geofence_supported(JNIEnv* /* env */,
+ jobject /* obj */)
+{
if (sGpsGeofencingInterface != NULL) {
return JNI_TRUE;
}
return JNI_FALSE;
}
-static jboolean android_location_GpsLocationProvider_add_geofence(JNIEnv* env, jobject obj,
- jint geofence_id, jdouble latitude, jdouble longitude, jdouble radius,
+static jboolean android_location_GpsLocationProvider_add_geofence(JNIEnv* /* env */,
+ jobject /* obj */, jint geofence_id, jdouble latitude, jdouble longitude, jdouble radius,
jint last_transition, jint monitor_transition, jint notification_responsiveness,
jint unknown_timer) {
if (sGpsGeofencingInterface != NULL) {
@@ -860,8 +868,8 @@ static jboolean android_location_GpsLocationProvider_add_geofence(JNIEnv* env, j
return JNI_FALSE;
}
-static jboolean android_location_GpsLocationProvider_remove_geofence(JNIEnv* env, jobject obj,
- jint geofence_id) {
+static jboolean android_location_GpsLocationProvider_remove_geofence(JNIEnv* /* env */,
+ jobject /* obj */, jint geofence_id) {
if (sGpsGeofencingInterface != NULL) {
sGpsGeofencingInterface->remove_geofence_area(geofence_id);
return JNI_TRUE;
@@ -871,8 +879,8 @@ static jboolean android_location_GpsLocationProvider_remove_geofence(JNIEnv* env
return JNI_FALSE;
}
-static jboolean android_location_GpsLocationProvider_pause_geofence(JNIEnv* env, jobject obj,
- jint geofence_id) {
+static jboolean android_location_GpsLocationProvider_pause_geofence(JNIEnv* /* env */,
+ jobject /* obj */, jint geofence_id) {
if (sGpsGeofencingInterface != NULL) {
sGpsGeofencingInterface->pause_geofence(geofence_id);
return JNI_TRUE;
@@ -882,8 +890,8 @@ static jboolean android_location_GpsLocationProvider_pause_geofence(JNIEnv* env,
return JNI_FALSE;
}
-static jboolean android_location_GpsLocationProvider_resume_geofence(JNIEnv* env, jobject obj,
- jint geofence_id, jint monitor_transition) {
+static jboolean android_location_GpsLocationProvider_resume_geofence(JNIEnv* /* env */,
+ jobject /* obj */, jint geofence_id, jint monitor_transition) {
if (sGpsGeofencingInterface != NULL) {
sGpsGeofencingInterface->resume_geofence(geofence_id, monitor_transition);
return JNI_TRUE;
@@ -1253,7 +1261,7 @@ static void measurement_callback(GpsData* data) {
env->DeleteLocalRef(gpsMeasurementsEventClass);
env->DeleteLocalRef(gpsMeasurementsEvent);
} else {
- ALOGE("Invalid GpsData size found in gps_measurement_callback, size=%d", data->size);
+ ALOGE("Invalid GpsData size found in gps_measurement_callback, size=%zd", data->size);
}
}
@@ -1304,7 +1312,7 @@ static jobject translate_gps_navigation_message(JNIEnv* env, GpsNavigationMessag
size_t dataLength = message->data_length;
uint8_t* data = message->data;
if (dataLength == 0 || data == NULL) {
- ALOGE("Invalid Navigation Message found: data=%p, length=%d", data, dataLength);
+ ALOGE("Invalid Navigation Message found: data=%p, length=%zd", data, dataLength);
return NULL;
}
@@ -1363,7 +1371,7 @@ static void navigation_message_callback(GpsNavigationMessage* message) {
env->DeleteLocalRef(navigationMessageEventClass);
env->DeleteLocalRef(navigationMessageEvent);
} else {
- ALOGE("Invalid GpsNavigationMessage size found: %d", message->size);
+ ALOGE("Invalid GpsNavigationMessage size found: %zd", message->size);
}
}
diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp b/services/core/jni/com_android_server_power_PowerManagerService.cpp
index 33e0bd7..6dcdd9d 100644
--- a/services/core/jni/com_android_server_power_PowerManagerService.cpp
+++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp
@@ -112,17 +112,17 @@ static void nativeInit(JNIEnv* env, jobject obj) {
}
}
-static void nativeAcquireSuspendBlocker(JNIEnv *env, jclass clazz, jstring nameStr) {
+static void nativeAcquireSuspendBlocker(JNIEnv *env, jclass /* clazz */, jstring nameStr) {
ScopedUtfChars name(env, nameStr);
acquire_wake_lock(PARTIAL_WAKE_LOCK, name.c_str());
}
-static void nativeReleaseSuspendBlocker(JNIEnv *env, jclass clazz, jstring nameStr) {
+static void nativeReleaseSuspendBlocker(JNIEnv *env, jclass /* clazz */, jstring nameStr) {
ScopedUtfChars name(env, nameStr);
release_wake_lock(name.c_str());
}
-static void nativeSetInteractive(JNIEnv *env, jclass clazz, jboolean enable) {
+static void nativeSetInteractive(JNIEnv* /* env */, jclass /* clazz */, jboolean enable) {
if (gPowerModule) {
if (enable) {
ALOGD_IF_SLOW(20, "Excessive delay in setInteractive(true) while turning screen on");
@@ -134,7 +134,7 @@ static void nativeSetInteractive(JNIEnv *env, jclass clazz, jboolean enable) {
}
}
-static void nativeSetAutoSuspend(JNIEnv *env, jclass clazz, jboolean enable) {
+static void nativeSetAutoSuspend(JNIEnv* /* env */, jclass /* clazz */, jboolean enable) {
if (enable) {
ALOGD_IF_SLOW(100, "Excessive delay in autosuspend_enable() while turning screen off");
autosuspend_enable();
@@ -189,6 +189,7 @@ static JNINativeMethod gPowerManagerServiceMethods[] = {
int register_android_server_PowerManagerService(JNIEnv* env) {
int res = jniRegisterNativeMethods(env, "com/android/server/power/PowerManagerService",
gPowerManagerServiceMethods, NELEM(gPowerManagerServiceMethods));
+ (void) res; // Faked use when LOG_NDEBUG.
LOG_FATAL_IF(res < 0, "Unable to register native methods.");
// Callbacks
diff --git a/services/core/jni/com_android_server_tv_TvInputHal.cpp b/services/core/jni/com_android_server_tv_TvInputHal.cpp
index dcb5199..507bc9c 100644
--- a/services/core/jni/com_android_server_tv_TvInputHal.cpp
+++ b/services/core/jni/com_android_server_tv_TvInputHal.cpp
@@ -688,6 +688,7 @@ int register_android_server_tv_TvInputHal(JNIEnv* env) {
int res = jniRegisterNativeMethods(env, "com/android/server/tv/TvInputHal",
gTvInputHalMethods, NELEM(gTvInputHalMethods));
LOG_FATAL_IF(res < 0, "Unable to register native methods.");
+ (void)res; // Don't complain about unused variable in the LOG_NDEBUG case
jclass clazz;
FIND_CLASS(clazz, "com/android/server/tv/TvInputHal");
diff --git a/services/core/jni/onload.cpp b/services/core/jni/onload.cpp
index 7b2e408..c65b3be 100644
--- a/services/core/jni/onload.cpp
+++ b/services/core/jni/onload.cpp
@@ -46,7 +46,7 @@ int register_android_server_Watchdog(JNIEnv* env);
using namespace android;
-extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved)
+extern "C" jint JNI_OnLoad(JavaVM* vm, void* /* reserved */)
{
JNIEnv* env = NULL;
jint result = -1;
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 334cdf6..7871147 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -410,6 +410,7 @@ public final class SystemServer {
ConsumerIrService consumerIr = null;
AudioService audioService = null;
MmsServiceBroker mmsService = null;
+ EntropyMixer entropyMixer = null;
boolean disableStorage = SystemProperties.getBoolean("config.disable_storage", false);
boolean disableMedia = SystemProperties.getBoolean("config.disable_media", false);
@@ -436,7 +437,7 @@ public final class SystemServer {
ServiceManager.addService("telephony.registry", telephonyRegistry);
Slog.i(TAG, "Entropy Mixer");
- ServiceManager.addService("entropy", new EntropyMixer(context));
+ entropyMixer = new EntropyMixer(context);
mContentResolver = context.getContentResolver();