Ejemplo n.º 1
0
 public static Map readMapFromParcel(Parcel in) {
   int flag = in.readInt();
   if (flag == EXIST_SEPARATOR) {
     return in.readHashMap(HashMap.class.getClassLoader());
   } else {
     return null;
   }
 }
Ejemplo n.º 2
0
  @Test
  public void testReadWriteMap() throws Exception {
    HashMap<String, String> original = new HashMap<String, String>();
    original.put("key", "value");
    parcel.writeMap(original);
    HashMap<String, String> rehydrated = parcel.readHashMap(null);

    assertEquals("value", rehydrated.get("key"));
  }
Ejemplo n.º 3
0
  public Presence(Parcel source) {
    mStatus = source.readInt();
    mStatusText = source.readString();
    mAvatarData = source.createByteArray();
    mAvatarType = source.readString();
    mClientType = source.readInt();
    // TODO - what ClassLoader should be passed to readMap?
    // TODO - switch to Bundle
    mExtendedInfo = source.readHashMap(null);

    // this may not exist for older persisted presence data
    if (source.dataAvail() > 0) mResource = source.readString();
  }
 public void readFromParcel(Parcel source) {
   geometryType = source.readInt();
   horizontalAlign = source.readInt();
   index = source.readInt();
   itemData = source.readHashMap(HashMap.class.getClassLoader());
   lineColor = source.readInt();
   lineWidth = source.readInt();
   mapItemClass = source.readString();
   offsetX = source.readInt();
   offsetY = source.readInt();
   symbol = source.readInt();
   verticalAlign = source.readInt();
   query = source.readString();
   mapPoints = source.readArrayList(MapPoint.class.getClassLoader());
   contents = source.readArrayList(MapItemContent.class.getClassLoader());
 }
        public boolean onTransact(int i, Parcel parcel, Parcel parcel1, int j)
            throws RemoteException
        {
            switch (i)
            {
            default:
                return super.onTransact(i, parcel, parcel1, j);

            case 1598968902: 
                parcel1.writeString("com.amazon.dcp.sso.IWebserviceCallback");
                return true;

            case 1: // '\001'
                parcel.enforceInterface("com.amazon.dcp.sso.IWebserviceCallback");
                onResponseReceived(parcel.readLong(), parcel.readHashMap(getClass().getClassLoader()), parcel.createByteArray());
                parcel1.writeNoException();
                return true;

            case 2: // '\002'
                parcel.enforceInterface("com.amazon.dcp.sso.IWebserviceCallback");
                onNetworkError();
                parcel1.writeNoException();
                return true;

            case 3: // '\003'
                parcel.enforceInterface("com.amazon.dcp.sso.IWebserviceCallback");
                onAuthenticationFailed();
                parcel1.writeNoException();
                return true;

            case 4: // '\004'
                parcel.enforceInterface("com.amazon.dcp.sso.IWebserviceCallback");
                onBadResponse();
                parcel1.writeNoException();
                return true;

            case 5: // '\005'
                parcel.enforceInterface("com.amazon.dcp.sso.IWebserviceCallback");
                onInvalidRequest();
                parcel1.writeNoException();
                return true;
            }
        }
  @Override
  public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
    switch (code) {
      case SCHEDULE_PAUSE_ACTIVITY_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          IBinder b = data.readStrongBinder();
          boolean finished = data.readInt() != 0;
          boolean userLeaving = data.readInt() != 0;
          int configChanges = data.readInt();
          schedulePauseActivity(b, finished, userLeaving, configChanges);
          return true;
        }

      case SCHEDULE_STOP_ACTIVITY_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          IBinder b = data.readStrongBinder();
          boolean show = data.readInt() != 0;
          int configChanges = data.readInt();
          scheduleStopActivity(b, show, configChanges);
          return true;
        }

      case SCHEDULE_WINDOW_VISIBILITY_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          IBinder b = data.readStrongBinder();
          boolean show = data.readInt() != 0;
          scheduleWindowVisibility(b, show);
          return true;
        }

      case SCHEDULE_SLEEPING_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          IBinder b = data.readStrongBinder();
          boolean sleeping = data.readInt() != 0;
          scheduleSleeping(b, sleeping);
          return true;
        }

      case SCHEDULE_RESUME_ACTIVITY_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          IBinder b = data.readStrongBinder();
          boolean isForward = data.readInt() != 0;
          scheduleResumeActivity(b, isForward);
          return true;
        }

      case SCHEDULE_SEND_RESULT_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          IBinder b = data.readStrongBinder();
          List<ResultInfo> ri = data.createTypedArrayList(ResultInfo.CREATOR);
          scheduleSendResult(b, ri);
          return true;
        }

      case SCHEDULE_LAUNCH_ACTIVITY_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          Intent intent = Intent.CREATOR.createFromParcel(data);
          IBinder b = data.readStrongBinder();
          int ident = data.readInt();
          ActivityInfo info = ActivityInfo.CREATOR.createFromParcel(data);
          Configuration curConfig = Configuration.CREATOR.createFromParcel(data);
          CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
          Bundle state = data.readBundle();
          List<ResultInfo> ri = data.createTypedArrayList(ResultInfo.CREATOR);
          List<Intent> pi = data.createTypedArrayList(Intent.CREATOR);
          boolean notResumed = data.readInt() != 0;
          boolean isForward = data.readInt() != 0;
          String profileName = data.readString();
          ParcelFileDescriptor profileFd = data.readInt() != 0 ? data.readFileDescriptor() : null;
          boolean autoStopProfiler = data.readInt() != 0;
          scheduleLaunchActivity(
              intent,
              b,
              ident,
              info,
              curConfig,
              compatInfo,
              state,
              ri,
              pi,
              notResumed,
              isForward,
              profileName,
              profileFd,
              autoStopProfiler);
          return true;
        }

      case SCHEDULE_RELAUNCH_ACTIVITY_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          IBinder b = data.readStrongBinder();
          List<ResultInfo> ri = data.createTypedArrayList(ResultInfo.CREATOR);
          List<Intent> pi = data.createTypedArrayList(Intent.CREATOR);
          int configChanges = data.readInt();
          boolean notResumed = data.readInt() != 0;
          Configuration config = null;
          if (data.readInt() != 0) {
            config = Configuration.CREATOR.createFromParcel(data);
          }
          scheduleRelaunchActivity(b, ri, pi, configChanges, notResumed, config);
          return true;
        }

      case SCHEDULE_NEW_INTENT_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          List<Intent> pi = data.createTypedArrayList(Intent.CREATOR);
          IBinder b = data.readStrongBinder();
          scheduleNewIntent(pi, b);
          return true;
        }

      case SCHEDULE_FINISH_ACTIVITY_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          IBinder b = data.readStrongBinder();
          boolean finishing = data.readInt() != 0;
          int configChanges = data.readInt();
          scheduleDestroyActivity(b, finishing, configChanges);
          return true;
        }

      case SCHEDULE_RECEIVER_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          Intent intent = Intent.CREATOR.createFromParcel(data);
          ActivityInfo info = ActivityInfo.CREATOR.createFromParcel(data);
          CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
          int resultCode = data.readInt();
          String resultData = data.readString();
          Bundle resultExtras = data.readBundle();
          boolean sync = data.readInt() != 0;
          scheduleReceiver(intent, info, compatInfo, resultCode, resultData, resultExtras, sync);
          return true;
        }

      case SCHEDULE_CREATE_SERVICE_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          IBinder token = data.readStrongBinder();
          ServiceInfo info = ServiceInfo.CREATOR.createFromParcel(data);
          CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
          scheduleCreateService(token, info, compatInfo);
          return true;
        }

      case SCHEDULE_BIND_SERVICE_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          IBinder token = data.readStrongBinder();
          Intent intent = Intent.CREATOR.createFromParcel(data);
          boolean rebind = data.readInt() != 0;
          scheduleBindService(token, intent, rebind);
          return true;
        }

      case SCHEDULE_UNBIND_SERVICE_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          IBinder token = data.readStrongBinder();
          Intent intent = Intent.CREATOR.createFromParcel(data);
          scheduleUnbindService(token, intent);
          return true;
        }

      case SCHEDULE_SERVICE_ARGS_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          IBinder token = data.readStrongBinder();
          boolean taskRemoved = data.readInt() != 0;
          int startId = data.readInt();
          int fl = data.readInt();
          Intent args;
          if (data.readInt() != 0) {
            args = Intent.CREATOR.createFromParcel(data);
          } else {
            args = null;
          }
          scheduleServiceArgs(token, taskRemoved, startId, fl, args);
          return true;
        }

      case SCHEDULE_STOP_SERVICE_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          IBinder token = data.readStrongBinder();
          scheduleStopService(token);
          return true;
        }

      case BIND_APPLICATION_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          String packageName = data.readString();
          ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data);
          List<ProviderInfo> providers = data.createTypedArrayList(ProviderInfo.CREATOR);
          ComponentName testName = (data.readInt() != 0) ? new ComponentName(data) : null;
          String profileName = data.readString();
          ParcelFileDescriptor profileFd = data.readInt() != 0 ? data.readFileDescriptor() : null;
          boolean autoStopProfiler = data.readInt() != 0;
          Bundle testArgs = data.readBundle();
          IBinder binder = data.readStrongBinder();
          IInstrumentationWatcher testWatcher = IInstrumentationWatcher.Stub.asInterface(binder);
          int testMode = data.readInt();
          boolean restrictedBackupMode = (data.readInt() != 0);
          boolean persistent = (data.readInt() != 0);
          Configuration config = Configuration.CREATOR.createFromParcel(data);
          CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
          HashMap<String, IBinder> services = data.readHashMap(null);
          Bundle coreSettings = data.readBundle();
          bindApplication(
              packageName,
              info,
              providers,
              testName,
              profileName,
              profileFd,
              autoStopProfiler,
              testArgs,
              testWatcher,
              testMode,
              restrictedBackupMode,
              persistent,
              config,
              compatInfo,
              services,
              coreSettings);
          return true;
        }

      case SCHEDULE_EXIT_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          scheduleExit();
          return true;
        }

      case SCHEDULE_SUICIDE_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          scheduleSuicide();
          return true;
        }

      case REQUEST_THUMBNAIL_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          IBinder b = data.readStrongBinder();
          requestThumbnail(b);
          return true;
        }

      case SCHEDULE_CONFIGURATION_CHANGED_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          Configuration config = Configuration.CREATOR.createFromParcel(data);
          scheduleConfigurationChanged(config);
          return true;
        }

      case UPDATE_TIME_ZONE_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          updateTimeZone();
          return true;
        }

      case CLEAR_DNS_CACHE_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          clearDnsCache();
          return true;
        }

      case SET_HTTP_PROXY_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          final String proxy = data.readString();
          final String port = data.readString();
          final String exclList = data.readString();
          setHttpProxy(proxy, port, exclList);
          return true;
        }

      case PROCESS_IN_BACKGROUND_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          processInBackground();
          return true;
        }

      case DUMP_SERVICE_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          ParcelFileDescriptor fd = data.readFileDescriptor();
          final IBinder service = data.readStrongBinder();
          final String[] args = data.readStringArray();
          if (fd != null) {
            dumpService(fd.getFileDescriptor(), service, args);
            try {
              fd.close();
            } catch (IOException e) {
            }
          }
          return true;
        }

      case SCHEDULE_REGISTERED_RECEIVER_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          IIntentReceiver receiver = IIntentReceiver.Stub.asInterface(data.readStrongBinder());
          Intent intent = Intent.CREATOR.createFromParcel(data);
          int resultCode = data.readInt();
          String dataStr = data.readString();
          Bundle extras = data.readBundle();
          boolean ordered = data.readInt() != 0;
          boolean sticky = data.readInt() != 0;
          scheduleRegisteredReceiver(
              receiver, intent, resultCode, dataStr, extras, ordered, sticky);
          return true;
        }

      case SCHEDULE_LOW_MEMORY_TRANSACTION:
        {
          scheduleLowMemory();
          return true;
        }

      case SCHEDULE_ACTIVITY_CONFIGURATION_CHANGED_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          IBinder b = data.readStrongBinder();
          scheduleActivityConfigurationChanged(b);
          return true;
        }

      case PROFILER_CONTROL_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          boolean start = data.readInt() != 0;
          int profileType = data.readInt();
          String path = data.readString();
          ParcelFileDescriptor fd = data.readInt() != 0 ? data.readFileDescriptor() : null;
          profilerControl(start, path, fd, profileType);
          return true;
        }

      case SET_SCHEDULING_GROUP_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          int group = data.readInt();
          setSchedulingGroup(group);
          return true;
        }

      case SCHEDULE_CREATE_BACKUP_AGENT_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          ApplicationInfo appInfo = ApplicationInfo.CREATOR.createFromParcel(data);
          CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
          int backupMode = data.readInt();
          scheduleCreateBackupAgent(appInfo, compatInfo, backupMode);
          return true;
        }

      case SCHEDULE_DESTROY_BACKUP_AGENT_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          ApplicationInfo appInfo = ApplicationInfo.CREATOR.createFromParcel(data);
          CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
          scheduleDestroyBackupAgent(appInfo, compatInfo);
          return true;
        }

      case GET_MEMORY_INFO_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          Debug.MemoryInfo mi = new Debug.MemoryInfo();
          getMemoryInfo(mi);
          reply.writeNoException();
          mi.writeToParcel(reply, 0);
          return true;
        }

      case DISPATCH_PACKAGE_BROADCAST_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          int cmd = data.readInt();
          String[] packages = data.readStringArray();
          dispatchPackageBroadcast(cmd, packages);
          return true;
        }

      case SCHEDULE_CRASH_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          String msg = data.readString();
          scheduleCrash(msg);
          return true;
        }

      case DUMP_HEAP_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          boolean managed = data.readInt() != 0;
          String path = data.readString();
          ParcelFileDescriptor fd = data.readInt() != 0 ? data.readFileDescriptor() : null;
          dumpHeap(managed, path, fd);
          return true;
        }

      case DUMP_ACTIVITY_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          ParcelFileDescriptor fd = data.readFileDescriptor();
          final IBinder activity = data.readStrongBinder();
          final String prefix = data.readString();
          final String[] args = data.readStringArray();
          if (fd != null) {
            dumpActivity(fd.getFileDescriptor(), activity, prefix, args);
            try {
              fd.close();
            } catch (IOException e) {
            }
          }
          return true;
        }

      case SET_CORE_SETTINGS_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          Bundle settings = data.readBundle();
          setCoreSettings(settings);
          return true;
        }

      case UPDATE_PACKAGE_COMPATIBILITY_INFO_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          String pkg = data.readString();
          CompatibilityInfo compat = CompatibilityInfo.CREATOR.createFromParcel(data);
          updatePackageCompatibilityInfo(pkg, compat);
          return true;
        }

      case SCHEDULE_TRIM_MEMORY_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          int level = data.readInt();
          scheduleTrimMemory(level);
          return true;
        }

      case DUMP_MEM_INFO_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          ParcelFileDescriptor fd = data.readFileDescriptor();
          boolean checkin = data.readInt() != 0;
          boolean all = data.readInt() != 0;
          String[] args = data.readStringArray();
          Debug.MemoryInfo mi = null;
          if (fd != null) {
            try {
              mi = dumpMemInfo(fd.getFileDescriptor(), checkin, all, args);
            } finally {
              try {
                fd.close();
              } catch (IOException e) {
                // swallowed, not propagated back to the caller
              }
            }
          }
          reply.writeNoException();
          mi.writeToParcel(reply, 0);
          return true;
        }

      case DUMP_GFX_INFO_TRANSACTION:
        {
          data.enforceInterface(IApplicationThread.descriptor);
          ParcelFileDescriptor fd = data.readFileDescriptor();
          String[] args = data.readStringArray();
          if (fd != null) {
            try {
              dumpGfxInfo(fd.getFileDescriptor(), args);
            } finally {
              try {
                fd.close();
              } catch (IOException e) {
                // swallowed, not propagated back to the caller
              }
            }
          }
          reply.writeNoException();
          return true;
        }
    }

    return super.onTransact(code, data, reply, flags);
  }