diff options
Diffstat (limited to 'services/java/com/android')
16 files changed, 293 insertions, 183 deletions
diff --git a/services/java/com/android/server/DevicePolicyManagerService.java b/services/java/com/android/server/DevicePolicyManagerService.java index d8e3d59..eb33060 100644 --- a/services/java/com/android/server/DevicePolicyManagerService.java +++ b/services/java/com/android/server/DevicePolicyManagerService.java @@ -451,7 +451,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { public DevicePolicyManagerService(Context context) { mContext = context; mMonitor = new MyPackageMonitor(); - mMonitor.register(context, true); + mMonitor.register(context, null, true); mWakeLock = ((PowerManager)context.getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "DPM"); IntentFilter filter = new IntentFilter(); diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java index a474cec..43c2292 100644 --- a/services/java/com/android/server/InputMethodManagerService.java +++ b/services/java/com/android/server/InputMethodManagerService.java @@ -594,7 +594,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } mImListManager = new InputMethodAndSubtypeListManager(context, this); - (new MyPackageMonitor()).register(mContext, true); + (new MyPackageMonitor()).register(mContext, null, true); IntentFilter screenOnOffFilt = new IntentFilter(); screenOnOffFilt.addAction(Intent.ACTION_SCREEN_ON); diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java index 8cb9d99b..d651111 100644 --- a/services/java/com/android/server/LocationManagerService.java +++ b/services/java/com/android/server/LocationManagerService.java @@ -511,7 +511,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run com.android.internal.R.string.config_networkLocationProvider); mGeocodeProviderPackageName = resources.getString( com.android.internal.R.string.config_geocodeProvider); - mPackageMonitor.register(context, true); + mPackageMonitor.register(context, null, true); if (LOCAL_LOGV) { Slog.v(TAG, "Constructed LocationManager Service"); diff --git a/services/java/com/android/server/RecognitionManagerService.java b/services/java/com/android/server/RecognitionManagerService.java index 85224d8..3567cfc 100644 --- a/services/java/com/android/server/RecognitionManagerService.java +++ b/services/java/com/android/server/RecognitionManagerService.java @@ -65,7 +65,7 @@ public class RecognitionManagerService extends Binder { RecognitionManagerService(Context context) { mContext = context; mMonitor = new MyPackageMonitor(); - mMonitor.register(context, true); + mMonitor.register(context, null, true); } public void systemReady() { diff --git a/services/java/com/android/server/TextServicesManagerService.java b/services/java/com/android/server/TextServicesManagerService.java index 106bb3e..499ff7a 100644 --- a/services/java/com/android/server/TextServicesManagerService.java +++ b/services/java/com/android/server/TextServicesManagerService.java @@ -77,7 +77,7 @@ public class TextServicesManagerService extends ITextServicesManager.Stub { mSystemReady = false; mContext = context; mMonitor = new TextServicesMonitor(); - mMonitor.register(context, true); + mMonitor.register(context, null, true); synchronized (mSpellCheckerMap) { buildSpellCheckerMapLocked(context, mSpellCheckerList, mSpellCheckerMap); } diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java index 6d83f30..d97d335 100644 --- a/services/java/com/android/server/WallpaperManagerService.java +++ b/services/java/com/android/server/WallpaperManagerService.java @@ -295,7 +295,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub { || !wallpaper.wallpaperComponent.getPackageName().equals(packageName)) { continue; } - doPackagesChanged(true, wallpaper); + doPackagesChangedLocked(true, wallpaper); } } } @@ -315,66 +315,68 @@ class WallpaperManagerService extends IWallpaperManager.Stub { @Override public boolean onHandleForceStop(Intent intent, String[] packages, int uid, boolean doit) { - boolean changed = false; - for (int i = 0; i < mWallpaperMap.size(); i++) { - WallpaperData wallpaper = mWallpaperMap.valueAt(i); - boolean res = doPackagesChanged(doit, wallpaper); - changed |= res; + synchronized (mLock) { + boolean changed = false; + for (int i = 0; i < mWallpaperMap.size(); i++) { + WallpaperData wallpaper = mWallpaperMap.valueAt(i); + boolean res = doPackagesChangedLocked(doit, wallpaper); + changed |= res; + } + return changed; } - return changed; } @Override public void onSomePackagesChanged() { - for (int i = 0; i < mWallpaperMap.size(); i++) { - WallpaperData wallpaper = mWallpaperMap.valueAt(i); - doPackagesChanged(true, wallpaper); + synchronized (mLock) { + for (int i = 0; i < mWallpaperMap.size(); i++) { + WallpaperData wallpaper = mWallpaperMap.valueAt(i); + doPackagesChangedLocked(true, wallpaper); + } } } - boolean doPackagesChanged(boolean doit, WallpaperData wallpaper) { + boolean doPackagesChangedLocked(boolean doit, WallpaperData wallpaper) { boolean changed = false; - synchronized (mLock) { - if (wallpaper.wallpaperComponent != null) { - int change = isPackageDisappearing(wallpaper.wallpaperComponent - .getPackageName()); - if (change == PACKAGE_PERMANENT_CHANGE - || change == PACKAGE_TEMPORARY_CHANGE) { - changed = true; - if (doit) { - Slog.w(TAG, "Wallpaper uninstalled, removing: " - + wallpaper.wallpaperComponent); - clearWallpaperLocked(false, wallpaper.userId); - } - } - } - if (wallpaper.nextWallpaperComponent != null) { - int change = isPackageDisappearing(wallpaper.nextWallpaperComponent - .getPackageName()); - if (change == PACKAGE_PERMANENT_CHANGE - || change == PACKAGE_TEMPORARY_CHANGE) { - wallpaper.nextWallpaperComponent = null; - } - } - if (wallpaper.wallpaperComponent != null - && isPackageModified(wallpaper.wallpaperComponent.getPackageName())) { - try { - mContext.getPackageManager().getServiceInfo( - wallpaper.wallpaperComponent, 0); - } catch (NameNotFoundException e) { - Slog.w(TAG, "Wallpaper component gone, removing: " + if (wallpaper.wallpaperComponent != null) { + int change = isPackageDisappearing(wallpaper.wallpaperComponent + .getPackageName()); + if (change == PACKAGE_PERMANENT_CHANGE + || change == PACKAGE_TEMPORARY_CHANGE) { + changed = true; + if (doit) { + Slog.w(TAG, "Wallpaper uninstalled, removing: " + wallpaper.wallpaperComponent); clearWallpaperLocked(false, wallpaper.userId); } } - if (wallpaper.nextWallpaperComponent != null - && isPackageModified(wallpaper.nextWallpaperComponent.getPackageName())) { - try { - mContext.getPackageManager().getServiceInfo( - wallpaper.nextWallpaperComponent, 0); - } catch (NameNotFoundException e) { - wallpaper.nextWallpaperComponent = null; - } + } + if (wallpaper.nextWallpaperComponent != null) { + int change = isPackageDisappearing(wallpaper.nextWallpaperComponent + .getPackageName()); + if (change == PACKAGE_PERMANENT_CHANGE + || change == PACKAGE_TEMPORARY_CHANGE) { + wallpaper.nextWallpaperComponent = null; + } + } + if (wallpaper.wallpaperComponent != null + && isPackageModified(wallpaper.wallpaperComponent.getPackageName())) { + try { + mContext.getPackageManager().getServiceInfo( + wallpaper.wallpaperComponent, 0); + } catch (NameNotFoundException e) { + Slog.w(TAG, "Wallpaper component gone, removing: " + + wallpaper.wallpaperComponent); + clearWallpaperLocked(false, wallpaper.userId); + } + } + if (wallpaper.nextWallpaperComponent != null + && isPackageModified(wallpaper.nextWallpaperComponent.getPackageName())) { + try { + mContext.getPackageManager().getServiceInfo( + wallpaper.nextWallpaperComponent, 0); + } catch (NameNotFoundException e) { + wallpaper.nextWallpaperComponent = null; } } return changed; @@ -387,7 +389,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub { mIWindowManager = IWindowManager.Stub.asInterface( ServiceManager.getService(Context.WINDOW_SERVICE)); mMonitor = new MyPackageMonitor(); - mMonitor.register(context, true); + mMonitor.register(context, null, true); WALLPAPER_BASE_DIR.mkdirs(); loadSettingsLocked(0); } diff --git a/services/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/java/com/android/server/accessibility/AccessibilityManagerService.java index 7361062..e980ccc 100644 --- a/services/java/com/android/server/accessibility/AccessibilityManagerService.java +++ b/services/java/com/android/server/accessibility/AccessibilityManagerService.java @@ -41,6 +41,7 @@ import android.hardware.input.InputManager; import android.net.Uri; import android.os.Binder; import android.os.Build; +import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Looper; @@ -282,11 +283,11 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub }; // package changes - monitor.register(context, true); + monitor.register(context, null, true); // boot completed IntentFilter bootFiler = new IntentFilter(Intent.ACTION_BOOT_COMPLETED); - mContext.registerReceiver(monitor, bootFiler); + mContext.registerReceiver(monitor, bootFiler, null, monitor.getRegisteredHandler()); } /** @@ -1007,10 +1008,12 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub synchronized (mGestureLock) { Thread worker = new Thread(this, THREAD_NAME); worker.start(); - try { - mGestureLock.wait(); - } catch (InterruptedException ie) { - /* ignore */ + while (mHandlerCaller == null) { + try { + mGestureLock.wait(); + } catch (InterruptedException ie) { + /* ignore */ + } } } } @@ -1044,7 +1047,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub IAccessibilityServiceClient service = (IAccessibilityServiceClient) message.obj; final int gestureId = message.arg1; - final int interactionId = message.arg1; + final int interactionId = message.arg2; try { service.onGesture(gestureId, this, interactionId); @@ -1545,7 +1548,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub @Override public boolean performAccessibilityAction(int accessibilityWindowId, - long accessibilityNodeId, int action, int interactionId, + long accessibilityNodeId, int action, Bundle arguments, int interactionId, IAccessibilityInteractionConnectionCallback callback, long interrogatingTid) { final int resolvedWindowId = resolveAccessibilityWindowId(accessibilityWindowId); IAccessibilityInteractionConnection connection = null; @@ -1566,8 +1569,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub final int flags = (mIncludeNotImportantViews) ? AccessibilityNodeInfo.INCLUDE_NOT_IMPORTANT_VIEWS : 0; final int interrogatingPid = Binder.getCallingPid(); - connection.performAccessibilityAction(accessibilityNodeId, action, interactionId, - callback, flags, interrogatingPid, interrogatingTid); + connection.performAccessibilityAction(accessibilityNodeId, action, arguments, + interactionId, callback, flags, interrogatingPid, interrogatingTid); } catch (RemoteException re) { if (DEBUG) { Slog.e(LOG_TAG, "Error calling performAccessibilityAction()"); @@ -1696,7 +1699,9 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub | AccessibilityNodeInfo.ACTION_SELECT | AccessibilityNodeInfo.ACTION_CLEAR_SELECTION | AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS - | AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS; + | AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS + | AccessibilityNodeInfo.ACTION_NEXT_AT_GRANULARITY + | AccessibilityNodeInfo.ACTION_PREVIOUS_AT_GRANULARITY; private static final int RETRIEVAL_ALLOWING_EVENT_TYPES = AccessibilityEvent.TYPE_VIEW_CLICKED diff --git a/services/java/com/android/server/am/UsageStatsService.java b/services/java/com/android/server/am/UsageStatsService.java index e810e3c..ba65f39 100644 --- a/services/java/com/android/server/am/UsageStatsService.java +++ b/services/java/com/android/server/am/UsageStatsService.java @@ -656,7 +656,7 @@ public final class UsageStatsService extends IUsageStats.Stub { } } }; - mPackageMonitor.register(mContext, true); + mPackageMonitor.register(mContext, null, true); filterHistoryStats(); } diff --git a/services/java/com/android/server/net/NetworkPolicyManagerService.java b/services/java/com/android/server/net/NetworkPolicyManagerService.java index 1e17067..52d5019 100644 --- a/services/java/com/android/server/net/NetworkPolicyManagerService.java +++ b/services/java/com/android/server/net/NetworkPolicyManagerService.java @@ -30,6 +30,8 @@ import static android.net.ConnectivityManager.TYPE_ETHERNET; import static android.net.ConnectivityManager.TYPE_MOBILE; import static android.net.ConnectivityManager.TYPE_WIFI; import static android.net.ConnectivityManager.TYPE_WIMAX; +import static android.net.ConnectivityManager.isNetworkTypeMobile; +import static android.net.NetworkPolicy.CYCLE_NONE; import static android.net.NetworkPolicy.LIMIT_DISABLED; import static android.net.NetworkPolicy.SNOOZE_NEVER; import static android.net.NetworkPolicy.WARNING_DISABLED; @@ -48,6 +50,14 @@ import static android.net.NetworkTemplate.MATCH_MOBILE_ALL; import static android.net.NetworkTemplate.MATCH_WIFI; import static android.net.NetworkTemplate.buildTemplateMobileAll; import static android.net.TrafficStats.MB_IN_BYTES; +import static android.net.wifi.WifiInfo.removeDoubleQuotes; +import static android.net.wifi.WifiManager.CHANGE_REASON_ADDED; +import static android.net.wifi.WifiManager.CHANGE_REASON_REMOVED; +import static android.net.wifi.WifiManager.CONFIGURED_NETWORKS_CHANGED_ACTION; +import static android.net.wifi.WifiManager.EXTRA_CHANGE_REASON; +import static android.net.wifi.WifiManager.EXTRA_NETWORK_INFO; +import static android.net.wifi.WifiManager.EXTRA_WIFI_CONFIGURATION; +import static android.net.wifi.WifiManager.EXTRA_WIFI_INFO; import static android.telephony.TelephonyManager.SIM_STATE_READY; import static android.text.format.DateUtils.DAY_IN_MILLIS; import static com.android.internal.util.ArrayUtils.appendInt; @@ -84,10 +94,14 @@ import android.net.INetworkPolicyListener; import android.net.INetworkPolicyManager; import android.net.INetworkStatsService; import android.net.NetworkIdentity; +import android.net.NetworkInfo; import android.net.NetworkPolicy; import android.net.NetworkQuotaInfo; import android.net.NetworkState; import android.net.NetworkTemplate; +import android.net.wifi.WifiConfiguration; +import android.net.wifi.WifiInfo; +import android.net.wifi.WifiManager; import android.os.Binder; import android.os.Environment; import android.os.Handler; @@ -355,6 +369,17 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { mContext.registerReceiver(mSnoozeWarningReceiver, snoozeWarningFilter, MANAGE_NETWORK_POLICY, mHandler); + // listen for configured wifi networks to be removed + final IntentFilter wifiConfigFilter = new IntentFilter(CONFIGURED_NETWORKS_CHANGED_ACTION); + mContext.registerReceiver( + mWifiConfigReceiver, wifiConfigFilter, CONNECTIVITY_INTERNAL, mHandler); + + // listen for wifi state changes to catch metered hint + final IntentFilter wifiStateFilter = new IntentFilter( + WifiManager.NETWORK_STATE_CHANGED_ACTION); + mContext.registerReceiver( + mWifiStateReceiver, wifiStateFilter, CONNECTIVITY_INTERNAL, mHandler); + } private IProcessObserver mProcessObserver = new IProcessObserver.Stub() { @@ -463,6 +488,73 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { }; /** + * Receiver that watches for {@link WifiConfiguration} to be changed. + */ + private BroadcastReceiver mWifiConfigReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + // on background handler thread, and verified CONNECTIVITY_INTERNAL + // permission above. + + final int reason = intent.getIntExtra(EXTRA_CHANGE_REASON, CHANGE_REASON_ADDED); + if (reason == CHANGE_REASON_REMOVED) { + final WifiConfiguration config = intent.getParcelableExtra( + EXTRA_WIFI_CONFIGURATION); + final NetworkTemplate template = NetworkTemplate.buildTemplateWifi( + removeDoubleQuotes(config.SSID)); + synchronized (mRulesLock) { + if (mNetworkPolicy.containsKey(template)) { + mNetworkPolicy.remove(template); + writePolicyLocked(); + } + } + } + } + }; + + /** + * Receiver that watches {@link WifiInfo} state changes to infer metered + * state. Ignores hints when policy is user-defined. + */ + private BroadcastReceiver mWifiStateReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + // on background handler thread, and verified CONNECTIVITY_INTERNAL + // permission above. + + // ignore when not connected + final NetworkInfo netInfo = intent.getParcelableExtra(EXTRA_NETWORK_INFO); + if (!netInfo.isConnected()) return; + + final WifiInfo info = intent.getParcelableExtra(EXTRA_WIFI_INFO); + final boolean meteredHint = info.getMeteredHint(); + + final NetworkTemplate template = NetworkTemplate.buildTemplateWifi( + removeDoubleQuotes(info.getSSID())); + synchronized (mRulesLock) { + NetworkPolicy policy = mNetworkPolicy.get(template); + if (policy == null && meteredHint) { + // policy doesn't exist, and AP is hinting that it's + // metered: create an inferred policy. + policy = new NetworkPolicy(template, CYCLE_NONE, Time.TIMEZONE_UTC, + WARNING_DISABLED, LIMIT_DISABLED, SNOOZE_NEVER, SNOOZE_NEVER, + meteredHint, true); + addNetworkPolicyLocked(policy); + + } else if (policy != null && policy.inferred) { + // policy exists, and was inferred: update its current + // metered state. + policy.metered = meteredHint; + + // since this is inferred for each wifi session, just update + // rules without persisting. + updateNetworkRulesLocked(); + } + } + } + }; + + /** * Observer that watches for {@link INetworkManagementService} alerts. */ private INetworkManagementEventObserver mAlertObserver = new NetworkAlertObserver() { @@ -974,9 +1066,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { final String cycleTimezone = time.timezone; final NetworkTemplate template = buildTemplateMobileAll(subscriberId); - mNetworkPolicy.put(template, new NetworkPolicy(template, cycleDay, cycleTimezone, - warningBytes, LIMIT_DISABLED, SNOOZE_NEVER, SNOOZE_NEVER, true, true)); - writePolicyLocked(); + final NetworkPolicy policy = new NetworkPolicy(template, cycleDay, cycleTimezone, + warningBytes, LIMIT_DISABLED, SNOOZE_NEVER, SNOOZE_NEVER, true, true); + addNetworkPolicyLocked(policy); } } @@ -1269,6 +1361,15 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } } + private void addNetworkPolicyLocked(NetworkPolicy policy) { + mNetworkPolicy.put(policy.template, policy); + + updateNetworkEnabledLocked(); + updateNetworkRulesLocked(); + updateNotificationsLocked(); + writePolicyLocked(); + } + @Override public NetworkPolicy[] getNetworkPolicies() { mContext.enforceCallingOrSelfPermission(MANAGE_NETWORK_POLICY, TAG); @@ -1402,6 +1503,10 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { if (policy != null) { return policy.metered; } else { + final int type = state.networkInfo.getType(); + if (isNetworkTypeMobile(type) || type == TYPE_WIMAX) { + return true; + } return false; } } diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java index b97d7fd..6891b76 100644 --- a/services/java/com/android/server/pm/PackageManagerService.java +++ b/services/java/com/android/server/pm/PackageManagerService.java @@ -6067,10 +6067,23 @@ public class PackageManagerService extends IPackageManager.Stub { Intent.FLAG_GRANT_READ_URI_PERMISSION); ret = imcs.copyResource(packageURI, out); } finally { - try { if (out != null) out.close(); } catch (IOException e) {} + IoUtils.closeQuietly(out); mContext.revokeUriPermission(packageURI, Intent.FLAG_GRANT_READ_URI_PERMISSION); } + if (isFwdLocked()) { + final File destResourceFile = new File(getResourcePath()); + + // Copy the public files + try { + PackageHelper.extractPublicFiles(codeFileName, destResourceFile); + } catch (IOException e) { + Slog.e(TAG, "Couldn't create a new zip file for the public parts of a" + + " forward-locked app."); + destResourceFile.delete(); + return PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE; + } + } return ret; } @@ -6086,21 +6099,29 @@ public class PackageManagerService extends IPackageManager.Stub { cleanUp(); return false; } else { - // Rename based on packageName - File codeFile = new File(getCodePath()); - String apkName = getNextCodePath(oldCodePath, pkgName, ".apk"); - File desFile = new File(installDir, apkName + ".apk"); - if (!codeFile.renameTo(desFile)) { + final File oldCodeFile = new File(getCodePath()); + final File oldResourceFile = new File(getResourcePath()); + + // Rename APK file based on packageName + final String apkName = getNextCodePath(oldCodePath, pkgName, ".apk"); + final File newCodeFile = new File(installDir, apkName + ".apk"); + if (!oldCodeFile.renameTo(newCodeFile)) { + return false; + } + codeFileName = newCodeFile.getPath(); + + // Rename public resource file if it's forward-locked. + final File newResFile = new File(getResourcePathFromCodePath()); + if (isFwdLocked() && !oldResourceFile.renameTo(newResFile)) { return false; } - // Reset paths since the file has been renamed. - codeFileName = desFile.getPath(); resourceFileName = getResourcePathFromCodePath(); - // Set permissions + + // Attempt to set permissions if (!setPermissions()) { - // Failed setting permissions. return false; } + return true; } } @@ -6116,11 +6137,26 @@ public class PackageManagerService extends IPackageManager.Stub { return resourceFileName; } - String getResourcePathFromCodePath() { - String codePath = getCodePath(); - if ((flags & PackageManager.INSTALL_FORWARD_LOCK) != 0) { - String apkNameOnly = getApkName(codePath); - return mAppInstallDir.getPath() + "/" + apkNameOnly + ".zip"; + private String getResourcePathFromCodePath() { + final String codePath = getCodePath(); + if (isFwdLocked()) { + final StringBuilder sb = new StringBuilder(); + + sb.append(mAppInstallDir.getPath()); + sb.append('/'); + sb.append(getApkName(codePath)); + sb.append(".zip"); + + /* + * If our APK is a temporary file, mark the resource as a + * temporary file as well so it can be cleaned up after + * catastrophic failure. + */ + if (codePath.endsWith(".tmp")) { + sb.append(".tmp"); + } + + return sb.toString(); } else { return codePath; } @@ -6941,15 +6977,6 @@ public class PackageManagerService extends IPackageManager.Stub { // TODO Gross hack but fix later. Ideally move this to be a post installation // check after alloting uid. if (isForwardLocked(newPackage)) { - File destResourceFile = new File(newPackage.applicationInfo.publicSourceDir); - try { - extractPublicFiles(newPackage, destResourceFile); - } catch (IOException e) { - Slog.e(TAG, "Couldn't create a new zip file for the public parts of a" + - " forward-locked app."); - destResourceFile.delete(); - return PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE; - } retCode = mInstaller.setForwardLockPerm(getApkName(newPackage.mPath), newPackage.applicationInfo.uid); } else { @@ -6986,67 +7013,6 @@ public class PackageManagerService extends IPackageManager.Stub { return (pkg.applicationInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0; } - private void extractPublicFiles(PackageParser.Package newPackage, - File publicZipFile) throws IOException { - final FileOutputStream fstr = new FileOutputStream(publicZipFile); - final ZipOutputStream publicZipOutStream = new ZipOutputStream(fstr); - try { - final ZipFile privateZip = new ZipFile(newPackage.mPath); - try { - // Copy manifest, resources.arsc and res directory to public zip - - final Enumeration<? extends ZipEntry> privateZipEntries = privateZip.entries(); - while (privateZipEntries.hasMoreElements()) { - final ZipEntry zipEntry = privateZipEntries.nextElement(); - final String zipEntryName = zipEntry.getName(); - if ("AndroidManifest.xml".equals(zipEntryName) - || "resources.arsc".equals(zipEntryName) - || zipEntryName.startsWith("res/")) { - copyZipEntry(zipEntry, privateZip, publicZipOutStream); - } - } - } finally { - try { privateZip.close(); } catch (IOException e) { } - } - - publicZipOutStream.finish(); - publicZipOutStream.flush(); - FileUtils.sync(fstr); - publicZipOutStream.close(); - FileUtils.setPermissions(publicZipFile.getAbsolutePath(), FileUtils.S_IRUSR - | FileUtils.S_IWUSR | FileUtils.S_IRGRP | FileUtils.S_IROTH, -1, -1); - } finally { - IoUtils.closeQuietly(publicZipOutStream); - } - } - - private static void copyZipEntry(ZipEntry zipEntry, - ZipFile inZipFile, - ZipOutputStream outZipStream) throws IOException { - byte[] buffer = new byte[4096]; - int num; - - ZipEntry newEntry; - if (zipEntry.getMethod() == ZipEntry.STORED) { - // Preserve the STORED method of the input entry. - newEntry = new ZipEntry(zipEntry); - } else { - // Create a new entry so that the compressed len is recomputed. - newEntry = new ZipEntry(zipEntry.getName()); - } - outZipStream.putNextEntry(newEntry); - - final InputStream data = inZipFile.getInputStream(zipEntry); - try { - while ((num = data.read(buffer)) > 0) { - outZipStream.write(buffer, 0, num); - } - outZipStream.flush(); - } finally { - IoUtils.closeQuietly(data); - } - } - private void deleteTempPackageFiles() { FilenameFilter filter = new FilenameFilter() { public boolean accept(File dir, String name) { diff --git a/services/java/com/android/server/pm/Settings.java b/services/java/com/android/server/pm/Settings.java index 35b6bde..d015278 100644 --- a/services/java/com/android/server/pm/Settings.java +++ b/services/java/com/android/server/pm/Settings.java @@ -2300,12 +2300,15 @@ final class Settings { } private List<UserInfo> getAllUsers() { + long id = Binder.clearCallingIdentity(); try { return AppGlobals.getPackageManager().getUsers(); } catch (RemoteException re) { // Local to system process, shouldn't happen } catch (NullPointerException npe) { // packagemanager not yet initialized + } finally { + Binder.restoreCallingIdentity(id); } return null; } @@ -2347,6 +2350,7 @@ final class Settings { final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); final Date date = new Date(); boolean printedSomething = false; + List<UserInfo> users = getAllUsers(); for (final PackageSetting ps : mPackages.values()) { if (packageName != null && !packageName.equals(ps.realName) && !packageName.equals(ps.name)) { @@ -2447,7 +2451,6 @@ final class Settings { pw.print(" haveGids="); pw.println(ps.haveGids); pw.print(" pkgFlags=0x"); pw.print(Integer.toHexString(ps.pkgFlags)); pw.print(" installStatus="); pw.print(ps.installStatus); - List<UserInfo> users = getAllUsers(); for (UserInfo user : users) { pw.print(" User "); pw.print(user.id); pw.print(": "); pw.print(" stopped="); diff --git a/services/java/com/android/server/usb/UsbSettingsManager.java b/services/java/com/android/server/usb/UsbSettingsManager.java index 0baafbb..7dde340 100644 --- a/services/java/com/android/server/usb/UsbSettingsManager.java +++ b/services/java/com/android/server/usb/UsbSettingsManager.java @@ -370,7 +370,7 @@ class UsbSettingsManager { synchronized (mLock) { readSettingsLocked(); } - mPackageMonitor.register(context, true); + mPackageMonitor.register(context, null, true); } private void readPreference(XmlPullParser parser) diff --git a/services/java/com/android/server/wm/DimAnimator.java b/services/java/com/android/server/wm/DimAnimator.java index b08c864..f9f9d1a 100644 --- a/services/java/com/android/server/wm/DimAnimator.java +++ b/services/java/com/android/server/wm/DimAnimator.java @@ -42,10 +42,17 @@ class DimAnimator { DimAnimator (SurfaceSession session) { if (mDimSurface == null) { try { - mDimSurface = new Surface(session, 0, + if (WindowManagerService.DEBUG_SURFACE_TRACE) { + mDimSurface = new WindowStateAnimator.SurfaceTrace(session, 0, "DimAnimator", -1, 16, 16, PixelFormat.OPAQUE, Surface.FX_SURFACE_DIM); + } else { + mDimSurface = new Surface(session, 0, + "DimAnimator", + -1, 16, 16, PixelFormat.OPAQUE, + Surface.FX_SURFACE_DIM); + } if (WindowManagerService.SHOW_TRANSACTIONS || WindowManagerService.SHOW_SURFACE_ALLOC) Slog.i(WindowManagerService.TAG, " DIM " + mDimSurface + ": CREATE"); diff --git a/services/java/com/android/server/wm/WindowAnimator.java b/services/java/com/android/server/wm/WindowAnimator.java index 7611a0f..f946f6c 100644 --- a/services/java/com/android/server/wm/WindowAnimator.java +++ b/services/java/com/android/server/wm/WindowAnimator.java @@ -75,6 +75,9 @@ public class WindowAnimator { DimAnimator mDimAnimator = null; DimAnimator.Parameters mDimParams = null; + static final int WALLPAPER_ACTION_PENDING = 1; + int mPendingActions; + WindowAnimator(final WindowManagerService service, final Context context, final WindowManagerPolicy policy) { mService = service; @@ -364,7 +367,9 @@ public class WindowAnimator { for (int i=unForceHiding.size()-1; i>=0; i--) { Animation a = mPolicy.createForceHideEnterAnimation(wallpaperInUnForceHiding); if (a != null) { - unForceHiding.get(i).setAnimation(a); + final WindowStateAnimator winAnimator = unForceHiding.get(i); + winAnimator.setAnimation(a); + winAnimator.mAnimationIsEntrance = true; } } } @@ -421,13 +426,16 @@ public class WindowAnimator { mWindowAnimationBackgroundColor = 0; updateWindowsAndWallpaperLocked(); + if ((mPendingLayoutChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER) != 0) { + mPendingActions |= WALLPAPER_ACTION_PENDING; + } if (mTokenMayBeDrawn) { testTokenMayBeDrawnLocked(); } } - void animate() { + synchronized void animate() { mPendingLayoutChanges = 0; mCurrentTime = SystemClock.uptimeMillis(); mBulkUpdateParams = 0; @@ -554,4 +562,8 @@ public class WindowAnimator { mAnimDh = animDh; } } + + synchronized void clearPendingActions() { + mPendingActions = 0; + } } diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index f698fbc..ff41899 100755 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -34,6 +34,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG; import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; import com.android.internal.app.IBatteryStats; +import com.android.internal.app.ShutdownThread; import com.android.internal.policy.PolicyManager; import com.android.internal.policy.impl.PhoneWindowManager; import com.android.internal.view.IInputContext; @@ -1629,9 +1630,7 @@ public class WindowManagerService extends IWindowManager.Stub "Found wallpaper activity: #" + i + "=" + w); foundW = w; foundI = i; - if (w == mWallpaperTarget && ((w.mAppToken != null - && w.mAppToken.mAppAnimator.animation != null) - || w.mWinAnimator.mAnimation != null)) { + if (w == mWallpaperTarget && w.mWinAnimator.isAnimating()) { // The current wallpaper target is animating, so we'll // look behind it for another possible target and figure // out what is going on below. @@ -6507,6 +6506,13 @@ public class WindowManagerService extends IWindowManager.Stub KeyEvent.KEYCODE_VOLUME_DOWN); mSafeMode = menuState > 0 || sState > 0 || dpadState > 0 || trackballState > 0 || volumeDownState > 0; + try { + if (SystemProperties.getInt(ShutdownThread.REBOOT_SAFEMODE_PROPERTY, 0) != 0) { + mSafeMode = true; + SystemProperties.set(ShutdownThread.REBOOT_SAFEMODE_PROPERTY, ""); + } + } catch (IllegalArgumentException e) { + } if (mSafeMode) { Log.i(TAG, "SAFE MODE ENABLED (menu=" + menuState + " s=" + sState + " dpad=" + dpadState + " trackball=" + trackballState + ")"); @@ -6618,6 +6624,7 @@ public class WindowManagerService extends IWindowManager.Stub public static final int SET_WALLPAPER_OFFSET = ANIMATOR_WHAT_OFFSET + 2; public static final int SET_DIM_PARAMETERS = ANIMATOR_WHAT_OFFSET + 3; public static final int SET_MOVE_ANIMATION = ANIMATOR_WHAT_OFFSET + 4; + public static final int CLEAR_PENDING_ACTIONS = ANIMATOR_WHAT_OFFSET + 5; private Session mLastReportedHold; @@ -7070,7 +7077,8 @@ public class WindowManagerService extends IWindowManager.Stub } if (doRequest) { - requestTraversalLocked(); + mH.sendEmptyMessage(CLEAR_PENDING_ACTIONS); + performLayoutAndPlaceSurfacesLocked(); } } break; @@ -7111,6 +7119,11 @@ public class WindowManagerService extends IWindowManager.Stub scheduleAnimationLocked(); break; } + + case CLEAR_PENDING_ACTIONS: { + mAnimator.clearPendingActions(); + break; + } } if (DEBUG_WINDOW_TRACE) { Slog.v(TAG, "handleMessage: exit"); diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java index 0cebee7..74e3304 100644 --- a/services/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/java/com/android/server/wm/WindowStateAnimator.java @@ -186,6 +186,7 @@ class WindowStateAnimator { if (mAnimation != null) { mAnimation.cancel(); mAnimation = null; + mLocalAnimating = false; destroySurfaceLocked(); } } @@ -262,9 +263,6 @@ class WindowStateAnimator { // If the display is frozen, and there is a pending animation, // clear it and make sure we run the cleanup code. mAnimating = true; - mLocalAnimating = true; - mAnimation.cancel(); - mAnimation = null; } if (!mAnimating && !mLocalAnimating) { @@ -878,11 +876,14 @@ class WindowStateAnimator { ": " + mWin.mShownFrame + ", alpha=" + mTransformation.getAlpha() + ", mShownAlpha=" + mShownAlpha); return; + } else if (mWin.mIsWallpaper && + (mAnimator.mPendingActions & WindowAnimator.WALLPAPER_ACTION_PENDING) != 0) { + return; } if (WindowManagerService.localLOGV) Slog.v( - TAG, "computeShownFrameLocked: " + this + - " not attached, mAlpha=" + mAlpha); + TAG, "computeShownFrameLocked: " + this + + " not attached, mAlpha=" + mAlpha); mWin.mShownFrame.set(mWin.mFrame); if (mWin.mXOffset != 0 || mWin.mYOffset != 0) { mWin.mShownFrame.offset(mWin.mXOffset, mWin.mYOffset); @@ -920,19 +921,19 @@ class WindowStateAnimator { mSurfaceH = height; } - if (mSurfaceX != w.mShownFrame.left - || mSurfaceY != w.mShownFrame.top) { + final float left = w.mShownFrame.left; + final float top = w.mShownFrame.top; + if (mSurfaceX != left || mSurfaceY != top) { try { if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w, - "POS " + w.mShownFrame.left - + ", " + w.mShownFrame.top, null); - mSurfaceX = w.mShownFrame.left; - mSurfaceY = w.mShownFrame.top; - mSurface.setPosition(w.mShownFrame.left, w.mShownFrame.top); + "POS " + left + ", " + top, null); + mSurfaceX = left; + mSurfaceY = top; + mSurface.setPosition(left, top); } catch (RuntimeException e) { Slog.w(TAG, "Error positioning surface of " + w - + " pos=(" + w.mShownFrame.left - + "," + w.mShownFrame.top + ")", e); + + " pos=(" + left + + "," + top + ")", e); if (!recoveringMemory) { mService.reclaimSomeSurfaceMemoryLocked(this, "position", true); } @@ -1177,12 +1178,7 @@ class WindowStateAnimator { // will do an animation to reveal it from behind the // starting window, so there is no need for it to also // be doing its own stuff. - if (mAnimation != null) { - mAnimation.cancel(); - mAnimation = null; - // Make sure we clean up the animation. - mAnimating = true; - } + clearAnimation(); mService.mFinishedStarting.add(mWin.mAppToken); mService.mH.sendEmptyMessage(H.FINISHED_STARTING); } @@ -1286,6 +1282,7 @@ class WindowStateAnimator { if (WindowManagerService.DEBUG_ANIM) Slog.v(TAG, "applyAnimation: win=" + this + " anim=" + anim + " attr=0x" + Integer.toHexString(attr) + + " a=" + a + " mAnimation=" + mAnimation + " isEntrance=" + isEntrance); if (a != null) { |
