am 2c8fa5ee: am 2f9c5fd4: Merge "Add standard options to readlink" into klp-dev
* commit '2c8fa5eecf407107f951ba6aa9f618a794ef0a33':
Add standard options to readlink
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index 688c7ff..a2da3ee 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -28,6 +28,7 @@
#include <unistd.h>
#include <batteryservice/BatteryService.h>
#include <cutils/klog.h>
+#include <utils/Errors.h>
#include <utils/String8.h>
#include <utils/Vector.h>
@@ -272,6 +273,40 @@
props.chargerWirelessOnline;
}
+status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) {
+ status_t ret = BAD_VALUE;
+
+ switch(id) {
+ case BATTERY_PROP_CHARGE_COUNTER:
+ if (!mHealthdConfig->batteryChargeCounterPath.isEmpty()) {
+ val->valueInt =
+ getIntField(mHealthdConfig->batteryChargeCounterPath);
+ ret = NO_ERROR;
+ } else {
+ ret = NAME_NOT_FOUND;
+ }
+ break;
+
+ case BATTERY_PROP_CURRENT_NOW:
+ if (!mHealthdConfig->batteryCurrentNowPath.isEmpty()) {
+ val->valueInt =
+ getIntField(mHealthdConfig->batteryCurrentNowPath);
+ ret = NO_ERROR;
+ } else {
+ ret = NAME_NOT_FOUND;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if (ret != NO_ERROR)
+ val->valueInt = INT_MIN;
+
+ return ret;
+}
+
void BatteryMonitor::init(struct healthd_config *hc, bool nosvcmgr) {
String8 path;
diff --git a/healthd/BatteryMonitor.h b/healthd/BatteryMonitor.h
index ba291af..34b423d 100644
--- a/healthd/BatteryMonitor.h
+++ b/healthd/BatteryMonitor.h
@@ -17,6 +17,7 @@
#ifndef HEALTHD_BATTERYMONITOR_H
#define HEALTHD_BATTERYMONITOR_H
+#include <batteryservice/BatteryService.h>
#include <binder/IInterface.h>
#include <utils/String8.h>
#include <utils/Vector.h>
@@ -41,6 +42,7 @@
void init(struct healthd_config *hc, bool nosvcmgr);
bool update(void);
+ status_t getProperty(int id, struct BatteryProperty *val);
private:
struct healthd_config *mHealthdConfig;
diff --git a/healthd/BatteryPropertiesRegistrar.cpp b/healthd/BatteryPropertiesRegistrar.cpp
index 6a33ad8..3e06866 100644
--- a/healthd/BatteryPropertiesRegistrar.cpp
+++ b/healthd/BatteryPropertiesRegistrar.cpp
@@ -67,6 +67,10 @@
}
}
+status_t BatteryPropertiesRegistrar::getProperty(int id, struct BatteryProperty *val) {
+ return mBatteryMonitor->getProperty(id, val);
+}
+
void BatteryPropertiesRegistrar::binderDied(const wp<IBinder>& who) {
Mutex::Autolock _l(mRegistrationLock);
diff --git a/healthd/BatteryPropertiesRegistrar.h b/healthd/BatteryPropertiesRegistrar.h
index 793ddad..0ce6c04 100644
--- a/healthd/BatteryPropertiesRegistrar.h
+++ b/healthd/BatteryPropertiesRegistrar.h
@@ -44,6 +44,7 @@
void registerListener(const sp<IBatteryPropertiesListener>& listener);
void unregisterListener(const sp<IBatteryPropertiesListener>& listener);
+ status_t getProperty(int id, struct BatteryProperty *val);
void binderDied(const wp<IBinder>& who);
};
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 882f28f..33dd40e 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -442,6 +442,7 @@
onrestart restart zygote
onrestart restart media
onrestart restart surfaceflinger
+ onrestart restart inputflinger
onrestart restart drm
service vold /system/bin/vold
@@ -471,6 +472,12 @@
group graphics drmrpc
onrestart restart zygote
+service inputflinger /system/bin/inputflinger
+ class main
+ user system
+ group input
+ onrestart restart zygote
+
service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
class main
socket zygote stream 660 root system
diff --git a/run-as/run-as.c b/run-as/run-as.c
index 3c0ecc4..cc05e63 100644
--- a/run-as/run-as.c
+++ b/run-as/run-as.c
@@ -36,9 +36,9 @@
/*
* WARNING WARNING WARNING WARNING
*
- * This program runs as set-uid root on Android production devices.
- * Be very conservative when modifying it to avoid any serious
- * security issue. Keep in mind the following:
+ * This program runs with CAP_SETUID and CAP_SETGID capabilities on Android
+ * production devices. Be very conservative when modifying it to avoid any
+ * serious security issue. Keep in mind the following:
*
* - This program should only run for the 'root' or 'shell' users
*
@@ -61,14 +61,19 @@
*
* run-as <package-name> <command> <args>
*
- * The 'run-as' binary is setuid, but will check the following:
+ * The 'run-as' binary is installed with CAP_SETUID and CAP_SETGID file
+ * capabilities, but will check the following:
*
* - that it is invoked from the 'shell' or 'root' user (abort otherwise)
* - that '<package-name>' is the name of an installed and debuggable package
* - that the package's data directory is well-formed (see package.c)
*
- * If so, it will cd to the package's data directory, drop to the application's
- * user id / group id then run the command there.
+ * If so, it will drop to the application's user id / group id, cd to the
+ * package's data directory, then run the command there.
+ *
+ * NOTE: In the future it might not be possible to cd to the package's data
+ * directory under that package's user id / group id, in which case this
+ * utility will need to be changed accordingly.
*
* This can be useful for a number of different things on production devices:
*
@@ -141,19 +146,6 @@
return 1;
}
- /* then move to it */
- {
- int ret;
- do {
- ret = chdir(info.dataDir);
- } while (ret < 0 && errno == EINTR);
-
- if (ret < 0) {
- panic("Could not cd to package's data directory: %s\n", strerror(errno));
- return 1;
- }
- }
-
/* Ensure that we change all real/effective/saved IDs at the
* same time to avoid nasty surprises.
*/
@@ -168,6 +160,19 @@
return 1;
}
+ /* cd into the data directory */
+ {
+ int ret;
+ do {
+ ret = chdir(info.dataDir);
+ } while (ret < 0 && errno == EINTR);
+
+ if (ret < 0) {
+ panic("Could not cd to package's data directory: %s\n", strerror(errno));
+ return 1;
+ }
+ }
+
/* User specified command for exec. */
if (argc >= 3 ) {
if (execvp(argv[2], argv+2) < 0) {