Jump to content

Turan Can

Members
  • Content Count

    63
  • Joined

  • Last visited

Posts posted by Turan Can


  1. Hello everyone,

     

    How do we constantly check whether there is a connection in a TCP/IP connection?

     

    windows sample, With what can I get android connection status? POSIX

     

    function TGateSocket.IsConnected: Boolean;
    var
      FDSet: Fd_Set;
      Tv: TimeVal;
      I: Integer;
    begin
      Result := False;

      FD_ZERO(FDSet);
      _FD_SET(SockId, FDSet);
      Tv.tv_sec := 0;
      Tv.tv_usec := 500;

    {$IFDEF MSWINDOWS}

      I := select(0, @FDSet, nil, nil, @Tv);

      if (I = SOCKET_ERROR) then
        Result := False

    else

          if recv(FSockId, FDSet, -1, 0)  = 0 then
            Result := False
          else
            Result := True;

    {$ENDIF}

    {$IFDEF POSIX}

    ??

    {$ENDIF}
    end;

     

     


  2. Thank you so much. It meets my need.

     

    I wonder. Android is ultimately held in memory. Doesn't this memory have a serial number?

     

    As far as I understand. if the user has root authority. it can change the imei numbers including androidid that you sent last.
    I need something like the unique identification key of the device or borad.


  3. Hello Dave,

     

    Thanks for the example.

    However, this only takes external hdd cards..

     

    Should I give my uses permission authorization?

     

    Is there a ready helper in Delphi android where we can get the class structure like this?

     

    https://developer.android.com/reference/android/os/storage/StorageManager

     

    c# xamarin

    public static String getSerialNumber() {
        String serialNumber;

        try {
            Class<?> c = Class.forName("android.os.SystemProperties");
            Method get = c.getMethod("get", String.class);

            serialNumber = (String) get.invoke(c, "gsm.sn1");
            if (serialNumber.equals(""))
                serialNumber = (String) get.invoke(c, "ril.serialnumber");
            if (serialNumber.equals(""))
                serialNumber = (String) get.invoke(c, "ro.serialno");
            if (serialNumber.equals(""))
                serialNumber = (String) get.invoke(c, "sys.serialnumber");
            if (serialNumber.equals(""))
                serialNumber = Build.SERIAL;

            // If none of the methods above worked
            if (serialNumber.equals(""))
                serialNumber = null;
        } catch (Exception e) {
            e.printStackTrace();
            serialNumber = null;
        }

        return serialNumber;
    }

     

    uses.jpg


  4. Hi,

    Windows hdd serial number function It works very successfully.

    Is there an example for Android?

     

    function GetHardDiskSerial(const DriveLetter: Char): string;

    var
      NotUsed, VolumeFlags, VolumeSerialNumber: DWORD;
      VolumeInfo: array [0 .. MAX_PATH] of Char;
    begin
      ZeroMemory(@VolumeInfo, SizeOf(VolumeInfo));
      GetVolumeInformation(PChar(DriveLetter + ':\'), nil, SizeOf(VolumeInfo), @VolumeSerialNumber, NotUsed, VolumeFlags, nil, 0);
      Result := Format('%8.8X', [VolumeSerialNumber]);
    end;

     

    "android.os.SystemProperties"

     


  5. David, I care about what you write.
    Is there anything wrong with this simple code?
    Is it normal to see the output differently in Windows and android?

    //win32 debug ch #8,#9,#$A

    //Android debug ch #10,\t,#012

     

    Remy, I know what you're saying. That's not the problem.

     

    procedure TForm1.Button10Click(Sender: TObject);
    const
      CTable: array [0 .. 2] of Byte = ($8, $9, $A);
    var
      Ch: Char;
      I: Integer;
    begin
      for I := 0 to High(CTable) do
        Ch := Char(CTable);

    //win32 debug ch #8,#9,#$A

    //Android debug ch #10,\t,#012
    end;


  6. No, this is not a tstringlist issue. this is officially chartable difference.
    You will see the difference when each char 0..to bla bla binds to numeric or character.
    char (8) > 10
    char (9) > t tab

    linux android

    This is a serious mistake.
    It affects thousands of delphi android users.
    Think a little. Your application on Android sends data to an application on windows.

     

    I'm not asking questions easily. I solve all my work myself. However, this made me drink "alcohol jack daniels oopss I put a reset on my brain."  for exactly 1 week 🙂

    Delphi needs to urgently a patch.
    You will either tell the project settings that you want to use the charset table, or it should offer two different char set options for windows and android.

     


  7. Probably the person I gave the job will not be able to do it but he insisted he said. 🙂 We will see it all together.
    Dear friends, I hope you have a good understanding of what I want.
    Look, this is such a big problem. Think a little, you will understand.

     

    Thanks for your nice words Dany,


    I try to give as much detail as I can.
    It seems that I will not be able to solve the problem here. I gave this problem as a "freelancer" as a job.

    250$ 🙂

    https://www.freelancer.com/projects/delphi/Android-Project-for-Delphi/payments/

     


  8. Hi Kas,

     

    It is no different from the jeans sample I made.

    your sample test.


    I added 2 pictures windows and android.

     

    This problem is actually a charset table problem. Possibly differences in windows charset and linux android char sets.

    For this problem, Delphi had to come up with a solution. Example: At the start of the project, I started to think that there should be a setting like setwindows charset table.

     

    So what is the source of the problem why I need this 🙂
    I use AES 256 bit and the same data should be the same in andorid and linux.

     

    https://github.com/Turan-Can/Delphi-Encryption-Compendium

     

    android.jpg

    windows.jpg


  9. Dear friends;

    First of all, thank you for your answers.


    There are two results in the picture.
    Is this true ? Do I need to use something different for the character table?

    I wrote a very simple code at the bottom. This will explain everything

     

    David and Atilla, this code will work

    Please run windows first and then android.
    Look into the list. I made it in the picture below.

     

    procedure TForm1.Button9Click(Sender: TObject);
    var
      Ch: Char;
      I: Integer;
      T: TStringList;
    begin
      T := TStringList.Create;
      for I := 0 to 300 - 1 do
      begin
        Ch := Char(I);
        T.Append(Ch);
      end;
    end;

     

    Char.jpg


  10. string xor

     

    win32 output

    #0#1#2#3#4#5#6#7#8#9#1#2#3#4#5#6

    android output

    #001#002#003#004#005#006#007#010'\t'#001#002#003#004#005#006#007

     

    function XorStr(Str1, Str2: String): String;
    var
      I: Integer;
      Ci:Char;
    begin
      for I := 0 to Length(Str1) - 1 do
      begin
        Ci := Char(Ord(Str1) xor Ord(Str2));
        Result := Result + Ci;
      end;
    end;

     

    procedure TForm1.Button7Click(Sender: TObject);
    var
      I, Len: Integer;
      S, T, D, Buff: string;
    begin

      S := '1234567891234567';
      T := '0000000000000000';
      D := XorStr(S, T);
    end;


  11. Dear David heffernan;

     

    first of all thank you for your answer.

    This code has been working on windows for years.

    I listened to you, I made a different example, but andorid has the same problem.
    My request from you. Please, I would be very happy if you first tested and respond accordingly.

    If I have a mistake, can you make a simple example?

    Please test it.

    Thank you.

     

    #001#002#003#004#005#006#007#010'\t'#001#002#003#004#005#006#007

     

    function XorUtf(Str1, Str2: UTF8String): UTF8String;
    var
      I: Integer;
      Ci:Char;
    begin
      for I := 0 to Length(Str1) - 1 do
      begin
        Ci := Char(Ord(Str1) xor Ord(Str2));
        Result := Result + Ci;
      end;
    end;

     

    procedure TForm1.Button7Click(Sender: TObject);
    var
      I, Len: Integer;
      S, T, D, Buff: UTF8String;
    begin
      Len := 16;

      SetLength(S, Len);
      SetLength(T, Len);
    //  SetLength(D, Len);

      S := '1234567891234567';
      T := '0000000000000000';
    D:=XorUtf(s,t);

    end;

     


  12. Hi,


    No one left here from the old great masters 🙂


    Windows is running smoothly.
    I think there is a very serious bug on Android.
    in trouble numbers. I did not see any problems in the alphabet, but I did not look at what the ascii is.


    Step to step output data
    1 xor 0 > #1
    2 xor 0 > #2
    3 xor 0 > #3
    4 xor 0 > #4
    5 xor 0 > #5
    6 xor 0 > #6
    7 xor 0 > #7
    //these two lines don't. instead "" gives it.
    8 xor 0 > #1 -- 8>#10 why.....
    9 xor 0 > #1 -- 9>'t'
    1 xor 0 > #1
    2 xor 0 > #2
    3 xor 0 > #3
    4 xor 0 > #4
    5 xor 0 > #5
    6 xor 0 > #6
    7 xor 0 > #7

     

    Sample code
    procedure TForm1.Button5Click(Sender: TObject);
    var
      I, Len: Integer;
      S, T, D, Buff: UTF8String;
    begin
      Len := 16;
      SetLength(S, Len);
      SetLength(T, Len);
      SetLength(D, Len);
      S := '1234567891234567';
      T := '0000000000000000';
      D := T;
      XORBuffers(S[1], T[1], Len, D[1]);
      // XORBuffers(S[0],T[0],Len,D[0]);
    end;

     

    procedure TForm1.XORBuffers(const Source1, Source2; Size: Integer; var Dest);
    var
      I: Integer;
      S, T,D:PByte;
    😄Byte;
      Buff: Binary;
    begin
      S := PByte(@Source1);
      T := PByte(@Source2);
      D := PByte(@Dest);
      for I := 0 to Size - 1 do
      begin
        C := Byte(S xor T);
        D := Byte(C);
      end;
      SetString(Buff, PAnsiChar(@D[0]), Size);
    end;

×