diff options
| author | Kenny Root <kroot@google.com> | 2010-09-28 18:16:50 -0700 |
|---|---|---|
| committer | Kenny Root <kroot@google.com> | 2010-09-28 18:16:50 -0700 |
| commit | bff405f91001237ec94ec64f86fa2370c4509559 (patch) | |
| tree | c492bfa8bacef42800f47b1638b1812275cecb6d /services | |
| parent | e63f20b5fe373822758182226d7512859d8e8356 (diff) | |
| parent | d8e8186c887fe47977721315f439465771a96374 (diff) | |
| download | frameworks_base-bff405f91001237ec94ec64f86fa2370c4509559.zip frameworks_base-bff405f91001237ec94ec64f86fa2370c4509559.tar.gz frameworks_base-bff405f91001237ec94ec64f86fa2370c4509559.tar.bz2 | |
resolved conflicts for merge of d8e8186c to master
Change-Id: Ica3f6cd958717ea7033cab8b4bf9cd3425c1e1c5
Diffstat (limited to 'services')
| -rw-r--r-- | services/java/com/android/server/MountService.java | 61 |
1 files changed, 39 insertions, 22 deletions
diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java index 32f5e73..e6c6953 100644 --- a/services/java/com/android/server/MountService.java +++ b/services/java/com/android/server/MountService.java @@ -46,6 +46,7 @@ import android.os.storage.IObbActionListener; import android.os.storage.StorageResultCode; import android.util.Slog; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -150,7 +151,7 @@ class MountService extends IMountService.Stub * Mounted OBB tracking information. Used to track the current state of all * OBBs. */ - final private Map<IObbActionListener, ObbState> mObbMounts = new HashMap<IObbActionListener, ObbState>(); + final private Map<IObbActionListener, List<ObbState>> mObbMounts = new HashMap<IObbActionListener, List<ObbState>>(); final private Map<String, ObbState> mObbPathToStateMap = new HashMap<String, ObbState>(); class ObbState implements IBinder.DeathRecipient { @@ -162,13 +163,13 @@ class MountService extends IMountService.Stub } // OBB source filename - String filename; + final String filename; // Token of remote Binder caller - IObbActionListener token; + final IObbActionListener token; // Binder.callingUid() - public int callerUid; + final public int callerUid; // Whether this is mounted currently. boolean mounted; @@ -227,9 +228,9 @@ class MountService extends IMountService.Stub private static final int MAX_UNMOUNT_RETRIES = 4; class UnmountCallBack { - String path; + final String path; + final boolean force; int retries; - boolean force; UnmountCallBack(String path, boolean force) { retries = 0; @@ -244,7 +245,7 @@ class MountService extends IMountService.Stub } class UmsEnableCallBack extends UnmountCallBack { - String method; + final String method; UmsEnableCallBack(String path, String method, boolean force) { super(path, force); @@ -1526,10 +1527,6 @@ class MountService extends IMountService.Stub throw new IllegalArgumentException("OBB file is already mounted"); } - if (mObbMounts.containsKey(token)) { - throw new IllegalArgumentException("You may only have one OBB mounted at a time"); - } - final int callerUid = Binder.getCallingUid(); obbState = new ObbState(filename, token, callerUid); addObbState(obbState); @@ -1567,14 +1564,25 @@ class MountService extends IMountService.Stub private void addObbState(ObbState obbState) { synchronized (mObbMounts) { - mObbMounts.put(obbState.token, obbState); + List<ObbState> obbStates = mObbMounts.get(obbState.token); + if (obbStates == null) { + obbStates = new ArrayList<ObbState>(); + mObbMounts.put(obbState.token, obbStates); + } + obbStates.add(obbState); mObbPathToStateMap.put(obbState.filename, obbState); } } private void removeObbState(ObbState obbState) { synchronized (mObbMounts) { - mObbMounts.remove(obbState.token); + final List<ObbState> obbStates = mObbMounts.get(obbState.token); + if (obbStates != null) { + obbStates.remove(obbState); + } + if (obbStates == null || obbStates.isEmpty()) { + mObbMounts.remove(obbState.token); + } mObbPathToStateMap.remove(obbState.filename); } } @@ -1750,7 +1758,7 @@ class MountService extends IMountService.Stub } } - abstract void handleExecute() throws RemoteException; + abstract void handleExecute() throws RemoteException, IOException; abstract void handleError(); } @@ -1762,8 +1770,12 @@ class MountService extends IMountService.Stub mKey = key; } - public void handleExecute() throws RemoteException { + public void handleExecute() throws RemoteException, IOException { ObbInfo obbInfo = mContainerService.getObbInfo(mObbState.filename); + if (obbInfo == null) { + throw new IOException("Couldn't read OBB file"); + } + if (!isUidOwnerOfPackageOrSystem(obbInfo.packageName, mObbState.callerUid)) { throw new IllegalArgumentException("Caller package does not match OBB file"); } @@ -1786,15 +1798,17 @@ class MountService extends IMountService.Stub if (rc == StorageResultCode.OperationSucceeded) { try { - mObbState.token.onObbResult(mObbState.filename, "mounted"); + mObbState.token.onObbResult(mObbState.filename, Environment.MEDIA_MOUNTED); } catch (RemoteException e) { Slog.w(TAG, "MountServiceListener went away while calling onObbStateChanged"); } } else { - Slog.e(TAG, "Couldn't mount OBB file"); + Slog.e(TAG, "Couldn't mount OBB file: " + rc); // We didn't succeed, so remove this from the mount-set. removeObbState(mObbState); + + mObbState.token.onObbResult(mObbState.filename, Environment.MEDIA_BAD_REMOVAL); } } @@ -1802,7 +1816,7 @@ class MountService extends IMountService.Stub removeObbState(mObbState); try { - mObbState.token.onObbResult(mObbState.filename, "error"); + mObbState.token.onObbResult(mObbState.filename, Environment.MEDIA_BAD_REMOVAL); } catch (RemoteException e) { Slog.e(TAG, "Couldn't send back OBB mount error for " + mObbState.filename); } @@ -1831,8 +1845,11 @@ class MountService extends IMountService.Stub mForceUnmount = force; } - public void handleExecute() throws RemoteException { + public void handleExecute() throws RemoteException, IOException { ObbInfo obbInfo = mContainerService.getObbInfo(mObbState.filename); + if (obbInfo == null) { + throw new IOException("Couldn't read OBB file"); + } if (!isCallerOwnerOfPackageOrSystem(obbInfo.packageName)) { throw new IllegalArgumentException("Caller package does not match OBB file"); @@ -1856,13 +1873,13 @@ class MountService extends IMountService.Stub removeObbState(mObbState); try { - mObbState.token.onObbResult(mObbState.filename, "unmounted"); + mObbState.token.onObbResult(mObbState.filename, Environment.MEDIA_UNMOUNTED); } catch (RemoteException e) { Slog.w(TAG, "MountServiceListener went away while calling onObbStateChanged"); } } else { try { - mObbState.token.onObbResult(mObbState.filename, "error"); + mObbState.token.onObbResult(mObbState.filename, Environment.MEDIA_BAD_REMOVAL); } catch (RemoteException e) { Slog.w(TAG, "MountServiceListener went away while calling onObbStateChanged"); } @@ -1873,7 +1890,7 @@ class MountService extends IMountService.Stub removeObbState(mObbState); try { - mObbState.token.onObbResult(mObbState.filename, "error"); + mObbState.token.onObbResult(mObbState.filename, Environment.MEDIA_BAD_REMOVAL); } catch (RemoteException e) { Slog.e(TAG, "Couldn't send back OBB unmount error for " + mObbState.filename); } |
