diff options
Diffstat (limited to 'services/java/com/android')
3 files changed, 78 insertions, 1 deletions
diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java index 8814e48..f81c519 100644 --- a/services/java/com/android/server/MountService.java +++ b/services/java/com/android/server/MountService.java @@ -82,6 +82,8 @@ class MountService extends IMountService.Stub { private boolean mMounted; + private boolean mAutoStartUms; + /** * Constructs a new MountService instance * @@ -100,6 +102,8 @@ class MountService extends IMountService.Stub { mShowSafeUnmountNotificationWhenUnmounted = false; mPlaySounds = SystemProperties.get("persist.service.mount.playsnd", "1").equals("1"); + + mAutoStartUms = SystemProperties.get("persist.service.mount.umsauto", "0").equals("1"); } BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { @@ -198,6 +202,26 @@ class MountService extends IMountService.Stub { } /** + * Returns true if we auto-start UMS on cable insertion. + */ + public boolean getAutoStartUms() { + return mAutoStartUms; + } + + /** + * Set whether or not we're playing media notification sounds. + */ + public void setAutoStartUms(boolean enabled) { + if (mContext.checkCallingOrSelfPermission( + android.Manifest.permission.WRITE_SETTINGS) + != PackageManager.PERMISSION_GRANTED) { + throw new SecurityException("Requires WRITE_SETTINGS permission"); + } + mAutoStartUms = enabled; + SystemProperties.set("persist.service.mount.umsauto", (enabled ? "1" : "0")); + } + + /** * Update the state of the USB mass storage notification */ void updateUsbMassStorageNotification(boolean suppressIfConnected, boolean sound) { @@ -239,7 +263,14 @@ class MountService extends IMountService.Stub { !storageState.equals(Environment.MEDIA_BAD_REMOVAL) && !storageState.equals(Environment.MEDIA_CHECKING)) { - updateUsbMassStorageNotification(false, true); + if (mAutoStartUms) { + try { + setMassStorageEnabled(true); + } catch (RemoteException e) { + } + } else { + updateUsbMassStorageNotification(false, true); + } } Intent intent = new Intent(Intent.ACTION_UMS_CONNECTED); diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java index fec3608..9f428e9 100644 --- a/services/java/com/android/server/PackageManagerService.java +++ b/services/java/com/android/server/PackageManagerService.java @@ -5460,6 +5460,12 @@ class PackageManagerService extends IPackageManager.Stub { // has to delete the one installed in the data partition in order to pick up the // new system package. return p; + } else if ((p.pkg != null) && (p.pkg.applicationInfo != null) && + ((p.pkg.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0)) { + // Check for non-system apps + reportSettingsProblem(Log.WARN, + "Package " + name + " codePath changed from " + p.codePath + + " to " + codePath + "; Retaining data and using new code"); } else { reportSettingsProblem(Log.WARN, "Package " + name + " codePath changed from " + p.codePath diff --git a/services/java/com/android/server/TelephonyRegistry.java b/services/java/com/android/server/TelephonyRegistry.java index 5e5fb93..a74915c 100644 --- a/services/java/com/android/server/TelephonyRegistry.java +++ b/services/java/com/android/server/TelephonyRegistry.java @@ -28,6 +28,7 @@ import android.telephony.PhoneStateListener; import android.telephony.ServiceState; import android.telephony.TelephonyManager; import android.text.TextUtils; +import android.util.Log; import java.util.ArrayList; import java.io.FileDescriptor; @@ -187,6 +188,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } public void notifyCallState(int state, String incomingNumber) { + if (!checkPhoneStatePermission("notifyCallState()")) { + return; + } synchronized (mRecords) { mCallState = state; mCallIncomingNumber = incomingNumber; @@ -206,6 +210,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } public void notifyServiceState(ServiceState state) { + if (!checkPhoneStatePermission("notifyServiceState()")) { + return; + } synchronized (mRecords) { mServiceState = state; final int N = mRecords.size(); @@ -220,6 +227,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } public void notifySignalStrength(int signalStrengthASU) { + if (!checkPhoneStatePermission("notifySignalStrength()")) { + return; + } synchronized (mRecords) { mSignalStrength = signalStrengthASU; final int N = mRecords.size(); @@ -238,6 +248,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } public void notifyMessageWaitingChanged(boolean mwi) { + if (!checkPhoneStatePermission("notifyMessageWaitingChanged()")) { + return; + } synchronized (mRecords) { mMessageWaiting = mwi; final int N = mRecords.size(); @@ -255,6 +268,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } public void notifyCallForwardingChanged(boolean cfi) { + if (!checkPhoneStatePermission("notifyCallForwardingChanged()")) { + return; + } synchronized (mRecords) { mCallForwarding = cfi; final int N = mRecords.size(); @@ -272,6 +288,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } public void notifyDataActivity(int state) { + if (!checkPhoneStatePermission("notifyDataActivity()")) { + return; + } synchronized (mRecords) { mDataActivity = state; final int N = mRecords.size(); @@ -290,6 +309,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { public void notifyDataConnection(int state, boolean isDataConnectivityPissible, String reason, String apn, String interfaceName) { + if (!checkPhoneStatePermission("notifyDataConnection()")) { + return; + } synchronized (mRecords) { mDataConnectionState = state; mDataConnectionPossible = isDataConnectivityPissible; @@ -313,6 +335,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } public void notifyDataConnectionFailed(String reason) { + if (!checkPhoneStatePermission("notifyDataConnectionFailed()")) { + return; + } /* * This is commented out because there is on onDataConnectionFailed callback * on PhoneStateListener. There should be. @@ -331,6 +356,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } public void notifyCellLocation(Bundle cellLocation) { + if (!checkPhoneStatePermission("notifyCellLocation()")) { + return; + } synchronized (mRecords) { mCellLocation = cellLocation; final int N = mRecords.size(); @@ -459,4 +487,16 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { intent.putExtra(Phone.FAILURE_REASON_KEY, reason); mContext.sendStickyBroadcast(intent); } + + private boolean checkPhoneStatePermission(String method) { + if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE) + == PackageManager.PERMISSION_GRANTED) { + return true; + } + String msg = "Modify Phone State Permission Denial: " + method + " from pid=" + + Binder.getCallingPid() + + ", uid=" + Binder.getCallingUid(); + Log.w(TAG, msg); + return false; + } } |